mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
PPP, IPV6CP, build out IPv6 VJ support using the existing IPV6CP_COMP define
This commit is contained in:
parent
99bcce7892
commit
1dd050aaca
@ -150,7 +150,9 @@
|
|||||||
* Options.
|
* Options.
|
||||||
*/
|
*/
|
||||||
#define CI_IFACEID 1 /* Interface Identifier */
|
#define CI_IFACEID 1 /* Interface Identifier */
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
|
||||||
/* No compression types yet defined.
|
/* No compression types yet defined.
|
||||||
*#define IPV6CP_COMP 0x004f
|
*#define IPV6CP_COMP 0x004f
|
||||||
@ -165,9 +167,13 @@ typedef struct ipv6cp_options {
|
|||||||
#if 0
|
#if 0
|
||||||
unsigned int use_persistent :1; /* use uniquely persistent value for address */
|
unsigned int use_persistent :1; /* use uniquely persistent value for address */
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
unsigned int neg_vj :1; /* Van Jacobson Compression? */
|
unsigned int neg_vj :1; /* Van Jacobson Compression? */
|
||||||
unsigned int :1; /* 1 bit of padding to round out to 8 bits */
|
#endif /* IPV6CP_COMP */
|
||||||
|
unsigned int :2; /* 2 bit of padding to round out to 8 bits */
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
u_short vj_protocol; /* protocol value to use in VJ option */
|
u_short vj_protocol; /* protocol value to use in VJ option */
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
eui64_t ourid, hisid; /* Interface identifiers */
|
eui64_t ourid, hisid; /* Interface identifiers */
|
||||||
} ipv6cp_options;
|
} ipv6cp_options;
|
||||||
|
|
||||||
|
@ -528,11 +528,16 @@ static int ipv6cp_cilen(fsm *f) {
|
|||||||
ppp_pcb *pcb = f->pcb;
|
ppp_pcb *pcb = f->pcb;
|
||||||
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
||||||
|
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
#define LENCIVJ(neg) (neg ? CILEN_COMPRESS : 0)
|
#define LENCIVJ(neg) (neg ? CILEN_COMPRESS : 0)
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
#define LENCIIFACEID(neg) (neg ? CILEN_IFACEID : 0)
|
#define LENCIIFACEID(neg) (neg ? CILEN_IFACEID : 0)
|
||||||
|
|
||||||
return (LENCIIFACEID(go->neg_ifaceid) +
|
return (LENCIIFACEID(go->neg_ifaceid) +
|
||||||
LENCIVJ(go->neg_vj));
|
#ifdef IPV6CP_COMP
|
||||||
|
LENCIVJ(go->neg_vj) +
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -544,6 +549,7 @@ static void ipv6cp_addci(fsm *f, u_char *ucp, int *lenp) {
|
|||||||
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
||||||
int len = *lenp;
|
int len = *lenp;
|
||||||
|
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
#define ADDCIVJ(opt, neg, val) \
|
#define ADDCIVJ(opt, neg, val) \
|
||||||
if (neg) { \
|
if (neg) { \
|
||||||
int vjlen = CILEN_COMPRESS; \
|
int vjlen = CILEN_COMPRESS; \
|
||||||
@ -555,6 +561,7 @@ static void ipv6cp_addci(fsm *f, u_char *ucp, int *lenp) {
|
|||||||
} else \
|
} else \
|
||||||
neg = 0; \
|
neg = 0; \
|
||||||
}
|
}
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
|
||||||
#define ADDCIIFACEID(opt, neg, val1) \
|
#define ADDCIIFACEID(opt, neg, val1) \
|
||||||
if (neg) { \
|
if (neg) { \
|
||||||
@ -570,7 +577,9 @@ static void ipv6cp_addci(fsm *f, u_char *ucp, int *lenp) {
|
|||||||
|
|
||||||
ADDCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid);
|
ADDCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid);
|
||||||
|
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol);
|
ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol);
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
|
||||||
*lenp -= len;
|
*lenp -= len;
|
||||||
}
|
}
|
||||||
@ -586,7 +595,10 @@ static void ipv6cp_addci(fsm *f, u_char *ucp, int *lenp) {
|
|||||||
static int ipv6cp_ackci(fsm *f, u_char *p, int len) {
|
static int ipv6cp_ackci(fsm *f, u_char *p, int len) {
|
||||||
ppp_pcb *pcb = f->pcb;
|
ppp_pcb *pcb = f->pcb;
|
||||||
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
||||||
u_short cilen, citype, cishort;
|
u_short cilen, citype;
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
|
u_short cishort;
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
eui64_t ifaceid;
|
eui64_t ifaceid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -595,6 +607,7 @@ static int ipv6cp_ackci(fsm *f, u_char *p, int len) {
|
|||||||
* If we find any deviations, then this packet is bad.
|
* If we find any deviations, then this packet is bad.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
#define ACKCIVJ(opt, neg, val) \
|
#define ACKCIVJ(opt, neg, val) \
|
||||||
if (neg) { \
|
if (neg) { \
|
||||||
int vjlen = CILEN_COMPRESS; \
|
int vjlen = CILEN_COMPRESS; \
|
||||||
@ -609,6 +622,7 @@ static int ipv6cp_ackci(fsm *f, u_char *p, int len) {
|
|||||||
if (cishort != val) \
|
if (cishort != val) \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
}
|
}
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
|
||||||
#define ACKCIIFACEID(opt, neg, val1) \
|
#define ACKCIIFACEID(opt, neg, val1) \
|
||||||
if (neg) { \
|
if (neg) { \
|
||||||
@ -627,7 +641,9 @@ static int ipv6cp_ackci(fsm *f, u_char *p, int len) {
|
|||||||
|
|
||||||
ACKCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid);
|
ACKCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid);
|
||||||
|
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol);
|
ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol);
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there are any remaining CIs, then this packet is bad.
|
* If there are any remaining CIs, then this packet is bad.
|
||||||
@ -654,7 +670,9 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
|||||||
ppp_pcb *pcb = f->pcb;
|
ppp_pcb *pcb = f->pcb;
|
||||||
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
||||||
u_char citype, cilen, *next;
|
u_char citype, cilen, *next;
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
u_short cishort;
|
u_short cishort;
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
eui64_t ifaceid;
|
eui64_t ifaceid;
|
||||||
ipv6cp_options no; /* options we've seen Naks for */
|
ipv6cp_options no; /* options we've seen Naks for */
|
||||||
ipv6cp_options try_; /* options to request next time */
|
ipv6cp_options try_; /* options to request next time */
|
||||||
@ -679,6 +697,7 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
|||||||
code \
|
code \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
#define NAKCIVJ(opt, neg, code) \
|
#define NAKCIVJ(opt, neg, code) \
|
||||||
if (go->neg && \
|
if (go->neg && \
|
||||||
((cilen = p[1]) == CILEN_COMPRESS) && \
|
((cilen = p[1]) == CILEN_COMPRESS) && \
|
||||||
@ -690,6 +709,7 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
|||||||
no.neg = 1; \
|
no.neg = 1; \
|
||||||
code \
|
code \
|
||||||
}
|
}
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Accept the peer's idea of {our,his} interface identifier, if different
|
* Accept the peer's idea of {our,his} interface identifier, if different
|
||||||
@ -717,13 +737,7 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
#else
|
#endif /* IPV6CP_COMP */
|
||||||
NAKCIVJ(CI_COMPRESSTYPE, neg_vj,
|
|
||||||
{
|
|
||||||
try_.neg_vj = 0;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There may be remaining CIs, if the peer is requesting negotiation
|
* There may be remaining CIs, if the peer is requesting negotiation
|
||||||
@ -739,12 +753,14 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
|||||||
next = p + cilen - 2;
|
next = p + cilen - 2;
|
||||||
|
|
||||||
switch (citype) {
|
switch (citype) {
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
case CI_COMPRESSTYPE:
|
case CI_COMPRESSTYPE:
|
||||||
if (go->neg_vj || no.neg_vj ||
|
if (go->neg_vj || no.neg_vj ||
|
||||||
(cilen != CILEN_COMPRESS))
|
(cilen != CILEN_COMPRESS))
|
||||||
goto bad;
|
goto bad;
|
||||||
no.neg_vj = 1;
|
no.neg_vj = 1;
|
||||||
break;
|
break;
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
case CI_IFACEID:
|
case CI_IFACEID:
|
||||||
if (go->neg_ifaceid || no.neg_ifaceid || cilen != CILEN_IFACEID)
|
if (go->neg_ifaceid || no.neg_ifaceid || cilen != CILEN_IFACEID)
|
||||||
goto bad;
|
goto bad;
|
||||||
@ -789,7 +805,9 @@ static int ipv6cp_rejci(fsm *f, u_char *p, int len) {
|
|||||||
ppp_pcb *pcb = f->pcb;
|
ppp_pcb *pcb = f->pcb;
|
||||||
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
||||||
u_char cilen;
|
u_char cilen;
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
u_short cishort;
|
u_short cishort;
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
eui64_t ifaceid;
|
eui64_t ifaceid;
|
||||||
ipv6cp_options try_; /* options to request next time */
|
ipv6cp_options try_; /* options to request next time */
|
||||||
|
|
||||||
@ -813,6 +831,7 @@ static int ipv6cp_rejci(fsm *f, u_char *p, int len) {
|
|||||||
try_.neg = 0; \
|
try_.neg = 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
#define REJCIVJ(opt, neg, val) \
|
#define REJCIVJ(opt, neg, val) \
|
||||||
if (go->neg && \
|
if (go->neg && \
|
||||||
p[1] == CILEN_COMPRESS && \
|
p[1] == CILEN_COMPRESS && \
|
||||||
@ -826,10 +845,13 @@ static int ipv6cp_rejci(fsm *f, u_char *p, int len) {
|
|||||||
goto bad; \
|
goto bad; \
|
||||||
try_.neg = 0; \
|
try_.neg = 0; \
|
||||||
}
|
}
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
|
||||||
REJCIIFACEID(CI_IFACEID, neg_ifaceid, go->ourid);
|
REJCIIFACEID(CI_IFACEID, neg_ifaceid, go->ourid);
|
||||||
|
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol);
|
REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol);
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there are any remaining CIs, then this packet is bad.
|
* If there are any remaining CIs, then this packet is bad.
|
||||||
@ -868,7 +890,9 @@ static int ipv6cp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) {
|
|||||||
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
ipv6cp_options *go = &pcb->ipv6cp_gotoptions;
|
||||||
u_char *cip, *next; /* Pointer to current and next CIs */
|
u_char *cip, *next; /* Pointer to current and next CIs */
|
||||||
u_short cilen, citype; /* Parsed len, type */
|
u_short cilen, citype; /* Parsed len, type */
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
u_short cishort; /* Parsed short value */
|
u_short cishort; /* Parsed short value */
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
eui64_t ifaceid; /* Parsed interface identifier */
|
eui64_t ifaceid; /* Parsed interface identifier */
|
||||||
int rc = CONFACK; /* Final packet return code */
|
int rc = CONFACK; /* Final packet return code */
|
||||||
int orc; /* Individual option return code */
|
int orc; /* Individual option return code */
|
||||||
@ -950,6 +974,7 @@ static int ipv6cp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) {
|
|||||||
ho->hisid = ifaceid;
|
ho->hisid = ifaceid;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#ifdef IPV6CP_COMP
|
||||||
case CI_COMPRESSTYPE:
|
case CI_COMPRESSTYPE:
|
||||||
IPV6CPDEBUG(("ipv6cp: received COMPRESSTYPE "));
|
IPV6CPDEBUG(("ipv6cp: received COMPRESSTYPE "));
|
||||||
if (!ao->neg_vj ||
|
if (!ao->neg_vj ||
|
||||||
@ -959,6 +984,7 @@ static int ipv6cp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) {
|
|||||||
}
|
}
|
||||||
GETSHORT(cishort, p);
|
GETSHORT(cishort, p);
|
||||||
IPV6CPDEBUG(("(%d)", cishort));
|
IPV6CPDEBUG(("(%d)", cishort));
|
||||||
|
#endif /* IPV6CP_COMP */
|
||||||
|
|
||||||
#ifdef IPV6CP_COMP
|
#ifdef IPV6CP_COMP
|
||||||
if (!(cishort == IPV6CP_COMP)) {
|
if (!(cishort == IPV6CP_COMP)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user