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

Function cisco_input

freebsd/netgraph/ng_cisco.c:438–573  ·  view source on GitHub ↗

* Receive data */

Source from the content-addressed store, hash-verified

436 * Receive data
437 */
438static int
439cisco_input(sc_p sc, item_p item)
440{
441 const struct cisco_header *h;
442 struct cisco_header hdrbuf;
443 struct protoent *pep;
444 struct mbuf *m;
445 int error = 0;
446
447 /* Get data */
448 m = NGI_M(item);
449
450 /* Sanity check header length */
451 if (m->m_pkthdr.len < sizeof(*h)) {
452 error = EINVAL;
453 goto drop;
454 }
455
456 /* Get cisco header */
457 if (m->m_len >= sizeof(*h)) /* the common case */
458 h = mtod(m, const struct cisco_header *);
459 else {
460 m_copydata(m, 0, sizeof(*h), (caddr_t)&hdrbuf);
461 h = &hdrbuf;
462 }
463 m_adj(m, sizeof(*h));
464
465 /* Check header address */
466 switch (h->address) {
467 default: /* Invalid Cisco packet. */
468 goto drop;
469 case CISCO_UNICAST:
470 case CISCO_MULTICAST:
471 /* Don't check the control field here (RFC 1547). */
472 switch (ntohs(h->protocol)) {
473 default:
474 goto drop;
475 case CISCO_KEEPALIVE:
476 {
477 const struct cisco_packet *p;
478 struct cisco_packet pktbuf;
479
480 /* Sanity check packet length */
481 if (m->m_pkthdr.len < sizeof(*p)) {
482 error = EINVAL;
483 goto drop;
484 }
485
486 /* Get cisco packet */
487 if (m->m_len >= sizeof(*p)) /* the common case */
488 p = mtod(m, const struct cisco_packet *);
489 else {
490 m_copydata(m, 0, sizeof(*p), (caddr_t)&pktbuf);
491 p = &pktbuf;
492 }
493
494 /* Check packet type */
495 switch (ntohl(p->type)) {

Callers 1

cisco_rcvdataFunction · 0.85

Calls 5

m_copydataFunction · 0.85
m_adjFunction · 0.85
cisco_notifyFunction · 0.85
cisco_sendFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected