]> git.saurik.com Git - apple/ipsec.git/blame - ipsec-tools/racoon/sockmisc.h
ipsec-34.0.3.tar.gz
[apple/ipsec.git] / ipsec-tools / racoon / sockmisc.h
CommitLineData
52b7d2ce
A
1/* $Id: sockmisc.h,v 1.5.10.4 2005/10/04 09:54:27 manubsd Exp $ */
2
3/*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#ifndef _SOCKMISC_H
33#define _SOCKMISC_H
34
35struct netaddr {
36 union {
37 struct sockaddr sa;
38 struct sockaddr_in sin;
39 struct sockaddr_in6 sin6;
40 } sa;
41 unsigned long prefix;
42};
43
44extern const int niflags;
45
46extern int cmpsaddrwop __P((const struct sockaddr *, const struct sockaddr *));
47extern int cmpsaddrwild __P((const struct sockaddr *, const struct sockaddr *));
48extern int cmpsaddrstrict __P((const struct sockaddr *, const struct sockaddr *));
49
50#ifdef ENABLE_NATT
51#define CMPSADDR(saddr1, saddr2) cmpsaddrstrict((saddr1), (saddr2))
52#else
53#define CMPSADDR(saddr1, saddr2) cmpsaddrwop((saddr1), (saddr2))
54#endif
55
56extern struct sockaddr *getlocaladdr __P((struct sockaddr *));
57
58extern int recvfromto __P((int, void *, size_t, int,
59 struct sockaddr *, socklen_t *, struct sockaddr *, unsigned int *));
60extern int sendfromto __P((int, const void *, size_t,
61 struct sockaddr *, struct sockaddr *, int));
62
63extern int setsockopt_bypass __P((int, int));
64
65extern struct sockaddr *newsaddr __P((int));
66extern struct sockaddr *dupsaddr __P((struct sockaddr *));
67extern char *saddr2str __P((const struct sockaddr *));
68extern char *saddrwop2str __P((const struct sockaddr *));
69extern char *saddr2str_fromto __P((const char *format,
70 const struct sockaddr *saddr,
71 const struct sockaddr *daddr));
72extern struct sockaddr *str2saddr __P((char *, char *));
73extern void mask_sockaddr __P((struct sockaddr *, const struct sockaddr *,
74 size_t));
75
76/* struct netaddr functions */
77extern char *naddrwop2str __P((const struct netaddr *naddr));
78extern char *naddrwop2str_fromto __P((const char *format, const struct netaddr *saddr,
79 const struct netaddr *daddr));
80extern int naddr_score(const struct netaddr *naddr, const struct sockaddr *saddr);
81
82/* Some usefull functions for sockaddr port manipulations. */
83extern u_int16_t extract_port __P((const struct sockaddr *addr));
84extern u_int16_t *set_port __P((struct sockaddr *addr, u_int16_t new_port));
85extern u_int16_t *get_port_ptr __P((struct sockaddr *addr));
86
87#endif /* _SOCKMISC_H */