X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fplugins%2Fpppol2tp%2Fopenl2tp.c;fp=pppd%2Fplugins%2Fpppol2tp%2Fopenl2tp.c;h=940d2bc4e59e4682880b5badb0170c8c7f4c59ff;hp=2ba870716f62a3908f3b9098bdff4ac104e7c656;hb=ba7f7e053daae846a54a1d08d3d133a5f1266ace;hpb=76016e1b948b7d9675b4e0750d1f943d96d9523b diff --git a/pppd/plugins/pppol2tp/openl2tp.c b/pppd/plugins/pppol2tp/openl2tp.c index 2ba8707..940d2bc 100644 --- a/pppd/plugins/pppol2tp/openl2tp.c +++ b/pppd/plugins/pppol2tp/openl2tp.c @@ -29,17 +29,22 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include #include -#include +#include #include #include #include #include +#include #ifndef aligned_u64 @@ -71,7 +76,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. @@ -177,8 +184,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(); @@ -187,9 +198,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; @@ -225,7 +235,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; @@ -249,9 +259,6 @@ out: (*old_pppol2tp_ip_updown_hook)(tunnel_id, session_id, up); } - if (user_name != NULL) - free(user_name); - return; } @@ -273,14 +280,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 @@ -294,7 +303,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 }