]> git.saurik.com Git - apple/ipsec.git/blame - ipsec-tools/Common/libpfkey.h
ipsec-292.40.4.tar.gz
[apple/ipsec.git] / ipsec-tools / Common / libpfkey.h
CommitLineData
52b7d2ce
A
1/* $Id: libpfkey.h,v 1.8.2.4 2005/12/04 20:41:47 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 _LIBPFKEY_H
33#define _LIBPFKEY_H
34
35#ifndef KAME_LIBPFKEY_H
36#define KAME_LIBPFKEY_H
37
38#include "config.h"
39
40#define PRIORITY_LOW 0xC0000000
41#define PRIORITY_DEFAULT 0x80000000
42#define PRIORITY_HIGH 0x40000000
43
44#define PRIORITY_OFFSET_POSITIVE_MAX 0x3fffffff
45#define PRIORITY_OFFSET_NEGATIVE_MAX 0x40000000
46
47struct sadb_msg;
65c25746
A
48extern void pfkey_sadump (struct sadb_msg *);
49extern void pfkey_sadump_withports (struct sadb_msg *);
50extern void pfkey_spdump (struct sadb_msg *);
51extern void pfkey_spdump_withports (struct sadb_msg *);
52b7d2ce 52
85f41bec 53struct sockaddr_storage;
52b7d2ce
A
54struct sadb_alg;
55
56/* Accomodate different prototypes in <netinet6/ipsec.h> */
57#include <sys/types.h>
58#ifdef HAVE_NETINET6_IPSEC
59# include <netinet6/ipsec.h>
60#else
61# include <netinet/ipsec.h>
62#endif
63
64#ifndef HAVE_IPSEC_POLICY_T
65typedef caddr_t ipsec_policy_t;
66#define __ipsec_const
67#else
68#define __ipsec_const const
69#endif
70
71/* IPsec Library Routines */
72
65c25746
A
73int ipsec_check_keylen (u_int, u_int, u_int);
74int ipsec_check_keylen2 (u_int, u_int, u_int);
75int ipsec_get_keylen (u_int, u_int, struct sadb_alg *);
76char *ipsec_dump_policy_withports (void *, const char *);
77void ipsec_hexdump (const void *, int);
78const char *ipsec_strerror (void);
79void kdebug_sadb (struct sadb_msg *);
80ipsec_policy_t ipsec_set_policy (__ipsec_const char *, int);
81int ipsec_get_policylen (ipsec_policy_t);
82char *ipsec_dump_policy (ipsec_policy_t, __ipsec_const char *);
52b7d2ce
A
83
84/* PFKey Routines */
85
65c25746
A
86u_int pfkey_set_softrate (u_int, u_int);
87u_int pfkey_get_softrate (u_int);
88int pfkey_send_getspi (int, u_int, u_int, struct sockaddr_storage *,
89 struct sockaddr_storage *, u_int32_t, u_int32_t, u_int32_t, u_int, u_int64_t, u_int32_t, u_int);
90int pfkey_send_update (int, u_int, u_int, struct sockaddr_storage *,
85f41bec 91 struct sockaddr_storage *, u_int32_t, u_int32_t, u_int,
52b7d2ce 92 caddr_t, u_int, u_int, u_int, u_int, u_int, u_int32_t, u_int64_t,
65c25746
A
93 u_int64_t, u_int64_t, u_int32_t, u_int16_t, u_int);
94int pfkey_send_add (int, u_int, u_int, struct sockaddr_storage *,
85f41bec 95 struct sockaddr_storage *, u_int32_t, u_int32_t, u_int,
52b7d2ce 96 caddr_t, u_int, u_int, u_int, u_int, u_int, u_int32_t, u_int64_t,
65c25746
A
97 u_int64_t, u_int64_t, u_int32_t, u_int16_t, u_int);
98
99int pfkey_send_delete (int, u_int, u_int,
100 struct sockaddr_storage *, struct sockaddr_storage *, u_int32_t);
101int pfkey_send_delete_all (int, u_int, u_int,
102 struct sockaddr_storage *, struct sockaddr_storage *);
103int pfkey_send_get (int, u_int, u_int,
104 struct sockaddr_storage *, struct sockaddr_storage *, u_int32_t);
105int pfkey_send_register (int, u_int);
106int pfkey_recv_register (int);
107int pfkey_set_supported (struct sadb_msg *, int);
108int pfkey_send_flush (int, u_int);
109int pfkey_send_dump (int, u_int);
110int pfkey_send_promisc_toggle (int, int);
111int pfkey_send_spdadd (int, struct sockaddr_storage *, u_int,
112 struct sockaddr_storage *, u_int, u_int, caddr_t, int, u_int32_t);
113int pfkey_send_spdadd_with_interface(int, struct sockaddr_storage *,
114 struct sockaddr_storage *, u_int, struct sockaddr_storage *,
115 struct sockaddr_storage *, u_int, u_int, caddr_t, int, u_int32_t, char *,
116 char *, char *, u_int);
117int pfkey_send_spdadd2 (int, struct sockaddr_storage *, u_int,
85f41bec 118 struct sockaddr_storage *, u_int, u_int, u_int64_t, u_int64_t,
65c25746
A
119 caddr_t, int, u_int32_t);
120int pfkey_send_spdupdate (int, struct sockaddr_storage *, u_int,
121 struct sockaddr_storage *, u_int, u_int, caddr_t, int, u_int32_t);
122int pfkey_send_spdupdate2 (int, struct sockaddr_storage *, u_int,
85f41bec 123 struct sockaddr_storage *, u_int, u_int, u_int64_t, u_int64_t,
65c25746
A
124 caddr_t, int, u_int32_t);
125int pfkey_send_spddelete (int, struct sockaddr_storage *, u_int,
126 struct sockaddr_storage *, u_int, u_int, caddr_t, int, u_int32_t);
127int pfkey_send_spddelete2 (int, u_int32_t);
128int pfkey_send_spdenable(int so, u_int32_t spid);
129int pfkey_send_spddisable(int so, u_int32_t spid);
130int pfkey_send_spdget (int, u_int32_t);
131int pfkey_send_spdsetidx (int, struct sockaddr_storage *, u_int,
132 struct sockaddr_storage *, u_int, u_int, caddr_t, int, u_int32_t);
133int pfkey_send_spdflush (int);
134int pfkey_send_spddump (int);
135
136int pfkey_open (void);
137void pfkey_close (void);
138void pfkey_close_sock(int);
139struct sadb_msg *pfkey_recv (int);
140int pfkey_send (int, struct sadb_msg *, int);
141int pfkey_align (struct sadb_msg *, caddr_t *);
142int pfkey_check (caddr_t *);
143int pfkey_send_getsastats (int, u_int32_t, u_int64_t [], u_int32_t, u_int8_t, struct sastat [], u_int32_t);
52b7d2ce
A
144
145#ifndef __SYSDEP_SA_LEN__
146#define __SYSDEP_SA_LEN__
147#include <netinet/in.h>
148
149#ifndef IPPROTO_IPV4
150#define IPPROTO_IPV4 IPPROTO_IPIP
151#endif
152
153#ifndef IPPROTO_IPCOMP
154#define IPPROTO_IPCOMP IPPROTO_COMP
155#endif
156
157static __inline u_int8_t
158sysdep_sa_len (const struct sockaddr *sa)
159{
52b7d2ce 160 return sa->sa_len;
52b7d2ce
A
161}
162#endif
163
164#endif /* KAME_LIBPFKEY_H */
165
166#endif /* _LIBPFKEY_H */