1 | /* net/gen/dhcp.h - DHCP packet format Author: Kees J. Bot
|
---|
2 | * 1 Dec 2000
|
---|
3 | */
|
---|
4 |
|
---|
5 | #ifndef __NET__GEN__DHCP_H__
|
---|
6 | #define __NET__GEN__DHCP_H__
|
---|
7 |
|
---|
8 | typedef struct dhcp {
|
---|
9 | u8_t op; /* Message opcode/type. */
|
---|
10 | u8_t htype; /* Hardware address type. */
|
---|
11 | u8_t hlen; /* Hardware address length. */
|
---|
12 | u8_t hops; /* Hop count when relaying. */
|
---|
13 | u32_t xid; /* Transaction ID. */
|
---|
14 | u16_t secs; /* Seconds past since client began. */
|
---|
15 | u16_t flags; /* Flags. */
|
---|
16 | ipaddr_t ciaddr; /* Client IP address. */
|
---|
17 | ipaddr_t yiaddr; /* "Your" IP address. */
|
---|
18 | ipaddr_t siaddr; /* Boot server IP address. */
|
---|
19 | ipaddr_t giaddr; /* Relay agent (gateway) IP address. */
|
---|
20 | u8_t chaddr[16]; /* Client hardware address. */
|
---|
21 | u8_t sname[64]; /* Server host name. */
|
---|
22 | u8_t file[128]; /* Boot file. */
|
---|
23 | u32_t magic; /* Magic number. */
|
---|
24 | u8_t options[308]; /* Optional parameters. */
|
---|
25 | } dhcp_t;
|
---|
26 |
|
---|
27 | /* DHCP operations and stuff: */
|
---|
28 | #define DHCP_BOOTREQUEST 1 /* Boot request message. */
|
---|
29 | #define DHCP_BOOTREPLY 2 /* Boot reply message. */
|
---|
30 | #define DHCP_HTYPE_ETH 1 /* Ethernet hardware type. */
|
---|
31 | #define DHCP_HLEN_ETH 6 /* Ethernet hardware address length. */
|
---|
32 | #define DHCP_FLAGS_BCAST 0x8000U /* Reply must be broadcast to client. */
|
---|
33 |
|
---|
34 | /* "Magic" first four option bytes. */
|
---|
35 | #define DHCP_MAGIC HTONL(0x63825363UL)
|
---|
36 |
|
---|
37 | /* DHCP common tags: */
|
---|
38 | #define DHCP_TAG_NETMASK 1 /* Netmask. */
|
---|
39 | #define DHCP_TAG_GATEWAY 3 /* Gateway list. */
|
---|
40 | #define DHCP_TAG_DNS 6 /* DNS Nameserver list. */
|
---|
41 | #define DHCP_TAG_HOSTNAME 12 /* Host name. */
|
---|
42 | #define DHCP_TAG_DOMAIN 15 /* Domain. */
|
---|
43 | #define DHCP_TAG_IPMTU 26 /* Interface MTU. */
|
---|
44 |
|
---|
45 | /* DHCP protocol tags: */
|
---|
46 | #define DHCP_TAG_REQIP 50 /* Request this IP. */
|
---|
47 | #define DHCP_TAG_LEASE 51 /* Lease time requested/offered. */
|
---|
48 | #define DHCP_TAG_OVERLOAD 52 /* Options continued in file/sname. */
|
---|
49 | #define DHCP_TAG_TYPE 53 /* DHCP message (values below). */
|
---|
50 | #define DHCP_TAG_SERVERID 54 /* Server identifier. */
|
---|
51 | #define DHCP_TAG_REQPAR 55 /* Parameters requested. */
|
---|
52 | #define DHCP_TAG_MESSAGE 56 /* Error message. */
|
---|
53 | #define DHCP_TAG_MAXDHCP 57 /* Max DHCP packet size. */
|
---|
54 | #define DHCP_TAG_RENEWAL 58 /* Time to go into renewal state. */
|
---|
55 | #define DHCP_TAG_REBINDING 59 /* Time to go into rebinding state. */
|
---|
56 | #define DHCP_TAG_CLASSID 60 /* Class identifier. */
|
---|
57 | #define DHCP_TAG_CLIENTID 61 /* Client identifier. */
|
---|
58 |
|
---|
59 | /* DHCP messages: */
|
---|
60 | #define DHCP_DISCOVER 1 /* Locate available servers. */
|
---|
61 | #define DHCP_OFFER 2 /* Parameters offered to client. */
|
---|
62 | #define DHCP_REQUEST 3 /* (Re)request offered parameters. */
|
---|
63 | #define DHCP_DECLINE 4 /* Client declines offer. */
|
---|
64 | #define DHCP_ACK 5 /* Server acknowlegdes request. */
|
---|
65 | #define DHCP_NAK 6 /* Server denies request. */
|
---|
66 | #define DHCP_RELEASE 7 /* Client relinguishes address. */
|
---|
67 | #define DHCP_INFORM 8 /* Client requests just local config. */
|
---|
68 |
|
---|
69 | void dhcp_init(dhcp_t *_dp);
|
---|
70 | int dhcp_settag(dhcp_t *_dp, int _tag, void *_data, size_t _len);
|
---|
71 | int dhcp_gettag(dhcp_t *_dp, int _searchtag, u8_t **_pdata, size_t *_plen);
|
---|
72 |
|
---|
73 | #endif /* __NET__GEN__DHCP_H__ */
|
---|