1/* 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 46 unchanged lines hidden (view full) --- 55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 60 * SUCH DAMAGE. 61 * 62 * @(#)udp_var.h 8.1 (Berkeley) 6/10/93 |
63 * $FreeBSD: head/sys/netinet6/udp6_usrreq.c 55009 1999-12-22 19:13:38Z shin $ |
64 */ 65 |
66#include "opt_ipsec.h" 67 |
68#include <sys/param.h> 69#include <sys/kernel.h> 70#include <sys/malloc.h> 71#include <sys/mbuf.h> 72#include <sys/protosw.h> 73#include <sys/socket.h> 74#include <sys/socketvar.h> 75#include <sys/sysctl.h> --- 19 unchanged lines hidden (view full) --- 95#include <netinet6/ip6_var.h> 96#include <netinet6/in6_pcb.h> 97#include <netinet6/icmp6.h> 98#include <netinet6/udp6_var.h> 99#include <netinet6/ip6protosw.h> 100 101#ifdef IPSEC 102#include <netinet6/ipsec.h> |
103#include <netinet6/ipsec6.h> |
104#endif /*IPSEC*/ 105 106#include "faith.h" 107 108/* 109 * UDP protocol inplementation. 110 * Per RFC 768, August, 1980. 111 */ --- 137 unchanged lines hidden (view full) --- 249 250 if (last != NULL) { 251 struct mbuf *n; 252 253#ifdef IPSEC 254 /* 255 * Check AH/ESP integrity. 256 */ |
257 if (ipsec6_in_reject_so(m, last->inp_socket)) |
258 ipsec6stat.in_polvio++; 259 /* do not inject data into pcb */ |
260 else |
261#endif /*IPSEC*/ 262 if ((n = m_copy(m, 0, M_COPYALL)) != NULL) { 263 /* 264 * KAME NOTE: do not 265 * m_copy(m, offset, ...) above. 266 * sbappendaddr() expects M_PKTHDR, 267 * and m_copy() will copy M_PKTHDR 268 * only if offset is 0. --- 38 unchanged lines hidden (view full) --- 307 udpstat.udps_noport++; 308 udpstat.udps_noportmcast++; 309 goto bad; 310 } 311#ifdef IPSEC 312 /* 313 * Check AH/ESP integrity. 314 */ |
315 if (ipsec6_in_reject_so(m, last->inp_socket)) { |
316 ipsec6stat.in_polvio++; 317 goto bad; 318 } 319#endif /*IPSEC*/ 320 if (last->in6p_flags & IN6P_CONTROLOPTS 321 || last->in6p_socket->so_options & SO_TIMESTAMP) 322 ip6_savecontrol(last, &opts, ip6, m); 323 --- 31 unchanged lines hidden (view full) --- 355 } 356 icmp6_error(m, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0); 357 return IPPROTO_DONE; 358 } 359#ifdef IPSEC 360 /* 361 * Check AH/ESP integrity. 362 */ |
363 if (ipsec6_in_reject_so(m, in6p->in6p_socket)) { |
364 ipsec6stat.in_polvio++; 365 goto bad; 366 } 367#endif /*IPSEC*/ 368 369 /* 370 * Construct sockaddr format source address. 371 * Stuff source address and datagram in user buffer. --- 100 unchanged lines hidden (view full) --- 472 error = SYSCTL_IN(req, addrs, sizeof(addrs)); 473 if (error) 474 return (error); 475 s = splnet(); 476 inp = in6_pcblookup_hash(&udbinfo, &addrs[1].sin6_addr, 477 addrs[1].sin6_port, 478 &addrs[0].sin6_addr, addrs[0].sin6_port, 479 1, NULL); |
480 if (!inp || !inp->inp_socket) { |
481 error = ENOENT; 482 goto out; 483 } 484 error = SYSCTL_OUT(req, inp->inp_socket->so_cred, 485 sizeof(struct ucred)); 486 487out: 488 splx(s); --- 64 unchanged lines hidden (view full) --- 553 splx(s); 554 goto release; 555 } 556 557 /* 558 * Stuff checksum and output datagram. 559 */ 560 ip6 = mtod(m, struct ip6_hdr *); |
561 ip6->ip6_flow = (ip6->ip6_flow & ~IPV6_FLOWINFO_MASK) | 562 (in6p->in6p_flowinfo & IPV6_FLOWINFO_MASK); 563 ip6->ip6_vfc = (ip6->ip6_vfc & ~IPV6_VERSION_MASK) | 564 (IPV6_VERSION & IPV6_VERSION_MASK); |
565 /* ip6_plen will be filled in ip6_output. */ 566 ip6->ip6_nxt = IPPROTO_UDP; 567 ip6->ip6_hlim = in6_selecthlim(in6p, 568 in6p->in6p_route.ro_rt ? 569 in6p->in6p_route.ro_rt->rt_ifp : 570 NULL); 571 ip6->ip6_src = in6p->in6p_laddr; 572 ip6->ip6_dst = in6p->in6p_faddr; --- 10 unchanged lines hidden (view full) --- 583 } 584 585 udpstat.udps_opackets++; 586 587#ifdef IPSEC 588 m->m_pkthdr.rcvif = (struct ifnet *)in6p->in6p_socket; 589#endif /*IPSEC*/ 590 error = ip6_output(m, in6p->in6p_outputopts, &in6p->in6p_route, |
591 IPV6_SOCKINMRCVIF, in6p->in6p_moptions, NULL); |
592 593 if (addr6) { 594 in6_pcbdisconnect(in6p); 595 in6p->in6p_laddr = laddr6; 596 splx(s); 597 } 598 goto releaseopt; 599 --- 241 unchanged lines hidden --- |