|
From: | web |
Subject: | Re: [lwip-users] Add support for outgoing VLAN tags? |
Date: | Mon, 28 Nov 2011 14:09:39 +0100 |
On 8 nov 2011 21:05 "address@hidden" <address@hidden> wrote:address@hidden wrote:Yes, it is. It is a mandatory feature for certain protocols, such as I have rewritten our VLAN PCP implementation, taking advantage of the ARP entry cache feature. In short, these are the modifications I have done. This snippet of code occurs in several places in LwIP: ************ #if LWIP_NETIF_HWADDRHINT netif->addr_hint = &(pcb->addr_hint); #endif /* LWIP_NETIF_HWADDRHINT*/ err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif); #if LWIP_NETIF_HWADDRHINT netif->addr_hint = NULL; #endif /* LWIP_NETIF_HWADDRHINT*/ ************ In all places I have replaced it with macros like this: ************ LWIP_SET_HINTS( netif, pcb ); err = ip_output_if(q, src_ip, dst_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif); LWIP_RESET_HINTS( netif ); ************ The macro copies both the ARP entry cache hint, as well as the VLAN PCP variable. I have changed the last argument of the function ip_output_hinted() from "u8_t *addr_hint" to "struct ip_pcb* pcb_hint". This allows other information besides the ARP entry cache to be copied from the pcb to the netif. The function tcp_rst did not support the ARP entry cache feature. I have added it by modifying tcp_rst like this: ************ tcp_rst(u32_t seqno, u32_t ackno, ip_addr_t *local_ip, ip_addr_t *remote_ip, u16_t local_port, u16_t remote_port #if LWIP_USE_HINTS , struct ip_pcb *pcb #endif /* LWIP_USE_HINTS */ ) ************ I have modified pbuf_alloc to allocate room for the VLAN tag, like this: ************ case PBUF_LINK: /* add room for link layer header */ offset += PBUF_LINK_HLEN; #if LWIP_VLAN_PCP /* add room for VLAN header */ offset += PBUF_VLAN_HLEN; #endif /* LWIP_VLAN_PCP */ break; ************ There is also new code in place in etharp_output to actually add the VLAN tag. What do you think about this solution? Regards, Timmy Brolin |
[Prev in Thread] | Current Thread | [Next in Thread] |