Magellan Linux

Diff of /trunk/mkinitrd-magellan/klibc/usr/kinit/ipconfig/main.c

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

revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC revision 815 by niro, Fri Apr 24 18:32:46 2009 UTC
# Line 85  static void configure_device(struct netd Line 85  static void configure_device(struct netd
85         dev->name, dev->mtu);         dev->name, dev->mtu);
86    
87   if (netdev_setaddress(dev))   if (netdev_setaddress(dev))
88   printf("IP-Config: failed to set addresses on %s\n", dev->name);   printf("IP-Config: failed to set addresses on %s\n",
89           dev->name);
90   if (netdev_setdefaultroute(dev))   if (netdev_setdefaultroute(dev))
91   printf("IP-Config: failed to set default route on %s\n",   printf("IP-Config: failed to set default route on %s\n",
92         dev->name);         dev->name);
# Line 192  static int process_receive_event(struct Line 193  static int process_receive_event(struct
193   case -1:   case -1:
194   s->state = DEVST_ERROR;   s->state = DEVST_ERROR;
195   break;   break;
196   case 1: /* Offer received */   case DHCPOFFER: /* Offer received */
197   s->state = DEVST_DHCPREQ;   s->state = DEVST_DHCPREQ;
198   dhcp_send_request(s->dev);   dhcp_send_request(s->dev);
199   break;   break;
# Line 205  static int process_receive_event(struct Line 206  static int process_receive_event(struct
206   case -1: /* error */   case -1: /* error */
207   s->state = DEVST_ERROR;   s->state = DEVST_ERROR;
208   break;   break;
209   case 1: /* ACK received */   case DHCPACK: /* ACK received */
210   s->state = DEVST_COMPLETE;   s->state = DEVST_COMPLETE;
211   break;   break;
212   case 2: /* NAK received */   case DHCPNAK: /* NAK received */
213   s->state = DEVST_DHCPDISC;   s->state = DEVST_DHCPDISC;
214   break;   break;
215   }   }
# Line 482  static int parse_device(struct netdev *d Line 483  static int parse_device(struct netdev *d
483   }   }
484    
485   if (!strchr(ip, ':')) {   if (!strchr(ip, ':')) {
486   /* Only one option, e.g. "ip=dhcp", or it's an interface name */   /* Only one option, e.g. "ip=dhcp", or an interface name */
487   if (is_ip) {   if (is_ip) {
488   dev->caps = parse_proto(ip);   dev->caps = parse_proto(ip);
489   bringup_first = 1;   bringup_first = 1;
# Line 495  static int parse_device(struct netdev *d Line 496  static int parse_device(struct netdev *d
496   *cp++ = '\0';   *cp++ = '\0';
497   }   }
498   if (opt > 6) {   if (opt > 6) {
499   fprintf(stderr, "%s: too many options for %s\n",   fprintf(stderr,
500     "%s: too many options for %s\n",
501   progname, dev->name);   progname, dev->name);
502   longjmp(abort_buf, 1);   longjmp(abort_buf, 1);
503   }   }
# Line 534  static int parse_device(struct netdev *d Line 536  static int parse_device(struct netdev *d
536   if (dev->name == NULL ||   if (dev->name == NULL ||
537      dev->name[0] == '\0' || strcmp(dev->name, "all") == 0) {      dev->name[0] == '\0' || strcmp(dev->name, "all") == 0) {
538   add_all_devices(dev);   add_all_devices(dev);
539     bringup_first = 1;
540   return 0;   return 0;
541   }   }
542   return 1;   return 1;
# Line 621  static int add_all_devices(struct netdev Line 624  static int add_all_devices(struct netdev
624   return 0;   return 0;
625    
626   while ((de = readdir(d)) != NULL) {   while ((de = readdir(d)) != NULL) {
627   /* This excludes devices beginning with dots or "dummy", as well as . or .. */   /* This excludes devices beginning with dots or "dummy",
628       as well as . or .. */
629   if (de->d_name[0] == '.' || !strcmp(de->d_name, ".."))   if (de->d_name[0] == '.' || !strcmp(de->d_name, ".."))
630   continue;   continue;
631   i = snprintf(t, PATH_MAX - 1, "%s/%s/flags", sysfs_class_net,   i = snprintf(t, PATH_MAX - 1, "%s/%s/flags", sysfs_class_net,
# Line 777  int ipconfig_main(int argc, char *argv[] Line 781  int ipconfig_main(int argc, char *argv[]
781   if (check_autoconfig()) {   if (check_autoconfig()) {
782   if (cfg_local_port != LOCAL_PORT) {   if (cfg_local_port != LOCAL_PORT) {
783   printf("IP-Config: binding source port to %d, "   printf("IP-Config: binding source port to %d, "
784         "dest to %d\n", cfg_local_port, cfg_remote_port);         "dest to %d\n",
785           cfg_local_port, cfg_remote_port);
786   }   }
787   loop();   loop();
788   }   }

Legend:
Removed from v.532  
changed lines
  Added in v.815