11/*
22 * DHCP client, internal to ktcp.
33 */
4- #include <sys/types.h>
54#include <stdio.h>
65#include <string.h>
76#include <arpa/inet.h>
@@ -25,11 +24,11 @@ static timeq_t dhcp_retry_time;
2524static int dhcp_retry_count ;
2625static timeq_t dhcp_start_time ;
2726
28- static uint32_t dhcp_xid ;
29- static uint32_t dhcp_yiaddr ;
30- static uint32_t dhcp_server_ip ;
31- static uint32_t dhcp_netmask_val ;
32- static uint32_t dhcp_gateway_val ;
27+ static __u32 dhcp_xid ;
28+ static __u32 dhcp_yiaddr ;
29+ static __u32 dhcp_server_ip ;
30+ static __u32 dhcp_netmask_val ;
31+ static __u32 dhcp_gateway_val ;
3332
3433static unsigned char dhcp_buf [DHCP_MSG_LEN ];
3534
@@ -44,12 +43,12 @@ static void dhcp_send_discover(void)
4443 msg -> htype = 1 ;
4544 msg -> hlen = 6 ;
4645 msg -> xid = htonl (dhcp_xid );
47- msg -> secs = htons ((uint16_t )(((Now - dhcp_start_time ) * 60 ) / 1000 ));
46+ msg -> secs = htons ((__u16 )(((Now - dhcp_start_time ) * 60 ) / 1000 ));
4847 msg -> flags = htons (0x8000 );
4948 memcpy (msg -> chaddr , eth_local_addr , 6 );
5049
5150 opts = (unsigned char * )(msg + 1 );
52- * (uint32_t * )opts = htonl (DHCP_MAGIC_COOKIE );
51+ * (__u32 * )opts = htonl (DHCP_MAGIC_COOKIE );
5352 opts += 4 ;
5453
5554 * opts ++ = DHCP_OPT_MSG_TYPE ;
@@ -80,12 +79,12 @@ static void dhcp_send_request(void)
8079 msg -> htype = 1 ;
8180 msg -> hlen = 6 ;
8281 msg -> xid = htonl (dhcp_xid );
83- msg -> secs = htons ((uint16_t )(((Now - dhcp_start_time ) * 60 ) / 1000 ));
82+ msg -> secs = htons ((__u16 )(((Now - dhcp_start_time ) * 60 ) / 1000 ));
8483 msg -> flags = htons (0x8000 );
8584 memcpy (msg -> chaddr , eth_local_addr , 6 );
8685
8786 opts = (unsigned char * )(msg + 1 );
88- * (uint32_t * )opts = htonl (DHCP_MAGIC_COOKIE );
87+ * (__u32 * )opts = htonl (DHCP_MAGIC_COOKIE );
8988 opts += 4 ;
9089
9190 * opts ++ = DHCP_OPT_MSG_TYPE ;
@@ -94,12 +93,12 @@ static void dhcp_send_request(void)
9493
9594 * opts ++ = DHCP_OPT_REQ_IP ;
9695 * opts ++ = 4 ;
97- * (uint32_t * )opts = dhcp_yiaddr ;
96+ * (__u32 * )opts = dhcp_yiaddr ;
9897 opts += 4 ;
9998
10099 * opts ++ = DHCP_OPT_SERVER_ID ;
101100 * opts ++ = 4 ;
102- * (uint32_t * )opts = dhcp_server_ip ;
101+ * (__u32 * )opts = dhcp_server_ip ;
103102 opts += 4 ;
104103
105104 * opts ++ = DHCP_OPT_END ;
@@ -203,8 +202,10 @@ void dhcp_init(void)
203202 dhcp_retry_count = 0 ;
204203 dhcp_start_time = Now ;
205204
206- dhcp_xid = ((uint32_t )eth_local_addr [0 ] << 24 ) | ((uint32_t )eth_local_addr [1 ] << 16 ) |
207- (eth_local_addr [2 ] << 8 ) | eth_local_addr [3 ];
205+ dhcp_xid = ((unsigned long )eth_local_addr [0 ] << 24 ) |
206+ ((unsigned long )eth_local_addr [1 ] << 16 ) |
207+ (eth_local_addr [2 ] << 8 ) |
208+ eth_local_addr [3 ];
208209 dhcp_xid ^= (Now & 0xFF ) << 8 ;
209210
210211 udp_register (DHCP_CLIENT_PORT , dhcp_input );
@@ -254,7 +255,7 @@ void dhcp_timer(void)
254255 * Handles OFFER, ACK, and NAK replies from the DHCP server.
255256 * Registered in dhcp_init() via udp_register().
256257 */
257- void dhcp_input (struct iphdr_s * iph , uint16_t src_port , unsigned char * data , int len )
258+ void dhcp_input (struct iphdr_s * iph , __u16 src_port , unsigned char * data , int len )
258259{
259260 struct dhcp_message_s * msg = (struct dhcp_message_s * )data ;
260261 unsigned char * opts ;
@@ -275,7 +276,7 @@ void dhcp_input(struct iphdr_s *iph, uint16_t src_port, unsigned char *data, int
275276
276277 if (optlen < 4 )
277278 return ;
278- if (* (uint32_t * )opts != htonl (DHCP_MAGIC_COOKIE )) /* DHCP option marker */
279+ if (* (__u32 * )opts != htonl (DHCP_MAGIC_COOKIE )) /* DHCP option marker */
279280 return ;
280281 opts += 4 ;
281282 optlen -= 4 ;
0 commit comments