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

Function ip6_input_hbh

freebsd/netinet6/ip6_input.c:405–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403#endif
404
405static int
406ip6_input_hbh(struct mbuf **mp, uint32_t *plen, uint32_t *rtalert, int *off,
407 int *nxt, int *ours)
408{
409 struct mbuf *m;
410 struct ip6_hdr *ip6;
411 struct ip6_hbh *hbh;
412
413 if (ip6_hopopts_input(plen, rtalert, mp, off)) {
414#if 0 /*touches NULL pointer*/
415 in6_ifstat_inc((*mp)->m_pkthdr.rcvif, ifs6_in_discard);
416#endif
417 goto out; /* m have already been freed */
418 }
419
420 /* adjust pointer */
421 m = *mp;
422 ip6 = mtod(m, struct ip6_hdr *);
423
424 /*
425 * if the payload length field is 0 and the next header field
426 * indicates Hop-by-Hop Options header, then a Jumbo Payload
427 * option MUST be included.
428 */
429 if (ip6->ip6_plen == 0 && *plen == 0) {
430 /*
431 * Note that if a valid jumbo payload option is
432 * contained, ip6_hopopts_input() must set a valid
433 * (non-zero) payload length to the variable plen.
434 */
435 IP6STAT_INC(ip6s_badoptions);
436 in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_discard);
437 in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
438 icmp6_error(m, ICMP6_PARAM_PROB,
439 ICMP6_PARAMPROB_HEADER,
440 (caddr_t)&ip6->ip6_plen - (caddr_t)ip6);
441 goto out;
442 }
443 /* ip6_hopopts_input() ensures that mbuf is contiguous */
444 hbh = (struct ip6_hbh *)(ip6 + 1);
445 *nxt = hbh->ip6h_nxt;
446
447 /*
448 * If we are acting as a router and the packet contains a
449 * router alert option, see if we know the option value.
450 * Currently, we only support the option value for MLD, in which
451 * case we should pass the packet to the multicast routing
452 * daemon.
453 */
454 if (*rtalert != ~0) {
455 switch (*rtalert) {
456 case IP6OPT_RTALERT_MLD:
457 if (V_ip6_forwarding)
458 *ours = 1;
459 break;
460 default:
461 /*
462 * RFC2711 requires unrecognized values must be

Callers 1

ip6_inputFunction · 0.85

Calls 2

ip6_hopopts_inputFunction · 0.85
icmp6_errorFunction · 0.85

Tested by

no test coverage detected