From ffb10e7aac817158e6b14ddbefc917a4c3974b30 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sun, 19 Apr 2015 13:51:35 +0200 Subject: [PATCH] PPP, CCP, added receive and transmit chosen protocols in ccp_flags_set() (renamed ccp_set()) We need to know which methods were chosen when CCP is up, this used to be done using ccp_test() which we are in the process of removing. Using non-existing method 0 instead of -1 in CCP for unset method, allowing type change from s16_t to u8_t for method. --- src/include/netif/ppp/ccp.h | 2 +- src/include/netif/ppp/ppp_impl.h | 2 +- src/netif/ppp/ccp.c | 14 +++++++------- src/netif/ppp/ppp.c | 8 +++++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/include/netif/ppp/ccp.h b/src/include/netif/ppp/ccp.h index 4c9c88aa..654ff175 100644 --- a/src/include/netif/ppp/ccp.h +++ b/src/include/netif/ppp/ccp.h @@ -152,7 +152,7 @@ typedef struct ccp_options { #if DEFLATE_SUPPORT u_short deflate_size; /* lg(window size) for Deflate */ #endif /* DEFLATE_SUPPORT */ - short method; /* code for chosen compression method */ + u8_t method; /* code for chosen compression method */ } ccp_options; extern const struct protent ccp_protent; diff --git a/src/include/netif/ppp/ppp_impl.h b/src/include/netif/ppp/ppp_impl.h index 794c9984..480760a8 100644 --- a/src/include/netif/ppp/ppp_impl.h +++ b/src/include/netif/ppp/ppp_impl.h @@ -475,7 +475,7 @@ int netif_get_mtu(ppp_pcb *pcb); #if CCP_SUPPORT int ccp_test(ppp_pcb *pcb, u_char *opt_ptr, int opt_len, int for_transmit); -void ccp_flags_set(ppp_pcb *pcb, int isopen, int isup); +void ccp_set(ppp_pcb *pcb, u8_t isopen, u8_t isup, u8_t receive_method, u8_t transmit_method); int ccp_fatal_error(ppp_pcb *pcb); #endif /* CCP_SUPPORT */ diff --git a/src/netif/ppp/ccp.c b/src/netif/ppp/ccp.c index d1dfec17..2ac1cce5 100644 --- a/src/netif/ppp/ccp.c +++ b/src/netif/ppp/ccp.c @@ -420,7 +420,7 @@ static void ccp_open(ppp_pcb *pcb) { ccp_options *go = &pcb->ccp_gotoptions; if (f->state != PPP_FSM_OPENED) - ccp_flags_set(pcb, 1, 0); + ccp_set(pcb, 1, 0, 0, 0); /* * Find out which compressors the kernel supports before @@ -438,7 +438,7 @@ static void ccp_open(ppp_pcb *pcb) { */ static void ccp_close(ppp_pcb *pcb, const char *reason) { fsm *f = &pcb->ccp_fsm; - ccp_flags_set(pcb, 0, 0); + ccp_set(pcb, 0, 0, 0, 0); fsm_close(f, reason); } @@ -530,7 +530,7 @@ static void ccp_protrej(ppp_pcb *pcb) { ccp_options *go = &pcb->ccp_gotoptions; #endif /* MPPE_SUPPORT */ - ccp_flags_set(pcb, 0, 0); + ccp_set(pcb, 0, 0, 0, 0); fsm_lowerdown(f); #if MPPE_SUPPORT @@ -820,7 +820,7 @@ static void ccp_addci(fsm *f, u_char *p, int *lenp) { } #endif /* PREDICTOR_SUPPORT */ - go->method = (p > p0)? p0[0]: -1; + go->method = (p > p0)? p0[0]: 0; *lenp = p - p0; } @@ -1120,7 +1120,7 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) { len = *lenp; memset(ho, 0, sizeof(ccp_options)); - ho->method = (len > 0)? p[0]: -1; + ho->method = (len > 0)? p[0]: 0; while (len > 0) { newret = CONFACK; @@ -1459,7 +1459,7 @@ static void ccp_up(fsm *f) { ccp_options *ho = &pcb->ccp_hisoptions; char method1[64]; - ccp_flags_set(pcb, 1, 1); + ccp_set(pcb, 1, 1, go->method, ho->method); if (ccp_anycompress(go)) { if (ccp_anycompress(ho)) { if (go->method == ho->method) { @@ -1492,7 +1492,7 @@ static void ccp_down(fsm *f) { if (pcb->ccp_localstate & RACK_PENDING) UNTIMEOUT(ccp_rack_timeout, f); pcb->ccp_localstate = 0; - ccp_flags_set(pcb, 1, 0); + ccp_set(pcb, 1, 0, 0, 0); #if MPPE_SUPPORT if (go->mppe) { go->mppe = 0; diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 664d951f..488224cf 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -114,7 +114,7 @@ #endif /* EAP_SUPPORT */ #if CCP_SUPPORT #include "netif/ppp/ccp.h" -#endif /* EAP_SUPPORT */ +#endif /* CCP_SUPPORT */ #if ECP_SUPPORT #include "netif/ppp/ecp.h" #endif /* EAP_SUPPORT */ @@ -1153,14 +1153,16 @@ ccp_test(ppp_pcb *pcb, u_char *opt_ptr, int opt_len, int for_transmit) } /* - * ccp_flags_set - inform about the current state of CCP. + * ccp_set - inform about the current state of CCP. */ void -ccp_flags_set(ppp_pcb *pcb, int isopen, int isup) +ccp_set(ppp_pcb *pcb, u8_t isopen, u8_t isup, u8_t receive_method, u8_t transmit_method) { LWIP_UNUSED_ARG(pcb); LWIP_UNUSED_ARG(isopen); LWIP_UNUSED_ARG(isup); + LWIP_UNUSED_ARG(receive_method); + LWIP_UNUSED_ARG(transmit_method); } /*