bootp.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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_FIELD_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_FIELD_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_FIELD_SIZE]; /* Vendor information */
  47. };
  48. #define BOOTP_HDR_SIZE sizeof(struct Bootp_t)
  49. /**********************************************************************/
  50. /*
  51. * Global functions and variables.
  52. */
  53. /* bootp.c */
  54. extern ulong BootpID; /* ID of cur BOOTP request */
  55. extern char BootFile[128]; /* Boot file name */
  56. extern int BootpTry;
  57. /* Send a BOOTP request */
  58. extern void BootpReset(void);
  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. /**********************************************************************/
  79. #endif /* __BOOTP_H__ */