Re: vlans in socket progrmaming

Peter Stuge <[email protected]>
Newsgroups gmane.linux.drivers.vlan
Message-ID <[email protected]>
Hi Stefan,

On Mon, May 30, 2005 at 10:37:56AM +0200, Stefan Linecker wrote:
> i'm searching for a code-snippet/faq/tutorial showing basic vlan
> things in socket programming, especially how to set and get the
> vlan-id in network packets.
> 
> anybody out who can help? any hints welcome.

VLAN tags are assigned by the kernel depending on which interface
packets are sent out on. So the normal rules for routing applies even
with VLAN interfaces.

The vconfig administrative tool adds VLAN interfaces "onto" an
existing interface, either physical or virtual. (ie. eth0 and br0
both work as the "base" interface) The new interfaces are named like
eth0.4 by default, where 4 is the VLAN number as specified when
running vconfig.

Then, a network address is assigned to eth0.4, and when an
application bind():s to this address or if the default route is
through the eth0.4 interface, a VLAN tag of 4 is added to outgoing
packets by the kernel.

If you really want to construct VLAN packets in user-space you'll
need to use a raw socket and do all of the protocols on your own.


//Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.