aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/httpd.c7
-rw-r--r--networking/ip.c2
-rw-r--r--networking/libiproute/iprule.c32
-rw-r--r--networking/netstat.c28
-rw-r--r--networking/nslookup.c5
-rw-r--r--networking/ntpd.c9
-rw-r--r--networking/ping.c4
-rw-r--r--networking/traceroute.c2
-rw-r--r--networking/udhcp/common.c10
-rw-r--r--networking/udhcp/common.h6
-rw-r--r--networking/udhcp/d6_dhcpc.c2
-rw-r--r--networking/udhcp/d6_packet.c2
-rw-r--r--networking/udhcp/dhcpc.c4
-rw-r--r--networking/udhcp/packet.c4
14 files changed, 77 insertions, 40 deletions
diff --git a/networking/httpd.c b/networking/httpd.c
index 7684ca4e7..daa3ca1d0 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1038,6 +1038,12 @@ static char *encodeString(const char *string)
1038 */ 1038 */
1039static void decodeBase64(char *Data) 1039static void decodeBase64(char *Data)
1040{ 1040{
1041# if ENABLE_BASE64 || ENABLE_UUDECODE
1042 /* Call decode_base64() from uuencode.c */
1043 char *eptr = Data;
1044 decode_base64(&eptr, Data);
1045 *eptr = '\0';
1046# else
1041 const unsigned char *in = (const unsigned char *)Data; 1047 const unsigned char *in = (const unsigned char *)Data;
1042 /* The decoded size will be at most 3/4 the size of the encoded */ 1048 /* The decoded size will be at most 3/4 the size of the encoded */
1043 unsigned ch = 0; 1049 unsigned ch = 0;
@@ -1071,6 +1077,7 @@ static void decodeBase64(char *Data)
1071 } 1077 }
1072 } 1078 }
1073 *Data = '\0'; 1079 *Data = '\0';
1080# endif
1074} 1081}
1075#endif 1082#endif
1076 1083
diff --git a/networking/ip.c b/networking/ip.c
index 7d3faf7f8..33bea5f49 100644
--- a/networking/ip.c
+++ b/networking/ip.c
@@ -252,7 +252,7 @@
252//usage:#define iprule_trivial_usage 252//usage:#define iprule_trivial_usage
253//usage: "[list] | add|del SELECTOR ACTION" 253//usage: "[list] | add|del SELECTOR ACTION"
254//usage:#define iprule_full_usage "\n\n" 254//usage:#define iprule_full_usage "\n\n"
255//usage: " SELECTOR := [from PREFIX] [to PREFIX] [tos TOS] [fwmark FWMARK]\n" 255//usage: " SELECTOR := [from PREFIX] [to PREFIX] [tos TOS] [fwmark FWMARK[/MASK]]\n"
256//usage: " [dev IFACE] [pref NUMBER]\n" 256//usage: " [dev IFACE] [pref NUMBER]\n"
257//usage: " ACTION := [table TABLE_ID] [nat ADDR]\n" 257//usage: " ACTION := [table TABLE_ID] [nat ADDR]\n"
258//usage: " [prohibit|reject|unreachable]\n" 258//usage: " [prohibit|reject|unreachable]\n"
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c
index 0ce0dfeef..50acfe4e7 100644
--- a/networking/libiproute/iprule.c
+++ b/networking/libiproute/iprule.c
@@ -17,8 +17,10 @@
17#include <arpa/inet.h> 17#include <arpa/inet.h>
18 18
19/* from <linux/fib_rules.h>: */ 19/* from <linux/fib_rules.h>: */
20#define FRA_SUPPRESS_IFGROUP 13 20#define FRA_FWMARK 10
21#define FRA_SUPPRESS_PREFIXLEN 14 21#define FRA_SUPPRESS_IFGROUP 13
22#define FRA_SUPPRESS_PREFIXLEN 14
23#define FRA_FWMASK 16
22 24
23#include "ip_common.h" /* #include "libbb.h" is inside */ 25#include "ip_common.h" /* #include "libbb.h" is inside */
24#include "rt_names.h" 26#include "rt_names.h"
@@ -117,8 +119,18 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM,
117 if (r->rtm_tos) { 119 if (r->rtm_tos) {
118 printf("tos %s ", rtnl_dsfield_n2a(r->rtm_tos)); 120 printf("tos %s ", rtnl_dsfield_n2a(r->rtm_tos));
119 } 121 }
120 if (tb[RTA_PROTOINFO]) { 122
121 printf("fwmark %#x ", *(uint32_t*)RTA_DATA(tb[RTA_PROTOINFO])); 123 if (tb[FRA_FWMARK] || tb[FRA_FWMASK]) {
124 uint32_t mark = 0, mask = 0;
125
126 if (tb[FRA_FWMARK])
127 mark = *(uint32_t*)RTA_DATA(tb[FRA_FWMARK]);
128 if (tb[FRA_FWMASK]
129 && (mask = *(uint32_t*)RTA_DATA(tb[FRA_FWMASK])) != 0xFFFFFFFF
130 )
131 printf("fwmark %#x/%#x ", mark, mask);
132 else
133 printf("fwmark %#x ", mark);
122 } 134 }
123 135
124 if (tb[RTA_IIF]) { 136 if (tb[RTA_IIF]) {
@@ -257,10 +269,18 @@ static int iprule_modify(int cmd, char **argv)
257 invarg_1_to_2(*argv, "TOS"); 269 invarg_1_to_2(*argv, "TOS");
258 req.r.rtm_tos = tos; 270 req.r.rtm_tos = tos;
259 } else if (key == ARG_fwmark) { 271 } else if (key == ARG_fwmark) {
260 uint32_t fwmark; 272 char *slash;
273 uint32_t fwmark, fwmask;
261 NEXT_ARG(); 274 NEXT_ARG();
275 slash = strchr(*argv, '/');
276 if (slash)
277 *slash = '\0';
262 fwmark = get_u32(*argv, keyword_fwmark); 278 fwmark = get_u32(*argv, keyword_fwmark);
263 addattr32(&req.n, sizeof(req), RTA_PROTOINFO, fwmark); 279 addattr32(&req.n, sizeof(req), FRA_FWMARK, fwmark);
280 if (slash) {
281 fwmask = get_u32(slash + 1, "fwmask");
282 addattr32(&req.n, sizeof(req), FRA_FWMASK, fwmask);
283 }
264 } else if (key == ARG_realms) { 284 } else if (key == ARG_realms) {
265 uint32_t realm; 285 uint32_t realm;
266 NEXT_ARG(); 286 NEXT_ARG();
diff --git a/networking/netstat.c b/networking/netstat.c
index 936610f89..3ab7b0d21 100644
--- a/networking/netstat.c
+++ b/networking/netstat.c
@@ -272,10 +272,9 @@ static long extract_socket_inode(const char *lname)
272 return inode; 272 return inode;
273} 273}
274 274
275static int FAST_FUNC add_to_prg_cache_if_socket(const char *fileName, 275static int FAST_FUNC add_to_prg_cache_if_socket(struct recursive_state *state,
276 struct stat *statbuf UNUSED_PARAM, 276 const char *fileName,
277 void *pid_slash_progname, 277 struct stat *statbuf UNUSED_PARAM)
278 int depth UNUSED_PARAM)
279{ 278{
280 char *linkname; 279 char *linkname;
281 long inode; 280 long inode;
@@ -284,16 +283,17 @@ static int FAST_FUNC add_to_prg_cache_if_socket(const char *fileName,
284 if (linkname != NULL) { 283 if (linkname != NULL) {
285 inode = extract_socket_inode(linkname); 284 inode = extract_socket_inode(linkname);
286 free(linkname); 285 free(linkname);
287 if (inode >= 0) 286 if (inode >= 0) {
288 prg_cache_add(inode, (char *)pid_slash_progname); 287 char *pid_slash_progname = state->userData;
288 prg_cache_add(inode, pid_slash_progname);
289 }
289 } 290 }
290 return TRUE; 291 return TRUE;
291} 292}
292 293
293static int FAST_FUNC dir_act(const char *fileName, 294static int FAST_FUNC dir_act(struct recursive_state *state,
294 struct stat *statbuf UNUSED_PARAM, 295 const char *fileName,
295 void *userData UNUSED_PARAM, 296 struct stat *statbuf UNUSED_PARAM)
296 int depth)
297{ 297{
298 const char *pid; 298 const char *pid;
299 char *pid_slash_progname; 299 char *pid_slash_progname;
@@ -301,7 +301,7 @@ static int FAST_FUNC dir_act(const char *fileName,
301 char cmdline_buf[512]; 301 char cmdline_buf[512];
302 int n, len; 302 int n, len;
303 303
304 if (depth == 0) /* "/proc" itself */ 304 if (state->depth == 0) /* "/proc" itself */
305 return TRUE; /* continue looking one level below /proc */ 305 return TRUE; /* continue looking one level below /proc */
306 306
307 pid = fileName + sizeof("/proc/")-1; /* point after "/proc/" */ 307 pid = fileName + sizeof("/proc/")-1; /* point after "/proc/" */
@@ -321,8 +321,8 @@ static int FAST_FUNC dir_act(const char *fileName,
321 ACTION_RECURSE | ACTION_QUIET, 321 ACTION_RECURSE | ACTION_QUIET,
322 add_to_prg_cache_if_socket, 322 add_to_prg_cache_if_socket,
323 NULL, 323 NULL,
324 (void *)pid_slash_progname, 324 (void *)pid_slash_progname
325 0); 325 );
326 free(pid_slash_progname); 326 free(pid_slash_progname);
327 327
328 if (!n) 328 if (!n)
@@ -337,7 +337,7 @@ static void prg_cache_load(void)
337 337
338 prg_cache_loaded = 1; 338 prg_cache_loaded = 1;
339 load_ok = recursive_action("/proc", ACTION_RECURSE | ACTION_QUIET, 339 load_ok = recursive_action("/proc", ACTION_RECURSE | ACTION_QUIET,
340 NULL, dir_act, NULL, 0); 340 NULL, dir_act, NULL);
341 if (load_ok) 341 if (load_ok)
342 return; 342 return;
343 343
diff --git a/networking/nslookup.c b/networking/nslookup.c
index c43e60558..759de5c83 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -703,12 +703,13 @@ static void parse_resolvconf(void)
703 703
704 while (fgets(line, sizeof(line), resolv)) { 704 while (fgets(line, sizeof(line), resolv)) {
705 char *p, *arg; 705 char *p, *arg;
706 char *tokstate;
706 707
707 p = strtok(line, " \t\n"); 708 p = strtok_r(line, " \t\n", &tokstate);
708 if (!p) 709 if (!p)
709 continue; 710 continue;
710 dbg("resolv_key:'%s'\n", p); 711 dbg("resolv_key:'%s'\n", p);
711 arg = strtok(NULL, "\n"); 712 arg = strtok_r(NULL, "\n", &tokstate);
712 dbg("resolv_arg:'%s'\n", arg); 713 dbg("resolv_arg:'%s'\n", arg);
713 if (!arg) 714 if (!arg)
714 continue; 715 continue;
diff --git a/networking/ntpd.c b/networking/ntpd.c
index d721fe80c..44e711232 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2025,6 +2025,15 @@ recv_and_process_peer_pkt(peer_t *p)
2025 2025
2026 offset = 0; 2026 offset = 0;
2027 2027
2028 /* The below can happen as follows:
2029 * = we receive two peer rsponses at once.
2030 * = recv_and_process_peer_pkt(PEER1) -> update_local_clock()
2031 * -> step_time() and it closes all other fds, sets all ->fd to -1.
2032 * = recv_and_process_peer_pkt(PEER2) sees PEER2->fd == -1
2033 */
2034 if (p->p_fd < 0)
2035 return;
2036
2028 /* We can recvfrom here and check from.IP, but some multihomed 2037 /* We can recvfrom here and check from.IP, but some multihomed
2029 * ntp servers reply from their *other IP*. 2038 * ntp servers reply from their *other IP*.
2030 * TODO: maybe we should check at least what we can: from.port == 123? 2039 * TODO: maybe we should check at least what we can: from.port == 123?
diff --git a/networking/ping.c b/networking/ping.c
index 47b6ab1b2..5f7e5b9b5 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -217,7 +217,7 @@ static void ping4(len_and_sockaddr *lsa)
217 /*memset(pkt, 0, sizeof(G.packet)); already is */ 217 /*memset(pkt, 0, sizeof(G.packet)); already is */
218 pkt->icmp_type = ICMP_ECHO; 218 pkt->icmp_type = ICMP_ECHO;
219 pkt->icmp_id = G.myid; 219 pkt->icmp_id = G.myid;
220 pkt->icmp_cksum = inet_cksum((uint16_t *) pkt, sizeof(G.packet)); 220 pkt->icmp_cksum = inet_cksum(pkt, sizeof(G.packet));
221 221
222 xsendto(pingsock, G.packet, DEFDATALEN + ICMP_MINLEN, &lsa->u.sa, lsa->len); 222 xsendto(pingsock, G.packet, DEFDATALEN + ICMP_MINLEN, &lsa->u.sa, lsa->len);
223 223
@@ -529,7 +529,7 @@ static void sendping4(int junk UNUSED_PARAM)
529 /* No hton: we'll read it back on the same machine */ 529 /* No hton: we'll read it back on the same machine */
530 *(uint32_t*)&pkt->icmp_dun = G.cur_us = monotonic_us(); 530 *(uint32_t*)&pkt->icmp_dun = G.cur_us = monotonic_us();
531 531
532 pkt->icmp_cksum = inet_cksum((uint16_t *) pkt, datalen + ICMP_MINLEN); 532 pkt->icmp_cksum = inet_cksum(pkt, datalen + ICMP_MINLEN);
533 533
534 sendping_tail(sendping4, ICMP_MINLEN); 534 sendping_tail(sendping4, ICMP_MINLEN);
535} 535}
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 5068f654b..1c4dc3e4a 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -468,7 +468,7 @@ send_probe(int seq, int ttl)
468 /* Always calculate checksum for icmp packets */ 468 /* Always calculate checksum for icmp packets */
469 outicmp->icmp_cksum = 0; 469 outicmp->icmp_cksum = 0;
470 outicmp->icmp_cksum = inet_cksum( 470 outicmp->icmp_cksum = inet_cksum(
471 (uint16_t *)outicmp, 471 outicmp,
472 ((char*)outip + packlen) - (char*)outicmp 472 ((char*)outip + packlen) - (char*)outicmp
473 ); 473 );
474 if (outicmp->icmp_cksum == 0) 474 if (outicmp->icmp_cksum == 0)
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index 20d843bab..4bc719001 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -526,7 +526,7 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg,
526 526
527 /* Cheat, the only *const* str possible is "" */ 527 /* Cheat, the only *const* str possible is "" */
528 str = (char *) const_str; 528 str = (char *) const_str;
529 opt = strtok(str, " \t=:"); 529 opt = strtok_r(str, " \t=:", &str);
530 if (!opt) 530 if (!opt)
531 return 0; 531 return 0;
532 532
@@ -550,10 +550,10 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg,
550 char *val; 550 char *val;
551 551
552 if (optflag->flags == OPTION_BIN) { 552 if (optflag->flags == OPTION_BIN) {
553 val = strtok(NULL, ""); /* do not split "'q w e'" */ 553 val = strtok_r(NULL, "", &str); /* do not split "'q w e'" */
554 if (val) trim(val); 554 if (val) trim(val);
555 } else 555 } else
556 val = strtok(NULL, ", \t"); 556 val = strtok_r(NULL, ", \t", &str);
557 if (!val) 557 if (!val)
558 break; 558 break;
559 559
@@ -567,7 +567,7 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg,
567 break; 567 break;
568 case OPTION_IP_PAIR: 568 case OPTION_IP_PAIR:
569 retval = udhcp_str2nip(val, buffer); 569 retval = udhcp_str2nip(val, buffer);
570 val = strtok(NULL, ", \t/-"); 570 val = strtok_r(NULL, ", \t/-", &str);
571 if (!val) 571 if (!val)
572 retval = 0; 572 retval = 0;
573 if (retval) 573 if (retval)
@@ -631,7 +631,7 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg,
631 *slash = '\0'; 631 *slash = '\0';
632 retval = udhcp_str2nip(val, buffer + 1); 632 retval = udhcp_str2nip(val, buffer + 1);
633 buffer[0] = mask = bb_strtou(slash + 1, NULL, 10); 633 buffer[0] = mask = bb_strtou(slash + 1, NULL, 10);
634 val = strtok(NULL, ", \t/-"); 634 val = strtok_r(NULL, ", \t/-", &str);
635 if (!val || mask > 32 || errno) 635 if (!val || mask > 32 || errno)
636 retval = 0; 636 retval = 0;
637 if (retval) { 637 if (retval) {
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index 81c1dcbdc..3cbd2d3c8 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -46,7 +46,7 @@ struct dhcp_packet {
46 uint8_t file[128]; /* boot file name (ASCIZ) */ 46 uint8_t file[128]; /* boot file name (ASCIZ) */
47 uint32_t cookie; /* fixed first four option bytes (99,130,83,99 dec) */ 47 uint32_t cookie; /* fixed first four option bytes (99,130,83,99 dec) */
48 uint8_t options[DHCP_OPTIONS_BUFSIZE + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS]; 48 uint8_t options[DHCP_OPTIONS_BUFSIZE + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS];
49} PACKED; 49};
50#define DHCP_PKT_SNAME_LEN 64 50#define DHCP_PKT_SNAME_LEN 64
51#define DHCP_PKT_FILE_LEN 128 51#define DHCP_PKT_FILE_LEN 128
52#define DHCP_PKT_SNAME_LEN_STR "64" 52#define DHCP_PKT_SNAME_LEN_STR "64"
@@ -56,12 +56,12 @@ struct ip_udp_dhcp_packet {
56 struct iphdr ip; 56 struct iphdr ip;
57 struct udphdr udp; 57 struct udphdr udp;
58 struct dhcp_packet data; 58 struct dhcp_packet data;
59} PACKED; 59};
60 60
61struct udp_dhcp_packet { 61struct udp_dhcp_packet {
62 struct udphdr udp; 62 struct udphdr udp;
63 struct dhcp_packet data; 63 struct dhcp_packet data;
64} PACKED; 64};
65 65
66enum { 66enum {
67 IP_UDP_DHCP_SIZE = sizeof(struct ip_udp_dhcp_packet) - CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS, 67 IP_UDP_DHCP_SIZE = sizeof(struct ip_udp_dhcp_packet) - CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS,
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index fc2d672b7..ac8af91d3 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -947,7 +947,7 @@ static NOINLINE int d6_recv_raw_packet(struct in6_addr *peer_ipv6, struct d6_pac
947// packet.ip.tot_len = packet.udp.len; /* yes, this is needed */ 947// packet.ip.tot_len = packet.udp.len; /* yes, this is needed */
948// check = packet.udp.check; 948// check = packet.udp.check;
949// packet.udp.check = 0; 949// packet.udp.check = 0;
950// if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { 950// if (check && check != inet_cksum(&packet, bytes)) {
951// log1("packet with bad UDP checksum received, ignoring"); 951// log1("packet with bad UDP checksum received, ignoring");
952// return -2; 952// return -2;
953// } 953// }
diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c
index 446497e15..167a813e3 100644
--- a/networking/udhcp/d6_packet.c
+++ b/networking/udhcp/d6_packet.c
@@ -103,7 +103,7 @@ int FAST_FUNC d6_send_raw_packet(
103 */ 103 */
104 packet.ip6.ip6_hlim = IPPROTO_UDP; 104 packet.ip6.ip6_hlim = IPPROTO_UDP;
105 packet.udp.check = inet_cksum( 105 packet.udp.check = inet_cksum(
106 (uint16_t *)&packet + 2, 106 (uint8_t *)&packet + 4,
107 offsetof(struct ip6_udp_d6_packet, data) - 4 + d6_pkt_size 107 offsetof(struct ip6_udp_d6_packet, data) - 4 + d6_pkt_size
108 ); 108 );
109 /* fix 'hop limit' and 'next header' after UDP checksumming */ 109 /* fix 'hop limit' and 'next header' after UDP checksumming */
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index e13eb3f9f..66aa38c20 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -935,7 +935,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
935 /* verify IP checksum */ 935 /* verify IP checksum */
936 check = packet.ip.check; 936 check = packet.ip.check;
937 packet.ip.check = 0; 937 packet.ip.check = 0;
938 if (check != inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip))) { 938 if (check != inet_cksum(&packet.ip, sizeof(packet.ip))) {
939 log1s("bad IP header checksum, ignoring"); 939 log1s("bad IP header checksum, ignoring");
940 return -2; 940 return -2;
941 } 941 }
@@ -960,7 +960,7 @@ static NOINLINE int udhcp_recv_raw_packet(struct dhcp_packet *dhcp_pkt, int fd)
960 packet.ip.tot_len = packet.udp.len; /* yes, this is needed */ 960 packet.ip.tot_len = packet.udp.len; /* yes, this is needed */
961 check = packet.udp.check; 961 check = packet.udp.check;
962 packet.udp.check = 0; 962 packet.udp.check = 0;
963 if (check && check != inet_cksum((uint16_t *)&packet, bytes)) { 963 if (check && check != inet_cksum(&packet, bytes)) {
964 log1s("packet with bad UDP checksum received, ignoring"); 964 log1s("packet with bad UDP checksum received, ignoring");
965 return -2; 965 return -2;
966 } 966 }
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index 6d4375237..51374646d 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -164,14 +164,14 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt,
164 packet.udp.len = htons(UDP_DHCP_SIZE - padding); 164 packet.udp.len = htons(UDP_DHCP_SIZE - padding);
165 /* for UDP checksumming, ip.len is set to UDP packet len */ 165 /* for UDP checksumming, ip.len is set to UDP packet len */
166 packet.ip.tot_len = packet.udp.len; 166 packet.ip.tot_len = packet.udp.len;
167 packet.udp.check = inet_cksum((uint16_t *)&packet, 167 packet.udp.check = inet_cksum(&packet,
168 IP_UDP_DHCP_SIZE - padding); 168 IP_UDP_DHCP_SIZE - padding);
169 /* but for sending, it is set to IP packet len */ 169 /* but for sending, it is set to IP packet len */
170 packet.ip.tot_len = htons(IP_UDP_DHCP_SIZE - padding); 170 packet.ip.tot_len = htons(IP_UDP_DHCP_SIZE - padding);
171 packet.ip.ihl = sizeof(packet.ip) >> 2; 171 packet.ip.ihl = sizeof(packet.ip) >> 2;
172 packet.ip.version = IPVERSION; 172 packet.ip.version = IPVERSION;
173 packet.ip.ttl = IPDEFTTL; 173 packet.ip.ttl = IPDEFTTL;
174 packet.ip.check = inet_cksum((uint16_t *)&packet.ip, sizeof(packet.ip)); 174 packet.ip.check = inet_cksum(&packet.ip, sizeof(packet.ip));
175 175
176 udhcp_dump_packet(dhcp_pkt); 176 udhcp_dump_packet(dhcp_pkt);
177 result = sendto(fd, &packet, IP_UDP_DHCP_SIZE - padding, /*flags:*/ 0, 177 result = sendto(fd, &packet, IP_UDP_DHCP_SIZE - padding, /*flags:*/ 0,