Lines Matching refs:pkt
66 static inline enum net_verdict process_data(struct net_pkt *pkt, in process_data() argument
72 net_pkt_set_l2_processed(pkt, false); in process_data()
75 ret = net_packet_socket_input(pkt, ETH_P_ALL); in process_data()
83 if (net_pkt_is_ip_reassembled(pkt)) { in process_data()
88 if (!pkt->frags) { in process_data()
89 NET_DBG("Corrupted packet (frags %p)", pkt->frags); in process_data()
90 net_stats_update_processing_error(net_pkt_iface(pkt)); in process_data()
96 ret = net_if_recv_data(net_pkt_iface(pkt), pkt); in process_data()
99 NET_DBG("Packet %p discarded by L2", pkt); in process_data()
101 net_pkt_iface(pkt)); in process_data()
108 net_pkt_set_l2_processed(pkt, true); in process_data()
113 net_pkt_cursor_init(pkt); in process_data()
119 ret = net_packet_socket_input(pkt, ETH_P_ALL); in process_data()
125 uint8_t family = net_pkt_family(pkt); in process_data()
131 ret = net_packet_socket_input(pkt, IPPROTO_RAW); in process_data()
137 uint8_t vtc_vhl = NET_IPV6_HDR(pkt)->vtc & 0xf0; in process_data()
140 return net_ipv6_input(pkt, is_loopback); in process_data()
142 return net_ipv4_input(pkt, is_loopback); in process_data()
145 NET_DBG("Unknown IP family packet (0x%x)", NET_IPV6_HDR(pkt)->vtc & 0xf0); in process_data()
146 net_stats_update_ip_errors_protoerr(net_pkt_iface(pkt)); in process_data()
147 net_stats_update_ip_errors_vhlerr(net_pkt_iface(pkt)); in process_data()
150 return net_canbus_socket_input(pkt); in process_data()
157 static void processing_data(struct net_pkt *pkt, bool is_loopback) in processing_data() argument
160 switch (process_data(pkt, is_loopback)) { in processing_data()
168 NET_DBG("Dropping pkt %p", pkt); in processing_data()
169 net_pkt_unref(pkt); in processing_data()
173 NET_DBG("Consumed pkt %p", pkt); in processing_data()
177 NET_DBG("Dropping pkt %p", pkt); in processing_data()
178 net_pkt_unref(pkt); in processing_data()
194 static inline void copy_ll_addr(struct net_pkt *pkt) in copy_ll_addr() argument
196 memcpy(net_pkt_lladdr_src(pkt), net_pkt_lladdr_if(pkt), in copy_ll_addr()
198 memcpy(net_pkt_lladdr_dst(pkt), net_pkt_lladdr_if(pkt), in copy_ll_addr()
206 static inline int check_ip(struct net_pkt *pkt) in check_ip() argument
215 family = net_pkt_family(pkt); in check_ip()
220 if (NET_IPV6_HDR(pkt)->hop_limit == 0) { in check_ip()
234 if (net_if_l2(net_pkt_iface(pkt)) == &NET_L2_GET_NAME(DUMMY)) { in check_ip()
238 if (net_ipv6_addr_cmp((struct in6_addr *)NET_IPV6_HDR(pkt)->dst, in check_ip()
249 (struct in6_addr *)NET_IPV6_HDR(pkt)->dst) || in check_ip()
251 (struct in6_addr *)NET_IPV6_HDR(pkt)->dst)) && in check_ip()
252 !net_pkt_forwarding(pkt)) { in check_ip()
258 net_ipv6_addr_copy_raw((uint8_t *)&addr, NET_IPV6_HDR(pkt)->src); in check_ip()
259 net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->src, in check_ip()
260 NET_IPV6_HDR(pkt)->dst); in check_ip()
261 net_ipv6_addr_copy_raw(NET_IPV6_HDR(pkt)->dst, (uint8_t *)&addr); in check_ip()
263 net_pkt_set_ll_proto_type(pkt, ETH_P_IPV6); in check_ip()
264 copy_ll_addr(pkt); in check_ip()
276 (struct in6_addr *)NET_IPV6_HDR(pkt)->dst)) { in check_ip()
285 (struct in6_addr *)NET_IPV6_HDR(pkt)->src)) { in check_ip()
293 if (NET_IPV4_HDR(pkt)->ttl == 0) { in check_ip()
307 if (net_if_l2(net_pkt_iface(pkt)) == &NET_L2_GET_NAME(DUMMY)) { in check_ip()
311 if (net_ipv4_addr_cmp((struct in_addr *)NET_IPV4_HDR(pkt)->dst, in check_ip()
321 if (net_ipv4_is_addr_loopback((struct in_addr *)NET_IPV4_HDR(pkt)->dst) || in check_ip()
322 (net_ipv4_is_addr_bcast(net_pkt_iface(pkt), in check_ip()
323 (struct in_addr *)NET_IPV4_HDR(pkt)->dst) == false && in check_ip()
324 net_ipv4_is_my_addr((struct in_addr *)NET_IPV4_HDR(pkt)->dst))) { in check_ip()
330 net_ipv4_addr_copy_raw((uint8_t *)&addr, NET_IPV4_HDR(pkt)->src); in check_ip()
331 net_ipv4_addr_copy_raw(NET_IPV4_HDR(pkt)->src, in check_ip()
332 NET_IPV4_HDR(pkt)->dst); in check_ip()
333 net_ipv4_addr_copy_raw(NET_IPV4_HDR(pkt)->dst, (uint8_t *)&addr); in check_ip()
335 net_pkt_set_ll_proto_type(pkt, ETH_P_IP); in check_ip()
336 copy_ll_addr(pkt); in check_ip()
345 if (net_ipv4_is_addr_loopback((struct in_addr *)NET_IPV4_HDR(pkt)->src)) { in check_ip()
357 net_stats_update_ipv6_drop(net_pkt_iface(pkt)); in check_ip()
359 net_stats_update_ipv4_drop(net_pkt_iface(pkt)); in check_ip()
367 int net_send_data(struct net_pkt *pkt) in net_send_data() argument
372 SYS_PORT_TRACING_FUNC_ENTER(net, send_data, pkt); in net_send_data()
374 if (!pkt || !pkt->frags) { in net_send_data()
379 if (!net_pkt_iface(pkt)) { in net_send_data()
384 net_pkt_trim_buffer(pkt); in net_send_data()
385 net_pkt_cursor_init(pkt); in net_send_data()
387 status = check_ip(pkt); in net_send_data()
404 NET_DBG("Loopback pkt %p back to us", pkt); in net_send_data()
405 processing_data(pkt, true); in net_send_data()
410 if (net_if_send_data(net_pkt_iface(pkt), pkt) == NET_DROP) { in net_send_data()
416 switch (net_pkt_family(pkt)) { in net_send_data()
418 net_stats_update_ipv4_sent(net_pkt_iface(pkt)); in net_send_data()
421 net_stats_update_ipv6_sent(net_pkt_iface(pkt)); in net_send_data()
429 SYS_PORT_TRACING_FUNC_EXIT(net, send_data, pkt, ret); in net_send_data()
434 static void net_rx(struct net_if *iface, struct net_pkt *pkt) in net_rx() argument
439 pkt_len = net_pkt_get_len(pkt); in net_rx()
441 NET_DBG("Received pkt %p len %zu", pkt, pkt_len); in net_rx()
453 processing_data(pkt, is_loopback); in net_rx()
459 void net_process_rx_packet(struct net_pkt *pkt) in net_process_rx_packet() argument
461 net_pkt_set_rx_stats_tick(pkt, k_cycle_get_32()); in net_process_rx_packet()
463 net_capture_pkt(net_pkt_iface(pkt), pkt); in net_process_rx_packet()
465 net_rx(net_pkt_iface(pkt), pkt); in net_process_rx_packet()
468 static void net_queue_rx(struct net_if *iface, struct net_pkt *pkt) in net_queue_rx() argument
470 uint8_t prio = net_pkt_priority(pkt); in net_queue_rx()
475 net_stats_update_tc_recv_bytes(iface, tc, net_pkt_get_len(pkt)); in net_queue_rx()
480 NET_DBG("TC %d with prio %d pkt %p", tc, prio, pkt); in net_queue_rx()
484 net_process_rx_packet(pkt); in net_queue_rx()
486 net_tc_submit_to_rx_queue(tc, pkt); in net_queue_rx()
491 int net_recv_data(struct net_if *iface, struct net_pkt *pkt) in net_recv_data() argument
495 SYS_PORT_TRACING_FUNC_ENTER(net, recv_data, iface, pkt); in net_recv_data()
497 if (!pkt || !iface) { in net_recv_data()
502 if (net_pkt_is_empty(pkt)) { in net_recv_data()
512 net_pkt_set_overwrite(pkt, true); in net_recv_data()
513 net_pkt_cursor_init(pkt); in net_recv_data()
515 NET_DBG("prio %d iface %p pkt %p len %zu", net_pkt_priority(pkt), in net_recv_data()
516 iface, pkt, net_pkt_get_len(pkt)); in net_recv_data()
519 net_pkt_set_orig_iface(pkt, iface); in net_recv_data()
522 net_pkt_set_iface(pkt, iface); in net_recv_data()
524 if (!net_pkt_filter_recv_ok(pkt)) { in net_recv_data()
526 net_pkt_unref(pkt); in net_recv_data()
528 net_queue_rx(iface, pkt); in net_recv_data()
534 SYS_PORT_TRACING_FUNC_EXIT(net, recv_data, iface, pkt, ret); in net_recv_data()
565 int net_send_data(struct net_pkt *pkt) in net_send_data() argument
567 ARG_UNUSED(pkt); in net_send_data()
571 int net_recv_data(struct net_if *iface, struct net_pkt *pkt) in net_recv_data() argument
574 ARG_UNUSED(pkt); in net_recv_data()