Annotation of embedaddon/ipsec-tools/src/racoon/sockmisc.h, revision 1.1.1.1
1.1 misho 1: /* $NetBSD: sockmisc.h,v 1.13 2011/03/14 17:18:13 tteras Exp $ */
2:
3: /* Id: sockmisc.h,v 1.9 2005/10/05 16:55:41 manubsd Exp */
4:
5: /*
6: * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7: * All rights reserved.
8: *
9: * Redistribution and use in source and binary forms, with or without
10: * modification, are permitted provided that the following conditions
11: * are met:
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.
20: *
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
31: * SUCH DAMAGE.
32: */
33:
34: #ifndef _SOCKMISC_H
35: #define _SOCKMISC_H
36:
37: #ifndef IP_IPSEC_POLICY
38: #define IP_IPSEC_POLICY 16 /* XXX: from linux/in.h */
39: #endif
40:
41: #ifndef IPV6_IPSEC_POLICY
42: #define IPV6_IPSEC_POLICY 34 /* XXX: from linux/???.h per
43: "Tom Lendacky" <toml@us.ibm.com> */
44: #endif
45:
46: union sockaddr_any {
47: struct sockaddr sa;
48: struct sockaddr_in sin;
49: struct sockaddr_in6 sin6;
50: };
51:
52: struct netaddr {
53: union sockaddr_any sa;
54: unsigned long prefix;
55: };
56:
57: extern const int niflags;
58:
59: #define CMPSADDR_MATCH 0
60: #define CMPSADDR_WILDPORT_MATCH 1
61: #define CMPSADDR_WOP_MATCH 2
62: #define CMPSADDR_MISMATCH 3
63:
64: extern int cmpsaddr __P((const struct sockaddr *, const struct sockaddr *));
65:
66: extern struct sockaddr *getlocaladdr __P((struct sockaddr *));
67:
68: extern int recvfromto __P((int, void *, size_t, int,
69: struct sockaddr *, socklen_t *, struct sockaddr *, unsigned int *));
70: extern int sendfromto __P((int, const void *, size_t,
71: struct sockaddr *, struct sockaddr *, int));
72:
73: extern int setsockopt_bypass __P((int, int));
74:
75: extern struct sockaddr *newsaddr __P((int));
76: extern struct sockaddr *dupsaddr __P((struct sockaddr *));
77: extern char *saddr2str __P((const struct sockaddr *));
78: extern char *saddrwop2str __P((const struct sockaddr *));
79: extern char *saddr2str_fromto __P((const char *format,
80: const struct sockaddr *saddr,
81: const struct sockaddr *daddr));
82: extern struct sockaddr *str2saddr __P((char *, char *));
83: extern void mask_sockaddr __P((struct sockaddr *, const struct sockaddr *,
84: size_t));
85:
86: /* struct netaddr functions */
87: extern char *naddrwop2str __P((const struct netaddr *naddr));
88: extern char *naddrwop2str_fromto __P((const char *format, const struct netaddr *saddr,
89: const struct netaddr *daddr));
90: extern int naddr_score(const struct netaddr *naddr, const struct sockaddr *saddr);
91:
92: /* Some useful functions for sockaddr port manipulations. */
93: extern u_int16_t extract_port __P((const struct sockaddr *addr));
94: extern u_int16_t *set_port __P((struct sockaddr *addr, u_int16_t new_port));
95: extern u_int16_t *get_port_ptr __P((struct sockaddr *addr));
96:
97: #endif /* _SOCKMISC_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>