static int enslave(char *master_ifname, char *slave_ifname);
static int release(char *master_ifname, char *slave_ifname);
+static void strncpy_IFNAMSIZ(char *dst, const char *src)
+{
+ strncpy(dst, src, IFNAMSIZ);
+}
int ifenslave_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ifenslave_main(int argc ATTRIBUTE_UNUSED, char **argv)
struct ethtool_drvinfo info;
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, master_ifname);
ifr.ifr_data = (caddr_t)&info;
info.cmd = ETHTOOL_GDRVINFO;
slave_ifname);
}
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, master_ifname);
+ strncpy_IFNAMSIZ(ifr.ifr_slave, slave_ifname);
if (ioctl(skfd, SIOCBONDCHANGEACTIVE, &ifr) < 0
&& ioctl(skfd, BOND_CHANGE_ACTIVE_OLD, &ifr) < 0
) {
}
/* Do the real thing */
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, master_ifname);
+ strncpy_IFNAMSIZ(ifr.ifr_slave, slave_ifname);
if (ioctl(skfd, SIOCBONDENSLAVE, &ifr) < 0
&& ioctl(skfd, BOND_ENSLAVE_OLD, &ifr) < 0
) {
return 1;
}
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
- strncpy(ifr.ifr_slave, slave_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, master_ifname);
+ strncpy_IFNAMSIZ(ifr.ifr_slave, slave_ifname);
if (ioctl(skfd, SIOCBONDRELEASE, &ifr) < 0
&& ioctl(skfd, BOND_RELEASE_OLD, &ifr) < 0
) {
{
int res;
- strncpy(dd->mtu.ifr_name, ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(dd->mtu.ifr_name, ifname);
res = ioctl(skfd, SIOCGIFMTU, &dd->mtu);
- strncpy(dd->flags.ifr_name, ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(dd->flags.ifr_name, ifname);
res |= ioctl(skfd, SIOCGIFFLAGS, &dd->flags);
- strncpy(dd->hwaddr.ifr_name, ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(dd->hwaddr.ifr_name, ifname);
res |= ioctl(skfd, SIOCGIFHWADDR, &dd->hwaddr);
return res;
static int get_slave_flags(char *slave_ifname)
{
- strncpy(slave.flags.ifr_name, slave_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(slave.flags.ifr_name, slave_ifname);
return ioctl(skfd, SIOCGIFFLAGS, &slave.flags);
}
{
struct ifreq ifr;
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, master_ifname);
memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr));
return ioctl(skfd, SIOCSIFHWADDR, &ifr);
}
{
struct ifreq ifr;
- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, slave_ifname);
memcpy(&(ifr.ifr_hwaddr), hwaddr, sizeof(struct sockaddr));
return ioctl(skfd, SIOCSIFHWADDR, &ifr);
}
struct ifreq ifr;
ifr.ifr_mtu = mtu;
- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, slave_ifname);
return ioctl(skfd, SIOCSIFMTU, &ifr);
}
struct ifreq ifr;
ifr.ifr_flags = flags;
- strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
return ioctl(skfd, SIOCSIFFLAGS, &ifr);
}
{
struct ifreq ifr;
- strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, ifname);
ifr.ifr_addr.sa_family = AF_INET;
memset(ifr.ifr_addr.sa_data, 0, sizeof(ifr.ifr_addr.sa_data));
return ioctl(skfd, SIOCSIFADDR, &ifr);
int i;
for (i = 0; i < ARRAY_SIZE(ifra); i++) {
- strncpy(ifr.ifr_name, master_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, master_ifname);
res = ioctl(skfd, ifra[i].g_ioctl, &ifr);
if (res < 0) {
ifr.ifr_addr.sa_family = AF_INET;
sizeof(ifr.ifr_addr.sa_data));
}
- strncpy(ifr.ifr_name, slave_ifname, IFNAMSIZ);
+ strncpy_IFNAMSIZ(ifr.ifr_name, slave_ifname);
res = ioctl(skfd, ifra[i].s_ioctl, &ifr);
if (res < 0)
return res;
struct interface {
struct interface *next, *prev;
- char name[IFNAMSIZ]; /* interface name */
- short type; /* if type */
- short flags; /* various flags */
- int metric; /* routing metric */
- int mtu; /* MTU value */
- int tx_queue_len; /* transmit queue length */
- struct ifmap map; /* hardware setup */
- struct sockaddr addr; /* IP address */
- struct sockaddr dstaddr; /* P-P IP address */
- struct sockaddr broadaddr; /* IP broadcast address */
- struct sockaddr netmask; /* IP network mask */
+ char name[IFNAMSIZ]; /* interface name */
+ short type; /* if type */
+ short flags; /* various flags */
+ int metric; /* routing metric */
+ int mtu; /* MTU value */
+ int tx_queue_len; /* transmit queue length */
+ struct ifmap map; /* hardware setup */
+ struct sockaddr addr; /* IP address */
+ struct sockaddr dstaddr; /* P-P IP address */
+ struct sockaddr broadaddr; /* IP broadcast address */
+ struct sockaddr netmask; /* IP network mask */
int has_ip;
- char hwaddr[32]; /* HW address */
+ char hwaddr[32]; /* HW address */
int statistics_valid;
- struct user_net_device_stats stats; /* statistics */
- int keepalive; /* keepalive value for SLIP */
- int outfill; /* outfill value for SLIP */
+ struct user_net_device_stats stats; /* statistics */
+ int keepalive; /* keepalive value for SLIP */
+ int outfill; /* outfill value for SLIP */
};
}
new = xzalloc(sizeof(*new));
- safe_strncpy(new->name, name, IFNAMSIZ);
+ strncpy(new->name, name, IFNAMSIZ);
nextp = ife ? &ife->next : &int_list;
new->prev = ife;
new->next = *nextp;