mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-13 22:09:16 +08:00
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.
This commit is contained in:
parent
c83cf5cba8
commit
ab7739a574
@ -235,6 +235,8 @@ ifconfig_(rtems_bsd_rc_conf* rc_conf,
|
|||||||
{
|
{
|
||||||
const char** args;
|
const char** args;
|
||||||
int arg;
|
int arg;
|
||||||
|
int ifconfig_argc = 0;
|
||||||
|
bool add_up = true;
|
||||||
int r;
|
int r;
|
||||||
const char const* ifconfig_show[] = { "ifconfig", ifname, NULL };
|
const char const* ifconfig_show[] = { "ifconfig", ifname, NULL };
|
||||||
|
|
||||||
@ -249,17 +251,25 @@ ifconfig_(rtems_bsd_rc_conf* rc_conf,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
args[0] = "ifconfig";
|
args[ifconfig_argc++] = "ifconfig";
|
||||||
args[1] = ifname;
|
args[ifconfig_argc++] = ifname;
|
||||||
|
|
||||||
for (arg = 1; arg < argc; ++arg)
|
for (arg = 1; arg < argc; ++arg) {
|
||||||
args[arg + 1] = argv[arg];
|
if (strcasecmp("DHCP", argv[arg]) == 0 ||
|
||||||
|
strcasecmp("SYNCDHCP", argv[arg]) == 0) {
|
||||||
|
add_up = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
args[ifconfig_argc++] = argv[arg];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
args[argc + 1] = "up";
|
if (add_up)
|
||||||
|
args[ifconfig_argc++] = "up";
|
||||||
|
|
||||||
rtems_bsd_rc_conf_print_cmd(rc_conf, "ifconfig", argc + 2, args);
|
rtems_bsd_rc_conf_print_cmd(rc_conf, "ifconfig", ifconfig_argc, args);
|
||||||
|
|
||||||
r = rtems_bsd_command_ifconfig(argc + 2, (char**) args);
|
r = rtems_bsd_command_ifconfig(ifconfig_argc, (char**) args);
|
||||||
|
|
||||||
free(args);
|
free(args);
|
||||||
|
|
||||||
@ -374,10 +384,12 @@ show_interfaces(const char* msg, struct ifaddrs* ifap)
|
|||||||
static int
|
static int
|
||||||
dhcp_check(rtems_bsd_rc_conf_argc_argv* aa)
|
dhcp_check(rtems_bsd_rc_conf_argc_argv* aa)
|
||||||
{
|
{
|
||||||
if (aa->argc == 2 &&
|
int arg;
|
||||||
(strcasecmp("DHCP", aa->argv[1]) == 0 ||
|
for (arg = 0; arg < aa->argc; ++arg) {
|
||||||
strcasecmp("SYNCDHCP", aa->argv[1]) == 0))
|
if (strcasestr(aa->argv[1], "DHCP") != NULL ||
|
||||||
|
strcasestr(aa->argv[1], "SYNCDHCP") != NULL)
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,12 +431,14 @@ setup_interfaces(rtems_bsd_rc_conf* rc_conf,
|
|||||||
if (dhcp_check(aa)) {
|
if (dhcp_check(aa)) {
|
||||||
*dhcp = true;
|
*dhcp = true;
|
||||||
}
|
}
|
||||||
else {
|
/*
|
||||||
|
* A DHCP ifconfig can have other options we need to set on the
|
||||||
|
* interface.
|
||||||
|
*/
|
||||||
show_result(iface, ifconfig_(rc_conf, ifa->ifa_name, aa->argc, aa->argv));
|
show_result(iface, ifconfig_(rc_conf, ifa->ifa_name, aa->argc, aa->argv));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user