Lines Matching defs:sp
282 static void pppoe_start(sessp sp);
284 static const struct pppoe_tag *scan_tags(sessp sp,
286 static int pppoe_send_event(sessp sp, enum cmd cmdid);
349 init_tags(sessp sp)
351 KASSERT(sp->neg != NULL, ("%s: no neg", __func__));
352 sp->neg->numtags = 0;
356 insert_tag(sessp sp, const struct pppoe_tag *tp)
358 negp neg = sp->neg;
380 make_packet(sessp sp) {
381 struct pppoe_full_hdr *wh = &sp->neg->pkt->pkt_header;
388 KASSERT((sp->neg != NULL) && (sp->neg->m != NULL),
390 CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID);
393 for (count = 0, tag = sp->neg->tags;
394 ((count < sp->neg->numtags) && (count < NUMTAGS));
399 sp->neg->numtags = count;
407 sp->neg->m->m_len = length + sizeof(*wh);
408 sp->neg->m->m_pkthdr.len = length + sizeof(*wh);
428 sessp sp;
430 LIST_FOREACH(sp, &privp->listeners, sessions) {
431 negp neg = sp->neg;
450 sp?sp->hook:NULL, (const char *)(tag + 1));
452 return (sp?sp->hook:NULL);
465 sessp sp;
468 LIST_FOREACH(sp, &privp->listeners, sessions) {
474 NG_SEND_DATA_ONLY(error, sp->hook, m);
489 sessp sp;
491 LIST_FOREACH(sp, &privp->listeners, sessions) {
492 negp neg = sp->neg;
496 return (sp->hook);
507 pppoe_getnewsession(sessp sp)
509 const priv_p privp = NG_NODE_PRIVATE(NG_HOOK_NODE(sp->hook));
529 sp->Session_ID = val;
530 LIST_INSERT_HEAD(&privp->sesshash[hash].head, sp, sessions);
543 pppoe_addsession(sessp sp)
545 const priv_p privp = NG_NODE_PRIVATE(NG_HOOK_NODE(sp->hook));
546 uint16_t hash = SESSHASH(sp->Session_ID);
549 LIST_INSERT_HEAD(&privp->sesshash[hash].head, sp, sessions);
555 pppoe_delsession(sessp sp)
557 const priv_p privp = NG_NODE_PRIVATE(NG_HOOK_NODE(sp->hook));
558 uint16_t hash = SESSHASH(sp->Session_ID);
561 LIST_REMOVE(sp, sessions);
571 sessp sp = NULL;
574 LIST_FOREACH(sp, &privp->sesshash[hash].head, sessions) {
575 if (sp->Session_ID == session &&
576 bcmp(sp->pkt_hdr.eh.ether_dhost,
582 CTR3(KTR_NET, "%20s: matched %p for %d", __func__, sp?sp->hook:NULL,
585 return (sp);
657 sessp sp;
671 sp = malloc(sizeof(*sp), M_NETGRAPH_PPPOE, M_NOWAIT | M_ZERO);
672 if (sp == NULL)
675 NG_HOOK_SET_PRIVATE(hook, sp);
676 sp->hook = hook;
730 sessp sp = NULL;
776 sp = NG_HOOK_PRIVATE(hook);
777 if (sp == NULL)
797 if (sp->state != PPPOE_SNONE) {
818 sp->neg = neg;
829 sp->creator = NGI_RETADDR(item);
874 pppoe_start(sp);
897 sp->state = PPPOE_LISTENING;
898 LIST_INSERT_HEAD(&privp->listeners, sp, sessions);
918 sp->state = PPPOE_PRIMED;
926 if (sp->state != PPPOE_PRIMED) {
931 neg = sp->neg;
1058 pppoe_start(sessp sp)
1060 hook_p hook = sp->hook;
1063 negp neg = sp->neg;
1074 CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID);
1075 sp->state = PPPOE_SINIT;
1085 uniqtag.data.pointer = sp;
1086 init_tags(sp);
1087 insert_tag(sp, &uniqtag.hdr);
1088 insert_tag(sp, &neg->service.hdr);
1090 insert_tag(sp, &privp->max_payload.hdr);
1091 make_packet(sp);
1103 send_acname(sessp sp, const struct pppoe_tag *tag)
1109 CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID);
1120 NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);
1126 send_sessionid(sessp sp)
1131 CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID);
1138 *(uint16_t *)msg->data = sp->Session_ID;
1139 NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);
1145 send_maxp(sessp sp, const struct pppoe_tag *tag)
1151 CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID);
1159 strncpy(maxp->hook, NG_HOOK_NAME(sp->hook), NG_HOOKSIZ);
1161 NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);
1174 sessp sp = NG_HOOK_PRIVATE(hook);
1183 switch (sp->state) {
1208 bcopy(&sp->pkt_hdr, wh, sizeof(*wh));
1222 negp neg = sp->neg;
1257 sp->state = PPPOE_SOFFER;
1265 uniqtag.hdr.tag_len = htons((u_int16_t)sizeof(sp));
1266 uniqtag.data.pointer = sp;
1267 init_tags(sp);
1268 insert_tag(sp, &neg->ac_name.hdr); /* AC_NAME */
1270 insert_tag(sp, tag); /* return service */
1280 insert_tag(sp, &neg->service.hdr); /* SERVICE */
1283 insert_tag(sp, tag); /* returned hostunique */
1284 insert_tag(sp, &uniqtag.hdr);
1285 scan_tags(sp, ph);
1286 make_packet(sp);
1293 m0 = m_copypacket(sp->neg->m, M_NOWAIT);
1321 sessp sp;
1442 (ntohs(utag->tag_len) != sizeof(sp))) {
1459 sp = NG_HOOK_PRIVATE(sendhook);
1460 if (sp->state == PPPOE_SREQ ||
1461 sp->state == PPPOE_CONNECTED) {
1464 if (sp->state != PPPOE_SINIT) {
1469 neg = sp->neg;
1484 sp->state = PPPOE_SREQ;
1498 init_tags(sp);
1499 insert_tag(sp, utag); /* Host Unique */
1501 insert_tag(sp, tag); /* return cookie */
1503 insert_tag(sp, tag); /* return it */
1504 send_acname(sp, tag);
1508 insert_tag(sp, tag); /* return it */
1509 insert_tag(sp, &neg->service.hdr); /* Service */
1510 scan_tags(sp, ph);
1511 make_packet(sp);
1512 sp->state = PPPOE_SREQ;
1513 ng_callout(&neg->handle, node, sp->hook,
1528 (ntohs(utag->tag_len) != sizeof(sp))) {
1542 sp = NG_HOOK_PRIVATE(sendhook);
1543 if (sp->state == PPPOE_NEWCONNECTED) {
1548 sp->state = PPPOE_SOFFER;
1549 } else if (sp->state != PPPOE_SOFFER)
1551 neg = sp->neg;
1554 if (sp->Session_ID == 0) {
1556 htons(pppoe_getnewsession(sp));
1558 send_sessionid(sp);
1563 init_tags(sp);
1564 insert_tag(sp, &neg->ac_name.hdr); /* AC_NAME */
1566 insert_tag(sp, tag);/* return service */
1568 insert_tag(sp, tag); /* return it */
1569 insert_tag(sp, utag); /* ac_cookie */
1570 scan_tags(sp, ph);
1571 make_packet(sp);
1572 sp->state = PPPOE_NEWCONNECTED;
1575 m0 = m_copypacket(sp->neg->m, M_NOWAIT);
1586 sp->pkt_hdr = neg->pkt->pkt_header;
1589 if (sp->pkt_hdr.eh.ether_type ==
1591 sp->pkt_hdr.eh.ether_type
1594 sp->pkt_hdr.eh.ether_type
1596 sp->pkt_hdr.ph.code = 0;
1597 pppoe_send_event(sp, NGM_PPPOE_SUCCESS);
1609 (ntohs(utag->tag_len) != sizeof(sp))) {
1620 sp = NG_HOOK_PRIVATE(sendhook);
1621 if (sp->state != PPPOE_SREQ)
1623 neg = sp->neg;
1626 sp->Session_ID = ntohs(wh->ph.sid);
1627 pppoe_addsession(sp);
1628 send_sessionid(sp);
1630 sp->state = PPPOE_CONNECTED;
1636 sp->pkt_hdr = neg->pkt->pkt_header;
1638 sp->pkt_hdr.eh.ether_type
1641 sp->pkt_hdr.eh.ether_type
1643 sp->pkt_hdr.ph.code = 0;
1645 free(sp->neg, M_NETGRAPH_PPPOE);
1646 sp->neg = NULL;
1649 send_maxp(sp, tag);
1650 pppoe_send_event(sp, NGM_PPPOE_SUCCESS);
1656 sp = pppoe_findsession(privp, wh);
1657 if (sp == NULL)
1660 ng_rmhook_self(sp->hook);
1671 sp = pppoe_findsession(privp, wh);
1672 if (sp == NULL)
1683 if ( sp->state != PPPOE_CONNECTED) {
1684 if (sp->state == PPPOE_NEWCONNECTED) {
1685 sp->state = PPPOE_CONNECTED;
1692 m_freem(sp->neg->m);
1693 ng_uncallout(&sp->neg->handle, node);
1694 free(sp->neg, M_NETGRAPH_PPPOE);
1695 sp->neg = NULL;
1700 NG_FWD_NEW_DATA(error, item, sp->hook, m);
1760 sessp sp;
1769 sp = NG_HOOK_PRIVATE(hook);
1770 if (sp->state != PPPOE_SNONE ) {
1771 pppoe_send_event(sp, NGM_PPPOE_CLOSE);
1779 && ((sp->state == PPPOE_CONNECTED)
1780 || (sp->state == PPPOE_NEWCONNECTED))) {
1797 bcopy(&sp->pkt_hdr, wh, sizeof(*wh));
1825 if (sp->state == PPPOE_LISTENING)
1826 LIST_REMOVE(sp, sessions);
1827 else if (sp->Session_ID)
1828 pppoe_delsession(sp);
1833 if (sp->neg) {
1834 ng_uncallout(&sp->neg->handle, node);
1835 if (sp->neg->m)
1836 m_freem(sp->neg->m);
1837 free(sp->neg, M_NETGRAPH_PPPOE);
1839 free(sp, M_NETGRAPH_PPPOE);
1855 sessp sp = NG_HOOK_PRIVATE(hook);
1856 negp neg = sp->neg;
1861 __func__, node->nd_ID, node, hook->hk_name, hook, sp->Session_ID);
1862 switch(sp->state) {
1871 m0 = m_copypacket(sp->neg->m, M_NOWAIT);
1876 if (sp->state == PPPOE_SREQ) {
1878 pppoe_start(sp);
1902 scan_tags(sessp sp, const struct pppoe_hdr* ph)
1911 CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID);
1923 insert_tag(sp, pt);
1944 pppoe_send_event(sessp sp, enum cmd cmdid)
1950 CTR2(KTR_NET, "%20s: called %d", __func__, sp->Session_ID);
1957 strncpy(sts->hook, NG_HOOK_NAME(sp->hook), NG_HOOKSIZ);
1958 NG_SEND_MSG_ID(error, NG_HOOK_NODE(sp->hook), msg, sp->creator, 0);