title: Build vlan header in c
body: <p>I need to build a vlan header.
  I have code that build eh header  (struct ether_header) and it work ok.</p>
  
  <pre><code>/* Ethernet header */
  memcpy(eh-&gt;ether_shost,src_mac_.data(), 6);
  memcpy(eh-&gt;ether_dhost,socketAddress.sll_addr , 6);
  
  /* Ethertype field */
  eh-&gt;ether_type = htons(ETH_P_IP);
  </code></pre>
  
  <p>I didnt find struct for vlan_eth_header , so i create my own and populate it like this:</p>
  
  <pre><code>struct vlan_ethhdr {
    u_int8_t  ether_dhost[ETH_ALEN];  /* destination eth addr */
    u_int8_t  ether_shost[ETH_ALEN];  /* source ether addr    */
    u_int16_t          h_vlan_proto;
    u_int16_t          h_vlan_TCI;
    u_int16_t ether_type;
   };
  
      /* Ethernet header */
      memcpy(eh-&gt;ether_shost,src_mac_.data(), 6);
      memcpy(eh-&gt;ether_dhost,socketAddress.sll_addr , 6);
          eh-&gt;h_vlan_proto = htons(0x8100);
          eh-&gt;h_vlan_TCI = htons(VLAN_ID);
      /* Ethertype field */
      eh-&gt;ether_type = htons(ETH_P_IP);
  </code></pre>
  
  <p>It seems that i did it wrong.
  It seems that Wireshak even didnt recognize the packet (the old code sent tcp packet and send them correct).
  Any advice?</p>