Changeset 1770 in MondoRescue for branches/stable/mindi-busybox/networking/udhcp/dhcpd.h
- Timestamp:
- Nov 6, 2007, 11:01:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi-busybox/networking/udhcp/dhcpd.h
r821 r1770 1 /* vi: set sw=4 ts=4: */ 1 2 /* dhcpd.h */ 2 3 #ifndef _DHCPD_H 3 4 #define _DHCPD_H 4 5 #include <netinet/ip.h>6 #include <netinet/udp.h>7 8 #include "libbb_udhcp.h"9 #include "leases.h"10 5 11 6 /************************************/ … … 20 15 #define DHCPD_CONF_FILE "/etc/udhcpd.conf" 21 16 22 /*****************************************************************/23 /* Do not modify below here unless you know what you are doing!! */24 /*****************************************************************/25 26 /* DHCP protocol -- see RFC 2131 */27 #define SERVER_PORT 6728 #define CLIENT_PORT 6829 30 #define DHCP_MAGIC 0x6382536331 32 /* DHCP option codes (partial list) */33 #define DHCP_PADDING 0x0034 #define DHCP_SUBNET 0x0135 #define DHCP_TIME_OFFSET 0x0236 #define DHCP_ROUTER 0x0337 #define DHCP_TIME_SERVER 0x0438 #define DHCP_NAME_SERVER 0x0539 #define DHCP_DNS_SERVER 0x0640 #define DHCP_LOG_SERVER 0x0741 #define DHCP_COOKIE_SERVER 0x0842 #define DHCP_LPR_SERVER 0x0943 #define DHCP_HOST_NAME 0x0c44 #define DHCP_BOOT_SIZE 0x0d45 #define DHCP_DOMAIN_NAME 0x0f46 #define DHCP_SWAP_SERVER 0x1047 #define DHCP_ROOT_PATH 0x1148 #define DHCP_IP_TTL 0x1749 #define DHCP_MTU 0x1a50 #define DHCP_BROADCAST 0x1c51 #define DHCP_NTP_SERVER 0x2a52 #define DHCP_WINS_SERVER 0x2c53 #define DHCP_REQUESTED_IP 0x3254 #define DHCP_LEASE_TIME 0x3355 #define DHCP_OPTION_OVER 0x3456 #define DHCP_MESSAGE_TYPE 0x3557 #define DHCP_SERVER_ID 0x3658 #define DHCP_PARAM_REQ 0x3759 #define DHCP_MESSAGE 0x3860 #define DHCP_MAX_SIZE 0x3961 #define DHCP_T1 0x3a62 #define DHCP_T2 0x3b63 #define DHCP_VENDOR 0x3c64 #define DHCP_CLIENT_ID 0x3d65 #define DHCP_FQDN 0x5166 67 #define DHCP_END 0xFF68 69 70 #define BOOTREQUEST 171 #define BOOTREPLY 272 73 #define ETH_10MB 174 #define ETH_10MB_LEN 675 76 #define DHCPDISCOVER 177 #define DHCPOFFER 278 #define DHCPREQUEST 379 #define DHCPDECLINE 480 #define DHCPACK 581 #define DHCPNAK 682 #define DHCPRELEASE 783 #define DHCPINFORM 884 85 #define BROADCAST_FLAG 0x800086 87 #define OPTION_FIELD 088 #define FILE_FIELD 189 #define SNAME_FIELD 290 91 /* miscellaneous defines */92 #define MAC_BCAST_ADDR (uint8_t *) "\xff\xff\xff\xff\xff\xff"93 #define OPT_CODE 094 #define OPT_LEN 195 #define OPT_DATA 296 97 17 struct option_set { 98 18 uint8_t *data; … … 101 21 102 22 struct static_lease { 23 struct static_lease *next; 103 24 uint8_t *mac; 104 25 uint32_t *ip; 105 struct static_lease *next;106 26 }; 107 27 108 28 struct server_config_t { 109 uint32_t server; /* Our IP, in network order */ 110 uint32_t start; /* Start address of leases, network order */ 111 uint32_t end; /* End of leases, network order */ 112 struct option_set *options; /* List of DHCP options loaded from the config file */ 113 char *interface; /* The name of the interface to use */ 114 int ifindex; /* Index number of the interface to use */ 115 uint8_t arp[6]; /* Our arp address */ 116 unsigned long lease; /* lease time in seconds (host order) */ 117 unsigned long max_leases; /* maximum number of leases (including reserved address) */ 118 char remaining; /* should the lease file be interpreted as lease time remaining, or 119 * as the time the lease expires */ 120 unsigned long auto_time; /* how long should udhcpd wait before writing a config file. 121 * if this is zero, it will only write one on SIGUSR1 */ 122 unsigned long decline_time; /* how long an address is reserved if a client returns a 123 * decline message */ 124 unsigned long conflict_time; /* how long an arp conflict offender is leased for */ 125 unsigned long offer_time; /* how long an offered address is reserved */ 126 unsigned long min_lease; /* minimum lease a client can request*/ 29 uint32_t server; /* Our IP, in network order */ 30 /* start,end are in host order: we need to compare start <= ip <= end */ 31 uint32_t start_ip; /* Start address of leases, in host order */ 32 uint32_t end_ip; /* End of leases, in host order */ 33 struct option_set *options; /* List of DHCP options loaded from the config file */ 34 char *interface; /* The name of the interface to use */ 35 int ifindex; /* Index number of the interface to use */ 36 uint8_t arp[6]; /* Our arp address */ 37 char remaining; /* should the lease file be interpreted as lease time remaining, or 38 * as the time the lease expires */ 39 uint32_t lease; /* lease time in seconds (host order) */ 40 uint32_t max_leases; /* maximum number of leases (including reserved address) */ 41 uint32_t auto_time; /* how long should udhcpd wait before writing a config file. 42 * if this is zero, it will only write one on SIGUSR1 */ 43 uint32_t decline_time; /* how long an address is reserved if a client returns a 44 * decline message */ 45 uint32_t conflict_time; /* how long an arp conflict offender is leased for */ 46 uint32_t offer_time; /* how long an offered address is reserved */ 47 uint32_t min_lease; /* minimum lease a client can request */ 127 48 char *lease_file; 128 49 char *pidfile; 129 char *notify_file; 130 uint32_t siaddr; 131 char *sname; 132 char *boot_file; 50 char *notify_file; /* What to run whenever leases are written */ 51 uint32_t siaddr; /* next server bootp option */ 52 char *sname; /* bootp server name */ 53 char *boot_file; /* bootp boot file option */ 133 54 struct static_lease *static_leases; /* List of ip/mac pairs to assign static leases */ 134 55 }; … … 138 59 139 60 61 /*** leases.h ***/ 62 63 struct dhcpOfferedAddr { 64 uint8_t chaddr[16]; 65 uint32_t yiaddr; /* network order */ 66 uint32_t expires; /* host order */ 67 }; 68 69 struct dhcpOfferedAddr *add_lease(const uint8_t *chaddr, uint32_t yiaddr, unsigned long lease); 70 int lease_expired(struct dhcpOfferedAddr *lease); 71 struct dhcpOfferedAddr *find_lease_by_chaddr(const uint8_t *chaddr); 72 struct dhcpOfferedAddr *find_lease_by_yiaddr(uint32_t yiaddr); 73 uint32_t find_address(int check_expired); 74 75 76 /*** static_leases.h ***/ 77 78 /* Config file will pass static lease info to this function which will add it 79 * to a data structure that can be searched later */ 80 int addStaticLease(struct static_lease **lease_struct, uint8_t *mac, uint32_t *ip); 81 /* Check to see if a mac has an associated static lease */ 82 uint32_t getIpByMac(struct static_lease *lease_struct, void *arg); 83 /* Check to see if an ip is reserved as a static ip */ 84 uint32_t reservedIp(struct static_lease *lease_struct, uint32_t ip); 85 /* Print out static leases just to check what's going on (debug code) */ 86 void printStaticLeases(struct static_lease **lease_struct); 87 88 89 /*** serverpacket.h ***/ 90 91 int sendOffer(struct dhcpMessage *oldpacket); 92 int sendNAK(struct dhcpMessage *oldpacket); 93 int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr); 94 int send_inform(struct dhcpMessage *oldpacket); 95 96 97 /*** files.h ***/ 98 99 int read_config(const char *file); 100 void write_leases(void); 101 void read_leases(const char *file); 102 struct option_set *find_option(struct option_set *opt_list, char code); 103 104 140 105 #endif
Note:
See TracChangeset
for help on using the changeset viewer.