1efee1709Swdenk /* 2efee1709Swdenk * Copied from LiMon - BOOTP. 3efee1709Swdenk * 4efee1709Swdenk * Copyright 1994, 1995, 2000 Neil Russell. 5efee1709Swdenk * (See License) 6efee1709Swdenk * Copyright 2000 Paolo Scaffardi 7efee1709Swdenk */ 8efee1709Swdenk 9efee1709Swdenk #ifndef __BOOTP_H__ 10efee1709Swdenk #define __BOOTP_H__ 11efee1709Swdenk 12efee1709Swdenk #ifndef __NET_H__ 13efee1709Swdenk #include <net.h> 14efee1709Swdenk #endif /* __NET_H__ */ 15efee1709Swdenk 16efee1709Swdenk /**********************************************************************/ 17efee1709Swdenk 18efee1709Swdenk /* 19efee1709Swdenk * BOOTP header. 20efee1709Swdenk */ 21643d1ab2SJon Loeliger #if defined(CONFIG_CMD_DHCP) 223090b7e3SJoe Hershberger /* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */ 23f8315731SJoe Hershberger #define OPT_FIELD_SIZE 312 243090b7e3SJoe Hershberger #if defined(CONFIG_BOOTP_VENDOREX) 253090b7e3SJoe Hershberger extern u8 *dhcp_vendorex_prep(u8 *e); /*rtn new e after add own opts. */ 263090b7e3SJoe Hershberger extern u8 *dhcp_vendorex_proc(u8 *e); /*rtn next e if mine,else NULL */ 273090b7e3SJoe Hershberger #endif 28efee1709Swdenk #else 29f8315731SJoe Hershberger #define OPT_FIELD_SIZE 64 30efee1709Swdenk #endif 31efee1709Swdenk 327044c6bbSJoe Hershberger struct bootp_hdr { 33717234e0SSergey Temerkhanov u8 bp_op; /* Operation */ 34efee1709Swdenk # define OP_BOOTREQUEST 1 35efee1709Swdenk # define OP_BOOTREPLY 2 36717234e0SSergey Temerkhanov u8 bp_htype; /* Hardware type */ 37efee1709Swdenk # define HWT_ETHER 1 38717234e0SSergey Temerkhanov u8 bp_hlen; /* Hardware address length */ 39efee1709Swdenk # define HWL_ETHER 6 40717234e0SSergey Temerkhanov u8 bp_hops; /* Hop count (gateway thing) */ 415917e7d1SSergey Temerkhanov u32 bp_id; /* Transaction ID */ 42717234e0SSergey Temerkhanov u16 bp_secs; /* Seconds since boot */ 43717234e0SSergey Temerkhanov u16 bp_spare1; /* Alignment */ 44049a95a7SJoe Hershberger struct in_addr bp_ciaddr; /* Client IP address */ 45049a95a7SJoe Hershberger struct in_addr bp_yiaddr; /* Your (client) IP address */ 46049a95a7SJoe Hershberger struct in_addr bp_siaddr; /* Server IP address */ 47049a95a7SJoe Hershberger struct in_addr bp_giaddr; /* Gateway IP address */ 48717234e0SSergey Temerkhanov u8 bp_chaddr[16]; /* Client hardware address */ 49efee1709Swdenk char bp_sname[64]; /* Server host name */ 50efee1709Swdenk char bp_file[128]; /* Boot file name */ 51f8315731SJoe Hershberger char bp_vend[OPT_FIELD_SIZE]; /* Vendor information */ 52*704f3acfSDenis Pynkin } __attribute__((packed)); 53efee1709Swdenk 547044c6bbSJoe Hershberger #define BOOTP_HDR_SIZE sizeof(struct bootp_hdr) 55efee1709Swdenk 56efee1709Swdenk /**********************************************************************/ 57efee1709Swdenk /* 58efee1709Swdenk * Global functions and variables. 59efee1709Swdenk */ 60efee1709Swdenk 61efee1709Swdenk /* bootp.c */ 625917e7d1SSergey Temerkhanov extern u32 bootp_id; /* ID of cur BOOTP request */ 637044c6bbSJoe Hershberger extern int bootp_try; 64efee1709Swdenk 65efee1709Swdenk 66efee1709Swdenk /* Send a BOOTP request */ 677044c6bbSJoe Hershberger void bootp_reset(void); 687044c6bbSJoe Hershberger void bootp_request(void); 69efee1709Swdenk 70efee1709Swdenk /****************** DHCP Support *********************/ 717044c6bbSJoe Hershberger void dhcp_request(void); 72efee1709Swdenk 73efee1709Swdenk /* DHCP States */ 74efee1709Swdenk typedef enum { INIT, 75efee1709Swdenk INIT_REBOOT, 76efee1709Swdenk REBOOTING, 77efee1709Swdenk SELECTING, 78efee1709Swdenk REQUESTING, 79efee1709Swdenk REBINDING, 80efee1709Swdenk BOUND, 81efee1709Swdenk RENEWING } dhcp_state_t; 82efee1709Swdenk 83efee1709Swdenk #define DHCP_DISCOVER 1 84efee1709Swdenk #define DHCP_OFFER 2 85efee1709Swdenk #define DHCP_REQUEST 3 86efee1709Swdenk #define DHCP_DECLINE 4 87efee1709Swdenk #define DHCP_ACK 5 88efee1709Swdenk #define DHCP_NAK 6 89efee1709Swdenk #define DHCP_RELEASE 7 90efee1709Swdenk 91efee1709Swdenk /**********************************************************************/ 92efee1709Swdenk 93efee1709Swdenk #endif /* __BOOTP_H__ */ 94