1 /* $KAME: strnames.c,v 1.23 2001/12/12 18:23:42 sakane 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
32 #include <sys/types.h>
33 #include <sys/param.h>
34 #include <sys/socket.h>
36 #include <netinet6/ipsec.h>
37 #include <netinet/in.h>
45 #include "isakmp_var.h"
47 #include "ipsec_doi.h"
52 #include "algorithm.h"
57 char *(*f
) __P((int));
60 static char *num2str
__P((int n
));
68 snprintf(buf
, sizeof(buf
), "%d", n
);
75 s_isakmp_state(t
, d
, s
)
79 case ISAKMP_ETYPE_AGG
:
83 case PHASE1ST_MSG1SENT
:
85 case PHASE1ST_ESTABLISHED
:
92 case PHASE1ST_MSG1SENT
:
99 case ISAKMP_ETYPE_BASE
:
103 case PHASE1ST_MSG1SENT
:
104 return "base I msg1";
105 case PHASE1ST_MSG2SENT
:
106 return "base I msg2";
112 case PHASE1ST_MSG1SENT
:
113 return "base R msg1";
114 case PHASE1ST_ESTABLISHED
:
115 return "base R msg2";
121 case ISAKMP_ETYPE_IDENT
:
125 case PHASE1ST_MSG1SENT
:
126 return "ident I msg1";
127 case PHASE1ST_MSG2SENT
:
128 return "ident I msg2";
129 case PHASE1ST_MSG3SENT
:
130 return "ident I msg3";
136 case PHASE1ST_MSG1SENT
:
137 return "ident R msg1";
138 case PHASE1ST_MSG2SENT
:
139 return "ident R msg2";
140 case PHASE1ST_ESTABLISHED
:
141 return "ident R msg3";
147 case ISAKMP_ETYPE_QUICK
:
151 case PHASE2ST_MSG1SENT
:
152 return "quick I msg1";
154 return "quick I msg2";
160 case PHASE2ST_MSG1SENT
:
161 return "quick R msg1";
162 case PHASE2ST_COMMIT
:
163 return "quick R msg2";
170 case ISAKMP_ETYPE_NONE
:
171 case ISAKMP_ETYPE_AUTH
:
172 case ISAKMP_ETYPE_INFO
:
173 case ISAKMP_ETYPE_NEWGRP
:
174 case ISAKMP_ETYPE_ACKINFO
:
182 static struct ksmap name_isakmp_certtype
[] = {
183 { ISAKMP_CERT_NONE
, "NONE", NULL
},
184 { ISAKMP_CERT_PKCS7
, "PKCS #7 wrapped X.509 certificate", NULL
},
185 { ISAKMP_CERT_PGP
, "PGP Certificate", NULL
},
186 { ISAKMP_CERT_DNS
, "DNS Signed Key", NULL
},
187 { ISAKMP_CERT_X509SIGN
, "X.509 Certificate Signature", NULL
},
188 { ISAKMP_CERT_X509KE
, "X.509 Certificate Key Exchange", NULL
},
189 { ISAKMP_CERT_KERBEROS
, "Kerberos Tokens", NULL
},
190 { ISAKMP_CERT_CRL
, "Certificate Revocation List (CRL)", NULL
},
191 { ISAKMP_CERT_ARL
, "Authority Revocation List (ARL)", NULL
},
192 { ISAKMP_CERT_SPKI
, "SPKI Certificate", NULL
},
193 { ISAKMP_CERT_X509ATTR
, "X.509 Certificate Attribute", NULL
},
201 for (i
= 0; i
< ARRAYLEN(name_isakmp_certtype
); i
++)
202 if (name_isakmp_certtype
[i
].key
== k
)
203 return name_isakmp_certtype
[i
].str
;
207 static struct ksmap name_isakmp_etype
[] = {
208 { ISAKMP_ETYPE_NONE
, "None", NULL
},
209 { ISAKMP_ETYPE_BASE
, "Base", NULL
},
210 { ISAKMP_ETYPE_IDENT
, "Identity Protection", NULL
},
211 { ISAKMP_ETYPE_AUTH
, "Authentication Only", NULL
},
212 { ISAKMP_ETYPE_AGG
, "Aggressive", NULL
},
213 { ISAKMP_ETYPE_INFO
, "Informational", NULL
},
214 { ISAKMP_ETYPE_QUICK
, "Quick", NULL
},
215 { ISAKMP_ETYPE_NEWGRP
, "New Group", NULL
},
216 { ISAKMP_ETYPE_ACKINFO
, "Acknowledged Informational", NULL
},
224 for (i
= 0; i
< ARRAYLEN(name_isakmp_etype
); i
++)
225 if (name_isakmp_etype
[i
].key
== k
)
226 return name_isakmp_etype
[i
].str
;
230 static struct ksmap name_isakmp_notify_msg
[] = {
231 { ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE
, "INVALID-PAYLOAD-TYPE", NULL
},
232 { ISAKMP_NTYPE_DOI_NOT_SUPPORTED
, "DOI-NOT-SUPPORTED", NULL
},
233 { ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED
, "SITUATION-NOT-SUPPORTED", NULL
},
234 { ISAKMP_NTYPE_INVALID_COOKIE
, "INVALID-COOKIE", NULL
},
235 { ISAKMP_NTYPE_INVALID_MAJOR_VERSION
, "INVALID-MAJOR-VERSION", NULL
},
236 { ISAKMP_NTYPE_INVALID_MINOR_VERSION
, "INVALID-MINOR-VERSION", NULL
},
237 { ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE
, "INVALID-EXCHANGE-TYPE", NULL
},
238 { ISAKMP_NTYPE_INVALID_FLAGS
, "INVALID-FLAGS", NULL
},
239 { ISAKMP_NTYPE_INVALID_MESSAGE_ID
, "INVALID-MESSAGE-ID", NULL
},
240 { ISAKMP_NTYPE_INVALID_PROTOCOL_ID
, "INVALID-PROTOCOL-ID", NULL
},
241 { ISAKMP_NTYPE_INVALID_SPI
, "INVALID-SPI", NULL
},
242 { ISAKMP_NTYPE_INVALID_TRANSFORM_ID
, "INVALID-TRANSFORM-ID", NULL
},
243 { ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED
, "ATTRIBUTES-NOT-SUPPORTED", NULL
},
244 { ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN
, "NO-PROPOSAL-CHOSEN", NULL
},
245 { ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX
, "BAD-PROPOSAL-SYNTAX", NULL
},
246 { ISAKMP_NTYPE_PAYLOAD_MALFORMED
, "PAYLOAD-MALFORMED", NULL
},
247 { ISAKMP_NTYPE_INVALID_KEY_INFORMATION
, "INVALID-KEY-INFORMATION", NULL
},
248 { ISAKMP_NTYPE_INVALID_ID_INFORMATION
, "INVALID-ID-INFORMATION", NULL
},
249 { ISAKMP_NTYPE_INVALID_CERT_ENCODING
, "INVALID-CERT-ENCODING", NULL
},
250 { ISAKMP_NTYPE_INVALID_CERTIFICATE
, "INVALID-CERTIFICATE", NULL
},
251 { ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX
, "BAD-CERT-REQUEST-SYNTAX", NULL
},
252 { ISAKMP_NTYPE_INVALID_CERT_AUTHORITY
, "INVALID-CERT-AUTHORITY", NULL
},
253 { ISAKMP_NTYPE_INVALID_HASH_INFORMATION
, "INVALID-HASH-INFORMATION", NULL
},
254 { ISAKMP_NTYPE_AUTHENTICATION_FAILED
, "AUTHENTICATION-FAILED", NULL
},
255 { ISAKMP_NTYPE_INVALID_SIGNATURE
, "INVALID-SIGNATURE", NULL
},
256 { ISAKMP_NTYPE_ADDRESS_NOTIFICATION
, "ADDRESS-NOTIFICATION", NULL
},
257 { ISAKMP_NTYPE_NOTIFY_SA_LIFETIME
, "NOTIFY-SA-LIFETIME", NULL
},
258 { ISAKMP_NTYPE_CERTIFICATE_UNAVAILABLE
, "CERTIFICATE-UNAVAILABLE", NULL
},
259 { ISAKMP_NTYPE_UNSUPPORTED_EXCHANGE_TYPE
, "UNSUPPORTED-EXCHANGE-TYPE", NULL
},
260 { ISAKMP_NTYPE_UNEQUAL_PAYLOAD_LENGTHS
, "UNEQUAL-PAYLOAD-LENGTHS", NULL
},
261 { ISAKMP_NTYPE_CONNECTED
, "CONNECTED", NULL
},
262 { ISAKMP_NTYPE_RESPONDER_LIFETIME
, "RESPONDER-LIFETIME", NULL
},
263 { ISAKMP_NTYPE_REPLAY_STATUS
, "REPLAY-STATUS", NULL
},
264 { ISAKMP_NTYPE_INITIAL_CONTACT
, "INITIAL-CONTACT", NULL
},
265 { ISAKMP_LOG_RETRY_LIMIT_REACHED
, "RETRY-LIMIT-REACHED", NULL
},
269 s_isakmp_notify_msg(k
)
273 for (i
= 0; i
< ARRAYLEN(name_isakmp_notify_msg
); i
++)
274 if (name_isakmp_notify_msg
[i
].key
== k
)
275 return name_isakmp_notify_msg
[i
].str
;
280 static struct ksmap name_isakmp_nptype
[] = {
281 { ISAKMP_NPTYPE_NONE
, "none", NULL
},
282 { ISAKMP_NPTYPE_SA
, "sa", NULL
},
283 { ISAKMP_NPTYPE_P
, "prop", NULL
},
284 { ISAKMP_NPTYPE_T
, "trns", NULL
},
285 { ISAKMP_NPTYPE_KE
, "ke", NULL
},
286 { ISAKMP_NPTYPE_ID
, "id", NULL
},
287 { ISAKMP_NPTYPE_CERT
, "cert", NULL
},
288 { ISAKMP_NPTYPE_CR
, "cr", NULL
},
289 { ISAKMP_NPTYPE_HASH
, "hash", NULL
},
290 { ISAKMP_NPTYPE_SIG
, "sig", NULL
},
291 { ISAKMP_NPTYPE_NONCE
, "nonce", NULL
},
292 { ISAKMP_NPTYPE_N
, "notify", NULL
},
293 { ISAKMP_NPTYPE_D
, "delete", NULL
},
294 { ISAKMP_NPTYPE_VID
, "vid", NULL
},
295 { ISAKMP_NPTYPE_GSS
, "gss id", NULL
},
297 { ISAKMP_NPTYPE_NATD_RFC
, "natd", NULL
},
298 { ISAKMP_NPTYPE_NATOA_RFC
, "nat-oa", NULL
},
299 { ISAKMP_NPTYPE_NATD_DRAFT
, "natd (draft)", NULL
},
300 { ISAKMP_NPTYPE_NATOA_DRAFT
, "nat-oa (draft)", NULL
},
301 { ISAKMP_NPTYPE_NATD_BADDRAFT
, "natd (bad draft)", NULL
},
302 { ISAKMP_NPTYPE_NATOA_BADDRAFT
, "nat-oa (bad draft)", NULL
}
310 for (i
= 0; i
< ARRAYLEN(name_isakmp_nptype
); i
++)
311 if (name_isakmp_nptype
[i
].key
== k
)
312 return name_isakmp_nptype
[i
].str
;
317 static struct ksmap name_ipsecdoi_proto
[] = {
318 { IPSECDOI_PROTO_ISAKMP
, "ISAKMP", s_ipsecdoi_trns_isakmp
},
319 { IPSECDOI_PROTO_IPSEC_AH
, "AH", s_ipsecdoi_trns_ah
},
320 { IPSECDOI_PROTO_IPSEC_ESP
, "ESP", s_ipsecdoi_trns_esp
},
321 { IPSECDOI_PROTO_IPCOMP
, "IPCOMP", s_ipsecdoi_trns_ipcomp
},
329 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
330 if (name_ipsecdoi_proto
[i
].key
== k
)
331 return name_ipsecdoi_proto
[i
].str
;
335 static struct ksmap name_ipsecdoi_trns_isakmp
[] = {
336 { IPSECDOI_KEY_IKE
, "IKE", NULL
},
340 s_ipsecdoi_trns_isakmp(k
)
344 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_isakmp
); i
++)
345 if (name_ipsecdoi_trns_isakmp
[i
].key
== k
)
346 return name_ipsecdoi_trns_isakmp
[i
].str
;
350 static struct ksmap name_ipsecdoi_trns_ah
[] = {
351 { IPSECDOI_AH_MD5
, "MD5", NULL
},
352 { IPSECDOI_AH_SHA
, "SHA", NULL
},
353 { IPSECDOI_AH_DES
, "DES", NULL
},
357 s_ipsecdoi_trns_ah(k
)
361 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ah
); i
++)
362 if (name_ipsecdoi_trns_ah
[i
].key
== k
)
363 return name_ipsecdoi_trns_ah
[i
].str
;
367 static struct ksmap name_ipsecdoi_trns_esp
[] = {
368 { IPSECDOI_ESP_DES_IV64
, "DES_IV64", NULL
},
369 { IPSECDOI_ESP_DES
, "DES", NULL
},
370 { IPSECDOI_ESP_3DES
, "3DES", NULL
},
371 { IPSECDOI_ESP_RC5
, "RC5", NULL
},
372 { IPSECDOI_ESP_IDEA
, "IDEA", NULL
},
373 { IPSECDOI_ESP_CAST
, "CAST", NULL
},
374 { IPSECDOI_ESP_BLOWFISH
, "BLOWFISH", NULL
},
375 { IPSECDOI_ESP_3IDEA
, "3IDEA", NULL
},
376 { IPSECDOI_ESP_DES_IV32
, "DES_IV32", NULL
},
377 { IPSECDOI_ESP_RC4
, "RC4", NULL
},
378 { IPSECDOI_ESP_NULL
, "NULL", NULL
},
379 { IPSECDOI_ESP_RIJNDAEL
, "RIJNDAEL", NULL
},
380 { IPSECDOI_ESP_TWOFISH
, "TWOFISH", NULL
},
384 s_ipsecdoi_trns_esp(k
)
388 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_esp
); i
++)
389 if (name_ipsecdoi_trns_esp
[i
].key
== k
)
390 return name_ipsecdoi_trns_esp
[i
].str
;
394 static struct ksmap name_ipsecdoi_trns_ipcomp
[] = {
395 { IPSECDOI_IPCOMP_OUI
, "OUI", NULL
},
396 { IPSECDOI_IPCOMP_DEFLATE
, "DEFLATE", NULL
},
397 { IPSECDOI_IPCOMP_LZS
, "LZS", NULL
},
401 s_ipsecdoi_trns_ipcomp(k
)
405 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ipcomp
); i
++)
406 if (name_ipsecdoi_trns_ipcomp
[i
].key
== k
)
407 return name_ipsecdoi_trns_ipcomp
[i
].str
;
412 s_ipsecdoi_trns(proto
, trns
)
416 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
417 if (name_ipsecdoi_proto
[i
].key
== proto
418 && name_ipsecdoi_proto
[i
].f
)
419 return (name_ipsecdoi_proto
[i
].f
)(trns
);
420 return num2str(trns
);
423 static struct ksmap name_attr_ipsec
[] = {
424 { IPSECDOI_ATTR_SA_LD_TYPE
, "SA Life Type", s_ipsecdoi_ltype
},
425 { IPSECDOI_ATTR_SA_LD
, "SA Life Duration", NULL
},
426 { IPSECDOI_ATTR_GRP_DESC
, "Group Description", NULL
},
427 { IPSECDOI_ATTR_ENC_MODE
, "Encription Mode", s_ipsecdoi_encmode
},
428 { IPSECDOI_ATTR_AUTH
, "Authentication Algorithm", s_ipsecdoi_auth
},
429 { IPSECDOI_ATTR_KEY_LENGTH
, "Key Length", NULL
},
430 { IPSECDOI_ATTR_KEY_ROUNDS
, "Key Rounds", NULL
},
431 { IPSECDOI_ATTR_COMP_DICT_SIZE
, "Compression Dictionary Size", NULL
},
432 { IPSECDOI_ATTR_COMP_PRIVALG
, "Compression Private Algorithm", NULL
},
440 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
441 if (name_attr_ipsec
[i
].key
== k
)
442 return name_attr_ipsec
[i
].str
;
446 static struct ksmap name_attr_ipsec_ltype
[] = {
447 { IPSECDOI_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
448 { IPSECDOI_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
456 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_ltype
); i
++)
457 if (name_attr_ipsec_ltype
[i
].key
== k
)
458 return name_attr_ipsec_ltype
[i
].str
;
462 static struct ksmap name_attr_ipsec_encmode
[] = {
463 { IPSECDOI_ATTR_ENC_MODE_ANY
, "Any", NULL
},
464 { IPSECDOI_ATTR_ENC_MODE_TUNNEL
, "Tunnel", NULL
},
465 { IPSECDOI_ATTR_ENC_MODE_TRNS
, "Transport", NULL
},
466 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC
, "UDP Encapsulated Tunnel", NULL
},
467 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC
, "UDP Encapsulated Transport", NULL
},
468 { IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT
, "UDP Encapsulated Tunnel (NATT DRAFT)", NULL
},
469 { IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT
, "UDP Encapsulated Transport (NATT DRAFT)", NULL
},
473 s_ipsecdoi_encmode(k
)
477 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_encmode
); i
++)
478 if (name_attr_ipsec_encmode
[i
].key
== k
)
479 return name_attr_ipsec_encmode
[i
].str
;
483 static struct ksmap name_attr_ipsec_auth
[] = {
484 { IPSECDOI_ATTR_AUTH_HMAC_MD5
, "hmac-md5", NULL
},
485 { IPSECDOI_ATTR_AUTH_HMAC_SHA1
, "hmac-sha", NULL
},
486 { IPSECDOI_ATTR_AUTH_DES_MAC
, "des-mac", NULL
},
487 { IPSECDOI_ATTR_AUTH_KPDK
, "kpdk", NULL
},
495 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_auth
); i
++)
496 if (name_attr_ipsec_auth
[i
].key
== k
)
497 return name_attr_ipsec_auth
[i
].str
;
502 s_ipsecdoi_attr_v(type
, val
)
506 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
507 if (name_attr_ipsec
[i
].key
== type
508 && name_attr_ipsec
[i
].f
)
509 return (name_attr_ipsec
[i
].f
)(val
);
513 static struct ksmap name_ipsecdoi_ident
[] = {
514 { IPSECDOI_ID_IPV4_ADDR
, "IPv4_address", NULL
},
515 { IPSECDOI_ID_FQDN
, "FQDN", NULL
},
516 { IPSECDOI_ID_USER_FQDN
, "User_FQDN", NULL
},
517 { IPSECDOI_ID_IPV4_ADDR_SUBNET
, "IPv4_subnet", NULL
},
518 { IPSECDOI_ID_IPV6_ADDR
, "IPv6_address", NULL
},
519 { IPSECDOI_ID_IPV6_ADDR_SUBNET
, "IPv6_subnet", NULL
},
520 { IPSECDOI_ID_IPV4_ADDR_RANGE
, "IPv4_address_range", NULL
},
521 { IPSECDOI_ID_IPV6_ADDR_RANGE
, "IPv6_address_range", NULL
},
522 { IPSECDOI_ID_DER_ASN1_DN
, "DER_ASN1_DN", NULL
},
523 { IPSECDOI_ID_DER_ASN1_GN
, "DER_ASN1_GN", NULL
},
524 { IPSECDOI_ID_KEY_ID
, "KEY_ID", NULL
},
532 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_ident
); i
++)
533 if (name_ipsecdoi_ident
[i
].key
== k
)
534 return name_ipsecdoi_ident
[i
].str
;
539 static struct ksmap name_oakley_attr
[] = {
540 { OAKLEY_ATTR_ENC_ALG
, "Encryption Algorithm", s_attr_isakmp_enc
},
541 { OAKLEY_ATTR_HASH_ALG
, "Hash Algorithm", s_attr_isakmp_hash
},
542 { OAKLEY_ATTR_AUTH_METHOD
, "Authentication Method", s_oakley_attr_method
},
543 { OAKLEY_ATTR_GRP_DESC
, "Group Description", s_attr_isakmp_desc
},
544 { OAKLEY_ATTR_GRP_TYPE
, "Group Type", s_attr_isakmp_group
},
545 { OAKLEY_ATTR_GRP_PI
, "Group Prime/Irreducible Polynomial", NULL
},
546 { OAKLEY_ATTR_GRP_GEN_ONE
, "Group Generator One", NULL
},
547 { OAKLEY_ATTR_GRP_GEN_TWO
, "Group Generator Two", NULL
},
548 { OAKLEY_ATTR_GRP_CURVE_A
, "Group Curve A", NULL
},
549 { OAKLEY_ATTR_GRP_CURVE_B
, "Group Curve B", NULL
},
550 { OAKLEY_ATTR_SA_LD_TYPE
, "Life Type", s_attr_isakmp_ltype
},
551 { OAKLEY_ATTR_SA_LD
, "Life Duration", NULL
},
552 { OAKLEY_ATTR_PRF
, "PRF", NULL
},
553 { OAKLEY_ATTR_KEY_LEN
, "Key Length", NULL
},
554 { OAKLEY_ATTR_FIELD_SIZE
, "Field Size", NULL
},
555 { OAKLEY_ATTR_GRP_ORDER
, "Group Order", NULL
},
556 { OAKLEY_ATTR_BLOCK_SIZE
, "Block Size", NULL
},
557 { OAKLEY_ATTR_GSS_ID
, "GSS-API endpoint name",NULL
},
565 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
566 if (name_oakley_attr
[i
].key
== k
)
567 return name_oakley_attr
[i
].str
;
571 static struct ksmap name_attr_isakmp_enc
[] = {
572 { OAKLEY_ATTR_ENC_ALG_DES
, "DES-CBC", NULL
},
573 { OAKLEY_ATTR_ENC_ALG_IDEA
, "IDEA-CBC", NULL
},
574 { OAKLEY_ATTR_ENC_ALG_BLOWFISH
, "Blowfish-CBC", NULL
},
575 { OAKLEY_ATTR_ENC_ALG_RC5
, "RC5-R16-B64-CBC", NULL
},
576 { OAKLEY_ATTR_ENC_ALG_3DES
, "3DES-CBC", NULL
},
577 { OAKLEY_ATTR_ENC_ALG_CAST
, "CAST-CBC", NULL
},
585 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_enc
); i
++)
586 if (name_attr_isakmp_enc
[i
].key
== k
)
587 return name_attr_isakmp_enc
[i
].str
;
591 static struct ksmap name_attr_isakmp_hash
[] = {
592 { OAKLEY_ATTR_HASH_ALG_MD5
, "MD5", NULL
},
593 { OAKLEY_ATTR_HASH_ALG_SHA
, "SHA", NULL
},
594 { OAKLEY_ATTR_HASH_ALG_TIGER
, "Tiger", NULL
},
598 s_attr_isakmp_hash(k
)
602 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_hash
); i
++)
603 if (name_attr_isakmp_hash
[i
].key
== k
)
604 return name_attr_isakmp_hash
[i
].str
;
608 static struct ksmap name_attr_isakmp_method
[] = {
609 { OAKLEY_ATTR_AUTH_METHOD_PSKEY
, "pre-shared key", NULL
},
610 { OAKLEY_ATTR_AUTH_METHOD_DSSSIG
, "DSS signatures", NULL
},
611 { OAKLEY_ATTR_AUTH_METHOD_RSASIG
, "RSA signatures", NULL
},
612 { OAKLEY_ATTR_AUTH_METHOD_RSAENC
, "Encryption with RSA", NULL
},
613 { OAKLEY_ATTR_AUTH_METHOD_RSAREV
, "Revised encryption with RSA", NULL
},
614 { OAKLEY_ATTR_AUTH_METHOD_EGENC
, "Encryption with El-Gamal", NULL
},
615 { OAKLEY_ATTR_AUTH_METHOD_EGREV
, "Revised encryption with El-Gamal", NULL
},
616 { OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
, "GSS-API on Kerberos 5", NULL
},
620 s_oakley_attr_method(k
)
624 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_method
); i
++)
625 if (name_attr_isakmp_method
[i
].key
== k
)
626 return name_attr_isakmp_method
[i
].str
;
630 static struct ksmap name_attr_isakmp_desc
[] = {
631 { OAKLEY_ATTR_GRP_DESC_MODP768
, "768-bit MODP group", NULL
},
632 { OAKLEY_ATTR_GRP_DESC_MODP1024
, "1024-bit MODP group", NULL
},
633 { OAKLEY_ATTR_GRP_DESC_EC2N155
, "EC2N group on GP[2^155]", NULL
},
634 { OAKLEY_ATTR_GRP_DESC_EC2N185
, "EC2N group on GP[2^185]", NULL
},
635 { OAKLEY_ATTR_GRP_DESC_MODP1536
, "1536-bit MODP group", NULL
},
636 { OAKLEY_ATTR_GRP_DESC_MODP2048
, "2048-bit MODP group", NULL
},
637 { OAKLEY_ATTR_GRP_DESC_MODP3072
, "3072-bit MODP group", NULL
},
638 { OAKLEY_ATTR_GRP_DESC_MODP4096
, "4096-bit MODP group", NULL
},
639 { OAKLEY_ATTR_GRP_DESC_MODP6144
, "6144-bit MODP group", NULL
},
640 { OAKLEY_ATTR_GRP_DESC_MODP8192
, "8192-bit MODP group", NULL
},
644 s_attr_isakmp_desc(k
)
648 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_desc
); i
++)
649 if (name_attr_isakmp_desc
[i
].key
== k
)
650 return name_attr_isakmp_desc
[i
].str
;
654 static struct ksmap name_attr_isakmp_group
[] = {
655 { OAKLEY_ATTR_GRP_TYPE_MODP
, "MODP", NULL
},
656 { OAKLEY_ATTR_GRP_TYPE_ECP
, "ECP", NULL
},
657 { OAKLEY_ATTR_GRP_TYPE_EC2N
, "EC2N", NULL
},
661 s_attr_isakmp_group(k
)
665 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_group
); i
++)
666 if (name_attr_isakmp_group
[i
].key
== k
)
667 return name_attr_isakmp_group
[i
].str
;
671 static struct ksmap name_attr_isakmp_ltype
[] = {
672 { OAKLEY_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
673 { OAKLEY_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
677 s_attr_isakmp_ltype(k
)
681 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_ltype
); i
++)
682 if (name_attr_isakmp_ltype
[i
].key
== k
)
683 return name_attr_isakmp_ltype
[i
].str
;
688 s_oakley_attr_v(type
, val
)
692 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
693 if (name_oakley_attr
[i
].key
== type
694 && name_oakley_attr
[i
].f
)
695 return (name_oakley_attr
[i
].f
)(val
);
699 /* netinet6/ipsec.h */
700 static struct ksmap name_ipsec_level
[] = {
701 { IPSEC_LEVEL_USE
, "use", NULL
},
702 { IPSEC_LEVEL_REQUIRE
, "require", NULL
},
703 { IPSEC_LEVEL_UNIQUE
, "unique", NULL
},
711 for (i
= 0; i
< ARRAYLEN(name_ipsec_level
); i
++)
712 if (name_ipsec_level
[i
].key
== k
)
713 return name_ipsec_level
[i
].str
;
717 static struct ksmap name_algclass
[] = {
718 { algclass_ipsec_enc
, "ipsec enc", s_ipsecdoi_trns_esp
},
719 { algclass_ipsec_auth
, "ipsec auth", s_ipsecdoi_trns_ah
},
720 { algclass_ipsec_comp
, "ipsec comp", s_ipsecdoi_trns_ipcomp
},
721 { algclass_isakmp_enc
, "isakmp enc", s_attr_isakmp_enc
},
722 { algclass_isakmp_hash
, "isakmp hash", s_attr_isakmp_hash
},
723 { algclass_isakmp_dh
, "isakmp dh", s_attr_isakmp_desc
},
724 { algclass_isakmp_ameth
, "isakmp auth method", s_oakley_attr_method
},
732 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
733 if (name_algclass
[i
].key
== k
)
734 return name_algclass
[i
].str
;
743 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
744 if (name_algclass
[i
].key
== class
745 && name_algclass
[i
].f
)
746 return (name_algclass
[i
].f
)(n
);
751 static struct ksmap name_pfkey_type
[] = {
752 { SADB_GETSPI
, "GETSPI", NULL
},
753 { SADB_UPDATE
, "UPDATE", NULL
},
754 { SADB_ADD
, "ADD", NULL
},
755 { SADB_DELETE
, "DELETE", NULL
},
756 { SADB_GET
, "GET", NULL
},
757 { SADB_ACQUIRE
, "ACQUIRE", NULL
},
758 { SADB_REGISTER
, "REGISTER", NULL
},
759 { SADB_EXPIRE
, "EXPIRE", NULL
},
760 { SADB_FLUSH
, "FLUSH", NULL
},
761 { SADB_DUMP
, "DUMP", NULL
},
762 { SADB_X_PROMISC
, "X_PRIMISC", NULL
},
763 { SADB_X_PCHANGE
, "X_PCHANGE", NULL
},
764 { SADB_X_SPDUPDATE
, "X_SPDUPDATE", NULL
},
765 { SADB_X_SPDADD
, "X_SPDADD", NULL
},
766 { SADB_X_SPDDELETE
, "X_SPDDELETE", NULL
},
767 { SADB_X_SPDGET
, "X_SPDGET", NULL
},
768 { SADB_X_SPDACQUIRE
, "X_SPDACQUIRE", NULL
},
769 { SADB_X_SPDDUMP
, "X_SPDDUMP", NULL
},
770 { SADB_X_SPDFLUSH
, "X_SPDFLUSH", NULL
},
771 { SADB_X_SPDSETIDX
, "X_SPDSETIDX", NULL
},
772 { SADB_X_SPDEXPIRE
, "X_SPDEXPIRE", NULL
},
773 { SADB_X_SPDDELETE2
, "X_SPDDELETE2", NULL
},
781 for (i
= 0; i
< ARRAYLEN(name_pfkey_type
); i
++)
782 if (name_pfkey_type
[i
].key
== k
)
783 return name_pfkey_type
[i
].str
;
787 static struct ksmap name_pfkey_satype
[] = {
788 { SADB_SATYPE_UNSPEC
, "UNSPEC", NULL
},
789 { SADB_SATYPE_AH
, "AH", NULL
},
790 { SADB_SATYPE_ESP
, "ESP", NULL
},
791 { SADB_SATYPE_RSVP
, "RSVP", NULL
},
792 { SADB_SATYPE_OSPFV2
, "OSPFV2", NULL
},
793 { SADB_SATYPE_RIPV2
, "RIPV2", NULL
},
794 { SADB_SATYPE_MIP
, "MIP", NULL
},
795 { SADB_X_SATYPE_IPCOMP
, "IPCOMP", NULL
},
803 for (i
= 0; i
< ARRAYLEN(name_pfkey_satype
); i
++)
804 if (name_pfkey_satype
[i
].key
== k
)
805 return name_pfkey_satype
[i
].str
;
809 static struct ksmap name_direction
[] = {
810 { IPSEC_DIR_INBOUND
, "in", NULL
},
811 { IPSEC_DIR_OUTBOUND
, "out", NULL
},
819 for (i
= 0; i
< ARRAYLEN(name_direction
); i
++)
820 if (name_direction
[i
].key
== k
)
821 return name_direction
[i
].str
;
838 case IPSEC_ULPROTO_ANY
: