mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-09 07:54:38 +08:00
Minor changes in PPP (coding style, tabs, idents...)
This commit is contained in:
parent
a3ef33c56f
commit
fc2d28b851
@ -62,7 +62,7 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: chap.h,v 1.3 2007/12/02 22:56:19 fbernon Exp $
|
* $Id: chap.h,v 1.4 2007/12/19 20:47:22 fbernon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CHAP_H
|
#ifndef CHAP_H
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: chpms.h,v 1.4 2007/12/02 22:56:19 fbernon Exp $
|
* $Id: chpms.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CHPMS_H
|
#ifndef CHPMS_H
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: fsm.h,v 1.3 2007/12/02 23:24:59 fbernon Exp $
|
* $Id: fsm.h,v 1.4 2007/12/19 20:47:23 fbernon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FSM_H
|
#ifndef FSM_H
|
||||||
|
@ -188,7 +188,8 @@ static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */
|
|||||||
* sources. Assumes u32_t instead of struct in_addr.
|
* sources. Assumes u32_t instead of struct in_addr.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char * _inet_ntoa(u32_t n)
|
char *
|
||||||
|
_inet_ntoa(u32_t n)
|
||||||
{
|
{
|
||||||
struct in_addr ia;
|
struct in_addr ia;
|
||||||
ia.s_addr = n;
|
ia.s_addr = n;
|
||||||
@ -200,7 +201,8 @@ char * _inet_ntoa(u32_t n)
|
|||||||
/*
|
/*
|
||||||
* ipcp_init - Initialize IPCP.
|
* ipcp_init - Initialize IPCP.
|
||||||
*/
|
*/
|
||||||
static void ipcp_init(int unit)
|
static void
|
||||||
|
ipcp_init(int unit)
|
||||||
{
|
{
|
||||||
fsm *f = &ipcp_fsm[unit];
|
fsm *f = &ipcp_fsm[unit];
|
||||||
ipcp_options *wo = &ipcp_wantoptions[unit];
|
ipcp_options *wo = &ipcp_wantoptions[unit];
|
||||||
@ -224,7 +226,6 @@ static void ipcp_init(int unit)
|
|||||||
wo->vj_protocol = IPCP_VJ_COMP;
|
wo->vj_protocol = IPCP_VJ_COMP;
|
||||||
wo->maxslotindex = MAX_SLOTS - 1;
|
wo->maxslotindex = MAX_SLOTS - 1;
|
||||||
wo->cflag = 0;
|
wo->cflag = 0;
|
||||||
|
|
||||||
wo->default_route = 1;
|
wo->default_route = 1;
|
||||||
|
|
||||||
ao->neg_addr = 1;
|
ao->neg_addr = 1;
|
||||||
@ -235,7 +236,6 @@ static void ipcp_init(int unit)
|
|||||||
#endif /* VJ_SUPPORT */
|
#endif /* VJ_SUPPORT */
|
||||||
ao->maxslotindex = MAX_SLOTS - 1;
|
ao->maxslotindex = MAX_SLOTS - 1;
|
||||||
ao->cflag = 1;
|
ao->cflag = 1;
|
||||||
|
|
||||||
ao->default_route = 1;
|
ao->default_route = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +243,8 @@ static void ipcp_init(int unit)
|
|||||||
/*
|
/*
|
||||||
* ipcp_open - IPCP is allowed to come up.
|
* ipcp_open - IPCP is allowed to come up.
|
||||||
*/
|
*/
|
||||||
static void ipcp_open(int unit)
|
static void
|
||||||
|
ipcp_open(int unit)
|
||||||
{
|
{
|
||||||
fsm_open(&ipcp_fsm[unit]);
|
fsm_open(&ipcp_fsm[unit]);
|
||||||
}
|
}
|
||||||
@ -252,7 +253,8 @@ static void ipcp_open(int unit)
|
|||||||
/*
|
/*
|
||||||
* ipcp_close - Take IPCP down.
|
* ipcp_close - Take IPCP down.
|
||||||
*/
|
*/
|
||||||
static void ipcp_close(int unit, char *reason)
|
static void
|
||||||
|
ipcp_close(int unit, char *reason)
|
||||||
{
|
{
|
||||||
fsm_close(&ipcp_fsm[unit], reason);
|
fsm_close(&ipcp_fsm[unit], reason);
|
||||||
}
|
}
|
||||||
@ -261,7 +263,8 @@ static void ipcp_close(int unit, char *reason)
|
|||||||
/*
|
/*
|
||||||
* ipcp_lowerup - The lower layer is up.
|
* ipcp_lowerup - The lower layer is up.
|
||||||
*/
|
*/
|
||||||
static void ipcp_lowerup(int unit)
|
static void
|
||||||
|
ipcp_lowerup(int unit)
|
||||||
{
|
{
|
||||||
fsm_lowerup(&ipcp_fsm[unit]);
|
fsm_lowerup(&ipcp_fsm[unit]);
|
||||||
}
|
}
|
||||||
@ -270,7 +273,8 @@ static void ipcp_lowerup(int unit)
|
|||||||
/*
|
/*
|
||||||
* ipcp_lowerdown - The lower layer is down.
|
* ipcp_lowerdown - The lower layer is down.
|
||||||
*/
|
*/
|
||||||
static void ipcp_lowerdown(int unit)
|
static void
|
||||||
|
ipcp_lowerdown(int unit)
|
||||||
{
|
{
|
||||||
fsm_lowerdown(&ipcp_fsm[unit]);
|
fsm_lowerdown(&ipcp_fsm[unit]);
|
||||||
}
|
}
|
||||||
@ -279,7 +283,8 @@ static void ipcp_lowerdown(int unit)
|
|||||||
/*
|
/*
|
||||||
* ipcp_input - Input IPCP packet.
|
* ipcp_input - Input IPCP packet.
|
||||||
*/
|
*/
|
||||||
static void ipcp_input(int unit, u_char *p, int len)
|
static void
|
||||||
|
ipcp_input(int unit, u_char *p, int len)
|
||||||
{
|
{
|
||||||
fsm_input(&ipcp_fsm[unit], p, len);
|
fsm_input(&ipcp_fsm[unit], p, len);
|
||||||
}
|
}
|
||||||
@ -290,7 +295,8 @@ static void ipcp_input(int unit, u_char *p, int len)
|
|||||||
*
|
*
|
||||||
* Pretend the lower layer went down, so we shut up.
|
* Pretend the lower layer went down, so we shut up.
|
||||||
*/
|
*/
|
||||||
static void ipcp_protrej(int unit)
|
static void
|
||||||
|
ipcp_protrej(int unit)
|
||||||
{
|
{
|
||||||
fsm_lowerdown(&ipcp_fsm[unit]);
|
fsm_lowerdown(&ipcp_fsm[unit]);
|
||||||
}
|
}
|
||||||
@ -299,15 +305,18 @@ static void ipcp_protrej(int unit)
|
|||||||
/*
|
/*
|
||||||
* ipcp_resetci - Reset our CI.
|
* ipcp_resetci - Reset our CI.
|
||||||
*/
|
*/
|
||||||
static void ipcp_resetci(fsm *f)
|
static void
|
||||||
|
ipcp_resetci(fsm *f)
|
||||||
{
|
{
|
||||||
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
||||||
|
|
||||||
wo->req_addr = wo->neg_addr && ipcp_allowoptions[f->unit].neg_addr;
|
wo->req_addr = wo->neg_addr && ipcp_allowoptions[f->unit].neg_addr;
|
||||||
if (wo->ouraddr == 0)
|
if (wo->ouraddr == 0) {
|
||||||
wo->accept_local = 1;
|
wo->accept_local = 1;
|
||||||
if (wo->hisaddr == 0)
|
}
|
||||||
|
if (wo->hisaddr == 0) {
|
||||||
wo->accept_remote = 1;
|
wo->accept_remote = 1;
|
||||||
|
}
|
||||||
/* Request DNS addresses from the peer */
|
/* Request DNS addresses from the peer */
|
||||||
wo->req_dns1 = ppp_settings.usepeerdns;
|
wo->req_dns1 = ppp_settings.usepeerdns;
|
||||||
wo->req_dns2 = ppp_settings.usepeerdns;
|
wo->req_dns2 = ppp_settings.usepeerdns;
|
||||||
@ -319,7 +328,8 @@ static void ipcp_resetci(fsm *f)
|
|||||||
/*
|
/*
|
||||||
* ipcp_cilen - Return length of our CI.
|
* ipcp_cilen - Return length of our CI.
|
||||||
*/
|
*/
|
||||||
static int ipcp_cilen(fsm *f)
|
static int
|
||||||
|
ipcp_cilen(fsm *f)
|
||||||
{
|
{
|
||||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||||
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
||||||
@ -353,8 +363,8 @@ static int ipcp_cilen(fsm *f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (LENCIADDR(go->neg_addr, go->old_addrs)
|
return (LENCIADDR(go->neg_addr, go->old_addrs) +
|
||||||
+ LENCIVJ(go->neg_vj, go->old_vj) +
|
LENCIVJ(go->neg_vj, go->old_vj) +
|
||||||
LENCIDNS(go->req_dns1) +
|
LENCIDNS(go->req_dns1) +
|
||||||
LENCIDNS(go->req_dns2));
|
LENCIDNS(go->req_dns2));
|
||||||
}
|
}
|
||||||
@ -363,7 +373,8 @@ static int ipcp_cilen(fsm *f)
|
|||||||
/*
|
/*
|
||||||
* ipcp_addci - Add our desired CIs to a packet.
|
* ipcp_addci - Add our desired CIs to a packet.
|
||||||
*/
|
*/
|
||||||
static void ipcp_addci(fsm *f, u_char *ucp, int *lenp)
|
static void
|
||||||
|
ipcp_addci(fsm *f, u_char *ucp, int *lenp)
|
||||||
{
|
{
|
||||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||||
int len = *lenp;
|
int len = *lenp;
|
||||||
@ -380,8 +391,9 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp)
|
|||||||
PUTCHAR(cflag, ucp); \
|
PUTCHAR(cflag, ucp); \
|
||||||
} \
|
} \
|
||||||
len -= vjlen; \
|
len -= vjlen; \
|
||||||
} else \
|
} else { \
|
||||||
neg = 0; \
|
neg = 0; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ADDCIADDR(opt, neg, old, val1, val2) \
|
#define ADDCIADDR(opt, neg, old, val1, val2) \
|
||||||
@ -398,8 +410,9 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp)
|
|||||||
PUTLONG(l, ucp); \
|
PUTLONG(l, ucp); \
|
||||||
} \
|
} \
|
||||||
len -= addrlen; \
|
len -= addrlen; \
|
||||||
} else \
|
} else { \
|
||||||
neg = 0; \
|
neg = 0; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ADDCIDNS(opt, neg, addr) \
|
#define ADDCIDNS(opt, neg, addr) \
|
||||||
@ -411,8 +424,9 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp)
|
|||||||
l = ntohl(addr); \
|
l = ntohl(addr); \
|
||||||
PUTLONG(l, ucp); \
|
PUTLONG(l, ucp); \
|
||||||
len -= CILEN_ADDR; \
|
len -= CILEN_ADDR; \
|
||||||
} else \
|
} else { \
|
||||||
neg = 0; \
|
neg = 0; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
ADDCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr,
|
ADDCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr,
|
||||||
@ -436,7 +450,8 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp)
|
|||||||
* 0 - Ack was bad.
|
* 0 - Ack was bad.
|
||||||
* 1 - Ack was good.
|
* 1 - Ack was good.
|
||||||
*/
|
*/
|
||||||
static int ipcp_ackci(fsm *f, u_char *p, int len)
|
static int
|
||||||
|
ipcp_ackci(fsm *f, u_char *p, int len)
|
||||||
{
|
{
|
||||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||||
u_short cilen, citype, cishort;
|
u_short cilen, citype, cishort;
|
||||||
@ -452,63 +467,75 @@ static int ipcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
#define ACKCIVJ(opt, neg, val, old, maxslotindex, cflag) \
|
#define ACKCIVJ(opt, neg, val, old, maxslotindex, cflag) \
|
||||||
if (neg) { \
|
if (neg) { \
|
||||||
int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \
|
int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \
|
||||||
if ((len -= vjlen) < 0) \
|
if ((len -= vjlen) < 0) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
GETCHAR(citype, p); \
|
GETCHAR(citype, p); \
|
||||||
GETCHAR(cilen, p); \
|
GETCHAR(cilen, p); \
|
||||||
if (cilen != vjlen || \
|
if (cilen != vjlen || \
|
||||||
citype != opt) \
|
citype != opt) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
GETSHORT(cishort, p); \
|
GETSHORT(cishort, p); \
|
||||||
if (cishort != val) \
|
if (cishort != val) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
if (!old) { \
|
if (!old) { \
|
||||||
GETCHAR(cimaxslotindex, p); \
|
GETCHAR(cimaxslotindex, p); \
|
||||||
if (cimaxslotindex != maxslotindex) \
|
if (cimaxslotindex != maxslotindex) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
GETCHAR(cicflag, p); \
|
GETCHAR(cicflag, p); \
|
||||||
if (cicflag != cflag) \
|
if (cicflag != cflag) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
} \
|
} \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ACKCIADDR(opt, neg, old, val1, val2) \
|
#define ACKCIADDR(opt, neg, old, val1, val2) \
|
||||||
if (neg) { \
|
if (neg) { \
|
||||||
int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \
|
int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \
|
||||||
u32_t l; \
|
u32_t l; \
|
||||||
if ((len -= addrlen) < 0) \
|
if ((len -= addrlen) < 0) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
GETCHAR(citype, p); \
|
GETCHAR(citype, p); \
|
||||||
GETCHAR(cilen, p); \
|
GETCHAR(cilen, p); \
|
||||||
if (cilen != addrlen || \
|
if (cilen != addrlen || \
|
||||||
citype != opt) \
|
citype != opt) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
GETLONG(l, p); \
|
GETLONG(l, p); \
|
||||||
cilong = htonl(l); \
|
cilong = htonl(l); \
|
||||||
if (val1 != cilong) \
|
if (val1 != cilong) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
if (old) { \
|
if (old) { \
|
||||||
GETLONG(l, p); \
|
GETLONG(l, p); \
|
||||||
cilong = htonl(l); \
|
cilong = htonl(l); \
|
||||||
if (val2 != cilong) \
|
if (val2 != cilong) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
} \
|
} \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ACKCIDNS(opt, neg, addr) \
|
#define ACKCIDNS(opt, neg, addr) \
|
||||||
if (neg) { \
|
if (neg) { \
|
||||||
u32_t l; \
|
u32_t l; \
|
||||||
if ((len -= CILEN_ADDR) < 0) \
|
if ((len -= CILEN_ADDR) < 0) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
GETCHAR(citype, p); \
|
GETCHAR(citype, p); \
|
||||||
GETCHAR(cilen, p); \
|
GETCHAR(cilen, p); \
|
||||||
if (cilen != CILEN_ADDR || \
|
if (cilen != CILEN_ADDR || \
|
||||||
citype != opt) \
|
citype != opt) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
GETLONG(l, p); \
|
GETLONG(l, p); \
|
||||||
cilong = htonl(l); \
|
cilong = htonl(l); \
|
||||||
if (addr != cilong) \
|
if (addr != cilong) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
ACKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr,
|
ACKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr,
|
||||||
@ -524,8 +551,9 @@ static int ipcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
/*
|
/*
|
||||||
* If there are any remaining CIs, then this packet is bad.
|
* If there are any remaining CIs, then this packet is bad.
|
||||||
*/
|
*/
|
||||||
if (len != 0)
|
if (len != 0) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
@ -542,7 +570,8 @@ bad:
|
|||||||
* 0 - Nak was bad.
|
* 0 - Nak was bad.
|
||||||
* 1 - Nak was good.
|
* 1 - Nak was good.
|
||||||
*/
|
*/
|
||||||
static int ipcp_nakci(fsm *f, u_char *p, int len)
|
static int
|
||||||
|
ipcp_nakci(fsm *f, u_char *p, int len)
|
||||||
{
|
{
|
||||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||||
u_char cimaxslotindex, cicflag;
|
u_char cimaxslotindex, cicflag;
|
||||||
@ -573,8 +602,9 @@ static int ipcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
GETLONG(l, p); \
|
GETLONG(l, p); \
|
||||||
ciaddr2 = htonl(l); \
|
ciaddr2 = htonl(l); \
|
||||||
no.old_addrs = 1; \
|
no.old_addrs = 1; \
|
||||||
} else \
|
} else { \
|
||||||
ciaddr2 = 0; \
|
ciaddr2 = 0; \
|
||||||
|
} \
|
||||||
no.neg = 1; \
|
no.neg = 1; \
|
||||||
code \
|
code \
|
||||||
}
|
}
|
||||||
@ -633,10 +663,12 @@ static int ipcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
GETCHAR(cicflag, p);
|
GETCHAR(cicflag, p);
|
||||||
if (cishort == IPCP_VJ_COMP) {
|
if (cishort == IPCP_VJ_COMP) {
|
||||||
try.old_vj = 0;
|
try.old_vj = 0;
|
||||||
if (cimaxslotindex < go->maxslotindex)
|
if (cimaxslotindex < go->maxslotindex) {
|
||||||
try.maxslotindex = cimaxslotindex;
|
try.maxslotindex = cimaxslotindex;
|
||||||
if (!cicflag)
|
}
|
||||||
|
if (!cicflag) {
|
||||||
try.cflag = 0;
|
try.cflag = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
try.neg_vj = 0;
|
try.neg_vj = 0;
|
||||||
}
|
}
|
||||||
@ -669,43 +701,51 @@ static int ipcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
while (len > CILEN_VOID) {
|
while (len > CILEN_VOID) {
|
||||||
GETCHAR(citype, p);
|
GETCHAR(citype, p);
|
||||||
GETCHAR(cilen, p);
|
GETCHAR(cilen, p);
|
||||||
if( (len -= cilen) < 0 )
|
if( (len -= cilen) < 0 ) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
next = p + cilen - 2;
|
next = p + cilen - 2;
|
||||||
|
|
||||||
switch (citype) {
|
switch (citype) {
|
||||||
case CI_COMPRESSTYPE:
|
case CI_COMPRESSTYPE:
|
||||||
if (go->neg_vj || no.neg_vj ||
|
if (go->neg_vj || no.neg_vj ||
|
||||||
(cilen != CILEN_VJ && cilen != CILEN_COMPRESS))
|
(cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
no.neg_vj = 1;
|
no.neg_vj = 1;
|
||||||
break;
|
break;
|
||||||
case CI_ADDRS:
|
case CI_ADDRS:
|
||||||
if ((go->neg_addr && go->old_addrs) || no.old_addrs
|
if ((go->neg_addr && go->old_addrs) || no.old_addrs
|
||||||
|| cilen != CILEN_ADDRS)
|
|| cilen != CILEN_ADDRS) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
try.neg_addr = 1;
|
try.neg_addr = 1;
|
||||||
try.old_addrs = 1;
|
try.old_addrs = 1;
|
||||||
GETLONG(l, p);
|
GETLONG(l, p);
|
||||||
ciaddr1 = htonl(l);
|
ciaddr1 = htonl(l);
|
||||||
if (ciaddr1 && go->accept_local)
|
if (ciaddr1 && go->accept_local) {
|
||||||
try.ouraddr = ciaddr1;
|
try.ouraddr = ciaddr1;
|
||||||
|
}
|
||||||
GETLONG(l, p);
|
GETLONG(l, p);
|
||||||
ciaddr2 = htonl(l);
|
ciaddr2 = htonl(l);
|
||||||
if (ciaddr2 && go->accept_remote)
|
if (ciaddr2 && go->accept_remote) {
|
||||||
try.hisaddr = ciaddr2;
|
try.hisaddr = ciaddr2;
|
||||||
|
}
|
||||||
no.old_addrs = 1;
|
no.old_addrs = 1;
|
||||||
break;
|
break;
|
||||||
case CI_ADDR:
|
case CI_ADDR:
|
||||||
if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR)
|
if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
try.old_addrs = 0;
|
try.old_addrs = 0;
|
||||||
GETLONG(l, p);
|
GETLONG(l, p);
|
||||||
ciaddr1 = htonl(l);
|
ciaddr1 = htonl(l);
|
||||||
if (ciaddr1 && go->accept_local)
|
if (ciaddr1 && go->accept_local) {
|
||||||
try.ouraddr = ciaddr1;
|
try.ouraddr = ciaddr1;
|
||||||
if (try.ouraddr != 0)
|
}
|
||||||
|
if (try.ouraddr != 0) {
|
||||||
try.neg_addr = 1;
|
try.neg_addr = 1;
|
||||||
|
}
|
||||||
no.neg_addr = 1;
|
no.neg_addr = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -713,14 +753,16 @@ static int ipcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If there is still anything left, this packet is bad. */
|
/* If there is still anything left, this packet is bad. */
|
||||||
if (len != 0)
|
if (len != 0) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OK, the Nak is good. Now we can update state.
|
* OK, the Nak is good. Now we can update state.
|
||||||
*/
|
*/
|
||||||
if (f->state != LS_OPENED)
|
if (f->state != LS_OPENED) {
|
||||||
*go = try;
|
*go = try;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -733,7 +775,8 @@ bad:
|
|||||||
/*
|
/*
|
||||||
* ipcp_rejci - Reject some of our CIs.
|
* ipcp_rejci - Reject some of our CIs.
|
||||||
*/
|
*/
|
||||||
static int ipcp_rejci(fsm *f, u_char *p, int len)
|
static int
|
||||||
|
ipcp_rejci(fsm *f, u_char *p, int len)
|
||||||
{
|
{
|
||||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||||
u_char cimaxslotindex, ciflag, cilen;
|
u_char cimaxslotindex, ciflag, cilen;
|
||||||
@ -758,15 +801,17 @@ static int ipcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
GETLONG(l, p); \
|
GETLONG(l, p); \
|
||||||
cilong = htonl(l); \
|
cilong = htonl(l); \
|
||||||
/* Check rejected value. */ \
|
/* Check rejected value. */ \
|
||||||
if (cilong != val1) \
|
if (cilong != val1) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
if (old) { \
|
if (old) { \
|
||||||
GETLONG(l, p); \
|
GETLONG(l, p); \
|
||||||
cilong = htonl(l); \
|
cilong = htonl(l); \
|
||||||
/* Check rejected value. */ \
|
/* Check rejected value. */ \
|
||||||
if (cilong != val2) \
|
if (cilong != val2) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
} \
|
} \
|
||||||
|
} \
|
||||||
try.neg = 0; \
|
try.neg = 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,16 +824,19 @@ static int ipcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
INCPTR(2, p); \
|
INCPTR(2, p); \
|
||||||
GETSHORT(cishort, p); \
|
GETSHORT(cishort, p); \
|
||||||
/* Check rejected value. */ \
|
/* Check rejected value. */ \
|
||||||
if (cishort != val) \
|
if (cishort != val) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
if (!old) { \
|
if (!old) { \
|
||||||
GETCHAR(cimaxslotindex, p); \
|
GETCHAR(cimaxslotindex, p); \
|
||||||
if (cimaxslotindex != maxslot) \
|
if (cimaxslotindex != maxslot) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
GETCHAR(ciflag, p); \
|
GETCHAR(ciflag, p); \
|
||||||
if (ciflag != cflag) \
|
if (ciflag != cflag) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
} \
|
} \
|
||||||
|
} \
|
||||||
try.neg = 0; \
|
try.neg = 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,8 +851,9 @@ static int ipcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
GETLONG(l, p); \
|
GETLONG(l, p); \
|
||||||
cilong = htonl(l); \
|
cilong = htonl(l); \
|
||||||
/* Check rejected value. */ \
|
/* Check rejected value. */ \
|
||||||
if (cilong != dnsaddr) \
|
if (cilong != dnsaddr) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
try.neg = 0; \
|
try.neg = 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,13 +870,15 @@ static int ipcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
/*
|
/*
|
||||||
* If there are any remaining CIs, then this packet is bad.
|
* If there are any remaining CIs, then this packet is bad.
|
||||||
*/
|
*/
|
||||||
if (len != 0)
|
if (len != 0) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Now we can update state.
|
* Now we can update state.
|
||||||
*/
|
*/
|
||||||
if (f->state != LS_OPENED)
|
if (f->state != LS_OPENED) {
|
||||||
*go = try;
|
*go = try;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
@ -843,12 +894,8 @@ bad:
|
|||||||
* appropriately. If reject_if_disagree is non-zero, doesn't return
|
* appropriately. If reject_if_disagree is non-zero, doesn't return
|
||||||
* CONFNAK; returns CONFREJ if it can't return CONFACK.
|
* CONFNAK; returns CONFREJ if it can't return CONFACK.
|
||||||
*/
|
*/
|
||||||
static int ipcp_reqci(
|
static int
|
||||||
fsm *f,
|
ipcp_reqci(fsm *f, u_char *inp/* Requested CIs */,int *len/* Length of requested CIs */,int reject_if_disagree)
|
||||||
u_char *inp, /* Requested CIs */
|
|
||||||
int *len, /* Length of requested CIs */
|
|
||||||
int reject_if_disagree
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
||||||
ipcp_options *ho = &ipcp_hisoptions[f->unit];
|
ipcp_options *ho = &ipcp_hisoptions[f->unit];
|
||||||
@ -1110,16 +1157,18 @@ static int ipcp_reqci(
|
|||||||
|
|
||||||
endswitch:
|
endswitch:
|
||||||
if (orc == CONFACK && /* Good CI */
|
if (orc == CONFACK && /* Good CI */
|
||||||
rc != CONFACK) /* but prior CI wasnt? */
|
rc != CONFACK) { /* but prior CI wasnt? */
|
||||||
continue; /* Don't send this one */
|
continue; /* Don't send this one */
|
||||||
|
}
|
||||||
|
|
||||||
if (orc == CONFNAK) { /* Nak this CI? */
|
if (orc == CONFNAK) { /* Nak this CI? */
|
||||||
if (reject_if_disagree) { /* Getting fed up with sending NAKs? */
|
if (reject_if_disagree) { /* Getting fed up with sending NAKs? */
|
||||||
IPCPDEBUG((LOG_INFO, "ipcp_reqci: Rejecting too many naks\n"));
|
IPCPDEBUG((LOG_INFO, "ipcp_reqci: Rejecting too many naks\n"));
|
||||||
orc = CONFREJ; /* Get tough if so */
|
orc = CONFREJ; /* Get tough if so */
|
||||||
} else {
|
} else {
|
||||||
if (rc == CONFREJ) /* Rejecting prior CI? */
|
if (rc == CONFREJ) { /* Rejecting prior CI? */
|
||||||
continue; /* Don't send this one */
|
continue; /* Don't send this one */
|
||||||
|
}
|
||||||
if (rc == CONFACK) { /* Ack'd all prior CIs? */
|
if (rc == CONFACK) { /* Ack'd all prior CIs? */
|
||||||
rc = CONFNAK; /* Not anymore... */
|
rc = CONFNAK; /* Not anymore... */
|
||||||
ucp = inp; /* Backup */
|
ucp = inp; /* Backup */
|
||||||
@ -1134,8 +1183,9 @@ endswitch:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Need to move CI? */
|
/* Need to move CI? */
|
||||||
if (ucp != cip)
|
if (ucp != cip) {
|
||||||
BCOPY(cip, ucp, cilen); /* Move it */
|
BCOPY(cip, ucp, cilen); /* Move it */
|
||||||
|
}
|
||||||
|
|
||||||
/* Update output pointer */
|
/* Update output pointer */
|
||||||
INCPTR(cilen, ucp);
|
INCPTR(cilen, ucp);
|
||||||
@ -1173,7 +1223,8 @@ endswitch:
|
|||||||
* ip_check_options - check that any IP-related options are OK,
|
* ip_check_options - check that any IP-related options are OK,
|
||||||
* and assign appropriate defaults.
|
* and assign appropriate defaults.
|
||||||
*/
|
*/
|
||||||
static void ip_check_options(u_long localAddr)
|
static void
|
||||||
|
ip_check_options(u_long localAddr)
|
||||||
{
|
{
|
||||||
ipcp_options *wo = &ipcp_wantoptions[0];
|
ipcp_options *wo = &ipcp_wantoptions[0];
|
||||||
|
|
||||||
@ -1194,7 +1245,8 @@ static void ip_check_options(u_long localAddr)
|
|||||||
*
|
*
|
||||||
* Configure the IP network interface appropriately and bring it up.
|
* Configure the IP network interface appropriately and bring it up.
|
||||||
*/
|
*/
|
||||||
static void ipcp_up(fsm *f)
|
static void
|
||||||
|
ipcp_up(fsm *f)
|
||||||
{
|
{
|
||||||
u32_t mask;
|
u32_t mask;
|
||||||
ipcp_options *ho = &ipcp_hisoptions[f->unit];
|
ipcp_options *ho = &ipcp_hisoptions[f->unit];
|
||||||
@ -1207,8 +1259,9 @@ static void ipcp_up(fsm *f)
|
|||||||
/*
|
/*
|
||||||
* We must have a non-zero IP address for both ends of the link.
|
* We must have a non-zero IP address for both ends of the link.
|
||||||
*/
|
*/
|
||||||
if (!ho->neg_addr)
|
if (!ho->neg_addr) {
|
||||||
ho->hisaddr = wo->hisaddr;
|
ho->hisaddr = wo->hisaddr;
|
||||||
|
}
|
||||||
|
|
||||||
if (ho->hisaddr == 0) {
|
if (ho->hisaddr == 0) {
|
||||||
IPCPDEBUG((LOG_ERR, "Could not determine remote IP address\n"));
|
IPCPDEBUG((LOG_ERR, "Could not determine remote IP address\n"));
|
||||||
@ -1259,9 +1312,11 @@ static void ipcp_up(fsm *f)
|
|||||||
sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
|
sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
|
||||||
|
|
||||||
/* assign a default route through the interface if required */
|
/* assign a default route through the interface if required */
|
||||||
if (ipcp_wantoptions[f->unit].default_route)
|
if (ipcp_wantoptions[f->unit].default_route) {
|
||||||
if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
|
if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr)) {
|
||||||
default_route_set[f->unit] = 1;
|
default_route_set[f->unit] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IPCPDEBUG((LOG_NOTICE, "local IP address %s\n", inet_ntoa(go->ouraddr)));
|
IPCPDEBUG((LOG_NOTICE, "local IP address %s\n", inet_ntoa(go->ouraddr)));
|
||||||
IPCPDEBUG((LOG_NOTICE, "remote IP address %s\n", inet_ntoa(ho->hisaddr)));
|
IPCPDEBUG((LOG_NOTICE, "remote IP address %s\n", inet_ntoa(ho->hisaddr)));
|
||||||
@ -1280,7 +1335,8 @@ static void ipcp_up(fsm *f)
|
|||||||
* Take the IP network interface down, clear its addresses
|
* Take the IP network interface down, clear its addresses
|
||||||
* and delete routes through it.
|
* and delete routes through it.
|
||||||
*/
|
*/
|
||||||
static void ipcp_down(fsm *f)
|
static void
|
||||||
|
ipcp_down(fsm *f)
|
||||||
{
|
{
|
||||||
IPCPDEBUG((LOG_INFO, "ipcp: down\n"));
|
IPCPDEBUG((LOG_INFO, "ipcp: down\n"));
|
||||||
np_down(f->unit, PPP_IP);
|
np_down(f->unit, PPP_IP);
|
||||||
@ -1294,7 +1350,8 @@ static void ipcp_down(fsm *f)
|
|||||||
/*
|
/*
|
||||||
* ipcp_clear_addrs() - clear the interface addresses, routes, etc.
|
* ipcp_clear_addrs() - clear the interface addresses, routes, etc.
|
||||||
*/
|
*/
|
||||||
static void ipcp_clear_addrs(int unit)
|
static void
|
||||||
|
ipcp_clear_addrs(int unit)
|
||||||
{
|
{
|
||||||
u32_t ouraddr, hisaddr;
|
u32_t ouraddr, hisaddr;
|
||||||
|
|
||||||
@ -1311,18 +1368,15 @@ static void ipcp_clear_addrs(int unit)
|
|||||||
/*
|
/*
|
||||||
* ipcp_finished - possibly shut down the lower layers.
|
* ipcp_finished - possibly shut down the lower layers.
|
||||||
*/
|
*/
|
||||||
static void ipcp_finished(fsm *f)
|
static void
|
||||||
|
ipcp_finished(fsm *f)
|
||||||
{
|
{
|
||||||
np_finished(f->unit, PPP_IP);
|
np_finished(f->unit, PPP_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static int ipcp_printpkt(
|
static int
|
||||||
u_char *p,
|
ipcp_printpkt(u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg)
|
||||||
int plen,
|
|
||||||
void (*printer) (void *, char *, ...),
|
|
||||||
void *arg
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
LWIP_UNUSED_ARG(p);
|
LWIP_UNUSED_ARG(p);
|
||||||
LWIP_UNUSED_ARG(plen);
|
LWIP_UNUSED_ARG(plen);
|
||||||
@ -1354,25 +1408,31 @@ static int ipcp_printpkt(
|
|||||||
#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4)
|
#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4)
|
||||||
#define get_tcpflags(x) (((unsigned char *)(x))[13])
|
#define get_tcpflags(x) (((unsigned char *)(x))[13])
|
||||||
|
|
||||||
static int ip_active_pkt(u_char *pkt, int len)
|
static int
|
||||||
|
ip_active_pkt(u_char *pkt, int len)
|
||||||
{
|
{
|
||||||
u_char *tcp;
|
u_char *tcp;
|
||||||
int hlen;
|
int hlen;
|
||||||
|
|
||||||
len -= PPP_HDRLEN;
|
len -= PPP_HDRLEN;
|
||||||
pkt += PPP_HDRLEN;
|
pkt += PPP_HDRLEN;
|
||||||
if (len < IP_HDRLEN)
|
if (len < IP_HDRLEN) {
|
||||||
return 0;
|
return 0;
|
||||||
if ((get_ipoff(pkt) & IP_OFFMASK) != 0)
|
}
|
||||||
|
if ((get_ipoff(pkt) & IP_OFFMASK) != 0) {
|
||||||
return 0;
|
return 0;
|
||||||
if (get_ipproto(pkt) != IPPROTO_TCP)
|
}
|
||||||
|
if (get_ipproto(pkt) != IPPROTO_TCP) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
hlen = get_iphl(pkt) * 4;
|
hlen = get_iphl(pkt) * 4;
|
||||||
if (len < hlen + TCP_HDRLEN)
|
if (len < hlen + TCP_HDRLEN) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
tcp = pkt + hlen;
|
tcp = pkt + hlen;
|
||||||
if ((get_tcpflags(tcp) & TH_FIN) != 0 && len == hlen + get_tcpoff(tcp) * 4)
|
if ((get_tcpflags(tcp) & TH_FIN) != 0 && len == hlen + get_tcpoff(tcp) * 4) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: ipcp.h,v 1.2 2007/11/29 22:19:57 fbernon Exp $
|
* $Id: ipcp.h,v 1.3 2007/12/19 20:47:23 fbernon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IPCP_H
|
#ifndef IPCP_H
|
||||||
|
@ -127,8 +127,7 @@ static void LcpEchoCheck (fsm*);
|
|||||||
static void lcp_input (int, u_char *, int);
|
static void lcp_input (int, u_char *, int);
|
||||||
static void lcp_protrej (int);
|
static void lcp_protrej (int);
|
||||||
|
|
||||||
#define CODENAME(x) ((x) == CONFACK ? "ACK" : \
|
#define CODENAME(x) ((x) == CONFACK ? "ACK" : (x) == CONFNAK ? "NAK" : "REJ")
|
||||||
(x) == CONFNAK ? "NAK" : "REJ")
|
|
||||||
|
|
||||||
|
|
||||||
/******************************/
|
/******************************/
|
||||||
@ -206,7 +205,8 @@ int lcp_loopbackfail = DEFLOOPBACKFAIL;
|
|||||||
/*
|
/*
|
||||||
* lcp_init - Initialize LCP.
|
* lcp_init - Initialize LCP.
|
||||||
*/
|
*/
|
||||||
void lcp_init(int unit)
|
void
|
||||||
|
lcp_init(int unit)
|
||||||
{
|
{
|
||||||
fsm *f = &lcp_fsm[unit];
|
fsm *f = &lcp_fsm[unit];
|
||||||
lcp_options *wo = &lcp_wantoptions[unit];
|
lcp_options *wo = &lcp_wantoptions[unit];
|
||||||
@ -220,8 +220,7 @@ void lcp_init(int unit)
|
|||||||
|
|
||||||
wo->passive = 0;
|
wo->passive = 0;
|
||||||
wo->silent = 0;
|
wo->silent = 0;
|
||||||
wo->restart = 0; /* Set to 1 in kernels or multi-line
|
wo->restart = 0; /* Set to 1 in kernels or multi-line implementations */
|
||||||
* implementations */
|
|
||||||
wo->neg_mru = 1;
|
wo->neg_mru = 1;
|
||||||
wo->mru = PPP_DEFMRU;
|
wo->mru = PPP_DEFMRU;
|
||||||
wo->neg_asyncmap = 1;
|
wo->neg_asyncmap = 1;
|
||||||
@ -254,7 +253,7 @@ void lcp_init(int unit)
|
|||||||
*/
|
*/
|
||||||
memset(xmit_accm[unit], 0, sizeof(xmit_accm[0]));
|
memset(xmit_accm[unit], 0, sizeof(xmit_accm[0]));
|
||||||
xmit_accm[unit][15] = 0x60;
|
xmit_accm[unit][15] = 0x60;
|
||||||
xmit_accm[unit][0] = (u_char)(ao->asyncmap & 0xFF);
|
xmit_accm[unit][0] = (u_char)((ao->asyncmap & 0xFF));
|
||||||
xmit_accm[unit][1] = (u_char)((ao->asyncmap >> 8) & 0xFF);
|
xmit_accm[unit][1] = (u_char)((ao->asyncmap >> 8) & 0xFF);
|
||||||
xmit_accm[unit][2] = (u_char)((ao->asyncmap >> 16) & 0xFF);
|
xmit_accm[unit][2] = (u_char)((ao->asyncmap >> 16) & 0xFF);
|
||||||
xmit_accm[unit][3] = (u_char)((ao->asyncmap >> 24) & 0xFF);
|
xmit_accm[unit][3] = (u_char)((ao->asyncmap >> 24) & 0xFF);
|
||||||
@ -271,16 +270,19 @@ void lcp_init(int unit)
|
|||||||
/*
|
/*
|
||||||
* lcp_open - LCP is allowed to come up.
|
* lcp_open - LCP is allowed to come up.
|
||||||
*/
|
*/
|
||||||
void lcp_open(int unit)
|
void
|
||||||
|
lcp_open(int unit)
|
||||||
{
|
{
|
||||||
fsm *f = &lcp_fsm[unit];
|
fsm *f = &lcp_fsm[unit];
|
||||||
lcp_options *wo = &lcp_wantoptions[unit];
|
lcp_options *wo = &lcp_wantoptions[unit];
|
||||||
|
|
||||||
f->flags = 0;
|
f->flags = 0;
|
||||||
if (wo->passive)
|
if (wo->passive) {
|
||||||
f->flags |= OPT_PASSIVE;
|
f->flags |= OPT_PASSIVE;
|
||||||
if (wo->silent)
|
}
|
||||||
|
if (wo->silent) {
|
||||||
f->flags |= OPT_SILENT;
|
f->flags |= OPT_SILENT;
|
||||||
|
}
|
||||||
fsm_open(f);
|
fsm_open(f);
|
||||||
|
|
||||||
lcp_phase[unit] = PHASE_ESTABLISH;
|
lcp_phase[unit] = PHASE_ESTABLISH;
|
||||||
@ -290,12 +292,14 @@ void lcp_open(int unit)
|
|||||||
/*
|
/*
|
||||||
* lcp_close - Take LCP down.
|
* lcp_close - Take LCP down.
|
||||||
*/
|
*/
|
||||||
void lcp_close(int unit, char *reason)
|
void
|
||||||
|
lcp_close(int unit, char *reason)
|
||||||
{
|
{
|
||||||
fsm *f = &lcp_fsm[unit];
|
fsm *f = &lcp_fsm[unit];
|
||||||
|
|
||||||
if (lcp_phase[unit] != PHASE_DEAD)
|
if (lcp_phase[unit] != PHASE_DEAD) {
|
||||||
lcp_phase[unit] = PHASE_TERMINATE;
|
lcp_phase[unit] = PHASE_TERMINATE;
|
||||||
|
}
|
||||||
if (f->state == LS_STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) {
|
if (f->state == LS_STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) {
|
||||||
/*
|
/*
|
||||||
* This action is not strictly according to the FSM in RFC1548,
|
* This action is not strictly according to the FSM in RFC1548,
|
||||||
@ -305,16 +309,17 @@ void lcp_close(int unit, char *reason)
|
|||||||
*/
|
*/
|
||||||
f->state = LS_CLOSED;
|
f->state = LS_CLOSED;
|
||||||
lcp_finished(f);
|
lcp_finished(f);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
fsm_close(&lcp_fsm[unit], reason);
|
fsm_close(&lcp_fsm[unit], reason);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lcp_lowerup - The lower layer is up.
|
* lcp_lowerup - The lower layer is up.
|
||||||
*/
|
*/
|
||||||
void lcp_lowerup(int unit)
|
void
|
||||||
|
lcp_lowerup(int unit)
|
||||||
{
|
{
|
||||||
lcp_options *wo = &lcp_wantoptions[unit];
|
lcp_options *wo = &lcp_wantoptions[unit];
|
||||||
|
|
||||||
@ -328,8 +333,7 @@ void lcp_lowerup(int unit)
|
|||||||
ppp_recv_config(unit, PPP_MRU, 0x00000000l,
|
ppp_recv_config(unit, PPP_MRU, 0x00000000l,
|
||||||
wo->neg_pcompression, wo->neg_accompression);
|
wo->neg_pcompression, wo->neg_accompression);
|
||||||
peer_mru[unit] = PPP_MRU;
|
peer_mru[unit] = PPP_MRU;
|
||||||
lcp_allowoptions[unit].asyncmap
|
lcp_allowoptions[unit].asyncmap = (u_long)xmit_accm[unit][0]
|
||||||
= (u_long)xmit_accm[unit][0]
|
|
||||||
| ((u_long)xmit_accm[unit][1] << 8)
|
| ((u_long)xmit_accm[unit][1] << 8)
|
||||||
| ((u_long)xmit_accm[unit][2] << 16)
|
| ((u_long)xmit_accm[unit][2] << 16)
|
||||||
| ((u_long)xmit_accm[unit][3] << 24);
|
| ((u_long)xmit_accm[unit][3] << 24);
|
||||||
@ -346,7 +350,8 @@ void lcp_lowerup(int unit)
|
|||||||
/*
|
/*
|
||||||
* lcp_lowerdown - The lower layer is down.
|
* lcp_lowerdown - The lower layer is down.
|
||||||
*/
|
*/
|
||||||
void lcp_lowerdown(int unit)
|
void
|
||||||
|
lcp_lowerdown(int unit)
|
||||||
{
|
{
|
||||||
fsm_lowerdown(&lcp_fsm[unit]);
|
fsm_lowerdown(&lcp_fsm[unit]);
|
||||||
}
|
}
|
||||||
@ -354,15 +359,15 @@ void lcp_lowerdown(int unit)
|
|||||||
/*
|
/*
|
||||||
* lcp_sprotrej - Send a Protocol-Reject for some protocol.
|
* lcp_sprotrej - Send a Protocol-Reject for some protocol.
|
||||||
*/
|
*/
|
||||||
void lcp_sprotrej(int unit, u_char *p, int len)
|
void
|
||||||
|
lcp_sprotrej(int unit, u_char *p, int len)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Send back the protocol and the information field of the
|
* Send back the protocol and the information field of the
|
||||||
* rejected packet. We only get here if LCP is in the LS_OPENED state.
|
* rejected packet. We only get here if LCP is in the LS_OPENED state.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id,
|
fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id, p, len);
|
||||||
p, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -373,7 +378,8 @@ void lcp_sprotrej(int unit, u_char *p, int len)
|
|||||||
/*
|
/*
|
||||||
* lcp_input - Input LCP packet.
|
* lcp_input - Input LCP packet.
|
||||||
*/
|
*/
|
||||||
static void lcp_input(int unit, u_char *p, int len)
|
static void
|
||||||
|
lcp_input(int unit, u_char *p, int len)
|
||||||
{
|
{
|
||||||
fsm *f = &lcp_fsm[unit];
|
fsm *f = &lcp_fsm[unit];
|
||||||
|
|
||||||
@ -384,7 +390,8 @@ static void lcp_input(int unit, u_char *p, int len)
|
|||||||
/*
|
/*
|
||||||
* lcp_extcode - Handle a LCP-specific code.
|
* lcp_extcode - Handle a LCP-specific code.
|
||||||
*/
|
*/
|
||||||
static int lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len)
|
static int
|
||||||
|
lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len)
|
||||||
{
|
{
|
||||||
u_char *magp;
|
u_char *magp;
|
||||||
|
|
||||||
@ -394,8 +401,9 @@ static int lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ECHOREQ:
|
case ECHOREQ:
|
||||||
if (f->state != LS_OPENED)
|
if (f->state != LS_OPENED) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
LCPDEBUG((LOG_INFO, "lcp: Echo-Request, Rcvd id %d\n", id));
|
LCPDEBUG((LOG_INFO, "lcp: Echo-Request, Rcvd id %d\n", id));
|
||||||
magp = inp;
|
magp = inp;
|
||||||
PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp);
|
PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp);
|
||||||
@ -421,59 +429,56 @@ static int lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len)
|
|||||||
*
|
*
|
||||||
* Figure out which protocol is rejected and inform it.
|
* Figure out which protocol is rejected and inform it.
|
||||||
*/
|
*/
|
||||||
static void lcp_rprotrej(fsm *f, u_char *inp, int len)
|
static void
|
||||||
|
lcp_rprotrej(fsm *f, u_char *inp, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct protent *protp;
|
struct protent *protp;
|
||||||
u_short prot;
|
u_short prot;
|
||||||
|
|
||||||
if (len < sizeof (u_short)) {
|
if (len < sizeof (u_short)) {
|
||||||
LCPDEBUG((LOG_INFO,
|
LCPDEBUG((LOG_INFO, "lcp_rprotrej: Rcvd short Protocol-Reject packet!\n"));
|
||||||
"lcp_rprotrej: Rcvd short Protocol-Reject packet!\n"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GETSHORT(prot, inp);
|
GETSHORT(prot, inp);
|
||||||
|
|
||||||
LCPDEBUG((LOG_INFO,
|
LCPDEBUG((LOG_INFO, "lcp_rprotrej: Rcvd Protocol-Reject packet for %x!\n", prot));
|
||||||
"lcp_rprotrej: Rcvd Protocol-Reject packet for %x!\n",
|
|
||||||
prot));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Protocol-Reject packets received in any state other than the LCP
|
* Protocol-Reject packets received in any state other than the LCP
|
||||||
* LS_OPENED state SHOULD be silently discarded.
|
* LS_OPENED state SHOULD be silently discarded.
|
||||||
*/
|
*/
|
||||||
if( f->state != LS_OPENED ) {
|
if( f->state != LS_OPENED ) {
|
||||||
LCPDEBUG((LOG_INFO, "Protocol-Reject discarded: LCP in state %d\n",
|
LCPDEBUG((LOG_INFO, "Protocol-Reject discarded: LCP in state %d\n", f->state));
|
||||||
f->state));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Upcall the proper Protocol-Reject routine.
|
* Upcall the proper Protocol-Reject routine.
|
||||||
*/
|
*/
|
||||||
for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i)
|
for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) {
|
||||||
if (protp->protocol == prot && protp->enabled_flag) {
|
if (protp->protocol == prot && protp->enabled_flag) {
|
||||||
(*protp->protrej)(f->unit);
|
(*protp->protrej)(f->unit);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LCPDEBUG((LOG_WARNING, "Protocol-Reject for unsupported protocol 0x%x\n",
|
LCPDEBUG((LOG_WARNING, "Protocol-Reject for unsupported protocol 0x%x\n", prot));
|
||||||
prot));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lcp_protrej - A Protocol-Reject was received.
|
* lcp_protrej - A Protocol-Reject was received.
|
||||||
*/
|
*/
|
||||||
static void lcp_protrej(int unit)
|
static void
|
||||||
|
lcp_protrej(int unit)
|
||||||
{
|
{
|
||||||
LWIP_UNUSED_ARG(unit);
|
LWIP_UNUSED_ARG(unit);
|
||||||
/*
|
/*
|
||||||
* Can't reject LCP!
|
* Can't reject LCP!
|
||||||
*/
|
*/
|
||||||
LCPDEBUG((LOG_WARNING,
|
LCPDEBUG((LOG_WARNING, "lcp_protrej: Received Protocol-Reject for LCP!\n"));
|
||||||
"lcp_protrej: Received Protocol-Reject for LCP!\n"));
|
|
||||||
fsm_protreject(&lcp_fsm[unit]);
|
fsm_protreject(&lcp_fsm[unit]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,7 +486,8 @@ static void lcp_protrej(int unit)
|
|||||||
/*
|
/*
|
||||||
* lcp_resetci - Reset our CI.
|
* lcp_resetci - Reset our CI.
|
||||||
*/
|
*/
|
||||||
static void lcp_resetci(fsm *f)
|
static void
|
||||||
|
lcp_resetci(fsm *f)
|
||||||
{
|
{
|
||||||
lcp_wantoptions[f->unit].magicnumber = magic();
|
lcp_wantoptions[f->unit].magicnumber = magic();
|
||||||
lcp_wantoptions[f->unit].numloops = 0;
|
lcp_wantoptions[f->unit].numloops = 0;
|
||||||
@ -523,7 +529,8 @@ static int lcp_cilen(fsm *f)
|
|||||||
/*
|
/*
|
||||||
* lcp_addci - Add our desired CIs to a packet.
|
* lcp_addci - Add our desired CIs to a packet.
|
||||||
*/
|
*/
|
||||||
static void lcp_addci(fsm *f, u_char *ucp, int *lenp)
|
static void
|
||||||
|
lcp_addci(fsm *f, u_char *ucp, int *lenp)
|
||||||
{
|
{
|
||||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||||
u_char *start_ucp = ucp;
|
u_char *start_ucp = ucp;
|
||||||
@ -573,8 +580,7 @@ static void lcp_addci(fsm *f, u_char *ucp, int *lenp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ADDCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru);
|
ADDCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru);
|
||||||
ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl,
|
ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap);
|
||||||
go->asyncmap);
|
|
||||||
ADDCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
|
ADDCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
|
||||||
ADDCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
|
ADDCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
|
||||||
ADDCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
|
ADDCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
|
||||||
@ -598,7 +604,8 @@ static void lcp_addci(fsm *f, u_char *ucp, int *lenp)
|
|||||||
* 0 - Ack was bad.
|
* 0 - Ack was bad.
|
||||||
* 1 - Ack was good.
|
* 1 - Ack was good.
|
||||||
*/
|
*/
|
||||||
static int lcp_ackci(fsm *f, u_char *p, int len)
|
static int
|
||||||
|
lcp_ackci(fsm *f, u_char *p, int len)
|
||||||
{
|
{
|
||||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||||
u_char cilen, citype, cichar;
|
u_char cilen, citype, cichar;
|
||||||
@ -616,8 +623,7 @@ static int lcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
goto bad; \
|
goto bad; \
|
||||||
GETCHAR(citype, p); \
|
GETCHAR(citype, p); \
|
||||||
GETCHAR(cilen, p); \
|
GETCHAR(cilen, p); \
|
||||||
if (cilen != CILEN_VOID || \
|
if (cilen != CILEN_VOID || citype != opt) \
|
||||||
citype != opt) \
|
|
||||||
goto bad; \
|
goto bad; \
|
||||||
}
|
}
|
||||||
#define ACKCISHORT(opt, neg, val) \
|
#define ACKCISHORT(opt, neg, val) \
|
||||||
@ -626,8 +632,7 @@ static int lcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
goto bad; \
|
goto bad; \
|
||||||
GETCHAR(citype, p); \
|
GETCHAR(citype, p); \
|
||||||
GETCHAR(cilen, p); \
|
GETCHAR(cilen, p); \
|
||||||
if (cilen != CILEN_SHORT || \
|
if (cilen != CILEN_SHORT || citype != opt) \
|
||||||
citype != opt) \
|
|
||||||
goto bad; \
|
goto bad; \
|
||||||
GETSHORT(cishort, p); \
|
GETSHORT(cishort, p); \
|
||||||
if (cishort != val) \
|
if (cishort != val) \
|
||||||
@ -639,8 +644,7 @@ static int lcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
goto bad; \
|
goto bad; \
|
||||||
GETCHAR(citype, p); \
|
GETCHAR(citype, p); \
|
||||||
GETCHAR(cilen, p); \
|
GETCHAR(cilen, p); \
|
||||||
if (cilen != CILEN_CHAR || \
|
if (cilen != CILEN_CHAR || citype != opt) \
|
||||||
citype != opt) \
|
|
||||||
goto bad; \
|
goto bad; \
|
||||||
GETCHAR(cichar, p); \
|
GETCHAR(cichar, p); \
|
||||||
if (cichar != val) \
|
if (cichar != val) \
|
||||||
@ -652,8 +656,7 @@ static int lcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
goto bad; \
|
goto bad; \
|
||||||
GETCHAR(citype, p); \
|
GETCHAR(citype, p); \
|
||||||
GETCHAR(cilen, p); \
|
GETCHAR(cilen, p); \
|
||||||
if (cilen != CILEN_CHAP || \
|
if (cilen != CILEN_CHAP || citype != opt) \
|
||||||
citype != opt) \
|
|
||||||
goto bad; \
|
goto bad; \
|
||||||
GETSHORT(cishort, p); \
|
GETSHORT(cishort, p); \
|
||||||
if (cishort != val) \
|
if (cishort != val) \
|
||||||
@ -668,8 +671,7 @@ static int lcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
goto bad; \
|
goto bad; \
|
||||||
GETCHAR(citype, p); \
|
GETCHAR(citype, p); \
|
||||||
GETCHAR(cilen, p); \
|
GETCHAR(cilen, p); \
|
||||||
if (cilen != CILEN_LONG || \
|
if (cilen != CILEN_LONG || citype != opt) \
|
||||||
citype != opt) \
|
|
||||||
goto bad; \
|
goto bad; \
|
||||||
GETLONG(cilong, p); \
|
GETLONG(cilong, p); \
|
||||||
if (cilong != val) \
|
if (cilong != val) \
|
||||||
@ -681,8 +683,7 @@ static int lcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
goto bad; \
|
goto bad; \
|
||||||
GETCHAR(citype, p); \
|
GETCHAR(citype, p); \
|
||||||
GETCHAR(cilen, p); \
|
GETCHAR(cilen, p); \
|
||||||
if (cilen != CILEN_LQR || \
|
if (cilen != CILEN_LQR || citype != opt) \
|
||||||
citype != opt) \
|
|
||||||
goto bad; \
|
goto bad; \
|
||||||
GETSHORT(cishort, p); \
|
GETSHORT(cishort, p); \
|
||||||
if (cishort != PPP_LQR) \
|
if (cishort != PPP_LQR) \
|
||||||
@ -693,8 +694,7 @@ static int lcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ACKCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru);
|
ACKCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru);
|
||||||
ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl,
|
ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap);
|
||||||
go->asyncmap);
|
|
||||||
ACKCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
|
ACKCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
|
||||||
ACKCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
|
ACKCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
|
||||||
ACKCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
|
ACKCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
|
||||||
@ -706,8 +706,9 @@ static int lcp_ackci(fsm *f, u_char *p, int len)
|
|||||||
/*
|
/*
|
||||||
* If there are any remaining CIs, then this packet is bad.
|
* If there are any remaining CIs, then this packet is bad.
|
||||||
*/
|
*/
|
||||||
if (len != 0)
|
if (len != 0) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
LCPDEBUG((LOG_INFO, "lcp_acki: Ack\n"));
|
LCPDEBUG((LOG_INFO, "lcp_acki: Ack\n"));
|
||||||
return (1);
|
return (1);
|
||||||
bad:
|
bad:
|
||||||
@ -725,7 +726,8 @@ bad:
|
|||||||
* 0 - Nak was bad.
|
* 0 - Nak was bad.
|
||||||
* 1 - Nak was good.
|
* 1 - Nak was good.
|
||||||
*/
|
*/
|
||||||
static int lcp_nakci(fsm *f, u_char *p, int len)
|
static int
|
||||||
|
lcp_nakci(fsm *f, u_char *p, int len)
|
||||||
{
|
{
|
||||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||||
lcp_options *wo = &lcp_wantoptions[f->unit];
|
lcp_options *wo = &lcp_wantoptions[f->unit];
|
||||||
@ -822,8 +824,9 @@ static int lcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
*/
|
*/
|
||||||
if (go->neg_mru && go->mru != PPP_DEFMRU) {
|
if (go->neg_mru && go->mru != PPP_DEFMRU) {
|
||||||
NAKCISHORT(CI_MRU, neg_mru,
|
NAKCISHORT(CI_MRU, neg_mru,
|
||||||
if (cishort <= wo->mru || cishort < PPP_DEFMRU)
|
if (cishort <= wo->mru || cishort < PPP_DEFMRU) {
|
||||||
try.mru = cishort;
|
try.mru = cishort;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,8 +859,9 @@ static int lcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
* If we weren't asking for CHAP, then we were asking for PAP,
|
* If we weren't asking for CHAP, then we were asking for PAP,
|
||||||
* in which case this Nak is bad.
|
* in which case this Nak is bad.
|
||||||
*/
|
*/
|
||||||
if (!go->neg_chap)
|
if (!go->neg_chap) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
try.neg_chap = 0;
|
try.neg_chap = 0;
|
||||||
|
|
||||||
} else if (cishort == PPP_CHAP && cilen == CILEN_CHAP) {
|
} else if (cishort == PPP_CHAP && cilen == CILEN_CHAP) {
|
||||||
@ -868,8 +872,9 @@ static int lcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
* algorithm. If they can't do MD5, we'll have to stop
|
* algorithm. If they can't do MD5, we'll have to stop
|
||||||
* asking for CHAP.
|
* asking for CHAP.
|
||||||
*/
|
*/
|
||||||
if (cichar != go->chap_mdtype)
|
if (cichar != go->chap_mdtype) {
|
||||||
try.neg_chap = 0;
|
try.neg_chap = 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Stop asking for PAP if we were asking for it.
|
* Stop asking for PAP if we were asking for it.
|
||||||
@ -882,10 +887,11 @@ static int lcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
* We don't recognize what they're suggesting.
|
* We don't recognize what they're suggesting.
|
||||||
* Stop asking for what we were asking for.
|
* Stop asking for what we were asking for.
|
||||||
*/
|
*/
|
||||||
if (go->neg_chap)
|
if (go->neg_chap) {
|
||||||
try.neg_chap = 0;
|
try.neg_chap = 0;
|
||||||
else
|
} else {
|
||||||
try.neg_upap = 0;
|
try.neg_upap = 0;
|
||||||
|
}
|
||||||
p += cilen - CILEN_SHORT;
|
p += cilen - CILEN_SHORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -896,10 +902,11 @@ static int lcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
* If they Nak the reporting period, take their value XXX ?
|
* If they Nak the reporting period, take their value XXX ?
|
||||||
*/
|
*/
|
||||||
NAKCILQR(CI_QUALITY, neg_lqr,
|
NAKCILQR(CI_QUALITY, neg_lqr,
|
||||||
if (cishort != PPP_LQR)
|
if (cishort != PPP_LQR) {
|
||||||
try.neg_lqr = 0;
|
try.neg_lqr = 0;
|
||||||
else
|
} else {
|
||||||
try.lqr_period = cilong;
|
try.lqr_period = cilong;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -948,54 +955,64 @@ static int lcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
while (len > CILEN_VOID) {
|
while (len > CILEN_VOID) {
|
||||||
GETCHAR(citype, p);
|
GETCHAR(citype, p);
|
||||||
GETCHAR(cilen, p);
|
GETCHAR(cilen, p);
|
||||||
if (cilen < CILEN_VOID || (len -= cilen) < 0)
|
if (cilen < CILEN_VOID || (len -= cilen) < 0) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
next = p + cilen - 2;
|
next = p + cilen - 2;
|
||||||
|
|
||||||
switch (citype) {
|
switch (citype) {
|
||||||
case CI_MRU:
|
case CI_MRU:
|
||||||
if ((go->neg_mru && go->mru != PPP_DEFMRU)
|
if ((go->neg_mru && go->mru != PPP_DEFMRU)
|
||||||
|| no.neg_mru || cilen != CILEN_SHORT)
|
|| no.neg_mru || cilen != CILEN_SHORT) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
GETSHORT(cishort, p);
|
GETSHORT(cishort, p);
|
||||||
if (cishort < PPP_DEFMRU)
|
if (cishort < PPP_DEFMRU) {
|
||||||
try.mru = cishort;
|
try.mru = cishort;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CI_ASYNCMAP:
|
case CI_ASYNCMAP:
|
||||||
if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl)
|
if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl)
|
||||||
|| no.neg_asyncmap || cilen != CILEN_LONG)
|
|| no.neg_asyncmap || cilen != CILEN_LONG) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CI_AUTHTYPE:
|
case CI_AUTHTYPE:
|
||||||
if (go->neg_chap || no.neg_chap || go->neg_upap || no.neg_upap)
|
if (go->neg_chap || no.neg_chap || go->neg_upap || no.neg_upap) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CI_MAGICNUMBER:
|
case CI_MAGICNUMBER:
|
||||||
if (go->neg_magicnumber || no.neg_magicnumber ||
|
if (go->neg_magicnumber || no.neg_magicnumber ||
|
||||||
cilen != CILEN_LONG)
|
cilen != CILEN_LONG) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CI_PCOMPRESSION:
|
case CI_PCOMPRESSION:
|
||||||
if (go->neg_pcompression || no.neg_pcompression
|
if (go->neg_pcompression || no.neg_pcompression
|
||||||
|| cilen != CILEN_VOID)
|
|| cilen != CILEN_VOID) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CI_ACCOMPRESSION:
|
case CI_ACCOMPRESSION:
|
||||||
if (go->neg_accompression || no.neg_accompression
|
if (go->neg_accompression || no.neg_accompression
|
||||||
|| cilen != CILEN_VOID)
|
|| cilen != CILEN_VOID) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CI_QUALITY:
|
case CI_QUALITY:
|
||||||
if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR)
|
if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
p = next;
|
p = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there is still anything left, this packet is bad. */
|
/* If there is still anything left, this packet is bad. */
|
||||||
if (len != 0)
|
if (len != 0) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OK, the Nak is good. Now we can update state.
|
* OK, the Nak is good. Now we can update state.
|
||||||
@ -1006,9 +1023,9 @@ static int lcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
LCPDEBUG((LOG_NOTICE, "Serial line is looped back.\n"));
|
LCPDEBUG((LOG_NOTICE, "Serial line is looped back.\n"));
|
||||||
lcp_close(f->unit, "Loopback detected");
|
lcp_close(f->unit, "Loopback detected");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
try.numloops = 0;
|
try.numloops = 0;
|
||||||
|
}
|
||||||
*go = try;
|
*go = try;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1029,7 +1046,8 @@ bad:
|
|||||||
* 0 - Reject was bad.
|
* 0 - Reject was bad.
|
||||||
* 1 - Reject was good.
|
* 1 - Reject was good.
|
||||||
*/
|
*/
|
||||||
static int lcp_rejci(fsm *f, u_char *p, int len)
|
static int
|
||||||
|
lcp_rejci(fsm *f, u_char *p, int len)
|
||||||
{
|
{
|
||||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||||
u_char cichar;
|
u_char cichar;
|
||||||
@ -1063,8 +1081,9 @@ static int lcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
INCPTR(2, p); \
|
INCPTR(2, p); \
|
||||||
GETSHORT(cishort, p); \
|
GETSHORT(cishort, p); \
|
||||||
/* Check rejected value. */ \
|
/* Check rejected value. */ \
|
||||||
if (cishort != val) \
|
if (cishort != val) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
try.neg = 0; \
|
try.neg = 0; \
|
||||||
LCPDEBUG((LOG_INFO,"lcp_rejci: short opt %d rejected\n", opt)); \
|
LCPDEBUG((LOG_INFO,"lcp_rejci: short opt %d rejected\n", opt)); \
|
||||||
}
|
}
|
||||||
@ -1078,8 +1097,9 @@ static int lcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
GETSHORT(cishort, p); \
|
GETSHORT(cishort, p); \
|
||||||
GETCHAR(cichar, p); \
|
GETCHAR(cichar, p); \
|
||||||
/* Check rejected value. */ \
|
/* Check rejected value. */ \
|
||||||
if (cishort != val || cichar != digest) \
|
if (cishort != val || cichar != digest) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
try.neg = 0; \
|
try.neg = 0; \
|
||||||
try.neg_upap = 0; \
|
try.neg_upap = 0; \
|
||||||
LCPDEBUG((LOG_INFO,"lcp_rejci: chap opt %d rejected\n", opt)); \
|
LCPDEBUG((LOG_INFO,"lcp_rejci: chap opt %d rejected\n", opt)); \
|
||||||
@ -1093,8 +1113,9 @@ static int lcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
INCPTR(2, p); \
|
INCPTR(2, p); \
|
||||||
GETLONG(cilong, p); \
|
GETLONG(cilong, p); \
|
||||||
/* Check rejected value. */ \
|
/* Check rejected value. */ \
|
||||||
if (cilong != val) \
|
if (cilong != val) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
try.neg = 0; \
|
try.neg = 0; \
|
||||||
LCPDEBUG((LOG_INFO,"lcp_rejci: long opt %d rejected\n", opt)); \
|
LCPDEBUG((LOG_INFO,"lcp_rejci: long opt %d rejected\n", opt)); \
|
||||||
}
|
}
|
||||||
@ -1108,8 +1129,9 @@ static int lcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
GETSHORT(cishort, p); \
|
GETSHORT(cishort, p); \
|
||||||
GETLONG(cilong, p); \
|
GETLONG(cilong, p); \
|
||||||
/* Check rejected value. */ \
|
/* Check rejected value. */ \
|
||||||
if (cishort != PPP_LQR || cilong != val) \
|
if (cishort != PPP_LQR || cilong != val) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
try.neg = 0; \
|
try.neg = 0; \
|
||||||
LCPDEBUG((LOG_INFO,"lcp_rejci: LQR opt %d rejected\n", opt)); \
|
LCPDEBUG((LOG_INFO,"lcp_rejci: LQR opt %d rejected\n", opt)); \
|
||||||
}
|
}
|
||||||
@ -1122,8 +1144,9 @@ static int lcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
INCPTR(2, p); \
|
INCPTR(2, p); \
|
||||||
GETCHAR(cichar, p); \
|
GETCHAR(cichar, p); \
|
||||||
/* Check rejected value. */ \
|
/* Check rejected value. */ \
|
||||||
if (cichar != val) \
|
if (cichar != val) { \
|
||||||
goto bad; \
|
goto bad; \
|
||||||
|
} \
|
||||||
try.neg = 0; \
|
try.neg = 0; \
|
||||||
LCPDEBUG((LOG_INFO,"lcp_rejci: Callback opt %d rejected\n", opt)); \
|
LCPDEBUG((LOG_INFO,"lcp_rejci: Callback opt %d rejected\n", opt)); \
|
||||||
}
|
}
|
||||||
@ -1143,13 +1166,15 @@ static int lcp_rejci(fsm *f, u_char *p, int len)
|
|||||||
/*
|
/*
|
||||||
* If there are any remaining CIs, then this packet is bad.
|
* If there are any remaining CIs, then this packet is bad.
|
||||||
*/
|
*/
|
||||||
if (len != 0)
|
if (len != 0) {
|
||||||
goto bad;
|
goto bad;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Now we can update state.
|
* Now we can update state.
|
||||||
*/
|
*/
|
||||||
if (f->state != LS_OPENED)
|
if (f->state != LS_OPENED) {
|
||||||
*go = try;
|
*go = try;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
@ -1165,7 +1190,8 @@ bad:
|
|||||||
* appropriately. If reject_if_disagree is non-zero, doesn't return
|
* appropriately. If reject_if_disagree is non-zero, doesn't return
|
||||||
* CONFNAK; returns CONFREJ if it can't return CONFACK.
|
* CONFNAK; returns CONFREJ if it can't return CONFACK.
|
||||||
*/
|
*/
|
||||||
static int lcp_reqci(fsm *f,
|
static int
|
||||||
|
lcp_reqci(fsm *f,
|
||||||
u_char *inp, /* Requested CIs */
|
u_char *inp, /* Requested CIs */
|
||||||
int *lenp, /* Length of requested CIs */
|
int *lenp, /* Length of requested CIs */
|
||||||
int reject_if_disagree)
|
int reject_if_disagree)
|
||||||
@ -1389,8 +1415,7 @@ static int lcp_reqci(fsm *f,
|
|||||||
PUTCHAR(CILEN_CHAP, nakp);
|
PUTCHAR(CILEN_CHAP, nakp);
|
||||||
PUTSHORT(PPP_CHAP, nakp);
|
PUTSHORT(PPP_CHAP, nakp);
|
||||||
PUTCHAR(ao->chap_mdtype, nakp);
|
PUTCHAR(ao->chap_mdtype, nakp);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
LCPDEBUG((LOG_WARNING, "lcp_reqci: Nak AUTHTYPE %d req PAP\n", cishort));
|
LCPDEBUG((LOG_WARNING, "lcp_reqci: Nak AUTHTYPE %d req PAP\n", cishort));
|
||||||
PUTCHAR(CILEN_SHORT, nakp);
|
PUTCHAR(CILEN_SHORT, nakp);
|
||||||
PUTSHORT(PPP_PAP, nakp);
|
PUTSHORT(PPP_PAP, nakp);
|
||||||
@ -1521,24 +1546,26 @@ static int lcp_reqci(fsm *f,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (orc == CONFACK && /* Good CI */
|
if (orc == CONFACK && /* Good CI */
|
||||||
rc != CONFACK) /* but prior CI wasnt? */
|
rc != CONFACK) { /* but prior CI wasnt? */
|
||||||
continue; /* Don't send this one */
|
continue; /* Don't send this one */
|
||||||
|
}
|
||||||
|
|
||||||
if (orc == CONFNAK) { /* Nak this CI? */
|
if (orc == CONFNAK) { /* Nak this CI? */
|
||||||
if (reject_if_disagree /* Getting fed up with sending NAKs? */
|
if (reject_if_disagree /* Getting fed up with sending NAKs? */
|
||||||
&& citype != CI_MAGICNUMBER) {
|
&& citype != CI_MAGICNUMBER) {
|
||||||
orc = CONFREJ; /* Get tough if so */
|
orc = CONFREJ; /* Get tough if so */
|
||||||
}
|
} else {
|
||||||
else {
|
if (rc == CONFREJ) { /* Rejecting prior CI? */
|
||||||
if (rc == CONFREJ) /* Rejecting prior CI? */
|
|
||||||
continue; /* Don't send this one */
|
continue; /* Don't send this one */
|
||||||
|
}
|
||||||
rc = CONFNAK;
|
rc = CONFNAK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (orc == CONFREJ) { /* Reject this CI */
|
if (orc == CONFREJ) { /* Reject this CI */
|
||||||
rc = CONFREJ;
|
rc = CONFREJ;
|
||||||
if (cip != rejp) /* Need to move rejected CI? */
|
if (cip != rejp) { /* Need to move rejected CI? */
|
||||||
BCOPY(cip, rejp, cilen); /* Move it */
|
BCOPY(cip, rejp, cilen); /* Move it */
|
||||||
|
}
|
||||||
INCPTR(cilen, rejp); /* Update output pointer */
|
INCPTR(cilen, rejp); /* Update output pointer */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1579,17 +1606,20 @@ static int lcp_reqci(fsm *f,
|
|||||||
/*
|
/*
|
||||||
* lcp_up - LCP has come UP.
|
* lcp_up - LCP has come UP.
|
||||||
*/
|
*/
|
||||||
static void lcp_up(fsm *f)
|
static void
|
||||||
|
lcp_up(fsm *f)
|
||||||
{
|
{
|
||||||
lcp_options *wo = &lcp_wantoptions[f->unit];
|
lcp_options *wo = &lcp_wantoptions[f->unit];
|
||||||
lcp_options *ho = &lcp_hisoptions[f->unit];
|
lcp_options *ho = &lcp_hisoptions[f->unit];
|
||||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||||
lcp_options *ao = &lcp_allowoptions[f->unit];
|
lcp_options *ao = &lcp_allowoptions[f->unit];
|
||||||
|
|
||||||
if (!go->neg_magicnumber)
|
if (!go->neg_magicnumber) {
|
||||||
go->magicnumber = 0;
|
go->magicnumber = 0;
|
||||||
if (!ho->neg_magicnumber)
|
}
|
||||||
|
if (!ho->neg_magicnumber) {
|
||||||
ho->magicnumber = 0;
|
ho->magicnumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set our MTU to the smaller of the MTU we wanted and
|
* Set our MTU to the smaller of the MTU we wanted and
|
||||||
@ -1609,8 +1639,9 @@ static void lcp_up(fsm *f)
|
|||||||
(go->neg_asyncmap? go->asyncmap: 0x00000000),
|
(go->neg_asyncmap? go->asyncmap: 0x00000000),
|
||||||
go->neg_pcompression, go->neg_accompression);
|
go->neg_pcompression, go->neg_accompression);
|
||||||
|
|
||||||
if (ho->neg_mru)
|
if (ho->neg_mru) {
|
||||||
peer_mru[f->unit] = ho->mru;
|
peer_mru[f->unit] = ho->mru;
|
||||||
|
}
|
||||||
|
|
||||||
lcp_echo_lowerup(f->unit); /* Enable echo messages */
|
lcp_echo_lowerup(f->unit); /* Enable echo messages */
|
||||||
|
|
||||||
@ -1623,7 +1654,8 @@ static void lcp_up(fsm *f)
|
|||||||
*
|
*
|
||||||
* Alert other protocols.
|
* Alert other protocols.
|
||||||
*/
|
*/
|
||||||
static void lcp_down(fsm *f)
|
static void
|
||||||
|
lcp_down(fsm *f)
|
||||||
{
|
{
|
||||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||||
|
|
||||||
@ -1642,7 +1674,8 @@ static void lcp_down(fsm *f)
|
|||||||
/*
|
/*
|
||||||
* lcp_starting - LCP needs the lower layer up.
|
* lcp_starting - LCP needs the lower layer up.
|
||||||
*/
|
*/
|
||||||
static void lcp_starting(fsm *f)
|
static void
|
||||||
|
lcp_starting(fsm *f)
|
||||||
{
|
{
|
||||||
link_required(f->unit);
|
link_required(f->unit);
|
||||||
}
|
}
|
||||||
@ -1651,7 +1684,8 @@ static void lcp_starting(fsm *f)
|
|||||||
/*
|
/*
|
||||||
* lcp_finished - LCP has finished with the lower layer.
|
* lcp_finished - LCP has finished with the lower layer.
|
||||||
*/
|
*/
|
||||||
static void lcp_finished(fsm *f)
|
static void
|
||||||
|
lcp_finished(fsm *f)
|
||||||
{
|
{
|
||||||
link_terminated(f->unit);
|
link_terminated(f->unit);
|
||||||
}
|
}
|
||||||
@ -1662,12 +1696,8 @@ static void lcp_finished(fsm *f)
|
|||||||
* print_string - print a readable representation of a string using
|
* print_string - print a readable representation of a string using
|
||||||
* printer.
|
* printer.
|
||||||
*/
|
*/
|
||||||
static void print_string(
|
static void
|
||||||
char *p,
|
print_string( char *p, int len, void (*printer) (void *, char *, ...), void *arg)
|
||||||
int len,
|
|
||||||
void (*printer) (void *, char *, ...),
|
|
||||||
void *arg
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
@ -1675,8 +1705,9 @@ static void print_string(
|
|||||||
for (; len > 0; --len) {
|
for (; len > 0; --len) {
|
||||||
c = *p++;
|
c = *p++;
|
||||||
if (' ' <= c && c <= '~') {
|
if (' ' <= c && c <= '~') {
|
||||||
if (c == '\\' || c == '"')
|
if (c == '\\' || c == '"') {
|
||||||
printer(arg, "\\");
|
printer(arg, "\\");
|
||||||
|
}
|
||||||
printer(arg, "%c", c);
|
printer(arg, "%c", c);
|
||||||
} else {
|
} else {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -1707,31 +1738,30 @@ static char *lcp_codenames[] = {
|
|||||||
"EchoReq", "EchoRep", "DiscReq"
|
"EchoReq", "EchoRep", "DiscReq"
|
||||||
};
|
};
|
||||||
|
|
||||||
static int lcp_printpkt(
|
static int
|
||||||
u_char *p,
|
lcp_printpkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg)
|
||||||
int plen,
|
|
||||||
void (*printer) (void *, char *, ...),
|
|
||||||
void *arg
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
int code, id, len, olen;
|
int code, id, len, olen;
|
||||||
u_char *pstart, *optend;
|
u_char *pstart, *optend;
|
||||||
u_short cishort;
|
u_short cishort;
|
||||||
u32_t cilong;
|
u32_t cilong;
|
||||||
|
|
||||||
if (plen < HEADERLEN)
|
if (plen < HEADERLEN) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
pstart = p;
|
pstart = p;
|
||||||
GETCHAR(code, p);
|
GETCHAR(code, p);
|
||||||
GETCHAR(id, p);
|
GETCHAR(id, p);
|
||||||
GETSHORT(len, p);
|
GETSHORT(len, p);
|
||||||
if (len < HEADERLEN || len > plen)
|
if (len < HEADERLEN || len > plen) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (code >= 1 && code <= sizeof(lcp_codenames) / sizeof(char *))
|
if (code >= 1 && code <= sizeof(lcp_codenames) / sizeof(char *)) {
|
||||||
printer(arg, " %s", lcp_codenames[code-1]);
|
printer(arg, " %s", lcp_codenames[code-1]);
|
||||||
else
|
} else {
|
||||||
printer(arg, " code=0x%x", code);
|
printer(arg, " code=0x%x", code);
|
||||||
|
}
|
||||||
printer(arg, " id=0x%x", id);
|
printer(arg, " id=0x%x", id);
|
||||||
len -= HEADERLEN;
|
len -= HEADERLEN;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
@ -1873,8 +1903,8 @@ static int lcp_printpkt(
|
|||||||
/*
|
/*
|
||||||
* Time to shut down the link because there is nothing out there.
|
* Time to shut down the link because there is nothing out there.
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
static void LcpLinkFailure (fsm *f)
|
LcpLinkFailure (fsm *f)
|
||||||
{
|
{
|
||||||
if (f->state == LS_OPENED) {
|
if (f->state == LS_OPENED) {
|
||||||
LCPDEBUG((LOG_INFO, "No response to %d echo-requests\n", lcp_echos_pending));
|
LCPDEBUG((LOG_INFO, "No response to %d echo-requests\n", lcp_echos_pending));
|
||||||
@ -1886,8 +1916,8 @@ static void LcpLinkFailure (fsm *f)
|
|||||||
/*
|
/*
|
||||||
* Timer expired for the LCP echo requests from this process.
|
* Timer expired for the LCP echo requests from this process.
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
static void LcpEchoCheck (fsm *f)
|
LcpEchoCheck (fsm *f)
|
||||||
{
|
{
|
||||||
LcpSendEchoRequest (f);
|
LcpSendEchoRequest (f);
|
||||||
|
|
||||||
@ -1903,8 +1933,8 @@ static void LcpEchoCheck (fsm *f)
|
|||||||
/*
|
/*
|
||||||
* LcpEchoTimeout - Timer expired on the LCP echo
|
* LcpEchoTimeout - Timer expired on the LCP echo
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
static void LcpEchoTimeout (void *arg)
|
LcpEchoTimeout (void *arg)
|
||||||
{
|
{
|
||||||
if (lcp_echo_timer_running != 0) {
|
if (lcp_echo_timer_running != 0) {
|
||||||
lcp_echo_timer_running = 0;
|
lcp_echo_timer_running = 0;
|
||||||
@ -1915,7 +1945,8 @@ static void LcpEchoTimeout (void *arg)
|
|||||||
/*
|
/*
|
||||||
* LcpEchoReply - LCP has received a reply to the echo
|
* LcpEchoReply - LCP has received a reply to the echo
|
||||||
*/
|
*/
|
||||||
static void lcp_received_echo_reply (fsm *f, int id, u_char *inp, int len)
|
static void
|
||||||
|
lcp_received_echo_reply (fsm *f, int id, u_char *inp, int len)
|
||||||
{
|
{
|
||||||
u32_t magic;
|
u32_t magic;
|
||||||
|
|
||||||
@ -1927,8 +1958,7 @@ static void lcp_received_echo_reply (fsm *f, int id, u_char *inp, int len)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GETLONG(magic, inp);
|
GETLONG(magic, inp);
|
||||||
if (lcp_gotoptions[f->unit].neg_magicnumber
|
if (lcp_gotoptions[f->unit].neg_magicnumber && magic == lcp_gotoptions[f->unit].magicnumber) {
|
||||||
&& magic == lcp_gotoptions[f->unit].magicnumber) {
|
|
||||||
LCPDEBUG((LOG_WARNING, "appear to have received our own echo-reply!\n"));
|
LCPDEBUG((LOG_WARNING, "appear to have received our own echo-reply!\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1940,8 +1970,8 @@ static void lcp_received_echo_reply (fsm *f, int id, u_char *inp, int len)
|
|||||||
/*
|
/*
|
||||||
* LcpSendEchoRequest - Send an echo request frame to the peer
|
* LcpSendEchoRequest - Send an echo request frame to the peer
|
||||||
*/
|
*/
|
||||||
|
static void
|
||||||
static void LcpSendEchoRequest (fsm *f)
|
LcpSendEchoRequest (fsm *f)
|
||||||
{
|
{
|
||||||
u32_t lcp_magic;
|
u32_t lcp_magic;
|
||||||
u_char pkt[4], *pktp;
|
u_char pkt[4], *pktp;
|
||||||
@ -1971,7 +2001,8 @@ static void LcpSendEchoRequest (fsm *f)
|
|||||||
* lcp_echo_lowerup - Start the timer for the LCP frame
|
* lcp_echo_lowerup - Start the timer for the LCP frame
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void lcp_echo_lowerup (int unit)
|
static void
|
||||||
|
lcp_echo_lowerup (int unit)
|
||||||
{
|
{
|
||||||
fsm *f = &lcp_fsm[unit];
|
fsm *f = &lcp_fsm[unit];
|
||||||
|
|
||||||
@ -1981,15 +2012,17 @@ static void lcp_echo_lowerup (int unit)
|
|||||||
lcp_echo_timer_running = 0;
|
lcp_echo_timer_running = 0;
|
||||||
|
|
||||||
/* If a timeout interval is specified then start the timer */
|
/* If a timeout interval is specified then start the timer */
|
||||||
if (lcp_echo_interval != 0)
|
if (lcp_echo_interval != 0) {
|
||||||
LcpEchoCheck (f);
|
LcpEchoCheck (f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lcp_echo_lowerdown - Stop the timer for the LCP frame
|
* lcp_echo_lowerdown - Stop the timer for the LCP frame
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void lcp_echo_lowerdown (int unit)
|
static void
|
||||||
|
lcp_echo_lowerdown (int unit)
|
||||||
{
|
{
|
||||||
fsm *f = &lcp_fsm[unit];
|
fsm *f = &lcp_fsm[unit];
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* $Id: lcp.h,v 1.2 2007/11/29 22:19:57 fbernon Exp $
|
* $Id: lcp.h,v 1.3 2007/12/19 20:47:23 fbernon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LCP_H
|
#ifndef LCP_H
|
||||||
|
@ -82,8 +82,6 @@ static void upap_sauthreq (upap_state *);
|
|||||||
static void upap_sresp (upap_state *, u_char, u_char, char *, int);
|
static void upap_sresp (upap_state *, u_char, u_char, char *, int);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************/
|
/******************************/
|
||||||
/*** PUBLIC DATA STRUCTURES ***/
|
/*** PUBLIC DATA STRUCTURES ***/
|
||||||
/******************************/
|
/******************************/
|
||||||
@ -119,7 +117,8 @@ upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */
|
|||||||
/*
|
/*
|
||||||
* Set the default login name and password for the pap sessions
|
* Set the default login name and password for the pap sessions
|
||||||
*/
|
*/
|
||||||
void upap_setloginpasswd(int unit, const char *luser, const char *lpassword)
|
void
|
||||||
|
upap_setloginpasswd(int unit, const char *luser, const char *lpassword)
|
||||||
{
|
{
|
||||||
upap_state *u = &upap[unit];
|
upap_state *u = &upap[unit];
|
||||||
|
|
||||||
@ -136,7 +135,8 @@ void upap_setloginpasswd(int unit, const char *luser, const char *lpassword)
|
|||||||
*
|
*
|
||||||
* Set new state and send authenticate's.
|
* Set new state and send authenticate's.
|
||||||
*/
|
*/
|
||||||
void upap_authwithpeer(int unit, char *user, char *password)
|
void
|
||||||
|
upap_authwithpeer(int unit, char *user, char *password)
|
||||||
{
|
{
|
||||||
upap_state *u = &upap[unit];
|
upap_state *u = &upap[unit];
|
||||||
|
|
||||||
@ -163,7 +163,8 @@ void upap_authwithpeer(int unit, char *user, char *password)
|
|||||||
*
|
*
|
||||||
* Set new state.
|
* Set new state.
|
||||||
*/
|
*/
|
||||||
void upap_authpeer(int unit)
|
void
|
||||||
|
upap_authpeer(int unit)
|
||||||
{
|
{
|
||||||
upap_state *u = &upap[unit];
|
upap_state *u = &upap[unit];
|
||||||
|
|
||||||
@ -175,9 +176,10 @@ void upap_authpeer(int unit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
u->us_serverstate = UPAPSS_LISTEN;
|
u->us_serverstate = UPAPSS_LISTEN;
|
||||||
if (u->us_reqtimeout > 0)
|
if (u->us_reqtimeout > 0) {
|
||||||
TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout);
|
TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -187,7 +189,8 @@ void upap_authpeer(int unit)
|
|||||||
/*
|
/*
|
||||||
* upap_init - Initialize a UPAP unit.
|
* upap_init - Initialize a UPAP unit.
|
||||||
*/
|
*/
|
||||||
static void upap_init(int unit)
|
static void
|
||||||
|
upap_init(int unit)
|
||||||
{
|
{
|
||||||
upap_state *u = &upap[unit];
|
upap_state *u = &upap[unit];
|
||||||
|
|
||||||
@ -208,15 +211,17 @@ static void upap_init(int unit)
|
|||||||
/*
|
/*
|
||||||
* upap_timeout - Retransmission timer for sending auth-reqs expired.
|
* upap_timeout - Retransmission timer for sending auth-reqs expired.
|
||||||
*/
|
*/
|
||||||
static void upap_timeout(void *arg)
|
static void
|
||||||
|
upap_timeout(void *arg)
|
||||||
{
|
{
|
||||||
upap_state *u = (upap_state *) arg;
|
upap_state *u = (upap_state *) arg;
|
||||||
|
|
||||||
UPAPDEBUG((LOG_INFO, "upap_timeout: %d timeout %d expired s=%d\n",
|
UPAPDEBUG((LOG_INFO, "upap_timeout: %d timeout %d expired s=%d\n",
|
||||||
u->us_unit, u->us_timeouttime, u->us_clientstate));
|
u->us_unit, u->us_timeouttime, u->us_clientstate));
|
||||||
|
|
||||||
if (u->us_clientstate != UPAPCS_AUTHREQ)
|
if (u->us_clientstate != UPAPCS_AUTHREQ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (u->us_transmits >= u->us_maxtransmits) {
|
if (u->us_transmits >= u->us_maxtransmits) {
|
||||||
/* give up in disgust */
|
/* give up in disgust */
|
||||||
@ -233,12 +238,14 @@ static void upap_timeout(void *arg)
|
|||||||
/*
|
/*
|
||||||
* upap_reqtimeout - Give up waiting for the peer to send an auth-req.
|
* upap_reqtimeout - Give up waiting for the peer to send an auth-req.
|
||||||
*/
|
*/
|
||||||
static void upap_reqtimeout(void *arg)
|
static void
|
||||||
|
upap_reqtimeout(void *arg)
|
||||||
{
|
{
|
||||||
upap_state *u = (upap_state *) arg;
|
upap_state *u = (upap_state *) arg;
|
||||||
|
|
||||||
if (u->us_serverstate != UPAPSS_LISTEN)
|
if (u->us_serverstate != UPAPSS_LISTEN) {
|
||||||
return; /* huh?? */
|
return; /* huh?? */
|
||||||
|
}
|
||||||
|
|
||||||
auth_peer_fail(u->us_unit, PPP_PAP);
|
auth_peer_fail(u->us_unit, PPP_PAP);
|
||||||
u->us_serverstate = UPAPSS_BADAUTH;
|
u->us_serverstate = UPAPSS_BADAUTH;
|
||||||
@ -250,26 +257,28 @@ static void upap_reqtimeout(void *arg)
|
|||||||
*
|
*
|
||||||
* Start authenticating if pending.
|
* Start authenticating if pending.
|
||||||
*/
|
*/
|
||||||
static void upap_lowerup(int unit)
|
static void
|
||||||
|
upap_lowerup(int unit)
|
||||||
{
|
{
|
||||||
upap_state *u = &upap[unit];
|
upap_state *u = &upap[unit];
|
||||||
|
|
||||||
UPAPDEBUG((LOG_INFO, "upap_lowerup: %d s=%d\n", unit, u->us_clientstate));
|
UPAPDEBUG((LOG_INFO, "upap_lowerup: %d s=%d\n", unit, u->us_clientstate));
|
||||||
|
|
||||||
if (u->us_clientstate == UPAPCS_INITIAL)
|
if (u->us_clientstate == UPAPCS_INITIAL) {
|
||||||
u->us_clientstate = UPAPCS_CLOSED;
|
u->us_clientstate = UPAPCS_CLOSED;
|
||||||
else if (u->us_clientstate == UPAPCS_PENDING) {
|
} else if (u->us_clientstate == UPAPCS_PENDING) {
|
||||||
upap_sauthreq(u); /* send an auth-request */
|
upap_sauthreq(u); /* send an auth-request */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u->us_serverstate == UPAPSS_INITIAL)
|
if (u->us_serverstate == UPAPSS_INITIAL) {
|
||||||
u->us_serverstate = UPAPSS_CLOSED;
|
u->us_serverstate = UPAPSS_CLOSED;
|
||||||
else if (u->us_serverstate == UPAPSS_PENDING) {
|
} else if (u->us_serverstate == UPAPSS_PENDING) {
|
||||||
u->us_serverstate = UPAPSS_LISTEN;
|
u->us_serverstate = UPAPSS_LISTEN;
|
||||||
if (u->us_reqtimeout > 0)
|
if (u->us_reqtimeout > 0) {
|
||||||
TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout);
|
TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -277,16 +286,19 @@ static void upap_lowerup(int unit)
|
|||||||
*
|
*
|
||||||
* Cancel all timeouts.
|
* Cancel all timeouts.
|
||||||
*/
|
*/
|
||||||
static void upap_lowerdown(int unit)
|
static void
|
||||||
|
upap_lowerdown(int unit)
|
||||||
{
|
{
|
||||||
upap_state *u = &upap[unit];
|
upap_state *u = &upap[unit];
|
||||||
|
|
||||||
UPAPDEBUG((LOG_INFO, "upap_lowerdown: %d s=%d\n", unit, u->us_clientstate));
|
UPAPDEBUG((LOG_INFO, "upap_lowerdown: %d s=%d\n", unit, u->us_clientstate));
|
||||||
|
|
||||||
if (u->us_clientstate == UPAPCS_AUTHREQ) /* Timeout pending? */
|
if (u->us_clientstate == UPAPCS_AUTHREQ) { /* Timeout pending? */
|
||||||
UNTIMEOUT(upap_timeout, u); /* Cancel timeout */
|
UNTIMEOUT(upap_timeout, u); /* Cancel timeout */
|
||||||
if (u->us_serverstate == UPAPSS_LISTEN && u->us_reqtimeout > 0)
|
}
|
||||||
|
if (u->us_serverstate == UPAPSS_LISTEN && u->us_reqtimeout > 0) {
|
||||||
UNTIMEOUT(upap_reqtimeout, u);
|
UNTIMEOUT(upap_reqtimeout, u);
|
||||||
|
}
|
||||||
|
|
||||||
u->us_clientstate = UPAPCS_INITIAL;
|
u->us_clientstate = UPAPCS_INITIAL;
|
||||||
u->us_serverstate = UPAPSS_INITIAL;
|
u->us_serverstate = UPAPSS_INITIAL;
|
||||||
@ -298,7 +310,8 @@ static void upap_lowerdown(int unit)
|
|||||||
*
|
*
|
||||||
* This shouldn't happen. In any case, pretend lower layer went down.
|
* This shouldn't happen. In any case, pretend lower layer went down.
|
||||||
*/
|
*/
|
||||||
static void upap_protrej(int unit)
|
static void
|
||||||
|
upap_protrej(int unit)
|
||||||
{
|
{
|
||||||
upap_state *u = &upap[unit];
|
upap_state *u = &upap[unit];
|
||||||
|
|
||||||
@ -317,7 +330,8 @@ static void upap_protrej(int unit)
|
|||||||
/*
|
/*
|
||||||
* upap_input - Input UPAP packet.
|
* upap_input - Input UPAP packet.
|
||||||
*/
|
*/
|
||||||
static void upap_input(int unit, u_char *inpacket, int l)
|
static void
|
||||||
|
upap_input(int unit, u_char *inpacket, int l)
|
||||||
{
|
{
|
||||||
upap_state *u = &upap[unit];
|
upap_state *u = &upap[unit];
|
||||||
u_char *inp;
|
u_char *inp;
|
||||||
@ -371,12 +385,8 @@ static void upap_input(int unit, u_char *inpacket, int l)
|
|||||||
/*
|
/*
|
||||||
* upap_rauth - Receive Authenticate.
|
* upap_rauth - Receive Authenticate.
|
||||||
*/
|
*/
|
||||||
static void upap_rauthreq(
|
static void
|
||||||
upap_state *u,
|
upap_rauthreq(upap_state *u, u_char *inp, int id, int len)
|
||||||
u_char *inp,
|
|
||||||
int id,
|
|
||||||
int len
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
u_char ruserlen, rpasswdlen;
|
u_char ruserlen, rpasswdlen;
|
||||||
char *ruser, *rpasswd;
|
char *ruser, *rpasswd;
|
||||||
@ -386,8 +396,9 @@ static void upap_rauthreq(
|
|||||||
|
|
||||||
UPAPDEBUG((LOG_INFO, "pap_rauth: Rcvd id %d.\n", id));
|
UPAPDEBUG((LOG_INFO, "pap_rauth: Rcvd id %d.\n", id));
|
||||||
|
|
||||||
if (u->us_serverstate < UPAPSS_LISTEN)
|
if (u->us_serverstate < UPAPSS_LISTEN) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we receive a duplicate authenticate-request, we are
|
* If we receive a duplicate authenticate-request, we are
|
||||||
@ -427,8 +438,7 @@ static void upap_rauthreq(
|
|||||||
/*
|
/*
|
||||||
* Check the username and password given.
|
* Check the username and password given.
|
||||||
*/
|
*/
|
||||||
retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd,
|
retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd, rpasswdlen, &msg, &msglen);
|
||||||
rpasswdlen, &msg, &msglen);
|
|
||||||
BZERO(rpasswd, rpasswdlen);
|
BZERO(rpasswd, rpasswdlen);
|
||||||
|
|
||||||
upap_sresp(u, retcode, id, msg, msglen);
|
upap_sresp(u, retcode, id, msg, msglen);
|
||||||
@ -441,28 +451,26 @@ static void upap_rauthreq(
|
|||||||
auth_peer_fail(u->us_unit, PPP_PAP);
|
auth_peer_fail(u->us_unit, PPP_PAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u->us_reqtimeout > 0)
|
if (u->us_reqtimeout > 0) {
|
||||||
UNTIMEOUT(upap_reqtimeout, u);
|
UNTIMEOUT(upap_reqtimeout, u);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* upap_rauthack - Receive Authenticate-Ack.
|
* upap_rauthack - Receive Authenticate-Ack.
|
||||||
*/
|
*/
|
||||||
static void upap_rauthack(
|
static void
|
||||||
upap_state *u,
|
upap_rauthack(upap_state *u, u_char *inp, int id, int len)
|
||||||
u_char *inp,
|
|
||||||
int id,
|
|
||||||
int len
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
u_char msglen;
|
u_char msglen;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
UPAPDEBUG((LOG_INFO, "pap_rauthack: Rcvd id %d s=%d\n", id, u->us_clientstate));
|
UPAPDEBUG((LOG_INFO, "pap_rauthack: Rcvd id %d s=%d\n", id, u->us_clientstate));
|
||||||
|
|
||||||
if (u->us_clientstate != UPAPCS_AUTHREQ) /* XXX */
|
if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse message.
|
* Parse message.
|
||||||
@ -489,20 +497,17 @@ static void upap_rauthack(
|
|||||||
/*
|
/*
|
||||||
* upap_rauthnak - Receive Authenticate-Nakk.
|
* upap_rauthnak - Receive Authenticate-Nakk.
|
||||||
*/
|
*/
|
||||||
static void upap_rauthnak(
|
static void
|
||||||
upap_state *u,
|
upap_rauthnak(upap_state *u, u_char *inp, int id, int len)
|
||||||
u_char *inp,
|
|
||||||
int id,
|
|
||||||
int len
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
u_char msglen;
|
u_char msglen;
|
||||||
char *msg;
|
char *msg;
|
||||||
|
|
||||||
UPAPDEBUG((LOG_INFO, "pap_rauthnak: Rcvd id %d s=%d\n", id, u->us_clientstate));
|
UPAPDEBUG((LOG_INFO, "pap_rauthnak: Rcvd id %d s=%d\n", id, u->us_clientstate));
|
||||||
|
|
||||||
if (u->us_clientstate != UPAPCS_AUTHREQ) /* XXX */
|
if (u->us_clientstate != UPAPCS_AUTHREQ) { /* XXX */
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse message.
|
* Parse message.
|
||||||
@ -530,7 +535,8 @@ static void upap_rauthnak(
|
|||||||
/*
|
/*
|
||||||
* upap_sauthreq - Send an Authenticate-Request.
|
* upap_sauthreq - Send an Authenticate-Request.
|
||||||
*/
|
*/
|
||||||
static void upap_sauthreq(upap_state *u)
|
static void
|
||||||
|
upap_sauthreq(upap_state *u)
|
||||||
{
|
{
|
||||||
u_char *outp;
|
u_char *outp;
|
||||||
int outlen;
|
int outlen;
|
||||||
@ -563,13 +569,8 @@ static void upap_sauthreq(upap_state *u)
|
|||||||
/*
|
/*
|
||||||
* upap_sresp - Send a response (ack or nak).
|
* upap_sresp - Send a response (ack or nak).
|
||||||
*/
|
*/
|
||||||
static void upap_sresp(
|
static void
|
||||||
upap_state *u,
|
upap_sresp(upap_state *u, u_char code, u_char id, char *msg, int msglen)
|
||||||
u_char code,
|
|
||||||
u_char id,
|
|
||||||
char *msg,
|
|
||||||
int msglen
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
u_char *outp;
|
u_char *outp;
|
||||||
int outlen;
|
int outlen;
|
||||||
@ -585,8 +586,7 @@ static void upap_sresp(
|
|||||||
BCOPY(msg, outp, msglen);
|
BCOPY(msg, outp, msglen);
|
||||||
pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN);
|
pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN);
|
||||||
|
|
||||||
UPAPDEBUG((LOG_INFO, "pap_sresp: Sent code %d, id %d s=%d\n",
|
UPAPDEBUG((LOG_INFO, "pap_sresp: Sent code %d, id %d s=%d\n", code, id, u->us_clientstate));
|
||||||
code, id, u->us_clientstate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -277,22 +277,27 @@ pppoe_destroy(struct netif *ifp)
|
|||||||
struct pppoe_softc * sc;
|
struct pppoe_softc * sc;
|
||||||
|
|
||||||
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
|
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
|
||||||
if (sc->sc_ethif == ifp)
|
if (sc->sc_ethif == ifp) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!(sc && (sc->sc_ethif == ifp)))
|
if(!(sc && (sc->sc_ethif == ifp))) {
|
||||||
return ERR_IF;
|
return ERR_IF;
|
||||||
|
}
|
||||||
|
|
||||||
tcpip_untimeout(pppoe_timeout, sc);
|
tcpip_untimeout(pppoe_timeout, sc);
|
||||||
LIST_REMOVE(sc, sc_list);
|
LIST_REMOVE(sc, sc_list);
|
||||||
|
|
||||||
if (sc->sc_concentrator_name)
|
if (sc->sc_concentrator_name) {
|
||||||
mem_free(sc->sc_concentrator_name);
|
mem_free(sc->sc_concentrator_name);
|
||||||
if (sc->sc_service_name)
|
}
|
||||||
|
if (sc->sc_service_name) {
|
||||||
mem_free(sc->sc_service_name);
|
mem_free(sc->sc_service_name);
|
||||||
if (sc->sc_ac_cookie)
|
}
|
||||||
|
if (sc->sc_ac_cookie) {
|
||||||
mem_free(sc->sc_ac_cookie);
|
mem_free(sc->sc_ac_cookie);
|
||||||
|
}
|
||||||
mem_free(sc);
|
mem_free(sc);
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -309,18 +314,20 @@ pppoe_find_softc_by_session(u_int session, struct netif *rcvif)
|
|||||||
{
|
{
|
||||||
struct pppoe_softc *sc;
|
struct pppoe_softc *sc;
|
||||||
|
|
||||||
if (session == 0)
|
if (session == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
|
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
|
||||||
if (sc->sc_state == PPPOE_STATE_SESSION
|
if (sc->sc_state == PPPOE_STATE_SESSION
|
||||||
&& sc->sc_session == session) {
|
&& sc->sc_session == session) {
|
||||||
if (sc->sc_ethif == rcvif)
|
if (sc->sc_ethif == rcvif) {
|
||||||
return sc;
|
return sc;
|
||||||
else
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,15 +338,20 @@ pppoe_find_softc_by_hunique(u8_t *token, size_t len, struct netif *rcvif)
|
|||||||
{
|
{
|
||||||
struct pppoe_softc *sc, *t;
|
struct pppoe_softc *sc, *t;
|
||||||
|
|
||||||
if (LIST_EMPTY(&pppoe_softc_list))
|
if (LIST_EMPTY(&pppoe_softc_list)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (len != sizeof sc)
|
if (len != sizeof sc) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
memcpy(&t, token, len);
|
memcpy(&t, token, len);
|
||||||
|
|
||||||
LIST_FOREACH(sc, &pppoe_softc_list, sc_list)
|
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
|
||||||
if (sc == t) break;
|
if (sc == t) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sc == NULL) {
|
if (sc == NULL) {
|
||||||
PPPDEBUG((LOG_DEBUG, "pppoe: alien host unique tag, no session found\n"));
|
PPPDEBUG((LOG_DEBUG, "pppoe: alien host unique tag, no session found\n"));
|
||||||
@ -414,8 +426,7 @@ pppoe_dispatch_disc_pkt(struct netif *netif, struct pbuf *pb)
|
|||||||
|
|
||||||
ph = (struct pppoehdr *) (ethhdr + 1);
|
ph = (struct pppoehdr *) (ethhdr + 1);
|
||||||
if (ph->vertype != PPPOE_VERTYPE) {
|
if (ph->vertype != PPPOE_VERTYPE) {
|
||||||
printf("pppoe: unknown version/type packet: 0x%x\n",
|
printf("pppoe: unknown version/type packet: 0x%x\n", ph->vertype);
|
||||||
ph->vertype);
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
session = ntohs(ph->session);
|
session = ntohs(ph->session);
|
||||||
@ -427,8 +438,9 @@ pppoe_dispatch_disc_pkt(struct netif *netif, struct pbuf *pb)
|
|||||||
pb->len - off, plen);
|
pb->len - off, plen);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if(pb->tot_len == pb->len)
|
if(pb->tot_len == pb->len) {
|
||||||
pb->tot_len = pb->len = off + plen; /* ignore trailing garbage */
|
pb->tot_len = pb->len = off + plen; /* ignore trailing garbage */
|
||||||
|
}
|
||||||
tag = 0;
|
tag = 0;
|
||||||
len = 0;
|
len = 0;
|
||||||
sc = NULL;
|
sc = NULL;
|
||||||
@ -448,15 +460,17 @@ pppoe_dispatch_disc_pkt(struct netif *netif, struct pbuf *pb)
|
|||||||
case PPPOE_TAG_ACNAME:
|
case PPPOE_TAG_ACNAME:
|
||||||
break; /* ignored */
|
break; /* ignored */
|
||||||
case PPPOE_TAG_HUNIQUE:
|
case PPPOE_TAG_HUNIQUE:
|
||||||
if (sc != NULL)
|
if (sc != NULL) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
#ifdef PPPOE_SERVER
|
#ifdef PPPOE_SERVER
|
||||||
hunique = (u8_t*)pb->payload + off + sizeof(pt);
|
hunique = (u8_t*)pb->payload + off + sizeof(pt);
|
||||||
hunique_len = len;
|
hunique_len = len;
|
||||||
#endif
|
#endif
|
||||||
sc = pppoe_find_softc_by_hunique((u8_t*)pb->payload + off + sizeof(pt), len, netif);
|
sc = pppoe_find_softc_by_hunique((u8_t*)pb->payload + off + sizeof(pt), len, netif);
|
||||||
if (sc != NULL)
|
if (sc != NULL) {
|
||||||
snprintf(devname, sizeof(devname), "%c%c%"U16_F, sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num);
|
snprintf(devname, sizeof(devname), "%c%c%"U16_F, sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PPPOE_TAG_ACCOOKIE:
|
case PPPOE_TAG_ACCOOKIE:
|
||||||
if (ac_cookie == NULL) {
|
if (ac_cookie == NULL) {
|
||||||
@ -489,13 +503,16 @@ pppoe_dispatch_disc_pkt(struct netif *netif, struct pbuf *pb)
|
|||||||
if (error) {
|
if (error) {
|
||||||
printf("%s: %s: %s\n", devname, err_msg, error);
|
printf("%s: %s: %s\n", devname, err_msg, error);
|
||||||
mem_free(error);
|
mem_free(error);
|
||||||
} else
|
} else {
|
||||||
printf("%s: %s\n", devname, err_msg);
|
printf("%s: %s\n", devname, err_msg);
|
||||||
if (errortag)
|
}
|
||||||
|
if (errortag) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
off += sizeof(pt) + len;
|
off += sizeof(pt) + len;
|
||||||
}
|
}
|
||||||
|
|
||||||
breakbreak:;
|
breakbreak:;
|
||||||
switch (ph->code) {
|
switch (ph->code) {
|
||||||
case PPPOE_CODE_PADI:
|
case PPPOE_CODE_PADI:
|
||||||
@ -504,26 +521,32 @@ breakbreak:;
|
|||||||
* got service name, concentrator name, and/or host unique.
|
* got service name, concentrator name, and/or host unique.
|
||||||
* ignore if we have no interfaces with IFF_PASSIVE|IFF_UP.
|
* ignore if we have no interfaces with IFF_PASSIVE|IFF_UP.
|
||||||
*/
|
*/
|
||||||
if (LIST_EMPTY(&pppoe_softc_list))
|
if (LIST_EMPTY(&pppoe_softc_list)) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
|
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
|
||||||
if (!(sc->sc_sppp.pp_if.if_flags & IFF_UP))
|
if (!(sc->sc_sppp.pp_if.if_flags & IFF_UP)) {
|
||||||
continue;
|
continue;
|
||||||
if (!(sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE))
|
}
|
||||||
|
if (!(sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) {
|
||||||
continue;
|
continue;
|
||||||
if (sc->sc_state == PPPOE_STATE_INITIAL)
|
}
|
||||||
|
if (sc->sc_state == PPPOE_STATE_INITIAL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (sc == NULL) {
|
if (sc == NULL) {
|
||||||
/* printf("pppoe: free passive interface is not found\n"); */
|
/* printf("pppoe: free passive interface is not found\n"); */
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (hunique) {
|
if (hunique) {
|
||||||
if (sc->sc_hunique)
|
if (sc->sc_hunique) {
|
||||||
mem_free(sc->sc_hunique);
|
mem_free(sc->sc_hunique);
|
||||||
|
}
|
||||||
sc->sc_hunique = mem_malloc(hunique_len);
|
sc->sc_hunique = mem_malloc(hunique_len);
|
||||||
if (sc->sc_hunique == NULL)
|
if (sc->sc_hunique == NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
sc->sc_hunique_len = hunique_len;
|
sc->sc_hunique_len = hunique_len;
|
||||||
memcpy(sc->sc_hunique, hunique, hunique_len);
|
memcpy(sc->sc_hunique, hunique, hunique_len);
|
||||||
}
|
}
|
||||||
@ -545,8 +568,9 @@ breakbreak:;
|
|||||||
sc = pppoe_find_softc_by_hunique(ac_cookie, ac_cookie_len, netif);
|
sc = pppoe_find_softc_by_hunique(ac_cookie, ac_cookie_len, netif);
|
||||||
if (sc == NULL) {
|
if (sc == NULL) {
|
||||||
/* be quiet if there is not a single pppoe instance */
|
/* be quiet if there is not a single pppoe instance */
|
||||||
if (!LIST_EMPTY(&pppoe_softc_list))
|
if (!LIST_EMPTY(&pppoe_softc_list)) {
|
||||||
printf("pppoe: received PADR but could not find request for it\n");
|
printf("pppoe: received PADR but could not find request for it\n");
|
||||||
|
}
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
|
if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
|
||||||
@ -554,11 +578,13 @@ breakbreak:;
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (hunique) {
|
if (hunique) {
|
||||||
if (sc->sc_hunique)
|
if (sc->sc_hunique) {
|
||||||
mem_free(sc->sc_hunique);
|
mem_free(sc->sc_hunique);
|
||||||
|
}
|
||||||
sc->sc_hunique = mem_malloc(hunique_len);
|
sc->sc_hunique = mem_malloc(hunique_len);
|
||||||
if (sc->sc_hunique == NULL)
|
if (sc->sc_hunique == NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
sc->sc_hunique_len = hunique_len;
|
sc->sc_hunique_len = hunique_len;
|
||||||
memcpy(sc->sc_hunique, hunique, hunique_len);
|
memcpy(sc->sc_hunique, hunique, hunique_len);
|
||||||
}
|
}
|
||||||
@ -573,8 +599,9 @@ breakbreak:;
|
|||||||
case PPPOE_CODE_PADO:
|
case PPPOE_CODE_PADO:
|
||||||
if (sc == NULL) {
|
if (sc == NULL) {
|
||||||
/* be quiet if there is not a single pppoe instance */
|
/* be quiet if there is not a single pppoe instance */
|
||||||
if (!LIST_EMPTY(&pppoe_softc_list))
|
if (!LIST_EMPTY(&pppoe_softc_list)) {
|
||||||
printf("pppoe: received PADO but could not find request for it\n");
|
printf("pppoe: received PADO but could not find request for it\n");
|
||||||
|
}
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (sc->sc_state != PPPOE_STATE_PADI_SENT) {
|
if (sc->sc_state != PPPOE_STATE_PADI_SENT) {
|
||||||
@ -582,11 +609,13 @@ breakbreak:;
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (ac_cookie) {
|
if (ac_cookie) {
|
||||||
if (sc->sc_ac_cookie)
|
if (sc->sc_ac_cookie) {
|
||||||
mem_free(sc->sc_ac_cookie);
|
mem_free(sc->sc_ac_cookie);
|
||||||
|
}
|
||||||
sc->sc_ac_cookie = mem_malloc(ac_cookie_len);
|
sc->sc_ac_cookie = mem_malloc(ac_cookie_len);
|
||||||
if (sc->sc_ac_cookie == NULL)
|
if (sc->sc_ac_cookie == NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
sc->sc_ac_cookie_len = ac_cookie_len;
|
sc->sc_ac_cookie_len = ac_cookie_len;
|
||||||
memcpy(sc->sc_ac_cookie, ac_cookie, ac_cookie_len);
|
memcpy(sc->sc_ac_cookie, ac_cookie, ac_cookie_len);
|
||||||
}
|
}
|
||||||
@ -600,8 +629,9 @@ breakbreak:;
|
|||||||
tcpip_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc);
|
tcpip_timeout(PPPOE_DISC_TIMEOUT * (1 + sc->sc_padr_retried), pppoe_timeout, sc);
|
||||||
break;
|
break;
|
||||||
case PPPOE_CODE_PADS:
|
case PPPOE_CODE_PADS:
|
||||||
if (sc == NULL)
|
if (sc == NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
sc->sc_session = session;
|
sc->sc_session = session;
|
||||||
tcpip_untimeout(pppoe_timeout, sc);
|
tcpip_untimeout(pppoe_timeout, sc);
|
||||||
PPPDEBUG((LOG_DEBUG, "pppoe: %c%c%"U16_F": session 0x%x connected\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, session));
|
PPPDEBUG((LOG_DEBUG, "pppoe: %c%c%"U16_F": session 0x%x connected\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, session));
|
||||||
@ -609,8 +639,9 @@ breakbreak:;
|
|||||||
tcpip_timeout (100, pppoe_linkstatus_up, sc); /* notify upper layers */
|
tcpip_timeout (100, pppoe_linkstatus_up, sc); /* notify upper layers */
|
||||||
break;
|
break;
|
||||||
case PPPOE_CODE_PADT:
|
case PPPOE_CODE_PADT:
|
||||||
if (sc == NULL)
|
if (sc == NULL) {
|
||||||
goto done;
|
goto done;
|
||||||
|
}
|
||||||
pppoe_clear_softc(sc, "received PADT");
|
pppoe_clear_softc(sc, "received PADT");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -635,9 +666,10 @@ pppoe_disc_input(struct netif *netif, struct pbuf *p)
|
|||||||
/* avoid error messages if there is not a single pppoe instance */
|
/* avoid error messages if there is not a single pppoe instance */
|
||||||
if (!LIST_EMPTY(&pppoe_softc_list)) {
|
if (!LIST_EMPTY(&pppoe_softc_list)) {
|
||||||
pppoe_dispatch_disc_pkt(netif, p);
|
pppoe_dispatch_disc_pkt(netif, p);
|
||||||
} else
|
} else {
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pppoe_data_input(struct netif *netif, struct pbuf *pb)
|
pppoe_data_input(struct netif *netif, struct pbuf *pb)
|
||||||
@ -676,8 +708,9 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb)
|
|||||||
printf("pppoe (data): unknown version/type packet: 0x%x\n", ph->vertype);
|
printf("pppoe (data): unknown version/type packet: 0x%x\n", ph->vertype);
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
if (ph->code != 0)
|
if (ph->code != 0) {
|
||||||
goto drop;
|
goto drop;
|
||||||
|
}
|
||||||
|
|
||||||
session = ntohs(ph->session);
|
session = ntohs(ph->session);
|
||||||
sc = pppoe_find_softc_by_session(session, netif);
|
sc = pppoe_find_softc_by_session(session, netif);
|
||||||
@ -702,8 +735,9 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb)
|
|||||||
sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num,
|
sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num,
|
||||||
pb->len, plen));
|
pb->len, plen));
|
||||||
|
|
||||||
if (pb->len < plen)
|
if (pb->len < plen) {
|
||||||
goto drop;
|
goto drop;
|
||||||
|
}
|
||||||
|
|
||||||
pppInProcOverEthernet(sc->sc_pd, pb);
|
pppInProcOverEthernet(sc->sc_pd, pb);
|
||||||
|
|
||||||
@ -751,8 +785,9 @@ pppoe_send_padi(struct pppoe_softc *sc)
|
|||||||
u8_t *p;
|
u8_t *p;
|
||||||
int len, l1 = 0, l2 = 0; /* XXX: gcc */
|
int len, l1 = 0, l2 = 0; /* XXX: gcc */
|
||||||
|
|
||||||
if (sc->sc_state >PPPOE_STATE_PADI_SENT)
|
if (sc->sc_state >PPPOE_STATE_PADI_SENT) {
|
||||||
PPPDEBUG((LOG_ERR, "ERROR: pppoe_send_padi in state %d", sc->sc_state));
|
PPPDEBUG((LOG_ERR, "ERROR: pppoe_send_padi in state %d", sc->sc_state));
|
||||||
|
}
|
||||||
|
|
||||||
/* calculate length of frame (excluding ethernet header + pppoe header) */
|
/* calculate length of frame (excluding ethernet header + pppoe header) */
|
||||||
len = 2 + 2 + 2 + 2 + sizeof sc; /* service name tag is required, host unique is send too */
|
len = 2 + 2 + 2 + 2 + sizeof sc; /* service name tag is required, host unique is send too */
|
||||||
@ -767,8 +802,9 @@ pppoe_send_padi(struct pppoe_softc *sc)
|
|||||||
|
|
||||||
/* allocate a buffer */
|
/* allocate a buffer */
|
||||||
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM);
|
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM);
|
||||||
if (!pb)
|
if (!pb) {
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
|
}
|
||||||
|
|
||||||
p = (u8_t*)pb->payload + sizeof (struct eth_hdr);
|
p = (u8_t*)pb->payload + sizeof (struct eth_hdr);
|
||||||
/* fill in pkt */
|
/* fill in pkt */
|
||||||
@ -841,8 +877,7 @@ pppoe_timeout(void *arg)
|
|||||||
case PPPOE_STATE_PADR_SENT:
|
case PPPOE_STATE_PADR_SENT:
|
||||||
sc->sc_padr_retried++;
|
sc->sc_padr_retried++;
|
||||||
if (sc->sc_padr_retried >= PPPOE_DISC_MAXPADR) {
|
if (sc->sc_padr_retried >= PPPOE_DISC_MAXPADR) {
|
||||||
memcpy(&sc->sc_dest, ethbroadcast.addr,
|
memcpy(&sc->sc_dest, ethbroadcast.addr, sizeof(sc->sc_dest));
|
||||||
sizeof(sc->sc_dest));
|
|
||||||
sc->sc_state = PPPOE_STATE_PADI_SENT;
|
sc->sc_state = PPPOE_STATE_PADI_SENT;
|
||||||
sc->sc_padr_retried = 0;
|
sc->sc_padr_retried = 0;
|
||||||
if ((err = pppoe_send_padi(sc)) != 0) {
|
if ((err = pppoe_send_padi(sc)) != 0) {
|
||||||
@ -871,13 +906,15 @@ pppoe_connect(struct pppoe_softc *sc)
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (sc->sc_state != PPPOE_STATE_INITIAL)
|
if (sc->sc_state != PPPOE_STATE_INITIAL) {
|
||||||
return EBUSY;
|
return EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef PPPOE_SERVER
|
#ifdef PPPOE_SERVER
|
||||||
/* wait PADI if IFF_PASSIVE */
|
/* wait PADI if IFF_PASSIVE */
|
||||||
if ((sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE))
|
if ((sc->sc_sppp.pp_if.if_flags & IFF_PASSIVE)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/* save state, in case we fail to send PADI */
|
/* save state, in case we fail to send PADI */
|
||||||
sc->sc_state = PPPOE_STATE_PADI_SENT;
|
sc->sc_state = PPPOE_STATE_PADI_SENT;
|
||||||
@ -892,8 +929,9 @@ pppoe_connect(struct pppoe_softc *sc)
|
|||||||
void
|
void
|
||||||
pppoe_disconnect(struct pppoe_softc *sc)
|
pppoe_disconnect(struct pppoe_softc *sc)
|
||||||
{
|
{
|
||||||
if (sc->sc_state < PPPOE_STATE_SESSION)
|
if (sc->sc_state < PPPOE_STATE_SESSION) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Do not call pppoe_disconnect here, the upper layer state
|
* Do not call pppoe_disconnect here, the upper layer state
|
||||||
* machine gets confused by this. We must return from this
|
* machine gets confused by this. We must return from this
|
||||||
@ -908,9 +946,9 @@ pppoe_do_disconnect(struct pppoe_softc *sc)
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (sc->sc_state < PPPOE_STATE_SESSION)
|
if (sc->sc_state < PPPOE_STATE_SESSION) {
|
||||||
err = EBUSY;
|
err = EBUSY;
|
||||||
else {
|
} else {
|
||||||
PPPDEBUG((LOG_DEBUG, "pppoe: %c%c%"U16_F": disconnecting\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
|
PPPDEBUG((LOG_DEBUG, "pppoe: %c%c%"U16_F": disconnecting\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num));
|
||||||
err = pppoe_send_padt(sc->sc_ethif, sc->sc_session, (const u8_t *)&sc->sc_dest);
|
err = pppoe_send_padt(sc->sc_ethif, sc->sc_session, (const u8_t *)&sc->sc_dest);
|
||||||
}
|
}
|
||||||
@ -959,19 +997,22 @@ pppoe_send_padr(struct pppoe_softc *sc)
|
|||||||
u8_t *p;
|
u8_t *p;
|
||||||
size_t len, l1 = 0; /* XXX: gcc */
|
size_t len, l1 = 0; /* XXX: gcc */
|
||||||
|
|
||||||
if (sc->sc_state != PPPOE_STATE_PADR_SENT)
|
if (sc->sc_state != PPPOE_STATE_PADR_SENT) {
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
|
}
|
||||||
|
|
||||||
len = 2 + 2 + 2 + 2 + sizeof(sc); /* service name, host unique */
|
len = 2 + 2 + 2 + 2 + sizeof(sc); /* service name, host unique */
|
||||||
if (sc->sc_service_name != NULL) { /* service name tag maybe empty */
|
if (sc->sc_service_name != NULL) { /* service name tag maybe empty */
|
||||||
l1 = strlen(sc->sc_service_name);
|
l1 = strlen(sc->sc_service_name);
|
||||||
len += l1;
|
len += l1;
|
||||||
}
|
}
|
||||||
if (sc->sc_ac_cookie_len > 0)
|
if (sc->sc_ac_cookie_len > 0) {
|
||||||
len += 2 + 2 + sc->sc_ac_cookie_len; /* AC cookie */
|
len += 2 + 2 + sc->sc_ac_cookie_len; /* AC cookie */
|
||||||
|
}
|
||||||
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM);
|
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM);
|
||||||
if (!pb)
|
if (!pb) {
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
|
}
|
||||||
p = (u8_t*)pb->payload + sizeof (struct eth_hdr);
|
p = (u8_t*)pb->payload + sizeof (struct eth_hdr);
|
||||||
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADR, 0, len);
|
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADR, 0, len);
|
||||||
PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
|
PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
|
||||||
@ -995,7 +1036,6 @@ pppoe_send_padr(struct pppoe_softc *sc)
|
|||||||
return pppoe_output(sc, pb);
|
return pppoe_output(sc, pb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* send a PADT packet */
|
/* send a PADT packet */
|
||||||
static err_t
|
static err_t
|
||||||
pppoe_send_padt(struct netif *outgoing_if, u_int session, const u8_t *dest)
|
pppoe_send_padt(struct netif *outgoing_if, u_int session, const u8_t *dest)
|
||||||
@ -1006,8 +1046,9 @@ pppoe_send_padt(struct netif *outgoing_if, u_int session, const u8_t *dest)
|
|||||||
u8_t *p;
|
u8_t *p;
|
||||||
|
|
||||||
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN, PBUF_RAM);
|
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN, PBUF_RAM);
|
||||||
if (!pb)
|
if (!pb) {
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
|
}
|
||||||
|
|
||||||
ethhdr = (struct eth_hdr *)pb->payload;
|
ethhdr = (struct eth_hdr *)pb->payload;
|
||||||
ethhdr->type = htons(ETHTYPE_PPPOEDISC);
|
ethhdr->type = htons(ETHTYPE_PPPOEDISC);
|
||||||
@ -1032,8 +1073,9 @@ pppoe_send_pado(struct pppoe_softc *sc)
|
|||||||
u8_t *p;
|
u8_t *p;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (sc->sc_state != PPPOE_STATE_PADO_SENT)
|
if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
|
}
|
||||||
|
|
||||||
/* calc length */
|
/* calc length */
|
||||||
len = 0;
|
len = 0;
|
||||||
@ -1042,8 +1084,9 @@ pppoe_send_pado(struct pppoe_softc *sc)
|
|||||||
/* include hunique */
|
/* include hunique */
|
||||||
len += 2 + 2 + sc->sc_hunique_len;
|
len += 2 + 2 + sc->sc_hunique_len;
|
||||||
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM);
|
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM);
|
||||||
if (!pb)
|
if (!pb) {
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
|
}
|
||||||
p = (u8_t*)pb->payload + sizeof (struct eth_hdr);
|
p = (u8_t*)pb->payload + sizeof (struct eth_hdr);
|
||||||
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADO, 0, len);
|
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADO, 0, len);
|
||||||
PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE);
|
PPPOE_ADD_16(p, PPPOE_TAG_ACCOOKIE);
|
||||||
@ -1063,8 +1106,9 @@ pppoe_send_pads(struct pppoe_softc *sc)
|
|||||||
u8_t *p;
|
u8_t *p;
|
||||||
size_t len, l1 = 0; /* XXX: gcc */
|
size_t len, l1 = 0; /* XXX: gcc */
|
||||||
|
|
||||||
if (sc->sc_state != PPPOE_STATE_PADO_SENT)
|
if (sc->sc_state != PPPOE_STATE_PADO_SENT) {
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
|
}
|
||||||
|
|
||||||
sc->sc_session = mono_time.tv_sec % 0xff + 1;
|
sc->sc_session = mono_time.tv_sec % 0xff + 1;
|
||||||
/* calc length */
|
/* calc length */
|
||||||
@ -1076,8 +1120,9 @@ pppoe_send_pads(struct pppoe_softc *sc)
|
|||||||
len += l1;
|
len += l1;
|
||||||
}
|
}
|
||||||
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM);
|
pb = pbuf_alloc(PBUF_LINK, sizeof(struct eth_hdr) + PPPOE_HEADERLEN + len, PBUF_RAM);
|
||||||
if (!pb)
|
if (!pb) {
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
|
}
|
||||||
p = (u8_t*)pb->payload + sizeof (struct eth_hdr);
|
p = (u8_t*)pb->payload + sizeof (struct eth_hdr);
|
||||||
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADS, sc->sc_session, len);
|
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADS, sc->sc_session, len);
|
||||||
PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
|
PPPOE_ADD_16(p, PPPOE_TAG_SNAME);
|
||||||
@ -1132,12 +1177,14 @@ pppoe_ifattach_hook(void *arg, struct pbuf **mp, struct netif *ifp, int dir)
|
|||||||
struct pppoe_softc *sc;
|
struct pppoe_softc *sc;
|
||||||
int s;
|
int s;
|
||||||
|
|
||||||
if (mp != (struct pbuf **)PFIL_IFNET_DETACH)
|
if (mp != (struct pbuf **)PFIL_IFNET_DETACH) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
|
LIST_FOREACH(sc, &pppoe_softc_list, sc_list) {
|
||||||
if (sc->sc_ethif != ifp)
|
if (sc->sc_ethif != ifp) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (sc->sc_sppp.pp_if.if_flags & IFF_UP) {
|
if (sc->sc_sppp.pp_if.if_flags & IFF_UP) {
|
||||||
sc->sc_sppp.pp_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
|
sc->sc_sppp.pp_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
|
||||||
printf("%c%c%"U16_F": ethernet interface detached, going down\n",
|
printf("%c%c%"U16_F": ethernet interface detached, going down\n",
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*
|
*
|
||||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||||
* - Initial distribution.
|
* Initial distribution.
|
||||||
*
|
*
|
||||||
* Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au,
|
* Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au,
|
||||||
* so that the entire packet being decompressed doesn't have
|
* so that the entire packet being decompressed doesn't have
|
||||||
@ -55,7 +55,8 @@
|
|||||||
#define getth_off(base) ((base).th_off)
|
#define getth_off(base) ((base).th_off)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void vj_compress_init(struct vjcompress *comp)
|
void
|
||||||
|
vj_compress_init(struct vjcompress *comp)
|
||||||
{
|
{
|
||||||
register u_int i;
|
register u_int i;
|
||||||
register struct cstate *tstate = comp->tstate;
|
register struct cstate *tstate = comp->tstate;
|
||||||
@ -141,10 +142,8 @@ void vj_compress_init(struct vjcompress *comp)
|
|||||||
* Return the VJ type code indicating whether or not the packet was
|
* Return the VJ type code indicating whether or not the packet was
|
||||||
* compressed.
|
* compressed.
|
||||||
*/
|
*/
|
||||||
u_int vj_compress_tcp(
|
u_int
|
||||||
struct vjcompress *comp,
|
vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb)
|
||||||
struct pbuf *pb
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
register struct ip *ip = (struct ip *)pb->payload;
|
register struct ip *ip = (struct ip *)pb->payload;
|
||||||
register struct cstate *cs = comp->last_cs->cs_next;
|
register struct cstate *cs = comp->last_cs->cs_next;
|
||||||
@ -160,20 +159,22 @@ u_int vj_compress_tcp(
|
|||||||
/*
|
/*
|
||||||
* Check that the packet is IP proto TCP.
|
* Check that the packet is IP proto TCP.
|
||||||
*/
|
*/
|
||||||
if (ip->ip_p != IPPROTO_TCP)
|
if (ip->ip_p != IPPROTO_TCP) {
|
||||||
return (TYPE_IP);
|
return (TYPE_IP);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bail if this is an IP fragment or if the TCP packet isn't
|
* Bail if this is an IP fragment or if the TCP packet isn't
|
||||||
* `compressible' (i.e., ACK isn't set or some other control bit is
|
* `compressible' (i.e., ACK isn't set or some other control bit is
|
||||||
* set).
|
* set).
|
||||||
*/
|
*/
|
||||||
if ((ip->ip_off & htons(0x3fff)) || pb->tot_len < 40)
|
if ((ip->ip_off & htons(0x3fff)) || pb->tot_len < 40) {
|
||||||
return (TYPE_IP);
|
return (TYPE_IP);
|
||||||
|
}
|
||||||
th = (struct tcphdr *)&((long *)ip)[hlen];
|
th = (struct tcphdr *)&((long *)ip)[hlen];
|
||||||
if ((th->th_flags & (TCP_SYN|TCP_FIN|TCP_RST|TCP_ACK)) != TCP_ACK)
|
if ((th->th_flags & (TCP_SYN|TCP_FIN|TCP_RST|TCP_ACK)) != TCP_ACK) {
|
||||||
return (TYPE_IP);
|
return (TYPE_IP);
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Packet is compressible -- we're going to send either a
|
* Packet is compressible -- we're going to send either a
|
||||||
* COMPRESSED_TCP or UNCOMPRESSED_TCP packet. Either way we need
|
* COMPRESSED_TCP or UNCOMPRESSED_TCP packet. Either way we need
|
||||||
@ -205,8 +206,9 @@ u_int vj_compress_tcp(
|
|||||||
INCR(vjs_searches);
|
INCR(vjs_searches);
|
||||||
if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
|
if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
|
||||||
&& ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
|
&& ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
|
||||||
&& *(long *)th == ((long *)&cs->cs_ip)[getip_hl(cs->cs_ip)])
|
&& *(long *)th == ((long *)&cs->cs_ip)[getip_hl(cs->cs_ip)]) {
|
||||||
goto found;
|
goto found;
|
||||||
|
}
|
||||||
} while (cs != lastcs);
|
} while (cs != lastcs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -222,17 +224,18 @@ u_int vj_compress_tcp(
|
|||||||
hlen += getth_off(*th);
|
hlen += getth_off(*th);
|
||||||
hlen <<= 2;
|
hlen <<= 2;
|
||||||
/* Check that the IP/TCP headers are contained in the first buffer. */
|
/* Check that the IP/TCP headers are contained in the first buffer. */
|
||||||
if (hlen > pb->len)
|
if (hlen > pb->len) {
|
||||||
return (TYPE_IP);
|
return (TYPE_IP);
|
||||||
|
}
|
||||||
goto uncompressed;
|
goto uncompressed;
|
||||||
|
|
||||||
found:
|
found:
|
||||||
/*
|
/*
|
||||||
* Found it -- move to the front on the connection list.
|
* Found it -- move to the front on the connection list.
|
||||||
*/
|
*/
|
||||||
if (cs == lastcs)
|
if (cs == lastcs) {
|
||||||
comp->last_cs = lcs;
|
comp->last_cs = lcs;
|
||||||
else {
|
} else {
|
||||||
lcs->cs_next = cs->cs_next;
|
lcs->cs_next = cs->cs_next;
|
||||||
cs->cs_next = lastcs->cs_next;
|
cs->cs_next = lastcs->cs_next;
|
||||||
lastcs->cs_next = cs;
|
lastcs->cs_next = cs;
|
||||||
@ -245,8 +248,7 @@ u_int vj_compress_tcp(
|
|||||||
hlen <<= 2;
|
hlen <<= 2;
|
||||||
/* Check that the IP/TCP headers are contained in the first buffer. */
|
/* Check that the IP/TCP headers are contained in the first buffer. */
|
||||||
if (hlen > pb->len) {
|
if (hlen > pb->len) {
|
||||||
PPPDEBUG((LOG_INFO, "vj_compress_tcp: header len %d spans buffers\n",
|
PPPDEBUG((LOG_INFO, "vj_compress_tcp: header len %d spans buffers\n", hlen));
|
||||||
hlen));
|
|
||||||
return (TYPE_IP);
|
return (TYPE_IP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,8 +268,9 @@ u_int vj_compress_tcp(
|
|||||||
|| ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4]
|
|| ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4]
|
||||||
|| getth_off(*th) != getth_off(*oth)
|
|| getth_off(*th) != getth_off(*oth)
|
||||||
|| (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2))
|
|| (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2))
|
||||||
|| (getth_off(*th) > 5 && BCMP(th + 1, oth + 1, (getth_off(*th) - 5) << 2)))
|
|| (getth_off(*th) > 5 && BCMP(th + 1, oth + 1, (getth_off(*th) - 5) << 2))) {
|
||||||
goto uncompressed;
|
goto uncompressed;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Figure out which of the changing fields changed. The
|
* Figure out which of the changing fields changed. The
|
||||||
@ -279,12 +282,13 @@ u_int vj_compress_tcp(
|
|||||||
deltaS = ntohs(th->th_urp);
|
deltaS = ntohs(th->th_urp);
|
||||||
ENCODEZ(deltaS);
|
ENCODEZ(deltaS);
|
||||||
changes |= NEW_U;
|
changes |= NEW_U;
|
||||||
} else if (th->th_urp != oth->th_urp)
|
} else if (th->th_urp != oth->th_urp) {
|
||||||
/* argh! URG not set but urp changed -- a sensible
|
/* argh! URG not set but urp changed -- a sensible
|
||||||
* implementation should never do this but RFC793
|
* implementation should never do this but RFC793
|
||||||
* doesn't prohibit the change so we have to deal
|
* doesn't prohibit the change so we have to deal
|
||||||
* with it. */
|
* with it. */
|
||||||
goto uncompressed;
|
goto uncompressed;
|
||||||
|
}
|
||||||
|
|
||||||
if ((deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) != 0) {
|
if ((deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) != 0) {
|
||||||
ENCODE(deltaS);
|
ENCODE(deltaS);
|
||||||
@ -292,23 +296,24 @@ u_int vj_compress_tcp(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((deltaL = ntohl(th->th_ack) - ntohl(oth->th_ack)) != 0) {
|
if ((deltaL = ntohl(th->th_ack) - ntohl(oth->th_ack)) != 0) {
|
||||||
if (deltaL > 0xffff)
|
if (deltaL > 0xffff) {
|
||||||
goto uncompressed;
|
goto uncompressed;
|
||||||
|
}
|
||||||
deltaA = (u_short)deltaL;
|
deltaA = (u_short)deltaL;
|
||||||
ENCODE(deltaA);
|
ENCODE(deltaA);
|
||||||
changes |= NEW_A;
|
changes |= NEW_A;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((deltaL = ntohl(th->th_seq) - ntohl(oth->th_seq)) != 0) {
|
if ((deltaL = ntohl(th->th_seq) - ntohl(oth->th_seq)) != 0) {
|
||||||
if (deltaL > 0xffff)
|
if (deltaL > 0xffff) {
|
||||||
goto uncompressed;
|
goto uncompressed;
|
||||||
|
}
|
||||||
deltaS = (u_short)deltaL;
|
deltaS = (u_short)deltaL;
|
||||||
ENCODE(deltaS);
|
ENCODE(deltaS);
|
||||||
changes |= NEW_S;
|
changes |= NEW_S;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(changes) {
|
switch(changes) {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
/*
|
/*
|
||||||
* Nothing changed. If this packet contains data and the
|
* Nothing changed. If this packet contains data and the
|
||||||
@ -319,8 +324,9 @@ u_int vj_compress_tcp(
|
|||||||
* in case the other side missed the compressed version.
|
* in case the other side missed the compressed version.
|
||||||
*/
|
*/
|
||||||
if (ip->ip_len != cs->cs_ip.ip_len &&
|
if (ip->ip_len != cs->cs_ip.ip_len &&
|
||||||
ntohs(cs->cs_ip.ip_len) == hlen)
|
ntohs(cs->cs_ip.ip_len) == hlen) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* (fall through) */
|
/* (fall through) */
|
||||||
|
|
||||||
@ -354,8 +360,9 @@ u_int vj_compress_tcp(
|
|||||||
ENCODEZ(deltaS);
|
ENCODEZ(deltaS);
|
||||||
changes |= NEW_I;
|
changes |= NEW_I;
|
||||||
}
|
}
|
||||||
if (th->th_flags & TCP_PSH)
|
if (th->th_flags & TCP_PSH) {
|
||||||
changes |= TCP_PUSH_BIT;
|
changes |= TCP_PUSH_BIT;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Grab the cksum before we overwrite it below. Then update our
|
* Grab the cksum before we overwrite it below. Then update our
|
||||||
* state with this packet's header.
|
* state with this packet's header.
|
||||||
@ -413,7 +420,8 @@ uncompressed:
|
|||||||
/*
|
/*
|
||||||
* Called when we may have missed a packet.
|
* Called when we may have missed a packet.
|
||||||
*/
|
*/
|
||||||
void vj_uncompress_err(struct vjcompress *comp)
|
void
|
||||||
|
vj_uncompress_err(struct vjcompress *comp)
|
||||||
{
|
{
|
||||||
comp->flags |= VJF_TOSS;
|
comp->flags |= VJF_TOSS;
|
||||||
INCR(vjs_errorin);
|
INCR(vjs_errorin);
|
||||||
@ -423,10 +431,8 @@ void vj_uncompress_err(struct vjcompress *comp)
|
|||||||
* "Uncompress" a packet of type TYPE_UNCOMPRESSED_TCP.
|
* "Uncompress" a packet of type TYPE_UNCOMPRESSED_TCP.
|
||||||
* Return 0 on success, -1 on failure.
|
* Return 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
int vj_uncompress_uncomp(
|
int
|
||||||
struct pbuf *nb,
|
vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp)
|
||||||
struct vjcompress *comp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
register u_int hlen;
|
register u_int hlen;
|
||||||
register struct cstate *cs;
|
register struct cstate *cs;
|
||||||
@ -462,10 +468,8 @@ int vj_uncompress_uncomp(
|
|||||||
* This procedure replaces the compressed header with the uncompressed
|
* This procedure replaces the compressed header with the uncompressed
|
||||||
* header and returns the length of the VJ header.
|
* header and returns the length of the VJ header.
|
||||||
*/
|
*/
|
||||||
int vj_uncompress_tcp(
|
int
|
||||||
struct pbuf **nb,
|
vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp)
|
||||||
struct vjcompress *comp
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
u_char *cp;
|
u_char *cp;
|
||||||
struct tcphdr *th;
|
struct tcphdr *th;
|
||||||
@ -507,10 +511,11 @@ int vj_uncompress_tcp(
|
|||||||
th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
|
th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
|
||||||
th->th_sum = htons((*cp << 8) | cp[1]);
|
th->th_sum = htons((*cp << 8) | cp[1]);
|
||||||
cp += 2;
|
cp += 2;
|
||||||
if (changes & TCP_PUSH_BIT)
|
if (changes & TCP_PUSH_BIT) {
|
||||||
th->th_flags |= TCP_PSH;
|
th->th_flags |= TCP_PSH;
|
||||||
else
|
} else {
|
||||||
th->th_flags &=~ TCP_PSH;
|
th->th_flags &=~ TCP_PSH;
|
||||||
|
}
|
||||||
|
|
||||||
switch (changes & SPECIALS_MASK) {
|
switch (changes & SPECIALS_MASK) {
|
||||||
case SPECIAL_I:
|
case SPECIAL_I:
|
||||||
@ -534,14 +539,18 @@ int vj_uncompress_tcp(
|
|||||||
if (changes & NEW_U) {
|
if (changes & NEW_U) {
|
||||||
th->th_flags |= TCP_URG;
|
th->th_flags |= TCP_URG;
|
||||||
DECODEU(th->th_urp);
|
DECODEU(th->th_urp);
|
||||||
} else
|
} else {
|
||||||
th->th_flags &=~ TCP_URG;
|
th->th_flags &=~ TCP_URG;
|
||||||
if (changes & NEW_W)
|
}
|
||||||
|
if (changes & NEW_W) {
|
||||||
DECODES(th->th_win);
|
DECODES(th->th_win);
|
||||||
if (changes & NEW_A)
|
}
|
||||||
|
if (changes & NEW_A) {
|
||||||
DECODEL(th->th_ack);
|
DECODEL(th->th_ack);
|
||||||
if (changes & NEW_S)
|
}
|
||||||
|
if (changes & NEW_S) {
|
||||||
DECODEL(th->th_seq);
|
DECODEL(th->th_seq);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (changes & NEW_I) {
|
if (changes & NEW_I) {
|
||||||
@ -577,8 +586,9 @@ int vj_uncompress_tcp(
|
|||||||
/* recompute the ip header checksum */
|
/* recompute the ip header checksum */
|
||||||
bp = (u_short *) &cs->cs_ip;
|
bp = (u_short *) &cs->cs_ip;
|
||||||
cs->cs_ip.ip_sum = 0;
|
cs->cs_ip.ip_sum = 0;
|
||||||
for (tmp = 0; hlen > 0; hlen -= 2)
|
for (tmp = 0; hlen > 0; hlen -= 2) {
|
||||||
tmp += *bp++;
|
tmp += *bp++;
|
||||||
|
}
|
||||||
tmp = (tmp & 0xffff) + (tmp >> 16);
|
tmp = (tmp & 0xffff) + (tmp >> 16);
|
||||||
tmp = (tmp & 0xffff) + (tmp >> 16);
|
tmp = (tmp & 0xffff) + (tmp >> 16);
|
||||||
cs->cs_ip.ip_sum = (u_short)(~tmp);
|
cs->cs_ip.ip_sum = (u_short)(~tmp);
|
||||||
@ -590,7 +600,6 @@ int vj_uncompress_tcp(
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(LWIP_MEM_ALIGN(n0->payload) != n0->payload) {
|
if(LWIP_MEM_ALIGN(n0->payload) != n0->payload) {
|
||||||
struct pbuf *np, *q;
|
struct pbuf *np, *q;
|
||||||
u8_t *bufptr;
|
u8_t *bufptr;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Definitions for tcp compression routines.
|
* Definitions for tcp compression routines.
|
||||||
*
|
*
|
||||||
* $Id: vj.h,v 1.4 2004/02/07 00:30:03 likewise Exp $
|
* $Id: vj.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 1989 Regents of the University of California.
|
* Copyright (c) 1989 Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user