@@ -1467,6 +1467,8 @@ static unsigned int wolfIP_if_for_local_ip(struct wolfIP *s, ip4 local_ip, int *
14671467
14681468static uint16_t transport_checksum (union transport_pseudo_header * ph , void * _data );
14691469static int transport_verify_checksum (union transport_pseudo_header * ph , void * data );
1470+ static void wolfIP_send_port_unreachable (struct wolfIP * s , unsigned int if_idx ,
1471+ struct wolfIP_ip_packet * orig );
14701472#ifdef ETHERNET
14711473static uint16_t icmp_checksum (struct wolfIP_icmp_packet * icmp , uint16_t len );
14721474static void iphdr_set_checksum (struct wolfIP_ip_packet * ip );
@@ -1479,7 +1481,7 @@ static void arp_request(struct wolfIP *s, unsigned int if_idx, ip4 tip);
14791481static int arp_lookup (struct wolfIP * s , unsigned int if_idx , ip4 ip , uint8_t * mac );
14801482#endif
14811483
1482- #ifdef ETHERNET
1484+ #if WOLFIP_ENABLE_FORWARDING && defined( ETHERNET )
14831485static void wolfIP_send_ttl_exceeded (struct wolfIP * s , unsigned int if_idx ,
14841486 struct wolfIP_ip_packet * orig )
14851487{
@@ -1518,7 +1520,17 @@ static void wolfIP_send_ttl_exceeded(struct wolfIP *s, unsigned int if_idx,
15181520 }
15191521 wolfIP_ll_send_frame (s , if_idx , & icmp , sizeof (icmp ));
15201522}
1523+ #elif WOLFIP_ENABLE_FORWARDING
1524+ static void wolfIP_send_ttl_exceeded (struct wolfIP * s , unsigned int if_idx ,
1525+ struct wolfIP_ip_packet * orig )
1526+ {
1527+ (void )s ;
1528+ (void )if_idx ;
1529+ (void )orig ;
1530+ }
1531+ #endif
15211532
1533+ #ifdef ETHERNET
15221534static void wolfIP_send_port_unreachable (struct wolfIP * s , unsigned int if_idx ,
15231535 struct wolfIP_ip_packet * orig )
15241536{
@@ -1559,14 +1571,6 @@ static void wolfIP_send_port_unreachable(struct wolfIP *s, unsigned int if_idx,
15591571 wolfIP_ll_send_frame (s , if_idx , & icmp , sizeof (icmp ));
15601572}
15611573#else
1562- static void wolfIP_send_ttl_exceeded (struct wolfIP * s , unsigned int if_idx ,
1563- struct wolfIP_ip_packet * orig )
1564- {
1565- (void )s ;
1566- (void )if_idx ;
1567- (void )orig ;
1568- }
1569-
15701574static void wolfIP_send_port_unreachable (struct wolfIP * s , unsigned int if_idx ,
15711575 struct wolfIP_ip_packet * orig )
15721576{
@@ -2294,11 +2298,22 @@ static void tcp_send_reset_reply(struct wolfIP *s, unsigned int if_idx,
22942298 out .csum = ee16 (transport_checksum (& ph , & out .src_port ));
22952299
22962300#ifdef ETHERNET
2297- if (!wolfIP_ll_is_non_ethernet (s , if_idx ))
2298- wolfIP_forward_packet (s , if_idx , & out .ip , sizeof (out ), in -> ip .eth .src , 0 );
2299- else
2301+ if (!wolfIP_ll_is_non_ethernet (s , if_idx )) {
2302+ if (eth_output_add_header (s , if_idx , in -> ip .eth .src , & out .ip .eth , ETH_TYPE_IP ) != 0 )
2303+ return ;
2304+ }
2305+ #endif
2306+ if (wolfIP_filter_notify_tcp (WOLFIP_FILT_SENDING , s , if_idx , & out , sizeof (out )) != 0 )
2307+ return ;
2308+ if (wolfIP_filter_notify_ip (WOLFIP_FILT_SENDING , s , if_idx , & out .ip , sizeof (out )) != 0 )
2309+ return ;
2310+ #ifdef ETHERNET
2311+ if (!wolfIP_ll_is_non_ethernet (s , if_idx )) {
2312+ if (wolfIP_filter_notify_eth (WOLFIP_FILT_SENDING , s , if_idx , & out .ip .eth , sizeof (out )) != 0 )
2313+ return ;
2314+ }
23002315#endif
2301- wolfIP_forward_packet (s , if_idx , & out .ip , sizeof (out ), NULL , 0 );
2316+ wolfIP_ll_send_frame (s , if_idx , & out .ip , sizeof (out ));
23022317}
23032318
23042319static void tcp_send_finack (struct tsocket * t )
0 commit comments