1 /* $NetBSD: strnames.c,v 1.7.6.1 2007/08/01 11:52:22 vanhu Exp $ */
3 /* $KAME: strnames.c,v 1.25 2003/11/13 10:53:26 itojun Exp $ */
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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.
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
36 #include <sys/types.h>
37 #include <sys/param.h>
38 #include <sys/socket.h>
40 #include <netinet/in.h>
41 #ifdef HAVE_NETINET6_IPSEC
42 # include <netinet6/ipsec.h>
44 # include <netinet/ipsec.h>
46 #include <netinet/in.h>
60 #include "isakmp_var.h"
63 # include "isakmp_xauth.h"
64 # include "isakmp_unity.h"
65 # include "isakmp_cfg.h"
67 #include "ipsec_doi.h"
72 #include "algorithm.h"
86 snprintf(buf
, sizeof(buf
), "%d", n
);
93 s_isakmp_state(t
, d
, s
)
97 case IKEV1_STATE_PHASE1_ESTABLISHED
:
98 return "Phase 1 Established";
99 case IKEV1_STATE_PHASE2_ESTABLISHED
:
100 return "Phase 2 established";
101 case IKEV1_STATE_PHASE1_EXPIRED
:
102 return "Phase 1 expired";
103 case IKEV1_STATE_PHASE2_EXPIRED
:
104 return "Phase 2 expired";
105 case IKEV1_STATE_INFO
:
107 case IKEV1_STATE_IDENT_I_START
:
108 return "IKEv1 ident I start";
109 case IKEV1_STATE_IDENT_I_MSG1SENT
:
110 return "IKEv1 ident I msg1 sent";
111 case IKEV1_STATE_IDENT_I_MSG2RCVD
:
112 return "IKEv1 ident I msg2 rcvd";
113 case IKEV1_STATE_IDENT_I_MSG3SENT
:
114 return "IKEv1 ident I msg3 sent";
115 case IKEV1_STATE_IDENT_I_MSG4RCVD
:
116 return "IKEv1 ident I msg4 rcvd";
117 case IKEV1_STATE_IDENT_I_MSG5SENT
:
118 return "IKEv1 ident I msg5 sent";
119 case IKEV1_STATE_IDENT_I_MSG6RCVD
:
120 return "IKEv1 ident I msg6 rcvd";
122 case IKEV1_STATE_IDENT_R_START
:
123 return "IKEv1 ident R start";
124 case IKEV1_STATE_IDENT_R_MSG1RCVD
:
125 return "IKEv1 ident R msg1 rcvd";
126 case IKEV1_STATE_IDENT_R_MSG2SENT
:
127 return "IKEv1 ident R msg2 sent";
128 case IKEV1_STATE_IDENT_R_MSG3RCVD
:
129 return "IKEv1 ident R msg3 rcvd";
130 case IKEV1_STATE_IDENT_R_MSG4SENT
:
131 return "IKEv1 ident R msg4 sent";
132 case IKEV1_STATE_IDENT_R_MSG5RCVD
:
133 return "IKEv1 ident R msg5 rcvd";
135 case IKEV1_STATE_AGG_I_START
:
136 return "IKEv1 agg I start";
137 case IKEV1_STATE_AGG_I_MSG1SENT
:
138 return "IKEv1 agg I msg1 sent";
139 case IKEV1_STATE_AGG_I_MSG2RCVD
:
140 return "IKEv1 agg I msg2 rcvd";
141 case IKEV1_STATE_AGG_I_MSG3SENT
:
142 return "IKEv1 agg I msg3 sent";
143 case IKEV1_STATE_AGG_R_START
:
144 return "IKEv1 agg R start";
145 case IKEV1_STATE_AGG_R_MSG1RCVD
:
146 return "IKEv1 agg R msg1 rcvd";
147 case IKEV1_STATE_AGG_R_MSG2SENT
:
148 return "IKEv1 agg R msg2 sent";
149 case IKEV1_STATE_AGG_R_MSG3RCVD
:
150 return "IKEv1 agg R msg3 rcvd";
152 case IKEV1_STATE_QUICK_I_START
:
153 return "IKEv1 quick I start";
154 case IKEV1_STATE_QUICK_I_GETSPISENT
:
155 return "IKEv1 quick I getspi sent";
156 case IKEV1_STATE_QUICK_I_GETSPIDONE
:
157 return "IKEv1 quick I getspi done";
158 case IKEV1_STATE_QUICK_I_MSG1SENT
:
159 return "IKEv1 quick I msg1 sent";
160 case IKEV1_STATE_QUICK_I_MSG2RCVD
:
161 return "IKEv1 quick I msg2 rcvd";
162 case IKEV1_STATE_QUICK_I_MSG3SENT
:
163 return "IKEv1 quick I msg3 sent";
164 case IKEV1_STATE_QUICK_I_ADDSA
:
165 return "IKEv1 quick I addsa";
166 case IKEV1_STATE_QUICK_R_START
:
167 return "IKEv1 quick R start";
168 case IKEV1_STATE_QUICK_R_MSG1RCVD
:
169 return "IKEv1 quick R msg1 rcvd";
170 case IKEV1_STATE_QUICK_R_GETSPISENT
:
171 return "IKEv1 quick R getspi sent";
172 case IKEV1_STATE_QUICK_R_GETSPIDONE
:
173 return "IKEv1 quick R getspi done";
174 case IKEV1_STATE_QUICK_R_MSG2SENT
:
175 return "IKEv1 quick R msg2 sent";
176 case IKEV1_STATE_QUICK_R_MSG3RCVD
:
177 return "IKEv1 quick R msg3 rcvd";
178 case IKEV1_STATE_QUICK_R_COMMIT
:
179 return "IKEv1 quick R commit";
180 case IKEV1_STATE_QUICK_R_ADDSA
:
181 return "IKEv1 quick R addsa";
187 static struct ksmap name_isakmp_certtype
[] = {
188 { ISAKMP_CERT_NONE
, "NONE", NULL
},
189 { ISAKMP_CERT_PKCS7
, "PKCS #7 wrapped X.509 certificate", NULL
},
190 { ISAKMP_CERT_PGP
, "PGP Certificate", NULL
},
191 { ISAKMP_CERT_DNS
, "DNS Signed Key", NULL
},
192 { ISAKMP_CERT_X509SIGN
, "X.509 Certificate Signature", NULL
},
193 { ISAKMP_CERT_X509KE
, "X.509 Certificate Key Exchange", NULL
},
194 { ISAKMP_CERT_KERBEROS
, "Kerberos Tokens", NULL
},
195 { ISAKMP_CERT_CRL
, "Certificate Revocation List (CRL)", NULL
},
196 { ISAKMP_CERT_ARL
, "Authority Revocation List (ARL)", NULL
},
197 { ISAKMP_CERT_SPKI
, "SPKI Certificate", NULL
},
198 { ISAKMP_CERT_X509ATTR
, "X.509 Certificate Attribute", NULL
},
206 for (i
= 0; i
< ARRAYLEN(name_isakmp_certtype
); i
++)
207 if (name_isakmp_certtype
[i
].key
== k
)
208 return name_isakmp_certtype
[i
].str
;
212 static struct ksmap name_isakmp_etype
[] = {
213 { ISAKMP_ETYPE_NONE
, "None", NULL
},
214 { ISAKMP_ETYPE_BASE
, "Base", NULL
},
215 { ISAKMP_ETYPE_IDENT
, "Identity Protection", NULL
},
216 { ISAKMP_ETYPE_AUTH
, "Authentication Only", NULL
},
217 { ISAKMP_ETYPE_AGG
, "Aggressive", NULL
},
218 { ISAKMP_ETYPE_INFO
, "Informational", NULL
},
219 { ISAKMP_ETYPE_CFG
, "Mode config", NULL
},
220 { ISAKMP_ETYPE_QUICK
, "Quick", NULL
},
221 { ISAKMP_ETYPE_NEWGRP
, "New Group", NULL
},
222 { ISAKMP_ETYPE_ACKINFO
, "Acknowledged Informational", NULL
},
230 for (i
= 0; i
< ARRAYLEN(name_isakmp_etype
); i
++)
231 if (name_isakmp_etype
[i
].key
== k
)
232 return name_isakmp_etype
[i
].str
;
236 static struct ksmap name_isakmp_notify_msg
[] = {
237 { ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE
, "INVALID-PAYLOAD-TYPE", NULL
},
238 { ISAKMP_NTYPE_DOI_NOT_SUPPORTED
, "DOI-NOT-SUPPORTED", NULL
},
239 { ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED
, "SITUATION-NOT-SUPPORTED", NULL
},
240 { ISAKMP_NTYPE_INVALID_COOKIE
, "INVALID-COOKIE", NULL
},
241 { ISAKMP_NTYPE_INVALID_MAJOR_VERSION
, "INVALID-MAJOR-VERSION", NULL
},
242 { ISAKMP_NTYPE_INVALID_MINOR_VERSION
, "INVALID-MINOR-VERSION", NULL
},
243 { ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE
, "INVALID-EXCHANGE-TYPE", NULL
},
244 { ISAKMP_NTYPE_INVALID_FLAGS
, "INVALID-FLAGS", NULL
},
245 { ISAKMP_NTYPE_INVALID_MESSAGE_ID
, "INVALID-MESSAGE-ID", NULL
},
246 { ISAKMP_NTYPE_INVALID_PROTOCOL_ID
, "INVALID-PROTOCOL-ID", NULL
},
247 { ISAKMP_NTYPE_INVALID_SPI
, "INVALID-SPI", NULL
},
248 { ISAKMP_NTYPE_INVALID_TRANSFORM_ID
, "INVALID-TRANSFORM-ID", NULL
},
249 { ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED
, "ATTRIBUTES-NOT-SUPPORTED", NULL
},
250 { ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN
, "NO-PROPOSAL-CHOSEN", NULL
},
251 { ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX
, "BAD-PROPOSAL-SYNTAX", NULL
},
252 { ISAKMP_NTYPE_PAYLOAD_MALFORMED
, "PAYLOAD-MALFORMED", NULL
},
253 { ISAKMP_NTYPE_INVALID_KEY_INFORMATION
, "INVALID-KEY-INFORMATION", NULL
},
254 { ISAKMP_NTYPE_INVALID_ID_INFORMATION
, "INVALID-ID-INFORMATION", NULL
},
255 { ISAKMP_NTYPE_INVALID_CERT_ENCODING
, "INVALID-CERT-ENCODING", NULL
},
256 { ISAKMP_NTYPE_INVALID_CERTIFICATE
, "INVALID-CERTIFICATE", NULL
},
257 { ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX
, "BAD-CERT-REQUEST-SYNTAX", NULL
},
258 { ISAKMP_NTYPE_INVALID_CERT_AUTHORITY
, "INVALID-CERT-AUTHORITY", NULL
},
259 { ISAKMP_NTYPE_INVALID_HASH_INFORMATION
, "INVALID-HASH-INFORMATION", NULL
},
260 { ISAKMP_NTYPE_AUTHENTICATION_FAILED
, "AUTHENTICATION-FAILED", NULL
},
261 { ISAKMP_NTYPE_INVALID_SIGNATURE
, "INVALID-SIGNATURE", NULL
},
262 { ISAKMP_NTYPE_ADDRESS_NOTIFICATION
, "ADDRESS-NOTIFICATION", NULL
},
263 { ISAKMP_NTYPE_NOTIFY_SA_LIFETIME
, "NOTIFY-SA-LIFETIME", NULL
},
264 { ISAKMP_NTYPE_CERTIFICATE_UNAVAILABLE
, "CERTIFICATE-UNAVAILABLE", NULL
},
265 { ISAKMP_NTYPE_UNSUPPORTED_EXCHANGE_TYPE
, "UNSUPPORTED-EXCHANGE-TYPE", NULL
},
266 { ISAKMP_NTYPE_UNEQUAL_PAYLOAD_LENGTHS
, "UNEQUAL-PAYLOAD-LENGTHS", NULL
},
267 { ISAKMP_NTYPE_CONNECTED
, "CONNECTED", NULL
},
268 { ISAKMP_NTYPE_RESPONDER_LIFETIME
, "RESPONDER-LIFETIME", NULL
},
269 { ISAKMP_NTYPE_REPLAY_STATUS
, "REPLAY-STATUS", NULL
},
270 { ISAKMP_NTYPE_INITIAL_CONTACT
, "INITIAL-CONTACT", NULL
},
272 { ISAKMP_NTYPE_UNITY_HEARTBEAT
, "HEARTBEAT (Unity)", NULL
},
274 { ISAKMP_LOG_RETRY_LIMIT_REACHED
, "RETRY-LIMIT-REACHED", NULL
},
278 s_isakmp_notify_msg(k
)
282 for (i
= 0; i
< ARRAYLEN(name_isakmp_notify_msg
); i
++)
283 if (name_isakmp_notify_msg
[i
].key
== k
)
284 return name_isakmp_notify_msg
[i
].str
;
289 static struct ksmap name_isakmp_nptype
[] = {
290 { ISAKMP_NPTYPE_NONE
, "none", NULL
},
291 { ISAKMP_NPTYPE_SA
, "sa", NULL
},
292 { ISAKMP_NPTYPE_P
, "prop", NULL
},
293 { ISAKMP_NPTYPE_T
, "trns", NULL
},
294 { ISAKMP_NPTYPE_KE
, "ke", NULL
},
295 { ISAKMP_NPTYPE_ID
, "id", NULL
},
296 { ISAKMP_NPTYPE_CERT
, "cert", NULL
},
297 { ISAKMP_NPTYPE_CR
, "cr", NULL
},
298 { ISAKMP_NPTYPE_HASH
, "hash", NULL
},
299 { ISAKMP_NPTYPE_SIG
, "sig", NULL
},
300 { ISAKMP_NPTYPE_NONCE
, "nonce", NULL
},
301 { ISAKMP_NPTYPE_N
, "notify", NULL
},
302 { ISAKMP_NPTYPE_D
, "delete", NULL
},
303 { ISAKMP_NPTYPE_VID
, "vid", NULL
},
304 { ISAKMP_NPTYPE_ATTR
, "attr", NULL
},
305 { ISAKMP_NPTYPE_GSS
, "gss id", NULL
},
306 { ISAKMP_NPTYPE_NATD_RFC
, "nat-d", NULL
},
307 { ISAKMP_NPTYPE_NATOA_RFC
, "nat-oa", NULL
},
308 { ISAKMP_NPTYPE_NATD_DRAFT
, "nat-d", NULL
},
309 { ISAKMP_NPTYPE_NATOA_DRAFT
, "nat-oa", NULL
},
310 { ISAKMP_NPTYPE_FRAG
, "ike frag", NULL
},
318 for (i
= 0; i
< ARRAYLEN(name_isakmp_nptype
); i
++)
319 if (name_isakmp_nptype
[i
].key
== k
)
320 return name_isakmp_nptype
[i
].str
;
325 /* isakmp_cfg.h / isakmp_unity.h / isakmp_xauth.h */
326 static struct ksmap name_isakmp_cfg_type
[] = {
327 { INTERNAL_IP4_ADDRESS
, "INTERNAL_IP4_ADDRESS", NULL
},
328 { INTERNAL_IP4_NETMASK
, "INTERNAL_IP4_NETMASK", NULL
},
329 { INTERNAL_IP4_DNS
, "INTERNAL_IP4_DNS", NULL
},
330 { INTERNAL_IP4_NBNS
, "INTERNAL_IP4_NBNS", NULL
},
331 { INTERNAL_ADDRESS_EXPIRY
, "INTERNAL_ADDRESS_EXPIRY", NULL
},
332 { INTERNAL_IP4_DHCP
, "INTERNAL_IP4_DHCP", NULL
},
333 { APPLICATION_VERSION
, "APPLICATION_VERSION", NULL
},
334 { INTERNAL_IP6_ADDRESS
, "INTERNAL_IP6_ADDRESS", NULL
},
335 { INTERNAL_IP6_NETMASK
, "INTERNAL_IP6_NETMASK", NULL
},
336 { INTERNAL_IP6_DNS
, "INTERNAL_IP6_DNS", NULL
},
337 { INTERNAL_IP6_NBNS
, "INTERNAL_IP6_NBNS", NULL
},
338 { INTERNAL_IP6_DHCP
, "INTERNAL_IP6_DHCP", NULL
},
339 { INTERNAL_IP4_SUBNET
, "INTERNAL_IP4_SUBNET", NULL
},
340 { SUPPORTED_ATTRIBUTES
, "SUPPORTED_ATTRIBUTES", NULL
},
341 { INTERNAL_IP6_SUBNET
, "INTERNAL_IP6_SUBNET", NULL
},
342 { XAUTH_TYPE
, "XAUTH_TYPE", NULL
},
343 { XAUTH_USER_NAME
, "XAUTH_USER_NAME", NULL
},
344 { XAUTH_USER_PASSWORD
, "XAUTH_USER_PASSWORD", NULL
},
345 { XAUTH_PASSCODE
, "XAUTH_PASSCODE", NULL
},
346 { XAUTH_MESSAGE
, "XAUTH_MESSAGE", NULL
},
347 { XAUTH_CHALLENGE
, "XAUTH_CHALLENGE", NULL
},
348 { XAUTH_DOMAIN
, "XAUTH_DOMAIN", NULL
},
349 { XAUTH_STATUS
, "XAUTH_STATUS", NULL
},
350 { XAUTH_NEXT_PIN
, "XAUTH_NEXT_PIN", NULL
},
351 { XAUTH_ANSWER
, "XAUTH_ANSWER", NULL
},
352 { UNITY_BANNER
, "UNITY_BANNER", NULL
},
353 { UNITY_SAVE_PASSWD
, "UNITY_SAVE_PASSWD", NULL
},
354 { UNITY_DEF_DOMAIN
, "UNITY_DEF_DOMAIN", NULL
},
355 { UNITY_SPLITDNS_NAME
, "UNITY_SPLITDNS_NAME", NULL
},
356 { UNITY_SPLIT_INCLUDE
, "UNITY_SPLIT_INCLUDE", NULL
},
357 { UNITY_NATT_PORT
, "UNITY_NATT_PORT", NULL
},
358 { UNITY_LOCAL_LAN
, "UNITY_LOCAL_LAN", NULL
},
359 { UNITY_PFS
, "UNITY_PFS", NULL
},
360 { UNITY_FW_TYPE
, "UNITY_FW_TYPE", NULL
},
361 { UNITY_BACKUP_SERVERS
, "UNITY_BACKUP_SERVERS", NULL
},
362 { UNITY_DDNS_HOSTNAME
, "UNITY_DDNS_HOSTNAME", NULL
},
370 for (i
= 0; i
< ARRAYLEN(name_isakmp_cfg_type
); i
++)
371 if (name_isakmp_cfg_type
[i
].key
== k
)
372 return name_isakmp_cfg_type
[i
].str
;
376 /* isakmp_cfg.h / isakmp_unity.h / isakmp_xauth.h */
377 static struct ksmap name_isakmp_cfg_ptype
[] = {
378 { ISAKMP_CFG_ACK
, "mode config ACK", NULL
},
379 { ISAKMP_CFG_SET
, "mode config SET", NULL
},
380 { ISAKMP_CFG_REQUEST
, "mode config REQUEST", NULL
},
381 { ISAKMP_CFG_REPLY
, "mode config REPLY", NULL
},
385 s_isakmp_cfg_ptype(k
)
389 for (i
= 0; i
< ARRAYLEN(name_isakmp_cfg_ptype
); i
++)
390 if (name_isakmp_cfg_ptype
[i
].key
== k
)
391 return name_isakmp_cfg_ptype
[i
].str
;
398 static struct ksmap name_ipsecdoi_proto
[] = {
399 { IPSECDOI_PROTO_ISAKMP
, "ISAKMP", s_ipsecdoi_trns_isakmp
},
400 { IPSECDOI_PROTO_IPSEC_AH
, "AH", s_ipsecdoi_trns_ah
},
401 { IPSECDOI_PROTO_IPSEC_ESP
, "ESP", s_ipsecdoi_trns_esp
},
402 { IPSECDOI_PROTO_IPCOMP
, "IPCOMP", s_ipsecdoi_trns_ipcomp
},
410 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
411 if (name_ipsecdoi_proto
[i
].key
== k
)
412 return name_ipsecdoi_proto
[i
].str
;
416 static struct ksmap name_ipsecdoi_trns_isakmp
[] = {
417 { IPSECDOI_KEY_IKE
, "IKE", NULL
},
421 s_ipsecdoi_trns_isakmp(k
)
425 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_isakmp
); i
++)
426 if (name_ipsecdoi_trns_isakmp
[i
].key
== k
)
427 return name_ipsecdoi_trns_isakmp
[i
].str
;
431 static struct ksmap name_ipsecdoi_trns_ah
[] = {
432 { IPSECDOI_AH_MD5
, "MD5", NULL
},
433 { IPSECDOI_AH_SHA
, "SHA", NULL
},
434 { IPSECDOI_AH_DES
, "DES", NULL
},
435 { IPSECDOI_AH_SHA256
, "SHA256", NULL
},
436 { IPSECDOI_AH_SHA384
, "SHA384", NULL
},
437 { IPSECDOI_AH_SHA512
, "SHA512", NULL
},
441 s_ipsecdoi_trns_ah(k
)
445 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ah
); i
++)
446 if (name_ipsecdoi_trns_ah
[i
].key
== k
)
447 return name_ipsecdoi_trns_ah
[i
].str
;
451 static struct ksmap name_ipsecdoi_trns_esp
[] = {
452 { IPSECDOI_ESP_DES_IV64
, "DES_IV64", NULL
},
453 { IPSECDOI_ESP_DES
, "DES", NULL
},
454 { IPSECDOI_ESP_3DES
, "3DES", NULL
},
455 { IPSECDOI_ESP_RC5
, "RC5", NULL
},
456 { IPSECDOI_ESP_IDEA
, "IDEA", NULL
},
457 { IPSECDOI_ESP_CAST
, "CAST", NULL
},
458 { IPSECDOI_ESP_BLOWFISH
, "BLOWFISH", NULL
},
459 { IPSECDOI_ESP_3IDEA
, "3IDEA", NULL
},
460 { IPSECDOI_ESP_DES_IV32
, "DES_IV32", NULL
},
461 { IPSECDOI_ESP_RC4
, "RC4", NULL
},
462 { IPSECDOI_ESP_NULL
, "NULL", NULL
},
463 { IPSECDOI_ESP_AES
, "AES", NULL
},
464 { IPSECDOI_ESP_TWOFISH
, "TWOFISH", NULL
},
468 s_ipsecdoi_trns_esp(k
)
472 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_esp
); i
++)
473 if (name_ipsecdoi_trns_esp
[i
].key
== k
)
474 return name_ipsecdoi_trns_esp
[i
].str
;
478 static struct ksmap name_ipsecdoi_trns_ipcomp
[] = {
479 { IPSECDOI_IPCOMP_OUI
, "OUI", NULL
},
480 { IPSECDOI_IPCOMP_DEFLATE
, "DEFLATE", NULL
},
481 { IPSECDOI_IPCOMP_LZS
, "LZS", NULL
},
485 s_ipsecdoi_trns_ipcomp(k
)
489 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ipcomp
); i
++)
490 if (name_ipsecdoi_trns_ipcomp
[i
].key
== k
)
491 return name_ipsecdoi_trns_ipcomp
[i
].str
;
496 s_ipsecdoi_trns(proto
, trns
)
500 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
501 if (name_ipsecdoi_proto
[i
].key
== proto
502 && name_ipsecdoi_proto
[i
].f
)
503 return (name_ipsecdoi_proto
[i
].f
)(trns
);
504 return num2str(trns
);
507 static struct ksmap name_attr_ipsec
[] = {
508 { IPSECDOI_ATTR_SA_LD_TYPE
, "SA Life Type", s_ipsecdoi_ltype
},
509 { IPSECDOI_ATTR_SA_LD
, "SA Life Duration", NULL
},
510 { IPSECDOI_ATTR_GRP_DESC
, "Group Description", NULL
},
511 { IPSECDOI_ATTR_ENC_MODE
, "Encryption Mode", s_ipsecdoi_encmode
},
512 { IPSECDOI_ATTR_AUTH
, "Authentication Algorithm", s_ipsecdoi_auth
},
513 { IPSECDOI_ATTR_KEY_LENGTH
, "Key Length", NULL
},
514 { IPSECDOI_ATTR_KEY_ROUNDS
, "Key Rounds", NULL
},
515 { IPSECDOI_ATTR_COMP_DICT_SIZE
, "Compression Dictionary Size", NULL
},
516 { IPSECDOI_ATTR_COMP_PRIVALG
, "Compression Private Algorithm", NULL
},
524 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
525 if (name_attr_ipsec
[i
].key
== k
)
526 return name_attr_ipsec
[i
].str
;
530 static struct ksmap name_attr_ipsec_ltype
[] = {
531 { IPSECDOI_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
532 { IPSECDOI_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
540 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_ltype
); i
++)
541 if (name_attr_ipsec_ltype
[i
].key
== k
)
542 return name_attr_ipsec_ltype
[i
].str
;
546 static struct ksmap name_attr_ipsec_encmode
[] = {
547 { IPSECDOI_ATTR_ENC_MODE_ANY
, "Any", NULL
},
548 { IPSECDOI_ATTR_ENC_MODE_TUNNEL
, "Tunnel", NULL
},
549 { IPSECDOI_ATTR_ENC_MODE_TRNS
, "Transport", NULL
},
550 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC
, "UDP-Tunnel", NULL
},
551 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC
, "UDP-Transport", NULL
},
552 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT
, "UDP-Tunnel", NULL
},
553 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT
, "UDP-Transport", NULL
},
557 s_ipsecdoi_encmode(k
)
561 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_encmode
); i
++)
562 if (name_attr_ipsec_encmode
[i
].key
== k
)
563 return name_attr_ipsec_encmode
[i
].str
;
567 static struct ksmap name_attr_ipsec_auth
[] = {
568 { IPSECDOI_ATTR_AUTH_HMAC_MD5
, "hmac-md5", NULL
},
569 { IPSECDOI_ATTR_AUTH_HMAC_SHA1
, "hmac-sha", NULL
},
570 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_256
, "hmac-sha256", NULL
},
571 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_384
, "hmac-sha384", NULL
},
572 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_512
, "hmac-sha512", NULL
},
573 { IPSECDOI_ATTR_AUTH_DES_MAC
, "des-mac", NULL
},
574 { IPSECDOI_ATTR_AUTH_KPDK
, "kpdk", NULL
},
582 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_auth
); i
++)
583 if (name_attr_ipsec_auth
[i
].key
== k
)
584 return name_attr_ipsec_auth
[i
].str
;
589 s_ipsecdoi_attr_v(type
, val
)
593 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
594 if (name_attr_ipsec
[i
].key
== type
595 && name_attr_ipsec
[i
].f
)
596 return (name_attr_ipsec
[i
].f
)(val
);
600 static struct ksmap name_ipsecdoi_ident
[] = {
601 { IPSECDOI_ID_IPV4_ADDR
, "IPv4_address", NULL
},
602 { IPSECDOI_ID_FQDN
, "FQDN", NULL
},
603 { IPSECDOI_ID_USER_FQDN
, "User_FQDN", NULL
},
604 { IPSECDOI_ID_IPV4_ADDR_SUBNET
, "IPv4_subnet", NULL
},
605 { IPSECDOI_ID_IPV6_ADDR
, "IPv6_address", NULL
},
606 { IPSECDOI_ID_IPV6_ADDR_SUBNET
, "IPv6_subnet", NULL
},
607 { IPSECDOI_ID_IPV4_ADDR_RANGE
, "IPv4_address_range", NULL
},
608 { IPSECDOI_ID_IPV6_ADDR_RANGE
, "IPv6_address_range", NULL
},
609 { IPSECDOI_ID_DER_ASN1_DN
, "DER_ASN1_DN", NULL
},
610 { IPSECDOI_ID_DER_ASN1_GN
, "DER_ASN1_GN", NULL
},
611 { IPSECDOI_ID_KEY_ID
, "KEY_ID", NULL
},
619 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_ident
); i
++)
620 if (name_ipsecdoi_ident
[i
].key
== k
)
621 return name_ipsecdoi_ident
[i
].str
;
626 static struct ksmap name_oakley_attr
[] = {
627 { OAKLEY_ATTR_ENC_ALG
, "Encryption Algorithm", s_attr_isakmp_enc
},
628 { OAKLEY_ATTR_HASH_ALG
, "Hash Algorithm", s_attr_isakmp_hash
},
629 { OAKLEY_ATTR_AUTH_METHOD
, "Authentication Method", s_oakley_attr_method
},
630 { OAKLEY_ATTR_GRP_DESC
, "Group Description", s_attr_isakmp_desc
},
631 { OAKLEY_ATTR_GRP_TYPE
, "Group Type", s_attr_isakmp_group
},
632 { OAKLEY_ATTR_GRP_PI
, "Group Prime/Irreducible Polynomial", NULL
},
633 { OAKLEY_ATTR_GRP_GEN_ONE
, "Group Generator One", NULL
},
634 { OAKLEY_ATTR_GRP_GEN_TWO
, "Group Generator Two", NULL
},
635 { OAKLEY_ATTR_GRP_CURVE_A
, "Group Curve A", NULL
},
636 { OAKLEY_ATTR_GRP_CURVE_B
, "Group Curve B", NULL
},
637 { OAKLEY_ATTR_SA_LD_TYPE
, "Life Type", s_attr_isakmp_ltype
},
638 { OAKLEY_ATTR_SA_LD
, "Life Duration", NULL
},
639 { OAKLEY_ATTR_PRF
, "PRF", NULL
},
640 { OAKLEY_ATTR_KEY_LEN
, "Key Length", NULL
},
641 { OAKLEY_ATTR_FIELD_SIZE
, "Field Size", NULL
},
642 { OAKLEY_ATTR_GRP_ORDER
, "Group Order", NULL
},
643 { OAKLEY_ATTR_BLOCK_SIZE
, "Block Size", NULL
},
644 { OAKLEY_ATTR_GSS_ID
, "GSS-API endpoint name",NULL
},
652 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
653 if (name_oakley_attr
[i
].key
== k
)
654 return name_oakley_attr
[i
].str
;
658 static struct ksmap name_attr_isakmp_enc
[] = {
659 { OAKLEY_ATTR_ENC_ALG_DES
, "DES-CBC", NULL
},
660 { OAKLEY_ATTR_ENC_ALG_IDEA
, "IDEA-CBC", NULL
},
661 { OAKLEY_ATTR_ENC_ALG_BLOWFISH
, "Blowfish-CBC", NULL
},
662 { OAKLEY_ATTR_ENC_ALG_RC5
, "RC5-R16-B64-CBC", NULL
},
663 { OAKLEY_ATTR_ENC_ALG_3DES
, "3DES-CBC", NULL
},
664 { OAKLEY_ATTR_ENC_ALG_CAST
, "CAST-CBC", NULL
},
665 { OAKLEY_ATTR_ENC_ALG_AES
, "AES-CBC", NULL
},
673 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_enc
); i
++)
674 if (name_attr_isakmp_enc
[i
].key
== k
)
675 return name_attr_isakmp_enc
[i
].str
;
679 static struct ksmap name_attr_isakmp_hash
[] = {
680 { OAKLEY_ATTR_HASH_ALG_MD5
, "MD5", NULL
},
681 { OAKLEY_ATTR_HASH_ALG_SHA
, "SHA", NULL
},
682 { OAKLEY_ATTR_HASH_ALG_TIGER
, "Tiger", NULL
},
683 { OAKLEY_ATTR_HASH_ALG_SHA2_256
,"SHA256", NULL
},
684 { OAKLEY_ATTR_HASH_ALG_SHA2_384
,"SHA384", NULL
},
685 { OAKLEY_ATTR_HASH_ALG_SHA2_512
,"SHA512", NULL
},
689 s_attr_isakmp_hash(k
)
693 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_hash
); i
++)
694 if (name_attr_isakmp_hash
[i
].key
== k
)
695 return name_attr_isakmp_hash
[i
].str
;
699 static struct ksmap name_attr_isakmp_method
[] = {
700 { OAKLEY_ATTR_AUTH_METHOD_PSKEY
, "pre-shared key", NULL
},
701 { OAKLEY_ATTR_AUTH_METHOD_DSSSIG
, "DSS signatures", NULL
},
702 { OAKLEY_ATTR_AUTH_METHOD_RSASIG
, "RSA signatures", NULL
},
703 { OAKLEY_ATTR_AUTH_METHOD_RSAENC
, "Encryption with RSA", NULL
},
704 { OAKLEY_ATTR_AUTH_METHOD_RSAREV
, "Revised encryption with RSA", NULL
},
705 { OAKLEY_ATTR_AUTH_METHOD_EGENC
, "Encryption with El-Gamal", NULL
},
706 { OAKLEY_ATTR_AUTH_METHOD_EGREV
, "Revised encryption with El-Gamal", NULL
},
708 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_R
, "Hybrid DSS server", NULL
},
709 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_R
, "Hybrid RSA server", NULL
},
710 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_I
, "Hybrid DSS client", NULL
},
711 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_I
, "Hybrid RSA client", NULL
},
712 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_I
, "XAuth pskey client", NULL
},
713 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_R
, "XAuth pskey server", NULL
},
714 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_I
, "XAuth RSASIG client", NULL
},
715 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_R
, "XAuth RSASIG server", NULL
},
720 s_oakley_attr_method(k
)
724 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_method
); i
++)
725 if (name_attr_isakmp_method
[i
].key
== k
)
726 return name_attr_isakmp_method
[i
].str
;
730 static struct ksmap name_attr_isakmp_desc
[] = {
731 { OAKLEY_ATTR_GRP_DESC_MODP768
, "768-bit MODP group", NULL
},
732 { OAKLEY_ATTR_GRP_DESC_MODP1024
, "1024-bit MODP group", NULL
},
733 { OAKLEY_ATTR_GRP_DESC_EC2N155
, "EC2N group on GP[2^155]", NULL
},
734 { OAKLEY_ATTR_GRP_DESC_EC2N185
, "EC2N group on GP[2^185]", NULL
},
735 { OAKLEY_ATTR_GRP_DESC_MODP1536
, "1536-bit MODP group", NULL
},
736 { OAKLEY_ATTR_GRP_DESC_MODP2048
, "2048-bit MODP group", NULL
},
737 { OAKLEY_ATTR_GRP_DESC_MODP3072
, "3072-bit MODP group", NULL
},
738 { OAKLEY_ATTR_GRP_DESC_MODP4096
, "4096-bit MODP group", NULL
},
739 { OAKLEY_ATTR_GRP_DESC_MODP6144
, "6144-bit MODP group", NULL
},
740 { OAKLEY_ATTR_GRP_DESC_MODP8192
, "8192-bit MODP group", NULL
},
744 s_attr_isakmp_desc(k
)
748 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_desc
); i
++)
749 if (name_attr_isakmp_desc
[i
].key
== k
)
750 return name_attr_isakmp_desc
[i
].str
;
754 static struct ksmap name_attr_isakmp_group
[] = {
755 { OAKLEY_ATTR_GRP_TYPE_MODP
, "MODP", NULL
},
756 { OAKLEY_ATTR_GRP_TYPE_ECP
, "ECP", NULL
},
757 { OAKLEY_ATTR_GRP_TYPE_EC2N
, "EC2N", NULL
},
761 s_attr_isakmp_group(k
)
765 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_group
); i
++)
766 if (name_attr_isakmp_group
[i
].key
== k
)
767 return name_attr_isakmp_group
[i
].str
;
771 static struct ksmap name_attr_isakmp_ltype
[] = {
772 { OAKLEY_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
773 { OAKLEY_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
777 s_attr_isakmp_ltype(k
)
781 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_ltype
); i
++)
782 if (name_attr_isakmp_ltype
[i
].key
== k
)
783 return name_attr_isakmp_ltype
[i
].str
;
788 s_oakley_attr_v(type
, val
)
792 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
793 if (name_oakley_attr
[i
].key
== type
794 && name_oakley_attr
[i
].f
)
795 return (name_oakley_attr
[i
].f
)(val
);
799 /* netinet6/ipsec.h */
800 static struct ksmap name_ipsec_level
[] = {
801 { IPSEC_LEVEL_USE
, "use", NULL
},
802 { IPSEC_LEVEL_REQUIRE
, "require", NULL
},
803 { IPSEC_LEVEL_UNIQUE
, "unique", NULL
},
811 for (i
= 0; i
< ARRAYLEN(name_ipsec_level
); i
++)
812 if (name_ipsec_level
[i
].key
== k
)
813 return name_ipsec_level
[i
].str
;
817 static struct ksmap name_algclass
[] = {
818 { algclass_ipsec_enc
, "ipsec enc", s_ipsecdoi_trns_esp
},
819 { algclass_ipsec_auth
, "ipsec auth", s_ipsecdoi_trns_ah
},
820 { algclass_ipsec_comp
, "ipsec comp", s_ipsecdoi_trns_ipcomp
},
821 { algclass_isakmp_enc
, "isakmp enc", s_attr_isakmp_enc
},
822 { algclass_isakmp_hash
, "isakmp hash", s_attr_isakmp_hash
},
823 { algclass_isakmp_dh
, "isakmp dh", s_attr_isakmp_desc
},
824 { algclass_isakmp_ameth
, "isakmp auth method", s_oakley_attr_method
},
832 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
833 if (name_algclass
[i
].key
== k
)
834 return name_algclass
[i
].str
;
843 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
844 if (name_algclass
[i
].key
== class
845 && name_algclass
[i
].f
)
846 return (name_algclass
[i
].f
)(n
);
851 static struct ksmap name_pfkey_type
[] = {
852 { SADB_GETSPI
, "GETSPI", NULL
},
853 { SADB_UPDATE
, "UPDATE", NULL
},
854 { SADB_ADD
, "ADD", NULL
},
855 { SADB_DELETE
, "DELETE", NULL
},
856 { SADB_GET
, "GET", NULL
},
857 { SADB_ACQUIRE
, "ACQUIRE", NULL
},
858 { SADB_REGISTER
, "REGISTER", NULL
},
859 { SADB_EXPIRE
, "EXPIRE", NULL
},
860 { SADB_FLUSH
, "FLUSH", NULL
},
861 { SADB_DUMP
, "DUMP", NULL
},
862 { SADB_X_PROMISC
, "X_PROMISC", NULL
},
863 { SADB_X_PCHANGE
, "X_PCHANGE", NULL
},
864 { SADB_X_SPDUPDATE
, "X_SPDUPDATE", NULL
},
865 { SADB_X_SPDADD
, "X_SPDADD", NULL
},
866 { SADB_X_SPDDELETE
, "X_SPDDELETE", NULL
},
867 { SADB_X_SPDGET
, "X_SPDGET", NULL
},
868 { SADB_X_SPDACQUIRE
, "X_SPDACQUIRE", NULL
},
869 { SADB_X_SPDDUMP
, "X_SPDDUMP", NULL
},
870 { SADB_X_SPDFLUSH
, "X_SPDFLUSH", NULL
},
871 { SADB_X_SPDSETIDX
, "X_SPDSETIDX", NULL
},
872 { SADB_X_SPDEXPIRE
, "X_SPDEXPIRE", NULL
},
873 { SADB_X_SPDDELETE2
, "X_SPDDELETE2", NULL
},
874 { SADB_GETSASTAT
, "X_GETSASTAT", NULL
},
875 #ifdef SADB_X_NAT_T_NEW_MAPPING
876 { SADB_X_NAT_T_NEW_MAPPING
, "X_NAT_T_NEW_MAPPING", NULL
},
878 #ifdef SADB_X_MIGRATE
879 { SADB_X_MIGRATE
, "X_MIGRATE", NULL
},
888 for (i
= 0; i
< ARRAYLEN(name_pfkey_type
); i
++)
889 if (name_pfkey_type
[i
].key
== k
)
890 return name_pfkey_type
[i
].str
;
894 static struct ksmap name_pfkey_satype
[] = {
895 { SADB_SATYPE_UNSPEC
, "UNSPEC", NULL
},
896 { SADB_SATYPE_AH
, "AH", NULL
},
897 { SADB_SATYPE_ESP
, "ESP", NULL
},
898 { SADB_SATYPE_RSVP
, "RSVP", NULL
},
899 { SADB_SATYPE_OSPFV2
, "OSPFV2", NULL
},
900 { SADB_SATYPE_RIPV2
, "RIPV2", NULL
},
901 { SADB_SATYPE_MIP
, "MIP", NULL
},
902 { SADB_X_SATYPE_IPCOMP
, "IPCOMP", NULL
},
910 for (i
= 0; i
< ARRAYLEN(name_pfkey_satype
); i
++)
911 if (name_pfkey_satype
[i
].key
== k
)
912 return name_pfkey_satype
[i
].str
;
916 static struct ksmap name_direction
[] = {
917 { IPSEC_DIR_INBOUND
, "in", NULL
},
918 { IPSEC_DIR_OUTBOUND
, "out", NULL
},
919 #ifdef HAVE_POLICY_FWD
920 { IPSEC_DIR_FWD
, "fwd", NULL
},
929 for (i
= 0; i
< ARRAYLEN(name_direction
); i
++)
930 if (name_direction
[i
].key
== k
)
931 return name_direction
[i
].str
;
948 case IPSEC_ULPROTO_ANY
:
970 case ISAKMP_ETYPE_NONE
:
972 case ISAKMP_ETYPE_BASE
:
974 case ISAKMP_ETYPE_IDENT
:
976 case ISAKMP_ETYPE_AUTH
:
978 case ISAKMP_ETYPE_AGG
:
980 case ISAKMP_ETYPE_INFO
:
982 case ISAKMP_ETYPE_QUICK
:
984 case ISAKMP_ETYPE_NEWGRP
:
986 case ISAKMP_ETYPE_ACKINFO
:
999 case IDTYPE_USERFQDN
:
1003 case IDTYPE_ADDRESS
: