dhcpd.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* dhcpd.h */
  2. #ifndef _DHCPD_H
  3. #define _DHCPD_H
  4. #include <netinet/ip.h>
  5. #include <netinet/udp.h>
  6. #include "libbb_udhcp.h"
  7. #include "leases.h"
  8. #include "version.h"
  9. /************************************/
  10. /* Defaults _you_ may want to tweak */
  11. /************************************/
  12. /* the period of time the client is allowed to use that address */
  13. #define LEASE_TIME (60*60*24*10) /* 10 days of seconds */
  14. #define LEASES_FILE "/var/lib/misc/udhcpd.leases"
  15. /* where to find the DHCP server configuration file */
  16. #define DHCPD_CONF_FILE "/etc/udhcpd.conf"
  17. /*****************************************************************/
  18. /* Do not modify below here unless you know what you are doing!! */
  19. /*****************************************************************/
  20. /* DHCP protocol -- see RFC 2131 */
  21. #define SERVER_PORT 67
  22. #define CLIENT_PORT 68
  23. #define DHCP_MAGIC 0x63825363
  24. /* DHCP option codes (partial list) */
  25. #define DHCP_PADDING 0x00
  26. #define DHCP_SUBNET 0x01
  27. #define DHCP_TIME_OFFSET 0x02
  28. #define DHCP_ROUTER 0x03
  29. #define DHCP_TIME_SERVER 0x04
  30. #define DHCP_NAME_SERVER 0x05
  31. #define DHCP_DNS_SERVER 0x06
  32. #define DHCP_LOG_SERVER 0x07
  33. #define DHCP_COOKIE_SERVER 0x08
  34. #define DHCP_LPR_SERVER 0x09
  35. #define DHCP_HOST_NAME 0x0c
  36. #define DHCP_BOOT_SIZE 0x0d
  37. #define DHCP_DOMAIN_NAME 0x0f
  38. #define DHCP_SWAP_SERVER 0x10
  39. #define DHCP_ROOT_PATH 0x11
  40. #define DHCP_IP_TTL 0x17
  41. #define DHCP_MTU 0x1a
  42. #define DHCP_BROADCAST 0x1c
  43. #define DHCP_NTP_SERVER 0x2a
  44. #define DHCP_WINS_SERVER 0x2c
  45. #define DHCP_REQUESTED_IP 0x32
  46. #define DHCP_LEASE_TIME 0x33
  47. #define DHCP_OPTION_OVER 0x34
  48. #define DHCP_MESSAGE_TYPE 0x35
  49. #define DHCP_SERVER_ID 0x36
  50. #define DHCP_PARAM_REQ 0x37
  51. #define DHCP_MESSAGE 0x38
  52. #define DHCP_MAX_SIZE 0x39
  53. #define DHCP_T1 0x3a
  54. #define DHCP_T2 0x3b
  55. #define DHCP_VENDOR 0x3c
  56. #define DHCP_CLIENT_ID 0x3d
  57. #define DHCP_END 0xFF
  58. #define BOOTREQUEST 1
  59. #define BOOTREPLY 2
  60. #define ETH_10MB 1
  61. #define ETH_10MB_LEN 6
  62. #define DHCPDISCOVER 1
  63. #define DHCPOFFER 2
  64. #define DHCPREQUEST 3
  65. #define DHCPDECLINE 4
  66. #define DHCPACK 5
  67. #define DHCPNAK 6
  68. #define DHCPRELEASE 7
  69. #define DHCPINFORM 8
  70. #define BROADCAST_FLAG 0x8000
  71. #define OPTION_FIELD 0
  72. #define FILE_FIELD 1
  73. #define SNAME_FIELD 2
  74. /* miscellaneous defines */
  75. #define MAC_BCAST_ADDR (uint8_t *) "\xff\xff\xff\xff\xff\xff"
  76. #define OPT_CODE 0
  77. #define OPT_LEN 1
  78. #define OPT_DATA 2
  79. struct option_set {
  80. uint8_t *data;
  81. struct option_set *next;
  82. };
  83. struct static_lease {
  84. uint8_t *mac;
  85. uint32_t *ip;
  86. struct static_lease *next;
  87. };
  88. struct server_config_t {
  89. uint32_t server; /* Our IP, in network order */
  90. uint32_t start; /* Start address of leases, network order */
  91. uint32_t end; /* End of leases, network order */
  92. struct option_set *options; /* List of DHCP options loaded from the config file */
  93. char *interface; /* The name of the interface to use */
  94. int ifindex; /* Index number of the interface to use */
  95. uint8_t arp[6]; /* Our arp address */
  96. unsigned long lease; /* lease time in seconds (host order) */
  97. unsigned long max_leases; /* maximum number of leases (including reserved address) */
  98. char remaining; /* should the lease file be interpreted as lease time remaining, or
  99. * as the time the lease expires */
  100. unsigned long auto_time; /* how long should udhcpd wait before writing a config file.
  101. * if this is zero, it will only write one on SIGUSR1 */
  102. unsigned long decline_time; /* how long an address is reserved if a client returns a
  103. * decline message */
  104. unsigned long conflict_time; /* how long an arp conflict offender is leased for */
  105. unsigned long offer_time; /* how long an offered address is reserved */
  106. unsigned long min_lease; /* minimum lease a client can request*/
  107. char *lease_file;
  108. char *pidfile;
  109. char *notify_file; /* What to run whenever leases are written */
  110. uint32_t siaddr; /* next server bootp option */
  111. char *sname; /* bootp server name */
  112. char *boot_file; /* bootp boot file option */
  113. struct static_lease *static_leases; /* List of ip/mac pairs to assign static leases */
  114. };
  115. extern struct server_config_t server_config;
  116. extern struct dhcpOfferedAddr *leases;
  117. #endif