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

Function ng_pppoe_rcvdata_ether

freebsd/netgraph/ng_pppoe.c:1558–1961  ·  view source on GitHub ↗

* Receive data from ether and do something with it. */

Source from the content-addressed store, hash-verified

1556 * Receive data from ether and do something with it.
1557 */
1558static int
1559ng_pppoe_rcvdata_ether(hook_p hook, item_p item)
1560{
1561 node_p node = NG_HOOK_NODE(hook);
1562 const priv_p privp = NG_NODE_PRIVATE(node);
1563 sessp sp;
1564 const struct pppoe_tag *utag = NULL, *tag = NULL;
1565 const struct pppoe_tag sntag = { PTT_SRV_NAME, 0 };
1566 const struct pppoe_full_hdr *wh;
1567 const struct pppoe_hdr *ph;
1568 negp neg = NULL;
1569 struct mbuf *m;
1570 hook_p sendhook;
1571 int error = 0;
1572 uint16_t session;
1573 uint16_t length;
1574 uint8_t code;
1575 struct mbuf *m0;
1576
1577 CTR6(KTR_NET, "%20s: node [%x] (%p) received %p on \"%s\" (%p)",
1578 __func__, node->nd_ID, node, item, hook->hk_name, hook);
1579
1580 NGI_GET_M(item, m);
1581 /*
1582 * Dig out various fields from the packet.
1583 * Use them to decide where to send it.
1584 */
1585 privp->packets_in++;
1586 if( m->m_len < sizeof(*wh)) {
1587 m = m_pullup(m, sizeof(*wh)); /* Checks length */
1588 if (m == NULL) {
1589 log(LOG_NOTICE, "ng_pppoe[%x]: couldn't "
1590 "m_pullup(wh)\n", node->nd_ID);
1591 LEAVE(ENOBUFS);
1592 }
1593 }
1594 wh = mtod(m, struct pppoe_full_hdr *);
1595 length = ntohs(wh->ph.length);
1596 switch(wh->eh.ether_type) {
1597 case ETHERTYPE_PPPOE_3COM_DISC: /* fall through */
1598 case ETHERTYPE_PPPOE_DISC:
1599 /*
1600 * We need to try to make sure that the tag area
1601 * is contiguous, or we could wander off the end
1602 * of a buffer and make a mess.
1603 * (Linux wouldn't have this problem).
1604 */
1605 if (m->m_pkthdr.len <= MHLEN) {
1606 if( m->m_len < m->m_pkthdr.len) {
1607 m = m_pullup(m, m->m_pkthdr.len);
1608 if (m == NULL) {
1609 log(LOG_NOTICE, "ng_pppoe[%x]: "
1610 "couldn't m_pullup(pkthdr)\n",
1611 node->nd_ID);
1612 LEAVE(ENOBUFS);
1613 }
1614 }
1615 }

Callers

nothing calls this directly

Calls 15

m_pullupFunction · 0.85
m_dupFunction · 0.85
get_tagFunction · 0.85
pppoe_match_svcFunction · 0.85
pppoe_broadcast_padiFunction · 0.85
pppoe_finduniqFunction · 0.85
strncmpFunction · 0.85
init_tagsFunction · 0.85
insert_tagFunction · 0.85
send_acnameFunction · 0.85
scan_tagsFunction · 0.85
make_packetFunction · 0.85

Tested by

no test coverage detected