1 #ifndef _IPSEC_POLICY_H
3 * policy interface file between pluto and applications
4 * Copyright (C) 2003 Michael Richardson <mcr@freeswan.org>
6 * This library is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Library General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/lgpl.txt>.
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 * License for more details.
18 #define _IPSEC_POLICY_H /* seen it, no need to see it again */
22 * this file defines an interface between an application (or rather an
23 * application library) and a key/policy daemon. It provides for inquiries
24 * as to the current state of a connected socket, as well as for general
27 * In general, the interface is defined as a series of functional interfaces,
28 * and the policy messages should be internal. However, because this is in
29 * fact an ABI between pieces of the system that may get compiled and revised
30 * seperately, this ABI must be public and revision controlled.
32 * It is expected that the daemon will always support previous versions.
35 #define IPSEC_POLICY_MSG_REVISION (unsigned)200305061
37 enum ipsec_policy_command
{
38 IPSEC_CMD_QUERY_FD
= 1,
39 IPSEC_CMD_QUERY_HOSTPAIR
= 2,
40 IPSEC_CMD_QUERY_DSTONLY
= 3,
43 struct ipsec_policy_msg_head
{
44 u_int32_t ipm_version
;
45 u_int32_t ipm_msg_len
;
46 u_int32_t ipm_msg_type
;
47 u_int32_t ipm_msg_seq
;
50 enum ipsec_privacy_quality
{
51 IPSEC_PRIVACY_NONE
= 0,
52 IPSEC_PRIVACY_INTEGRAL
= 4, /* not private at all. AH-like */
53 IPSEC_PRIVACY_UNKNOWN
= 8, /* something is claimed, but details unavail */
54 IPSEC_PRIVACY_ROT13
= 12, /* trivially breakable, i.e. 1DES */
55 IPSEC_PRIVACY_GAK
= 16, /* known eavesdroppers */
56 IPSEC_PRIVACY_PRIVATE
= 32, /* secure for at least a decade */
57 IPSEC_PRIVACY_STRONG
= 64, /* ridiculously secure */
58 IPSEC_PRIVACY_TORTOISE
= 192, /* even stronger, but very slow */
59 IPSEC_PRIVACY_OTP
= 224, /* some kind of *true* one time pad */
62 enum ipsec_bandwidth_quality
{
63 IPSEC_QOS_UNKNOWN
= 0, /* unknown bandwidth */
64 IPSEC_QOS_INTERACTIVE
= 16, /* reasonably moderate jitter, moderate fast.
65 Good enough for telnet/ssh. */
66 IPSEC_QOS_VOIP
= 32, /* faster crypto, predicable jitter */
67 IPSEC_QOS_FTP
= 64, /* higher throughput crypto, perhaps hardware
68 offloaded, but latency/jitter may be bad */
69 IPSEC_QOS_WIRESPEED
= 128, /* expect to be able to fill your pipe */
72 /* moved from programs/pluto/constants.h */
73 /* IPsec AH transform values
74 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.3
75 * and in http://www.iana.org/assignments/isakmp-registry
77 enum ipsec_authentication_algo
{
90 /* IPsec ESP transform values
91 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.4
92 * and from http://www.iana.org/assignments/isakmp-registry
95 enum ipsec_cipher_algo
{
113 ESP_UNASSIGNED_17
= 17,
123 /* IPCOMP transform values
124 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.5
127 enum ipsec_comp_algo
{
135 /* Identification type values
136 * RFC 2407 The Internet IP security Domain of Interpretation for ISAKMP 4.6.2.1
140 ID_IMPOSSIBLE
= (-2), /* private to Pluto */
141 ID_MYID
= (-1), /* private to Pluto */
142 ID_NONE
= 0, /* private to Pluto */
146 ID_IPV4_ADDR_SUBNET
= 4,
148 ID_IPV6_ADDR_SUBNET
= 6,
149 ID_IPV4_ADDR_RANGE
= 7,
150 ID_IPV6_ADDR_RANGE
= 8,
156 /* Certificate type values
157 * RFC 2408 ISAKMP, chapter 3.9
159 enum ipsec_cert_type
{
161 CERT_PKCS7_WRAPPED_X509
= 1,
163 CERT_DNS_SIGNED_KEY
= 3,
164 CERT_X509_SIGNATURE
= 4,
165 CERT_X509_KEY_EXCHANGE
= 5,
166 CERT_KERBEROS_TOKENS
= 6,
170 CERT_X509_ATTRIBUTE
= 10,
174 /* a SIG record in ASCII */
175 struct ipsec_dns_sig
{
177 char dns_sig
[768]; /* empty string if not signed */
180 struct ipsec_raw_key
{
185 struct ipsec_identity
{
186 enum ipsec_id_type ii_type
;
187 enum ipsec_cert_type ii_format
;
189 struct ipsec_dns_sig ipsec_dns_signed
;
190 /* some thing for PGP */
191 /* some thing for PKIX */
192 struct ipsec_raw_key ipsec_raw_key
;
196 #define IPSEC_MAX_CREDENTIALS 32
198 struct ipsec_policy_cmd_query
{
199 struct ipsec_policy_msg_head head
;
202 ip_address query_local
; /* us */
203 ip_address query_remote
; /* them */
204 u_short src_port
, dst_port
;
207 enum ipsec_privacy_quality strength
;
208 enum ipsec_bandwidth_quality bandwidth
;
209 enum ipsec_authentication_algo auth_detail
;
210 enum ipsec_cipher_algo esp_detail
;
211 enum ipsec_comp_algo comp_detail
;
213 int credential_count
;
215 struct ipsec_identity credentials
[IPSEC_MAX_CREDENTIALS
];
218 #define IPSEC_POLICY_SOCKET "/var/run/pluto.info"
221 extern err_t
ipsec_policy_lookup(int fd
, struct ipsec_policy_cmd_query
*result
);
222 extern err_t
ipsec_policy_init(void);
223 extern err_t
ipsec_policy_final(void);
224 extern err_t
ipsec_policy_readmsg(int policysock
,
225 unsigned char *buf
, size_t buflen
);
226 extern err_t
ipsec_policy_sendrecv(unsigned char *buf
, size_t buflen
);
227 extern err_t
ipsec_policy_cgilookup(struct ipsec_policy_cmd_query
*result
);
230 extern const char *ipsec_policy_version_code(void);
231 extern const char *ipsec_policy_version_string(void);
233 #endif /* _IPSEC_POLICY_H */