153 |
struct vjcompress vjComp; /* Van Jabobsen compression header. */ |
struct vjcompress vjComp; /* Van Jabobsen compression header. */ |
154 |
#endif |
#endif |
155 |
|
|
156 |
struct netif *netif; |
struct netif netif; |
157 |
|
|
158 |
struct ppp_addrs addrs; |
struct ppp_addrs addrs; |
159 |
|
|
296 |
|
|
297 |
for (i = 0; i < NUM_PPP; i++) { |
for (i = 0; i < NUM_PPP; i++) { |
298 |
pppControl[i].openFlag = 0; |
pppControl[i].openFlag = 0; |
|
pppControl[i].netif = NULL; |
|
299 |
|
|
300 |
subnetMask = htonl(0xffffff00); |
subnetMask = htonl(0xffffff00); |
301 |
|
|
536 |
/* Send a packet on the given connection. */ |
/* Send a packet on the given connection. */ |
537 |
static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *ipaddr) |
static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *ipaddr) |
538 |
{ |
{ |
539 |
int pd = (int)netif->state; |
int pd = (int)netif->state; |
540 |
u_short protocol = PPP_IP; |
u_short protocol = PPP_IP; |
541 |
PPPControl *pc = &pppControl[pd]; |
PPPControl *pc = &pppControl[pd]; |
542 |
u_int fcsOut = PPP_INITFCS; |
u_int fcsOut = PPP_INITFCS; |
543 |
struct pbuf *headMB = NULL, *tailMB = NULL, *p; |
struct pbuf *headMB = NULL, *tailMB = NULL, *p; |
544 |
u_char c; |
u_char c; |
545 |
|
|
546 |
(void)ipaddr; |
(void)ipaddr; |
547 |
|
|
548 |
/* Validate parameters. */ |
/* Validate parameters. */ |
549 |
/* We let any protocol value go through - it can't hurt us |
/* We let any protocol value go through - it can't hurt us |
1002 |
st = 0; |
st = 0; |
1003 |
PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd)); |
PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd)); |
1004 |
} else { |
} else { |
1005 |
if(pc->netif) |
netif_remove(&pc->netif); |
1006 |
netif_remove(pc->netif); |
if (netif_add(&pc->netif, &pc->addrs.our_ipaddr, &pc->addrs.netmask, &pc->addrs.his_ipaddr, (void *)pd, pppifNetifInit, ip_input)) { |
1007 |
pc->netif = netif_add(&pc->addrs.our_ipaddr, &pc->addrs.netmask, &pc->addrs.his_ipaddr, (void *)pd, pppifNetifInit, ip_input); |
pc->if_up = 1; |
1008 |
if(pc->netif) { |
pc->errCode = PPPERR_NONE; |
|
pc->if_up = 1; |
|
|
pc->errCode = PPPERR_NONE; |
|
1009 |
|
|
1010 |
PPPDEBUG((LOG_DEBUG, "sifup: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); |
PPPDEBUG((LOG_DEBUG, "sifup: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); |
1011 |
if(pc->linkStatusCB) |
if(pc->linkStatusCB) |
1043 |
PPPDEBUG((LOG_WARNING, "sifdown[%d]: bad parms\n", pd)); |
PPPDEBUG((LOG_WARNING, "sifdown[%d]: bad parms\n", pd)); |
1044 |
} else { |
} else { |
1045 |
pc->if_up = 0; |
pc->if_up = 0; |
1046 |
if(pc->netif) |
netif_remove(&pc->netif); |
1047 |
netif_remove(pc->netif); |
PPPDEBUG((LOG_DEBUG, "sifdown: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); |
1048 |
pc->netif = NULL; |
if(pc->linkStatusCB) |
1049 |
PPPDEBUG((LOG_DEBUG, "sifdown: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); |
pc->linkStatusCB(pc->linkStatusCtx, PPPERR_CONNECT, NULL); |
|
if(pc->linkStatusCB) |
|
|
pc->linkStatusCB(pc->linkStatusCtx, PPPERR_CONNECT, NULL); |
|
1050 |
} |
} |
1051 |
return st; |
return st; |
1052 |
} |
} |
1121 |
st = 0; |
st = 0; |
1122 |
PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd)); |
PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd)); |
1123 |
} else { |
} else { |
1124 |
netif_set_default(pc->netif); |
netif_set_default(&pc->netif); |
1125 |
} |
} |
1126 |
|
|
1127 |
/* TODO: check how PPP handled the netMask, previously not set by ipSetDefault */ |
/* TODO: check how PPP handled the netMask, previously not set by ipSetDefault */ |
1319 |
* pass the result to IP. |
* pass the result to IP. |
1320 |
*/ |
*/ |
1321 |
if (vj_uncompress_tcp(&nb, &pppControl[pd].vjComp) >= 0) { |
if (vj_uncompress_tcp(&nb, &pppControl[pd].vjComp) >= 0) { |
1322 |
pppControl[pd].netif->input(nb, pppControl[pd].netif); |
pppControl[pd].netif.input(nb, &pppControl[pd].netif); |
1323 |
return; |
return; |
1324 |
} |
} |
1325 |
/* Something's wrong so drop it. */ |
/* Something's wrong so drop it. */ |
1337 |
* the packet to IP. |
* the packet to IP. |
1338 |
*/ |
*/ |
1339 |
if (vj_uncompress_uncomp(nb, &pppControl[pd].vjComp) >= 0) { |
if (vj_uncompress_uncomp(nb, &pppControl[pd].vjComp) >= 0) { |
1340 |
pppControl[pd].netif->input(nb, pppControl[pd].netif); |
pppControl[pd].netif.input(nb, &pppControl[pd].netif); |
1341 |
return; |
return; |
1342 |
} |
} |
1343 |
/* Something's wrong so drop it. */ |
/* Something's wrong so drop it. */ |
1351 |
break; |
break; |
1352 |
case PPP_IP: /* Internet Protocol */ |
case PPP_IP: /* Internet Protocol */ |
1353 |
PPPDEBUG((LOG_INFO, "pppInput[%d]: ip in pbuf len=%d\n", pd, nb->len)); |
PPPDEBUG((LOG_INFO, "pppInput[%d]: ip in pbuf len=%d\n", pd, nb->len)); |
1354 |
pppControl[pd].netif->input(nb, pppControl[pd].netif); |
pppControl[pd].netif.input(nb, &pppControl[pd].netif); |
1355 |
return; |
return; |
1356 |
default: |
default: |
1357 |
{ |
{ |