Lines Matching +full:0 +full:- +full:576

8  * SPDX-License-Identifier: Apache-2.0
41 return -ENOBUFS; in net_icmpv4_create()
44 icmp_hdr->type = icmp_type; in net_icmpv4_create()
45 icmp_hdr->code = icmp_code; in net_icmpv4_create()
46 icmp_hdr->chksum = 0U; in net_icmpv4_create()
59 return -ENOBUFS; in net_icmpv4_finalize()
65 return -ENOBUFS; in net_icmpv4_finalize()
68 icmp_hdr->chksum = 0U; in net_icmpv4_finalize()
71 icmp_hdr->chksum = net_calc_chksum_icmpv4(pkt); in net_icmpv4_finalize()
91 uint8_t offset = 0U; in icmpv4_update_record_route()
135 return 0; in icmpv4_update_record_route()
153 skip = ptr - ptr_offset; in icmpv4_update_record_route()
172 if (net_pkt_write(reply, opt_data + offset, opt_len - offset)) { in icmpv4_update_record_route()
177 len += opt_len - offset; in icmpv4_update_record_route()
181 return 0; in icmpv4_update_record_route()
184 return -EINVAL; in icmpv4_update_record_route()
188 * Internet Timestamp. Timestamp value : 32-bit timestamp
199 uint8_t offset = 0U; in icmpv4_update_time_stamp()
227 flag = flag & 0x0F; in icmpv4_update_time_stamp()
228 overflow = (flag & 0xF0) >> 4U; in icmpv4_update_time_stamp()
239 if (overflow == 0x0F) { in icmpv4_update_time_stamp()
267 return 0; in icmpv4_update_time_stamp()
295 skip = ptr - ptr_offset; in icmpv4_update_time_stamp()
336 if (net_pkt_write(reply, opt_data + offset, opt_len - offset)) { in icmpv4_update_time_stamp()
341 len += opt_len - offset; in icmpv4_update_time_stamp()
345 return 0; in icmpv4_update_time_stamp()
348 return -EINVAL; in icmpv4_update_time_stamp()
361 ud->reply, ud->src); in icmpv4_reply_to_options()
364 ud->reply, ud->src); in icmpv4_reply_to_options()
367 return 0; in icmpv4_reply_to_options()
381 return -EINVAL; in icmpv4_handle_header_options()
387 if (len % 4U != 0U) { in icmpv4_handle_header_options()
388 uint8_t i = 4U - (len % 4U); in icmpv4_handle_header_options()
391 return -EINVAL; in icmpv4_handle_header_options()
400 return 0; in icmpv4_handle_header_options()
411 return 0; in icmpv4_handle_header_options()
422 struct net_ipv4_hdr *ip_hdr = hdr->ipv4; in icmpv4_handle_echo_request()
429 if (net_ipv4_is_addr_unspecified((struct in_addr *)ip_hdr->src)) { in icmpv4_handle_echo_request()
435 net_sprint_ipv4_addr(&ip_hdr->src), in icmpv4_handle_echo_request()
436 net_sprint_ipv4_addr(&ip_hdr->dst)); in icmpv4_handle_echo_request()
438 payload_len = net_pkt_get_len(pkt) - in icmpv4_handle_echo_request()
439 net_pkt_ip_hdr_len(pkt) - in icmpv4_handle_echo_request()
440 net_pkt_ipv4_opts_len(pkt) - NET_ICMPH_LEN; in icmpv4_handle_echo_request()
456 if (net_ipv4_is_addr_mcast((struct in_addr *)ip_hdr->dst) || in icmpv4_handle_echo_request()
458 (struct in_addr *)ip_hdr->dst)) { in icmpv4_handle_echo_request()
460 (struct in_addr *)ip_hdr->src); in icmpv4_handle_echo_request()
467 src = (struct in_addr *)ip_hdr->dst; in icmpv4_handle_echo_request()
473 if (net_ipv4_create(reply, src, (struct in_addr *)ip_hdr->src)) { in icmpv4_handle_echo_request()
484 if (net_icmpv4_create(reply, NET_ICMPV4_ECHO_REPLY, 0) || in icmpv4_handle_echo_request()
494 net_sprint_ipv4_addr(&ip_hdr->src)); in icmpv4_handle_echo_request()
496 if (net_send_data(reply) < 0) { in icmpv4_handle_echo_request()
502 return 0; in icmpv4_handle_echo_request()
510 return -EIO; in icmpv4_handle_echo_request()
516 int err = -EIO; in net_icmpv4_send_error()
528 if (ip_hdr->proto == IPPROTO_ICMP) { in net_icmpv4_send_error()
535 if (!icmp_hdr || icmp_hdr->code < 8) { in net_icmpv4_send_error()
537 err = -EINVAL; in net_icmpv4_send_error()
543 (struct in_addr *)ip_hdr->dst)) { in net_icmpv4_send_error()
548 net_sprint_ipv4_addr(&ip_hdr->src), in net_icmpv4_send_error()
549 net_proto2str(AF_INET, ip_hdr->proto)); in net_icmpv4_send_error()
553 if (ip_hdr->proto == IPPROTO_UDP) { in net_icmpv4_send_error()
556 } else if (ip_hdr->proto == IPPROTO_TCP) { in net_icmpv4_send_error()
560 copy_len = 0; in net_icmpv4_send_error()
568 err = -ENOMEM; in net_icmpv4_send_error()
572 if (net_ipv4_create(pkt, (struct in_addr *)ip_hdr->dst, in net_icmpv4_send_error()
573 (struct in_addr *)ip_hdr->src) || in net_icmpv4_send_error()
575 net_pkt_memset(pkt, 0, NET_ICMPV4_UNUSED_LEN) || in net_icmpv4_send_error()
583 net_pkt_lladdr_dst(pkt)->addr = net_pkt_lladdr_src(orig)->addr; in net_icmpv4_send_error()
584 net_pkt_lladdr_dst(pkt)->len = net_pkt_lladdr_src(orig)->len; in net_icmpv4_send_error()
588 net_sprint_ipv4_addr(&ip_hdr->dst), in net_icmpv4_send_error()
589 net_sprint_ipv4_addr(&ip_hdr->src)); in net_icmpv4_send_error()
591 if (net_send_data(pkt) >= 0) { in net_icmpv4_send_error()
593 return 0; in net_icmpv4_send_error()
622 if (net_calc_chksum_icmpv4(pkt) != 0U) { in net_icmpv4_input()
629 (struct in_addr *)ip_hdr->dst) && in net_icmpv4_input()
631 icmp_hdr->type != NET_ICMPV4_ECHO_REQUEST)) { in net_icmpv4_input()
639 icmp_hdr->type, icmp_hdr->code); in net_icmpv4_input()
644 if (ret < 0 && ret != -ENOENT) { in net_icmpv4_input()
660 * This is way too small in modern world, so make the minimum 576 octets.
673 struct net_ipv4_hdr *ip_hdr = hdr->ipv4; in icmpv4_handle_dst_unreach()
694 net_sprint_ipv4_addr(&ip_hdr->src), in icmpv4_handle_dst_unreach()
695 net_sprint_ipv4_addr(&ip_hdr->dst)); in icmpv4_handle_dst_unreach()
709 mtu = ntohs(dest_unreach_hdr->mtu); in icmpv4_handle_dst_unreach()
717 net_ipaddr_copy(&sockaddr_src.sin_addr, (struct in_addr *)&ip_hdr->src); in icmpv4_handle_dst_unreach()
722 net_sprint_ipv4_addr(&ip_hdr->src)); in icmpv4_handle_dst_unreach()
729 if (entry->mtu > 0 && entry->mtu < mtu) { in icmpv4_handle_dst_unreach()
731 net_sprint_ipv4_addr(&ip_hdr->src), mtu, in icmpv4_handle_dst_unreach()
732 entry->mtu); in icmpv4_handle_dst_unreach()
737 if (ret > 0) { in icmpv4_handle_dst_unreach()
739 net_sprint_ipv4_addr(&ip_hdr->src), ret, mtu); in icmpv4_handle_dst_unreach()
742 return 0; in icmpv4_handle_dst_unreach()
746 return -EIO; in icmpv4_handle_dst_unreach()
750 * return 0 so that icmpv4 module will not complain about it. in icmpv4_handle_dst_unreach()
754 return 0; in icmpv4_handle_dst_unreach()
765 ret = net_icmp_init_ctx(&ctx, NET_ICMPV4_ECHO_REQUEST, 0, icmpv4_handle_echo_request); in net_icmpv4_init()
766 if (ret < 0) { in net_icmpv4_init()
772 ret = net_icmp_init_ctx(&dst_unreach_ctx, NET_ICMPV4_DST_UNREACH, 0, in net_icmpv4_init()
774 if (ret < 0) { in net_icmpv4_init()