1 /* $KAME: strnames.c,v 1.25 2003/11/13 10:53:26 itojun Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
34 #include <sys/types.h>
35 #include <sys/param.h>
36 #include <sys/socket.h>
38 #include <netinet/in.h>
39 #ifdef HAVE_NETINET6_IPSEC
40 # include <netinet6/ipsec.h>
42 # include <netinet/ipsec.h>
44 #include <netinet/in.h>
54 #include "isakmp_var.h"
56 #include "ipsec_doi.h"
61 #include "algorithm.h"
66 char *(*f
) __P((int));
75 snprintf(buf
, sizeof(buf
), "%d", n
);
82 s_isakmp_state(t
, d
, s
)
86 case ISAKMP_ETYPE_AGG
:
90 case PHASE1ST_MSG1SENT
:
92 case PHASE1ST_ESTABLISHED
:
99 case PHASE1ST_MSG1SENT
:
106 case ISAKMP_ETYPE_BASE
:
110 case PHASE1ST_MSG1SENT
:
111 return "base I msg1";
112 case PHASE1ST_MSG2SENT
:
113 return "base I msg2";
119 case PHASE1ST_MSG1SENT
:
120 return "base R msg1";
121 case PHASE1ST_ESTABLISHED
:
122 return "base R msg2";
128 case ISAKMP_ETYPE_IDENT
:
132 case PHASE1ST_MSG1SENT
:
133 return "ident I msg1";
134 case PHASE1ST_MSG2SENT
:
135 return "ident I msg2";
136 case PHASE1ST_MSG3SENT
:
137 return "ident I msg3";
143 case PHASE1ST_MSG1SENT
:
144 return "ident R msg1";
145 case PHASE1ST_MSG2SENT
:
146 return "ident R msg2";
147 case PHASE1ST_ESTABLISHED
:
148 return "ident R msg3";
154 case ISAKMP_ETYPE_QUICK
:
158 case PHASE2ST_MSG1SENT
:
159 return "quick I msg1";
161 return "quick I msg2";
167 case PHASE2ST_MSG1SENT
:
168 return "quick R msg1";
169 case PHASE2ST_COMMIT
:
170 return "quick R msg2";
177 case ISAKMP_ETYPE_NONE
:
178 case ISAKMP_ETYPE_AUTH
:
179 case ISAKMP_ETYPE_INFO
:
180 case ISAKMP_ETYPE_NEWGRP
:
181 case ISAKMP_ETYPE_ACKINFO
:
189 static struct ksmap name_isakmp_certtype
[] = {
190 { ISAKMP_CERT_NONE
, "NONE", NULL
},
191 { ISAKMP_CERT_PKCS7
, "PKCS #7 wrapped X.509 certificate", NULL
},
192 { ISAKMP_CERT_PGP
, "PGP Certificate", NULL
},
193 { ISAKMP_CERT_DNS
, "DNS Signed Key", NULL
},
194 { ISAKMP_CERT_X509SIGN
, "X.509 Certificate Signature", NULL
},
195 { ISAKMP_CERT_X509KE
, "X.509 Certificate Key Exchange", NULL
},
196 { ISAKMP_CERT_KERBEROS
, "Kerberos Tokens", NULL
},
197 { ISAKMP_CERT_CRL
, "Certificate Revocation List (CRL)", NULL
},
198 { ISAKMP_CERT_ARL
, "Authority Revocation List (ARL)", NULL
},
199 { ISAKMP_CERT_SPKI
, "SPKI Certificate", NULL
},
200 { ISAKMP_CERT_X509ATTR
, "X.509 Certificate Attribute", NULL
},
208 for (i
= 0; i
< ARRAYLEN(name_isakmp_certtype
); i
++)
209 if (name_isakmp_certtype
[i
].key
== k
)
210 return name_isakmp_certtype
[i
].str
;
214 static struct ksmap name_isakmp_etype
[] = {
215 { ISAKMP_ETYPE_NONE
, "None", NULL
},
216 { ISAKMP_ETYPE_BASE
, "Base", NULL
},
217 { ISAKMP_ETYPE_IDENT
, "Identity Protection", NULL
},
218 { ISAKMP_ETYPE_AUTH
, "Authentication Only", NULL
},
219 { ISAKMP_ETYPE_AGG
, "Aggressive", NULL
},
220 { ISAKMP_ETYPE_INFO
, "Informational", NULL
},
221 { ISAKMP_ETYPE_QUICK
, "Quick", NULL
},
222 { ISAKMP_ETYPE_NEWGRP
, "New Group", NULL
},
223 { ISAKMP_ETYPE_ACKINFO
, "Acknowledged Informational", NULL
},
231 for (i
= 0; i
< ARRAYLEN(name_isakmp_etype
); i
++)
232 if (name_isakmp_etype
[i
].key
== k
)
233 return name_isakmp_etype
[i
].str
;
237 static struct ksmap name_isakmp_notify_msg
[] = {
238 { ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE
, "INVALID-PAYLOAD-TYPE", NULL
},
239 { ISAKMP_NTYPE_DOI_NOT_SUPPORTED
, "DOI-NOT-SUPPORTED", NULL
},
240 { ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED
, "SITUATION-NOT-SUPPORTED", NULL
},
241 { ISAKMP_NTYPE_INVALID_COOKIE
, "INVALID-COOKIE", NULL
},
242 { ISAKMP_NTYPE_INVALID_MAJOR_VERSION
, "INVALID-MAJOR-VERSION", NULL
},
243 { ISAKMP_NTYPE_INVALID_MINOR_VERSION
, "INVALID-MINOR-VERSION", NULL
},
244 { ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE
, "INVALID-EXCHANGE-TYPE", NULL
},
245 { ISAKMP_NTYPE_INVALID_FLAGS
, "INVALID-FLAGS", NULL
},
246 { ISAKMP_NTYPE_INVALID_MESSAGE_ID
, "INVALID-MESSAGE-ID", NULL
},
247 { ISAKMP_NTYPE_INVALID_PROTOCOL_ID
, "INVALID-PROTOCOL-ID", NULL
},
248 { ISAKMP_NTYPE_INVALID_SPI
, "INVALID-SPI", NULL
},
249 { ISAKMP_NTYPE_INVALID_TRANSFORM_ID
, "INVALID-TRANSFORM-ID", NULL
},
250 { ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED
, "ATTRIBUTES-NOT-SUPPORTED", NULL
},
251 { ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN
, "NO-PROPOSAL-CHOSEN", NULL
},
252 { ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX
, "BAD-PROPOSAL-SYNTAX", NULL
},
253 { ISAKMP_NTYPE_PAYLOAD_MALFORMED
, "PAYLOAD-MALFORMED", NULL
},
254 { ISAKMP_NTYPE_INVALID_KEY_INFORMATION
, "INVALID-KEY-INFORMATION", NULL
},
255 { ISAKMP_NTYPE_INVALID_ID_INFORMATION
, "INVALID-ID-INFORMATION", NULL
},
256 { ISAKMP_NTYPE_INVALID_CERT_ENCODING
, "INVALID-CERT-ENCODING", NULL
},
257 { ISAKMP_NTYPE_INVALID_CERTIFICATE
, "INVALID-CERTIFICATE", NULL
},
258 { ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX
, "BAD-CERT-REQUEST-SYNTAX", NULL
},
259 { ISAKMP_NTYPE_INVALID_CERT_AUTHORITY
, "INVALID-CERT-AUTHORITY", NULL
},
260 { ISAKMP_NTYPE_INVALID_HASH_INFORMATION
, "INVALID-HASH-INFORMATION", NULL
},
261 { ISAKMP_NTYPE_AUTHENTICATION_FAILED
, "AUTHENTICATION-FAILED", NULL
},
262 { ISAKMP_NTYPE_INVALID_SIGNATURE
, "INVALID-SIGNATURE", NULL
},
263 { ISAKMP_NTYPE_ADDRESS_NOTIFICATION
, "ADDRESS-NOTIFICATION", NULL
},
264 { ISAKMP_NTYPE_NOTIFY_SA_LIFETIME
, "NOTIFY-SA-LIFETIME", NULL
},
265 { ISAKMP_NTYPE_CERTIFICATE_UNAVAILABLE
, "CERTIFICATE-UNAVAILABLE", NULL
},
266 { ISAKMP_NTYPE_UNSUPPORTED_EXCHANGE_TYPE
, "UNSUPPORTED-EXCHANGE-TYPE", NULL
},
267 { ISAKMP_NTYPE_UNEQUAL_PAYLOAD_LENGTHS
, "UNEQUAL-PAYLOAD-LENGTHS", NULL
},
268 { ISAKMP_NTYPE_CONNECTED
, "CONNECTED", NULL
},
269 { ISAKMP_NTYPE_RESPONDER_LIFETIME
, "RESPONDER-LIFETIME", NULL
},
270 { ISAKMP_NTYPE_REPLAY_STATUS
, "REPLAY-STATUS", NULL
},
271 { ISAKMP_NTYPE_INITIAL_CONTACT
, "INITIAL-CONTACT", NULL
},
272 { ISAKMP_LOG_RETRY_LIMIT_REACHED
, "RETRY-LIMIT-REACHED", NULL
},
276 s_isakmp_notify_msg(k
)
280 for (i
= 0; i
< ARRAYLEN(name_isakmp_notify_msg
); i
++)
281 if (name_isakmp_notify_msg
[i
].key
== k
)
282 return name_isakmp_notify_msg
[i
].str
;
287 static struct ksmap name_isakmp_nptype
[] = {
288 { ISAKMP_NPTYPE_NONE
, "none", NULL
},
289 { ISAKMP_NPTYPE_SA
, "sa", NULL
},
290 { ISAKMP_NPTYPE_P
, "prop", NULL
},
291 { ISAKMP_NPTYPE_T
, "trns", NULL
},
292 { ISAKMP_NPTYPE_KE
, "ke", NULL
},
293 { ISAKMP_NPTYPE_ID
, "id", NULL
},
294 { ISAKMP_NPTYPE_CERT
, "cert", NULL
},
295 { ISAKMP_NPTYPE_CR
, "cr", NULL
},
296 { ISAKMP_NPTYPE_HASH
, "hash", NULL
},
297 { ISAKMP_NPTYPE_SIG
, "sig", NULL
},
298 { ISAKMP_NPTYPE_NONCE
, "nonce", NULL
},
299 { ISAKMP_NPTYPE_N
, "notify", NULL
},
300 { ISAKMP_NPTYPE_D
, "delete", NULL
},
301 { ISAKMP_NPTYPE_VID
, "vid", 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_NATD_BADDRAFT
, "nat-d", NULL
},
308 { ISAKMP_NPTYPE_NATOA_BADDRAFT
, "nat-oa", NULL
}
316 for (i
= 0; i
< ARRAYLEN(name_isakmp_nptype
); i
++)
317 if (name_isakmp_nptype
[i
].key
== k
)
318 return name_isakmp_nptype
[i
].str
;
323 static struct ksmap name_ipsecdoi_proto
[] = {
324 { IPSECDOI_PROTO_ISAKMP
, "ISAKMP", s_ipsecdoi_trns_isakmp
},
325 { IPSECDOI_PROTO_IPSEC_AH
, "AH", s_ipsecdoi_trns_ah
},
326 { IPSECDOI_PROTO_IPSEC_ESP
, "ESP", s_ipsecdoi_trns_esp
},
327 { IPSECDOI_PROTO_IPCOMP
, "IPCOMP", s_ipsecdoi_trns_ipcomp
},
335 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
336 if (name_ipsecdoi_proto
[i
].key
== k
)
337 return name_ipsecdoi_proto
[i
].str
;
341 static struct ksmap name_ipsecdoi_trns_isakmp
[] = {
342 { IPSECDOI_KEY_IKE
, "IKE", NULL
},
346 s_ipsecdoi_trns_isakmp(k
)
350 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_isakmp
); i
++)
351 if (name_ipsecdoi_trns_isakmp
[i
].key
== k
)
352 return name_ipsecdoi_trns_isakmp
[i
].str
;
356 static struct ksmap name_ipsecdoi_trns_ah
[] = {
357 { IPSECDOI_AH_MD5
, "MD5", NULL
},
358 { IPSECDOI_AH_SHA
, "SHA", NULL
},
359 { IPSECDOI_AH_DES
, "DES", NULL
},
360 { IPSECDOI_AH_SHA256
, "SHA256", NULL
},
361 { IPSECDOI_AH_SHA384
, "SHA384", NULL
},
362 { IPSECDOI_AH_SHA512
, "SHA512", NULL
},
366 s_ipsecdoi_trns_ah(k
)
370 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ah
); i
++)
371 if (name_ipsecdoi_trns_ah
[i
].key
== k
)
372 return name_ipsecdoi_trns_ah
[i
].str
;
376 static struct ksmap name_ipsecdoi_trns_esp
[] = {
377 { IPSECDOI_ESP_DES_IV64
, "DES_IV64", NULL
},
378 { IPSECDOI_ESP_DES
, "DES", NULL
},
379 { IPSECDOI_ESP_3DES
, "3DES", NULL
},
380 { IPSECDOI_ESP_RC5
, "RC5", NULL
},
381 { IPSECDOI_ESP_IDEA
, "IDEA", NULL
},
382 { IPSECDOI_ESP_CAST
, "CAST", NULL
},
383 { IPSECDOI_ESP_BLOWFISH
, "BLOWFISH", NULL
},
384 { IPSECDOI_ESP_3IDEA
, "3IDEA", NULL
},
385 { IPSECDOI_ESP_DES_IV32
, "DES_IV32", NULL
},
386 { IPSECDOI_ESP_RC4
, "RC4", NULL
},
387 { IPSECDOI_ESP_NULL
, "NULL", NULL
},
388 { IPSECDOI_ESP_AES
, "AES", NULL
},
389 { IPSECDOI_ESP_TWOFISH
, "TWOFISH", NULL
},
393 s_ipsecdoi_trns_esp(k
)
397 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_esp
); i
++)
398 if (name_ipsecdoi_trns_esp
[i
].key
== k
)
399 return name_ipsecdoi_trns_esp
[i
].str
;
403 static struct ksmap name_ipsecdoi_trns_ipcomp
[] = {
404 { IPSECDOI_IPCOMP_OUI
, "OUI", NULL
},
405 { IPSECDOI_IPCOMP_DEFLATE
, "DEFLATE", NULL
},
406 { IPSECDOI_IPCOMP_LZS
, "LZS", NULL
},
410 s_ipsecdoi_trns_ipcomp(k
)
414 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ipcomp
); i
++)
415 if (name_ipsecdoi_trns_ipcomp
[i
].key
== k
)
416 return name_ipsecdoi_trns_ipcomp
[i
].str
;
421 s_ipsecdoi_trns(proto
, trns
)
425 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
426 if (name_ipsecdoi_proto
[i
].key
== proto
427 && name_ipsecdoi_proto
[i
].f
)
428 return (name_ipsecdoi_proto
[i
].f
)(trns
);
429 return num2str(trns
);
432 static struct ksmap name_attr_ipsec
[] = {
433 { IPSECDOI_ATTR_SA_LD_TYPE
, "SA Life Type", s_ipsecdoi_ltype
},
434 { IPSECDOI_ATTR_SA_LD
, "SA Life Duration", NULL
},
435 { IPSECDOI_ATTR_GRP_DESC
, "Group Description", NULL
},
436 { IPSECDOI_ATTR_ENC_MODE
, "Encryption Mode", s_ipsecdoi_encmode
},
437 { IPSECDOI_ATTR_AUTH
, "Authentication Algorithm", s_ipsecdoi_auth
},
438 { IPSECDOI_ATTR_KEY_LENGTH
, "Key Length", NULL
},
439 { IPSECDOI_ATTR_KEY_ROUNDS
, "Key Rounds", NULL
},
440 { IPSECDOI_ATTR_COMP_DICT_SIZE
, "Compression Dictionary Size", NULL
},
441 { IPSECDOI_ATTR_COMP_PRIVALG
, "Compression Private Algorithm", NULL
},
449 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
450 if (name_attr_ipsec
[i
].key
== k
)
451 return name_attr_ipsec
[i
].str
;
455 static struct ksmap name_attr_ipsec_ltype
[] = {
456 { IPSECDOI_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
457 { IPSECDOI_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
465 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_ltype
); i
++)
466 if (name_attr_ipsec_ltype
[i
].key
== k
)
467 return name_attr_ipsec_ltype
[i
].str
;
471 static struct ksmap name_attr_ipsec_encmode
[] = {
472 { IPSECDOI_ATTR_ENC_MODE_ANY
, "Any", NULL
},
473 { IPSECDOI_ATTR_ENC_MODE_TUNNEL
, "Tunnel", NULL
},
474 { IPSECDOI_ATTR_ENC_MODE_TRNS
, "Transport", NULL
},
475 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC
, "UDP-Tunnel", NULL
},
476 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC
, "UDP-Transport", NULL
},
477 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT
, "UDP-Tunnel", NULL
},
478 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT
, "UDP-Transport", NULL
},
482 s_ipsecdoi_encmode(k
)
486 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_encmode
); i
++)
487 if (name_attr_ipsec_encmode
[i
].key
== k
)
488 return name_attr_ipsec_encmode
[i
].str
;
492 static struct ksmap name_attr_ipsec_auth
[] = {
493 { IPSECDOI_ATTR_AUTH_HMAC_MD5
, "hmac-md5", NULL
},
494 { IPSECDOI_ATTR_AUTH_HMAC_SHA1
, "hmac-sha", NULL
},
495 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_256
, "hmac-sha256", NULL
},
496 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_384
, "hmac-sha384", NULL
},
497 { IPSECDOI_ATTR_AUTH_HMAC_SHA2_512
, "hmac-sha512", NULL
},
498 { IPSECDOI_ATTR_AUTH_DES_MAC
, "des-mac", NULL
},
499 { IPSECDOI_ATTR_AUTH_KPDK
, "kpdk", NULL
},
507 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_auth
); i
++)
508 if (name_attr_ipsec_auth
[i
].key
== k
)
509 return name_attr_ipsec_auth
[i
].str
;
514 s_ipsecdoi_attr_v(type
, val
)
518 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
519 if (name_attr_ipsec
[i
].key
== type
520 && name_attr_ipsec
[i
].f
)
521 return (name_attr_ipsec
[i
].f
)(val
);
525 static struct ksmap name_ipsecdoi_ident
[] = {
526 { IPSECDOI_ID_IPV4_ADDR
, "IPv4_address", NULL
},
527 { IPSECDOI_ID_FQDN
, "FQDN", NULL
},
528 { IPSECDOI_ID_USER_FQDN
, "User_FQDN", NULL
},
529 { IPSECDOI_ID_IPV4_ADDR_SUBNET
, "IPv4_subnet", NULL
},
530 { IPSECDOI_ID_IPV6_ADDR
, "IPv6_address", NULL
},
531 { IPSECDOI_ID_IPV6_ADDR_SUBNET
, "IPv6_subnet", NULL
},
532 { IPSECDOI_ID_IPV4_ADDR_RANGE
, "IPv4_address_range", NULL
},
533 { IPSECDOI_ID_IPV6_ADDR_RANGE
, "IPv6_address_range", NULL
},
534 { IPSECDOI_ID_DER_ASN1_DN
, "DER_ASN1_DN", NULL
},
535 { IPSECDOI_ID_DER_ASN1_GN
, "DER_ASN1_GN", NULL
},
536 { IPSECDOI_ID_KEY_ID
, "KEY_ID", NULL
},
544 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_ident
); i
++)
545 if (name_ipsecdoi_ident
[i
].key
== k
)
546 return name_ipsecdoi_ident
[i
].str
;
551 static struct ksmap name_oakley_attr
[] = {
552 { OAKLEY_ATTR_ENC_ALG
, "Encryption Algorithm", s_attr_isakmp_enc
},
553 { OAKLEY_ATTR_HASH_ALG
, "Hash Algorithm", s_attr_isakmp_hash
},
554 { OAKLEY_ATTR_AUTH_METHOD
, "Authentication Method", s_oakley_attr_method
},
555 { OAKLEY_ATTR_GRP_DESC
, "Group Description", s_attr_isakmp_desc
},
556 { OAKLEY_ATTR_GRP_TYPE
, "Group Type", s_attr_isakmp_group
},
557 { OAKLEY_ATTR_GRP_PI
, "Group Prime/Irreducible Polynomial", NULL
},
558 { OAKLEY_ATTR_GRP_GEN_ONE
, "Group Generator One", NULL
},
559 { OAKLEY_ATTR_GRP_GEN_TWO
, "Group Generator Two", NULL
},
560 { OAKLEY_ATTR_GRP_CURVE_A
, "Group Curve A", NULL
},
561 { OAKLEY_ATTR_GRP_CURVE_B
, "Group Curve B", NULL
},
562 { OAKLEY_ATTR_SA_LD_TYPE
, "Life Type", s_attr_isakmp_ltype
},
563 { OAKLEY_ATTR_SA_LD
, "Life Duration", NULL
},
564 { OAKLEY_ATTR_PRF
, "PRF", NULL
},
565 { OAKLEY_ATTR_KEY_LEN
, "Key Length", NULL
},
566 { OAKLEY_ATTR_FIELD_SIZE
, "Field Size", NULL
},
567 { OAKLEY_ATTR_GRP_ORDER
, "Group Order", NULL
},
568 { OAKLEY_ATTR_BLOCK_SIZE
, "Block Size", NULL
},
569 { OAKLEY_ATTR_GSS_ID
, "GSS-API endpoint name",NULL
},
577 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
578 if (name_oakley_attr
[i
].key
== k
)
579 return name_oakley_attr
[i
].str
;
583 static struct ksmap name_attr_isakmp_enc
[] = {
584 { OAKLEY_ATTR_ENC_ALG_DES
, "DES-CBC", NULL
},
585 { OAKLEY_ATTR_ENC_ALG_IDEA
, "IDEA-CBC", NULL
},
586 { OAKLEY_ATTR_ENC_ALG_BLOWFISH
, "Blowfish-CBC", NULL
},
587 { OAKLEY_ATTR_ENC_ALG_RC5
, "RC5-R16-B64-CBC", NULL
},
588 { OAKLEY_ATTR_ENC_ALG_3DES
, "3DES-CBC", NULL
},
589 { OAKLEY_ATTR_ENC_ALG_CAST
, "CAST-CBC", NULL
},
597 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_enc
); i
++)
598 if (name_attr_isakmp_enc
[i
].key
== k
)
599 return name_attr_isakmp_enc
[i
].str
;
603 static struct ksmap name_attr_isakmp_hash
[] = {
604 { OAKLEY_ATTR_HASH_ALG_MD5
, "MD5", NULL
},
605 { OAKLEY_ATTR_HASH_ALG_SHA
, "SHA", NULL
},
606 { OAKLEY_ATTR_HASH_ALG_TIGER
, "Tiger", NULL
},
607 { OAKLEY_ATTR_HASH_ALG_SHA2_256
,"SHA256", NULL
},
608 { OAKLEY_ATTR_HASH_ALG_SHA2_384
,"SHA384", NULL
},
609 { OAKLEY_ATTR_HASH_ALG_SHA2_512
,"SHA512", NULL
},
613 s_attr_isakmp_hash(k
)
617 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_hash
); i
++)
618 if (name_attr_isakmp_hash
[i
].key
== k
)
619 return name_attr_isakmp_hash
[i
].str
;
623 static struct ksmap name_attr_isakmp_method
[] = {
624 { OAKLEY_ATTR_AUTH_METHOD_PSKEY
, "pre-shared key", NULL
},
625 { OAKLEY_ATTR_AUTH_METHOD_DSSSIG
, "DSS signatures", NULL
},
626 { OAKLEY_ATTR_AUTH_METHOD_RSASIG
, "RSA signatures", NULL
},
627 { OAKLEY_ATTR_AUTH_METHOD_RSAENC
, "Encryption with RSA", NULL
},
628 { OAKLEY_ATTR_AUTH_METHOD_RSAREV
, "Revised encryption with RSA", NULL
},
629 { OAKLEY_ATTR_AUTH_METHOD_EGENC
, "Encryption with El-Gamal", NULL
},
630 { OAKLEY_ATTR_AUTH_METHOD_EGREV
, "Revised encryption with El-Gamal", NULL
},
631 { OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
, "GSS-API on Kerberos 5", NULL
},
633 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_I
, "Hybrid DSS server", NULL
},
634 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_I
, "Hybrid RSA server", NULL
},
635 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_R
, "Hybrid DSS client", NULL
},
636 { OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_R
, "Hybrid RSA client", NULL
},
641 s_oakley_attr_method(k
)
645 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_method
); i
++)
646 if (name_attr_isakmp_method
[i
].key
== k
)
647 return name_attr_isakmp_method
[i
].str
;
651 static struct ksmap name_attr_isakmp_desc
[] = {
652 { OAKLEY_ATTR_GRP_DESC_MODP768
, "768-bit MODP group", NULL
},
653 { OAKLEY_ATTR_GRP_DESC_MODP1024
, "1024-bit MODP group", NULL
},
654 { OAKLEY_ATTR_GRP_DESC_EC2N155
, "EC2N group on GP[2^155]", NULL
},
655 { OAKLEY_ATTR_GRP_DESC_EC2N185
, "EC2N group on GP[2^185]", NULL
},
656 { OAKLEY_ATTR_GRP_DESC_MODP1536
, "1536-bit MODP group", NULL
},
657 { OAKLEY_ATTR_GRP_DESC_MODP2048
, "2048-bit MODP group", NULL
},
658 { OAKLEY_ATTR_GRP_DESC_MODP3072
, "3072-bit MODP group", NULL
},
659 { OAKLEY_ATTR_GRP_DESC_MODP4096
, "4096-bit MODP group", NULL
},
660 { OAKLEY_ATTR_GRP_DESC_MODP6144
, "6144-bit MODP group", NULL
},
661 { OAKLEY_ATTR_GRP_DESC_MODP8192
, "8192-bit MODP group", NULL
},
665 s_attr_isakmp_desc(k
)
669 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_desc
); i
++)
670 if (name_attr_isakmp_desc
[i
].key
== k
)
671 return name_attr_isakmp_desc
[i
].str
;
675 static struct ksmap name_attr_isakmp_group
[] = {
676 { OAKLEY_ATTR_GRP_TYPE_MODP
, "MODP", NULL
},
677 { OAKLEY_ATTR_GRP_TYPE_ECP
, "ECP", NULL
},
678 { OAKLEY_ATTR_GRP_TYPE_EC2N
, "EC2N", NULL
},
682 s_attr_isakmp_group(k
)
686 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_group
); i
++)
687 if (name_attr_isakmp_group
[i
].key
== k
)
688 return name_attr_isakmp_group
[i
].str
;
692 static struct ksmap name_attr_isakmp_ltype
[] = {
693 { OAKLEY_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
694 { OAKLEY_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
698 s_attr_isakmp_ltype(k
)
702 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_ltype
); i
++)
703 if (name_attr_isakmp_ltype
[i
].key
== k
)
704 return name_attr_isakmp_ltype
[i
].str
;
709 s_oakley_attr_v(type
, val
)
713 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
714 if (name_oakley_attr
[i
].key
== type
715 && name_oakley_attr
[i
].f
)
716 return (name_oakley_attr
[i
].f
)(val
);
720 /* netinet6/ipsec.h */
721 static struct ksmap name_ipsec_level
[] = {
722 { IPSEC_LEVEL_USE
, "use", NULL
},
723 { IPSEC_LEVEL_REQUIRE
, "require", NULL
},
724 { IPSEC_LEVEL_UNIQUE
, "unique", NULL
},
732 for (i
= 0; i
< ARRAYLEN(name_ipsec_level
); i
++)
733 if (name_ipsec_level
[i
].key
== k
)
734 return name_ipsec_level
[i
].str
;
738 static struct ksmap name_algclass
[] = {
739 { algclass_ipsec_enc
, "ipsec enc", s_ipsecdoi_trns_esp
},
740 { algclass_ipsec_auth
, "ipsec auth", s_ipsecdoi_trns_ah
},
741 { algclass_ipsec_comp
, "ipsec comp", s_ipsecdoi_trns_ipcomp
},
742 { algclass_isakmp_enc
, "isakmp enc", s_attr_isakmp_enc
},
743 { algclass_isakmp_hash
, "isakmp hash", s_attr_isakmp_hash
},
744 { algclass_isakmp_dh
, "isakmp dh", s_attr_isakmp_desc
},
745 { algclass_isakmp_ameth
, "isakmp auth method", s_oakley_attr_method
},
753 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
754 if (name_algclass
[i
].key
== k
)
755 return name_algclass
[i
].str
;
764 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
765 if (name_algclass
[i
].key
== class
766 && name_algclass
[i
].f
)
767 return (name_algclass
[i
].f
)(n
);
772 static struct ksmap name_pfkey_type
[] = {
773 { SADB_GETSPI
, "GETSPI", NULL
},
774 { SADB_UPDATE
, "UPDATE", NULL
},
775 { SADB_ADD
, "ADD", NULL
},
776 { SADB_DELETE
, "DELETE", NULL
},
777 { SADB_GET
, "GET", NULL
},
778 { SADB_ACQUIRE
, "ACQUIRE", NULL
},
779 { SADB_REGISTER
, "REGISTER", NULL
},
780 { SADB_EXPIRE
, "EXPIRE", NULL
},
781 { SADB_FLUSH
, "FLUSH", NULL
},
782 { SADB_DUMP
, "DUMP", NULL
},
783 { SADB_X_PROMISC
, "X_PRIMISC", NULL
},
784 { SADB_X_PCHANGE
, "X_PCHANGE", NULL
},
785 { SADB_X_SPDUPDATE
, "X_SPDUPDATE", NULL
},
786 { SADB_X_SPDADD
, "X_SPDADD", NULL
},
787 { SADB_X_SPDDELETE
, "X_SPDDELETE", NULL
},
788 { SADB_X_SPDGET
, "X_SPDGET", NULL
},
789 { SADB_X_SPDACQUIRE
, "X_SPDACQUIRE", NULL
},
790 { SADB_X_SPDDUMP
, "X_SPDDUMP", NULL
},
791 { SADB_X_SPDFLUSH
, "X_SPDFLUSH", NULL
},
792 { SADB_X_SPDSETIDX
, "X_SPDSETIDX", NULL
},
793 { SADB_X_SPDEXPIRE
, "X_SPDEXPIRE", NULL
},
794 { SADB_X_SPDDELETE2
, "X_SPDDELETE2", NULL
},
797 { SADB_X_NAT_T_NEW_MAPPING
, "X_NAT_T_NEW_MAPPING", NULL
},
807 for (i
= 0; i
< ARRAYLEN(name_pfkey_type
); i
++)
808 if (name_pfkey_type
[i
].key
== k
)
809 return name_pfkey_type
[i
].str
;
813 static struct ksmap name_pfkey_satype
[] = {
814 { SADB_SATYPE_UNSPEC
, "UNSPEC", NULL
},
815 { SADB_SATYPE_AH
, "AH", NULL
},
816 { SADB_SATYPE_ESP
, "ESP", NULL
},
817 { SADB_SATYPE_RSVP
, "RSVP", NULL
},
818 { SADB_SATYPE_OSPFV2
, "OSPFV2", NULL
},
819 { SADB_SATYPE_RIPV2
, "RIPV2", NULL
},
820 { SADB_SATYPE_MIP
, "MIP", NULL
},
821 { SADB_X_SATYPE_IPCOMP
, "IPCOMP", NULL
},
829 for (i
= 0; i
< ARRAYLEN(name_pfkey_satype
); i
++)
830 if (name_pfkey_satype
[i
].key
== k
)
831 return name_pfkey_satype
[i
].str
;
835 static struct ksmap name_direction
[] = {
836 { IPSEC_DIR_INBOUND
, "in", NULL
},
837 { IPSEC_DIR_OUTBOUND
, "out", NULL
},
838 #ifdef HAVE_POLICY_FWD
839 { IPSEC_DIR_FWD
, "fwd", NULL
},
848 for (i
= 0; i
< ARRAYLEN(name_direction
); i
++)
849 if (name_direction
[i
].key
== k
)
850 return name_direction
[i
].str
;
867 case IPSEC_ULPROTO_ANY
:
889 case ISAKMP_ETYPE_NONE
:
891 case ISAKMP_ETYPE_BASE
:
893 case ISAKMP_ETYPE_IDENT
:
895 case ISAKMP_ETYPE_AUTH
:
897 case ISAKMP_ETYPE_AGG
:
899 case ISAKMP_ETYPE_INFO
:
901 case ISAKMP_ETYPE_QUICK
:
903 case ISAKMP_ETYPE_NEWGRP
:
905 case ISAKMP_ETYPE_ACKINFO
:
918 case IDTYPE_USERFQDN
: