Annotation of /trunk/mkinitrd-magellan/klibc/usr/kinit/ipconfig/netdev.h
Parent Directory | Revision Log
Revision 1122 -
(hide annotations)
(download)
Wed Aug 18 21:11:40 2010 UTC (13 years, 9 months ago) by niro
File MIME type: text/plain
File size: 2272 byte(s)
Wed Aug 18 21:11:40 2010 UTC (13 years, 9 months ago) by niro
File MIME type: text/plain
File size: 2272 byte(s)
-updated to klibc-1.5.19
1 | niro | 532 | #ifndef IPCONFIG_NETDEV_H |
2 | #define IPCONFIG_NETDEV_H | ||
3 | |||
4 | #include <sys/utsname.h> | ||
5 | #include <net/if.h> | ||
6 | |||
7 | niro | 1122 | #define BPLEN 256 |
8 | niro | 532 | #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 | niro | 1122 | char reqhostname[SYS_NMLN]; /* requested hostname */ |
39 | niro | 532 | char hostname[SYS_NMLN]; /* hostname */ |
40 | char dnsdomainname[SYS_NMLN]; /* dns domain name */ | ||
41 | char nisdomainname[SYS_NMLN]; /* nis domain name */ | ||
42 | char bootpath[BPLEN]; /* boot path */ | ||
43 | char filename[FNLEN]; /* filename */ | ||
44 | struct netdev *next; /* next configured i/f */ | ||
45 | }; | ||
46 | |||
47 | extern struct netdev *ifaces; | ||
48 | |||
49 | /* | ||
50 | * Device capabilities | ||
51 | */ | ||
52 | #define CAP_BOOTP (1<<0) | ||
53 | #define CAP_DHCP (1<<1) | ||
54 | #define CAP_RARP (1<<2) | ||
55 | |||
56 | /* | ||
57 | * Device states | ||
58 | */ | ||
59 | #define DEVST_UP 0 | ||
60 | #define DEVST_BOOTP 1 | ||
61 | #define DEVST_DHCPDISC 2 | ||
62 | #define DEVST_DHCPREQ 3 | ||
63 | #define DEVST_COMPLETE 4 | ||
64 | #define DEVST_ERROR 5 | ||
65 | |||
66 | int netdev_getflags(struct netdev *dev, short *flags); | ||
67 | int netdev_setaddress(struct netdev *dev); | ||
68 | int netdev_setdefaultroute(struct netdev *dev); | ||
69 | int netdev_up(struct netdev *dev); | ||
70 | int netdev_down(struct netdev *dev); | ||
71 | int netdev_init_if(struct netdev *dev); | ||
72 | int netdev_setmtu(struct netdev *dev); | ||
73 | |||
74 | static inline int netdev_running(struct netdev *dev) | ||
75 | { | ||
76 | short flags; | ||
77 | int ret = netdev_getflags(dev, &flags); | ||
78 | |||
79 | return ret ? 0 : !!(flags & IFF_RUNNING); | ||
80 | } | ||
81 | |||
82 | #endif /* IPCONFIG_NETDEV_H */ |