* Receive data from ether and do something with it. */
| 1556 | * Receive data from ether and do something with it. |
| 1557 | */ |
| 1558 | static int |
| 1559 | ng_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 | } |
nothing calls this directly
no test coverage detected