Magellan Linux

Contents of /trunk/mkinitrd-magellan/klibc/usr/kinit/ipconfig/netdev.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 2215 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 #ifndef IPCONFIG_NETDEV_H
2 #define IPCONFIG_NETDEV_H
3
4 #include <sys/utsname.h>
5 #include <net/if.h>
6
7 #define BPLEN 40
8 #define FNLEN 128 /* from DHCP RFC 2131 */
9
10 struct netdev {
11 const char *name; /* Device name */
12 unsigned int ifindex; /* interface index */
13 unsigned int hwtype; /* ARPHRD_xxx */
14 unsigned int hwlen; /* HW address length */
15 uint8_t hwaddr[16]; /* HW address */
16 uint8_t hwbrd[16]; /* Broadcast HW address */
17 unsigned int mtu; /* Device mtu */
18 unsigned int caps; /* Capabilities */
19 time_t open_time;
20
21 struct { /* BOOTP/DHCP info */
22 int fd;
23 uint32_t xid;
24 uint32_t gateway; /* BOOTP/DHCP gateway */
25 } bootp;
26
27 struct { /* RARP information */
28 int fd;
29 } rarp;
30
31 uint32_t ip_addr; /* my address */
32 uint32_t ip_broadcast; /* broadcast address */
33 uint32_t ip_server; /* server address */
34 uint32_t ip_netmask; /* my subnet mask */
35 uint32_t ip_gateway; /* my gateway */
36 uint32_t ip_nameserver[2]; /* two nameservers */
37 uint32_t serverid; /* dhcp serverid */
38 char hostname[SYS_NMLN]; /* hostname */
39 char dnsdomainname[SYS_NMLN]; /* dns domain name */
40 char nisdomainname[SYS_NMLN]; /* nis domain name */
41 char bootpath[BPLEN]; /* boot path */
42 char filename[FNLEN]; /* filename */
43 struct netdev *next; /* next configured i/f */
44 };
45
46 extern struct netdev *ifaces;
47
48 /*
49 * Device capabilities
50 */
51 #define CAP_BOOTP (1<<0)
52 #define CAP_DHCP (1<<1)
53 #define CAP_RARP (1<<2)
54
55 /*
56 * Device states
57 */
58 #define DEVST_UP 0
59 #define DEVST_BOOTP 1
60 #define DEVST_DHCPDISC 2
61 #define DEVST_DHCPREQ 3
62 #define DEVST_COMPLETE 4
63 #define DEVST_ERROR 5
64
65 int netdev_getflags(struct netdev *dev, short *flags);
66 int netdev_setaddress(struct netdev *dev);
67 int netdev_setdefaultroute(struct netdev *dev);
68 int netdev_up(struct netdev *dev);
69 int netdev_down(struct netdev *dev);
70 int netdev_init_if(struct netdev *dev);
71 int netdev_setmtu(struct netdev *dev);
72
73 static inline int netdev_running(struct netdev *dev)
74 {
75 short flags;
76 int ret = netdev_getflags(dev, &flags);
77
78 return ret ? 0 : !!(flags & IFF_RUNNING);
79 }
80
81 #endif /* IPCONFIG_NETDEV_H */