1 /* AFS network device helpers
3 * Copyright (c) 2007 Patrick McHardy <kaber@trash.net>
6 #include <linux/string.h>
7 #include <linux/rtnetlink.h>
8 #include <linux/inetdevice.h>
9 #include <linux/netdevice.h>
10 #include <linux/if_arp.h>
11 #include <net/net_namespace.h>
15 * get a MAC address from a random ethernet interface that has a real one
16 * - the buffer will normally be 6 bytes in size
18 int afs_get_MAC_address(u8
*mac
, size_t maclen
)
20 struct net_device
*dev
;
23 BUG_ON(maclen
!= ETH_ALEN
);
26 dev
= __dev_getfirstbyhwtype(&init_net
, ARPHRD_ETHER
);
28 memcpy(mac
, dev
->dev_addr
, maclen
);
36 * get a list of this system's interface IPv4 addresses, netmasks and MTUs
37 * - maxbufs must be at least 1
38 * - returns the number of interface records in the buffer
40 int afs_get_ipv4_interfaces(struct afs_interface
*bufs
, size_t maxbufs
,
43 struct net_device
*dev
;
44 struct in_device
*idev
;
50 for_each_netdev(&init_net
, dev
) {
51 if (dev
->type
== ARPHRD_LOOPBACK
&& !wantloopback
)
53 idev
= __in_dev_get_rtnl(dev
);
56 for_primary_ifa(idev
) {
57 bufs
[n
].address
.s_addr
= ifa
->ifa_address
;
58 bufs
[n
].netmask
.s_addr
= ifa
->ifa_mask
;
59 bufs
[n
].mtu
= dev
->mtu
;
This page took 0.030905 seconds and 5 git commands to generate.