Changeset ab7739a in rtems-libbsd


Ignore:
Timestamp:
Aug 12, 2016, 3:55:37 AM (3 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
5283630d2c9d40deb0183696d278e02644fe4326, freebsd-9.3, bc2ba9a9cdc7381c2a4f2ae6ee303be636f31368
Children:
6634edb
Parents:
c83cf5c
git-author:
Chris Johns <chrisj@…> (08/12/16 03:55:37)
git-committer:
Chris Johns <chrisj@…> (08/12/16 05:56:36)
Message:

rc.conf/net: Let interface option appear on a DHCP ifconfig_ line.

An ifconfig_ line can have other options for the interface such as
ether or hardware checksum control. Allow these to be set on the
interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/rtems/rtems-bsd-rc-conf-net.c

    rc83cf5c rab7739a  
    236236  const char**      args;
    237237  int               arg;
     238  int               ifconfig_argc = 0;
     239  bool              add_up = true;
    238240  int               r;
    239241  const char const* ifconfig_show[] = { "ifconfig", ifname, NULL };
     
    250252  }
    251253
    252   args[0] = "ifconfig";
    253   args[1] = ifname;
    254 
    255   for (arg = 1; arg < argc; ++arg)
    256     args[arg + 1] = argv[arg];
    257 
    258   args[argc + 1] = "up";
    259 
    260   rtems_bsd_rc_conf_print_cmd(rc_conf, "ifconfig", argc + 2, args);
    261 
    262   r = rtems_bsd_command_ifconfig(argc + 2, (char**) args);
     254  args[ifconfig_argc++] = "ifconfig";
     255  args[ifconfig_argc++] = ifname;
     256
     257  for (arg = 1; arg < argc; ++arg) {
     258    if (strcasecmp("DHCP",     argv[arg]) == 0 ||
     259        strcasecmp("SYNCDHCP", argv[arg]) == 0) {
     260      add_up = false;
     261    }
     262    else {
     263      args[ifconfig_argc++] = argv[arg];
     264    }
     265  }
     266
     267  if (add_up)
     268    args[ifconfig_argc++] = "up";
     269
     270  rtems_bsd_rc_conf_print_cmd(rc_conf, "ifconfig", ifconfig_argc, args);
     271
     272  r = rtems_bsd_command_ifconfig(ifconfig_argc, (char**) args);
    263273
    264274  free(args);
     
    375385dhcp_check(rtems_bsd_rc_conf_argc_argv* aa)
    376386{
    377   if (aa->argc == 2 &&
    378       (strcasecmp("DHCP",     aa->argv[1]) == 0 ||
    379        strcasecmp("SYNCDHCP", aa->argv[1]) == 0))
    380     return true;
     387  int arg;
     388  for (arg = 0; arg < aa->argc; ++arg) {
     389    if (strcasestr(aa->argv[1], "DHCP") != NULL ||
     390        strcasestr(aa->argv[1], "SYNCDHCP") != NULL)
     391      return true;
     392  }
    381393  return false;
    382394}
     
    420432          *dhcp = true;
    421433        }
    422         else {
    423           show_result(iface, ifconfig_(rc_conf, ifa->ifa_name, aa->argc, aa->argv));
    424         }
     434        /*
     435         * A DHCP ifconfig can have other options we need to set on the
     436         * interface.
     437         */
     438        show_result(iface, ifconfig_(rc_conf, ifa->ifa_name, aa->argc, aa->argv));
    425439      }
    426440    }
Note: See TracChangeset for help on using the changeset viewer.