Lines Matching +full:re +full:- +full:routed
2 * SPDX-License-Identifier: BSD-3-Clause
73 "Enable forwarding source routed IP packets");
79 "Enable accepting source routed IP packets");
90 * are encountered, or forwarding it if source-routed.
94 * reason for as many as two passes is that when doing IPSTEALTH, non-routing
123 dst = ip->ip_dst; in ip_dooptions()
125 cnt = (ip->ip_hl << 2) - sizeof (struct ip); in ip_dooptions()
126 for (; cnt > 0; cnt -= optlen, cp += optlen) { in ip_dooptions()
134 code = &cp[IPOPT_OLEN] - (u_char *)ip; in ip_dooptions()
139 code = &cp[IPOPT_OLEN] - (u_char *)ip; in ip_dooptions()
150 * strictly routed, or do nothing if loosely routed. Record in ip_dooptions()
152 * strictly routed make sure next address is on directly in ip_dooptions()
162 code = &cp[IPOPT_OLEN] - (u_char *)ip; in ip_dooptions()
166 code = &cp[IPOPT_OFFSET] - (u_char *)ip; in ip_dooptions()
169 ipaddr.sin_addr = ip->ip_dst; in ip_dooptions()
185 off--; /* 0 origin */ in ip_dooptions()
186 if (off > optlen - (int)sizeof(struct in_addr)) { in ip_dooptions()
192 save_rte(m, cp, ip->ip_src); in ip_dooptions()
212 inet_ntoa_r(ip->ip_src, srcbuf), in ip_dooptions()
213 inet_ntoa_r(ip->ip_dst, dstbuf)); in ip_dooptions()
251 memcpy(cp + off, &(IA_SIN(ia)->sin_addr), in ip_dooptions()
260 memcpy(cp + off, &(IA_SIN(nh->nh_ifa)->sin_addr), in ip_dooptions()
264 ip->ip_dst = ipaddr.sin_addr; in ip_dooptions()
269 forward = !IN_MULTICAST(ntohl(ip->ip_dst.s_addr)); in ip_dooptions()
278 code = &cp[IPOPT_OFFSET] - (u_char *)ip; in ip_dooptions()
282 code = &cp[IPOPT_OFFSET] - (u_char *)ip; in ip_dooptions()
288 off--; /* 0 origin */ in ip_dooptions()
289 if (off > optlen - (int)sizeof(struct in_addr)) in ip_dooptions()
291 (void)memcpy(&ipaddr.sin_addr, &ip->ip_dst, in ip_dooptions()
294 * Locate outgoing interface; if we're the in ip_dooptions()
299 memcpy(cp + off, &(IA_SIN(ia)->sin_addr), in ip_dooptions()
303 memcpy(cp + off, &(IA_SIN(nh->nh_ifa)->sin_addr), in ip_dooptions()
318 code = cp - (u_char *)ip; in ip_dooptions()
320 code = &cp[IPOPT_OLEN] - (u_char *)ip; in ip_dooptions()
324 code = &cp[IPOPT_OLEN] - (u_char *)ip; in ip_dooptions()
327 if (off > optlen - (int)sizeof(int32_t)) { in ip_dooptions()
330 code = &cp[IPOPT_OFFSET] - (u_char *)ip; in ip_dooptions()
335 off--; /* 0 origin */ in ip_dooptions()
344 code = &cp[IPOPT_OFFSET] - (u_char *)ip; in ip_dooptions()
349 m->m_pkthdr.rcvif); in ip_dooptions()
352 (void)memcpy(sin, &IA_SIN(ia)->sin_addr, in ip_dooptions()
361 code = &cp[IPOPT_OFFSET] - (u_char *)ip; in ip_dooptions()
373 code = &cp[IPOPT_OFFSET + 1] - (u_char *)ip; in ip_dooptions()
408 if (olen > sizeof(opts->ip_srcrt) - (1 + sizeof(dst))) { in save_rte()
412 bcopy(option, opts->ip_srcrt.srcopt, olen); in save_rte()
413 opts->ip_nhops = (olen - IPOPT_OFFSET - 1) / sizeof(struct in_addr); in save_rte()
414 opts->ip_srcrt.dst = dst; in save_rte()
434 if (opts->ip_nhops == 0) in ip_srcroute()
440 #define OPTSIZ (sizeof(opts->ip_srcrt.nop) + sizeof(opts->ip_srcrt.srcopt)) in ip_srcroute()
443 m->m_len = opts->ip_nhops * sizeof(struct in_addr) + in ip_srcroute()
449 p = &(opts->ip_srcrt.route[opts->ip_nhops - 1]); in ip_srcroute()
450 *(mtod(m, struct in_addr *)) = *p--; in ip_srcroute()
455 opts->ip_srcrt.nop = IPOPT_NOP; in ip_srcroute()
456 opts->ip_srcrt.srcopt[IPOPT_OFFSET] = IPOPT_MINOFF; in ip_srcroute()
458 &(opts->ip_srcrt.nop), OPTSIZ); in ip_srcroute()
466 while (p >= opts->ip_srcrt.route) { in ip_srcroute()
467 *q++ = *p--; in ip_srcroute()
472 *q = opts->ip_srcrt.dst; in ip_srcroute()
486 olen = (ip->ip_hl << 2) - sizeof(struct ip); in ip_stripoptions()
487 m->m_len -= olen; in ip_stripoptions()
488 if (m->m_flags & M_PKTHDR) in ip_stripoptions()
489 m->m_pkthdr.len -= olen; in ip_stripoptions()
490 ip->ip_len = htons(ntohs(ip->ip_len) - olen); in ip_stripoptions()
491 ip->ip_hl = sizeof(struct ip) >> 2; in ip_stripoptions()
494 (size_t )(m->m_len - sizeof(struct ip))); in ip_stripoptions()
499 * required for IP source routing, as indicated by a non-zero in_addr at the
512 optlen = opt->m_len - sizeof(p->ipopt_dst); in ip_insertoptions()
513 if (optlen + ntohs(ip->ip_len) > IP_MAXPACKET) { in ip_insertoptions()
517 KASSERT((m->m_flags & M_EXTPG) == 0, ("%s: mbuf %p is unmapped", in ip_insertoptions()
519 if (p->ipopt_dst.s_addr) in ip_insertoptions()
520 ip->ip_dst = p->ipopt_dst; in ip_insertoptions()
528 n->m_pkthdr.rcvif = NULL; in ip_insertoptions()
529 n->m_pkthdr.len += optlen; in ip_insertoptions()
530 m->m_len -= sizeof(struct ip); in ip_insertoptions()
531 m->m_data += sizeof(struct ip); in ip_insertoptions()
532 n->m_next = m; in ip_insertoptions()
534 m->m_len = optlen + sizeof(struct ip); in ip_insertoptions()
535 m->m_data += max_linkhdr; in ip_insertoptions()
538 m->m_data -= optlen; in ip_insertoptions()
539 m->m_len += optlen; in ip_insertoptions()
540 m->m_pkthdr.len += optlen; in ip_insertoptions()
544 bcopy(p->ipopt_list, ip + 1, optlen); in ip_insertoptions()
546 ip->ip_v = IPVERSION; in ip_insertoptions()
547 ip->ip_hl = *phlen >> 2; in ip_insertoptions()
548 ip->ip_len = htons(ntohs(ip->ip_len) + optlen); in ip_insertoptions()
564 cnt = (ip->ip_hl << 2) - sizeof (struct ip); in ip_optcopy()
565 for (; cnt > 0; cnt -= optlen, cp += optlen) { in ip_optcopy()
590 for (optlen = dp - (u_char *)(jp+1); optlen & 0x3; optlen++) in ip_optcopy()
597 * with pointer in pcbopt, adding pseudo-option with destination address if
598 * source routed.
610 pcbopt = &inp->inp_options; in ip_pcbopts()
616 if (m == NULL || m->m_len == 0) { in ip_pcbopts()
625 if (m->m_len % sizeof(int32_t)) in ip_pcbopts()
628 * IP first-hop destination address will be stored before actual in ip_pcbopts()
631 if (m->m_data + m->m_len + sizeof(struct in_addr) >= &m->m_dat[MLEN]) in ip_pcbopts()
633 cnt = m->m_len; in ip_pcbopts()
634 m->m_len += sizeof(struct in_addr); in ip_pcbopts()
639 for (; cnt > 0; cnt -= optlen, cp += optlen) { in ip_pcbopts()
661 * ->A->B->C->D in ip_pcbopts()
669 /* XXX-BZ PRIV_NETINET_SETHDROPTS? */ in ip_pcbopts()
670 if (optlen < IPOPT_MINOFF - 1 + sizeof(struct in_addr)) in ip_pcbopts()
672 m->m_len -= sizeof(struct in_addr); in ip_pcbopts()
673 cnt -= sizeof(struct in_addr); in ip_pcbopts()
674 optlen -= sizeof(struct in_addr); in ip_pcbopts()
687 (unsigned)cnt - (IPOPT_MINOFF - 1)); in ip_pcbopts()
691 if (m->m_len > MAX_IPOPTLEN + sizeof(struct in_addr)) in ip_pcbopts()
715 * Return zero if not present or options are invalid, non-zero if present.
726 cnt = (ip->ip_hl << 2) - sizeof (struct ip); in ip_checkrouteralert()
727 for (; cnt > 0; cnt -= optlen, cp += optlen) { in ip_checkrouteralert()