1 /* $NetBSD: strnames.c,v 1.8 2007/07/18 12:07:52 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>
42 #include <netinet/in.h>
55 #include "isakmp_var.h"
58 # include "isakmp_xauth.h"
59 # include "isakmp_unity.h"
60 # include "isakmp_cfg.h"
62 #include "ipsec_doi.h"
67 #include "algorithm.h"
72 char *(*f
) __P((int));
81 snprintf(buf
, sizeof(buf
), "%d", n
);
88 s_isakmp_state(t
, d
, s
)
92 case ISAKMP_ETYPE_AGG
:
96 case PHASE1ST_MSG1SENT
:
98 case PHASE1ST_ESTABLISHED
:
105 case PHASE1ST_MSG1SENT
:
112 case ISAKMP_ETYPE_BASE
:
116 case PHASE1ST_MSG1SENT
:
117 return "base I msg1";
118 case PHASE1ST_MSG2SENT
:
119 return "base I msg2";
125 case PHASE1ST_MSG1SENT
:
126 return "base R msg1";
127 case PHASE1ST_ESTABLISHED
:
128 return "base R msg2";
134 case ISAKMP_ETYPE_IDENT
:
138 case PHASE1ST_MSG1SENT
:
139 return "ident I msg1";
140 case PHASE1ST_MSG2SENT
:
141 return "ident I msg2";
142 case PHASE1ST_MSG3SENT
:
143 return "ident I msg3";
149 case PHASE1ST_MSG1SENT
:
150 return "ident R msg1";
151 case PHASE1ST_MSG2SENT
:
152 return "ident R msg2";
153 case PHASE1ST_ESTABLISHED
:
154 return "ident R msg3";
160 case ISAKMP_ETYPE_QUICK
:
164 case PHASE2ST_MSG1SENT
:
165 return "quick I msg1";
167 return "quick I msg2";
173 case PHASE2ST_MSG1SENT
:
174 return "quick R msg1";
175 case PHASE2ST_COMMIT
:
176 return "quick R msg2";
183 case ISAKMP_ETYPE_NONE
:
184 case ISAKMP_ETYPE_AUTH
:
185 case ISAKMP_ETYPE_INFO
:
186 case ISAKMP_ETYPE_NEWGRP
:
187 case ISAKMP_ETYPE_ACKINFO
:
195 static struct ksmap name_isakmp_certtype
[] = {
196 { ISAKMP_CERT_NONE
, "NONE", NULL
},
197 { ISAKMP_CERT_PKCS7
, "PKCS #7 wrapped X.509 certificate", NULL
},
198 { ISAKMP_CERT_PGP
, "PGP Certificate", NULL
},
199 { ISAKMP_CERT_DNS
, "DNS Signed Key", NULL
},
200 { ISAKMP_CERT_X509SIGN
, "X.509 Certificate Signature", NULL
},
201 { ISAKMP_CERT_X509KE
, "X.509 Certificate Key Exchange", NULL
},
202 { ISAKMP_CERT_KERBEROS
, "Kerberos Tokens", NULL
},
203 { ISAKMP_CERT_CRL
, "Certificate Revocation List (CRL)", NULL
},
204 { ISAKMP_CERT_ARL
, "Authority Revocation List (ARL)", NULL
},
205 { ISAKMP_CERT_SPKI
, "SPKI Certificate", NULL
},
206 { ISAKMP_CERT_X509ATTR
, "X.509 Certificate Attribute", NULL
},
214 for (i
= 0; i
< ARRAYLEN(name_isakmp_certtype
); i
++)
215 if (name_isakmp_certtype
[i
].key
== k
)
216 return name_isakmp_certtype
[i
].str
;
220 static struct ksmap name_isakmp_etype
[] = {
221 { ISAKMP_ETYPE_NONE
, "None", NULL
},
222 { ISAKMP_ETYPE_BASE
, "Base", NULL
},
223 { ISAKMP_ETYPE_IDENT
, "Identity Protection", NULL
},
224 { ISAKMP_ETYPE_AUTH
, "Authentication Only", NULL
},
225 { ISAKMP_ETYPE_AGG
, "Aggressive", NULL
},
226 { ISAKMP_ETYPE_INFO
, "Informational", NULL
},
227 { ISAKMP_ETYPE_CFG
, "Mode config", NULL
},
228 { ISAKMP_ETYPE_QUICK
, "Quick", NULL
},
229 { ISAKMP_ETYPE_NEWGRP
, "New Group", NULL
},
230 { ISAKMP_ETYPE_ACKINFO
, "Acknowledged Informational", NULL
},
238 for (i
= 0; i
< ARRAYLEN(name_isakmp_etype
); i
++)
239 if (name_isakmp_etype
[i
].key
== k
)
240 return name_isakmp_etype
[i
].str
;
244 static struct ksmap name_isakmp_notify_msg
[] = {
245 { ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE
, "INVALID-PAYLOAD-TYPE", NULL
},
246 { ISAKMP_NTYPE_DOI_NOT_SUPPORTED
, "DOI-NOT-SUPPORTED", NULL
},
247 { ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED
, "SITUATION-NOT-SUPPORTED", NULL
},
248 { ISAKMP_NTYPE_INVALID_COOKIE
, "INVALID-COOKIE", NULL
},
249 { ISAKMP_NTYPE_INVALID_MAJOR_VERSION
, "INVALID-MAJOR-VERSION", NULL
},
250 { ISAKMP_NTYPE_INVALID_MINOR_VERSION
, "INVALID-MINOR-VERSION", NULL
},
251 { ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE
, "INVALID-EXCHANGE-TYPE", NULL
},
252 { ISAKMP_NTYPE_INVALID_FLAGS
, "INVALID-FLAGS", NULL
},
253 { ISAKMP_NTYPE_INVALID_MESSAGE_ID
, "INVALID-MESSAGE-ID", NULL
},
254 { ISAKMP_NTYPE_INVALID_PROTOCOL_ID
, "INVALID-PROTOCOL-ID", NULL
},
255 { ISAKMP_NTYPE_INVALID_SPI
, "INVALID-SPI", NULL
},
256 { ISAKMP_NTYPE_INVALID_TRANSFORM_ID
, "INVALID-TRANSFORM-ID", NULL
},
257 { ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED
, "ATTRIBUTES-NOT-SUPPORTED", NULL
},
258 { ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN
, "NO-PROPOSAL-CHOSEN", NULL
},
259 { ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX
, "BAD-PROPOSAL-SYNTAX", NULL
},
260 { ISAKMP_NTYPE_PAYLOAD_MALFORMED
, "PAYLOAD-MALFORMED", NULL
},
261 { ISAKMP_NTYPE_INVALID_KEY_INFORMATION
, "INVALID-KEY-INFORMATION", NULL
},
262 { ISAKMP_NTYPE_INVALID_ID_INFORMATION
, "INVALID-ID-INFORMATION", NULL
},
263 { ISAKMP_NTYPE_INVALID_CERT_ENCODING
, "INVALID-CERT-ENCODING", NULL
},
264 { ISAKMP_NTYPE_INVALID_CERTIFICATE
, "INVALID-CERTIFICATE", NULL
},
265 { ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX
, "BAD-CERT-REQUEST-SYNTAX", NULL
},
266 { ISAKMP_NTYPE_INVALID_CERT_AUTHORITY
, "INVALID-CERT-AUTHORITY", NULL
},
267 { ISAKMP_NTYPE_INVALID_HASH_INFORMATION
, "INVALID-HASH-INFORMATION", NULL
},
268 { ISAKMP_NTYPE_AUTHENTICATION_FAILED
, "AUTHENTICATION-FAILED", NULL
},
269 { ISAKMP_NTYPE_INVALID_SIGNATURE
, "INVALID-SIGNATURE", NULL
},
270 { ISAKMP_NTYPE_ADDRESS_NOTIFICATION
, "ADDRESS-NOTIFICATION", NULL
},
271 { ISAKMP_NTYPE_NOTIFY_SA_LIFETIME
, "NOTIFY-SA-LIFETIME", NULL
},
272 { ISAKMP_NTYPE_CERTIFICATE_UNAVAILABLE
, "CERTIFICATE-UNAVAILABLE", NULL
},
273 { ISAKMP_NTYPE_UNSUPPORTED_EXCHANGE_TYPE
, "UNSUPPORTED-EXCHANGE-TYPE", NULL
},
274 { ISAKMP_NTYPE_UNEQUAL_PAYLOAD_LENGTHS
, "UNEQUAL-PAYLOAD-LENGTHS", NULL
},
275 { ISAKMP_NTYPE_CONNECTED
, "CONNECTED", NULL
},
276 { ISAKMP_NTYPE_RESPONDER_LIFETIME
, "RESPONDER-LIFETIME", NULL
},
277 { ISAKMP_NTYPE_REPLAY_STATUS
, "REPLAY-STATUS", NULL
},
278 { ISAKMP_NTYPE_INITIAL_CONTACT
, "INITIAL-CONTACT", NULL
},
279 { ISAKMP_NTYPE_R_U_THERE
, "R-U-THERE", NULL
},
280 { ISAKMP_NTYPE_R_U_THERE_ACK
, "R-U-THERE-ACK", NULL
},
282 { ISAKMP_NTYPE_UNITY_HEARTBEAT
, "HEARTBEAT (Unity)", NULL
},
284 { ISAKMP_LOG_RETRY_LIMIT_REACHED
, "RETRY-LIMIT-REACHED", NULL
},
288 s_isakmp_notify_msg(k
)
292 for (i
= 0; i
< ARRAYLEN(name_isakmp_notify_msg
); i
++)
293 if (name_isakmp_notify_msg
[i
].key
== k
)
294 return name_isakmp_notify_msg
[i
].str
;
299 static struct ksmap name_isakmp_nptype
[] = {
300 { ISAKMP_NPTYPE_NONE
, "none", NULL
},
301 { ISAKMP_NPTYPE_SA
, "sa", NULL
},
302 { ISAKMP_NPTYPE_P
, "prop", NULL
},
303 { ISAKMP_NPTYPE_T
, "trns", NULL
},
304 { ISAKMP_NPTYPE_KE
, "ke", NULL
},
305 { ISAKMP_NPTYPE_ID
, "id", NULL
},
306 { ISAKMP_NPTYPE_CERT
, "cert", NULL
},
307 { ISAKMP_NPTYPE_CR
, "cr", NULL
},
308 { ISAKMP_NPTYPE_HASH
, "hash", NULL
},
309 { ISAKMP_NPTYPE_SIG
, "sig", NULL
},
310 { ISAKMP_NPTYPE_NONCE
, "nonce", NULL
},
311 { ISAKMP_NPTYPE_N
, "notify", NULL
},
312 { ISAKMP_NPTYPE_D
, "delete", NULL
},
313 { ISAKMP_NPTYPE_VID
, "vid", NULL
},
314 { ISAKMP_NPTYPE_ATTR
, "attr", NULL
},
315 { ISAKMP_NPTYPE_GSS
, "gss id", NULL
},
316 { ISAKMP_NPTYPE_NATD_RFC
, "nat-d", NULL
},
317 { ISAKMP_NPTYPE_NATOA_RFC
, "nat-oa", NULL
},
318 { ISAKMP_NPTYPE_NATD_DRAFT
, "nat-d", NULL
},
319 { ISAKMP_NPTYPE_NATOA_DRAFT
, "nat-oa", NULL
},
320 { ISAKMP_NPTYPE_FRAG
, "ike frag", NULL
},
328 for (i
= 0; i
< ARRAYLEN(name_isakmp_nptype
); i
++)
329 if (name_isakmp_nptype
[i
].key
== k
)
330 return name_isakmp_nptype
[i
].str
;
335 /* isakmp_cfg.h / isakmp_unity.h / isakmp_xauth.h */
336 static struct ksmap name_isakmp_cfg_type
[] = {
337 { INTERNAL_IP4_ADDRESS
, "INTERNAL_IP4_ADDRESS", NULL
},
338 { INTERNAL_IP4_NETMASK
, "INTERNAL_IP4_NETMASK", NULL
},
339 { INTERNAL_IP4_DNS
, "INTERNAL_IP4_DNS", NULL
},
340 { INTERNAL_IP4_NBNS
, "INTERNAL_IP4_NBNS", NULL
},
341 { INTERNAL_ADDRESS_EXPIRY
, "INTERNAL_ADDRESS_EXPIRY", NULL
},
342 { INTERNAL_IP4_DHCP
, "INTERNAL_IP4_DHCP", NULL
},
343 { APPLICATION_VERSION
, "APPLICATION_VERSION", NULL
},
344 { INTERNAL_IP6_ADDRESS
, "INTERNAL_IP6_ADDRESS", NULL
},
345 { INTERNAL_IP6_NETMASK
, "INTERNAL_IP6_NETMASK", NULL
},
346 { INTERNAL_IP6_DNS
, "INTERNAL_IP6_DNS", NULL
},
347 { INTERNAL_IP6_NBNS
, "INTERNAL_IP6_NBNS", NULL
},
348 { INTERNAL_IP6_DHCP
, "INTERNAL_IP6_DHCP", NULL
},
349 { INTERNAL_IP4_SUBNET
, "INTERNAL_IP4_SUBNET", NULL
},
350 { SUPPORTED_ATTRIBUTES
, "SUPPORTED_ATTRIBUTES", NULL
},
351 { INTERNAL_IP6_SUBNET
, "INTERNAL_IP6_SUBNET", NULL
},
352 { XAUTH_TYPE
, "XAUTH_TYPE", NULL
},
353 { XAUTH_USER_NAME
, "XAUTH_USER_NAME", NULL
},
354 { XAUTH_USER_PASSWORD
, "XAUTH_USER_PASSWORD", NULL
},
355 { XAUTH_PASSCODE
, "XAUTH_PASSCODE", NULL
},
356 { XAUTH_MESSAGE
, "XAUTH_MESSAGE", NULL
},
357 { XAUTH_CHALLENGE
, "XAUTH_CHALLENGE", NULL
},
358 { XAUTH_DOMAIN
, "XAUTH_DOMAIN", NULL
},
359 { XAUTH_STATUS
, "XAUTH_STATUS", NULL
},
360 { XAUTH_NEXT_PIN
, "XAUTH_NEXT_PIN", NULL
},
361 { XAUTH_ANSWER
, "XAUTH_ANSWER", NULL
},
362 { UNITY_BANNER
, "UNITY_BANNER", NULL
},
363 { UNITY_SAVE_PASSWD
, "UNITY_SAVE_PASSWD", NULL
},
364 { UNITY_DEF_DOMAIN
, "UNITY_DEF_DOMAIN", NULL
},
365 { UNITY_SPLITDNS_NAME
, "UNITY_SPLITDNS_NAME", NULL
},
366 { UNITY_SPLIT_INCLUDE
, "UNITY_SPLIT_INCLUDE", NULL
},
367 { UNITY_NATT_PORT
, "UNITY_NATT_PORT", NULL
},
368 { UNITY_LOCAL_LAN
, "UNITY_LOCAL_LAN", NULL
},
369 { UNITY_PFS
, "UNITY_PFS", NULL
},
370 { UNITY_FW_TYPE
, "UNITY_FW_TYPE", NULL
},
371 { UNITY_BACKUP_SERVERS
, "UNITY_BACKUP_SERVERS", NULL
},
372 { UNITY_DDNS_HOSTNAME
, "UNITY_DDNS_HOSTNAME", NULL
},
380 for (i
= 0; i
< ARRAYLEN(name_isakmp_cfg_type
); i
++)
381 if (name_isakmp_cfg_type
[i
].key
== k
)
382 return name_isakmp_cfg_type
[i
].str
;
386 /* isakmp_cfg.h / isakmp_unity.h / isakmp_xauth.h */
387 static struct ksmap name_isakmp_cfg_ptype
[] = {
388 { ISAKMP_CFG_ACK
, "mode config ACK", NULL
},
389 { ISAKMP_CFG_SET
, "mode config SET", NULL
},
390 { ISAKMP_CFG_REQUEST
, "mode config REQUEST", NULL
},
391 { ISAKMP_CFG_REPLY
, "mode config REPLY", NULL
},
395 s_isakmp_cfg_ptype(k
)
399 for (i
= 0; i
< ARRAYLEN(name_isakmp_cfg_ptype
); i
++)
400 if (name_isakmp_cfg_ptype
[i
].key
== k
)
401 return name_isakmp_cfg_ptype
[i
].str
;
408 static struct ksmap name_ipsecdoi_proto
[] = {
409 { IPSECDOI_PROTO_ISAKMP
, "ISAKMP", s_ipsecdoi_trns_isakmp
},
410 { IPSECDOI_PROTO_IPSEC_AH
, "AH", s_ipsecdoi_trns_ah
},
411 { IPSECDOI_PROTO_IPSEC_ESP
, "ESP", s_ipsecdoi_trns_esp
},
412 { IPSECDOI_PROTO_IPCOMP
, "IPCOMP", s_ipsecdoi_trns_ipcomp
},
420 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
421 if (name_ipsecdoi_proto
[i
].key
== k
)
422 return name_ipsecdoi_proto
[i
].str
;
426 static struct ksmap name_ipsecdoi_trns_isakmp
[] = {
427 { IPSECDOI_KEY_IKE
, "IKE", NULL
},
431 s_ipsecdoi_trns_isakmp(k
)
435 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_isakmp
); i
++)
436 if (name_ipsecdoi_trns_isakmp
[i
].key
== k
)
437 return name_ipsecdoi_trns_isakmp
[i
].str
;
441 static struct ksmap name_ipsecdoi_trns_ah
[] = {
442 { IPSECDOI_AH_MD5
, "MD5", NULL
},
443 { IPSECDOI_AH_SHA
, "SHA", NULL
},
444 { IPSECDOI_AH_DES
, "DES", NULL
},
445 { IPSECDOI_AH_SHA256
, "SHA256", NULL
},
446 { IPSECDOI_AH_SHA384
, "SHA384", NULL
},
447 { IPSECDOI_AH_SHA512
, "SHA512", NULL
},
451 s_ipsecdoi_trns_ah(k
)
455 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ah
); i
++)
456 if (name_ipsecdoi_trns_ah
[i
].key
== k
)
457 return name_ipsecdoi_trns_ah
[i
].str
;
461 static struct ksmap name_ipsecdoi_trns_esp
[] = {
462 { IPSECDOI_ESP_DES_IV64
, "DES_IV64", NULL
},
463 { IPSECDOI_ESP_DES
, "DES", NULL
},
464 { IPSECDOI_ESP_3DES
, "3DES", NULL
},
465 { IPSECDOI_ESP_RC5
, "RC5", NULL
},
466 { IPSECDOI_ESP_IDEA
, "IDEA", NULL
},
467 { IPSECDOI_ESP_CAST
, "CAST", NULL
},
468 { IPSECDOI_ESP_BLOWFISH
, "BLOWFISH", NULL
},
469 { IPSECDOI_ESP_3IDEA
, "3IDEA", NULL
},
470 { IPSECDOI_ESP_DES_IV32
, "DES_IV32", NULL
},
471 { IPSECDOI_ESP_RC4
, "RC4", NULL
},
472 { IPSECDOI_ESP_NULL
, "NULL", NULL
},
473 { IPSECDOI_ESP_AES
, "AES", NULL
},
474 { IPSECDOI_ESP_TWOFISH
, "TWOFISH", NULL
},
475 { IPSECDOI_ESP_CAMELLIA
, "CAMELLIA", NULL
},
479 s_ipsecdoi_trns_esp(k
)
483 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_esp
); i
++)
484 if (name_ipsecdoi_trns_esp
[i
].key
== k
)
485 return name_ipsecdoi_trns_esp
[i
].str
;
489 static struct ksmap name_ipsecdoi_trns_ipcomp
[] = {
490 { IPSECDOI_IPCOMP_OUI
, "OUI", NULL
},
491 { IPSECDOI_IPCOMP_DEFLATE
, "DEFLATE", NULL
},
492 { IPSECDOI_IPCOMP_LZS
, "LZS", NULL
},
496 s_ipsecdoi_trns_ipcomp(k
)
500 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ipcomp
); i
++)
501 if (name_ipsecdoi_trns_ipcomp
[i
].key
== k
)
502 return name_ipsecdoi_trns_ipcomp
[i
].str
;
507 s_ipsecdoi_trns(proto
, trns
)
511 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
512 if (name_ipsecdoi_proto
[i
].key
== proto
513 && name_ipsecdoi_proto
[i
].f
)
514 return (name_ipsecdoi_proto
[i
].f
)(trns
);
515 return num2str(trns
);
518 static struct ksmap name_attr_ipsec
[] = {
519 { IPSECDOI_ATTR_SA_LD_TYPE
, "SA Life Type", s_ipsecdoi_ltype
},
520 { IPSECDOI_ATTR_SA_LD
, "SA Life Duration", NULL
},
521 { IPSECDOI_ATTR_GRP_DESC
, "Group Description", NULL
},
522 { IPSECDOI_ATTR_ENC_MODE
, "Encryption Mode", s_ipsecdoi_encmode
},
523 { IPSECDOI_ATTR_AUTH
, "Authentication Algorithm", s_ipsecdoi_auth
},
524 { IPSECDOI_ATTR_KEY_LENGTH
, "Key Length", NULL
},
525 { IPSECDOI_ATTR_KEY_ROUNDS
, "Key Rounds", NULL
},
526 { IPSECDOI_ATTR_COMP_DICT_SIZE
, "Compression Dictionary Size", NULL
},
527 { IPSECDOI_ATTR_COMP_PRIVALG
, "Compression Private Algorithm", NULL
},
535 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
536 if (name_attr_ipsec
[i
].key
== k
)
537 return name_attr_ipsec
[i
].str
;
541 static struct ksmap name_attr_ipsec_ltype
[] = {
542 { IPSECDOI_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
543 { IPSECDOI_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
551 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_ltype
); i
++)
552 if (name_attr_ipsec_ltype
[i
].key
== k
)
553 return name_attr_ipsec_ltype
[i
].str
;
557 static struct ksmap name_attr_ipsec_encmode
[] = {
558 { IPSECDOI_ATTR_ENC_MODE_ANY
, "Any", NULL
},
559 { IPSECDOI_ATTR_ENC_MODE_TUNNEL
, "Tunnel", NULL
},
560 { IPSECDOI_ATTR_ENC_MODE_TRNS
, "Transport", NULL
},
561 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC
, "UDP-Tunnel", NULL
},
562 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC
, "UDP-Transport", NULL
},
563 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT
, "UDP-Tunnel", NULL
},
564 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT
, "UDP-Transport", NULL
},
568 s_ipsecdoi_encmode(k
)
572 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_encmode
); i
++)
573 if (name_attr_ipsec_encmode
[i
].key
== k
)
574 return name_attr_ipsec_encmode
[i
].str
;
578 static struct ksmap name_attr_ipsec_auth
[] = {
579 { IPSECDOI_ATTR_AUTH_HMAC_MD5
, "hmac-md5", NULL
},
580 { IPSECDOI_ATTR_AUTH_HMAC_SHA1
, "hmac-sha", NULL
},
581 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_256
, "hmac-sha256", NULL
},
582 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_384
, "hmac-sha384", NULL
},
583 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_512
, "hmac-sha512", NULL
},
584 { IPSECDOI_ATTR_AUTH_DES_MAC
, "des-mac", NULL
},
585 { IPSECDOI_ATTR_AUTH_KPDK
, "kpdk", NULL
},
593 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_auth
); i
++)
594 if (name_attr_ipsec_auth
[i
].key
== k
)
595 return name_attr_ipsec_auth
[i
].str
;
600 s_ipsecdoi_attr_v(type
, val
)
604 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
605 if (name_attr_ipsec
[i
].key
== type
606 && name_attr_ipsec
[i
].f
)
607 return (name_attr_ipsec
[i
].f
)(val
);
611 static struct ksmap name_ipsecdoi_ident
[] = {
612 { IPSECDOI_ID_IPV4_ADDR
, "IPv4_address", NULL
},
613 { IPSECDOI_ID_FQDN
, "FQDN", NULL
},
614 { IPSECDOI_ID_USER_FQDN
, "User_FQDN", NULL
},
615 { IPSECDOI_ID_IPV4_ADDR_SUBNET
, "IPv4_subnet", NULL
},
616 { IPSECDOI_ID_IPV6_ADDR
, "IPv6_address", NULL
},
617 { IPSECDOI_ID_IPV6_ADDR_SUBNET
, "IPv6_subnet", NULL
},
618 { IPSECDOI_ID_IPV4_ADDR_RANGE
, "IPv4_address_range", NULL
},
619 { IPSECDOI_ID_IPV6_ADDR_RANGE
, "IPv6_address_range", NULL
},
620 { IPSECDOI_ID_DER_ASN1_DN
, "DER_ASN1_DN", NULL
},
621 { IPSECDOI_ID_DER_ASN1_GN
, "DER_ASN1_GN", NULL
},
622 { IPSECDOI_ID_KEY_ID
, "KEY_ID", NULL
},
630 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_ident
); i
++)
631 if (name_ipsecdoi_ident
[i
].key
== k
)
632 return name_ipsecdoi_ident
[i
].str
;
637 static struct ksmap name_oakley_attr
[] = {
638 { OAKLEY_ATTR_ENC_ALG
, "Encryption Algorithm", s_attr_isakmp_enc
},
639 { OAKLEY_ATTR_HASH_ALG
, "Hash Algorithm", s_attr_isakmp_hash
},
640 { OAKLEY_ATTR_AUTH_METHOD
, "Authentication Method", s_oakley_attr_method
},
641 { OAKLEY_ATTR_GRP_DESC
, "Group Description", s_attr_isakmp_desc
},
642 { OAKLEY_ATTR_GRP_TYPE
, "Group Type", s_attr_isakmp_group
},
643 { OAKLEY_ATTR_GRP_PI
, "Group Prime/Irreducible Polynomial", NULL
},
644 { OAKLEY_ATTR_GRP_GEN_ONE
, "Group Generator One", NULL
},
645 { OAKLEY_ATTR_GRP_GEN_TWO
, "Group Generator Two", NULL
},
646 { OAKLEY_ATTR_GRP_CURVE_A
, "Group Curve A", NULL
},
647 { OAKLEY_ATTR_GRP_CURVE_B
, "Group Curve B", NULL
},
648 { OAKLEY_ATTR_SA_LD_TYPE
, "Life Type", s_attr_isakmp_ltype
},
649 { OAKLEY_ATTR_SA_LD
, "Life Duration", NULL
},
650 { OAKLEY_ATTR_PRF
, "PRF", NULL
},
651 { OAKLEY_ATTR_KEY_LEN
, "Key Length", NULL
},
652 { OAKLEY_ATTR_FIELD_SIZE
, "Field Size", NULL
},
653 { OAKLEY_ATTR_GRP_ORDER
, "Group Order", NULL
},
654 { OAKLEY_ATTR_BLOCK_SIZE
, "Block Size", NULL
},
655 { OAKLEY_ATTR_GSS_ID
, "GSS-API endpoint name",NULL
},
663 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
664 if (name_oakley_attr
[i
].key
== k
)
665 return name_oakley_attr
[i
].str
;
669 static struct ksmap name_attr_isakmp_enc
[] = {
670 { OAKLEY_ATTR_ENC_ALG_DES
, "DES-CBC", NULL
},
671 { OAKLEY_ATTR_ENC_ALG_IDEA
, "IDEA-CBC", NULL
},
672 { OAKLEY_ATTR_ENC_ALG_BLOWFISH
, "Blowfish-CBC", NULL
},
673 { OAKLEY_ATTR_ENC_ALG_RC5
, "RC5-R16-B64-CBC", NULL
},
674 { OAKLEY_ATTR_ENC_ALG_3DES
, "3DES-CBC", NULL
},
675 { OAKLEY_ATTR_ENC_ALG_CAST
, "CAST-CBC", NULL
},
676 { OAKLEY_ATTR_ENC_ALG_AES
, "AES-CBC", NULL
},
684 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_enc
); i
++)
685 if (name_attr_isakmp_enc
[i
].key
== k
)
686 return name_attr_isakmp_enc
[i
].str
;
690 static struct ksmap name_attr_isakmp_hash
[] = {
691 { OAKLEY_ATTR_HASH_ALG_MD5
, "MD5", NULL
},
692 { OAKLEY_ATTR_HASH_ALG_SHA
, "SHA", NULL
},
693 { OAKLEY_ATTR_HASH_ALG_TIGER
, "Tiger", NULL
},
694 { OAKLEY_ATTR_HASH_ALG_SHA2_256
,"SHA256", NULL
},
695 { OAKLEY_ATTR_HASH_ALG_SHA2_384
,"SHA384", NULL
},
696 { OAKLEY_ATTR_HASH_ALG_SHA2_512
,"SHA512", NULL
},
700 s_attr_isakmp_hash(k
)
704 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_hash
); i
++)
705 if (name_attr_isakmp_hash
[i
].key
== k
)
706 return name_attr_isakmp_hash
[i
].str
;
710 static struct ksmap name_attr_isakmp_method
[] = {
711 { OAKLEY_ATTR_AUTH_METHOD_PSKEY
, "pre-shared key", NULL
},
712 { OAKLEY_ATTR_AUTH_METHOD_DSSSIG
, "DSS signatures", NULL
},
713 { OAKLEY_ATTR_AUTH_METHOD_RSASIG
, "RSA signatures", NULL
},
714 { OAKLEY_ATTR_AUTH_METHOD_RSAENC
, "Encryption with RSA", NULL
},
715 { OAKLEY_ATTR_AUTH_METHOD_RSAREV
, "Revised encryption with RSA", NULL
},
716 { OAKLEY_ATTR_AUTH_METHOD_EGENC
, "Encryption with El-Gamal", NULL
},
717 { OAKLEY_ATTR_AUTH_METHOD_EGREV
, "Revised encryption with El-Gamal", NULL
},
719 { OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
, "GSS-API on Kerberos 5", NULL
},
722 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_R
, "Hybrid DSS server", NULL
},
723 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_R
, "Hybrid RSA server", NULL
},
724 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_I
, "Hybrid DSS client", NULL
},
725 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_I
, "Hybrid RSA client", NULL
},
726 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_I
, "XAuth pskey client", NULL
},
727 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_R
, "XAuth pskey server", NULL
},
728 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_I
, "XAuth RSASIG client", NULL
},
729 { OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_R
, "XAuth RSASIG server", NULL
},
734 s_oakley_attr_method(k
)
738 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_method
); i
++)
739 if (name_attr_isakmp_method
[i
].key
== k
)
740 return name_attr_isakmp_method
[i
].str
;
744 static struct ksmap name_attr_isakmp_desc
[] = {
745 { OAKLEY_ATTR_GRP_DESC_MODP768
, "768-bit MODP group", NULL
},
746 { OAKLEY_ATTR_GRP_DESC_MODP1024
, "1024-bit MODP group", NULL
},
747 { OAKLEY_ATTR_GRP_DESC_EC2N155
, "EC2N group on GP[2^155]", NULL
},
748 { OAKLEY_ATTR_GRP_DESC_EC2N185
, "EC2N group on GP[2^185]", NULL
},
749 { OAKLEY_ATTR_GRP_DESC_MODP1536
, "1536-bit MODP group", NULL
},
750 { OAKLEY_ATTR_GRP_DESC_MODP2048
, "2048-bit MODP group", NULL
},
751 { OAKLEY_ATTR_GRP_DESC_MODP3072
, "3072-bit MODP group", NULL
},
752 { OAKLEY_ATTR_GRP_DESC_MODP4096
, "4096-bit MODP group", NULL
},
753 { OAKLEY_ATTR_GRP_DESC_MODP6144
, "6144-bit MODP group", NULL
},
754 { OAKLEY_ATTR_GRP_DESC_MODP8192
, "8192-bit MODP group", NULL
},
758 s_attr_isakmp_desc(k
)
762 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_desc
); i
++)
763 if (name_attr_isakmp_desc
[i
].key
== k
)
764 return name_attr_isakmp_desc
[i
].str
;
768 static struct ksmap name_attr_isakmp_group
[] = {
769 { OAKLEY_ATTR_GRP_TYPE_MODP
, "MODP", NULL
},
770 { OAKLEY_ATTR_GRP_TYPE_ECP
, "ECP", NULL
},
771 { OAKLEY_ATTR_GRP_TYPE_EC2N
, "EC2N", NULL
},
775 s_attr_isakmp_group(k
)
779 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_group
); i
++)
780 if (name_attr_isakmp_group
[i
].key
== k
)
781 return name_attr_isakmp_group
[i
].str
;
785 static struct ksmap name_attr_isakmp_ltype
[] = {
786 { OAKLEY_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
787 { OAKLEY_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
791 s_attr_isakmp_ltype(k
)
795 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_ltype
); i
++)
796 if (name_attr_isakmp_ltype
[i
].key
== k
)
797 return name_attr_isakmp_ltype
[i
].str
;
802 s_oakley_attr_v(type
, val
)
806 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
807 if (name_oakley_attr
[i
].key
== type
808 && name_oakley_attr
[i
].f
)
809 return (name_oakley_attr
[i
].f
)(val
);
813 /* netinet6/ipsec.h */
814 static struct ksmap name_ipsec_level
[] = {
815 { IPSEC_LEVEL_USE
, "use", NULL
},
816 { IPSEC_LEVEL_REQUIRE
, "require", NULL
},
817 { IPSEC_LEVEL_UNIQUE
, "unique", NULL
},
825 for (i
= 0; i
< ARRAYLEN(name_ipsec_level
); i
++)
826 if (name_ipsec_level
[i
].key
== k
)
827 return name_ipsec_level
[i
].str
;
831 static struct ksmap name_algclass
[] = {
832 { algclass_ipsec_enc
, "ipsec enc", s_ipsecdoi_trns_esp
},
833 { algclass_ipsec_auth
, "ipsec auth", s_ipsecdoi_trns_ah
},
834 { algclass_ipsec_comp
, "ipsec comp", s_ipsecdoi_trns_ipcomp
},
835 { algclass_isakmp_enc
, "isakmp enc", s_attr_isakmp_enc
},
836 { algclass_isakmp_hash
, "isakmp hash", s_attr_isakmp_hash
},
837 { algclass_isakmp_dh
, "isakmp dh", s_attr_isakmp_desc
},
838 { algclass_isakmp_ameth
, "isakmp auth method", s_oakley_attr_method
},
846 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
847 if (name_algclass
[i
].key
== k
)
848 return name_algclass
[i
].str
;
857 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
858 if (name_algclass
[i
].key
== class
859 && name_algclass
[i
].f
)
860 return (name_algclass
[i
].f
)(n
);
865 static struct ksmap name_pfkey_type
[] = {
866 { SADB_GETSPI
, "GETSPI", NULL
},
867 { SADB_UPDATE
, "UPDATE", NULL
},
868 { SADB_ADD
, "ADD", NULL
},
869 { SADB_DELETE
, "DELETE", NULL
},
870 { SADB_GET
, "GET", NULL
},
871 { SADB_ACQUIRE
, "ACQUIRE", NULL
},
872 { SADB_REGISTER
, "REGISTER", NULL
},
873 { SADB_EXPIRE
, "EXPIRE", NULL
},
874 { SADB_FLUSH
, "FLUSH", NULL
},
875 { SADB_DUMP
, "DUMP", NULL
},
876 { SADB_X_PROMISC
, "X_PROMISC", NULL
},
877 { SADB_X_PCHANGE
, "X_PCHANGE", NULL
},
878 { SADB_X_SPDUPDATE
, "X_SPDUPDATE", NULL
},
879 { SADB_X_SPDADD
, "X_SPDADD", NULL
},
880 { SADB_X_SPDDELETE
, "X_SPDDELETE", NULL
},
881 { SADB_X_SPDGET
, "X_SPDGET", NULL
},
882 { SADB_X_SPDACQUIRE
, "X_SPDACQUIRE", NULL
},
883 { SADB_X_SPDDUMP
, "X_SPDDUMP", NULL
},
884 { SADB_X_SPDFLUSH
, "X_SPDFLUSH", NULL
},
885 { SADB_X_SPDSETIDX
, "X_SPDSETIDX", NULL
},
886 { SADB_X_SPDEXPIRE
, "X_SPDEXPIRE", NULL
},
887 { SADB_X_SPDDELETE2
, "X_SPDDELETE2", NULL
},
888 #ifdef SADB_X_NAT_T_NEW_MAPPING
889 { SADB_X_NAT_T_NEW_MAPPING
, "X_NAT_T_NEW_MAPPING", NULL
},
891 #ifdef SADB_X_MIGRATE
892 { SADB_X_MIGRATE
, "X_MIGRATE", NULL
},
901 for (i
= 0; i
< ARRAYLEN(name_pfkey_type
); i
++)
902 if (name_pfkey_type
[i
].key
== k
)
903 return name_pfkey_type
[i
].str
;
907 static struct ksmap name_pfkey_satype
[] = {
908 { SADB_SATYPE_UNSPEC
, "UNSPEC", NULL
},
909 { SADB_SATYPE_AH
, "AH", NULL
},
910 { SADB_SATYPE_ESP
, "ESP", NULL
},
911 { SADB_SATYPE_RSVP
, "RSVP", NULL
},
912 { SADB_SATYPE_OSPFV2
, "OSPFV2", NULL
},
913 { SADB_SATYPE_RIPV2
, "RIPV2", NULL
},
914 { SADB_SATYPE_MIP
, "MIP", NULL
},
915 { SADB_X_SATYPE_IPCOMP
, "IPCOMP", NULL
},
923 for (i
= 0; i
< ARRAYLEN(name_pfkey_satype
); i
++)
924 if (name_pfkey_satype
[i
].key
== k
)
925 return name_pfkey_satype
[i
].str
;
929 static struct ksmap name_direction
[] = {
930 { IPSEC_DIR_INBOUND
, "in", NULL
},
931 { IPSEC_DIR_OUTBOUND
, "out", NULL
},
932 #ifdef HAVE_POLICY_FWD
933 { IPSEC_DIR_FWD
, "fwd", NULL
},
942 for (i
= 0; i
< ARRAYLEN(name_direction
); i
++)
943 if (name_direction
[i
].key
== k
)
944 return name_direction
[i
].str
;
961 case IPSEC_ULPROTO_ANY
:
983 case ISAKMP_ETYPE_NONE
:
985 case ISAKMP_ETYPE_BASE
:
987 case ISAKMP_ETYPE_IDENT
:
989 case ISAKMP_ETYPE_AUTH
:
991 case ISAKMP_ETYPE_AGG
:
993 case ISAKMP_ETYPE_INFO
:
995 case ISAKMP_ETYPE_QUICK
:
997 case ISAKMP_ETYPE_NEWGRP
:
999 case ISAKMP_ETYPE_ACKINFO
:
1012 case IDTYPE_USERFQDN
:
1016 case IDTYPE_ADDRESS
: