--- embedaddon/mpd/src/l2tp.c 2016/11/01 09:56:12 1.1.1.3 +++ embedaddon/mpd/src/l2tp.c 2021/03/17 00:39:23 1.1.1.4 @@ -144,7 +144,7 @@ static void L2tpNodeUpdate(Link l); static int L2tpListen(Link l); static void L2tpUnListen(Link l); - static int L2tpSetCommand(Context ctx, int ac, char *av[], void *arg); + static int L2tpSetCommand(Context ctx, int ac, const char *const av[], const void *arg); /* L2TP control callbacks */ static ppp_l2tp_ctrl_connected_t ppp_l2tp_ctrl_connected_cb; @@ -220,14 +220,14 @@ L2tpSetCommand, NULL, 2, (void *) SET_ENABLE }, { "disable [opt ...]", "Disable option", L2tpSetCommand, NULL, 2, (void *) SET_DISABLE }, - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; /* * INTERNAL VARIABLES */ - static struct confinfo gConfList[] = { + static const struct confinfo gConfList[] = { { 0, L2TP_CONF_OUTCALL, "outcall" }, { 0, L2TP_CONF_HIDDEN, "hidden" }, { 0, L2TP_CONF_LENGTH, "length" }, @@ -236,13 +236,10 @@ { 0, 0, NULL }, }; -int L2tpListenUpdateSheduled = 0; -struct pppTimer L2tpListenUpdateTimer; +static struct ghash *gL2tpServers; +static struct ghash *gL2tpTuns; +static int one = 1; -struct ghash *gL2tpServers; -struct ghash *gL2tpTuns; -int one = 1; - /* * L2tpTInit() */ @@ -587,7 +584,7 @@ L2tpOpen(Link l) goto fail; } - if (!u_addrempty(&tun->self_addr)) { + if (!u_addrempty(&tun->self_addr) || tun->self_port != 0) { /* Bind socket to a new port */ u_addrtosockaddr(&tun->self_addr,tun->self_port,&sas); if (NgSendMsg(csock, namebuf, NGM_KSOCKET_COOKIE, @@ -860,6 +857,8 @@ L2tpPeerMacAddr(Link l, void *buf, size_t buf_len) { L2tpInfo const l2tp = (L2tpInfo) l->info; + if (buf_len < 18) + return 1; if (l2tp->tun && l2tp->tun->peer_iface[0]) { ether_ntoa_r((struct ether_addr *)l2tp->tun->peer_mac_addr, buf); return (0); @@ -1057,6 +1056,7 @@ ppp_l2tp_ctrl_terminated_cb(struct ppp_l2tp_ctrl *ctrl struct l2tp_tun *tun = ppp_l2tp_ctrl_get_cookie(ctrl); int k; + (void)result; Log(LG_PHYS, ("L2TP: Control connection %p terminated: %d (%s)", ctrl, error, errmsg)); @@ -1190,9 +1190,9 @@ ppp_l2tp_initiated_cb(struct ppp_l2tp_ctrl *ctrl, pi->tun = tun; tun->active_sessions++; pi->sess = sess; - if (ptrs->callingnum && ptrs->callingnum->number) + if (ptrs->callingnum) strlcpy(pi->callingnum, ptrs->callingnum->number, sizeof(pi->callingnum)); - if (ptrs->callednum && ptrs->callednum->number) + if (ptrs->callednum) strlcpy(pi->callednum, ptrs->callednum->number, sizeof(pi->callednum)); *include_length = (Enabled(&pi->conf.options, L2TP_CONF_LENGTH)?1:0); @@ -1389,6 +1389,7 @@ L2tpServerEvent(int type, void *arg) u_int16_t win; int k; + (void)type; /* Allocate buffer */ buf = Malloc(MB_PHYS, bufsize); @@ -1722,7 +1723,7 @@ L2tpNodeUpdate(Link l) */ static int -L2tpSetCommand(Context ctx, int ac, char *av[], void *arg) +L2tpSetCommand(Context ctx, int ac, const char *const av[], const void *arg) { L2tpInfo const l2tp = (L2tpInfo) ctx->lnk->info; char **fqdn_peer_addr = &l2tp->conf.fqdn_peer_addr; @@ -1802,11 +1803,15 @@ L2tpSetCommand(Context ctx, int ac, char *av[], void * */ int -L2tpsStat(Context ctx, int ac, char *av[], void *arg) +L2tpsStat(Context ctx, int ac, const char *const av[], const void *arg) { struct l2tp_tun *tun; struct ghash_walk walk; char buf1[64], buf2[64], buf3[64]; + + (void)ac; + (void)av; + (void)arg; Printf("Active L2TP tunnels:\r\n"); ghash_walk_init(gL2tpTuns, &walk);