Home | History | Annotate | Line # | Download | only in netinet6
in6_pcb.h revision 1.7
      1  1.7   itojun /*	$NetBSD: in6_pcb.h,v 1.7 1999/12/27 06:38:47 itojun Exp $	*/
      2  1.3  thorpej 
      3  1.2   itojun /*
      4  1.2   itojun  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
      5  1.2   itojun  * All rights reserved.
      6  1.2   itojun  *
      7  1.2   itojun  * Redistribution and use in source and binary forms, with or without
      8  1.2   itojun  * modification, are permitted provided that the following conditions
      9  1.2   itojun  * are met:
     10  1.2   itojun  * 1. Redistributions of source code must retain the above copyright
     11  1.2   itojun  *    notice, this list of conditions and the following disclaimer.
     12  1.2   itojun  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2   itojun  *    notice, this list of conditions and the following disclaimer in the
     14  1.2   itojun  *    documentation and/or other materials provided with the distribution.
     15  1.2   itojun  * 3. Neither the name of the project nor the names of its contributors
     16  1.2   itojun  *    may be used to endorse or promote products derived from this software
     17  1.2   itojun  *    without specific prior written permission.
     18  1.2   itojun  *
     19  1.2   itojun  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     20  1.2   itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21  1.2   itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22  1.2   itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     23  1.2   itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24  1.2   itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25  1.2   itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26  1.2   itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27  1.2   itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28  1.2   itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29  1.2   itojun  * SUCH DAMAGE.
     30  1.2   itojun  */
     31  1.2   itojun 
     32  1.2   itojun /*
     33  1.2   itojun  * Copyright (c) 1982, 1986, 1990, 1993
     34  1.2   itojun  *	The Regents of the University of California.  All rights reserved.
     35  1.2   itojun  *
     36  1.2   itojun  * Redistribution and use in source and binary forms, with or without
     37  1.2   itojun  * modification, are permitted provided that the following conditions
     38  1.2   itojun  * are met:
     39  1.2   itojun  * 1. Redistributions of source code must retain the above copyright
     40  1.2   itojun  *    notice, this list of conditions and the following disclaimer.
     41  1.2   itojun  * 2. Redistributions in binary form must reproduce the above copyright
     42  1.2   itojun  *    notice, this list of conditions and the following disclaimer in the
     43  1.2   itojun  *    documentation and/or other materials provided with the distribution.
     44  1.2   itojun  * 3. All advertising materials mentioning features or use of this software
     45  1.2   itojun  *    must display the following acknowledgement:
     46  1.2   itojun  *	This product includes software developed by the University of
     47  1.2   itojun  *	California, Berkeley and its contributors.
     48  1.2   itojun  * 4. Neither the name of the University nor the names of its contributors
     49  1.2   itojun  *    may be used to endorse or promote products derived from this software
     50  1.2   itojun  *    without specific prior written permission.
     51  1.2   itojun  *
     52  1.2   itojun  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     53  1.2   itojun  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54  1.2   itojun  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55  1.2   itojun  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     56  1.2   itojun  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57  1.2   itojun  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58  1.2   itojun  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59  1.2   itojun  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60  1.2   itojun  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61  1.2   itojun  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62  1.2   itojun  * SUCH DAMAGE.
     63  1.2   itojun  *
     64  1.2   itojun  *	@(#)in_pcb.h	8.1 (Berkeley) 6/10/93
     65  1.2   itojun  */
     66  1.2   itojun 
     67  1.2   itojun #ifndef _NETINET6_IN6_PCB_H_
     68  1.2   itojun #define _NETINET6_IN6_PCB_H_
     69  1.2   itojun 
     70  1.2   itojun #include <sys/queue.h>
     71  1.2   itojun 
     72  1.2   itojun /*
     73  1.2   itojun  * Common structure pcb for internet protocol implementation.
     74  1.2   itojun  * Here are stored pointers to local and foreign host table
     75  1.2   itojun  * entries, local and foreign socket numbers, and pointers
     76  1.2   itojun  * up (to a socket structure) and down (to a protocol-specific)
     77  1.2   itojun  * control block.
     78  1.2   itojun  */
     79  1.2   itojun struct icmp6_filter;
     80  1.2   itojun 
     81  1.2   itojun struct	in6pcb {
     82  1.2   itojun 	struct	in6pcb *in6p_next, *in6p_prev;
     83  1.2   itojun 					/* pointers to other pcb's */
     84  1.2   itojun 	struct	in6pcb *in6p_head;	/* pointer back to chain of
     85  1.2   itojun 					   in6pcb's for this protocol */
     86  1.2   itojun 	struct	in6_addr in6p_faddr;	/* foreign host table entry */
     87  1.2   itojun 	u_short	in6p_fport;		/* foreign port */
     88  1.2   itojun 	struct	in6_addr in6p_laddr;	/* local host table entry */
     89  1.2   itojun 	u_short	in6p_lport;		/* local port */
     90  1.5   itojun 	u_int32_t in6p_flowinfo;	/* priority and flowlabel */
     91  1.2   itojun 	struct	socket *in6p_socket;	/* back pointer to socket */
     92  1.2   itojun 	caddr_t	in6p_ppcb;		/* pointer to per-protocol pcb */
     93  1.2   itojun 	struct	route_in6 in6p_route;	/* placeholder for routing entry */
     94  1.2   itojun 	int	in6p_flags;		/* generic IP6/datagram flags */
     95  1.2   itojun 	int	in6p_hops;		/* default hop limit */
     96  1.2   itojun 	struct	ip6_hdr in6p_ip6;	/* header prototype */
     97  1.2   itojun 	struct	mbuf *in6p_options;   /* IP6 options */
     98  1.2   itojun 	struct	ip6_pktopts *in6p_outputopts; /* IP6 options for outgoing packets */
     99  1.2   itojun 	struct	ip6_moptions *in6p_moptions; /* IP6 multicast options */
    100  1.2   itojun 	u_short	in6p_ifindex;
    101  1.2   itojun 	/* should move the following just after next/prev */
    102  1.2   itojun 	LIST_ENTRY(in6pcb) in6p_hlist;	/* hash chain */
    103  1.2   itojun 	u_long	in6p_hash;		/* hash value */
    104  1.2   itojun #if 1 /*IPSEC*/
    105  1.2   itojun 	struct secpolicy *in6p_sp;	/* security policy. It may not be
    106  1.2   itojun 					 * used according to policy selection.
    107  1.2   itojun 					 */
    108  1.2   itojun #endif
    109  1.2   itojun 	struct icmp6_filter *in6p_icmp6filt;
    110  1.2   itojun 	int	in6p_cksum;		/* IPV6_CHECKSUM setsockopt */
    111  1.2   itojun };
    112  1.2   itojun 
    113  1.2   itojun #define in6p_ip6_nxt in6p_ip6.ip6_nxt  /* for KAME src sync over BSD*'s */
    114  1.2   itojun 
    115  1.7   itojun /*
    116  1.7   itojun  * Flags in in6p_flags
    117  1.7   itojun  * We define KAME's original flags in higher 16 bits as much as possible
    118  1.7   itojun  * for compatibility with *bsd*s.
    119  1.7   itojun  */
    120  1.7   itojun #define IN6P_RECVOPTS		0x001000 /* receive incoming IP6 options */
    121  1.7   itojun #define IN6P_RECVRETOPTS	0x002000 /* receive IP6 options for reply */
    122  1.7   itojun #define IN6P_RECVDSTADDR	0x004000 /* receive IP6 dst address */
    123  1.7   itojun #define IN6P_PKTINFO		0x010000 /* receive IP6 dst and I/F */
    124  1.7   itojun #define IN6P_HOPLIMIT		0x020000 /* receive hoplimit */
    125  1.7   itojun #define IN6P_HOPOPTS		0x040000 /* receive hop-by-hop options */
    126  1.7   itojun #define IN6P_DSTOPTS		0x080000 /* receive dst options after rthdr */
    127  1.7   itojun #define IN6P_RTHDR		0x100000 /* receive routing header */
    128  1.7   itojun #define IN6P_RTHDRDSTOPTS	0x200000 /* receive dstoptions before rthdr */
    129  1.7   itojun 
    130  1.7   itojun #define IN6P_HIGHPORT		0x1000000 /* user wants "high" port binding */
    131  1.7   itojun #define IN6P_LOWPORT		0x2000000 /* user wants "low" port binding */
    132  1.7   itojun #define IN6P_ANONPORT		0x4000000 /* port chosen for user */
    133  1.7   itojun #define IN6P_FAITH		0x8000000 /* accept FAITH'ed connections */
    134  1.7   itojun #define IN6P_BINDV6ONLY		0x10000000 /* do not grab IPv4 traffic */
    135  1.7   itojun 
    136  1.7   itojun #define IN6P_CONTROLOPTS	(IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\
    137  1.7   itojun 				 IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS)
    138  1.7   itojun 
    139  1.2   itojun 
    140  1.2   itojun #define IN6PLOOKUP_WILDCARD	1
    141  1.2   itojun #define IN6PLOOKUP_SETLOCAL	2
    142  1.2   itojun 
    143  1.2   itojun /* compute hash value for foreign and local in6_addr and port */
    144  1.2   itojun #define IN6_HASH(faddr, fport, laddr, lport) 			\
    145  1.2   itojun 	(((faddr)->s6_addr32[0] ^ (faddr)->s6_addr32[1] ^	\
    146  1.2   itojun 	  (faddr)->s6_addr32[2] ^ (faddr)->s6_addr32[3] ^	\
    147  1.2   itojun 	  (laddr)->s6_addr32[0] ^ (laddr)->s6_addr32[1] ^	\
    148  1.2   itojun 	  (laddr)->s6_addr32[2] ^ (laddr)->s6_addr32[3])	\
    149  1.2   itojun 	 + (fport) + (lport))
    150  1.2   itojun 
    151  1.2   itojun #define sotoin6pcb(so)	((struct in6pcb *)(so)->so_pcb)
    152  1.2   itojun 
    153  1.2   itojun #ifdef _KERNEL
    154  1.2   itojun void	in6_losing __P((struct in6pcb *));
    155  1.2   itojun int	in6_pcballoc __P((struct socket *, struct in6pcb *));
    156  1.2   itojun int	in6_pcbbind __P((struct in6pcb *, struct mbuf *));
    157  1.2   itojun int	in6_pcbconnect __P((struct in6pcb *, struct mbuf *));
    158  1.2   itojun void	in6_pcbdetach __P((struct in6pcb *));
    159  1.2   itojun void	in6_pcbdisconnect __P((struct in6pcb *));
    160  1.2   itojun struct	in6pcb *
    161  1.2   itojun 	in6_pcblookup __P((struct in6pcb *,
    162  1.2   itojun 			   struct in6_addr *, u_int, struct in6_addr *,
    163  1.2   itojun 			   u_int, int));
    164  1.2   itojun int	in6_pcbnotify __P((struct in6pcb *, struct sockaddr *,
    165  1.2   itojun 			   u_int, struct in6_addr *, u_int, int,
    166  1.2   itojun 			   void (*)(struct in6pcb *, int)));
    167  1.6   itojun int	in6_pcbsetport __P((struct in6_addr *, struct in6pcb *));
    168  1.2   itojun void	in6_rtchange __P((struct in6pcb *, int));
    169  1.2   itojun void	in6_setpeeraddr __P((struct in6pcb *, struct mbuf *));
    170  1.2   itojun void	in6_setsockaddr __P((struct in6pcb *, struct mbuf *));
    171  1.2   itojun struct 	in6_addr *in6_selectsrc __P((struct sockaddr_in6 *,
    172  1.6   itojun 				     struct ip6_pktopts *,
    173  1.6   itojun 				     struct ip6_moptions *,
    174  1.6   itojun 				     struct route_in6 *,
    175  1.6   itojun 				     struct in6_addr *, int *));
    176  1.6   itojun int	in6_selecthlim __P((struct in6pcb *, struct ifnet *));
    177  1.2   itojun 
    178  1.2   itojun #ifndef TCP6
    179  1.2   itojun extern struct rtentry *
    180  1.2   itojun 	in6_pcbrtentry __P((struct in6pcb *));
    181  1.2   itojun extern struct in6pcb *in6_pcblookup_connect __P((struct in6pcb *,
    182  1.4   itojun 	struct in6_addr *, u_int, struct in6_addr *, u_int, int));
    183  1.2   itojun extern struct in6pcb *in6_pcblookup_bind __P((struct in6pcb *,
    184  1.4   itojun 	struct in6_addr *, u_int, int));
    185  1.2   itojun #endif
    186  1.2   itojun #endif /* _KERNEL */
    187  1.2   itojun 
    188  1.2   itojun #endif /* !_NETINET6_IN6_PCB_H_ */
    189