/[lwip]/lwip/src/netif/ppp/ppp.c
ViewVC logotype

Diff of /lwip/src/netif/ppp/ppp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4.2.4 by jani, Mon Nov 3 07:57:21 2003 UTC revision 1.4.2.5 by jani, Mon Nov 24 08:23:55 2003 UTC
# Line 153  typedef struct PPPControl_s { Line 153  typedef struct PPPControl_s {
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    
# Line 296  void pppInit(void) Line 296  void pppInit(void)
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            
# Line 537  static struct pbuf *pppAppend(u_char c, Line 536  static struct pbuf *pppAppend(u_char c,
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
# Line 1003  int sifup(int pd) Line 1002  int sifup(int pd)
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)
# Line 1046  int sifdown(int pd) Line 1043  int sifdown(int pd)
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  }  }
# Line 1126  int sifdefaultroute(int pd, u32_t l, u32 Line 1121  int sifdefaultroute(int pd, u32_t l, u32
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 */
# Line 1324  static void pppInput(void *arg) Line 1319  static void pppInput(void *arg)
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. */
# Line 1342  static void pppInput(void *arg) Line 1337  static void pppInput(void *arg)
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. */
# Line 1356  static void pppInput(void *arg) Line 1351  static void pppInput(void *arg)
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          {          {

Legend:
Removed from v.1.4.2.4  
changed lines
  Added in v.1.4.2.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26