1 /* $NetBSD: sockmisc.h,v 1.10 2009/05/18 17:40:38 tteras Exp $ */
3 /* Id: sockmisc.h,v 1.9 2005/10/05 16:55:41 manubsd Exp */
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #ifndef IP_IPSEC_POLICY
38 #define IP_IPSEC_POLICY 16 /* XXX: from linux/in.h */
41 #ifndef IPV6_IPSEC_POLICY
42 #define IPV6_IPSEC_POLICY 34 /* XXX: from linux/???.h per
43 "Tom Lendacky" <toml@us.ibm.com> */
48 struct sockaddr_in sin
;
49 struct sockaddr_in6 sin6
;
53 union sockaddr_any sa
;
57 extern const int niflags
;
59 #define CMPSADDR_MATCH 0
60 #define CMPSADDR_WOP_MATCH 1
61 #define CMPSADDR_MISMATCH 2
63 extern int cmpsaddr
__P((const struct sockaddr
*, const struct sockaddr
*));
65 extern struct sockaddr
*getlocaladdr
__P((struct sockaddr
*));
67 extern int recvfromto
__P((int, void *, size_t, int,
68 struct sockaddr
*, socklen_t
*, struct sockaddr
*, unsigned int *));
69 extern int sendfromto
__P((int, const void *, size_t,
70 struct sockaddr
*, struct sockaddr
*, int));
72 extern int setsockopt_bypass
__P((int, int));
74 extern struct sockaddr
*newsaddr
__P((int));
75 extern struct sockaddr
*dupsaddr
__P((struct sockaddr
*));
76 extern char *saddr2str
__P((const struct sockaddr
*));
77 extern char *saddrwop2str
__P((const struct sockaddr
*));
78 extern char *saddr2str_fromto
__P((const char *format
,
79 const struct sockaddr
*saddr
,
80 const struct sockaddr
*daddr
));
81 extern struct sockaddr
*str2saddr
__P((char *, char *));
82 extern void mask_sockaddr
__P((struct sockaddr
*, const struct sockaddr
*,
85 /* struct netaddr functions */
86 extern char *naddrwop2str
__P((const struct netaddr
*naddr
));
87 extern char *naddrwop2str_fromto
__P((const char *format
, const struct netaddr
*saddr
,
88 const struct netaddr
*daddr
));
89 extern int naddr_score(const struct netaddr
*naddr
, const struct sockaddr
*saddr
);
91 /* Some usefull functions for sockaddr port manipulations. */
92 extern u_int16_t extract_port
__P((const struct sockaddr
*addr
));
93 extern u_int16_t
*set_port
__P((struct sockaddr
*addr
, u_int16_t new_port
));
94 extern u_int16_t
*get_port_ptr
__P((struct sockaddr
*addr
));
96 #endif /* _SOCKMISC_H */