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) 22efee1709Swdenk #define OPT_SIZE 312 /* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */ 23efee1709Swdenk #else 24efee1709Swdenk #define OPT_SIZE 64 25efee1709Swdenk #endif 26efee1709Swdenk 27efee1709Swdenk typedef struct 28efee1709Swdenk { 29efee1709Swdenk uchar bp_op; /* Operation */ 30efee1709Swdenk # define OP_BOOTREQUEST 1 31efee1709Swdenk # define OP_BOOTREPLY 2 32efee1709Swdenk uchar bp_htype; /* Hardware type */ 33efee1709Swdenk # define HWT_ETHER 1 34efee1709Swdenk uchar bp_hlen; /* Hardware address length */ 35efee1709Swdenk # define HWL_ETHER 6 36efee1709Swdenk uchar bp_hops; /* Hop count (gateway thing) */ 37efee1709Swdenk ulong bp_id; /* Transaction ID */ 38efee1709Swdenk ushort bp_secs; /* Seconds since boot */ 39efee1709Swdenk ushort bp_spare1; /* Alignment */ 40efee1709Swdenk IPaddr_t bp_ciaddr; /* Client IP address */ 41efee1709Swdenk IPaddr_t bp_yiaddr; /* Your (client) IP address */ 42efee1709Swdenk IPaddr_t bp_siaddr; /* Server IP address */ 43efee1709Swdenk IPaddr_t bp_giaddr; /* Gateway IP address */ 44efee1709Swdenk uchar bp_chaddr[16]; /* Client hardware address */ 45efee1709Swdenk char bp_sname[64]; /* Server host name */ 46efee1709Swdenk char bp_file[128]; /* Boot file name */ 47efee1709Swdenk char bp_vend[OPT_SIZE]; /* Vendor information */ 48efee1709Swdenk } Bootp_t; 49efee1709Swdenk 50efee1709Swdenk #define BOOTP_HDR_SIZE sizeof (Bootp_t) 51efee1709Swdenk #define BOOTP_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE + BOOTP_HDR_SIZE) 52efee1709Swdenk 53efee1709Swdenk /**********************************************************************/ 54efee1709Swdenk /* 55efee1709Swdenk * Global functions and variables. 56efee1709Swdenk */ 57efee1709Swdenk 58efee1709Swdenk /* bootp.c */ 59efee1709Swdenk extern ulong BootpID; /* ID of cur BOOTP request */ 60efee1709Swdenk extern char BootFile[128]; /* Boot file name */ 61efee1709Swdenk extern int BootpTry; 62efee1709Swdenk #ifdef CONFIG_BOOTP_RANDOM_DELAY 63*61365501SRemy Bohmer extern ulong seed1, seed2; /* seed for random BOOTP delay */ 64efee1709Swdenk #endif 65efee1709Swdenk 66efee1709Swdenk 67efee1709Swdenk /* Send a BOOTP request */ 68efee1709Swdenk extern void BootpRequest (void); 69efee1709Swdenk 70efee1709Swdenk /****************** DHCP Support *********************/ 71efee1709Swdenk extern void DhcpRequest(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 91079c2c4fSJean-Christophe PLAGNIOL-VILLARD #define SELECT_TIMEOUT 3UL /* Seconds to wait for offers */ 92efee1709Swdenk 93efee1709Swdenk /**********************************************************************/ 94efee1709Swdenk 95efee1709Swdenk #endif /* __BOOTP_H__ */ 96