sockets - Reading 802.1Q frames with specific VLAN tag under Linux -


Is there a way to get data for a specific VLAN tag frame? The frame being tagged by inputting htons (0x22f0) as input to all the VLAN sockets () I currently receive:

  m_iSocketDesc = socket (AF_PACKET, SOCK_RAW, htons (0x22f0)); Numbytes = recvfrom (m_iSocketDesc, message_data, 1522, 0, null, 0)    

I A similar requirement was to get a packet with a specific VLAN, I created a VLAN interface and forced it to my raw socket. Now I can send 802.3 frames, the kernel insert / removes the VLAN tag.

  1. Create the VLAN interface, you must have root access

      add ip link link & lt; PhyInterface & gt; Name & lt; PhyInterface.VLANID & gt; Type VLAN ID VLANID Example: IP Link Link Link eth0 Name eth0.100 Type vlan 100  
  2. Use the normal bind function in your application to connect to the VLAN interface Please. Eth0.100 in the above example.

    You can specify the following two links for the sample code (I am the owner of the not code) < P> Getting:

    Receiving:

    The only change is needed to bind the virtual VLAN interface instead of binding to the physical interface. Note that the received ethernet frames are un-tagged frames. Any frames sent to this interface will be automatically tagged with VLANID.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -