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

Function make_packet

freebsd/netgraph/ng_pppoe.c:394–424  ·  view source on GitHub ↗

* Make up a packet, using the tags filled out for the session. * * Assume that the actual pppoe header and ethernet header * are filled out externally to this routine. * Also assume that neg->wh points to the correct * location at the front of the buffer space. */

Source from the content-addressed store, hash-verified

392 * location at the front of the buffer space.
393 */
394static void
395make_packet(sessp sp) {
396 struct pppoe_full_hdr *wh = &sp->neg->pkt->pkt_header;
397 const struct pppoe_tag **tag;
398 char *dp;
399 int count;
400 int tlen;
401 uint16_t length = 0;
402
403 KASSERT((sp->neg != NULL) && (sp->neg->m != NULL),
404 ("%s: called from wrong state", __func__));
405 CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID);
406
407 dp = (char *)(&wh->ph + 1);
408 for (count = 0, tag = sp->neg->tags;
409 ((count < sp->neg->numtags) && (count < NUMTAGS));
410 tag++, count++) {
411 tlen = ntohs((*tag)->tag_len) + sizeof(**tag);
412 if ((length + tlen) > (ETHER_MAX_LEN - 4 - sizeof(*wh))) {
413 log(LOG_NOTICE, "ng_pppoe: tags too long\n");
414 sp->neg->numtags = count;
415 break; /* XXX chop off what's too long */
416 }
417 bcopy(*tag, (char *)dp, tlen);
418 length += tlen;
419 dp += tlen;
420 }
421 wh->ph.length = htons(length);
422 sp->neg->m->m_len = length + sizeof(*wh);
423 sp->neg->m->m_pkthdr.len = length + sizeof(*wh);
424}
425
426/**************************************************************************
427 * Routines to match a service. *

Callers 3

pppoe_startFunction · 0.85
ng_pppoe_rcvdataFunction · 0.85
ng_pppoe_rcvdata_etherFunction · 0.85

Calls 1

logFunction · 0.50

Tested by

no test coverage detected