* Process the received packet. */
| 505 | * Process the received packet. |
| 506 | */ |
| 507 | void |
| 508 | sppp_input(struct ifnet *ifp, struct mbuf *m) |
| 509 | { |
| 510 | struct ppp_header *h; |
| 511 | int isr = -1; |
| 512 | struct sppp *sp = IFP2SP(ifp); |
| 513 | int debug, do_account = 0; |
| 514 | #ifdef INET |
| 515 | int hlen, vjlen; |
| 516 | u_char *iphdr; |
| 517 | #endif |
| 518 | |
| 519 | SPPP_LOCK(sp); |
| 520 | debug = ifp->if_flags & IFF_DEBUG; |
| 521 | |
| 522 | if (ifp->if_flags & IFF_UP) |
| 523 | /* Count received bytes, add FCS and one flag */ |
| 524 | if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len + 3); |
| 525 | |
| 526 | if (m->m_pkthdr.len <= PPP_HEADER_LEN) { |
| 527 | /* Too small packet, drop it. */ |
| 528 | if (debug) |
| 529 | log(LOG_DEBUG, |
| 530 | SPP_FMT "input packet is too small, %d bytes\n", |
| 531 | SPP_ARGS(ifp), m->m_pkthdr.len); |
| 532 | drop: |
| 533 | m_freem (m); |
| 534 | SPPP_UNLOCK(sp); |
| 535 | drop2: |
| 536 | if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
| 537 | if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); |
| 538 | return; |
| 539 | } |
| 540 | |
| 541 | if (sp->pp_mode == PP_FR) { |
| 542 | sppp_fr_input (sp, m); |
| 543 | SPPP_UNLOCK(sp); |
| 544 | return; |
| 545 | } |
| 546 | |
| 547 | /* Get PPP header. */ |
| 548 | h = mtod (m, struct ppp_header*); |
| 549 | m_adj (m, PPP_HEADER_LEN); |
| 550 | |
| 551 | switch (h->address) { |
| 552 | case PPP_ALLSTATIONS: |
| 553 | if (h->control != PPP_UI) |
| 554 | goto invalid; |
| 555 | if (sp->pp_mode == IFF_CISCO) { |
| 556 | if (debug) |
| 557 | log(LOG_DEBUG, |
| 558 | SPP_FMT "PPP packet in Cisco mode " |
| 559 | "<addr=0x%x ctrl=0x%x proto=0x%x>\n", |
| 560 | SPP_ARGS(ifp), |
| 561 | h->address, h->control, ntohs(h->protocol)); |
| 562 | goto drop; |
| 563 | } |
| 564 | switch (ntohs (h->protocol)) { |
no test coverage detected