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
, "natd", NULL
}
305 for (i
= 0; i
< ARRAYLEN(name_isakmp_nptype
); i
++)
306 if (name_isakmp_nptype
[i
].key
== k
)
307 return name_isakmp_nptype
[i
].str
;
312 static struct ksmap name_ipsecdoi_proto
[] = {
313 { IPSECDOI_PROTO_ISAKMP
, "ISAKMP", s_ipsecdoi_trns_isakmp
},
314 { IPSECDOI_PROTO_IPSEC_AH
, "AH", s_ipsecdoi_trns_ah
},
315 { IPSECDOI_PROTO_IPSEC_ESP
, "ESP", s_ipsecdoi_trns_esp
},
316 { IPSECDOI_PROTO_IPCOMP
, "IPCOMP", s_ipsecdoi_trns_ipcomp
},
324 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
325 if (name_ipsecdoi_proto
[i
].key
== k
)
326 return name_ipsecdoi_proto
[i
].str
;
330 static struct ksmap name_ipsecdoi_trns_isakmp
[] = {
331 { IPSECDOI_KEY_IKE
, "IKE", NULL
},
335 s_ipsecdoi_trns_isakmp(k
)
339 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_isakmp
); i
++)
340 if (name_ipsecdoi_trns_isakmp
[i
].key
== k
)
341 return name_ipsecdoi_trns_isakmp
[i
].str
;
345 static struct ksmap name_ipsecdoi_trns_ah
[] = {
346 { IPSECDOI_AH_MD5
, "MD5", NULL
},
347 { IPSECDOI_AH_SHA
, "SHA", NULL
},
348 { IPSECDOI_AH_DES
, "DES", NULL
},
352 s_ipsecdoi_trns_ah(k
)
356 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ah
); i
++)
357 if (name_ipsecdoi_trns_ah
[i
].key
== k
)
358 return name_ipsecdoi_trns_ah
[i
].str
;
362 static struct ksmap name_ipsecdoi_trns_esp
[] = {
363 { IPSECDOI_ESP_DES_IV64
, "DES_IV64", NULL
},
364 { IPSECDOI_ESP_DES
, "DES", NULL
},
365 { IPSECDOI_ESP_3DES
, "3DES", NULL
},
366 { IPSECDOI_ESP_RC5
, "RC5", NULL
},
367 { IPSECDOI_ESP_IDEA
, "IDEA", NULL
},
368 { IPSECDOI_ESP_CAST
, "CAST", NULL
},
369 { IPSECDOI_ESP_BLOWFISH
, "BLOWFISH", NULL
},
370 { IPSECDOI_ESP_3IDEA
, "3IDEA", NULL
},
371 { IPSECDOI_ESP_DES_IV32
, "DES_IV32", NULL
},
372 { IPSECDOI_ESP_RC4
, "RC4", NULL
},
373 { IPSECDOI_ESP_NULL
, "NULL", NULL
},
374 { IPSECDOI_ESP_RIJNDAEL
, "RIJNDAEL", NULL
},
375 { IPSECDOI_ESP_TWOFISH
, "TWOFISH", NULL
},
379 s_ipsecdoi_trns_esp(k
)
383 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_esp
); i
++)
384 if (name_ipsecdoi_trns_esp
[i
].key
== k
)
385 return name_ipsecdoi_trns_esp
[i
].str
;
389 static struct ksmap name_ipsecdoi_trns_ipcomp
[] = {
390 { IPSECDOI_IPCOMP_OUI
, "OUI", NULL
},
391 { IPSECDOI_IPCOMP_DEFLATE
, "DEFLATE", NULL
},
392 { IPSECDOI_IPCOMP_LZS
, "LZS", NULL
},
396 s_ipsecdoi_trns_ipcomp(k
)
400 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_trns_ipcomp
); i
++)
401 if (name_ipsecdoi_trns_ipcomp
[i
].key
== k
)
402 return name_ipsecdoi_trns_ipcomp
[i
].str
;
407 s_ipsecdoi_trns(proto
, trns
)
411 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
412 if (name_ipsecdoi_proto
[i
].key
== proto
413 && name_ipsecdoi_proto
[i
].f
)
414 return (name_ipsecdoi_proto
[i
].f
)(trns
);
415 return num2str(trns
);
418 static struct ksmap name_attr_ipsec
[] = {
419 { IPSECDOI_ATTR_SA_LD_TYPE
, "SA Life Type", s_ipsecdoi_ltype
},
420 { IPSECDOI_ATTR_SA_LD
, "SA Life Duration", NULL
},
421 { IPSECDOI_ATTR_GRP_DESC
, "Group Description", NULL
},
422 { IPSECDOI_ATTR_ENC_MODE
, "Encription Mode", s_ipsecdoi_encmode
},
423 { IPSECDOI_ATTR_AUTH
, "Authentication Algorithm", s_ipsecdoi_auth
},
424 { IPSECDOI_ATTR_KEY_LENGTH
, "Key Length", NULL
},
425 { IPSECDOI_ATTR_KEY_ROUNDS
, "Key Rounds", NULL
},
426 { IPSECDOI_ATTR_COMP_DICT_SIZE
, "Compression Dictionary Size", NULL
},
427 { IPSECDOI_ATTR_COMP_PRIVALG
, "Compression Private Algorithm", NULL
},
435 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec
); i
++)
436 if (name_attr_ipsec
[i
].key
== k
)
437 return name_attr_ipsec
[i
].str
;
441 static struct ksmap name_attr_ipsec_ltype
[] = {
442 { IPSECDOI_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
443 { IPSECDOI_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
451 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_ltype
); i
++)
452 if (name_attr_ipsec_ltype
[i
].key
== k
)
453 return name_attr_ipsec_ltype
[i
].str
;
457 static struct ksmap name_attr_ipsec_encmode
[] = {
458 { IPSECDOI_ATTR_ENC_MODE_ANY
, "Any", NULL
},
459 { IPSECDOI_ATTR_ENC_MODE_TUNNEL
, "Tunnel", NULL
},
460 { IPSECDOI_ATTR_ENC_MODE_TRNS
, "Transport", NULL
},
461 { IPSECDOI_ATTR_ENC_MODE_UDP_TUNNEL
, "UDP Encapsulated Tunnel", NULL
},
462 { IPSECDOI_ATTR_ENC_MODE_UDP_TRNS
, "UDP Encapsulated Transport", NULL
},
466 s_ipsecdoi_encmode(k
)
470 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_encmode
); i
++)
471 if (name_attr_ipsec_encmode
[i
].key
== k
)
472 return name_attr_ipsec_encmode
[i
].str
;
476 static struct ksmap name_attr_ipsec_auth
[] = {
477 { IPSECDOI_ATTR_AUTH_HMAC_MD5
, "hmac-md5", NULL
},
478 { IPSECDOI_ATTR_AUTH_HMAC_SHA1
, "hmac-sha", NULL
},
479 { IPSECDOI_ATTR_AUTH_DES_MAC
, "des-mac", NULL
},
480 { IPSECDOI_ATTR_AUTH_KPDK
, "kpdk", NULL
},
488 for (i
= 0; i
< ARRAYLEN(name_attr_ipsec_auth
); i
++)
489 if (name_attr_ipsec_auth
[i
].key
== k
)
490 return name_attr_ipsec_auth
[i
].str
;
495 s_ipsecdoi_attr_v(type
, val
)
499 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_proto
); i
++)
500 if (name_attr_ipsec
[i
].key
== type
501 && name_attr_ipsec
[i
].f
)
502 return (name_attr_ipsec
[i
].f
)(val
);
506 static struct ksmap name_ipsecdoi_ident
[] = {
507 { IPSECDOI_ID_IPV4_ADDR
, "IPv4_address", NULL
},
508 { IPSECDOI_ID_FQDN
, "FQDN", NULL
},
509 { IPSECDOI_ID_USER_FQDN
, "User_FQDN", NULL
},
510 { IPSECDOI_ID_IPV4_ADDR_SUBNET
, "IPv4_subnet", NULL
},
511 { IPSECDOI_ID_IPV6_ADDR
, "IPv6_address", NULL
},
512 { IPSECDOI_ID_IPV6_ADDR_SUBNET
, "IPv6_subnet", NULL
},
513 { IPSECDOI_ID_IPV4_ADDR_RANGE
, "IPv4_address_range", NULL
},
514 { IPSECDOI_ID_IPV6_ADDR_RANGE
, "IPv6_address_range", NULL
},
515 { IPSECDOI_ID_DER_ASN1_DN
, "DER_ASN1_DN", NULL
},
516 { IPSECDOI_ID_DER_ASN1_GN
, "DER_ASN1_GN", NULL
},
517 { IPSECDOI_ID_KEY_ID
, "KEY_ID", NULL
},
525 for (i
= 0; i
< ARRAYLEN(name_ipsecdoi_ident
); i
++)
526 if (name_ipsecdoi_ident
[i
].key
== k
)
527 return name_ipsecdoi_ident
[i
].str
;
532 static struct ksmap name_oakley_attr
[] = {
533 { OAKLEY_ATTR_ENC_ALG
, "Encryption Algorithm", s_attr_isakmp_enc
},
534 { OAKLEY_ATTR_HASH_ALG
, "Hash Algorithm", s_attr_isakmp_hash
},
535 { OAKLEY_ATTR_AUTH_METHOD
, "Authentication Method", s_oakley_attr_method
},
536 { OAKLEY_ATTR_GRP_DESC
, "Group Description", s_attr_isakmp_desc
},
537 { OAKLEY_ATTR_GRP_TYPE
, "Group Type", s_attr_isakmp_group
},
538 { OAKLEY_ATTR_GRP_PI
, "Group Prime/Irreducible Polynomial", NULL
},
539 { OAKLEY_ATTR_GRP_GEN_ONE
, "Group Generator One", NULL
},
540 { OAKLEY_ATTR_GRP_GEN_TWO
, "Group Generator Two", NULL
},
541 { OAKLEY_ATTR_GRP_CURVE_A
, "Group Curve A", NULL
},
542 { OAKLEY_ATTR_GRP_CURVE_B
, "Group Curve B", NULL
},
543 { OAKLEY_ATTR_SA_LD_TYPE
, "Life Type", s_attr_isakmp_ltype
},
544 { OAKLEY_ATTR_SA_LD
, "Life Duration", NULL
},
545 { OAKLEY_ATTR_PRF
, "PRF", NULL
},
546 { OAKLEY_ATTR_KEY_LEN
, "Key Length", NULL
},
547 { OAKLEY_ATTR_FIELD_SIZE
, "Field Size", NULL
},
548 { OAKLEY_ATTR_GRP_ORDER
, "Group Order", NULL
},
549 { OAKLEY_ATTR_BLOCK_SIZE
, "Block Size", NULL
},
550 { OAKLEY_ATTR_GSS_ID
, "GSS-API endpoint name",NULL
},
558 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
559 if (name_oakley_attr
[i
].key
== k
)
560 return name_oakley_attr
[i
].str
;
564 static struct ksmap name_attr_isakmp_enc
[] = {
565 { OAKLEY_ATTR_ENC_ALG_DES
, "DES-CBC", NULL
},
566 { OAKLEY_ATTR_ENC_ALG_IDEA
, "IDEA-CBC", NULL
},
567 { OAKLEY_ATTR_ENC_ALG_BLOWFISH
, "Blowfish-CBC", NULL
},
568 { OAKLEY_ATTR_ENC_ALG_RC5
, "RC5-R16-B64-CBC", NULL
},
569 { OAKLEY_ATTR_ENC_ALG_3DES
, "3DES-CBC", NULL
},
570 { OAKLEY_ATTR_ENC_ALG_CAST
, "CAST-CBC", NULL
},
578 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_enc
); i
++)
579 if (name_attr_isakmp_enc
[i
].key
== k
)
580 return name_attr_isakmp_enc
[i
].str
;
584 static struct ksmap name_attr_isakmp_hash
[] = {
585 { OAKLEY_ATTR_HASH_ALG_MD5
, "MD5", NULL
},
586 { OAKLEY_ATTR_HASH_ALG_SHA
, "SHA", NULL
},
587 { OAKLEY_ATTR_HASH_ALG_TIGER
, "Tiger", NULL
},
591 s_attr_isakmp_hash(k
)
595 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_hash
); i
++)
596 if (name_attr_isakmp_hash
[i
].key
== k
)
597 return name_attr_isakmp_hash
[i
].str
;
601 static struct ksmap name_attr_isakmp_method
[] = {
602 { OAKLEY_ATTR_AUTH_METHOD_PSKEY
, "pre-shared key", NULL
},
603 { OAKLEY_ATTR_AUTH_METHOD_DSSSIG
, "DSS signatures", NULL
},
604 { OAKLEY_ATTR_AUTH_METHOD_RSASIG
, "RSA signatures", NULL
},
605 { OAKLEY_ATTR_AUTH_METHOD_RSAENC
, "Encryption with RSA", NULL
},
606 { OAKLEY_ATTR_AUTH_METHOD_RSAREV
, "Revised encryption with RSA", NULL
},
607 { OAKLEY_ATTR_AUTH_METHOD_EGENC
, "Encryption with El-Gamal", NULL
},
608 { OAKLEY_ATTR_AUTH_METHOD_EGREV
, "Revised encryption with El-Gamal", NULL
},
609 { OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
, "GSS-API on Kerberos 5", NULL
},
613 s_oakley_attr_method(k
)
617 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_method
); i
++)
618 if (name_attr_isakmp_method
[i
].key
== k
)
619 return name_attr_isakmp_method
[i
].str
;
623 static struct ksmap name_attr_isakmp_desc
[] = {
624 { OAKLEY_ATTR_GRP_DESC_MODP768
, "768-bit MODP group", NULL
},
625 { OAKLEY_ATTR_GRP_DESC_MODP1024
, "1024-bit MODP group", NULL
},
626 { OAKLEY_ATTR_GRP_DESC_EC2N155
, "EC2N group on GP[2^155]", NULL
},
627 { OAKLEY_ATTR_GRP_DESC_EC2N185
, "EC2N group on GP[2^185]", NULL
},
628 { OAKLEY_ATTR_GRP_DESC_MODP1536
, "1536-bit MODP group", NULL
},
629 { OAKLEY_ATTR_GRP_DESC_MODP2048
, "2048-bit MODP group", NULL
},
630 { OAKLEY_ATTR_GRP_DESC_MODP3072
, "3072-bit MODP group", NULL
},
631 { OAKLEY_ATTR_GRP_DESC_MODP4096
, "4096-bit MODP group", NULL
},
632 { OAKLEY_ATTR_GRP_DESC_MODP6144
, "6144-bit MODP group", NULL
},
633 { OAKLEY_ATTR_GRP_DESC_MODP8192
, "8192-bit MODP group", NULL
},
637 s_attr_isakmp_desc(k
)
641 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_desc
); i
++)
642 if (name_attr_isakmp_desc
[i
].key
== k
)
643 return name_attr_isakmp_desc
[i
].str
;
647 static struct ksmap name_attr_isakmp_group
[] = {
648 { OAKLEY_ATTR_GRP_TYPE_MODP
, "MODP", NULL
},
649 { OAKLEY_ATTR_GRP_TYPE_ECP
, "ECP", NULL
},
650 { OAKLEY_ATTR_GRP_TYPE_EC2N
, "EC2N", NULL
},
654 s_attr_isakmp_group(k
)
658 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_group
); i
++)
659 if (name_attr_isakmp_group
[i
].key
== k
)
660 return name_attr_isakmp_group
[i
].str
;
664 static struct ksmap name_attr_isakmp_ltype
[] = {
665 { OAKLEY_ATTR_SA_LD_TYPE_SEC
, "seconds", NULL
},
666 { OAKLEY_ATTR_SA_LD_TYPE_KB
, "kilobytes", NULL
},
670 s_attr_isakmp_ltype(k
)
674 for (i
= 0; i
< ARRAYLEN(name_attr_isakmp_ltype
); i
++)
675 if (name_attr_isakmp_ltype
[i
].key
== k
)
676 return name_attr_isakmp_ltype
[i
].str
;
681 s_oakley_attr_v(type
, val
)
685 for (i
= 0; i
< ARRAYLEN(name_oakley_attr
); i
++)
686 if (name_oakley_attr
[i
].key
== type
687 && name_oakley_attr
[i
].f
)
688 return (name_oakley_attr
[i
].f
)(val
);
692 /* netinet6/ipsec.h */
693 static struct ksmap name_ipsec_level
[] = {
694 { IPSEC_LEVEL_USE
, "use", NULL
},
695 { IPSEC_LEVEL_REQUIRE
, "require", NULL
},
696 { IPSEC_LEVEL_UNIQUE
, "unique", NULL
},
704 for (i
= 0; i
< ARRAYLEN(name_ipsec_level
); i
++)
705 if (name_ipsec_level
[i
].key
== k
)
706 return name_ipsec_level
[i
].str
;
710 static struct ksmap name_algclass
[] = {
711 { algclass_ipsec_enc
, "ipsec enc", s_ipsecdoi_trns_esp
},
712 { algclass_ipsec_auth
, "ipsec auth", s_ipsecdoi_trns_ah
},
713 { algclass_ipsec_comp
, "ipsec comp", s_ipsecdoi_trns_ipcomp
},
714 { algclass_isakmp_enc
, "isakmp enc", s_attr_isakmp_enc
},
715 { algclass_isakmp_hash
, "isakmp hash", s_attr_isakmp_hash
},
716 { algclass_isakmp_dh
, "isakmp dh", s_attr_isakmp_desc
},
717 { algclass_isakmp_ameth
, "isakmp auth method", s_oakley_attr_method
},
725 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
726 if (name_algclass
[i
].key
== k
)
727 return name_algclass
[i
].str
;
736 for (i
= 0; i
< ARRAYLEN(name_algclass
); i
++)
737 if (name_algclass
[i
].key
== class
738 && name_algclass
[i
].f
)
739 return (name_algclass
[i
].f
)(n
);
744 static struct ksmap name_pfkey_type
[] = {
745 { SADB_GETSPI
, "GETSPI", NULL
},
746 { SADB_UPDATE
, "UPDATE", NULL
},
747 { SADB_ADD
, "ADD", NULL
},
748 { SADB_DELETE
, "DELETE", NULL
},
749 { SADB_GET
, "GET", NULL
},
750 { SADB_ACQUIRE
, "ACQUIRE", NULL
},
751 { SADB_REGISTER
, "REGISTER", NULL
},
752 { SADB_EXPIRE
, "EXPIRE", NULL
},
753 { SADB_FLUSH
, "FLUSH", NULL
},
754 { SADB_DUMP
, "DUMP", NULL
},
755 { SADB_X_PROMISC
, "X_PRIMISC", NULL
},
756 { SADB_X_PCHANGE
, "X_PCHANGE", NULL
},
757 { SADB_X_SPDUPDATE
, "X_SPDUPDATE", NULL
},
758 { SADB_X_SPDADD
, "X_SPDADD", NULL
},
759 { SADB_X_SPDDELETE
, "X_SPDDELETE", NULL
},
760 { SADB_X_SPDGET
, "X_SPDGET", NULL
},
761 { SADB_X_SPDACQUIRE
, "X_SPDACQUIRE", NULL
},
762 { SADB_X_SPDDUMP
, "X_SPDDUMP", NULL
},
763 { SADB_X_SPDFLUSH
, "X_SPDFLUSH", NULL
},
764 { SADB_X_SPDSETIDX
, "X_SPDSETIDX", NULL
},
765 { SADB_X_SPDEXPIRE
, "X_SPDEXPIRE", NULL
},
766 { SADB_X_SPDDELETE2
, "X_SPDDELETE2", NULL
},
774 for (i
= 0; i
< ARRAYLEN(name_pfkey_type
); i
++)
775 if (name_pfkey_type
[i
].key
== k
)
776 return name_pfkey_type
[i
].str
;
780 static struct ksmap name_pfkey_satype
[] = {
781 { SADB_SATYPE_UNSPEC
, "UNSPEC", NULL
},
782 { SADB_SATYPE_AH
, "AH", NULL
},
783 { SADB_SATYPE_ESP
, "ESP", NULL
},
784 { SADB_SATYPE_RSVP
, "RSVP", NULL
},
785 { SADB_SATYPE_OSPFV2
, "OSPFV2", NULL
},
786 { SADB_SATYPE_RIPV2
, "RIPV2", NULL
},
787 { SADB_SATYPE_MIP
, "MIP", NULL
},
788 { SADB_X_SATYPE_IPCOMP
, "IPCOMP", NULL
},
796 for (i
= 0; i
< ARRAYLEN(name_pfkey_satype
); i
++)
797 if (name_pfkey_satype
[i
].key
== k
)
798 return name_pfkey_satype
[i
].str
;
802 static struct ksmap name_direction
[] = {
803 { IPSEC_DIR_INBOUND
, "in", NULL
},
804 { IPSEC_DIR_OUTBOUND
, "out", NULL
},
812 for (i
= 0; i
< ARRAYLEN(name_direction
); i
++)
813 if (name_direction
[i
].key
== k
)
814 return name_direction
[i
].str
;
831 case IPSEC_ULPROTO_ANY
: