On 8 nov 2011 21:05 "goldsi...@gmx.de" <goldsi...@gmx.de> wrote:

> <w...@brolinembedded.se> wrote:
> > Yes, it is. It is a mandatory feature for certain protocols, such as
> > the industrial control protocol "EtherNet/IP"
> > <http://en.wikipedia.org/wiki/Ethernet/IP>
> 
> That's interesting. Since I know of at least one Ethernet/IP stack
> being
> ported to linux, do you know whether/how linux allows changing the
> VLAN
> header per socket?
> 
> > The problem with adding VLAN PCP to LwIP is that a socket level
> > variable must somehow be communicated down to the link layer for
> > each
> > frame. There does not seem to be a easy way of doing this.
> Thinkig about it, we already have a mechanism for that: the per-pcb
> ARP
> entry cache. In the same manner as this, we could add members to
> struct
> netif which configure VLAN settings and change them before calling one
> of the ip_output functions (although that set/reset code would be
> scattered around tcp, udp, raw, icmp and igmp).
> 
> Simon
> 

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
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to