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