@@ -1322,6 +1322,9 @@ struct arp_pending_entry {
13221322
13231323static int arp_lookup (struct wolfIP * s , unsigned int if_idx , ip4 ip , uint8_t * mac );
13241324static void arp_request (struct wolfIP * s , unsigned int if_idx , ip4 tip );
1325+ static void arp_store_neighbor (struct wolfIP * s , unsigned int if_idx , ip4 ip ,
1326+ const uint8_t * mac );
1327+ static int arp_neighbor_index (struct wolfIP * s , unsigned int if_idx , ip4 ip );
13251328#if WOLFIP_ENABLE_FORWARDING
13261329static void wolfIP_forward_packet (struct wolfIP * s , unsigned int out_if ,
13271330 struct wolfIP_ip_packet * ip , uint32_t len ,
@@ -5203,6 +5206,13 @@ static void tcp_input(struct wolfIP *S, unsigned int if_idx,
52035206 t -> sock .tcp .snd_una = t -> sock .tcp .seq ;
52045207 t -> dst_port = ee16 (tcp -> src_port );
52055208 t -> remote_ip = ee32 (tcp -> ip .src );
5209+ {
5210+ unsigned int nh_if = if_idx ;
5211+ ip4 nh = wolfIP_select_nexthop_ex (S , & nh_if , t -> remote_ip );
5212+ if (!wolfIP_ll_is_non_ethernet (S , nh_if ) &&
5213+ arp_neighbor_index (S , nh_if , nh ) < 0 )
5214+ arp_store_neighbor (S , nh_if , nh , tcp -> ip .eth .src );
5215+ }
52065216 t -> events |= CB_EVENT_READABLE ; /* Keep flag until application calls accept */
52075217 tcp_process_ts (t , tcp , frame_len );
52085218 tcp_send_syn (t , TCP_FLAG_SYN | TCP_FLAG_ACK );
0 commit comments