X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fplugins%2Fpppol2tp%2Fopenl2tp.c;h=11600417afc7655708cb2e32ce0e78e59308de07;hp=85ff0b56cdc5b839382a2f970034419c6bcb7756;hb=HEAD;hpb=c58bf2e8023dd846683f09cb00e15d64143dac8c diff --git a/pppd/plugins/pppol2tp/openl2tp.c b/pppd/plugins/pppol2tp/openl2tp.c index 85ff0b5..1160041 100644 --- a/pppd/plugins/pppol2tp/openl2tp.c +++ b/pppd/plugins/pppol2tp/openl2tp.c @@ -23,21 +23,29 @@ #include #include #include -#include "pppd.h" -#include "pathnames.h" -#include "fsm.h" -#include "lcp.h" -#include "ccp.h" -#include "ipcp.h" + #include #include #include #include #include +#include #include #include #include #include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + #ifndef aligned_u64 /* should be defined in sys/types.h */ @@ -46,7 +54,6 @@ #include #include #include -#include #include #include @@ -59,7 +66,7 @@ extern void (*pppol2tp_send_accm_hook)(int tunnel_id, int session_id, uint32_t send_accm, uint32_t recv_accm); extern void (*pppol2tp_ip_updown_hook)(int tunnel_id, int session_id, int up); -const char pppd_version[] = VERSION; +const char pppd_version[] = PPPD_VERSION; static int openl2tp_fd = -1; @@ -68,7 +75,9 @@ static void (*old_pppol2tp_send_accm_hook)(int tunnel_id, int session_id, uint32_t recv_accm) = NULL; static void (*old_pppol2tp_ip_updown_hook)(int tunnel_id, int session_id, int up) = NULL; -static void (*old_multilink_join_hook)(void) = NULL; +#ifdef PPP_WITH_MULTILINK +static multilink_join_hook_fn *old_multilink_join_hook = NULL; +#endif /***************************************************************************** * OpenL2TP interface. @@ -174,8 +183,12 @@ static void openl2tp_ppp_updown_ind(int tunnel_id, int session_id, int up) uint16_t tid = tunnel_id; uint16_t sid = session_id; uint8_t state = up; - int unit = ifunit; - char *user_name = NULL; + int unit = 0; + char ifname[MAXNAMELEN]; + char user_name[MAXNAMELEN]; + + unit = ppp_ifunit(); + ppp_get_ifname(ifname, sizeof(ifname)); if (openl2tp_fd < 0) { result = openl2tp_client_create(); @@ -184,9 +197,8 @@ static void openl2tp_ppp_updown_ind(int tunnel_id, int session_id, int up) } } - if (peer_authname[0] != '\0') { - user_name = strdup(peer_authname); - } + if (!ppp_peer_authname(user_name, sizeof(user_name))) + user_name[0] = '\0'; msg->msg_signature = OPENL2TP_MSG_SIGNATURE; msg->msg_type = OPENL2TP_MSG_TYPE_PPP_UPDOWN_IND; @@ -222,7 +234,7 @@ static void openl2tp_ppp_updown_ind(int tunnel_id, int session_id, int up) memcpy(&tlv->tlv_value[0], ifname, tlv->tlv_len); msg->msg_len += sizeof(*tlv) + ALIGN32(tlv->tlv_len); - if (user_name != NULL) { + if (user_name[0] != '\0') { tlv = (void *) &msg->msg_data[msg->msg_len]; tlv->tlv_type = OPENL2TP_TLV_TYPE_PPP_USER_NAME; tlv->tlv_len = strlen(user_name) + 1; @@ -246,9 +258,6 @@ out: (*old_pppol2tp_ip_updown_hook)(tunnel_id, session_id, up); } - if (user_name != NULL) - free(user_name); - return; } @@ -270,14 +279,16 @@ out: * multilink bundle. *****************************************************************************/ +#ifdef PPP_WITH_MULTILINK static void openl2tp_multilink_join_ind(void) { - if (doing_multilink && !multilink_master) { + if (mp_on() && !mp_master()) { /* send event only if not master */ openl2tp_ppp_updown_ind(pppol2tp_tunnel_id, pppol2tp_session_id, 1); } } +#endif /***************************************************************************** * Application init @@ -291,7 +302,9 @@ void plugin_init(void) old_pppol2tp_ip_updown_hook = pppol2tp_ip_updown_hook; pppol2tp_ip_updown_hook = openl2tp_ppp_updown_ind; +#ifdef PPP_WITH_MULTILINK old_multilink_join_hook = multilink_join_hook; multilink_join_hook = openl2tp_multilink_join_ind; +#endif }