return 0;
}
-int ethtool_get_driver(int *fd, const char *ifname, char **ret) {
+int ethtool_get_driver(int *ethtool_fd, const char *ifname, char **ret) {
struct ethtool_drvinfo ecmd = {
.cmd = ETHTOOL_GDRVINFO
};
char *d;
int r;
- if (*fd < 0) {
- r = ethtool_connect_or_warn(fd, true);
+ if (*ethtool_fd < 0) {
+ r = ethtool_connect_or_warn(ethtool_fd, true);
if (r < 0)
return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
return 0;
}
-int ethtool_get_link_info(int *fd, const char *ifname,
+int ethtool_get_link_info(int *ethtool_fd, const char *ifname,
int *ret_autonegotiation, size_t *ret_speed,
Duplex *ret_duplex, NetDevPort *ret_port) {
struct ethtool_cmd ecmd = {
};
int r;
- if (*fd < 0) {
- r = ethtool_connect_or_warn(fd, false);
+ if (*ethtool_fd < 0) {
+ r = ethtool_connect_or_warn(ethtool_fd, false);
if (r < 0)
return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
return 0;
}
-int ethtool_get_permanent_macaddr(int *fd, const char *ifname, struct ether_addr *ret) {
+int ethtool_get_permanent_macaddr(int *ethtool_fd, const char *ifname, struct ether_addr *ret) {
_cleanup_free_ struct ethtool_perm_addr *epaddr = NULL;
struct ifreq ifr;
int r;
- assert(fd);
+ assert(ethtool_fd);
assert(ifname);
assert(ret);
- if (*fd < 0) {
- r = ethtool_connect_or_warn(fd, false);
+ if (*ethtool_fd < 0) {
+ r = ethtool_connect_or_warn(ethtool_fd, false);
if (r < 0)
return r;
}
};
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
return 0;
}
-int ethtool_set_speed(int *fd, const char *ifname, unsigned speed, Duplex duplex) {
+int ethtool_set_speed(int *ethtool_fd, const char *ifname, unsigned speed, Duplex duplex) {
struct ethtool_cmd ecmd = {
.cmd = ETHTOOL_GSET
};
if (speed == 0 && duplex == _DUP_INVALID)
return 0;
- if (*fd < 0) {
- r = ethtool_connect_or_warn(fd, true);
+ if (*ethtool_fd < 0) {
+ r = ethtool_connect_or_warn(ethtool_fd, true);
if (r < 0)
return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
if (need_update) {
ecmd.cmd = ETHTOOL_SSET;
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
}
return 0;
}
-int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol) {
+int ethtool_set_wol(int *ethtool_fd, const char *ifname, WakeOnLan wol) {
struct ethtool_wolinfo ecmd = {
.cmd = ETHTOOL_GWOL
};
if (wol == _WOL_INVALID)
return 0;
- if (*fd < 0) {
- r = ethtool_connect_or_warn(fd, true);
+ if (*ethtool_fd < 0) {
+ r = ethtool_connect_or_warn(ethtool_fd, true);
if (r < 0)
return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
if (need_update) {
ecmd.cmd = ETHTOOL_SWOL;
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
}
return 0;
}
-int ethtool_set_nic_buffer_size(int *fd, const char *ifname, netdev_ring_param *ring) {
+int ethtool_set_nic_buffer_size(int *ethtool_fd, const char *ifname, netdev_ring_param *ring) {
struct ethtool_ringparam ecmd = {
.cmd = ETHTOOL_GRINGPARAM
};
bool need_update = false;
int r;
- if (*fd < 0) {
- r = ethtool_connect_or_warn(fd, true);
+ if (*ethtool_fd < 0) {
+ r = ethtool_connect_or_warn(ethtool_fd, true);
if (r < 0)
return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
if (need_update) {
ecmd.cmd = ETHTOOL_SRINGPARAM;
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return -errno;
}
return 0;
}
-static int get_stringset(int fd, struct ifreq *ifr, int stringset_id, struct ethtool_gstrings **gstrings) {
+static int get_stringset(int ethtool_fd, struct ifreq *ifr, int stringset_id, struct ethtool_gstrings **gstrings) {
_cleanup_free_ struct ethtool_gstrings *strings = NULL;
struct {
struct ethtool_sset_info info;
ifr->ifr_data = (void *) &buffer.info;
- r = ioctl(fd, SIOCETHTOOL, ifr);
+ r = ioctl(ethtool_fd, SIOCETHTOOL, ifr);
if (r < 0)
return -errno;
ifr->ifr_data = (void *) strings;
- r = ioctl(fd, SIOCETHTOOL, ifr);
+ r = ioctl(ethtool_fd, SIOCETHTOOL, ifr);
if (r < 0)
return -errno;
return -ENODATA;
}
-int ethtool_set_features(int *fd, const char *ifname, int *features) {
+int ethtool_set_features(int *ethtool_fd, const char *ifname, int *features) {
_cleanup_free_ struct ethtool_gstrings *strings = NULL;
struct ethtool_sfeatures *sfeatures;
int block, bit, i, r;
struct ifreq ifr = {};
- if (*fd < 0) {
- r = ethtool_connect_or_warn(fd, true);
+ if (*ethtool_fd < 0) {
+ r = ethtool_connect_or_warn(ethtool_fd, true);
if (r < 0)
return r;
}
strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
- r = get_stringset(*fd, &ifr, ETH_SS_FEATURES, &strings);
+ r = get_stringset(*ethtool_fd, &ifr, ETH_SS_FEATURES, &strings);
if (r < 0)
return log_warning_errno(r, "ethtool: could not get ethtool features for %s", ifname);
ifr.ifr_data = (void *) sfeatures;
- r = ioctl(*fd, SIOCETHTOOL, &ifr);
+ r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
if (r < 0)
return log_warning_errno(r, "ethtool: could not set ethtool features for %s", ifname);
bool tx_pending_set;
} netdev_ring_param;
-int ethtool_get_driver(int *fd, const char *ifname, char **ret);
-int ethtool_get_link_info(int *fd, const char *ifname,
+int ethtool_get_driver(int *ethtool_fd, const char *ifname, char **ret);
+int ethtool_get_link_info(int *ethtool_fd, const char *ifname,
int *ret_autonegotiation, size_t *ret_speed,
Duplex *ret_duplex, NetDevPort *ret_port);
-int ethtool_get_permanent_macaddr(int *fd, const char *ifname, struct ether_addr *ret);
-int ethtool_set_speed(int *fd, const char *ifname, unsigned speed, Duplex duplex);
-int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol);
-int ethtool_set_nic_buffer_size(int *fd, const char *ifname, netdev_ring_param *ring);
-int ethtool_set_features(int *fd, const char *ifname, int *features);
-int ethtool_set_glinksettings(int *fd, const char *ifname,
+int ethtool_get_permanent_macaddr(int *ethtool_fd, const char *ifname, struct ether_addr *ret);
+int ethtool_set_speed(int *ethtool_fd, const char *ifname, unsigned speed, Duplex duplex);
+int ethtool_set_wol(int *ethtool_fd, const char *ifname, WakeOnLan wol);
+int ethtool_set_nic_buffer_size(int *ethtool_fd, const char *ifname, netdev_ring_param *ring);
+int ethtool_set_features(int *ethtool_fd, const char *ifname, int *features);
+int ethtool_set_glinksettings(int *ethtool_fd, const char *ifname,
int autonegotiation, uint32_t advertise[static N_ADVERTISE],
size_t speed, Duplex duplex, NetDevPort port);
-int ethtool_set_channels(int *fd, const char *ifname, netdev_channels *channels);
+int ethtool_set_channels(int *ethtool_fd, const char *ifname, netdev_channels *channels);
const char *duplex_to_string(Duplex d) _const_;
Duplex duplex_from_string(const char *d) _pure_;