1/*	$KAME: libpfkey.h,v 1.6 2001/03/05 18:22:17 thorpej 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
32struct sadb_msg;
33extern void pfkey_sadump __P((struct sadb_msg *));
34extern void pfkey_spdump __P((struct sadb_msg *));
35
36struct sockaddr;
37struct sadb_alg;
38int ipsec_check_keylen __P((u_int, u_int, u_int));
39int ipsec_check_keylen2 __P((u_int, u_int, u_int));
40int ipsec_get_keylen __P((u_int, u_int, struct sadb_alg *));
41u_int pfkey_set_softrate __P((u_int, u_int));
42u_int pfkey_get_softrate __P((u_int));
43int pfkey_send_getspi __P((int, u_int, u_int, struct sockaddr *,
44	struct sockaddr *, u_int32_t, u_int32_t, u_int32_t, u_int32_t));
45int pfkey_send_update __P((int, u_int, u_int, struct sockaddr *,
46	struct sockaddr *, u_int32_t, u_int32_t, u_int,
47	caddr_t, u_int, u_int, u_int, u_int, u_int, u_int32_t, u_int64_t,
48	u_int64_t, u_int64_t, u_int32_t));
49int pfkey_send_add __P((int, u_int, u_int, struct sockaddr *,
50	struct sockaddr *, u_int32_t, u_int32_t, u_int,
51	caddr_t, u_int, u_int, u_int, u_int, u_int, u_int32_t, u_int64_t,
52	u_int64_t, u_int64_t, u_int32_t));
53int pfkey_send_delete __P((int, u_int, u_int,
54	struct sockaddr *, struct sockaddr *, u_int32_t));
55int pfkey_send_delete_all __P((int, u_int, u_int,
56	struct sockaddr *, struct sockaddr *));
57int pfkey_send_get __P((int, u_int, u_int,
58	struct sockaddr *, struct sockaddr *, u_int32_t));
59int pfkey_send_register __P((int, u_int));
60int pfkey_recv_register __P((int));
61int pfkey_set_supported __P((struct sadb_msg *, int));
62int pfkey_send_flush __P((int, u_int));
63int pfkey_send_dump __P((int, u_int));
64int pfkey_send_promisc_toggle __P((int, int));
65int pfkey_send_spdadd __P((int, struct sockaddr *, u_int,
66	struct sockaddr *, u_int, u_int, caddr_t, int, u_int32_t));
67int pfkey_send_spdadd2 __P((int, struct sockaddr *, u_int,
68	struct sockaddr *, u_int, u_int, u_int64_t, u_int64_t,
69	caddr_t, int, u_int32_t));
70int pfkey_send_spdupdate __P((int, struct sockaddr *, u_int,
71	struct sockaddr *, u_int, u_int, caddr_t, int, u_int32_t));
72int pfkey_send_spdupdate2 __P((int, struct sockaddr *, u_int,
73	struct sockaddr *, u_int, u_int, u_int64_t, u_int64_t,
74	caddr_t, int, u_int32_t));
75int pfkey_send_spddelete __P((int, struct sockaddr *, u_int,
76	struct sockaddr *, u_int, u_int, caddr_t, int, u_int32_t));
77int pfkey_send_spddelete2 __P((int, u_int32_t));
78int pfkey_send_spdget __P((int, u_int32_t));
79int pfkey_send_spdsetidx __P((int, struct sockaddr *, u_int,
80	struct sockaddr *, u_int, u_int, caddr_t, int, u_int32_t));
81int pfkey_send_spdflush __P((int));
82int pfkey_send_spddump __P((int));
83
84int pfkey_open __P((void));
85void pfkey_close __P((int));
86struct sadb_msg *pfkey_recv __P((int));
87int pfkey_send __P((int, struct sadb_msg *, int));
88int pfkey_align __P((struct sadb_msg *, caddr_t *));
89int pfkey_check __P((caddr_t *));
90
91#include "libipsec.h"
92
93#ifndef __SYSDEP_SA_LEN__
94#define __SYSDEP_SA_LEN__
95#include <netinet/in.h>
96#include <linux/in6.h>
97#define IPPROTO_IPV4 IPPROTO_IPIP
98static inline u_int8_t
99sysdep_sa_len (struct sockaddr *sa)
100{
101  switch (sa->sa_family)
102    {
103    case AF_INET:
104      return sizeof (struct sockaddr_in);
105    case AF_INET6:
106      return sizeof (struct sockaddr_in6);
107    }
108  // log_print ("sysdep_sa_len: unknown sa family %d", sa->sa_family);
109  return sizeof (struct sockaddr_in);
110}
111#endif
112