1/*- 2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 3 * Copyright (c) 2010-2011 Juniper Networks, Inc. 4 * All rights reserved. 5 * 6 * Portions of this software were developed by Robert N. M. Watson under 7 * contract to Juniper Networks, Inc. 8 * --- 51 unchanged lines hidden (view full) --- 60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 62 * SUCH DAMAGE. 63 * 64 * @(#)in_pcb.c 8.2 (Berkeley) 1/4/94 65 */ 66 67#include <sys/cdefs.h> |
68__FBSDID("$FreeBSD: head/sys/netinet6/in6_pcb.c 222691 2011-06-04 16:33:06Z rwatson $"); |
69 70#include "opt_inet.h" 71#include "opt_inet6.h" 72#include "opt_ipsec.h" 73 74#include <sys/param.h> 75#include <sys/systm.h> 76#include <sys/malloc.h> --- 282 unchanged lines hidden (view full) --- 359/* 360 * Outer subroutine: 361 * Connect from a socket to a specified address. 362 * Both address and port must be specified in argument sin. 363 * If don't have a local address for this socket yet, 364 * then pick one. 365 */ 366int |
367in6_pcbconnect_mbuf(register struct inpcb *inp, struct sockaddr *nam, 368 struct ucred *cred, struct mbuf *m) |
369{ 370 struct inpcbinfo *pcbinfo = inp->inp_pcbinfo; 371 register struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; 372 struct in6_addr addr6; 373 int error; 374 375 INP_WLOCK_ASSERT(inp); 376 INP_HASH_WLOCK_ASSERT(pcbinfo); --- 23 unchanged lines hidden (view full) --- 400 inp->in6p_faddr = sin6->sin6_addr; 401 inp->inp_fport = sin6->sin6_port; 402 /* update flowinfo - draft-itojun-ipv6-flowlabel-api-00 */ 403 inp->inp_flow &= ~IPV6_FLOWLABEL_MASK; 404 if (inp->inp_flags & IN6P_AUTOFLOWLABEL) 405 inp->inp_flow |= 406 (htonl(ip6_randomflowlabel()) & IPV6_FLOWLABEL_MASK); 407 |
408 in_pcbrehash_mbuf(inp, m); |
409 410 return (0); 411} 412 |
413int 414in6_pcbconnect(struct inpcb *inp, struct sockaddr *nam, struct ucred *cred) 415{ 416 417 return (in6_pcbconnect_mbuf(inp, nam, cred, NULL)); 418} 419 |
420void 421in6_pcbdisconnect(struct inpcb *inp) 422{ 423 424 INP_WLOCK_ASSERT(inp); 425 INP_HASH_WLOCK_ASSERT(inp->inp_pcbinfo); 426 427 bzero((caddr_t)&inp->in6p_faddr, sizeof(inp->in6p_faddr)); --- 548 unchanged lines hidden (view full) --- 976 } else 977 panic("%s: locking bug", __func__); 978 } else 979 INP_HASH_RUNLOCK(pcbinfo); 980 return (inp); 981} 982 983/* |
984 * Public inpcb lookup routines, accepting a 4-tuple, and optionally, an mbuf 985 * from which a pre-calculated hash value may be extracted. |
986 */ 987struct inpcb * 988in6_pcblookup(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, u_int fport, 989 struct in6_addr *laddr, u_int lport, int lookupflags, struct ifnet *ifp) 990{ |
991 KASSERT((lookupflags & ~INPLOOKUP_MASK) == 0, 992 ("%s: invalid lookup flags %d", __func__, lookupflags)); 993 KASSERT((lookupflags & (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)) != 0, 994 ("%s: LOCKPCB not set", __func__)); |
995 |
996 return (in6_pcblookup_hash(pcbinfo, faddr, fport, laddr, lport, 997 lookupflags, ifp)); 998} 999 1000struct inpcb * 1001in6_pcblookup_mbuf(struct inpcbinfo *pcbinfo, struct in6_addr *faddr, 1002 u_int fport, struct in6_addr *laddr, u_int lport, int lookupflags, 1003 struct ifnet *ifp, struct mbuf *m) 1004{ |
1005 KASSERT((lookupflags & ~INPLOOKUP_MASK) == 0, 1006 ("%s: invalid lookup flags %d", __func__, lookupflags)); 1007 KASSERT((lookupflags & (INPLOOKUP_RLOCKPCB | INPLOOKUP_WLOCKPCB)) != 0, 1008 ("%s: LOCKPCB not set", __func__)); 1009 1010 return (in6_pcblookup_hash(pcbinfo, faddr, fport, laddr, lport, 1011 lookupflags, ifp)); 1012} --- 16 unchanged lines hidden --- |