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>
57 #include "isakmp_var.h"
60 # include "isakmp_xauth.h"
61 # include "isakmp_unity.h"
62 # include "isakmp_cfg.h"
64 #include "ipsec_doi.h"
69 #include "algorithm.h"
83 snprintf(buf
, sizeof(buf
), "%d", n
);
90 s_isakmp_state(t
, d
, s
)
94 case IKEV1_STATE_PHASE1_ESTABLISHED
:
95 return "Phase 1 Established";
96 case IKEV1_STATE_PHASE2_ESTABLISHED
:
97 return "Phase 2 established";
98 case IKEV1_STATE_PHASE1_EXPIRED
:
99 return "Phase 1 expired";
100 case IKEV1_STATE_PHASE2_EXPIRED
:
101 return "Phase 2 expired";
102 case IKEV1_STATE_INFO
:
104 case IKEV1_STATE_IDENT_I_START
:
105 return "IKEv1 ident I start";
106 case IKEV1_STATE_IDENT_I_MSG1SENT
:
107 return "IKEv1 ident I msg1 sent";
108 case IKEV1_STATE_IDENT_I_MSG2RCVD
:
109 return "IKEv1 ident I msg2 rcvd";
110 case IKEV1_STATE_IDENT_I_MSG3SENT
:
111 return "IKEv1 ident I msg3 sent";
112 case IKEV1_STATE_IDENT_I_MSG4RCVD
:
113 return "IKEv1 ident I msg4 rcvd";
114 case IKEV1_STATE_IDENT_I_MSG5SENT
:
115 return "IKEv1 ident I msg5 sent";
116 case IKEV1_STATE_IDENT_I_MSG6RCVD
:
117 return "IKEv1 ident I msg6 rcvd";
119 case IKEV1_STATE_IDENT_R_START
:
120 return "IKEv1 ident R start";
121 case IKEV1_STATE_IDENT_R_MSG1RCVD
:
122 return "IKEv1 ident R msg1 rcvd";
123 case IKEV1_STATE_IDENT_R_MSG2SENT
:
124 return "IKEv1 ident R msg2 sent";
125 case IKEV1_STATE_IDENT_R_MSG3RCVD
:
126 return "IKEv1 ident R msg3 rcvd";
127 case IKEV1_STATE_IDENT_R_MSG4SENT
:
128 return "IKEv1 ident R msg4 sent";
129 case IKEV1_STATE_IDENT_R_MSG5RCVD
:
130 return "IKEv1 ident R msg5 rcvd";
132 case IKEV1_STATE_AGG_I_START
:
133 return "IKEv1 agg I start";
134 case IKEV1_STATE_AGG_I_MSG1SENT
:
135 return "IKEv1 agg I msg1 sent";
136 case IKEV1_STATE_AGG_I_MSG2RCVD
:
137 return "IKEv1 agg I msg2 rcvd";
138 case IKEV1_STATE_AGG_I_MSG3SENT
:
139 return "IKEv1 agg I msg3 sent";
140 case IKEV1_STATE_AGG_R_START
:
141 return "IKEv1 agg R start";
142 case IKEV1_STATE_AGG_R_MSG1RCVD
:
143 return "IKEv1 agg R msg1 rcvd";
144 case IKEV1_STATE_AGG_R_MSG2SENT
:
145 return "IKEv1 agg R msg2 sent";
146 case IKEV1_STATE_AGG_R_MSG3RCVD
:
147 return "IKEv1 agg R msg3 rcvd";
149 case IKEV1_STATE_QUICK_I_START
:
150 return "IKEv1 quick I start";
151 case IKEV1_STATE_QUICK_I_GETSPISENT
:
152 return "IKEv1 quick I getspi sent";
153 case IKEV1_STATE_QUICK_I_GETSPIDONE
:
154 return "IKEv1 quick I getspi done";
155 case IKEV1_STATE_QUICK_I_MSG1SENT
:
156 return "IKEv1 quick I msg1 sent";
157 case IKEV1_STATE_QUICK_I_MSG2RCVD
:
158 return "IKEv1 quick I msg2 rcvd";
159 case IKEV1_STATE_QUICK_I_MSG3SENT
:
160 return "IKEv1 quick I msg3 sent";
161 case IKEV1_STATE_QUICK_I_ADDSA
:
162 return "IKEv1 quick I addsa";
163 case IKEV1_STATE_QUICK_R_START
:
164 return "IKEv1 quick R start";
165 case IKEV1_STATE_QUICK_R_MSG1RCVD
:
166 return "IKEv1 quick R msg1 rcvd";
167 case IKEV1_STATE_QUICK_R_GETSPISENT
:
168 return "IKEv1 quick R getspi sent";
169 case IKEV1_STATE_QUICK_R_GETSPIDONE
:
170 return "IKEv1 quick R getspi done";
171 case IKEV1_STATE_QUICK_R_MSG2SENT
:
172 return "IKEv1 quick R msg2 sent";
173 case IKEV1_STATE_QUICK_R_MSG3RCVD
:
174 return "IKEv1 quick R msg3 rcvd";
175 case IKEV1_STATE_QUICK_R_COMMIT
:
176 return "IKEv1 quick R commit";
177 case IKEV1_STATE_QUICK_R_ADDSA
:
178 return "IKEv1 quick R addsa";
184 static struct ksmap name_isakmp_certtype
[] = {
185 { ISAKMP_CERT_NONE
, "NONE", NULL
},
186 { ISAKMP_CERT_PKCS7
, "PKCS #7 wrapped X.509 certificate", NULL
},
187 { ISAKMP_CERT_PGP
, "PGP Certificate", NULL
},
188 { ISAKMP_CERT_DNS
, "DNS Signed Key", NULL
},
189 { ISAKMP_CERT_X509SIGN
, "X.509 Certificate Signature", NULL
},
190 { ISAKMP_CERT_X509KE
, "X.509 Certificate Key Exchange", NULL
},
191 { ISAKMP_CERT_KERBEROS
, "Kerberos Tokens", NULL
},
192 { ISAKMP_CERT_CRL
, "Certificate Revocation List (CRL)", NULL
},
193 { ISAKMP_CERT_ARL
, "Authority Revocation List (ARL)", NULL
},
194 { ISAKMP_CERT_SPKI
, "SPKI Certificate", NULL
},
195 { ISAKMP_CERT_X509ATTR
, "X.509 Certificate Attribute", NULL
},
203 for (i
= 0; i
< ARRAYLEN(name_isakmp_certtype
); i
++)
204 if (name_isakmp_certtype
[i
].key
== k
)
205 return name_isakmp_certtype
[i
].str
;
209 static struct ksmap name_isakmp_etype
[] = {
210 { ISAKMP_ETYPE_NONE
, "None", NULL
},
211 { ISAKMP_ETYPE_BASE
, "Base", NULL
},
212 { ISAKMP_ETYPE_IDENT
, "Identity Protection", NULL
},
213 { ISAKMP_ETYPE_AUTH
, "Authentication Only", NULL
},
214 { ISAKMP_ETYPE_AGG
, "Aggressive", NULL
},
215 { ISAKMP_ETYPE_INFO
, "Informational", NULL
},
216 { ISAKMP_ETYPE_CFG
, "Mode config", NULL
},
217 { ISAKMP_ETYPE_QUICK
, "Quick", NULL
},
218 { ISAKMP_ETYPE_NEWGRP
, "New Group", NULL
},
219 { ISAKMP_ETYPE_ACKINFO
, "Acknowledged Informational", NULL
},
227 for (i
= 0; i
< ARRAYLEN(name_isakmp_etype
); i
++)
228 if (name_isakmp_etype
[i
].key
== k
)
229 return name_isakmp_etype
[i
].str
;
233 static struct ksmap name_isakmp_notify_msg
[] = {
234 { ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE
, "INVALID-PAYLOAD-TYPE", NULL
},
235 { ISAKMP_NTYPE_DOI_NOT_SUPPORTED
, "DOI-NOT-SUPPORTED", NULL
},
236 { ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED
, "SITUATION-NOT-SUPPORTED", NULL
},
237 { ISAKMP_NTYPE_INVALID_COOKIE
, "INVALID-COOKIE", NULL
},
238 { ISAKMP_NTYPE_INVALID_MAJOR_VERSION
, "INVALID-MAJOR-VERSION", NULL
},
239 { ISAKMP_NTYPE_INVALID_MINOR_VERSION
, "INVALID-MINOR-VERSION", NULL
},
240 { ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE
, "INVALID-EXCHANGE-TYPE", NULL
},
241 { ISAKMP_NTYPE_INVALID_FLAGS
, "INVALID-FLAGS", NULL
},
242 { ISAKMP_NTYPE_INVALID_MESSAGE_ID
, "INVALID-MESSAGE-ID", NULL
},
243 { ISAKMP_NTYPE_INVALID_PROTOCOL_ID
, "INVALID-PROTOCOL-ID", NULL
},
244 { ISAKMP_NTYPE_INVALID_SPI
, "INVALID-SPI", NULL
},
245 { ISAKMP_NTYPE_INVALID_TRANSFORM_ID
, "INVALID-TRANSFORM-ID", NULL
},
246 { ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED
, "ATTRIBUTES-NOT-SUPPORTED", NULL
},
247 { ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN
, "NO-PROPOSAL-CHOSEN", NULL
},
248 { ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX
, "BAD-PROPOSAL-SYNTAX", NULL
},
249 { ISAKMP_NTYPE_PAYLOAD_MALFORMED
, "PAYLOAD-MALFORMED", NULL
},
250 { ISAKMP_NTYPE_INVALID_KEY_INFORMATION
, "INVALID-KEY-INFORMATION", NULL
},
251 { ISAKMP_NTYPE_INVALID_ID_INFORMATION
, "INVALID-ID-INFORMATION", NULL
},
252 { ISAKMP_NTYPE_INVALID_CERT_ENCODING
, "INVALID-CERT-ENCODING", NULL
},
253 { ISAKMP_NTYPE_INVALID_CERTIFICATE
, "INVALID-CERTIFICATE", NULL
},
254 { ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX
, "BAD-CERT-REQUEST-SYNTAX", NULL
},
255 { ISAKMP_NTYPE_INVALID_CERT_AUTHORITY
, "INVALID-CERT-AUTHORITY", NULL
},
256 { ISAKMP_NTYPE_INVALID_HASH_INFORMATION
, "INVALID-HASH-INFORMATION", NULL
},
257 { ISAKMP_NTYPE_AUTHENTICATION_FAILED
, "AUTHENTICATION-FAILED", NULL
},
258 { ISAKMP_NTYPE_INVALID_SIGNATURE
, "INVALID-SIGNATURE", NULL
},
259 { ISAKMP_NTYPE_ADDRESS_NOTIFICATION
, "ADDRESS-NOTIFICATION", NULL
},
260 { ISAKMP_NTYPE_NOTIFY_SA_LIFETIME
, "NOTIFY-SA-LIFETIME", NULL
},
261 { ISAKMP_NTYPE_CERTIFICATE_UNAVAILABLE
, "CERTIFICATE-UNAVAILABLE", NULL
},
262 { ISAKMP_NTYPE_UNSUPPORTED_EXCHANGE_TYPE
, "UNSUPPORTED-EXCHANGE-TYPE", NULL
},
263 { ISAKMP_NTYPE_UNEQUAL_PAYLOAD_LENGTHS
, "UNEQUAL-PAYLOAD-LENGTHS", NULL
},
264 { ISAKMP_NTYPE_CONNECTED
, "CONNECTED", NULL
},
265 { ISAKMP_NTYPE_RESPONDER_LIFETIME
, "RESPONDER-LIFETIME", NULL
},
266 { ISAKMP_NTYPE_REPLAY_STATUS
, "REPLAY-STATUS", NULL
},
267 { ISAKMP_NTYPE_INITIAL_CONTACT
, "INITIAL-CONTACT", NULL
},
269 { ISAKMP_NTYPE_UNITY_HEARTBEAT
, "HEARTBEAT (Unity)", NULL
},
271 { ISAKMP_LOG_RETRY_LIMIT_REACHED
, "RETRY-LIMIT-REACHED", NULL
},
275 s_isakmp_notify_msg(k
)
279 for (i
= 0; i
< ARRAYLEN(name_isakmp_notify_msg
); i
++)
280 if (name_isakmp_notify_msg
[i
].key
== k
)
281 return name_isakmp_notify_msg
[i
].str
;
286 static struct ksmap name_isakmp_nptype
[] = {
287 { ISAKMP_NPTYPE_NONE
, "none", NULL
},
288 { ISAKMP_NPTYPE_SA
, "sa", NULL
},
289 { ISAKMP_NPTYPE_P
, "prop", NULL
},
290 { ISAKMP_NPTYPE_T
, "trns", NULL
},
291 { ISAKMP_NPTYPE_KE
, "ke", NULL
},
292 { ISAKMP_NPTYPE_ID
, "id", NULL
},
293 { ISAKMP_NPTYPE_CERT
, "cert", NULL
},
294 { ISAKMP_NPTYPE_CR
, "cr", NULL
},
295 { ISAKMP_NPTYPE_HASH
, "hash", NULL
},
296 { ISAKMP_NPTYPE_SIG
, "sig", NULL
},
297 { ISAKMP_NPTYPE_NONCE
, "nonce", NULL
},
298 { ISAKMP_NPTYPE_N
, "notify", NULL
},
299 { ISAKMP_NPTYPE_D
, "delete", NULL
},
300 { ISAKMP_NPTYPE_VID
, "vid", NULL
},
301 { ISAKMP_NPTYPE_ATTR
, "attr", NULL
},
302 { ISAKMP_NPTYPE_GSS
, "gss id", NULL
},
303 { ISAKMP_NPTYPE_NATD_RFC
, "nat-d", NULL
},
304 { ISAKMP_NPTYPE_NATOA_RFC
, "nat-oa", NULL
},
305 { ISAKMP_NPTYPE_NATD_DRAFT
, "nat-d", NULL
},
306 { ISAKMP_NPTYPE_NATOA_DRAFT
, "nat-oa", NULL
},
307 { ISAKMP_NPTYPE_FRAG
, "ike frag", NULL
},
315 for (i
= 0; i
< ARRAYLEN(name_isakmp_nptype
); i
++)
316 if (name_isakmp_nptype
[i
].key
== k
)
317 return name_isakmp_nptype
[i
].str
;
322 /* isakmp_cfg.h / isakmp_unity.h / isakmp_xauth.h */
323 static struct ksmap name_isakmp_cfg_type
[] = {
324 { INTERNAL_IP4_ADDRESS
, "INTERNAL_IP4_ADDRESS", NULL
},
325 { INTERNAL_IP4_NETMASK
, "INTERNAL_IP4_NETMASK", NULL
},
326 { INTERNAL_IP4_DNS
, "INTERNAL_IP4_DNS", NULL
},
327 { INTERNAL_IP4_NBNS
, "INTERNAL_IP4_NBNS", NULL
},
328 { INTERNAL_ADDRESS_EXPIRY
, "INTERNAL_ADDRESS_EXPIRY", NULL
},
329 { INTERNAL_IP4_DHCP
, "INTERNAL_IP4_DHCP", NULL
},
330 { APPLICATION_VERSION
, "APPLICATION_VERSION", NULL
},
331 { INTERNAL_IP6_ADDRESS
, "INTERNAL_IP6_ADDRESS", NULL
},
332 { INTERNAL_IP6_NETMASK
, "INTERNAL_IP6_NETMASK", NULL
},
333 { INTERNAL_IP6_DNS
, "INTERNAL_IP6_DNS", NULL
},
334 { INTERNAL_IP6_NBNS
, "INTERNAL_IP6_NBNS", NULL
},
335 { INTERNAL_IP6_DHCP
, "INTERNAL_IP6_DHCP", NULL
},
336 { INTERNAL_IP4_SUBNET
, "INTERNAL_IP4_SUBNET", NULL
},
337 { SUPPORTED_ATTRIBUTES
, "SUPPORTED_ATTRIBUTES", NULL
},
338 { INTERNAL_IP6_SUBNET
, "INTERNAL_IP6_SUBNET", NULL
},
339 { XAUTH_TYPE
, "XAUTH_TYPE", NULL
},
340 { XAUTH_USER_NAME
, "XAUTH_USER_NAME", NULL
},
341 { XAUTH_USER_PASSWORD
, "XAUTH_USER_PASSWORD", NULL
},
342 { XAUTH_PASSCODE
, "XAUTH_PASSCODE", NULL
},
343 { XAUTH_MESSAGE
, "XAUTH_MESSAGE", NULL
},
344 { XAUTH_CHALLENGE
, "XAUTH_CHALLENGE", NULL
},
345 { XAUTH_DOMAIN
, "XAUTH_DOMAIN", NULL
},
346 { XAUTH_STATUS
, "XAUTH_STATUS", NULL
},
347 { XAUTH_NEXT_PIN
, "XAUTH_NEXT_PIN", NULL
},
348 { XAUTH_ANSWER
, "XAUTH_ANSWER", NULL
},
349 { UNITY_BANNER
, "UNITY_BANNER", NULL
},
350 { UNITY_SAVE_PASSWD
, "UNITY_SAVE_PASSWD", NULL
},
351 { UNITY_DEF_DOMAIN
, "UNITY_DEF_DOMAIN", NULL
},
352 { UNITY_SPLITDNS_NAME
, "UNITY_SPLITDNS_NAME", NULL
},
353 { UNITY_SPLIT_INCLUDE
, "UNITY_SPLIT_INCLUDE", NULL
},
354 { UNITY_NATT_PORT
, "UNITY_NATT_PORT", NULL
},
355 { UNITY_LOCAL_LAN
, "UNITY_LOCAL_LAN", NULL
},
356 { UNITY_PFS
, "UNITY_PFS", NULL
},
357 { UNITY_FW_TYPE
, "UNITY_FW_TYPE", NULL
},
358 { UNITY_BACKUP_SERVERS
, "UNITY_BACKUP_SERVERS", NULL
},
359 { UNITY_DDNS_HOSTNAME
, "UNITY_DDNS_HOSTNAME", NULL
},
367 for (i
= 0; i
< ARRAYLEN(name_isakmp_cfg_type
); i
++)
368 if (name_isakmp_cfg_type
[i
].key
== k
)
369 return name_isakmp_cfg_type
[i
].str
;
373 /* isakmp_cfg.h / isakmp_unity.h / isakmp_xauth.h */
374 static struct ksmap name_isakmp_cfg_ptype
[] = {
375 { ISAKMP_CFG_ACK
, "mode config ACK", NULL
},
376 { ISAKMP_CFG_SET
, "mode config SET", NULL
},
377 { ISAKMP_CFG_REQUEST
, "mode config REQUEST", NULL
},
378 { ISAKMP_CFG_REPLY
, "mode config REPLY", NULL
},
382 s_isakmp_cfg_ptype(k
)
386 for (i
= 0; i
< ARRAYLEN(name_isakmp_cfg_ptype
); i
++)
387 if (name_isakmp_cfg_ptype
[i
].key
== k
)
388 return name_isakmp_cfg_ptype
[i
].str
;
395 static struct ksmap name_ipsecdoi_proto
[] = {
396 { IPSECDOI_PROTO_ISAKMP
, "ISAKMP", s_ipsecdoi_trns_isakmp
},
397 { IPSECDOI_PROTO_IPSEC_AH
, "AH", s_ipsecdoi_trns_ah
},
398 { IPSECDOI_PROTO_IPSEC_ESP
, "ESP", s_ipsecdoi_trns_esp
},
399 { IPSECDOI_PROTO_IPCOMP
, "IPCOMP", s_ipsecdoi_trns_ipcomp
},
407 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
408 if (name_ipsecdoi_proto
[i
].key
== k
)
409 return name_ipsecdoi_proto
[i
].str
;
413 static struct ksmap name_ipsecdoi_trns_isakmp
[] = {
414 { IPSECDOI_KEY_IKE
, "IKE", NULL
},
418 s_ipsecdoi_trns_isakmp(k
)
422 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_isakmp
); i
++)
423 if (name_ipsecdoi_trns_isakmp
[i
].key
== k
)
424 return name_ipsecdoi_trns_isakmp
[i
].str
;
428 static struct ksmap name_ipsecdoi_trns_ah
[] = {
429 { IPSECDOI_AH_MD5
, "MD5", NULL
},
430 { IPSECDOI_AH_SHA
, "SHA", NULL
},
431 { IPSECDOI_AH_DES
, "DES", NULL
},
432 { IPSECDOI_AH_SHA256
, "SHA256", NULL
},
433 { IPSECDOI_AH_SHA384
, "SHA384", NULL
},
434 { IPSECDOI_AH_SHA512
, "SHA512", NULL
},
438 s_ipsecdoi_trns_ah(k
)
442 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ah
); i
++)
443 if (name_ipsecdoi_trns_ah
[i
].key
== k
)
444 return name_ipsecdoi_trns_ah
[i
].str
;
448 static struct ksmap name_ipsecdoi_trns_esp
[] = {
449 { IPSECDOI_ESP_DES_IV64
, "DES_IV64", NULL
},
450 { IPSECDOI_ESP_DES
, "DES", NULL
},
451 { IPSECDOI_ESP_3DES
, "3DES", NULL
},
452 { IPSECDOI_ESP_RC5
, "RC5", NULL
},
453 { IPSECDOI_ESP_IDEA
, "IDEA", NULL
},
454 { IPSECDOI_ESP_CAST
, "CAST", NULL
},
455 { IPSECDOI_ESP_BLOWFISH
, "BLOWFISH", NULL
},
456 { IPSECDOI_ESP_3IDEA
, "3IDEA", NULL
},
457 { IPSECDOI_ESP_DES_IV32
, "DES_IV32", NULL
},
458 { IPSECDOI_ESP_RC4
, "RC4", NULL
},
459 { IPSECDOI_ESP_NULL
, "NULL", NULL
},
460 { IPSECDOI_ESP_AES
, "AES", NULL
},
461 { IPSECDOI_ESP_TWOFISH
, "TWOFISH", NULL
},
465 s_ipsecdoi_trns_esp(k
)
469 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_esp
); i
++)
470 if (name_ipsecdoi_trns_esp
[i
].key
== k
)
471 return name_ipsecdoi_trns_esp
[i
].str
;
475 static struct ksmap name_ipsecdoi_trns_ipcomp
[] = {
476 { IPSECDOI_IPCOMP_OUI
, "OUI", NULL
},
477 { IPSECDOI_IPCOMP_DEFLATE
, "DEFLATE", NULL
},
478 { IPSECDOI_IPCOMP_LZS
, "LZS", NULL
},
482 s_ipsecdoi_trns_ipcomp(k
)
486 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ipcomp
); i
++)
487 if (name_ipsecdoi_trns_ipcomp
[i
].key
== k
)
488 return name_ipsecdoi_trns_ipcomp
[i
].str
;
493 s_ipsecdoi_trns(proto
, trns
)
497 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
498 if (name_ipsecdoi_proto
[i
].key
== proto
499 && name_ipsecdoi_proto
[i
].f
)
500 return (name_ipsecdoi_proto
[i
].f
)(trns
);
501 return num2str(trns
);
504 static struct ksmap name_attr_ipsec
[] = {
505 { IPSECDOI_ATTR_SA_LD_TYPE
, "SA Life Type", s_ipsecdoi_ltype
},
506 { IPSECDOI_ATTR_SA_LD
, "SA Life Duration", NULL
},
507 { IPSECDOI_ATTR_GRP_DESC
, "Group Description", NULL
},
508 { IPSECDOI_ATTR_ENC_MODE
, "Encryption Mode", s_ipsecdoi_encmode
},
509 { IPSECDOI_ATTR_AUTH
, "Authentication Algorithm", s_ipsecdoi_auth
},
510 { IPSECDOI_ATTR_KEY_LENGTH
, "Key Length", NULL
},
511 { IPSECDOI_ATTR_KEY_ROUNDS
, "Key Rounds", NULL
},
512 { IPSECDOI_ATTR_COMP_DICT_SIZE
, "Compression Dictionary Size", NULL
},
513 { IPSECDOI_ATTR_COMP_PRIVALG
, "Compression Private Algorithm", NULL
},
521 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
522 if (name_attr_ipsec
[i
].key
== k
)
523 return name_attr_ipsec
[i
].str
;
527 static struct ksmap name_attr_ipsec_ltype
[] = {
528 { IPSECDOI_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
529 { IPSECDOI_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
537 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_ltype
); i
++)
538 if (name_attr_ipsec_ltype
[i
].key
== k
)
539 return name_attr_ipsec_ltype
[i
].str
;
543 static struct ksmap name_attr_ipsec_encmode
[] = {
544 { IPSECDOI_ATTR_ENC_MODE_ANY
, "Any", NULL
},
545 { IPSECDOI_ATTR_ENC_MODE_TUNNEL
, "Tunnel", NULL
},
546 { IPSECDOI_ATTR_ENC_MODE_TRNS
, "Transport", NULL
},
547 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC
, "UDP-Tunnel", NULL
},
548 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC
, "UDP-Transport", NULL
},
549 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT
, "UDP-Tunnel", NULL
},
550 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT
, "UDP-Transport", NULL
},
554 s_ipsecdoi_encmode(k
)
558 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_encmode
); i
++)
559 if (name_attr_ipsec_encmode
[i
].key
== k
)
560 return name_attr_ipsec_encmode
[i
].str
;
564 static struct ksmap name_attr_ipsec_auth
[] = {
565 { IPSECDOI_ATTR_AUTH_HMAC_MD5
, "hmac-md5", NULL
},
566 { IPSECDOI_ATTR_AUTH_HMAC_SHA1
, "hmac-sha", NULL
},
567 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_256
, "hmac-sha256", NULL
},
568 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_384
, "hmac-sha384", NULL
},
569 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_512
, "hmac-sha512", NULL
},
570 { IPSECDOI_ATTR_AUTH_DES_MAC
, "des-mac", NULL
},
571 { IPSECDOI_ATTR_AUTH_KPDK
, "kpdk", NULL
},
579 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_auth
); i
++)
580 if (name_attr_ipsec_auth
[i
].key
== k
)
581 return name_attr_ipsec_auth
[i
].str
;
586 s_ipsecdoi_attr_v(type
, val
)
590 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
591 if (name_attr_ipsec
[i
].key
== type
592 && name_attr_ipsec
[i
].f
)
593 return (name_attr_ipsec
[i
].f
)(val
);
597 static struct ksmap name_ipsecdoi_ident
[] = {
598 { IPSECDOI_ID_IPV4_ADDR
, "IPv4_address", NULL
},
599 { IPSECDOI_ID_FQDN
, "FQDN", NULL
},
600 { IPSECDOI_ID_USER_FQDN
, "User_FQDN", NULL
},
601 { IPSECDOI_ID_IPV4_ADDR_SUBNET
, "IPv4_subnet", NULL
},
602 { IPSECDOI_ID_IPV6_ADDR
, "IPv6_address", NULL
},
603 { IPSECDOI_ID_IPV6_ADDR_SUBNET
, "IPv6_subnet", NULL
},
604 { IPSECDOI_ID_IPV4_ADDR_RANGE
, "IPv4_address_range", NULL
},
605 { IPSECDOI_ID_IPV6_ADDR_RANGE
, "IPv6_address_range", NULL
},
606 { IPSECDOI_ID_DER_ASN1_DN
, "DER_ASN1_DN", NULL
},
607 { IPSECDOI_ID_DER_ASN1_GN
, "DER_ASN1_GN", NULL
},
608 { IPSECDOI_ID_KEY_ID
, "KEY_ID", NULL
},
616 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_ident
); i
++)
617 if (name_ipsecdoi_ident
[i
].key
== k
)
618 return name_ipsecdoi_ident
[i
].str
;
623 static struct ksmap name_oakley_attr
[] = {
624 { OAKLEY_ATTR_ENC_ALG
, "Encryption Algorithm", s_attr_isakmp_enc
},
625 { OAKLEY_ATTR_HASH_ALG
, "Hash Algorithm", s_attr_isakmp_hash
},
626 { OAKLEY_ATTR_AUTH_METHOD
, "Authentication Method", s_oakley_attr_method
},
627 { OAKLEY_ATTR_GRP_DESC
, "Group Description", s_attr_isakmp_desc
},
628 { OAKLEY_ATTR_GRP_TYPE
, "Group Type", s_attr_isakmp_group
},
629 { OAKLEY_ATTR_GRP_PI
, "Group Prime/Irreducible Polynomial", NULL
},
630 { OAKLEY_ATTR_GRP_GEN_ONE
, "Group Generator One", NULL
},
631 { OAKLEY_ATTR_GRP_GEN_TWO
, "Group Generator Two", NULL
},
632 { OAKLEY_ATTR_GRP_CURVE_A
, "Group Curve A", NULL
},
633 { OAKLEY_ATTR_GRP_CURVE_B
, "Group Curve B", NULL
},
634 { OAKLEY_ATTR_SA_LD_TYPE
, "Life Type", s_attr_isakmp_ltype
},
635 { OAKLEY_ATTR_SA_LD
, "Life Duration", NULL
},
636 { OAKLEY_ATTR_PRF
, "PRF", NULL
},
637 { OAKLEY_ATTR_KEY_LEN
, "Key Length", NULL
},
638 { OAKLEY_ATTR_FIELD_SIZE
, "Field Size", NULL
},
639 { OAKLEY_ATTR_GRP_ORDER
, "Group Order", NULL
},
640 { OAKLEY_ATTR_BLOCK_SIZE
, "Block Size", NULL
},
641 { OAKLEY_ATTR_GSS_ID
, "GSS-API endpoint name",NULL
},
649 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
650 if (name_oakley_attr
[i
].key
== k
)
651 return name_oakley_attr
[i
].str
;
655 static struct ksmap name_attr_isakmp_enc
[] = {
656 { OAKLEY_ATTR_ENC_ALG_DES
, "DES-CBC", NULL
},
657 { OAKLEY_ATTR_ENC_ALG_IDEA
, "IDEA-CBC", NULL
},
658 { OAKLEY_ATTR_ENC_ALG_BLOWFISH
, "Blowfish-CBC", NULL
},
659 { OAKLEY_ATTR_ENC_ALG_RC5
, "RC5-R16-B64-CBC", NULL
},
660 { OAKLEY_ATTR_ENC_ALG_3DES
, "3DES-CBC", NULL
},
661 { OAKLEY_ATTR_ENC_ALG_CAST
, "CAST-CBC", NULL
},
662 { OAKLEY_ATTR_ENC_ALG_AES
, "AES-CBC", NULL
},
670 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_enc
); i
++)
671 if (name_attr_isakmp_enc
[i
].key
== k
)
672 return name_attr_isakmp_enc
[i
].str
;
676 static struct ksmap name_attr_isakmp_hash
[] = {
677 { OAKLEY_ATTR_HASH_ALG_MD5
, "MD5", NULL
},
678 { OAKLEY_ATTR_HASH_ALG_SHA
, "SHA", NULL
},
679 { OAKLEY_ATTR_HASH_ALG_TIGER
, "Tiger", NULL
},
680 { OAKLEY_ATTR_HASH_ALG_SHA2_256
,"SHA256", NULL
},
681 { OAKLEY_ATTR_HASH_ALG_SHA2_384
,"SHA384", NULL
},
682 { OAKLEY_ATTR_HASH_ALG_SHA2_512
,"SHA512", NULL
},
686 s_attr_isakmp_hash(k
)
690 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_hash
); i
++)
691 if (name_attr_isakmp_hash
[i
].key
== k
)
692 return name_attr_isakmp_hash
[i
].str
;
696 static struct ksmap name_attr_isakmp_method
[] = {
697 { OAKLEY_ATTR_AUTH_METHOD_PSKEY
, "pre-shared key", NULL
},
698 { OAKLEY_ATTR_AUTH_METHOD_DSSSIG
, "DSS signatures", NULL
},
699 { OAKLEY_ATTR_AUTH_METHOD_RSASIG
, "RSA signatures", NULL
},
700 { OAKLEY_ATTR_AUTH_METHOD_RSAENC
, "Encryption with RSA", NULL
},
701 { OAKLEY_ATTR_AUTH_METHOD_RSAREV
, "Revised encryption with RSA", NULL
},
702 { OAKLEY_ATTR_AUTH_METHOD_EGENC
, "Encryption with El-Gamal", NULL
},
703 { OAKLEY_ATTR_AUTH_METHOD_EGREV
, "Revised encryption with El-Gamal", NULL
},
705 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_R
, "Hybrid DSS server", NULL
},
706 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_R
, "Hybrid RSA server", NULL
},
707 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_I
, "Hybrid DSS client", NULL
},
708 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_I
, "Hybrid RSA client", NULL
},
709 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_I
, "XAuth pskey client", NULL
},
710 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_R
, "XAuth pskey server", NULL
},
711 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_I
, "XAuth RSASIG client", NULL
},
712 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_R
, "XAuth RSASIG server", NULL
},
717 s_oakley_attr_method(k
)
721 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_method
); i
++)
722 if (name_attr_isakmp_method
[i
].key
== k
)
723 return name_attr_isakmp_method
[i
].str
;
727 static struct ksmap name_attr_isakmp_desc
[] = {
728 { OAKLEY_ATTR_GRP_DESC_MODP768
, "768-bit MODP group", NULL
},
729 { OAKLEY_ATTR_GRP_DESC_MODP1024
, "1024-bit MODP group", NULL
},
730 { OAKLEY_ATTR_GRP_DESC_EC2N155
, "EC2N group on GP[2^155]", NULL
},
731 { OAKLEY_ATTR_GRP_DESC_EC2N185
, "EC2N group on GP[2^185]", NULL
},
732 { OAKLEY_ATTR_GRP_DESC_MODP1536
, "1536-bit MODP group", NULL
},
733 { OAKLEY_ATTR_GRP_DESC_MODP2048
, "2048-bit MODP group", NULL
},
734 { OAKLEY_ATTR_GRP_DESC_MODP3072
, "3072-bit MODP group", NULL
},
735 { OAKLEY_ATTR_GRP_DESC_MODP4096
, "4096-bit MODP group", NULL
},
736 { OAKLEY_ATTR_GRP_DESC_MODP6144
, "6144-bit MODP group", NULL
},
737 { OAKLEY_ATTR_GRP_DESC_MODP8192
, "8192-bit MODP group", NULL
},
741 s_attr_isakmp_desc(k
)
745 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_desc
); i
++)
746 if (name_attr_isakmp_desc
[i
].key
== k
)
747 return name_attr_isakmp_desc
[i
].str
;
751 static struct ksmap name_attr_isakmp_group
[] = {
752 { OAKLEY_ATTR_GRP_TYPE_MODP
, "MODP", NULL
},
753 { OAKLEY_ATTR_GRP_TYPE_ECP
, "ECP", NULL
},
754 { OAKLEY_ATTR_GRP_TYPE_EC2N
, "EC2N", NULL
},
758 s_attr_isakmp_group(k
)
762 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_group
); i
++)
763 if (name_attr_isakmp_group
[i
].key
== k
)
764 return name_attr_isakmp_group
[i
].str
;
768 static struct ksmap name_attr_isakmp_ltype
[] = {
769 { OAKLEY_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
770 { OAKLEY_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
774 s_attr_isakmp_ltype(k
)
778 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_ltype
); i
++)
779 if (name_attr_isakmp_ltype
[i
].key
== k
)
780 return name_attr_isakmp_ltype
[i
].str
;
785 s_oakley_attr_v(type
, val
)
789 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
790 if (name_oakley_attr
[i
].key
== type
791 && name_oakley_attr
[i
].f
)
792 return (name_oakley_attr
[i
].f
)(val
);
796 /* netinet6/ipsec.h */
797 static struct ksmap name_ipsec_level
[] = {
798 { IPSEC_LEVEL_USE
, "use", NULL
},
799 { IPSEC_LEVEL_REQUIRE
, "require", NULL
},
800 { IPSEC_LEVEL_UNIQUE
, "unique", NULL
},
808 for (i
= 0; i
< ARRAYLEN(name_ipsec_level
); i
++)
809 if (name_ipsec_level
[i
].key
== k
)
810 return name_ipsec_level
[i
].str
;
814 static struct ksmap name_algclass
[] = {
815 { algclass_ipsec_enc
, "ipsec enc", s_ipsecdoi_trns_esp
},
816 { algclass_ipsec_auth
, "ipsec auth", s_ipsecdoi_trns_ah
},
817 { algclass_ipsec_comp
, "ipsec comp", s_ipsecdoi_trns_ipcomp
},
818 { algclass_isakmp_enc
, "isakmp enc", s_attr_isakmp_enc
},
819 { algclass_isakmp_hash
, "isakmp hash", s_attr_isakmp_hash
},
820 { algclass_isakmp_dh
, "isakmp dh", s_attr_isakmp_desc
},
821 { algclass_isakmp_ameth
, "isakmp auth method", s_oakley_attr_method
},
829 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
830 if (name_algclass
[i
].key
== k
)
831 return name_algclass
[i
].str
;
840 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
841 if (name_algclass
[i
].key
== class
842 && name_algclass
[i
].f
)
843 return (name_algclass
[i
].f
)(n
);
848 static struct ksmap name_pfkey_type
[] = {
849 { SADB_GETSPI
, "GETSPI", NULL
},
850 { SADB_UPDATE
, "UPDATE", NULL
},
851 { SADB_ADD
, "ADD", NULL
},
852 { SADB_DELETE
, "DELETE", NULL
},
853 { SADB_GET
, "GET", NULL
},
854 { SADB_ACQUIRE
, "ACQUIRE", NULL
},
855 { SADB_REGISTER
, "REGISTER", NULL
},
856 { SADB_EXPIRE
, "EXPIRE", NULL
},
857 { SADB_FLUSH
, "FLUSH", NULL
},
858 { SADB_DUMP
, "DUMP", NULL
},
859 { SADB_X_PROMISC
, "X_PROMISC", NULL
},
860 { SADB_X_PCHANGE
, "X_PCHANGE", NULL
},
861 { SADB_X_SPDUPDATE
, "X_SPDUPDATE", NULL
},
862 { SADB_X_SPDADD
, "X_SPDADD", NULL
},
863 { SADB_X_SPDDELETE
, "X_SPDDELETE", NULL
},
864 { SADB_X_SPDGET
, "X_SPDGET", NULL
},
865 { SADB_X_SPDACQUIRE
, "X_SPDACQUIRE", NULL
},
866 { SADB_X_SPDDUMP
, "X_SPDDUMP", NULL
},
867 { SADB_X_SPDFLUSH
, "X_SPDFLUSH", NULL
},
868 { SADB_X_SPDSETIDX
, "X_SPDSETIDX", NULL
},
869 { SADB_X_SPDEXPIRE
, "X_SPDEXPIRE", NULL
},
870 { SADB_X_SPDDELETE2
, "X_SPDDELETE2", NULL
},
871 { SADB_GETSASTAT
, "X_GETSASTAT", NULL
},
872 #ifdef SADB_X_NAT_T_NEW_MAPPING
873 { SADB_X_NAT_T_NEW_MAPPING
, "X_NAT_T_NEW_MAPPING", NULL
},
875 #ifdef SADB_X_MIGRATE
876 { SADB_X_MIGRATE
, "X_MIGRATE", NULL
},
885 for (i
= 0; i
< ARRAYLEN(name_pfkey_type
); i
++)
886 if (name_pfkey_type
[i
].key
== k
)
887 return name_pfkey_type
[i
].str
;
891 static struct ksmap name_pfkey_satype
[] = {
892 { SADB_SATYPE_UNSPEC
, "UNSPEC", NULL
},
893 { SADB_SATYPE_AH
, "AH", NULL
},
894 { SADB_SATYPE_ESP
, "ESP", NULL
},
895 { SADB_SATYPE_RSVP
, "RSVP", NULL
},
896 { SADB_SATYPE_OSPFV2
, "OSPFV2", NULL
},
897 { SADB_SATYPE_RIPV2
, "RIPV2", NULL
},
898 { SADB_SATYPE_MIP
, "MIP", NULL
},
899 { SADB_X_SATYPE_IPCOMP
, "IPCOMP", NULL
},
907 for (i
= 0; i
< ARRAYLEN(name_pfkey_satype
); i
++)
908 if (name_pfkey_satype
[i
].key
== k
)
909 return name_pfkey_satype
[i
].str
;
913 static struct ksmap name_direction
[] = {
914 { IPSEC_DIR_INBOUND
, "in", NULL
},
915 { IPSEC_DIR_OUTBOUND
, "out", NULL
},
916 #ifdef HAVE_POLICY_FWD
917 { IPSEC_DIR_FWD
, "fwd", NULL
},
926 for (i
= 0; i
< ARRAYLEN(name_direction
); i
++)
927 if (name_direction
[i
].key
== k
)
928 return name_direction
[i
].str
;
945 case IPSEC_ULPROTO_ANY
:
967 case ISAKMP_ETYPE_NONE
:
969 case ISAKMP_ETYPE_BASE
:
971 case ISAKMP_ETYPE_IDENT
:
973 case ISAKMP_ETYPE_AUTH
:
975 case ISAKMP_ETYPE_AGG
:
977 case ISAKMP_ETYPE_INFO
:
979 case ISAKMP_ETYPE_QUICK
:
981 case ISAKMP_ETYPE_NEWGRP
:
983 case ISAKMP_ETYPE_ACKINFO
:
996 case IDTYPE_USERFQDN
:
1000 case IDTYPE_ADDRESS
: