File: netdev.h

package info (click to toggle)
yaird 0.0.12-18etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 1,432 kB
  • ctags: 725
  • sloc: perl: 4,161; xml: 3,233; ansic: 3,105; sh: 876; makefile: 150
file content (77 lines) | stat: -rw-r--r-- 1,943 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * ipconfig/netdev.h
 */
#include <sys/utsname.h>
#include <sys/types.h>
#include <linux/types.h>
#include <net/if.h>

#define BPLEN		40

struct netdev {
	const char 	*name;			/* Device name		*/
	unsigned int	ifindex;		/* interface index	*/
	unsigned int	hwtype;			/* ARPHRD_xxx		*/
	unsigned int	hwlen;			/* HW address length	*/
	__u8		hwaddr[16];		/* HW address		*/
	__u8		hwbrd[16];		/* Broadcast HW address */
	unsigned int	mtu;			/* Device mtu		*/
	unsigned int	caps;			/* Capabilities		*/
	time_t		open_time;

	struct {				/* BOOTP/DHCP info	*/
		int	fd;
		__u32	xid;
		__u32	gateway;		/* BOOTP/DHCP gateway	*/
	} bootp;

	struct {				/* RARP information	*/
		int	fd;
	} rarp;

	__u32		ip_addr;		/* my address		*/
	__u32		ip_broadcast;		/* broadcast address	*/
	__u32		ip_server;		/* server address	*/
	__u32		ip_netmask;		/* my subnet mask	*/
	__u32		ip_gateway;		/* my gateway		*/
	__u32		ip_nameserver[2];	/* two nameservers	*/
	__u32		serverid;		/* dhcp serverid	*/
	char		hostname[SYS_NMLN];	/* hostname		*/
	char		dnsdomainname[SYS_NMLN];/* dns domain name	*/
	char		nisdomainname[SYS_NMLN];/* nis domain name	*/
	char		bootpath[BPLEN];	/* boot path		*/
	struct netdev	*next;			/* next configured i/f	*/
};

/*
 * Device capabilities
 */
#define CAP_BOOTP	(1<<0)
#define CAP_DHCP	(1<<1)
#define CAP_RARP	(1<<2)

/*
 * Device states
 */
#define DEVST_UP	0
#define DEVST_BOOTP	1
#define DEVST_DHCPDISC	2
#define DEVST_DHCPREQ	3
#define DEVST_COMPLETE	4
#define DEVST_ERROR	5

int netdev_getflags(struct netdev *dev, short *flags);
int netdev_setaddress(struct netdev *dev);
int netdev_setdefaultroute(struct netdev *dev);
int netdev_up(struct netdev *dev);
int netdev_down(struct netdev *dev);
int netdev_init_if(struct netdev *dev);
int netdev_setmtu(struct netdev *dev);

static inline int netdev_running(struct netdev *dev)
{
	short flags;
	int ret = netdev_getflags(dev, &flags);

	return ret ? 0 : !!(flags & IFF_RUNNING);
}