diff options
Diffstat (limited to 'src/nat/gnunet-helper-nat-server.c')
-rw-r--r-- | src/nat/gnunet-helper-nat-server.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/nat/gnunet-helper-nat-server.c b/src/nat/gnunet-helper-nat-server.c index ef8e97482..f35649152 100644 --- a/src/nat/gnunet-helper-nat-server.c +++ b/src/nat/gnunet-helper-nat-server.c | |||
@@ -266,9 +266,9 @@ send_icmp_echo (const struct in_addr *my_ip) | |||
266 | ip_pkt.checksum = | 266 | ip_pkt.checksum = |
267 | htons (calc_checksum ((uint16_t *) & ip_pkt, | 267 | htons (calc_checksum ((uint16_t *) & ip_pkt, |
268 | sizeof (struct ip_header))); | 268 | sizeof (struct ip_header))); |
269 | memcpy (&packet[off], | 269 | GNUNET_memcpy (&packet[off], |
270 | &ip_pkt, | 270 | &ip_pkt, |
271 | sizeof (struct ip_header)); | 271 | sizeof (struct ip_header)); |
272 | off += sizeof (struct ip_header); | 272 | off += sizeof (struct ip_header); |
273 | 273 | ||
274 | icmp_echo.type = ICMP_ECHO; | 274 | icmp_echo.type = ICMP_ECHO; |
@@ -279,9 +279,9 @@ send_icmp_echo (const struct in_addr *my_ip) | |||
279 | htons (calc_checksum | 279 | htons (calc_checksum |
280 | ((uint16_t *) & icmp_echo, | 280 | ((uint16_t *) & icmp_echo, |
281 | sizeof (struct icmp_echo_header))); | 281 | sizeof (struct icmp_echo_header))); |
282 | memcpy (&packet[off], | 282 | GNUNET_memcpy (&packet[off], |
283 | &icmp_echo, | 283 | &icmp_echo, |
284 | sizeof (struct icmp_echo_header)); | 284 | sizeof (struct icmp_echo_header)); |
285 | off += sizeof (struct icmp_echo_header); | 285 | off += sizeof (struct icmp_echo_header); |
286 | 286 | ||
287 | memset (&dst, 0, sizeof (dst)); | 287 | memset (&dst, 0, sizeof (dst)); |
@@ -388,9 +388,13 @@ process_icmp_response () | |||
388 | return; | 388 | return; |
389 | } | 389 | } |
390 | off = 0; | 390 | off = 0; |
391 | memcpy (&ip_pkt, &buf[off], sizeof (struct ip_header)); | 391 | GNUNET_memcpy (&ip_pkt, |
392 | &buf[off], | ||
393 | sizeof (struct ip_header)); | ||
392 | off += sizeof (struct ip_header); | 394 | off += sizeof (struct ip_header); |
393 | memcpy (&icmp_ttl, &buf[off], sizeof (struct icmp_ttl_exceeded_header)); | 395 | GNUNET_memcpy (&icmp_ttl, |
396 | &buf[off], | ||
397 | sizeof (struct icmp_ttl_exceeded_header)); | ||
394 | off += sizeof (struct icmp_ttl_exceeded_header); | 398 | off += sizeof (struct icmp_ttl_exceeded_header); |
395 | if ((ICMP_TIME_EXCEEDED != icmp_ttl.type) || (0 != icmp_ttl.code)) | 399 | if ((ICMP_TIME_EXCEEDED != icmp_ttl.type) || (0 != icmp_ttl.code)) |
396 | { | 400 | { |
@@ -401,7 +405,9 @@ process_icmp_response () | |||
401 | source_ip.s_addr = ip_pkt.src_ip; | 405 | source_ip.s_addr = ip_pkt.src_ip; |
402 | 406 | ||
403 | /* skip 2nd IP header */ | 407 | /* skip 2nd IP header */ |
404 | memcpy (&ip_pkt, &buf[off], sizeof (struct ip_header)); | 408 | GNUNET_memcpy (&ip_pkt, |
409 | &buf[off], | ||
410 | sizeof (struct ip_header)); | ||
405 | off += sizeof (struct ip_header); | 411 | off += sizeof (struct ip_header); |
406 | 412 | ||
407 | switch (ip_pkt.proto) | 413 | switch (ip_pkt.proto) |
@@ -416,7 +422,9 @@ process_icmp_response () | |||
416 | return; | 422 | return; |
417 | } | 423 | } |
418 | /* grab ICMP ECHO content */ | 424 | /* grab ICMP ECHO content */ |
419 | memcpy (&icmp_echo, &buf[off], sizeof (struct icmp_echo_header)); | 425 | GNUNET_memcpy (&icmp_echo, |
426 | &buf[off], | ||
427 | sizeof (struct icmp_echo_header)); | ||
420 | port = (uint16_t) ntohl (icmp_echo.reserved); | 428 | port = (uint16_t) ntohl (icmp_echo.reserved); |
421 | break; | 429 | break; |
422 | case IPPROTO_UDP: | 430 | case IPPROTO_UDP: |
@@ -428,7 +436,9 @@ process_icmp_response () | |||
428 | return; | 436 | return; |
429 | } | 437 | } |
430 | /* grab UDP content */ | 438 | /* grab UDP content */ |
431 | memcpy (&udp_pkt, &buf[off], sizeof (struct udp_header)); | 439 | GNUNET_memcpy (&udp_pkt, |
440 | &buf[off], | ||
441 | sizeof (struct udp_header)); | ||
432 | port = ntohs (udp_pkt.length); | 442 | port = ntohs (udp_pkt.length); |
433 | break; | 443 | break; |
434 | default: | 444 | default: |