Changeset 158 for uKadecot/trunk/uip/apps/dhcpc/dhcpc.c
- Timestamp:
- Feb 20, 2016, 10:43:32 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uKadecot/trunk/uip/apps/dhcpc/dhcpc.c
r125 r158 35 35 #include <string.h> 36 36 37 #include " uip.h"38 #include "dhcpc .h"39 #include " timer.h"40 #include " pt.h"37 #include "net/ip/uip.h" 38 #include "dhcpc/dhcpc.h" 39 #include "sys/timer.h" 40 #include "sys/pt.h" 41 41 42 42 #define STATE_INITIAL 0 … … 53 53 54 54 struct dhcp_msg { 55 u 8_t op, htype, hlen, hops;56 u 8_t xid[4];57 u 16_t secs, flags;58 u 8_t ciaddr[4];59 u 8_t yiaddr[4];60 u 8_t siaddr[4];61 u 8_t giaddr[4];62 u 8_t chaddr[16];55 uint8_t op, htype, hlen, hops; 56 uint8_t xid[4]; 57 uint16_t secs, flags; 58 uint8_t ciaddr[4]; 59 uint8_t yiaddr[4]; 60 uint8_t siaddr[4]; 61 uint8_t giaddr[4]; 62 uint8_t chaddr[16]; 63 63 #ifndef UIP_CONF_DHCP_LIGHT 64 u 8_t sname[64];65 u 8_t file[128];66 #endif 67 u 8_t options[312];64 uint8_t sname[64]; 65 uint8_t file[128]; 66 #endif 67 uint8_t options[312]; 68 68 }; 69 69 … … 103 103 #define DHCP_OPTION_END 255 104 104 105 static const u 8_t xid[4] = {0xad, 0xde, 0x12, 0x23};106 static const u 8_t magic_cookie[4] = {99, 130, 83, 99};107 /*---------------------------------------------------------------------------*/ 108 static u 8_t *109 add_msg_type(u 8_t *optptr, u8_t type)105 static const uint8_t xid[4] = {0xad, 0xde, 0x12, 0x23}; 106 static const uint8_t magic_cookie[4] = {99, 130, 83, 99}; 107 /*---------------------------------------------------------------------------*/ 108 static uint8_t * 109 add_msg_type(uint8_t *optptr, uint8_t type) 110 110 { 111 111 *optptr++ = DHCP_OPTION_MSG_TYPE; … … 115 115 } 116 116 /*---------------------------------------------------------------------------*/ 117 static u 8_t *118 add_server_id(struct dhcpc_state *s, u 8_t *optptr)117 static uint8_t * 118 add_server_id(struct dhcpc_state *s, uint8_t *optptr) 119 119 { 120 120 *optptr++ = DHCP_OPTION_SERVER_ID; … … 124 124 } 125 125 /*---------------------------------------------------------------------------*/ 126 static u 8_t *127 add_req_ipaddr(struct dhcpc_state *s, u 8_t *optptr)126 static uint8_t * 127 add_req_ipaddr(struct dhcpc_state *s, uint8_t *optptr) 128 128 { 129 129 *optptr++ = DHCP_OPTION_REQ_IPADDR; … … 133 133 } 134 134 /*---------------------------------------------------------------------------*/ 135 static u 8_t *136 add_req_options(u 8_t *optptr)135 static uint8_t * 136 add_req_options(uint8_t *optptr) 137 137 { 138 138 *optptr++ = DHCP_OPTION_REQ_LIST; … … 144 144 } 145 145 /*---------------------------------------------------------------------------*/ 146 static u 8_t *147 add_end(u 8_t *optptr)146 static uint8_t * 147 add_end(uint8_t *optptr) 148 148 { 149 149 *optptr++ = DHCP_OPTION_END; … … 179 179 send_discover(struct dhcpc_state *s) 180 180 { 181 u 8_t *end;181 uint8_t *end; 182 182 struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata; 183 183 … … 188 188 end = add_end(end); 189 189 190 uip_send(uip_appdata, end - (u 8_t *)uip_appdata);190 uip_send(uip_appdata, end - (uint8_t *)uip_appdata); 191 191 } 192 192 /*---------------------------------------------------------------------------*/ … … 194 194 send_request(struct dhcpc_state *s) 195 195 { 196 u 8_t *end;196 uint8_t *end; 197 197 struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata; 198 198 … … 204 204 end = add_end(end); 205 205 206 uip_send(uip_appdata, end - (u 8_t *)uip_appdata);207 } 208 /*---------------------------------------------------------------------------*/ 209 static u 8_t210 parse_options(struct dhcpc_state *s, u 8_t *optptr, int len)211 { 212 u 8_t *end = optptr + len;213 u 8_t type = 0;206 uip_send(uip_appdata, end - (uint8_t *)uip_appdata); 207 } 208 /*---------------------------------------------------------------------------*/ 209 static uint8_t 210 parse_options(struct dhcpc_state *s, uint8_t *optptr, int len) 211 { 212 uint8_t *end = optptr + len; 213 uint8_t type = 0; 214 214 215 215 while(optptr < end) { … … 242 242 } 243 243 /*---------------------------------------------------------------------------*/ 244 static u 8_t244 static uint8_t 245 245 parse_msg(struct dhcpc_state *s) 246 246 { … … 386 386 dhcpc_request(struct dhcpc_state *s) 387 387 { 388 u 16_t ipaddr[2];388 uint16_t ipaddr[2]; 389 389 390 390 s->state = STATE_REQUEST;
Note:
See TracChangeset
for help on using the changeset viewer.