bootp.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copied from LiMon - BOOTP.
  3. *
  4. * Copyright 1994, 1995, 2000 Neil Russell.
  5. * (See License)
  6. * Copyright 2000 Paolo Scaffardi
  7. */
  8. #ifndef __BOOTP_H__
  9. #define __BOOTP_H__
  10. #ifndef __NET_H__
  11. #include <net.h>
  12. #endif /* __NET_H__ */
  13. /**********************************************************************/
  14. /*
  15. * BOOTP header.
  16. */
  17. #if defined(CONFIG_CMD_DHCP)
  18. /* Minimum DHCP Options size per RFC2131 - results in 576 byte pkt */
  19. #define OPT_SIZE 312
  20. #if defined(CONFIG_BOOTP_VENDOREX)
  21. extern u8 *dhcp_vendorex_prep(u8 *e); /*rtn new e after add own opts. */
  22. extern u8 *dhcp_vendorex_proc(u8 *e); /*rtn next e if mine,else NULL */
  23. #endif
  24. #else
  25. #define OPT_SIZE 64
  26. #endif
  27. struct Bootp_t {
  28. uchar bp_op; /* Operation */
  29. # define OP_BOOTREQUEST 1
  30. # define OP_BOOTREPLY 2
  31. uchar bp_htype; /* Hardware type */
  32. # define HWT_ETHER 1
  33. uchar bp_hlen; /* Hardware address length */
  34. # define HWL_ETHER 6
  35. uchar bp_hops; /* Hop count (gateway thing) */
  36. ulong bp_id; /* Transaction ID */
  37. ushort bp_secs; /* Seconds since boot */
  38. ushort bp_spare1; /* Alignment */
  39. IPaddr_t bp_ciaddr; /* Client IP address */
  40. IPaddr_t bp_yiaddr; /* Your (client) IP address */
  41. IPaddr_t bp_siaddr; /* Server IP address */
  42. IPaddr_t bp_giaddr; /* Gateway IP address */
  43. uchar bp_chaddr[16]; /* Client hardware address */
  44. char bp_sname[64]; /* Server host name */
  45. char bp_file[128]; /* Boot file name */
  46. char bp_vend[OPT_SIZE]; /* Vendor information */
  47. };
  48. #define BOOTP_HDR_SIZE sizeof(struct Bootp_t)
  49. #define BOOTP_SIZE (ETHER_HDR_SIZE + IP_UDP_HDR_SIZE + BOOTP_HDR_SIZE)
  50. /**********************************************************************/
  51. /*
  52. * Global functions and variables.
  53. */
  54. /* bootp.c */
  55. extern ulong BootpID; /* ID of cur BOOTP request */
  56. extern char BootFile[128]; /* Boot file name */
  57. extern int BootpTry;
  58. /* Send a BOOTP request */
  59. extern void BootpRequest(void);
  60. /****************** DHCP Support *********************/
  61. extern void DhcpRequest(void);
  62. /* DHCP States */
  63. typedef enum { INIT,
  64. INIT_REBOOT,
  65. REBOOTING,
  66. SELECTING,
  67. REQUESTING,
  68. REBINDING,
  69. BOUND,
  70. RENEWING } dhcp_state_t;
  71. #define DHCP_DISCOVER 1
  72. #define DHCP_OFFER 2
  73. #define DHCP_REQUEST 3
  74. #define DHCP_DECLINE 4
  75. #define DHCP_ACK 5
  76. #define DHCP_NAK 6
  77. #define DHCP_RELEASE 7
  78. #define SELECT_TIMEOUT 3000UL /* Milliseconds to wait for offers */
  79. /**********************************************************************/
  80. #endif /* __BOOTP_H__ */