--- embedaddon/mpd/src/pptp_ctrl.c 2013/07/22 08:44:29 1.1.1.2 +++ embedaddon/mpd/src/pptp_ctrl.c 2021/03/17 00:39:23 1.1.1.3 @@ -63,17 +63,6 @@ #define PPTP_FIND_CHAN_PNS_CID 3 /* match field vs. PNS cid */ #define PPTP_FIND_CHAN_PAC_CID 4 /* match field vs. PAC cid */ - /* Total info about a message type (except field layout) */ - struct pptpmsginfo { - const char *name; /* name for this message type */ - void (*handler)(); /* message handler function */ - u_char isReply; /* this is always a reply message */ - u_char length; /* length of message (sans header) */ - u_short states; /* states which admit this message */ - struct pptpchanid match; /* how to find corresponding channel */ - struct pptpreqrep reqrep; /* what kind of reply we expect */ - }; - typedef const struct pptpmsginfo *PptpMsgInfo; /* Receive window size XXX */ #define PPTP_RECV_WIN 16 @@ -135,7 +124,20 @@ char peer_name[MAXHOSTNAMELEN]; /* remote hostname */ }; typedef struct pptpctrl *PptpCtrl; + typedef void (*PptpHandler)(PptpCtrl, void *); + /* Total info about a message type (except field layout) */ + struct pptpmsginfo { + const char *name; /* name for this message type */ + PptpHandler handler; /* message handler function */ + u_char isReply; /* this is always a reply message */ + u_char length; /* length of message (sans header) */ + u_short states; /* states which admit this message */ + struct pptpchanid match; /* how to find corresponding channel */ + struct pptpreqrep reqrep; /* what kind of reply we expect */ + }; + typedef const struct pptpmsginfo *PptpMsgInfo; + struct pptplis { struct u_addr self_addr; /* local IP address */ in_port_t self_port; @@ -149,7 +151,7 @@ /* Our physical channel ID */ #define PHYS_CHAN(ch) (((ch)->ctrl->id << 16) | (ch)->id) - int PptpsStat(Context ctx, int ac, char *av[], void *arg); + int PptpsStat(Context ctx, int ac, const char *const av[], const void *arg); /* * INTERNAL FUNCTIONS @@ -303,96 +305,97 @@ static const struct pptpmsginfo gPptpMsgInfo[PPTP_MAX_CTRL_TYPE] = { { "PptpMsgHead", NULL, /* placeholder */ FALSE, sizeof(struct pptpMsgHead), + 0, { 0, 0, NULL, NULL }, { 0, 0, 0 }, }, - { "StartCtrlConnRequest", PptpStartCtrlConnRequest, + { "StartCtrlConnRequest", (PptpHandler) PptpStartCtrlConnRequest, FALSE, sizeof(struct pptpStartCtrlConnRequest), CL(IDLE), - { 0, 0 }, /* no associated channel */ + { 0, 0, NULL, NULL }, /* no associated channel */ { PPTP_StartCtrlConnReply, TRUE, PPTP_DFL_REPLY_TIME }, }, - { "StartCtrlConnReply", PptpStartCtrlConnReply, + { "StartCtrlConnReply", (PptpHandler) PptpStartCtrlConnReply, TRUE, sizeof(struct pptpStartCtrlConnReply), CL(WAIT_CTL_REPLY), - { 0, 0 }, /* no associated channel */ - { 0 }, /* no reply expected */ + { 0, 0, NULL, NULL }, /* no associated channel */ + { 0, 0, 0 }, /* no reply expected */ }, - { "StopCtrlConnRequest", PptpStopCtrlConnRequest, + { "StopCtrlConnRequest", (PptpHandler) PptpStopCtrlConnRequest, FALSE, sizeof(struct pptpStopCtrlConnRequest), CL(WAIT_CTL_REPLY)|CL(WAIT_STOP_REPLY)|CL(ESTABLISHED), - { 0, 0 }, /* no associated channel */ + { 0, 0, NULL, NULL }, /* no associated channel */ { PPTP_StopCtrlConnReply, TRUE, PPTP_STOPCCR_REPLY_TIME }, }, - { "StopCtrlConnReply", PptpStopCtrlConnReply, + { "StopCtrlConnReply", (PptpHandler) PptpStopCtrlConnReply, TRUE, sizeof(struct pptpStopCtrlConnReply), CL(WAIT_STOP_REPLY), - { 0, 0 }, /* no associated channel */ - { 0 }, /* no reply expected */ + { 0, 0, NULL, NULL }, /* no associated channel */ + { 0, 0, 0 }, /* no reply expected */ }, - { "EchoRequest", PptpEchoRequest, + { "EchoRequest", (PptpHandler) PptpEchoRequest, FALSE, sizeof(struct pptpEchoRequest), CL(ESTABLISHED), - { 0, 0 }, /* no associated channel */ + { 0, 0, NULL, NULL }, /* no associated channel */ { PPTP_EchoReply, TRUE, PPTP_DFL_REPLY_TIME }, }, - { "EchoReply", PptpEchoReply, + { "EchoReply", (PptpHandler) PptpEchoReply, TRUE, sizeof(struct pptpEchoReply), CL(ESTABLISHED), - { 0, 0 }, /* no associated channel */ - { 0 }, /* no reply expected */ + { 0, 0, NULL, NULL }, /* no associated channel */ + { 0, 0, 0 }, /* no reply expected */ }, - { "OutCallRequest", PptpOutCallRequest, + { "OutCallRequest", (PptpHandler) PptpOutCallRequest, FALSE, sizeof(struct pptpOutCallRequest), CL(ESTABLISHED), { 0, PPTP_FIND_CHAN_MY_CID, NULL, "cid" }, { PPTP_OutCallReply, TRUE, PPTP_OUTCALLREQ_REPLY_TIME }, }, - { "OutCallReply", PptpOutCallReply, + { "OutCallReply", (PptpHandler) PptpOutCallReply, TRUE, sizeof(struct pptpOutCallReply), CH(WAIT_OUT_REPLY), { PPTP_FIND_CHAN_MY_CID, PPTP_FIND_CHAN_MY_CID, "peerCid", "cid" }, - { 0 }, /* no reply expected */ + { 0, 0, 0 }, /* no reply expected */ }, - { "InCallRequest", PptpInCallRequest, + { "InCallRequest", (PptpHandler) PptpInCallRequest, FALSE, sizeof(struct pptpInCallRequest), CL(ESTABLISHED), { 0, PPTP_FIND_CHAN_MY_CID, NULL, "cid" }, { PPTP_InCallReply, FALSE, PPTP_DFL_REPLY_TIME }, }, - { "InCallReply", PptpInCallReply, + { "InCallReply", (PptpHandler) PptpInCallReply, TRUE, sizeof(struct pptpInCallReply), CH(WAIT_IN_REPLY), { PPTP_FIND_CHAN_MY_CID, PPTP_FIND_CHAN_MY_CID, "peerCid", "cid" }, { PPTP_InCallConn, FALSE, PPTP_INCALLREP_REPLY_TIME }, }, - { "InCallConn", PptpInCallConn, + { "InCallConn", (PptpHandler) PptpInCallConn, TRUE, sizeof(struct pptpInCallConn), CH(WAIT_CONNECT), { PPTP_FIND_CHAN_MY_CID, PPTP_FIND_CHAN_PEER_CID, "peerCid", "peerCid" }, - { 0 }, /* no reply expected */ + { 0, 0, 0 }, /* no reply expected */ }, - { "CallClearRequest", PptpCallClearRequest, + { "CallClearRequest", (PptpHandler) PptpCallClearRequest, FALSE, sizeof(struct pptpCallClearRequest), CH(WAIT_IN_REPLY)|CH(WAIT_ANSWER)|CH(ESTABLISHED), { PPTP_FIND_CHAN_PNS_CID, PPTP_FIND_CHAN_PNS_CID, "cid", "cid" }, { PPTP_CallDiscNotify, TRUE, PPTP_DFL_REPLY_TIME }, }, - { "CallDiscNotify", PptpCallDiscNotify, + { "CallDiscNotify", (PptpHandler) PptpCallDiscNotify, FALSE, sizeof(struct pptpCallDiscNotify), CH(WAIT_OUT_REPLY)|CH(WAIT_CONNECT)|CH(WAIT_DISCONNECT)|CH(ESTABLISHED), { PPTP_FIND_CHAN_PAC_CID, PPTP_FIND_CHAN_PAC_CID, "cid", "cid" }, - { 0 }, /* no reply expected */ + { 0, 0, 0 }, /* no reply expected */ }, - { "WanErrorNotify", PptpWanErrorNotify, + { "WanErrorNotify", (PptpHandler) PptpWanErrorNotify, FALSE, sizeof(struct pptpWanErrorNotify), CH(ESTABLISHED), { PPTP_FIND_CHAN_PNS_CID, PPTP_FIND_CHAN_PNS_CID, "cid", "cid" }, - { 0 }, /* no reply expected */ + { 0, 0, 0 }, /* no reply expected */ }, - { "SetLinkInfo", PptpSetLinkInfo, + { "SetLinkInfo", (PptpHandler) PptpSetLinkInfo, FALSE, sizeof(struct pptpSetLinkInfo), CH(ESTABLISHED), { PPTP_FIND_CHAN_PAC_CID, PPTP_FIND_CHAN_PAC_CID, "cid", "cid" }, - { 0 }, /* no reply expected */ + { 0, 0, 0 }, /* no reply expected */ }, }; @@ -542,13 +545,13 @@ PptpCtrlListen(struct u_addr *ip, in_port_t port) /* See if we're already have a listener matching this address and port */ for (k = 0; k < gNumPptpLis; k++) { - PptpLis const l = gPptpLis[k]; + PptpLis const m = gPptpLis[k]; - if (l != NULL - && (!u_addrcompare (&l->self_addr, ip)) - && l->self_port == port) { - l->ref++; - return(l); + if (m != NULL + && (!u_addrcompare (&m->self_addr, ip)) + && m->self_port == port) { + m->ref++; + return(m); } } @@ -623,6 +626,7 @@ PptpCtrlListenRetry(int type, void *cookie) { PptpLis const l = (PptpLis)cookie; + (void)type; if ((l->sock = TcpGetListenPort(&l->self_addr, l->self_port, FALSE)) < 0) { EventRegister(&l->retry, EVENT_TIMEOUT, PPTP_LISTEN_RETRY * 1000, 0, PptpCtrlListenRetry, l); @@ -805,6 +809,7 @@ PptpCtrlListenEvent(int type, void *cookie) char buf[48], buf2[48]; socklen_t addrLen; + (void)type; /* Accept connection */ if ((sock = TcpAcceptConnection(l->sock, &peerst, FALSE)) < 0) return; @@ -851,6 +856,8 @@ PptpCtrlConnEvent(int type, void *cookie) socklen_t addrLen = sizeof(addr); char buf[48]; + (void)type; + /* Get event */ assert(c->state == PPTP_CTRL_ST_IDLE); @@ -965,6 +972,8 @@ PptpCtrlReadCtrl(int type, void *cookie) PptpMsgHead const hdr = &c->frame.hdr; int nread; + (void)type; + /* Figure how much to read and read it */ nread = (c->flen < sizeof(*hdr) ? sizeof(*hdr) : hdr->length) - c->flen; if ((nread = read(c->csock, c->frame.buf + c->flen, nread)) <= 0) { @@ -1194,15 +1203,15 @@ PptpCtrlGetCtrl(int orig, struct u_addr *self_addr, if (orig) { /* See if we're already have a control block matching this address and port */ for (k = 0; k < gNumPptpCtrl; k++) { - PptpCtrl const c = gPptpCtrl[k]; + PptpCtrl const d = gPptpCtrl[k]; - if (c != NULL - && (c->active_sessions < gPPTPtunlimit) - && (u_addrcompare(&c->peer_addr, peer_addr) == 0) - && (c->peer_port == peer_port || c->orig != orig) + if (d != NULL + && (d->active_sessions < gPPTPtunlimit) + && (u_addrcompare(&d->peer_addr, peer_addr) == 0) + && (d->peer_port == peer_port || d->orig != orig) && (u_addrempty(self_addr) || - (u_addrcompare(&c->self_addr, self_addr) == 0))) { - return(c); + (u_addrcompare(&d->self_addr, self_addr) == 0))) { + return(d); } } } @@ -2098,6 +2107,7 @@ PptpStopCtrlConnRequest(PptpCtrl c, struct pptpStopCtr static void PptpStopCtrlConnReply(PptpCtrl c, struct pptpStopCtrlConnReply *rep) { + (void)rep; PptpCtrlKillCtrl(c); } @@ -2168,8 +2178,8 @@ PptpOutCallRequest(PptpCtrl c, struct pptpOutCallReque /* Ask link layer about making the outgoing call */ PptpCtrlInitCinfo(ch, &cinfo); - linfo = (*gGetOutLink)(&cinfo, &c->self_addr, &c->peer_addr, c->peer_port, req->bearType, - req->frameType, req->minBps, req->maxBps, calledNum, subAddress); + linfo = (*gGetOutLink)(&cinfo, &c->self_addr, &c->peer_addr, c->peer_port, + calledNum); if (linfo.cookie == NULL) goto denied; @@ -2281,7 +2291,7 @@ PptpInCallRequest(PptpCtrl c, struct pptpInCallRequest linfo.cancel = NULL; if (gGetInLink) linfo = (*gGetInLink)(&cinfo, &c->self_addr, &c->peer_addr, c->peer_port, - req->bearType, callingNum, calledNum, subAddress); + callingNum, calledNum); ch->linfo = linfo; if (linfo.cookie == NULL) { Log(LG_PHYS2, ("pptp%d: incoming call request denied", c->id)); @@ -2368,6 +2378,7 @@ PptpCallClearRequest(PptpChan ch, struct pptpCallClear struct pptpCallDiscNotify notify; PptpCtrl const c = ch->ctrl; + (void)req; if (PPTP_CHAN_IS_PNS(ch)) { Log(LG_PHYS2, ("pptp%d-%d: got %s, but we are PNS for this call", c->id, ch->id, gPptpMsgInfo[PPTP_CallClearRequest].name)); @@ -2407,6 +2418,7 @@ PptpWanErrorNotify(PptpChan ch, struct pptpWanErrorNot { PptpCtrl const c = ch->ctrl; + (void)notif; Log(LG_PHYS2, ("pptp%d-%d: ignoring %s", c->id, ch->id, gPptpMsgInfo[PPTP_WanErrorNotify].name)); } @@ -2433,10 +2445,14 @@ PptpSetLinkInfo(PptpChan ch, struct pptpSetLinkInfo *i */ int -PptpsStat(Context ctx, int ac, char *av[], void *arg) +PptpsStat(Context ctx, int ac, const char *const av[], const void *arg) { int k; char buf1[48], buf2[48]; + + (void)ac; + (void)av; + (void)arg; Printf("Active PPTP tunnels:\r\n"); for (k = 0; k < gNumPptpCtrl; k++) {