Please wait until the page is fully downloaded and then press the "Expand" button or the blue line numbers.
0080000 /* net/gen/dhcp.h - DHCP packet format Author: Kees J. Bot
0080001 * 1 Dec 2000
0080002 */
0080003
0080004 #ifndef __NET__GEN__DHCP_H__
0080005 #define __NET__GEN__DHCP_H__
0080006
0080007 typedef struct dhcp {
0080008 u8_t op; /* Message opcode/type. */
0080009 u8_t htype; /* Hardware address type. */
0080010 u8_t hlen; /* Hardware address length. */
0080011 u8_t hops; /* Hop count when relaying. */
0080012 u32_t xid; /* Transaction ID. */
0080013 u16_t secs; /* Seconds past since client began. */
0080014 u16_t flags; /* Flags. */
0080015 ipaddr_t ciaddr; /* Client IP address. */
0080016 ipaddr_t yiaddr; /* "Your" IP address. */
0080017 ipaddr_t siaddr; /* Boot server IP address. */
0080018 ipaddr_t giaddr; /* Relay agent (gateway) IP address. */
0080019 u8_t chaddr[16]; /* Client hardware address. */
0080020 u8_t sname[64]; /* Server host name. */
0080021 u8_t file[128]; /* Boot file. */
0080022 u32_t magic; /* Magic number. */
0080023 u8_t options[308]; /* Optional parameters. */
0080024 } dhcp_t;
0080025
0080026 /* DHCP operations and stuff: */
0080027 #define DHCP_BOOTREQUEST 1 /* Boot request message. */
0080028 #define DHCP_BOOTREPLY 2 /* Boot reply message. */
0080029 #define DHCP_HTYPE_ETH 1 /* Ethernet hardware type. */
0080030 #define DHCP_HLEN_ETH 6 /* Ethernet hardware address length. */
0080031 #define DHCP_FLAGS_BCAST 0x8000U /* Reply must be broadcast to client. */
0080032
0080033 /* "Magic" first four option bytes. */
0080034 #define DHCP_MAGIC HTONL(0x63825363UL)
0080035
0080036 /* DHCP common tags: */
0080037 #define DHCP_TAG_NETMASK 1 /* Netmask. */
0080038 #define DHCP_TAG_GATEWAY 3 /* Gateway list. */
0080039 #define DHCP_TAG_DNS 6 /* DNS Nameserver list. */
0080040 #define DHCP_TAG_HOSTNAME 12 /* Host name. */
0080041 #define DHCP_TAG_DOMAIN 15 /* Domain. */
0080042 #define DHCP_TAG_IPMTU 26 /* Interface MTU. */
0080043
0080044 /* DHCP protocol tags: */
0080045 #define DHCP_TAG_REQIP 50 /* Request this IP. */
0080046 #define DHCP_TAG_LEASE 51 /* Lease time requested/offered. */
0080047 #define DHCP_TAG_OVERLOAD 52 /* Options continued in file/sname. */
0080048 #define DHCP_TAG_TYPE 53 /* DHCP message (values below). */
0080049 #define DHCP_TAG_SERVERID 54 /* Server identifier. */
0080050 #define DHCP_TAG_REQPAR 55 /* Parameters requested. */
0080051 #define DHCP_TAG_MESSAGE 56 /* Error message. */
0080052 #define DHCP_TAG_MAXDHCP 57 /* Max DHCP packet size. */
0080053 #define DHCP_TAG_RENEWAL 58 /* Time to go into renewal state. */
0080054 #define DHCP_TAG_REBINDING 59 /* Time to go into rebinding state. */
0080055 #define DHCP_TAG_CLASSID 60 /* Class identifier. */
0080056 #define DHCP_TAG_CLIENTID 61 /* Client identifier. */
0080057
0080058 /* DHCP messages: */
0080059 #define DHCP_DISCOVER 1 /* Locate available servers. */
0080060 #define DHCP_OFFER 2 /* Parameters offered to client. */
0080061 #define DHCP_REQUEST 3 /* (Re)request offered parameters. */
0080062 #define DHCP_DECLINE 4 /* Client declines offer. */
0080063 #define DHCP_ACK 5 /* Server acknowlegdes request. */
0080064 #define DHCP_NAK 6 /* Server denies request. */
0080065 #define DHCP_RELEASE 7 /* Client relinguishes address. */
0080066 #define DHCP_INFORM 8 /* Client requests just local config. */
0080067
0080068 void dhcp_init(dhcp_t *_dp);
0080069 int dhcp_settag(dhcp_t *_dp, int _tag, void *_data, size_t _len);
0080070 int dhcp_gettag(dhcp_t *_dp, int _searchtag, u8_t **_pdata, size_t *_plen);
0080071
0080072 #endif /* __NET__GEN__DHCP_H__ */