1 /* Test the DHCP CLient with 2 physical interfaces, set NX_DHCP_CLIENT_MAX_INTERFACES = 2
2    and run the demo. Note because of limitations of the ram driver there is some
3    code in nx_dhcp_received_data_process in the nxd_dhcp_client.c to switch
4    packets that should be stamped for the secondary interface. Note to that DHCP Client
5    is modified in nx_dhcp_start() to set the XID arbitrarily. This simply facilitates
6    using the server responses (using "C arrays" from a real packet trace).*/
7 
8 
9 #include    "tx_api.h"
10 #include    "nx_api.h"
11 #include    "nxd_dhcp_client.h"
12 #include   "nx_ram_network_driver_test_1500.h"
13 
14 
15 #define     DEMO_STACK_SIZE         4096
16 #define     PACKET_PAYLOAD          1518
17 
18 extern NX_PACKET *packet_copy;
19 
20 /* Define the ThreadX, NetX object control blocks...  */
21 
22 NX_UDP_SOCKET           server_socket0;
23 TX_THREAD               server_thread0;
24 TX_THREAD               client_thread0;
25 NX_PACKET_POOL          client_pool;
26 NX_PACKET_POOL          server_pool;
27 NX_IP                   client_ip;
28 NX_IP                   server_ip0;
29 
30 
31 /* Define the NetX FTP object control block.  */
32 NX_DHCP                dhcp_client;
33 
34 typedef struct DHCP_RESPONSE_STRUCT
35 {
36     char              *dhcp_response_pkt_data;
37     int                dhcp_response_pkt_size;
38 } DHCP_RESPONSE;
39 
40 #define NUM_RESPONSES  7 // offer, ack, ack for renew for both interfaces
41                              // set to 7 to include an additional ack for rebind request on interface 0
42 static  DHCP_RESPONSE  dhcp_response[NUM_RESPONSES];
43 
44 /* Define the counters used in the demo application...  */
45 
46 static  UINT            error_counter = 0;
47 static  UINT            client_running = NX_FALSE;
48 static  UINT            state_changes[2] = {0,0};
49 static  UINT            renews[2] = {0,0};
50 static  UINT            rebinds[2] = {0,0};
51 static  UINT            bounds[2] = {0,0};
52 
53 #define SERVER_PORT      67
54 
55 
56 /* Replace the 'ram' driver with your Ethernet driver. */
57 extern  VOID nx_driver_ram_driver(NX_IP_DRIVER*);
58 
59 void    server0_thread_entry(ULONG thread_input);
60 void    client0_thread_entry(ULONG thread_input);
61 
62 static  UINT   nx_dhcp_response_packet_send(NX_UDP_SOCKET *socket_ptr, UINT port, INT packet_number, UINT iface_index);
63 static  void   dhcp_test_initialize();
64 
65 static  void   dhcp_interface_state_change0(NX_DHCP *dhcp_ptr, UCHAR new_state);
66 static  void   dhcp_interface_state_change1(NX_DHCP *dhcp_ptr, UCHAR new_state);
67 
68 extern   void  test_control_return(UINT);
69 extern   void _nx_ram_network_driver_1024(NX_IP_DRIVER *driver_req_ptr);
70 
71 
72 char offer_response[300] = {
73 
74 0x02, 0x01, 0x06, 0x00, 0x31, 0x9D, /* {.....T. */
75 0x58, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
76 0x00, 0x00, 0xc0, 0x02, 0x02, 0xf7, 0xc0, 0x02, /* ........ */
77 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, /* ........ */
78 0x22, 0x33, 0x44, 0x58, 0x00, 0x00, 0x00, 0x00, /* T....... */
79 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
80 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
81 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
82 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
83 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
84 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
85 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
88 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
89 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
90 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
91 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
92 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
93 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
94 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
95 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
96 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
97 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
100 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
101 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
102 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
103 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, /* ......c. */
104 0x53, 0x63, 0x35, 0x01, 0x02, 0x01, 0x04, 0xff, /* Sc5..... */
105 0xff, 0xff, 0x00, 0x3a, 0x04, 0x00, 0x06, 0xac, /* ...:.... */
106 0x98, 0x3b, 0x04, 0x00, 0x0b, 0xae, 0x0a, 0x33, /* .;.....3 */
107 0x04, 0x00, 0x0d, 0x59, 0x30, 0x36, 0x04, 0xc0, /* ...Y06.. */
108 0x02, 0x02, 0x01, 0x03, 0x04, 0xc0, 0x02, 0x02, /* ........ */
109 0x01, 0x06, 0x04, 0xc0, 0x02, 0x02, 0x01, 0xff, /* ........ */
110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00              /* ...... */
112 };
113 
114 static int offer_response_size = 300;
115 
116 /* Frame (342 bytes) */
117 char ack_response[300] = {
118 
119 0x02, 0x01, 0x06, 0x00, 0x31, 0x9D, /* {.....T. */
120 0x58, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
121 0x00, 0x00, 0xc0, 0x02, 0x02, 0xf7, 0xc0, 0x02, /* ........ */
122 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, /* ........ */
123 0x22, 0x33, 0x44, 0x58, 0x00, 0x00, 0x00, 0x00, /* T....... */
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
126 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
129 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
130 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
131 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
134 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
138 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
144 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
145 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
146 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
147 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
148 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, /* ......c. */
149 0x53, 0x63, 0x35, 0x01, 0x05, 0x3a, 0x04, 0x00, /* Sc5..:.. */
150 0x06, 0xac, 0x98, 0x3b, 0x04, 0x00, 0x0b, 0xae, /* ...;.... */
151 0x0a, 0x33, 0x04, 0x00, 0x0d, 0x59, 0x30, 0x36, /* .3...Y06 */
152 0x04, 0xc0, 0x02, 0x02, 0x01, 0x01, 0x04, 0xff, /* ........ */
153 0xff, 0xff, 0x00, 0x03, 0x04, 0xc0, 0x02, 0x02, /* ........ */
154 0x01, 0x06, 0x04, 0xc0, 0x02, 0x02, 0x01, 0xff, /* ........ */
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00              /* ...... */
157 };
158 
159 static int ack_response_size = 300;
160 
161 
162 /* Frame (342 bytes) */
163 static char renew_response[300] = {
164 
165 
166 0x02, 0x01, 0x06, 0x00, 0x31, 0x9D, /* :.....T. */
167 0x58, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
168 0x00, 0x00, 0xc0, 0x02, 0x02, 0xf8, 0x00, 0x00, /* ........ */
169 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, /* ........ */
170 0x22, 0x33, 0x44, 0x58, 0x00, 0x00, 0x00, 0x00, /* T....... */
171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
181 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
183 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
184 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
191 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
192 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
193 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
194 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, /* ......c. */
196 0x53, 0x63, 0x35, 0x01, 0x05, 0x3a, 0x04, 0x00, /* Sc5..:.. */
197 0x05, 0xac, 0x98, 0x3b, 0x04, 0x00, 0x0b, 0xae, /* ...;.... */
198 0x0a, 0x33, 0x04, 0x00, 0x0d, 0x59, 0x30, 0x36, /* .3...Y06 */
199 0x04, 0xc0, 0x02, 0x02, 0x01, 0x01, 0x04, 0xff, /* ........ */
200 0xff, 0xff, 0x00, 0x03, 0x04, 0xc0, 0x02, 0x02, /* ........ */
201 0x01, 0x06, 0x04, 0xc0, 0x02, 0x02, 0x01, 0xff, /* ........ */
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00              /* ...... */
204 };
205 
206 static int renew_response_size = 300;
207 
208 /* Frame (342 bytes) */
209 static char rebind_response[300] = {
210 
211 
212 0x02, 0x01, 0x06, 0x00, 0x31, 0x9D, /* g.....T. */
213 0x58, 0xA2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
214 0x00, 0x00, 0xc0, 0x02, 0x02, 0xf9, 0x00, 0x00, /* ........ */
215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, /* ........ */
216 0x22, 0x33, 0x44, 0x58, 0x00, 0x00, 0x00, 0x00, /* T....... */
217 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
219 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
220 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
221 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
222 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
223 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
224 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
226 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
227 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
228 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
229 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
230 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, /* ......c. */
242 0x53, 0x63, 0x35, 0x01, 0x05, 0x3a, 0x04, 0x00, /* Sc5..:.. */
243 0x07, 0xac, 0x98, 0x3b, 0x04, 0x00, 0x0b, 0xae, /* ...;.... */
244 0x0a, 0x33, 0x04, 0x00, 0x0d, 0x59, 0x30, 0x36, /* .3...Y06 */
245 0x04, 0xc0, 0x02, 0x02, 0x01, 0x01, 0x04, 0xff, /* ........ */
246 0xff, 0xff, 0x00, 0x03, 0x04, 0xc0, 0x02, 0x02, /* ........ */
247 0x01, 0x06, 0x04, 0xc0, 0x02, 0x02, 0x01, 0xff, /* ........ */
248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00              /* ...... */
250 };
251 static int rebind_response_size = 300;
252 
253 
254 /* Responses from server on interface 1 */
255 
256 char offer_response1[300] = {
257 
258 0x02, 0x01, 0x06, 0x00, 0x2a, 0x3e, /* {.....T. */
259 0xf0, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
260 0x00, 0x00, 0xc0, 0x01, 0x01, 0xf7, 0xc0, 0x01, /* ........ */
261 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, /* ........ */
262 0x22, 0x33, 0x44, 0x59, 0x00, 0x00, 0x00, 0x00, /* T....... */
263 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
264 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
265 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
270 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
271 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
272 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
273 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
274 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
275 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
278 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
281 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
282 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
285 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
286 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
287 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, /* ......c. */
288 0x53, 0x63, 0x35, 0x01, 0x02, 0x01, 0x04, 0xff, /* Sc5..... */
289 0xff, 0xff, 0x00, 0x3a, 0x04, 0x00, 0x06, 0xac, /* ...:.... */
290 0x98, 0x3b, 0x04, 0x00, 0x0b, 0xae, 0x0a, 0x33, /* .;.....3 */
291 0x04, 0x00, 0x0d, 0x59, 0x30, 0x36, 0x04, 0xc0, /* ...Y06.. */
292 0x01, 0x01, 0x01, 0x03, 0x04, 0xc0, 0x01, 0x01, /* ........ */
293 0x01, 0x06, 0x04, 0xc0, 0x01, 0x01, 0x01, 0xff, /* ........ */
294 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00              /* ...... */
296 };
297 
298 static int offer_response1_size = 300;
299 
300 /* Frame (342 bytes) */
301 char ack_response1[300] = {
302 
303 0x02, 0x01, 0x06, 0x00, 0x2a, 0x3e, /* {.....T. */
304 0xf0, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
305 0x00, 0x00, 0xc0, 0x01, 0x01, 0xf7, 0xc0, 0x01, /* ........ */
306 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, /* ........ */
307 0x22, 0x33, 0x44, 0x59, 0x00, 0x00, 0x00, 0x00, /* T....... */
308 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
309 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
310 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
311 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
312 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
313 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
315 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
316 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
317 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
318 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
319 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
320 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
321 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
322 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
323 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
324 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
325 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
326 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
327 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
328 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
329 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
331 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
332 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, /* ......c. */
333 0x53, 0x63, 0x35, 0x01, 0x05, 0x3a, 0x04, 0x00, /* Sc5..:.. */
334 0x06, 0xac, 0x98, 0x3b, 0x04, 0x00, 0x0b, 0xae, /* ...;.... */
335 0x0a, 0x33, 0x04, 0x00, 0x0d, 0x59, 0x30, 0x36, /* .3...Y06 */
336 0x04, 0xc0, 0x01, 0x01, 0x01, 0x01, 0x04, 0xff, /* ........ */
337 0xff, 0xff, 0x00, 0x03, 0x04, 0xc0, 0x01, 0x01, /* ........ */
338 0x01, 0x06, 0x04, 0xc0, 0x01, 0x01, 0x01, 0xff, /* ........ */
339 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
340 0x00, 0x00, 0x00, 0x00, 0x00, 0x00              /* ...... */
341 };
342 
343 static int ack_response1_size = 300;
344 
345 
346 /* Frame (342 bytes) */
347 static char renew_response1[300] = {
348 
349 
350 0x02, 0x01, 0x06, 0x00, 0x2a, 0x3e, /* :.....T. */
351 0xf0, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
352 0x00, 0x00, 0xc0, 0x01, 0x01, 0xf8, 0x00, 0x00, /* ........ */
353 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, /* ........ */
354 0x22, 0x33, 0x44, 0x59, 0x00, 0x00, 0x00, 0x00, /* T....... */
355 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
356 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
358 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
360 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
362 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
363 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
364 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
365 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
366 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
367 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
368 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
369 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
370 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
371 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
374 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
375 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
376 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
377 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
378 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x82, /* ......c. */
380 0x53, 0x63, 0x35, 0x01, 0x05, 0x3a, 0x04, 0x00, /* Sc5..:.. */
381 0x05, 0xac, 0x98, 0x3b, 0x04, 0x00, 0x0b, 0xae, /* ...;.... */
382 0x0a, 0x33, 0x04, 0x00, 0x0d, 0x59, 0x30, 0x36, /* .3...Y06 */
383 0x04, 0xc0, 0x01, 0x01, 0x01, 0x01, 0x04, 0xff, /* ........ */
384 0xff, 0xff, 0x00, 0x03, 0x04, 0xc0, 0x01, 0x01, /* ........ */
385 0x01, 0x06, 0x04, 0xc0, 0x01, 0x01, 0x01, 0xff, /* ........ */
386 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
387 0x00, 0x00, 0x00, 0x00, 0x00, 0x00              /* ...... */
388 };
389 
390 static int renew_response1_size = 300;
391 
392 
393 
394 
395 /* Define what the initial system looks like.  */
396 
397 #ifdef CTEST
test_application_define(void * first_unused_memory)398 VOID test_application_define(void *first_unused_memory)
399 #else
400 void    netx_dhcp_cilent_two_interface_test_application_define(void *first_unused_memory)
401 #endif
402 {
403 
404 UINT    status;
405 UCHAR   *pointer;
406 
407 
408     /* Setup the working pointer.  */
409     pointer =  (UCHAR *) first_unused_memory;
410 
411     /* Initialize NetX.  */
412     nx_system_initialize();
413 
414     /* Set up the FTP Server. */
415 
416     /* Create the main server thread.  */
417     status = tx_thread_create(&server_thread0, "Server0 thread ", server0_thread_entry, 0,
418             pointer, DEMO_STACK_SIZE,
419             6, 6, TX_NO_TIME_SLICE, TX_AUTO_START);
420     pointer = pointer + DEMO_STACK_SIZE ;
421 
422     /* Check status.  */
423     if (status != NX_SUCCESS)
424     {
425         error_counter++;
426         return;
427     }
428 
429     /* Create the server packet pool.  */
430     status =  nx_packet_pool_create(&server_pool, "Server Packet Pool", 700, pointer , 700*10);
431 
432     pointer = pointer + 700*10;
433     if (status)
434         error_counter++;
435 
436     /* Create an IP instance.  */
437     status = nx_ip_create(&server_ip0,
438                           "Server IP",
439                           IP_ADDRESS(192,2,2,1),
440                           0xFFFFFF00UL,
441                           &server_pool, _nx_ram_network_driver_1024,
442                           pointer, DEMO_STACK_SIZE, 1);
443 
444     pointer = pointer + DEMO_STACK_SIZE;
445 
446     if (status)
447         error_counter++;
448 
449     status = nx_ip_interface_attach(&server_ip0, "Server1 interface", IP_ADDRESS(192,1,1,1), 0xFFFFFF00UL, _nx_ram_network_driver_1024);
450     /* Check status.  */
451     if (status != NX_SUCCESS)
452     {
453         error_counter++;
454         return;
455     }
456 
457     /* Enable ARP and supply ARP cache memory for the server IP instance.  */
458     status =  nx_arp_enable(&server_ip0, (void *) pointer, 1024);
459     pointer = pointer + 1024;
460     if (status)
461         error_counter++;
462 
463      /* Enable UDP traffic.  */
464     status = nx_udp_enable(&server_ip0);
465     if (status)
466         error_counter++;
467 
468     /* Set up the Client. */
469 
470     /* Create the main client thread.  */
471     status = tx_thread_create(&client_thread0, "Client thread ", client0_thread_entry, 0,
472             pointer, DEMO_STACK_SIZE,
473             6, 6, TX_NO_TIME_SLICE, TX_AUTO_START);
474     pointer = pointer + DEMO_STACK_SIZE ;
475 
476     /* Check status.  */
477     if (status != NX_SUCCESS)
478     {
479         error_counter++;
480         return;
481     }
482 
483     /* Create a packet pool for the client.  */
484     status =  nx_packet_pool_create(&client_pool, "Client Packet Pool", PACKET_PAYLOAD, pointer, 25*PACKET_PAYLOAD);
485 
486         /* Check status.  */
487     if (status != NX_SUCCESS)
488     {
489         error_counter++;
490         return;
491     }
492 
493     pointer =  pointer + 25*PACKET_PAYLOAD;
494 
495     /* Create an IP instance for the client.  */
496     status = nx_ip_create(&client_ip, "Client0 IP", IP_ADDRESS(0,0,0,0), 0xFFFFFF00UL,
497                                                 &client_pool, _nx_ram_network_driver_1024, pointer, 2048, 1);
498 
499         /* Check status.  */
500     if (status != NX_SUCCESS)
501     {
502         error_counter++;
503         return;
504     }
505 
506     pointer = pointer + 2048;
507 
508     status = nx_ip_interface_attach(&client_ip, "Client1 IP", IP_ADDRESS(0,0,0,0), 0xFFFFFF00UL, _nx_ram_network_driver_1024);
509     /* Check status.  */
510     if (status != NX_SUCCESS)
511     {
512         error_counter++;
513         return;
514     }
515 
516     /* Enable ARP and supply ARP cache memory for the Client IP.  */
517     nx_arp_enable(&client_ip, (void *) pointer, 1024);
518 
519     pointer = pointer + 1024;
520 
521     /* Enable UDP for client IP instance.  */
522     nx_udp_enable(&client_ip);
523     nx_icmp_enable(&client_ip);
524 
525     return;
526 
527 }
528 
529 /* Define the main DHCP client thread.  */
client0_thread_entry(ULONG thread_input)530 void    client0_thread_entry(ULONG thread_input)
531 {
532 
533 UINT        status;
534 
535     tx_thread_sleep(20);
536 
537     /* Create the DHCP instance.  */
538     status =  nx_dhcp_create(&dhcp_client, &client_ip, "dhcp0");
539     if (status)
540         error_counter++;
541 
542     status = nx_dhcp_packet_pool_set(&dhcp_client, &client_pool);
543     if (status)
544         error_counter++;
545 
546     /* Register state change variable.  */
547     status =  nx_dhcp_interface_state_change_notify(&dhcp_client, 0, dhcp_interface_state_change0);
548     if (status)
549         error_counter++;
550 
551 
552     /* Register state change variable.  */
553     status =  nx_dhcp_interface_state_change_notify(&dhcp_client, 1, dhcp_interface_state_change1);
554     if (status)
555         error_counter++;
556 
557     printf("Start the client\n\n");
558     /* Start the DHCP Client.  */
559     status =  nx_dhcp_start(&dhcp_client);
560     if (status)
561         error_counter++;
562 
563     while(client_running == NX_FALSE)
564     {
565         tx_thread_sleep(100);
566     }
567 }
568 
569 /* Define the helper DHCP server thread on interface 0.  */
server0_thread_entry(ULONG thread_input)570 void    server0_thread_entry(ULONG thread_input)
571 {
572 
573 UINT         status;
574 NX_PACKET   *my_packet;
575 UINT         i, j, k;
576 
577     /* Print out test information banner.  */
578     printf("NetX Test:   DHCP Client Two Interface Test............................\n");
579 
580     /* Check for earlier error. */
581     if(error_counter)
582     {
583         printf("ERROR!\n");
584         test_control_return(1);
585     }
586 
587     /* Create a  socket as the  server.  */
588     status = nx_udp_socket_create(&server_ip0, &server_socket0, "Server0 socket", NX_IP_NORMAL, NX_FRAGMENT_OKAY, NX_IP_TIME_TO_LIVE, 5);
589 
590     /* Check status.  */
591     if (status)
592     {
593         error_counter++;
594     }
595 
596     status =  nx_udp_socket_bind(&server_socket0, NX_DHCP_SERVER_UDP_PORT, TX_WAIT_FOREVER);
597 
598     /* Check status.  */
599     if (status)
600     {
601         error_counter++;
602     }
603 
604     /* Load up the server 'responses'. */
605     dhcp_test_initialize();
606     i = 0;
607     j = 4; // index into array of responses to send from interface server 1
608     k = 0; // count of packets received on interface 1
609 
610     /* Wait for Client requests */
611     //while (i < 3)  //  Reduce this to see client packet retransmissions
612     while (i < NUM_RESPONSES)
613     {
614 
615         status =  nx_udp_socket_receive(&server_socket0, &my_packet, 10 * NX_IP_PERIODIC_RATE);
616 
617         /* Check status.  */
618         if (status)
619         {
620             printf("ERRO7R on 0!\n");
621             error_counter++;
622         }
623         else
624         {
625 
626             ULONG source_ip_address;
627             UINT protocol;
628             UINT source_port;
629             UINT iface_index;
630 
631             UCHAR *work_ptr = my_packet -> nx_packet_prepend_ptr + 4;
632             ULONG *id = (ULONG *)work_ptr;
633 
634             NX_CHANGE_ULONG_ENDIAN(*id);
635 
636             status = nx_udp_packet_info_extract(my_packet, &source_ip_address, &protocol, &source_port, &iface_index);
637 
638             if ((iface_index == 1) && (*id != 0x2a3ef01d))
639             {
640                 /* This packet is really intended for the server on the primary interface. */
641                 my_packet -> nx_packet_ip_interface = &(server_ip0.nx_ip_interface[0]);
642                 iface_index = 0;
643             }
644             else if ((iface_index == 0) && (*id != 0x319d58a2))
645             {
646                  /* This packet is really intended for server on secondary interface. */
647                 my_packet -> nx_packet_ip_interface = &(server_ip0.nx_ip_interface[1]);
648                 iface_index = 1;
649             }
650 
651              /* Is this packet from the client on interface 1? */
652             if (*id == 0x2a3ef01d)
653             {
654 
655 // do this silliness to drop server packets
656 if (i != 1)
657 {
658 //////////
659 
660                 /* Yes, make sure to send it out on interface 1. */
661                 printf("Server 1 got %dth packet. Send %d packet back\n", k, j-4);
662                 status = nx_dhcp_response_packet_send(&server_socket0, 68, j, 1);
663 }
664                 j++;
665                 k++;
666 
667             }
668             else
669             {
670 if (i != 1)
671 {
672                 printf("Server 0 got %dth packet\n", i);
673                 status = nx_dhcp_response_packet_send(&server_socket0, 68, i, 0);
674 }
675                 i++;
676             }
677             nx_packet_release(my_packet);
678         }
679     }
680 
681     printf("0: All done, waiting for client 0 to go away\n");
682 
683     /* Wait for the client to terminate the connection. */
684     while(client_running != NX_TRUE)
685       tx_thread_sleep(20);
686 
687     /* Delete the UDP socket.  */
688     nx_udp_socket_delete(&server_socket0);
689 
690     if(error_counter)
691     {
692         printf("ERROR!\n");
693         test_control_return(1);
694     }
695     else
696     {
697         printf("SUCCESS!\n");
698         test_control_return(0);
699     };
700 }
701 
702 
703 
704 
dhcp_test_initialize()705 static void  dhcp_test_initialize()
706 {
707 
708 
709 /* Download data responses */
710     dhcp_response[0].dhcp_response_pkt_data = &offer_response[0];
711     dhcp_response[0].dhcp_response_pkt_size = offer_response_size ;
712 
713     dhcp_response[1].dhcp_response_pkt_data = &ack_response[0];
714     dhcp_response[1].dhcp_response_pkt_size = ack_response_size ;
715 
716     dhcp_response[2].dhcp_response_pkt_data = &renew_response[0];
717     dhcp_response[2].dhcp_response_pkt_size = renew_response_size ;
718 
719     dhcp_response[3].dhcp_response_pkt_data = &rebind_response[0];
720     dhcp_response[3].dhcp_response_pkt_size = rebind_response_size ;
721 
722     /* Server on second interface */
723 
724     dhcp_response[4].dhcp_response_pkt_data = &offer_response1[0];
725     dhcp_response[4].dhcp_response_pkt_size = offer_response1_size ;
726 
727     dhcp_response[5].dhcp_response_pkt_data = &ack_response1[0];
728     dhcp_response[5].dhcp_response_pkt_size = ack_response1_size ;
729 
730     dhcp_response[6].dhcp_response_pkt_data = &renew_response1[0];
731     dhcp_response[6].dhcp_response_pkt_size = renew_response1_size ;
732 
733 }
734 
735 
736 
nx_dhcp_response_packet_send(NX_UDP_SOCKET * server_socket0,UINT port,INT packet_number,UINT iface_index)737 static UINT   nx_dhcp_response_packet_send(NX_UDP_SOCKET *server_socket0, UINT port, INT packet_number, UINT iface_index)
738 {
739 UINT        status;
740 NX_PACKET   *response_packet;
741 UINT        local_index;
742 
743     local_index = packet_number;
744     if (iface_index == 1)
745     {
746         local_index = packet_number - 4;
747     }
748     printf("Server %d sends %dth response\n", iface_index, local_index);
749     /* Allocate a response packet.  */
750     status =  nx_packet_allocate(&server_pool, &response_packet, NX_TCP_PACKET, TX_WAIT_FOREVER);
751 
752     /* Check status.  */
753     if (status)
754     {
755         error_counter++;
756     }
757 
758     /* Write the  response messages into the packet payload!  */
759     memcpy(response_packet -> nx_packet_prepend_ptr, dhcp_response[packet_number].dhcp_response_pkt_data,
760            dhcp_response[packet_number].dhcp_response_pkt_size);
761 
762     /* Adjust the write pointer.  */
763     response_packet -> nx_packet_length =  dhcp_response[packet_number].dhcp_response_pkt_size;
764     response_packet -> nx_packet_append_ptr =  response_packet -> nx_packet_prepend_ptr + response_packet -> nx_packet_length;
765 
766     if (iface_index == 0)
767     {
768 
769 
770         /* Set driver callback function. */
771         //advanced_packet_process_callback = advanced_packet_process;
772 
773         /* Send the  packet with the correct port.  */
774         status =  nx_udp_socket_send(server_socket0, response_packet, 0xFFFFFFFF, 68);
775     }
776     else
777     {
778 
779         /* Send the  packet with the correct port.  */
780         //status =  nx_udp_socket_send(&server_socket1, response_packet, 0xFFFFFFFF, 68);
781         NXD_ADDRESS temp;
782         temp.nxd_ip_version = NX_IP_VERSION_V4;
783         temp.nxd_ip_address.v4 = 0xFFFFFFFF;
784         status = nxd_udp_socket_source_send(server_socket0, response_packet, &temp, 68, 1);
785     }
786 
787     /* Check the status.  */
788     if (status)
789         nx_packet_release(response_packet);
790 
791     return status;
792 }
793 
794 
dhcp_interface_state_change0(NX_DHCP * dhcp_ptr,UCHAR new_state)795 void dhcp_interface_state_change0(NX_DHCP *dhcp_ptr, UCHAR new_state)
796 {
797 
798 UINT dhcp_state;
799 
800     dhcp_state = (UINT)new_state;
801 
802 
803     /* Increment state changes counter.  */
804     state_changes[0]++;
805 
806     if (dhcp_state == NX_DHCP_STATE_RENEWING)
807     {
808        renews[0]++;
809     }
810     else if (dhcp_state == NX_DHCP_STATE_REBINDING)
811     {
812        rebinds[0]++;
813     }
814     else if (dhcp_state == NX_DHCP_STATE_BOUND)
815     {
816        bounds[0]++;
817     }
818 
819     return;
820 }
821 
822 
dhcp_interface_state_change1(NX_DHCP * dhcp_ptr,UCHAR new_state)823 void dhcp_interface_state_change1(NX_DHCP *dhcp_ptr, UCHAR new_state)
824 {
825 
826 UINT dhcp_state;
827 
828     dhcp_state = (UINT)new_state;
829 
830 
831     /* Increment state changes counter.  */
832     state_changes[1]++;
833 
834     if (dhcp_state == NX_DHCP_STATE_RENEWING)
835     {
836        renews[1]++;
837     }
838     else if (dhcp_state == NX_DHCP_STATE_REBINDING)
839     {
840        rebinds[1]++;
841     }
842     else if (dhcp_state == NX_DHCP_STATE_BOUND)
843     {
844        bounds[1]++;
845     }
846 
847     return;
848 }
849 
850