diff --git a/src/include/netif/ppp/ipcp.h b/src/include/netif/ppp/ipcp.h index 2fb58c46..46805b4f 100644 --- a/src/include/netif/ppp/ipcp.h +++ b/src/include/netif/ppp/ipcp.h @@ -52,7 +52,9 @@ * Options. */ #define CI_ADDRS 1 /* IP Addresses */ +#if VJ_SUPPORT #define CI_COMPRESSTYPE 2 /* Compression Type */ +#endif /* VJ_SUPPORT */ #define CI_ADDR 3 #define CI_MS_DNS1 129 /* Primary DNS value */ @@ -60,6 +62,7 @@ #define CI_MS_DNS2 131 /* Secondary DNS value */ #define CI_MS_WINS2 132 /* Secondary WINS value */ +#if VJ_SUPPORT #define MAX_STATES 16 /* from slcompress.h */ #define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */ @@ -70,6 +73,7 @@ #define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/ #define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */ /* compression option*/ +#endif /* VJ_SUPPORT */ typedef struct ipcp_options { unsigned int neg_addr :1; /* Negotiate IP Address? */ @@ -80,21 +84,27 @@ typedef struct ipcp_options { unsigned int replace_default_route :1; /* Replace default route through interface? */ #endif /* UNUSED */ unsigned int proxy_arp :1; /* Make proxy ARP entry for peer? */ +#if VJ_SUPPORT unsigned int neg_vj :1; /* Van Jacobson Compression? */ unsigned int old_vj :1; /* use old (short) form of VJ option? */ + unsigned int cflag :1; +#else + unsigned int :3; /* 3 bits of padding */ +#endif /* VJ_SUPPORT */ unsigned int accept_local :1; /* accept peer's value for ouraddr */ unsigned int accept_remote :1; /* accept peer's value for hisaddr */ unsigned int req_dns1 :1; /* Ask peer to send primary DNS address? */ unsigned int req_dns2 :1; /* Ask peer to send secondary DNS address? */ - unsigned int cflag :1; unsigned int :5; /* 3 bits of padding to round out to 16 bits */ u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */ u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */ u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ +#if VJ_SUPPORT u16_t vj_protocol; /* protocol value to use in VJ option */ u8_t maxslotindex; /* values for RFC1332 VJ compression neg. */ +#endif /* VJ_SUPPORT */ } ipcp_options; #if 0 /* UNUSED, already defined by lwIP */ diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index bdafec61..49ff3805 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -615,24 +615,28 @@ static void ipcp_init(ppp_pcb *pcb) { memset(ao, 0, sizeof(*ao)); wo->neg_addr = wo->old_addrs = 1; +#if VJ_SUPPORT wo->neg_vj = 1; wo->vj_protocol = IPCP_VJ_COMP; wo->maxslotindex = MAX_STATES - 1; /* really max index */ wo->cflag = 1; +#endif /* VJ_SUPPORT */ #if 0 /* UNUSED */ /* wanting default route by default */ wo->default_route = 1; #endif /* UNUSED */ + ao->neg_addr = ao->old_addrs = 1; +#if VJ_SUPPORT /* max slots and slot-id compression are currently hardwired in */ /* ppp_if.c to 16 and 1, this needs to be changed (among other */ /* things) gmc */ - ao->neg_addr = ao->old_addrs = 1; ao->neg_vj = 1; ao->maxslotindex = MAX_STATES - 1; ao->cflag = 1; +#endif /* #if VJ_SUPPORT */ #if 0 /* UNUSED */ /* @@ -748,11 +752,15 @@ static void ipcp_resetci(fsm *f) { static int ipcp_cilen(fsm *f) { ppp_pcb *pcb = f->pcb; ipcp_options *go = &pcb->ipcp_gotoptions; +#if VJ_SUPPORT ipcp_options *wo = &pcb->ipcp_wantoptions; +#endif /* VJ_SUPPORT */ ipcp_options *ho = &pcb->ipcp_hisoptions; #define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0) +#if VJ_SUPPORT #define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) +#endif /* VJ_SUPPORT */ #define LENCIADDR(neg) (neg ? CILEN_ADDR : 0) #define LENCIDNS(neg) LENCIADDR(neg) #define LENCIWINS(neg) LENCIADDR(neg) @@ -763,6 +771,8 @@ static int ipcp_cilen(fsm *f) { */ if (go->neg_addr && go->old_addrs && !ho->neg_addr && ho->old_addrs) go->neg_addr = 0; + +#if VJ_SUPPORT if (wo->neg_vj && !go->neg_vj && !go->old_vj) { /* try an older style of VJ negotiation */ /* use the old style only if the peer did */ @@ -772,9 +782,12 @@ static int ipcp_cilen(fsm *f) { go->vj_protocol = ho->vj_protocol; } } +#endif /* VJ_SUPPORT */ return (LENCIADDRS(!go->neg_addr && go->old_addrs) + +#if VJ_SUPPORT LENCIVJ(go->neg_vj, go->old_vj) + +#endif /* VJ_SUPPORT */ LENCIADDR(go->neg_addr) + LENCIDNS(go->req_dns1) + LENCIDNS(go->req_dns2) + @@ -807,6 +820,7 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { go->old_addrs = 0; \ } +#if VJ_SUPPORT #define ADDCIVJ(opt, neg, val, old, maxslotindex, cflag) \ if (neg) { \ int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ @@ -822,6 +836,7 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { } else \ neg = 0; \ } +#endif /* VJ_SUPPORT */ #define ADDCIADDR(opt, neg, val) \ if (neg) { \ @@ -865,8 +880,10 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { ADDCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr, go->hisaddr); +#if VJ_SUPPORT ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, go->maxslotindex, go->cflag); +#endif /* VJ_SUPPORT */ ADDCIADDR(CI_ADDR, go->neg_addr, go->ouraddr); @@ -893,9 +910,12 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { static int ipcp_ackci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; ipcp_options *go = &pcb->ipcp_gotoptions; - u_short cilen, citype, cishort; + u_short cilen, citype; u32_t cilong; +#if VJ_SUPPORT + u_short cishort; u_char cimaxslotindex, cicflag; +#endif /* VJ_SUPPORT */ /* * CIs must be in exactly the same order that we sent... @@ -923,6 +943,7 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { goto bad; \ } +#if VJ_SUPPORT #define ACKCIVJ(opt, neg, val, old, maxslotindex, cflag) \ if (neg) { \ int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ @@ -945,6 +966,7 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { goto bad; \ } \ } +#endif /* VJ_SUPPORT */ #define ACKCIADDR(opt, neg, val) \ if (neg) { \ @@ -995,8 +1017,10 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { ACKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr, go->hisaddr); +#if VJ_SUPPORT ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, go->maxslotindex, go->cflag); +#endif /* VJ_SUPPORT */ ACKCIADDR(CI_ADDR, go->neg_addr, go->ouraddr); @@ -1033,9 +1057,11 @@ bad: static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { ppp_pcb *pcb = f->pcb; ipcp_options *go = &pcb->ipcp_gotoptions; - u_char cimaxslotindex, cicflag; u_char citype, cilen, *next; +#if VJ_SUPPORT + u_char cimaxslotindex, cicflag; u_short cishort; +#endif /* VJ_SUPPORT */ u32_t ciaddr1, ciaddr2, l, cidnsaddr; ipcp_options no; /* options we've seen Naks for */ ipcp_options try_; /* options to request next time */ @@ -1063,6 +1089,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { code \ } +#if VJ_SUPPORT #define NAKCIVJ(opt, neg, code) \ if (go->neg && \ ((cilen = p[1]) == CILEN_COMPRESS || cilen == CILEN_VJ) && \ @@ -1074,6 +1101,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { no.neg = 1; \ code \ } +#endif /* VJ_SUPPORT */ #define NAKCIADDR(opt, neg, code) \ if (go->neg && \ @@ -1120,6 +1148,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { } ); +#if VJ_SUPPORT /* * Accept the peer's value of maxslotindex provided that it * is less than what we asked for. Turn off slot-ID compression @@ -1150,6 +1179,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { } } ); +#endif /* VJ_SUPPORT */ NAKCIADDR(CI_ADDR, neg_addr, if (treat_as_reject) { @@ -1193,12 +1223,14 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { next = p + cilen - 2; switch (citype) { +#if VJ_SUPPORT case CI_COMPRESSTYPE: if (go->neg_vj || no.neg_vj || (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) goto bad; no.neg_vj = 1; break; +#endif /* VJ_SUPPORT */ case CI_ADDRS: if ((!go->neg_addr && go->old_addrs) || no.old_addrs || cilen != CILEN_ADDRS) @@ -1279,8 +1311,11 @@ bad: static int ipcp_rejci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; ipcp_options *go = &pcb->ipcp_gotoptions; - u_char cimaxslotindex, ciflag, cilen; + u_char cilen; +#if VJ_SUPPORT + u_char cimaxslotindex, ciflag; u_short cishort; +#endif /* VJ_SUPPORT */ u32_t cilong; ipcp_options try_; /* options to request next time */ @@ -1311,6 +1346,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { try_.old_addrs = 0; \ } +#if VJ_SUPPORT #define REJCIVJ(opt, neg, val, old, maxslot, cflag) \ if (go->neg && \ p[1] == (old? CILEN_COMPRESS : CILEN_VJ) && \ @@ -1332,6 +1368,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { } \ try_.neg = 0; \ } +#endif /* VJ_SUPPORT */ #define REJCIADDR(opt, neg, val) \ if (go->neg && \ @@ -1384,8 +1421,10 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { REJCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr, go->hisaddr); +#if VJ_SUPPORT REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol, go->old_vj, go->maxslotindex, go->cflag); +#endif /* VJ_SUPPORT */ REJCIADDR(CI_ADDR, neg_addr, go->ouraddr); @@ -1433,14 +1472,18 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { ipcp_options *ao = &pcb->ipcp_allowoptions; u_char *cip, *next; /* Pointer to current and next CIs */ u_short cilen, citype; /* Parsed len, type */ +#if VJ_SUPPORT u_short cishort; /* Parsed short value */ +#endif /* VJ_SUPPORT */ u32_t tl, ciaddr1, ciaddr2;/* Parsed address values */ int rc = CONFACK; /* Final packet return code */ int orc; /* Individual option return code */ u_char *p; /* Pointer to next char to parse */ u_char *ucp = inp; /* Pointer to current output char */ int l = *len; /* Length left */ +#if VJ_SUPPORT u_char maxslotindex, cflag; +#endif /* VJ_SUPPORT */ int d; /* @@ -1602,6 +1645,7 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { } break; +#if VJ_SUPPORT case CI_COMPRESSTYPE: if (!ao->neg_vj || (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) { @@ -1643,6 +1687,7 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { ho->cflag = 1; } break; +#endif /* VJ_SUPPORT */ default: orc = CONFREJ; @@ -2119,7 +2164,9 @@ static int ipcp_printpkt(u_char *p, int plen, void (*printer) (void *, const char *, ...), void *arg) { int code, id, len, olen; u_char *pstart, *optend; +#if VJ_SUPPORT u_short cishort; +#endif /* VJ_SUPPORT */ u32_t cilong; if (plen < HEADERLEN) @@ -2163,6 +2210,7 @@ static int ipcp_printpkt(u_char *p, int plen, printer(arg, " %I", htonl(cilong)); } break; +#if VJ_SUPPORT case CI_COMPRESSTYPE: if (olen >= CILEN_COMPRESS) { p += 2; @@ -2180,6 +2228,7 @@ static int ipcp_printpkt(u_char *p, int plen, } } break; +#endif /* VJ_SUPPORT */ case CI_ADDR: if (olen == CILEN_ADDR) { p += 2; diff --git a/src/netif/ppp/pppoe.c b/src/netif/ppp/pppoe.c index e118866f..ebb13ddd 100644 --- a/src/netif/ppp/pppoe.c +++ b/src/netif/ppp/pppoe.c @@ -912,10 +912,10 @@ pppoe_connect(ppp_pcb *ppp, void *ctx) struct pppoe_softc *sc = (struct pppoe_softc *)ctx; lcp_options *lcp_wo; lcp_options *lcp_ao; -#if PPP_IPV4_SUPPORT +#if PPP_IPV4_SUPPORT && VJ_SUPPORT ipcp_options *ipcp_wo; ipcp_options *ipcp_ao; -#endif /* PPP_IPV4_SUPPORT */ +#endif /* PPP_IPV4_SUPPORT && VJ_SUPPORT */ if (sc->sc_state != PPPOE_STATE_INITIAL) { return EBUSY; @@ -947,7 +947,7 @@ pppoe_connect(ppp_pcb *ppp, void *ctx) lcp_ao->neg_pcompression = 0; lcp_ao->neg_accompression = 0; -#if PPP_IPV4_SUPPORT +#if PPP_IPV4_SUPPORT && VJ_SUPPORT ipcp_wo = &ppp->ipcp_wantoptions; ipcp_wo->neg_vj = 0; ipcp_wo->old_vj = 0; @@ -955,7 +955,7 @@ pppoe_connect(ppp_pcb *ppp, void *ctx) ipcp_ao = &ppp->ipcp_allowoptions; ipcp_ao->neg_vj = 0; ipcp_ao->old_vj = 0; -#endif /* PPP_IPV4_SUPPORT */ +#endif /* PPP_IPV4_SUPPORT && VJ_SUPPORT */ /* save state, in case we fail to send PADI */ sc->sc_state = PPPOE_STATE_PADI_SENT; diff --git a/src/netif/ppp/pppol2tp.c b/src/netif/ppp/pppol2tp.c index 737e0677..0ae2a9ee 100644 --- a/src/netif/ppp/pppol2tp.c +++ b/src/netif/ppp/pppol2tp.c @@ -313,10 +313,10 @@ static err_t pppol2tp_connect(ppp_pcb *ppp, void *ctx) { pppol2tp_pcb *l2tp = (pppol2tp_pcb *)ctx; lcp_options *lcp_wo; lcp_options *lcp_ao; -#if PPP_IPV4_SUPPORT +#if PPP_IPV4_SUPPORT && VJ_SUPPORT ipcp_options *ipcp_wo; ipcp_options *ipcp_ao; -#endif /* PPP_IPV4_SUPPORT */ +#endif /* PPP_IPV4_SUPPORT && VJ_SUPPORT */ if (l2tp->phase != PPPOL2TP_STATE_INITIAL) { return ERR_VAL; @@ -338,7 +338,7 @@ static err_t pppol2tp_connect(ppp_pcb *ppp, void *ctx) { lcp_ao->neg_pcompression = 0; lcp_ao->neg_accompression = 0; -#if PPP_IPV4_SUPPORT +#if PPP_IPV4_SUPPORT && VJ_SUPPORT ipcp_wo = &ppp->ipcp_wantoptions; ipcp_wo->neg_vj = 0; ipcp_wo->old_vj = 0; @@ -346,7 +346,7 @@ static err_t pppol2tp_connect(ppp_pcb *ppp, void *ctx) { ipcp_ao = &ppp->ipcp_allowoptions; ipcp_ao->neg_vj = 0; ipcp_ao->old_vj = 0; -#endif /* PPP_IPV4_SUPPORT */ +#endif /* PPP_IPV4_SUPPORT && VJ_SUPPORT */ /* Listen to a random source port, we need to do that instead of using udp_connect() * because the L2TP LNS might answer with its own random source port (!= 1701) diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 6e2c1a78..0627253b 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -396,10 +396,6 @@ static err_t pppos_connect(ppp_pcb *ppp, void *ctx) { pppos_pcb *pppos = (pppos_pcb *)ctx; -#if !VJ_SUPPORT && PPP_IPV4_SUPPORT - ipcp_options *ipcp_wo; - ipcp_options *ipcp_ao; -#endif /* !VJ_SUPPORT && PPP_IPV4_SUPPORT */ #if PPP_INPROC_MULTITHREADED sys_mutex_lock(&pppos->mutex); @@ -414,20 +410,9 @@ pppos_connect(ppp_pcb *ppp, void *ctx) ppp_clear(ppp); -#if PPP_IPV4_SUPPORT -#if VJ_SUPPORT +#if PPP_IPV4_SUPPORT && VJ_SUPPORT vj_compress_init(&pppos->vj_comp); -#else /* VJ_SUPPORT */ - /* Don't even try to negotiate VJ if VJ is disabled */ - ipcp_wo = &ppp->ipcp_wantoptions; - ipcp_wo->neg_vj = 0; - ipcp_wo->old_vj = 0; - - ipcp_ao = &ppp->ipcp_allowoptions; - ipcp_ao->neg_vj = 0; - ipcp_ao->old_vj = 0; -#endif /* VJ_SUPPORT */ -#endif /* PPP_IPV4_SUPPORT */ +#endif /* PPP_IPV4_SUPPORT && VJ_SUPPORT */ /* * Default the in and out accm so that escape and flag characters @@ -451,9 +436,6 @@ pppos_listen(ppp_pcb *ppp, void *ctx, struct ppp_addrs *addrs) pppos_pcb *pppos = (pppos_pcb *)ctx; #if PPP_IPV4_SUPPORT ipcp_options *ipcp_wo; -#if !VJ_SUPPORT - ipcp_options *ipcp_ao; -#endif /* !VJ_SUPPORT */ #endif /* PPP_IPV4_SUPPORT */ lcp_options *lcp_wo; @@ -491,15 +473,6 @@ pppos_listen(ppp_pcb *ppp, void *ctx, struct ppp_addrs *addrs) #if VJ_SUPPORT vj_compress_init(&pppos->vj_comp); -#else /* VJ_SUPPORT */ - /* Don't even try to negotiate VJ if VJ is disabled */ - ipcp_wo = &ppp->ipcp_wantoptions; - ipcp_wo->neg_vj = 0; - ipcp_wo->old_vj = 0; - - ipcp_ao = &ppp->ipcp_allowoptions; - ipcp_ao->neg_vj = 0; - ipcp_ao->old_vj = 0; #endif /* VJ_SUPPORT */ #else /* PPP_IPV4_SUPPORT */