diff options
Diffstat (limited to 'accel-pptpd/ppp/ppp_ipcp.c')
-rw-r--r-- | accel-pptpd/ppp/ppp_ipcp.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/accel-pptpd/ppp/ppp_ipcp.c b/accel-pptpd/ppp/ppp_ipcp.c index f3c20a64..795cbc0e 100644 --- a/accel-pptpd/ppp/ppp_ipcp.c +++ b/accel-pptpd/ppp/ppp_ipcp.c @@ -31,6 +31,8 @@ static void send_conf_ack(struct ppp_fsm_t*); static void send_conf_nak(struct ppp_fsm_t*); static void send_conf_rej(struct ppp_fsm_t*); static void ipcp_recv(struct ppp_handler_t*); +static void send_term_req(struct ppp_fsm_t *fsm); +static void send_term_ack(struct ppp_fsm_t *fsm); static void ipcp_options_init(struct ppp_ipcp_t *ipcp) { @@ -77,7 +79,8 @@ static struct ppp_layer_data_t *ipcp_layer_init(struct ppp_t *ppp) ipcp->hnd.recv=ipcp_recv; ppp_register_unit_handler(ppp,&ipcp->hnd); - + + ipcp->fsm.proto = PPP_IPCP; ppp_fsm_init(&ipcp->fsm); ipcp->fsm.layer_up=ipcp_layer_up; @@ -86,6 +89,8 @@ static struct ppp_layer_data_t *ipcp_layer_init(struct ppp_t *ppp) ipcp->fsm.send_conf_ack=send_conf_ack; ipcp->fsm.send_conf_nak=send_conf_nak; ipcp->fsm.send_conf_rej=send_conf_rej; + ipcp->fsm.send_term_req=send_term_req; + ipcp->fsm.send_term_ack=send_term_ack; INIT_LIST_HEAD(&ipcp->options); INIT_LIST_HEAD(&ipcp->ropt_list); @@ -477,6 +482,36 @@ static int ipcp_recv_conf_ack(struct ppp_ipcp_t *ipcp,uint8_t *data,int size) return res; } +static void send_term_req(struct ppp_fsm_t *fsm) +{ + struct ppp_ipcp_t *ipcp=container_of(fsm,typeof(*ipcp),fsm); + struct ipcp_hdr_t hdr = { + .proto = htons(PPP_IPCP), + .code = TERMREQ, + .id = ++ipcp->fsm.id, + .len = htons(4), + }; + + log_ppp_debug("send [IPCP TermReq id=%i \"\"]\n",hdr.id); + + ppp_unit_send(ipcp->ppp, &hdr, 6); +} + +static void send_term_ack(struct ppp_fsm_t *fsm) +{ + struct ppp_ipcp_t *ipcp=container_of(fsm,typeof(*ipcp),fsm); + struct ipcp_hdr_t hdr = { + .proto = htons(PPP_IPCP), + .code = TERMACK, + .id = ipcp->fsm.recv_id, + .len = htons(4), + }; + + log_ppp_debug("send [IPCP TermAck id=%i \"\"]\n", hdr.id); + + ppp_unit_send(ipcp->ppp, &hdr, 6); +} + static void ipcp_recv(struct ppp_handler_t*h) { struct ipcp_hdr_t *hdr; @@ -541,17 +576,18 @@ static void ipcp_recv(struct ppp_handler_t*h) ppp_fsm_recv_conf_rej(&ipcp->fsm); break; case TERMREQ: - term_msg=_strndup((char*)(hdr+1),ntohs(hdr->len)); + term_msg=_strndup((char*)(hdr+1),ntohs(hdr->len) - 4); log_ppp_debug("recv [IPCP TermReq id=%x \"%s\"]\n",hdr->id,term_msg); _free(term_msg); ppp_fsm_recv_term_req(&ipcp->fsm); ppp_terminate(ipcp->ppp, 0); break; case TERMACK: - term_msg=_strndup((char*)(hdr+1),ntohs(hdr->len)); + term_msg=_strndup((char*)(hdr+1),ntohs(hdr->len) - 4); log_ppp_debug("recv [IPCP TermAck id=%x \"%s\"]\n",hdr->id,term_msg); _free(term_msg); ppp_fsm_recv_term_ack(&ipcp->fsm); + ppp_terminate(ipcp->ppp, 0); break; case CODEREJ: log_ppp_debug("recv [IPCP CodeRej id=%x]\n",hdr->id); |