return error;
}
-int
-netdev_nodev_set_etheraddr(const char *name, const uint8_t mac[ETH_ADDR_LEN])
-{
- init_netdev();
- return set_etheraddr(name, ARPHRD_ETHER, mac);
-}
-
/* Retrieves 'netdev''s MAC address. If successful, returns 0 and copies the
* the MAC address into 'mac'. On failure, returns a positive errno value and
* clears 'mac' to all-zeros. */
* 'in4' is non-null) and returns 0. Otherwise, returns a positive errno value
* and sets '*in4' to INADDR_ANY (0). */
int
-netdev_nodev_get_in4(const char *netdev_name, struct in_addr *in4)
+netdev_get_in4(const struct netdev *netdev, struct in_addr *in4)
{
+ const char *netdev_name = netdev_get_name(netdev);
struct ifreq ifr;
struct in_addr ip = { INADDR_ANY };
int error;
return error;
}
-int
-netdev_get_in4(const struct netdev *netdev, struct in_addr *in4)
-{
- return netdev_nodev_get_in4(netdev->name, in4);
-}
-
static void
make_in4_sockaddr(struct sockaddr *sa, struct in_addr addr)
{
int
netdev_get_flags(const struct netdev *netdev, enum netdev_flags *flagsp)
{
- return netdev_nodev_get_flags(netdev->name, flagsp);
+ int error, flags;
+
+ init_netdev();
+
+ *flagsp = 0;
+ error = get_flags(netdev_get_name(netdev), &flags);
+ if (error) {
+ return error;
+ }
+
+ if (flags & IFF_UP) {
+ *flagsp |= NETDEV_UP;
+ }
+ if (flags & IFF_PROMISC) {
+ *flagsp |= NETDEV_PROMISC;
+ }
+ return 0;
}
static int
* returns 0. Otherwise, it returns a positive errno value; in particular,
* ENXIO indicates that there is not ARP table entry for 'ip' on 'netdev'. */
int
-netdev_nodev_arp_lookup(const char *netdev_name, uint32_t ip,
- uint8_t mac[ETH_ADDR_LEN])
+netdev_arp_lookup(const struct netdev *netdev, uint32_t ip,
+ uint8_t mac[ETH_ADDR_LEN])
{
+ const char *netdev_name = netdev_get_name(netdev);
struct arpreq r;
struct sockaddr_in *pa;
int retval;
return retval;
}
-int
-netdev_arp_lookup(const struct netdev *netdev, uint32_t ip,
- uint8_t mac[ETH_ADDR_LEN])
-{
- return netdev_nodev_arp_lookup(netdev->name, ip, mac);
-}
-
static int
get_stats_via_netlink(int ifindex, struct netdev_stats *stats)
{
* 'netdev'. */
int
netdev_get_carrier(const struct netdev *netdev, bool *carrier)
-{
- return netdev_nodev_get_carrier(netdev->name, carrier);
-}
-
-int
-netdev_nodev_get_carrier(const char *netdev_name, bool *carrier)
{
char line[8];
int retval;
*carrier = false;
- fn = xasprintf("/sys/class/net/%s/carrier", netdev_name);
+ fn = xasprintf("/sys/class/net/%s/carrier", netdev_get_name(netdev));
fd = open(fn, O_RDONLY);
if (fd < 0) {
error = errno;
/* Attempts to set input rate limiting (policing) policy. */
int
-netdev_nodev_set_policing(const char *netdev_name, uint32_t kbits_rate,
- uint32_t kbits_burst)
+netdev_set_policing(struct netdev *netdev, uint32_t kbits_rate,
+ uint32_t kbits_burst)
{
+ const char *netdev_name = netdev_get_name(netdev);
char command[1024];
init_netdev();
return 0;
}
-int
-netdev_set_policing(struct netdev *netdev, uint32_t kbits_rate,
- uint32_t kbits_burst)
-{
- return netdev_nodev_set_policing(netdev->name, kbits_rate, kbits_burst);
-}
-
/* Initializes 'svec' with a list of the names of all known network devices. */
void
netdev_enumerate(struct svec *svec)
return netdev;
}
-/* Obtains the current flags for the network device named 'netdev_name' and
- * stores them into '*flagsp'. Returns 0 if successful, otherwise a positive
- * errno value. On error, stores 0 into '*flagsp'.
- *
- * If only device flags are needed, this is more efficient than calling
- * netdev_open(), netdev_get_flags(), netdev_close(). */
-int
-netdev_nodev_get_flags(const char *netdev_name, enum netdev_flags *flagsp)
-{
- int error, flags;
-
- init_netdev();
-
- *flagsp = 0;
- error = get_flags(netdev_name, &flags);
- if (error) {
- return error;
- }
-
- if (flags & IFF_UP) {
- *flagsp |= NETDEV_UP;
- }
- if (flags & IFF_PROMISC) {
- *flagsp |= NETDEV_PROMISC;
- }
- return 0;
-}
-
-int
-netdev_nodev_get_etheraddr(const char *netdev_name, uint8_t mac[6])
-{
- init_netdev();
-
- return get_etheraddr(netdev_name, mac, NULL);
-}
-
/* If 'netdev' is a VLAN network device (e.g. one created with vconfig(8)),
* sets '*vlan_vid' to the VLAN VID associated with that device and returns 0.
* Otherwise returns a errno value (specifically ENOENT if 'netdev_name' is the
{
struct ifreq ifr;
+ *hwaddr_familyp = 0;
memset(&ifr, 0, sizeof ifr);
strncpy(ifr.ifr_name, netdev_name, sizeof ifr.ifr_name);
COVERAGE_INC(netdev_get_hwaddr);
void netdev_enumerate(struct svec *);
struct netdev *netdev_find_dev_by_in4(const struct in_addr *);
-bool netdev_nodev_find_dev_by_in4(const struct in_addr *in4, char **netdev_name);
-int netdev_nodev_get_flags(const char *netdev_name, enum netdev_flags *);
-int netdev_nodev_get_in4(const char *netdev_name, struct in_addr *);
-int netdev_nodev_set_etheraddr(const char *name, const uint8_t mac[6]);
-int netdev_nodev_get_etheraddr(const char *netdev_name, uint8_t mac[6]);
-int netdev_nodev_set_policing(const char *netdev_name, uint32_t kbits_rate,
- uint32_t kbits_burst);
-int netdev_nodev_arp_lookup(const char *netdev_name, uint32_t ip,
- uint8_t mac[6]);
-int netdev_nodev_get_carrier(const char *netdev_name, bool *carrier);
int netdev_get_vlan_vid(const struct netdev *, int *vlan_vid);