hmm some BSDs implement SIOCSIFNAME, Solaris (being SVR4 UNIX) definitely does.

Implemented.
This commit is contained in:
despair86 2018-08-21 09:29:05 -05:00
parent 3ccb425021
commit 806e9f82a3
3 changed files with 39 additions and 13 deletions

View File

@ -33,13 +33,19 @@ tuntap_sys_set_ipv6(struct device *dev, t_tun_in6_addr *s6, uint32_t bits) {
return -1;
}
#ifndef SIOCSIFNAME
int
tuntap_sys_set_ifname(struct device *dev, const char *ifname, size_t len) {
(void)dev;
(void)ifname;
(void)len;
tuntap_log(TUNTAP_LOG_NOTICE,
"Your system does not support tuntap_set_ifname()");
return -1;
tuntap_sys_set_ifname(struct device *dev, const char *ifname, size_t len)
{
(void)dev;
(void)ifname;
(void)len;
tuntap_log(TUNTAP_LOG_NOTICE,
"Your system does not support tuntap_set_ifname()");
/* just leave it as tunX, there doesn't seem to be any
* practical manner of setting this param in NetBSD and its forks :-(
*/
return 0;
}
#endif

View File

@ -283,3 +283,17 @@ tuntap_sys_set_descr(struct device *dev, const char *descr, size_t len) {
#endif
}
int
tuntap_sys_set_ifname(struct device *dev, const char *ifname, size_t len) {
struct ifreq ifr;
(void)strncpy(ifr.ifr_name, dev->if_name, IF_NAMESIZE);
(void)strncpy(ifr.ifr_newname, ifname, len);
if (ioctl(dev->ctrl_sock, SIOCSIFNAME, &ifr) == -1) {
perror(NULL);
tuntap_log(TUNTAP_LOG_ERR, "Can't set interface name");
return -1;
}
return 0;
}

View File

@ -73,12 +73,18 @@ tuntap_sys_set_ipv6(struct device *dev, t_tun_in6_addr *s6, uint32_t imask)
}
int
tuntap_sys_set_ifname(struct device *dev, const char *ifname, size_t len)
{
(void)dev;
(void)ifname;
(void)len;
return -1;
tuntap_sys_set_ifname(struct device *dev, const char *ifname, size_t len) {
struct ifreq ifr;
(void)strncpy(ifr.ifr_name, dev->if_name, IF_NAMESIZE);
(void)strncpy(ifr.ifr_newname, ifname, len);
if (ioctl(dev->ctrl_sock, SIOCSIFNAME, &ifr) == -1) {
perror(NULL);
tuntap_log(TUNTAP_LOG_ERR, "Can't set interface name");
return -1;
}
return 0;
}
int