MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ether_vlanencap_proto

Function ether_vlanencap_proto

freebsd/net/if_ethersubr.c:1316–1342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1314}
1315
1316struct mbuf *
1317ether_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
1344static SYSCTL_NODE(_net_link, IFT_L2VLAN, vlan, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,
1345 "IEEE 802.1Q VLAN");

Callers 3

ether_vlanencapFunction · 0.85
ether_8021q_frameFunction · 0.85
ether_vlanencapFunction · 0.85

Calls 1

m_pullupFunction · 0.85

Tested by

no test coverage detected