The 'ip', 'snet', and 'bcast' commands have been replaced by 'ip4'. Remove
them.
This commit is contained in:
parent
a130448d46
commit
94d6b1fb2e
@ -132,8 +132,6 @@ static void perform_ip4set(const char *buf, size_t len)
|
|||||||
action Dispatch {
|
action Dispatch {
|
||||||
switch (cl.state) {
|
switch (cl.state) {
|
||||||
case STATE_IP4SET: perform_ip4set(tb, arg_len); break;
|
case STATE_IP4SET: perform_ip4set(tb, arg_len); break;
|
||||||
case STATE_IP: perform_ip(tb, arg_len); break;
|
|
||||||
case STATE_SUBNET: perform_subnet(tb, arg_len); break;
|
|
||||||
case STATE_TIMEZONE: perform_timezone( tb, arg_len); break;
|
case STATE_TIMEZONE: perform_timezone( tb, arg_len); break;
|
||||||
case STATE_ROUTER: perform_router(tb, arg_len); break;
|
case STATE_ROUTER: perform_router(tb, arg_len); break;
|
||||||
case STATE_DNS: perform_dns(tb, arg_len); break;
|
case STATE_DNS: perform_dns(tb, arg_len); break;
|
||||||
@ -142,7 +140,6 @@ static void perform_ip4set(const char *buf, size_t len)
|
|||||||
case STATE_DOMAIN: perform_domain(tb, arg_len); break;
|
case STATE_DOMAIN: perform_domain(tb, arg_len); break;
|
||||||
case STATE_IPTTL: perform_ipttl(tb, arg_len); break;
|
case STATE_IPTTL: perform_ipttl(tb, arg_len); break;
|
||||||
case STATE_MTU: perform_mtu(tb, arg_len); break;
|
case STATE_MTU: perform_mtu(tb, arg_len); break;
|
||||||
case STATE_BROADCAST: perform_broadcast(tb, arg_len); break;
|
|
||||||
case STATE_NTPSVR: perform_ntpsrv(tb, arg_len); break;
|
case STATE_NTPSVR: perform_ntpsrv(tb, arg_len); break;
|
||||||
case STATE_WINS: perform_wins(tb, arg_len); break;
|
case STATE_WINS: perform_wins(tb, arg_len); break;
|
||||||
default:
|
default:
|
||||||
@ -161,11 +158,7 @@ static void perform_ip4set(const char *buf, size_t len)
|
|||||||
u16_arg = (extend{2} > ArgSt % ArgEn) terminator;
|
u16_arg = (extend{2} > ArgSt % ArgEn) terminator;
|
||||||
u8_arg = (extend{1} > ArgSt % ArgEn) terminator;
|
u8_arg = (extend{1} > ArgSt % ArgEn) terminator;
|
||||||
|
|
||||||
cmd_ip = ('ip:' % { cl.state = STATE_IP; }
|
cmd_ip = ('routr:' % { cl.state = STATE_ROUTER; }) ip_arg;
|
||||||
|'snet:' % { cl.state = STATE_SUBNET; }
|
|
||||||
|'routr:' % { cl.state = STATE_ROUTER; }
|
|
||||||
|'bcast:' % { cl.state = STATE_BROADCAST; }
|
|
||||||
) ip_arg;
|
|
||||||
cmd_ip4set = ('ip4:' % { cl.state = STATE_IP4SET; }) ip4set_arg;
|
cmd_ip4set = ('ip4:' % { cl.state = STATE_IP4SET; }) ip4set_arg;
|
||||||
cmd_iplist = ('dns:' % { cl.state = STATE_DNS; }
|
cmd_iplist = ('dns:' % { cl.state = STATE_DNS; }
|
||||||
|'lpr:' % { cl.state = STATE_LPRSVR; }
|
|'lpr:' % { cl.state = STATE_LPRSVR; }
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
enum ifchd_states {
|
enum ifchd_states {
|
||||||
STATE_NOTHING,
|
STATE_NOTHING,
|
||||||
STATE_IP4SET,
|
STATE_IP4SET,
|
||||||
STATE_IP,
|
|
||||||
STATE_SUBNET,
|
|
||||||
STATE_TIMEZONE,
|
STATE_TIMEZONE,
|
||||||
STATE_ROUTER,
|
STATE_ROUTER,
|
||||||
STATE_DNS,
|
STATE_DNS,
|
||||||
@ -16,7 +14,6 @@ enum ifchd_states {
|
|||||||
STATE_DOMAIN,
|
STATE_DOMAIN,
|
||||||
STATE_IPTTL,
|
STATE_IPTTL,
|
||||||
STATE_MTU,
|
STATE_MTU,
|
||||||
STATE_BROADCAST,
|
|
||||||
STATE_NTPSVR,
|
STATE_NTPSVR,
|
||||||
STATE_WINS
|
STATE_WINS
|
||||||
};
|
};
|
||||||
|
100
ndhc/ifset.c
100
ndhc/ifset.c
@ -269,76 +269,6 @@ retry_sendto:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Sets IP address on an interface and brings it up. */
|
|
||||||
void perform_ip(const char *str, size_t len)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
struct in_addr ipaddr;
|
|
||||||
struct ifreq ifrt;
|
|
||||||
struct sockaddr_in sin;
|
|
||||||
|
|
||||||
if (!str)
|
|
||||||
return;
|
|
||||||
if (inet_pton(AF_INET, str, &ipaddr) <= 0)
|
|
||||||
return;
|
|
||||||
if (set_if_flag(IFF_UP | IFF_RUNNING))
|
|
||||||
return;
|
|
||||||
|
|
||||||
strnkcpy(ifrt.ifr_name, client_config.interface, IFNAMSIZ);
|
|
||||||
memset(&sin, 0, sizeof(struct sockaddr));
|
|
||||||
sin.sin_family = AF_INET;
|
|
||||||
sin.sin_addr = ipaddr;
|
|
||||||
memcpy(&ifrt.ifr_addr, &sin, sizeof(struct sockaddr));
|
|
||||||
|
|
||||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (fd == -1) {
|
|
||||||
log_line("%s: (perform_ip) failed to open interface socket: %s",
|
|
||||||
client_config.interface, strerror(errno));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ioctl(fd, SIOCSIFADDR, &ifrt) < 0)
|
|
||||||
log_line("%s: failed to configure IP: %s",
|
|
||||||
client_config.interface, strerror(errno));
|
|
||||||
else
|
|
||||||
log_line("Interface IP set to: '%s'", str);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sets the subnet mask on an interface. */
|
|
||||||
void perform_subnet(const char *str, size_t len)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
struct in_addr subnet;
|
|
||||||
struct ifreq ifrt;
|
|
||||||
struct sockaddr_in sin;
|
|
||||||
|
|
||||||
if (!str)
|
|
||||||
return;
|
|
||||||
if (inet_pton(AF_INET, str, &subnet) <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
strnkcpy(ifrt.ifr_name, client_config.interface, IFNAMSIZ);
|
|
||||||
memset(&sin, 0, sizeof(struct sockaddr));
|
|
||||||
sin.sin_family = AF_INET;
|
|
||||||
sin.sin_addr = subnet;
|
|
||||||
memcpy(&ifrt.ifr_addr, &sin, sizeof(struct sockaddr));
|
|
||||||
|
|
||||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (fd == -1) {
|
|
||||||
log_line("%s: (perform_ip) failed to open interface socket: %s",
|
|
||||||
client_config.interface, strerror(errno));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ioctl(fd, SIOCSIFNETMASK, &ifrt) < 0) {
|
|
||||||
sin.sin_addr.s_addr = 0xffffffff;
|
|
||||||
if (ioctl(fd, SIOCSIFNETMASK, &ifrt) < 0)
|
|
||||||
log_line("%s: failed to configure subnet: %s",
|
|
||||||
client_config.interface, strerror(errno));
|
|
||||||
} else
|
|
||||||
log_line("Interface subnet set to: '%s'", str);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void perform_router(const char *str, size_t len)
|
void perform_router(const char *str, size_t len)
|
||||||
{
|
{
|
||||||
struct rtentry rt;
|
struct rtentry rt;
|
||||||
@ -414,33 +344,3 @@ void perform_mtu(const char *str, size_t len)
|
|||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void perform_broadcast(const char *str, size_t len)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
struct in_addr broadcast;
|
|
||||||
struct ifreq ifrt;
|
|
||||||
struct sockaddr_in sin;
|
|
||||||
|
|
||||||
if (!str)
|
|
||||||
return;
|
|
||||||
if (inet_pton(AF_INET, str, &broadcast) <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
strnkcpy(ifrt.ifr_name, client_config.interface, IFNAMSIZ);
|
|
||||||
memset(&sin, 0, sizeof(struct sockaddr));
|
|
||||||
sin.sin_family = AF_INET;
|
|
||||||
sin.sin_addr = broadcast;
|
|
||||||
memcpy(&ifrt.ifr_addr, &sin, sizeof(struct sockaddr));
|
|
||||||
|
|
||||||
fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (fd == -1) {
|
|
||||||
log_line("%s: (perform_broadcast) failed to open interface socket: %s", client_config.interface, strerror(errno));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ioctl(fd, SIOCSIFBRDADDR, &ifrt) < 0)
|
|
||||||
log_line("%s: failed to set broadcast: %s",
|
|
||||||
client_config.interface, strerror(errno));
|
|
||||||
else
|
|
||||||
log_line("Broadcast address set to: '%s'", str);
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
@ -31,10 +31,7 @@
|
|||||||
extern void perform_ip_subnet_bcast(const char *str_ipaddr,
|
extern void perform_ip_subnet_bcast(const char *str_ipaddr,
|
||||||
const char *str_subnet,
|
const char *str_subnet,
|
||||||
const char *str_bcast);
|
const char *str_bcast);
|
||||||
extern void perform_ip(const char *str, size_t len);
|
|
||||||
extern void perform_subnet(const char *str, size_t len);
|
|
||||||
extern void perform_router(const char *str, size_t len);
|
extern void perform_router(const char *str, size_t len);
|
||||||
extern void perform_mtu(const char *str, size_t len);
|
extern void perform_mtu(const char *str, size_t len);
|
||||||
extern void perform_broadcast(const char *str, size_t len);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user