www.usr.com/support/gpl/USR9113_release1.0.tar.gz
[bcm963xx.git] / userapps / opensource / udhcp / dhcpd.h
1 /* dhcpd.h */
2 #ifndef _DHCPD_H
3 #define _DHCPD_H
4
5 #include <netinet/ip.h>
6 #include <netinet/udp.h>
7
8 #include "leases.h"
9
10 /************************************/
11 /* Defaults _you_ may want to tweak */
12 /************************************/
13
14 /* the period of time the client is allowed to use that address */
15 #define LEASE_TIME              (60*60*24*10) /* 10 days of seconds */
16
17 /* where to find the DHCP server configuration file */
18 #define DHCPD_CONF_FILE         "/etc/udhcpd.conf"
19
20 // BRCM
21 /* where to find the DHCP vendor IDs configuration file */
22 #define DHCPD_VENDORID_CONF_FILE         "/var/udhcpd_vendorid.conf"
23
24 /*****************************************************************/
25 /* Do not modify below here unless you know what you are doing!! */
26 /*****************************************************************/
27
28 /* DHCP protocol -- see RFC 2131 */
29 #define SERVER_PORT             67
30 #define CLIENT_PORT             68
31
32 #define DHCP_MAGIC              0x63825363
33
34 /* DHCP option codes (partial list) */
35 #define DHCP_PADDING            0x00
36 #define DHCP_SUBNET             0x01
37 #define DHCP_TIME_OFFSET        0x02
38 #define DHCP_ROUTER             0x03
39 #define DHCP_TIME_SERVER        0x04
40 #define DHCP_NAME_SERVER        0x05
41 #define DHCP_DNS_SERVER         0x06
42 #define DHCP_LOG_SERVER         0x07
43 #define DHCP_COOKIE_SERVER      0x08
44 #define DHCP_LPR_SERVER         0x09
45 #define DHCP_HOST_NAME          0x0c
46 #define DHCP_BOOT_SIZE          0x0d
47 #define DHCP_DOMAIN_NAME        0x0f
48 #define DHCP_SWAP_SERVER        0x10
49 #define DHCP_ROOT_PATH          0x11
50 #define DHCP_IP_TTL             0x17
51 #define DHCP_MTU                0x1a
52 #define DHCP_BROADCAST          0x1c
53 #define DHCP_NTP_SERVER         0x2a
54 #define DHCP_WINS_SERVER        0x2c
55 #define DHCP_REQUESTED_IP       0x32
56 #define DHCP_LEASE_TIME         0x33
57 #define DHCP_OPTION_OVER        0x34
58 #define DHCP_MESSAGE_TYPE       0x35
59 #define DHCP_SERVER_ID          0x36
60 #define DHCP_PARAM_REQ          0x37
61 #define DHCP_MESSAGE            0x38
62 #define DHCP_MAX_SIZE           0x39
63 #define DHCP_T1                 0x3a
64 #define DHCP_T2                 0x3b
65 #define DHCP_VENDOR             0x3c
66 #define DHCP_CLIENT_ID          0x3d
67 #define DHCP_VENDOR_IDENTIFYING 0x7d
68
69 #define DHCP_END                0xFF
70
71
72 #define BOOTREQUEST             1
73 #define BOOTREPLY               2
74
75 #define ETH_10MB                1
76 #define ETH_10MB_LEN            6
77
78 #define DHCPDISCOVER            1
79 #define DHCPOFFER               2
80 #define DHCPREQUEST             3
81 #define DHCPDECLINE             4
82 #define DHCPACK                 5
83 #define DHCPNAK                 6
84 #define DHCPRELEASE             7
85 #define DHCPINFORM              8
86
87 #define BROADCAST_FLAG          0x8000
88
89 #define OPTION_FIELD            0
90 #define FILE_FIELD              1
91 #define SNAME_FIELD             2
92
93 /* miscellaneous defines */
94 #define TRUE                    1
95 #define FALSE                   0
96 #define MAC_BCAST_ADDR          "\xff\xff\xff\xff\xff\xff"
97 #define OPT_CODE 0
98 #define OPT_LEN 1
99
100 // BRCM
101 #define MAX_VENDOR_IDS          80
102
103 struct option_set {
104         unsigned char *data;
105         struct option_set *next;
106 };
107
108 struct server_config_t {
109         u_int32_t server;               /* Our IP, in network order */
110         u_int32_t start;                /* Start address of leases, network order */
111         u_int32_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         unsigned char 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*/
127         char *lease_file;
128         char *pidfile;
129         char *notify_file;              /* What to run whenever leases are written */
130         u_int32_t siaddr;               /* next server bootp option */
131         char *sname;                    /* bootp server name */
132         char *boot_file;                /* bootp boot file option */
133         // BRCM vendirid and decline_file
134         char *vendorid;
135         char *decline_file;
136 };      
137
138 // BRCM
139 struct vendor_id_config_t {
140     char vendorid[64];
141 };
142
143 /* vendor identifying option */
144 typedef struct vi_option_info {
145   u_int32_t enterprise;
146   char *oui;
147   char *serialNumber;
148   char *productClass;
149   u_int32_t ipAddr;
150   struct vi_option_info *next;
151 } VI_OPTION_INFO, *pVI_OPTION_INFO;
152
153 typedef struct viInfoList 
154 {
155   int count;
156   pVI_OPTION_INFO pHead;
157   pVI_OPTION_INFO pTail;
158 } VI_INFO_LIST, *pVI_INFO_LIST;
159 extern pVI_INFO_LIST viList;
160
161 extern struct server_config_t server_config;
162 extern struct dhcpOfferedAddr *leases;
163 // BRCM
164 extern struct dhcpOfferedAddr *declines;
165 extern struct vendor_id_config_t vendor_id_config[MAX_VENDOR_IDS];
166                 
167
168 #endif