00001 /* net/gen/dhcp.h - DHCP packet format Author: Kees J. Bot 00002 * 1 Dec 2000 00003 */ 00004 00005 #ifndef __NET__GEN__DHCP_H__ 00006 #define __NET__GEN__DHCP_H__ 00007 00008 typedef struct dhcp { 00009 u8_t op; /* Message opcode/type. */ 00010 u8_t htype; /* Hardware address type. */ 00011 u8_t hlen; /* Hardware address length. */ 00012 u8_t hops; /* Hop count when relaying. */ 00013 u32_t xid; /* Transaction ID. */ 00014 u16_t secs; /* Seconds past since client began. */ 00015 u16_t flags; /* Flags. */ 00016 ipaddr_t ciaddr; /* Client IP address. */ 00017 ipaddr_t yiaddr; /* "Your" IP address. */ 00018 ipaddr_t siaddr; /* Boot server IP address. */ 00019 ipaddr_t giaddr; /* Relay agent (gateway) IP address. */ 00020 u8_t chaddr[16]; /* Client hardware address. */ 00021 u8_t sname[64]; /* Server host name. */ 00022 u8_t file[128]; /* Boot file. */ 00023 u32_t magic; /* Magic number. */ 00024 u8_t options[308]; /* Optional parameters. */ 00025 } dhcp_t; 00026 00027 /* DHCP operations and stuff: */ 00028 #define DHCP_BOOTREQUEST 1 /* Boot request message. */ 00029 #define DHCP_BOOTREPLY 2 /* Boot reply message. */ 00030 #define DHCP_HTYPE_ETH 1 /* Ethernet hardware type. */ 00031 #define DHCP_HLEN_ETH 6 /* Ethernet hardware address length. */ 00032 #define DHCP_FLAGS_BCAST 0x8000U /* Reply must be broadcast to client. */ 00033 00034 /* "Magic" first four option bytes. */ 00035 #define DHCP_MAGIC HTONL(0x63825363UL) 00036 00037 /* DHCP common tags: */ 00038 #define DHCP_TAG_NETMASK 1 /* Netmask. */ 00039 #define DHCP_TAG_GATEWAY 3 /* Gateway list. */ 00040 #define DHCP_TAG_DNS 6 /* DNS Nameserver list. */ 00041 #define DHCP_TAG_HOSTNAME 12 /* Host name. */ 00042 #define DHCP_TAG_DOMAIN 15 /* Domain. */ 00043 #define DHCP_TAG_IPMTU 26 /* Interface MTU. */ 00044 00045 /* DHCP protocol tags: */ 00046 #define DHCP_TAG_REQIP 50 /* Request this IP. */ 00047 #define DHCP_TAG_LEASE 51 /* Lease time requested/offered. */ 00048 #define DHCP_TAG_OVERLOAD 52 /* Options continued in file/sname. */ 00049 #define DHCP_TAG_TYPE 53 /* DHCP message (values below). */ 00050 #define DHCP_TAG_SERVERID 54 /* Server identifier. */ 00051 #define DHCP_TAG_REQPAR 55 /* Parameters requested. */ 00052 #define DHCP_TAG_MESSAGE 56 /* Error message. */ 00053 #define DHCP_TAG_MAXDHCP 57 /* Max DHCP packet size. */ 00054 #define DHCP_TAG_RENEWAL 58 /* Time to go into renewal state. */ 00055 #define DHCP_TAG_REBINDING 59 /* Time to go into rebinding state. */ 00056 #define DHCP_TAG_CLASSID 60 /* Class identifier. */ 00057 #define DHCP_TAG_CLIENTID 61 /* Client identifier. */ 00058 00059 /* DHCP messages: */ 00060 #define DHCP_DISCOVER 1 /* Locate available servers. */ 00061 #define DHCP_OFFER 2 /* Parameters offered to client. */ 00062 #define DHCP_REQUEST 3 /* (Re)request offered parameters. */ 00063 #define DHCP_DECLINE 4 /* Client declines offer. */ 00064 #define DHCP_ACK 5 /* Server acknowlegdes request. */ 00065 #define DHCP_NAK 6 /* Server denies request. */ 00066 #define DHCP_RELEASE 7 /* Client relinguishes address. */ 00067 #define DHCP_INFORM 8 /* Client requests just local config. */ 00068 00069 void dhcp_init(dhcp_t *_dp); 00070 int dhcp_settag(dhcp_t *_dp, int _tag, void *_data, size_t _len); 00071 int dhcp_gettag(dhcp_t *_dp, int _searchtag, u8_t **_pdata, size_t *_plen); 00072 00073 #endif /* __NET__GEN__DHCP_H__ */
1.4.6