1*1b8adde7SWilliam Kucharski #ifndef _BOOTP_H 2*1b8adde7SWilliam Kucharski #define _BOOTP_H 3*1b8adde7SWilliam Kucharski 4*1b8adde7SWilliam Kucharski #include "if_ether.h" 5*1b8adde7SWilliam Kucharski #include "ip.h" 6*1b8adde7SWilliam Kucharski #include "udp.h" 7*1b8adde7SWilliam Kucharski 8*1b8adde7SWilliam Kucharski #ifndef MAX_BOOTP_RETRIES 9*1b8adde7SWilliam Kucharski #define MAX_BOOTP_RETRIES 20 10*1b8adde7SWilliam Kucharski #endif 11*1b8adde7SWilliam Kucharski 12*1b8adde7SWilliam Kucharski #ifdef ALTERNATE_DHCP_PORTS_1067_1068 13*1b8adde7SWilliam Kucharski #undef NON_STANDARD_BOOTP_SERVER 14*1b8adde7SWilliam Kucharski #define NON_STANDARD_BOOTP_SERVER 1067 15*1b8adde7SWilliam Kucharski #undef NON_STANDARD_BOOTP_CLIENT 16*1b8adde7SWilliam Kucharski #define NON_STANDARD_BOOTP_CLIENT 1068 17*1b8adde7SWilliam Kucharski #endif 18*1b8adde7SWilliam Kucharski 19*1b8adde7SWilliam Kucharski #ifdef NON_STANDARD_BOOTP_SERVER 20*1b8adde7SWilliam Kucharski #define BOOTP_SERVER NON_STANDARD_BOOTP_SERVER 21*1b8adde7SWilliam Kucharski #else 22*1b8adde7SWilliam Kucharski #define BOOTP_SERVER 67 23*1b8adde7SWilliam Kucharski #endif 24*1b8adde7SWilliam Kucharski #ifdef NON_STANDARD_BOOTP_CLIENT 25*1b8adde7SWilliam Kucharski #define BOOTP_CLIENT NON_STANDARD_BOOTP_CLIENT 26*1b8adde7SWilliam Kucharski #else 27*1b8adde7SWilliam Kucharski #define BOOTP_CLIENT 68 28*1b8adde7SWilliam Kucharski #endif 29*1b8adde7SWilliam Kucharski 30*1b8adde7SWilliam Kucharski #define BOOTP_REQUEST 1 31*1b8adde7SWilliam Kucharski #define BOOTP_REPLY 2 32*1b8adde7SWilliam Kucharski 33*1b8adde7SWilliam Kucharski #define TAG_LEN(p) (*((p)+1)) 34*1b8adde7SWilliam Kucharski #define RFC1533_COOKIE 99, 130, 83, 99 35*1b8adde7SWilliam Kucharski #define RFC1533_PAD 0 36*1b8adde7SWilliam Kucharski #define RFC1533_NETMASK 1 37*1b8adde7SWilliam Kucharski #define RFC1533_TIMEOFFSET 2 38*1b8adde7SWilliam Kucharski #define RFC1533_GATEWAY 3 39*1b8adde7SWilliam Kucharski #define RFC1533_TIMESERVER 4 40*1b8adde7SWilliam Kucharski #define RFC1533_IEN116NS 5 41*1b8adde7SWilliam Kucharski #define RFC1533_DNS 6 42*1b8adde7SWilliam Kucharski #define RFC1533_LOGSERVER 7 43*1b8adde7SWilliam Kucharski #define RFC1533_COOKIESERVER 8 44*1b8adde7SWilliam Kucharski #define RFC1533_LPRSERVER 9 45*1b8adde7SWilliam Kucharski #define RFC1533_IMPRESSSERVER 10 46*1b8adde7SWilliam Kucharski #define RFC1533_RESOURCESERVER 11 47*1b8adde7SWilliam Kucharski #define RFC1533_HOSTNAME 12 48*1b8adde7SWilliam Kucharski #define RFC1533_BOOTFILESIZE 13 49*1b8adde7SWilliam Kucharski #define RFC1533_MERITDUMPFILE 14 50*1b8adde7SWilliam Kucharski #define RFC1533_DOMAINNAME 15 51*1b8adde7SWilliam Kucharski #define RFC1533_SWAPSERVER 16 52*1b8adde7SWilliam Kucharski #define RFC1533_ROOTPATH 17 53*1b8adde7SWilliam Kucharski #define RFC1533_EXTENSIONPATH 18 54*1b8adde7SWilliam Kucharski #define RFC1533_IPFORWARDING 19 55*1b8adde7SWilliam Kucharski #define RFC1533_IPSOURCEROUTING 20 56*1b8adde7SWilliam Kucharski #define RFC1533_IPPOLICYFILTER 21 57*1b8adde7SWilliam Kucharski #define RFC1533_IPMAXREASSEMBLY 22 58*1b8adde7SWilliam Kucharski #define RFC1533_IPTTL 23 59*1b8adde7SWilliam Kucharski #define RFC1533_IPMTU 24 60*1b8adde7SWilliam Kucharski #define RFC1533_IPMTUPLATEAU 25 61*1b8adde7SWilliam Kucharski #define RFC1533_INTMTU 26 62*1b8adde7SWilliam Kucharski #define RFC1533_INTLOCALSUBNETS 27 63*1b8adde7SWilliam Kucharski #define RFC1533_INTBROADCAST 28 64*1b8adde7SWilliam Kucharski #define RFC1533_INTICMPDISCOVER 29 65*1b8adde7SWilliam Kucharski #define RFC1533_INTICMPRESPOND 30 66*1b8adde7SWilliam Kucharski #define RFC1533_INTROUTEDISCOVER 31 67*1b8adde7SWilliam Kucharski #define RFC1533_INTROUTESOLICIT 32 68*1b8adde7SWilliam Kucharski #define RFC1533_INTSTATICROUTES 33 69*1b8adde7SWilliam Kucharski #define RFC1533_LLTRAILERENCAP 34 70*1b8adde7SWilliam Kucharski #define RFC1533_LLARPCACHETMO 35 71*1b8adde7SWilliam Kucharski #define RFC1533_LLETHERNETENCAP 36 72*1b8adde7SWilliam Kucharski #define RFC1533_TCPTTL 37 73*1b8adde7SWilliam Kucharski #define RFC1533_TCPKEEPALIVETMO 38 74*1b8adde7SWilliam Kucharski #define RFC1533_TCPKEEPALIVEGB 39 75*1b8adde7SWilliam Kucharski #define RFC1533_NISDOMAIN 40 76*1b8adde7SWilliam Kucharski #define RFC1533_NISSERVER 41 77*1b8adde7SWilliam Kucharski #define RFC1533_NTPSERVER 42 78*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR 43 79*1b8adde7SWilliam Kucharski #define RFC1533_NBNS 44 80*1b8adde7SWilliam Kucharski #define RFC1533_NBDD 45 81*1b8adde7SWilliam Kucharski #define RFC1533_NBNT 46 82*1b8adde7SWilliam Kucharski #define RFC1533_NBSCOPE 47 83*1b8adde7SWilliam Kucharski #define RFC1533_XFS 48 84*1b8adde7SWilliam Kucharski #define RFC1533_XDM 49 85*1b8adde7SWilliam Kucharski #ifndef NO_DHCP_SUPPORT 86*1b8adde7SWilliam Kucharski #define RFC2132_REQ_ADDR 50 87*1b8adde7SWilliam Kucharski #define RFC2132_MSG_TYPE 53 88*1b8adde7SWilliam Kucharski #define RFC2132_SRV_ID 54 89*1b8adde7SWilliam Kucharski #define RFC2132_PARAM_LIST 55 90*1b8adde7SWilliam Kucharski #define RFC2132_MAX_SIZE 57 91*1b8adde7SWilliam Kucharski #define RFC2132_VENDOR_CLASS_ID 60 92*1b8adde7SWilliam Kucharski 93*1b8adde7SWilliam Kucharski #define DHCPDISCOVER 1 94*1b8adde7SWilliam Kucharski #define DHCPOFFER 2 95*1b8adde7SWilliam Kucharski #define DHCPREQUEST 3 96*1b8adde7SWilliam Kucharski #define DHCPACK 5 97*1b8adde7SWilliam Kucharski #endif /* NO_DHCP_SUPPORT */ 98*1b8adde7SWilliam Kucharski 99*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_MAJOR 0 100*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_MINOR 0 101*1b8adde7SWilliam Kucharski 102*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_MAGIC 128 103*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_ADDPARM 129 104*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_ETHDEV 130 105*1b8adde7SWilliam Kucharski #ifdef IMAGE_FREEBSD 106*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_HOWTO 132 107*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_KERNEL_ENV 133 108*1b8adde7SWilliam Kucharski #endif 109*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_ETHERBOOT_ENCAP 150 110*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_MNUOPTS 160 111*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_NIC_DEV_ID 175 112*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_SELECTION 176 113*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_ARCH 177 114*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_MOTD 184 115*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_NUMOFMOTD 8 116*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_IMG 192 117*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_NUMOFIMG 16 118*1b8adde7SWilliam Kucharski 119*1b8adde7SWilliam Kucharski #define RFC1533_VENDOR_CONFIGFILE 150 120*1b8adde7SWilliam Kucharski 121*1b8adde7SWilliam Kucharski #define RFC1533_END 255 122*1b8adde7SWilliam Kucharski 123*1b8adde7SWilliam Kucharski #define BOOTP_VENDOR_LEN 64 124*1b8adde7SWilliam Kucharski 125*1b8adde7SWilliam Kucharski #define DHCP_OPT_LEN 312 126*1b8adde7SWilliam Kucharski 127*1b8adde7SWilliam Kucharski /* Format of a bootp packet */ 128*1b8adde7SWilliam Kucharski struct bootp_t { 129*1b8adde7SWilliam Kucharski uint8_t bp_op; 130*1b8adde7SWilliam Kucharski uint8_t bp_htype; 131*1b8adde7SWilliam Kucharski uint8_t bp_hlen; 132*1b8adde7SWilliam Kucharski uint8_t bp_hops; 133*1b8adde7SWilliam Kucharski uint32_t bp_xid; 134*1b8adde7SWilliam Kucharski uint16_t bp_secs; 135*1b8adde7SWilliam Kucharski uint16_t unused; 136*1b8adde7SWilliam Kucharski in_addr bp_ciaddr; 137*1b8adde7SWilliam Kucharski in_addr bp_yiaddr; 138*1b8adde7SWilliam Kucharski in_addr bp_siaddr; 139*1b8adde7SWilliam Kucharski in_addr bp_giaddr; 140*1b8adde7SWilliam Kucharski uint8_t bp_hwaddr[16]; 141*1b8adde7SWilliam Kucharski uint8_t bp_sname[64]; 142*1b8adde7SWilliam Kucharski char bp_file[128]; 143*1b8adde7SWilliam Kucharski uint8_t bp_vend[BOOTP_VENDOR_LEN]; 144*1b8adde7SWilliam Kucharski }; 145*1b8adde7SWilliam Kucharski 146*1b8adde7SWilliam Kucharski struct dhcp_t { 147*1b8adde7SWilliam Kucharski uint8_t bp_op; 148*1b8adde7SWilliam Kucharski uint8_t bp_htype; 149*1b8adde7SWilliam Kucharski uint8_t bp_hlen; 150*1b8adde7SWilliam Kucharski uint8_t bp_hops; 151*1b8adde7SWilliam Kucharski uint32_t bp_xid; 152*1b8adde7SWilliam Kucharski uint16_t bp_secs; 153*1b8adde7SWilliam Kucharski uint16_t bp_flag; 154*1b8adde7SWilliam Kucharski in_addr bp_ciaddr; 155*1b8adde7SWilliam Kucharski in_addr bp_yiaddr; 156*1b8adde7SWilliam Kucharski in_addr bp_siaddr; 157*1b8adde7SWilliam Kucharski in_addr bp_giaddr; 158*1b8adde7SWilliam Kucharski uint8_t bp_hwaddr[16]; 159*1b8adde7SWilliam Kucharski uint8_t bp_sname[64]; 160*1b8adde7SWilliam Kucharski char bp_file[128]; 161*1b8adde7SWilliam Kucharski uint8_t bp_vend[DHCP_OPT_LEN]; 162*1b8adde7SWilliam Kucharski }; 163*1b8adde7SWilliam Kucharski 164*1b8adde7SWilliam Kucharski /* Format of a bootp IP packet */ 165*1b8adde7SWilliam Kucharski struct bootpip_t 166*1b8adde7SWilliam Kucharski { 167*1b8adde7SWilliam Kucharski struct iphdr ip; 168*1b8adde7SWilliam Kucharski struct udphdr udp; 169*1b8adde7SWilliam Kucharski struct bootp_t bp; 170*1b8adde7SWilliam Kucharski }; 171*1b8adde7SWilliam Kucharski struct dhcpip_t 172*1b8adde7SWilliam Kucharski { 173*1b8adde7SWilliam Kucharski struct iphdr ip; 174*1b8adde7SWilliam Kucharski struct udphdr udp; 175*1b8adde7SWilliam Kucharski struct dhcp_t bp; 176*1b8adde7SWilliam Kucharski }; 177*1b8adde7SWilliam Kucharski 178*1b8adde7SWilliam Kucharski #define MAX_RFC1533_VENDLEN (ETH_MAX_MTU - sizeof(struct bootpip_t) + BOOTP_VENDOR_LEN) 179*1b8adde7SWilliam Kucharski 180*1b8adde7SWilliam Kucharski #define BOOTP_DATA_ADDR (&bootp_data) 181*1b8adde7SWilliam Kucharski 182*1b8adde7SWilliam Kucharski #endif /* _BOOTP_H */ 183