bootp.h 2.4 KB

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