aboutsummaryrefslogtreecommitdiff
path: root/lib/netdev.c
diff options
context:
space:
mode:
authorLuca Giraudo <lgiraudo@nicira.com>2011-12-06 13:01:25 -0800
committerBen Pfaff <blp@nicira.com>2011-12-06 13:01:27 -0800
commit733adf2aaf614cf7735e1c6f8466900ea79a7f98 (patch)
treee4a7d15367cc4778c4a8d001bdaf79e5bc03eee2 /lib/netdev.c
parentdcc13bc6eec136b35c5810fda27c1077ba89d1b3 (diff)
ofproto-dpif-sflow: allow sFlow to infer the agent device.
Bug #2407.
Diffstat (limited to 'lib/netdev.c')
-rw-r--r--lib/netdev.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/netdev.c b/lib/netdev.c
index e77fcdfa..eff6e4cb 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -692,6 +692,26 @@ netdev_set_in4(struct netdev *netdev, struct in_addr addr, struct in_addr mask)
: EOPNOTSUPP);
}
+/* Obtains ad IPv4 address from device name and save the address in
+ * in4. Returns 0 if successful, otherwise a positive errno value.
+ */
+int
+netdev_get_in4_by_name(const char *device_name, struct in_addr *in4)
+{
+ struct netdev *netdev;
+ int error;
+
+ error = netdev_open(device_name, "system", &netdev);
+ if (error) {
+ in4->s_addr = htonl(0);
+ return error;
+ }
+
+ error = netdev_get_in4(netdev, in4, NULL);
+ netdev_close(netdev);
+ return error;
+}
+
/* Adds 'router' as a default IP gateway for the TCP/IP stack that corresponds
* to 'netdev'. */
int