mirror of https://github.com/oxen-io/lokinet
hmm some BSDs implement SIOCSIFNAME, Solaris (being SVR4 UNIX) definitely does.
Implemented.
This commit is contained in:
parent
3ccb425021
commit
806e9f82a3
|
@ -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
|
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue