| 1314 | } |
| 1315 | |
| 1316 | struct mbuf * |
| 1317 | ether_vlanencap_proto(struct mbuf *m, uint16_t tag, uint16_t proto) |
| 1318 | { |
| 1319 | struct ether_vlan_header *evl; |
| 1320 | |
| 1321 | M_PREPEND(m, ETHER_VLAN_ENCAP_LEN, M_NOWAIT); |
| 1322 | if (m == NULL) |
| 1323 | return (NULL); |
| 1324 | /* M_PREPEND takes care of m_len, m_pkthdr.len for us */ |
| 1325 | |
| 1326 | if (m->m_len < sizeof(*evl)) { |
| 1327 | m = m_pullup(m, sizeof(*evl)); |
| 1328 | if (m == NULL) |
| 1329 | return (NULL); |
| 1330 | } |
| 1331 | |
| 1332 | /* |
| 1333 | * Transform the Ethernet header into an Ethernet header |
| 1334 | * with 802.1Q encapsulation. |
| 1335 | */ |
| 1336 | evl = mtod(m, struct ether_vlan_header *); |
| 1337 | bcopy((char *)evl + ETHER_VLAN_ENCAP_LEN, |
| 1338 | (char *)evl, ETHER_HDR_LEN - ETHER_TYPE_LEN); |
| 1339 | evl->evl_encap_proto = htons(proto); |
| 1340 | evl->evl_tag = htons(tag); |
| 1341 | return (m); |
| 1342 | } |
| 1343 | |
| 1344 | static SYSCTL_NODE(_net_link, IFT_L2VLAN, vlan, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, |
| 1345 | "IEEE 802.1Q VLAN"); |
no test coverage detected