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

Function me_input

freebsd/net/if_me.c:466–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

464}
465
466static int
467me_input(struct mbuf *m, int off, int proto, void *arg)
468{
469 struct me_softc *sc = arg;
470 struct mobhdr *mh;
471 struct ifnet *ifp;
472 struct ip *ip;
473 int hlen;
474
475 NET_EPOCH_ASSERT();
476
477 ifp = ME2IFP(sc);
478 /* checks for short packets */
479 hlen = sizeof(struct mobhdr);
480 if (m->m_pkthdr.len < sizeof(struct ip) + hlen)
481 hlen -= sizeof(struct in_addr);
482 if (m->m_len < sizeof(struct ip) + hlen)
483 m = m_pullup(m, sizeof(struct ip) + hlen);
484 if (m == NULL)
485 goto drop;
486 mh = (struct mobhdr *)mtodo(m, sizeof(struct ip));
487 /* check for wrong flags */
488 if (mh->mob_flags & (~MOB_FLAGS_SP)) {
489 m_freem(m);
490 goto drop;
491 }
492 if (mh->mob_flags) {
493 if (hlen != sizeof(struct mobhdr)) {
494 m_freem(m);
495 goto drop;
496 }
497 } else
498 hlen = sizeof(struct mobhdr) - sizeof(struct in_addr);
499 /* check mobile header checksum */
500 if (me_in_cksum((uint16_t *)mh, hlen / sizeof(uint16_t)) != 0) {
501 m_freem(m);
502 goto drop;
503 }
504#ifdef MAC
505 mac_ifnet_create_mbuf(ifp, m);
506#endif
507 ip = mtod(m, struct ip *);
508 ip->ip_dst = mh->mob_dst;
509 ip->ip_p = mh->mob_proto;
510 ip->ip_sum = 0;
511 ip->ip_len = htons(m->m_pkthdr.len - hlen);
512 if (mh->mob_flags)
513 ip->ip_src = mh->mob_src;
514 memmove(mtodo(m, hlen), ip, sizeof(struct ip));
515 m_adj(m, hlen);
516 m_clrprotoflags(m);
517 m->m_pkthdr.rcvif = ifp;
518 m->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID);
519 M_SETFIB(m, ifp->if_fib);
520 hlen = AF_INET;
521 BPF_MTAP2(ifp, &hlen, sizeof(hlen), m);
522 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
523 if_inc_counter(ifp, IFCOUNTER_IBYTES, m->m_pkthdr.len);

Callers

nothing calls this directly

Calls 9

m_pullupFunction · 0.85
me_in_cksumFunction · 0.85
mac_ifnet_create_mbufFunction · 0.85
m_adjFunction · 0.85
if_inc_counterFunction · 0.85
netisr_dispatchFunction · 0.85
m_freemFunction · 0.50
memmoveFunction · 0.50
m_clrprotoflagsFunction · 0.50

Tested by

no test coverage detected