bootp.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_hdr {
  28. u8 bp_op; /* Operation */
  29. # define OP_BOOTREQUEST 1
  30. # define OP_BOOTREPLY 2
  31. u8 bp_htype; /* Hardware type */
  32. # define HWT_ETHER 1
  33. u8 bp_hlen; /* Hardware address length */
  34. # define HWL_ETHER 6
  35. u8 bp_hops; /* Hop count (gateway thing) */
  36. u32 bp_id; /* Transaction ID */
  37. u16 bp_secs; /* Seconds since boot */
  38. u16 bp_spare1; /* Alignment */
  39. struct in_addr bp_ciaddr; /* Client IP address */
  40. struct in_addr bp_yiaddr; /* Your (client) IP address */
  41. struct in_addr bp_siaddr; /* Server IP address */
  42. struct in_addr bp_giaddr; /* Gateway IP address */
  43. u8 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. } __attribute__((packed));
  48. #define BOOTP_HDR_SIZE sizeof(struct bootp_hdr)
  49. /**********************************************************************/
  50. /*
  51. * Global functions and variables.
  52. */
  53. /* bootp.c */
  54. extern u32 bootp_id; /* ID of cur BOOTP request */
  55. extern int bootp_try;
  56. /* Send a BOOTP request */
  57. void bootp_reset(void);
  58. void bootp_request(void);
  59. /****************** DHCP Support *********************/
  60. void dhcp_request(void);
  61. /* DHCP States */
  62. typedef enum { INIT,
  63. INIT_REBOOT,
  64. REBOOTING,
  65. SELECTING,
  66. REQUESTING,
  67. REBINDING,
  68. BOUND,
  69. RENEWING } dhcp_state_t;
  70. #define DHCP_DISCOVER 1
  71. #define DHCP_OFFER 2
  72. #define DHCP_REQUEST 3
  73. #define DHCP_DECLINE 4
  74. #define DHCP_ACK 5
  75. #define DHCP_NAK 6
  76. #define DHCP_RELEASE 7
  77. /**********************************************************************/
  78. #endif /* __BOOTP_H__ */