]> git.saurik.com Git - apple/ipsec.git/blame - ipsec-tools/racoon/strnames.c
ipsec-146.3.tar.gz
[apple/ipsec.git] / ipsec-tools / racoon / strnames.c
CommitLineData
d1e348cf
A
1/* $NetBSD: strnames.c,v 1.7.6.1 2007/08/01 11:52:22 vanhu Exp $ */
2
52b7d2ce
A
3/* $KAME: strnames.c,v 1.25 2003/11/13 10:53:26 itojun Exp $ */
4
5/*
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
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.
20 *
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
31 * SUCH DAMAGE.
32 */
33
34#include "config.h"
35
36#include <sys/types.h>
37#include <sys/param.h>
38#include <sys/socket.h>
39
40#include <netinet/in.h>
41#ifdef HAVE_NETINET6_IPSEC
42# include <netinet6/ipsec.h>
43#else
44# include <netinet/ipsec.h>
45#endif
46#include <netinet/in.h>
47
48#include <stdio.h>
49#include <stdlib.h>
d1e348cf
A
50#ifdef ENABLE_HYBRID
51#include <resolv.h>
52#endif
52b7d2ce
A
53
54#include "var.h"
55#include "misc.h"
56#include "vmbuf.h"
57#include "plog.h"
58
59#include "isakmp_var.h"
60#include "isakmp.h"
d1e348cf
A
61#ifdef ENABLE_HYBRID
62# include "isakmp_xauth.h"
63# include "isakmp_unity.h"
64# include "isakmp_cfg.h"
65#endif
52b7d2ce
A
66#include "ipsec_doi.h"
67#include "oakley.h"
68#include "handler.h"
69#include "pfkey.h"
70#include "strnames.h"
71#include "algorithm.h"
72
73struct ksmap {
74 int key;
75 char *str;
76 char *(*f) __P((int));
77};
78
79char *
80num2str(n)
81 int n;
82{
83 static char buf[20];
84
85 snprintf(buf, sizeof(buf), "%d", n);
86
87 return buf;
88}
89
90/* isakmp.h */
91char *
92s_isakmp_state(t, d, s)
93 int t, d, s;
94{
95 switch (t) {
96 case ISAKMP_ETYPE_AGG:
97 switch (d) {
98 case INITIATOR:
99 switch (s) {
100 case PHASE1ST_MSG1SENT:
101 return "agg I msg1";
102 case PHASE1ST_ESTABLISHED:
103 return "agg I msg2";
104 default:
105 break;
106 }
107 case RESPONDER:
108 switch (s) {
109 case PHASE1ST_MSG1SENT:
110 return "agg R msg1";
111 default:
112 break;
113 }
114 }
115 break;
116 case ISAKMP_ETYPE_BASE:
117 switch (d) {
118 case INITIATOR:
119 switch (s) {
120 case PHASE1ST_MSG1SENT:
121 return "base I msg1";
122 case PHASE1ST_MSG2SENT:
123 return "base I msg2";
124 default:
125 break;
126 }
127 case RESPONDER:
128 switch (s) {
129 case PHASE1ST_MSG1SENT:
130 return "base R msg1";
131 case PHASE1ST_ESTABLISHED:
132 return "base R msg2";
133 default:
134 break;
135 }
136 }
137 break;
138 case ISAKMP_ETYPE_IDENT:
139 switch (d) {
140 case INITIATOR:
141 switch (s) {
142 case PHASE1ST_MSG1SENT:
143 return "ident I msg1";
144 case PHASE1ST_MSG2SENT:
145 return "ident I msg2";
146 case PHASE1ST_MSG3SENT:
147 return "ident I msg3";
148 default:
149 break;
150 }
151 case RESPONDER:
152 switch (s) {
153 case PHASE1ST_MSG1SENT:
154 return "ident R msg1";
155 case PHASE1ST_MSG2SENT:
156 return "ident R msg2";
157 case PHASE1ST_ESTABLISHED:
158 return "ident R msg3";
159 default:
160 break;
161 }
162 }
163 break;
164 case ISAKMP_ETYPE_QUICK:
165 switch (d) {
166 case INITIATOR:
167 switch (s) {
168 case PHASE2ST_MSG1SENT:
169 return "quick I msg1";
170 case PHASE2ST_ADDSA:
171 return "quick I msg2";
172 default:
173 break;
174 }
175 case RESPONDER:
176 switch (s) {
177 case PHASE2ST_MSG1SENT:
178 return "quick R msg1";
179 case PHASE2ST_COMMIT:
180 return "quick R msg2";
181 default:
182 break;
183 }
184 }
185 break;
186 default:
187 case ISAKMP_ETYPE_NONE:
188 case ISAKMP_ETYPE_AUTH:
189 case ISAKMP_ETYPE_INFO:
190 case ISAKMP_ETYPE_NEWGRP:
191 case ISAKMP_ETYPE_ACKINFO:
192 break;
193 }
194 /*NOTREACHED*/
195
196 return "???";
197}
198
199static struct ksmap name_isakmp_certtype[] = {
200{ ISAKMP_CERT_NONE, "NONE", NULL },
201{ ISAKMP_CERT_PKCS7, "PKCS #7 wrapped X.509 certificate", NULL },
202{ ISAKMP_CERT_PGP, "PGP Certificate", NULL },
203{ ISAKMP_CERT_DNS, "DNS Signed Key", NULL },
204{ ISAKMP_CERT_X509SIGN, "X.509 Certificate Signature", NULL },
205{ ISAKMP_CERT_X509KE, "X.509 Certificate Key Exchange", NULL },
206{ ISAKMP_CERT_KERBEROS, "Kerberos Tokens", NULL },
207{ ISAKMP_CERT_CRL, "Certificate Revocation List (CRL)", NULL },
208{ ISAKMP_CERT_ARL, "Authority Revocation List (ARL)", NULL },
209{ ISAKMP_CERT_SPKI, "SPKI Certificate", NULL },
210{ ISAKMP_CERT_X509ATTR, "X.509 Certificate Attribute", NULL },
211};
212
213char *
214s_isakmp_certtype(k)
215 int k;
216{
217 int i;
218 for (i = 0; i < ARRAYLEN(name_isakmp_certtype); i++)
219 if (name_isakmp_certtype[i].key == k)
220 return name_isakmp_certtype[i].str;
221 return num2str(k);
222}
223
224static struct ksmap name_isakmp_etype[] = {
225{ ISAKMP_ETYPE_NONE, "None", NULL },
226{ ISAKMP_ETYPE_BASE, "Base", NULL },
227{ ISAKMP_ETYPE_IDENT, "Identity Protection", NULL },
228{ ISAKMP_ETYPE_AUTH, "Authentication Only", NULL },
229{ ISAKMP_ETYPE_AGG, "Aggressive", NULL },
230{ ISAKMP_ETYPE_INFO, "Informational", NULL },
d1e348cf 231{ ISAKMP_ETYPE_CFG, "Mode config", NULL },
52b7d2ce
A
232{ ISAKMP_ETYPE_QUICK, "Quick", NULL },
233{ ISAKMP_ETYPE_NEWGRP, "New Group", NULL },
234{ ISAKMP_ETYPE_ACKINFO, "Acknowledged Informational", NULL },
235};
236
237char *
238s_isakmp_etype(k)
239 int k;
240{
241 int i;
242 for (i = 0; i < ARRAYLEN(name_isakmp_etype); i++)
243 if (name_isakmp_etype[i].key == k)
244 return name_isakmp_etype[i].str;
245 return num2str(k);
246}
247
248static struct ksmap name_isakmp_notify_msg[] = {
249{ ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE, "INVALID-PAYLOAD-TYPE", NULL },
250{ ISAKMP_NTYPE_DOI_NOT_SUPPORTED, "DOI-NOT-SUPPORTED", NULL },
251{ ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED, "SITUATION-NOT-SUPPORTED", NULL },
252{ ISAKMP_NTYPE_INVALID_COOKIE, "INVALID-COOKIE", NULL },
253{ ISAKMP_NTYPE_INVALID_MAJOR_VERSION, "INVALID-MAJOR-VERSION", NULL },
254{ ISAKMP_NTYPE_INVALID_MINOR_VERSION, "INVALID-MINOR-VERSION", NULL },
255{ ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE, "INVALID-EXCHANGE-TYPE", NULL },
256{ ISAKMP_NTYPE_INVALID_FLAGS, "INVALID-FLAGS", NULL },
257{ ISAKMP_NTYPE_INVALID_MESSAGE_ID, "INVALID-MESSAGE-ID", NULL },
258{ ISAKMP_NTYPE_INVALID_PROTOCOL_ID, "INVALID-PROTOCOL-ID", NULL },
259{ ISAKMP_NTYPE_INVALID_SPI, "INVALID-SPI", NULL },
260{ ISAKMP_NTYPE_INVALID_TRANSFORM_ID, "INVALID-TRANSFORM-ID", NULL },
261{ ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED, "ATTRIBUTES-NOT-SUPPORTED", NULL },
262{ ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN, "NO-PROPOSAL-CHOSEN", NULL },
263{ ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX, "BAD-PROPOSAL-SYNTAX", NULL },
264{ ISAKMP_NTYPE_PAYLOAD_MALFORMED, "PAYLOAD-MALFORMED", NULL },
265{ ISAKMP_NTYPE_INVALID_KEY_INFORMATION, "INVALID-KEY-INFORMATION", NULL },
266{ ISAKMP_NTYPE_INVALID_ID_INFORMATION, "INVALID-ID-INFORMATION", NULL },
267{ ISAKMP_NTYPE_INVALID_CERT_ENCODING, "INVALID-CERT-ENCODING", NULL },
268{ ISAKMP_NTYPE_INVALID_CERTIFICATE, "INVALID-CERTIFICATE", NULL },
269{ ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX, "BAD-CERT-REQUEST-SYNTAX", NULL },
270{ ISAKMP_NTYPE_INVALID_CERT_AUTHORITY, "INVALID-CERT-AUTHORITY", NULL },
271{ ISAKMP_NTYPE_INVALID_HASH_INFORMATION, "INVALID-HASH-INFORMATION", NULL },
272{ ISAKMP_NTYPE_AUTHENTICATION_FAILED, "AUTHENTICATION-FAILED", NULL },
273{ ISAKMP_NTYPE_INVALID_SIGNATURE, "INVALID-SIGNATURE", NULL },
274{ ISAKMP_NTYPE_ADDRESS_NOTIFICATION, "ADDRESS-NOTIFICATION", NULL },
275{ ISAKMP_NTYPE_NOTIFY_SA_LIFETIME, "NOTIFY-SA-LIFETIME", NULL },
276{ ISAKMP_NTYPE_CERTIFICATE_UNAVAILABLE, "CERTIFICATE-UNAVAILABLE", NULL },
277{ ISAKMP_NTYPE_UNSUPPORTED_EXCHANGE_TYPE, "UNSUPPORTED-EXCHANGE-TYPE", NULL },
278{ ISAKMP_NTYPE_UNEQUAL_PAYLOAD_LENGTHS, "UNEQUAL-PAYLOAD-LENGTHS", NULL },
279{ ISAKMP_NTYPE_CONNECTED, "CONNECTED", NULL },
280{ ISAKMP_NTYPE_RESPONDER_LIFETIME, "RESPONDER-LIFETIME", NULL },
281{ ISAKMP_NTYPE_REPLAY_STATUS, "REPLAY-STATUS", NULL },
282{ ISAKMP_NTYPE_INITIAL_CONTACT, "INITIAL-CONTACT", NULL },
d1e348cf
A
283#ifdef ENABLE_HYBRID
284{ ISAKMP_NTYPE_UNITY_HEARTBEAT, "HEARTBEAT (Unity)", NULL },
285#endif
52b7d2ce
A
286{ ISAKMP_LOG_RETRY_LIMIT_REACHED, "RETRY-LIMIT-REACHED", NULL },
287};
288
289char *
290s_isakmp_notify_msg(k)
291 int k;
292{
293 int i;
294 for (i = 0; i < ARRAYLEN(name_isakmp_notify_msg); i++)
295 if (name_isakmp_notify_msg[i].key == k)
296 return name_isakmp_notify_msg[i].str;
297
298 return num2str(k);
299}
300
301static struct ksmap name_isakmp_nptype[] = {
d1e348cf
A
302{ ISAKMP_NPTYPE_NONE, "none", NULL },
303{ ISAKMP_NPTYPE_SA, "sa", NULL },
304{ ISAKMP_NPTYPE_P, "prop", NULL },
305{ ISAKMP_NPTYPE_T, "trns", NULL },
306{ ISAKMP_NPTYPE_KE, "ke", NULL },
307{ ISAKMP_NPTYPE_ID, "id", NULL },
308{ ISAKMP_NPTYPE_CERT, "cert", NULL },
309{ ISAKMP_NPTYPE_CR, "cr", NULL },
310{ ISAKMP_NPTYPE_HASH, "hash", NULL },
311{ ISAKMP_NPTYPE_SIG, "sig", NULL },
312{ ISAKMP_NPTYPE_NONCE, "nonce", NULL },
313{ ISAKMP_NPTYPE_N, "notify", NULL },
314{ ISAKMP_NPTYPE_D, "delete", NULL },
315{ ISAKMP_NPTYPE_VID, "vid", NULL },
316{ ISAKMP_NPTYPE_ATTR, "attr", NULL },
317{ ISAKMP_NPTYPE_GSS, "gss id", NULL },
52b7d2ce
A
318{ ISAKMP_NPTYPE_NATD_RFC, "nat-d", NULL },
319{ ISAKMP_NPTYPE_NATOA_RFC, "nat-oa", NULL },
320{ ISAKMP_NPTYPE_NATD_DRAFT, "nat-d", NULL },
321{ ISAKMP_NPTYPE_NATOA_DRAFT, "nat-oa", NULL },
d1e348cf 322{ ISAKMP_NPTYPE_FRAG, "ike frag", NULL },
52b7d2ce
A
323};
324
325char *
326s_isakmp_nptype(k)
327 int k;
328{
329 int i;
330 for (i = 0; i < ARRAYLEN(name_isakmp_nptype); i++)
331 if (name_isakmp_nptype[i].key == k)
332 return name_isakmp_nptype[i].str;
333 return num2str(k);
334}
335
d1e348cf
A
336#ifdef ENABLE_HYBRID
337/* isakmp_cfg.h / isakmp_unity.h / isakmp_xauth.h */
338static struct ksmap name_isakmp_cfg_type[] = {
339{ INTERNAL_IP4_ADDRESS, "INTERNAL_IP4_ADDRESS", NULL },
340{ INTERNAL_IP4_NETMASK, "INTERNAL_IP4_NETMASK", NULL },
341{ INTERNAL_IP4_DNS, "INTERNAL_IP4_DNS", NULL },
342{ INTERNAL_IP4_NBNS, "INTERNAL_IP4_NBNS", NULL },
343{ INTERNAL_ADDRESS_EXPIRY, "INTERNAL_ADDRESS_EXPIRY", NULL },
344{ INTERNAL_IP4_DHCP, "INTERNAL_IP4_DHCP", NULL },
345{ APPLICATION_VERSION, "APPLICATION_VERSION", NULL },
346{ INTERNAL_IP6_ADDRESS, "INTERNAL_IP6_ADDRESS", NULL },
347{ INTERNAL_IP6_NETMASK, "INTERNAL_IP6_NETMASK", NULL },
348{ INTERNAL_IP6_DNS, "INTERNAL_IP6_DNS", NULL },
349{ INTERNAL_IP6_NBNS, "INTERNAL_IP6_NBNS", NULL },
350{ INTERNAL_IP6_DHCP, "INTERNAL_IP6_DHCP", NULL },
351{ INTERNAL_IP4_SUBNET, "INTERNAL_IP4_SUBNET", NULL },
352{ SUPPORTED_ATTRIBUTES, "SUPPORTED_ATTRIBUTES", NULL },
353{ INTERNAL_IP6_SUBNET, "INTERNAL_IP6_SUBNET", NULL },
354{ XAUTH_TYPE, "XAUTH_TYPE", NULL },
355{ XAUTH_USER_NAME, "XAUTH_USER_NAME", NULL },
356{ XAUTH_USER_PASSWORD, "XAUTH_USER_PASSWORD", NULL },
357{ XAUTH_PASSCODE, "XAUTH_PASSCODE", NULL },
358{ XAUTH_MESSAGE, "XAUTH_MESSAGE", NULL },
359{ XAUTH_CHALLENGE, "XAUTH_CHALLENGE", NULL },
360{ XAUTH_DOMAIN, "XAUTH_DOMAIN", NULL },
361{ XAUTH_STATUS, "XAUTH_STATUS", NULL },
362{ XAUTH_NEXT_PIN, "XAUTH_NEXT_PIN", NULL },
363{ XAUTH_ANSWER, "XAUTH_ANSWER", NULL },
364{ UNITY_BANNER, "UNITY_BANNER", NULL },
365{ UNITY_SAVE_PASSWD, "UNITY_SAVE_PASSWD", NULL },
366{ UNITY_DEF_DOMAIN, "UNITY_DEF_DOMAIN", NULL },
367{ UNITY_SPLITDNS_NAME, "UNITY_SPLITDNS_NAME", NULL },
368{ UNITY_SPLIT_INCLUDE, "UNITY_SPLIT_INCLUDE", NULL },
369{ UNITY_NATT_PORT, "UNITY_NATT_PORT", NULL },
370{ UNITY_LOCAL_LAN, "UNITY_LOCAL_LAN", NULL },
371{ UNITY_PFS, "UNITY_PFS", NULL },
372{ UNITY_FW_TYPE, "UNITY_FW_TYPE", NULL },
373{ UNITY_BACKUP_SERVERS, "UNITY_BACKUP_SERVERS", NULL },
374{ UNITY_DDNS_HOSTNAME, "UNITY_DDNS_HOSTNAME", NULL },
375};
376
377char *
378s_isakmp_cfg_type(k)
379 int k;
380{
381 int i;
382 for (i = 0; i < ARRAYLEN(name_isakmp_cfg_type); i++)
383 if (name_isakmp_cfg_type[i].key == k)
384 return name_isakmp_cfg_type[i].str;
385 return num2str(k);
386}
387
388/* isakmp_cfg.h / isakmp_unity.h / isakmp_xauth.h */
389static struct ksmap name_isakmp_cfg_ptype[] = {
390{ ISAKMP_CFG_ACK, "mode config ACK", NULL },
391{ ISAKMP_CFG_SET, "mode config SET", NULL },
392{ ISAKMP_CFG_REQUEST, "mode config REQUEST", NULL },
393{ ISAKMP_CFG_REPLY, "mode config REPLY", NULL },
394};
395
396char *
397s_isakmp_cfg_ptype(k)
398 int k;
399{
400 int i;
401 for (i = 0; i < ARRAYLEN(name_isakmp_cfg_ptype); i++)
402 if (name_isakmp_cfg_ptype[i].key == k)
403 return name_isakmp_cfg_ptype[i].str;
404 return num2str(k);
405}
406
407#endif
408
52b7d2ce
A
409/* ipsec_doi.h */
410static struct ksmap name_ipsecdoi_proto[] = {
411{ IPSECDOI_PROTO_ISAKMP, "ISAKMP", s_ipsecdoi_trns_isakmp },
412{ IPSECDOI_PROTO_IPSEC_AH, "AH", s_ipsecdoi_trns_ah },
413{ IPSECDOI_PROTO_IPSEC_ESP, "ESP", s_ipsecdoi_trns_esp },
414{ IPSECDOI_PROTO_IPCOMP, "IPCOMP", s_ipsecdoi_trns_ipcomp },
415};
416
417char *
418s_ipsecdoi_proto(k)
419 int k;
420{
421 int i;
422 for (i = 0; i < ARRAYLEN(name_ipsecdoi_proto); i++)
423 if (name_ipsecdoi_proto[i].key == k)
424 return name_ipsecdoi_proto[i].str;
425 return num2str(k);
426}
427
428static struct ksmap name_ipsecdoi_trns_isakmp[] = {
429{ IPSECDOI_KEY_IKE, "IKE", NULL },
430};
431
432char *
433s_ipsecdoi_trns_isakmp(k)
434 int k;
435{
436 int i;
437 for (i = 0; i < ARRAYLEN(name_ipsecdoi_trns_isakmp); i++)
438 if (name_ipsecdoi_trns_isakmp[i].key == k)
439 return name_ipsecdoi_trns_isakmp[i].str;
440 return num2str(k);
441}
442
443static struct ksmap name_ipsecdoi_trns_ah[] = {
444{ IPSECDOI_AH_MD5, "MD5", NULL },
445{ IPSECDOI_AH_SHA, "SHA", NULL },
446{ IPSECDOI_AH_DES, "DES", NULL },
447{ IPSECDOI_AH_SHA256, "SHA256", NULL },
448{ IPSECDOI_AH_SHA384, "SHA384", NULL },
449{ IPSECDOI_AH_SHA512, "SHA512", NULL },
450};
451
452char *
453s_ipsecdoi_trns_ah(k)
454 int k;
455{
456 int i;
457 for (i = 0; i < ARRAYLEN(name_ipsecdoi_trns_ah); i++)
458 if (name_ipsecdoi_trns_ah[i].key == k)
459 return name_ipsecdoi_trns_ah[i].str;
460 return num2str(k);
461}
462
463static struct ksmap name_ipsecdoi_trns_esp[] = {
464{ IPSECDOI_ESP_DES_IV64, "DES_IV64", NULL },
465{ IPSECDOI_ESP_DES, "DES", NULL },
466{ IPSECDOI_ESP_3DES, "3DES", NULL },
467{ IPSECDOI_ESP_RC5, "RC5", NULL },
468{ IPSECDOI_ESP_IDEA, "IDEA", NULL },
469{ IPSECDOI_ESP_CAST, "CAST", NULL },
470{ IPSECDOI_ESP_BLOWFISH, "BLOWFISH", NULL },
471{ IPSECDOI_ESP_3IDEA, "3IDEA", NULL },
472{ IPSECDOI_ESP_DES_IV32, "DES_IV32", NULL },
473{ IPSECDOI_ESP_RC4, "RC4", NULL },
474{ IPSECDOI_ESP_NULL, "NULL", NULL },
475{ IPSECDOI_ESP_AES, "AES", NULL },
476{ IPSECDOI_ESP_TWOFISH, "TWOFISH", NULL },
477};
478
479char *
480s_ipsecdoi_trns_esp(k)
481 int k;
482{
483 int i;
484 for (i = 0; i < ARRAYLEN(name_ipsecdoi_trns_esp); i++)
485 if (name_ipsecdoi_trns_esp[i].key == k)
486 return name_ipsecdoi_trns_esp[i].str;
487 return num2str(k);
488}
489
490static struct ksmap name_ipsecdoi_trns_ipcomp[] = {
491{ IPSECDOI_IPCOMP_OUI, "OUI", NULL},
492{ IPSECDOI_IPCOMP_DEFLATE, "DEFLATE", NULL},
493{ IPSECDOI_IPCOMP_LZS, "LZS", NULL},
494};
495
496char *
497s_ipsecdoi_trns_ipcomp(k)
498 int k;
499{
500 int i;
501 for (i = 0; i < ARRAYLEN(name_ipsecdoi_trns_ipcomp); i++)
502 if (name_ipsecdoi_trns_ipcomp[i].key == k)
503 return name_ipsecdoi_trns_ipcomp[i].str;
504 return num2str(k);
505}
506
507char *
508s_ipsecdoi_trns(proto, trns)
509 int proto, trns;
510{
511 int i;
512 for (i = 0; i < ARRAYLEN(name_ipsecdoi_proto); i++)
513 if (name_ipsecdoi_proto[i].key == proto
514 && name_ipsecdoi_proto[i].f)
515 return (name_ipsecdoi_proto[i].f)(trns);
516 return num2str(trns);
517}
518
519static struct ksmap name_attr_ipsec[] = {
520{ IPSECDOI_ATTR_SA_LD_TYPE, "SA Life Type", s_ipsecdoi_ltype },
521{ IPSECDOI_ATTR_SA_LD, "SA Life Duration", NULL },
522{ IPSECDOI_ATTR_GRP_DESC, "Group Description", NULL },
523{ IPSECDOI_ATTR_ENC_MODE, "Encryption Mode", s_ipsecdoi_encmode },
524{ IPSECDOI_ATTR_AUTH, "Authentication Algorithm", s_ipsecdoi_auth },
525{ IPSECDOI_ATTR_KEY_LENGTH, "Key Length", NULL },
526{ IPSECDOI_ATTR_KEY_ROUNDS, "Key Rounds", NULL },
527{ IPSECDOI_ATTR_COMP_DICT_SIZE, "Compression Dictionary Size", NULL },
528{ IPSECDOI_ATTR_COMP_PRIVALG, "Compression Private Algorithm", NULL },
529};
530
531char *
532s_ipsecdoi_attr(k)
533 int k;
534{
535 int i;
536 for (i = 0; i < ARRAYLEN(name_attr_ipsec); i++)
537 if (name_attr_ipsec[i].key == k)
538 return name_attr_ipsec[i].str;
539 return num2str(k);
540}
541
542static struct ksmap name_attr_ipsec_ltype[] = {
543{ IPSECDOI_ATTR_SA_LD_TYPE_SEC, "seconds", NULL },
544{ IPSECDOI_ATTR_SA_LD_TYPE_KB, "kilobytes", NULL },
545};
546
547char *
548s_ipsecdoi_ltype(k)
549 int k;
550{
551 int i;
552 for (i = 0; i < ARRAYLEN(name_attr_ipsec_ltype); i++)
553 if (name_attr_ipsec_ltype[i].key == k)
554 return name_attr_ipsec_ltype[i].str;
555 return num2str(k);
556}
557
558static struct ksmap name_attr_ipsec_encmode[] = {
559{ IPSECDOI_ATTR_ENC_MODE_ANY, "Any", NULL },
560{ IPSECDOI_ATTR_ENC_MODE_TUNNEL, "Tunnel", NULL },
561{ IPSECDOI_ATTR_ENC_MODE_TRNS, "Transport", NULL },
562{ IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC, "UDP-Tunnel", NULL },
563{ IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC, "UDP-Transport", NULL },
564{ IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT, "UDP-Tunnel", NULL },
565{ IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT, "UDP-Transport", NULL },
566};
567
568char *
569s_ipsecdoi_encmode(k)
570 int k;
571{
572 int i;
573 for (i = 0; i < ARRAYLEN(name_attr_ipsec_encmode); i++)
574 if (name_attr_ipsec_encmode[i].key == k)
575 return name_attr_ipsec_encmode[i].str;
576 return num2str(k);
577}
578
579static struct ksmap name_attr_ipsec_auth[] = {
580{ IPSECDOI_ATTR_AUTH_HMAC_MD5, "hmac-md5", NULL },
581{ IPSECDOI_ATTR_AUTH_HMAC_SHA1, "hmac-sha", NULL },
582{ IPSECDOI_ATTR_AUTH_HMAC_SHA2_256, "hmac-sha256", NULL },
583{ IPSECDOI_ATTR_AUTH_HMAC_SHA2_384, "hmac-sha384", NULL },
584{ IPSECDOI_ATTR_AUTH_HMAC_SHA2_512, "hmac-sha512", NULL },
585{ IPSECDOI_ATTR_AUTH_DES_MAC, "des-mac", NULL },
586{ IPSECDOI_ATTR_AUTH_KPDK, "kpdk", NULL },
587};
588
589char *
590s_ipsecdoi_auth(k)
591 int k;
592{
593 int i;
594 for (i = 0; i < ARRAYLEN(name_attr_ipsec_auth); i++)
595 if (name_attr_ipsec_auth[i].key == k)
596 return name_attr_ipsec_auth[i].str;
597 return num2str(k);
598}
599
600char *
601s_ipsecdoi_attr_v(type, val)
602 int type, val;
603{
604 int i;
605 for (i = 0; i < ARRAYLEN(name_attr_ipsec); i++)
606 if (name_attr_ipsec[i].key == type
607 && name_attr_ipsec[i].f)
608 return (name_attr_ipsec[i].f)(val);
609 return num2str(val);
610}
611
612static struct ksmap name_ipsecdoi_ident[] = {
613{ IPSECDOI_ID_IPV4_ADDR, "IPv4_address", NULL },
614{ IPSECDOI_ID_FQDN, "FQDN", NULL },
615{ IPSECDOI_ID_USER_FQDN, "User_FQDN", NULL },
616{ IPSECDOI_ID_IPV4_ADDR_SUBNET, "IPv4_subnet", NULL },
617{ IPSECDOI_ID_IPV6_ADDR, "IPv6_address", NULL },
618{ IPSECDOI_ID_IPV6_ADDR_SUBNET, "IPv6_subnet", NULL },
619{ IPSECDOI_ID_IPV4_ADDR_RANGE, "IPv4_address_range", NULL },
620{ IPSECDOI_ID_IPV6_ADDR_RANGE, "IPv6_address_range", NULL },
621{ IPSECDOI_ID_DER_ASN1_DN, "DER_ASN1_DN", NULL },
622{ IPSECDOI_ID_DER_ASN1_GN, "DER_ASN1_GN", NULL },
623{ IPSECDOI_ID_KEY_ID, "KEY_ID", NULL },
624};
625
626char *
627s_ipsecdoi_ident(k)
628 int k;
629{
630 int i;
631 for (i = 0; i < ARRAYLEN(name_ipsecdoi_ident); i++)
632 if (name_ipsecdoi_ident[i].key == k)
633 return name_ipsecdoi_ident[i].str;
634 return num2str(k);
635}
636
637/* oakley.h */
638static struct ksmap name_oakley_attr[] = {
639{ OAKLEY_ATTR_ENC_ALG, "Encryption Algorithm", s_attr_isakmp_enc },
640{ OAKLEY_ATTR_HASH_ALG, "Hash Algorithm", s_attr_isakmp_hash },
641{ OAKLEY_ATTR_AUTH_METHOD, "Authentication Method", s_oakley_attr_method },
642{ OAKLEY_ATTR_GRP_DESC, "Group Description", s_attr_isakmp_desc },
643{ OAKLEY_ATTR_GRP_TYPE, "Group Type", s_attr_isakmp_group },
644{ OAKLEY_ATTR_GRP_PI, "Group Prime/Irreducible Polynomial", NULL },
645{ OAKLEY_ATTR_GRP_GEN_ONE, "Group Generator One", NULL },
646{ OAKLEY_ATTR_GRP_GEN_TWO, "Group Generator Two", NULL },
647{ OAKLEY_ATTR_GRP_CURVE_A, "Group Curve A", NULL },
648{ OAKLEY_ATTR_GRP_CURVE_B, "Group Curve B", NULL },
649{ OAKLEY_ATTR_SA_LD_TYPE, "Life Type", s_attr_isakmp_ltype },
650{ OAKLEY_ATTR_SA_LD, "Life Duration", NULL },
651{ OAKLEY_ATTR_PRF, "PRF", NULL },
652{ OAKLEY_ATTR_KEY_LEN, "Key Length", NULL },
653{ OAKLEY_ATTR_FIELD_SIZE, "Field Size", NULL },
654{ OAKLEY_ATTR_GRP_ORDER, "Group Order", NULL },
655{ OAKLEY_ATTR_BLOCK_SIZE, "Block Size", NULL },
656{ OAKLEY_ATTR_GSS_ID, "GSS-API endpoint name",NULL },
657};
658
659char *
660s_oakley_attr(k)
661 int k;
662{
663 int i;
664 for (i = 0; i < ARRAYLEN(name_oakley_attr); i++)
665 if (name_oakley_attr[i].key == k)
666 return name_oakley_attr[i].str;
667 return num2str(k);
668}
669
670static struct ksmap name_attr_isakmp_enc[] = {
671{ OAKLEY_ATTR_ENC_ALG_DES, "DES-CBC", NULL },
672{ OAKLEY_ATTR_ENC_ALG_IDEA, "IDEA-CBC", NULL },
673{ OAKLEY_ATTR_ENC_ALG_BLOWFISH, "Blowfish-CBC", NULL },
674{ OAKLEY_ATTR_ENC_ALG_RC5, "RC5-R16-B64-CBC", NULL },
675{ OAKLEY_ATTR_ENC_ALG_3DES, "3DES-CBC", NULL },
676{ OAKLEY_ATTR_ENC_ALG_CAST, "CAST-CBC", NULL },
d1e348cf 677{ OAKLEY_ATTR_ENC_ALG_AES, "AES-CBC", NULL },
52b7d2ce
A
678};
679
680char *
681s_attr_isakmp_enc(k)
682 int k;
683{
684 int i;
685 for (i = 0; i < ARRAYLEN(name_attr_isakmp_enc); i++)
686 if (name_attr_isakmp_enc[i].key == k)
687 return name_attr_isakmp_enc[i].str;
688 return num2str(k);
689}
690
691static struct ksmap name_attr_isakmp_hash[] = {
692{ OAKLEY_ATTR_HASH_ALG_MD5, "MD5", NULL },
693{ OAKLEY_ATTR_HASH_ALG_SHA, "SHA", NULL },
694{ OAKLEY_ATTR_HASH_ALG_TIGER, "Tiger", NULL },
695{ OAKLEY_ATTR_HASH_ALG_SHA2_256,"SHA256", NULL },
696{ OAKLEY_ATTR_HASH_ALG_SHA2_384,"SHA384", NULL },
697{ OAKLEY_ATTR_HASH_ALG_SHA2_512,"SHA512", NULL },
698};
699
700char *
701s_attr_isakmp_hash(k)
702 int k;
703{
704 int i;
705 for (i = 0; i < ARRAYLEN(name_attr_isakmp_hash); i++)
706 if (name_attr_isakmp_hash[i].key == k)
707 return name_attr_isakmp_hash[i].str;
708 return num2str(k);
709}
710
711static struct ksmap name_attr_isakmp_method[] = {
d1e348cf
A
712{ OAKLEY_ATTR_AUTH_METHOD_PSKEY, "pre-shared key", NULL },
713{ OAKLEY_ATTR_AUTH_METHOD_DSSSIG, "DSS signatures", NULL },
714{ OAKLEY_ATTR_AUTH_METHOD_RSASIG, "RSA signatures", NULL },
715{ OAKLEY_ATTR_AUTH_METHOD_RSAENC, "Encryption with RSA", NULL },
716{ OAKLEY_ATTR_AUTH_METHOD_RSAREV, "Revised encryption with RSA", NULL },
717{ OAKLEY_ATTR_AUTH_METHOD_EGENC, "Encryption with El-Gamal", NULL },
718{ OAKLEY_ATTR_AUTH_METHOD_EGREV, "Revised encryption with El-Gamal", NULL },
719#ifdef HAVE_GSSAPI
720{ OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB, "GSS-API on Kerberos 5", NULL },
721#endif
52b7d2ce 722#ifdef ENABLE_HYBRID
d1e348cf
A
723{ OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_R, "Hybrid DSS server", NULL },
724{ OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_R, "Hybrid RSA server", NULL },
725{ OAKLEY_ATTR_AUTH_METHOD_HYBRID_DSS_I, "Hybrid DSS client", NULL },
726{ OAKLEY_ATTR_AUTH_METHOD_HYBRID_RSA_I, "Hybrid RSA client", NULL },
727{ OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_I, "XAuth pskey client", NULL },
728{ OAKLEY_ATTR_AUTH_METHOD_XAUTH_PSKEY_R, "XAuth pskey server", NULL },
729{ OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_I, "XAuth RSASIG client", NULL },
730{ OAKLEY_ATTR_AUTH_METHOD_XAUTH_RSASIG_R, "XAuth RSASIG server", NULL },
52b7d2ce
A
731#endif
732};
733
734char *
735s_oakley_attr_method(k)
736 int k;
737{
738 int i;
739 for (i = 0; i < ARRAYLEN(name_attr_isakmp_method); i++)
740 if (name_attr_isakmp_method[i].key == k)
741 return name_attr_isakmp_method[i].str;
742 return num2str(k);
743}
744
745static struct ksmap name_attr_isakmp_desc[] = {
746{ OAKLEY_ATTR_GRP_DESC_MODP768, "768-bit MODP group", NULL },
747{ OAKLEY_ATTR_GRP_DESC_MODP1024, "1024-bit MODP group", NULL },
748{ OAKLEY_ATTR_GRP_DESC_EC2N155, "EC2N group on GP[2^155]", NULL },
749{ OAKLEY_ATTR_GRP_DESC_EC2N185, "EC2N group on GP[2^185]", NULL },
750{ OAKLEY_ATTR_GRP_DESC_MODP1536, "1536-bit MODP group", NULL },
751{ OAKLEY_ATTR_GRP_DESC_MODP2048, "2048-bit MODP group", NULL },
752{ OAKLEY_ATTR_GRP_DESC_MODP3072, "3072-bit MODP group", NULL },
753{ OAKLEY_ATTR_GRP_DESC_MODP4096, "4096-bit MODP group", NULL },
754{ OAKLEY_ATTR_GRP_DESC_MODP6144, "6144-bit MODP group", NULL },
755{ OAKLEY_ATTR_GRP_DESC_MODP8192, "8192-bit MODP group", NULL },
756};
757
758char *
759s_attr_isakmp_desc(k)
760 int k;
761{
762 int i;
763 for (i = 0; i < ARRAYLEN(name_attr_isakmp_desc); i++)
764 if (name_attr_isakmp_desc[i].key == k)
765 return name_attr_isakmp_desc[i].str;
766 return num2str(k);
767}
768
769static struct ksmap name_attr_isakmp_group[] = {
770{ OAKLEY_ATTR_GRP_TYPE_MODP, "MODP", NULL },
771{ OAKLEY_ATTR_GRP_TYPE_ECP, "ECP", NULL },
772{ OAKLEY_ATTR_GRP_TYPE_EC2N, "EC2N", NULL },
773};
774
775char *
776s_attr_isakmp_group(k)
777 int k;
778{
779 int i;
780 for (i = 0; i < ARRAYLEN(name_attr_isakmp_group); i++)
781 if (name_attr_isakmp_group[i].key == k)
782 return name_attr_isakmp_group[i].str;
783 return num2str(k);
784}
785
786static struct ksmap name_attr_isakmp_ltype[] = {
787{ OAKLEY_ATTR_SA_LD_TYPE_SEC, "seconds", NULL },
788{ OAKLEY_ATTR_SA_LD_TYPE_KB, "kilobytes", NULL },
789};
790
791char *
792s_attr_isakmp_ltype(k)
793 int k;
794{
795 int i;
796 for (i = 0; i < ARRAYLEN(name_attr_isakmp_ltype); i++)
797 if (name_attr_isakmp_ltype[i].key == k)
798 return name_attr_isakmp_ltype[i].str;
799 return num2str(k);
800}
801
802char *
803s_oakley_attr_v(type, val)
804 int type, val;
805{
806 int i;
807 for (i = 0; i < ARRAYLEN(name_oakley_attr); i++)
808 if (name_oakley_attr[i].key == type
809 && name_oakley_attr[i].f)
810 return (name_oakley_attr[i].f)(val);
811 return num2str(val);
812}
813
814/* netinet6/ipsec.h */
815static struct ksmap name_ipsec_level[] = {
816{ IPSEC_LEVEL_USE, "use", NULL },
817{ IPSEC_LEVEL_REQUIRE, "require", NULL },
818{ IPSEC_LEVEL_UNIQUE, "unique", NULL },
819};
820
821char *
822s_ipsec_level(k)
823 int k;
824{
825 int i;
826 for (i = 0; i < ARRAYLEN(name_ipsec_level); i++)
827 if (name_ipsec_level[i].key == k)
828 return name_ipsec_level[i].str;
829 return num2str(k);
830}
831
832static struct ksmap name_algclass[] = {
833{ algclass_ipsec_enc, "ipsec enc", s_ipsecdoi_trns_esp },
834{ algclass_ipsec_auth, "ipsec auth", s_ipsecdoi_trns_ah },
835{ algclass_ipsec_comp, "ipsec comp", s_ipsecdoi_trns_ipcomp },
836{ algclass_isakmp_enc, "isakmp enc", s_attr_isakmp_enc },
837{ algclass_isakmp_hash, "isakmp hash", s_attr_isakmp_hash },
838{ algclass_isakmp_dh, "isakmp dh", s_attr_isakmp_desc },
839{ algclass_isakmp_ameth, "isakmp auth method", s_oakley_attr_method },
840};
841
842char *
843s_algclass(k)
844 int k;
845{
846 int i;
847 for (i = 0; i < ARRAYLEN(name_algclass); i++)
848 if (name_algclass[i].key == k)
849 return name_algclass[i].str;
850 return num2str(k);
851}
852
853char *
854s_algtype(class, n)
855 int class, n;
856{
857 int i;
858 for (i = 0; i < ARRAYLEN(name_algclass); i++)
859 if (name_algclass[i].key == class
860 && name_algclass[i].f)
861 return (name_algclass[i].f)(n);
862 return num2str(n);
863}
864
865/* pfkey.h */
866static struct ksmap name_pfkey_type[] = {
867{ SADB_GETSPI, "GETSPI", NULL },
868{ SADB_UPDATE, "UPDATE", NULL },
869{ SADB_ADD, "ADD", NULL },
870{ SADB_DELETE, "DELETE", NULL },
871{ SADB_GET, "GET", NULL },
872{ SADB_ACQUIRE, "ACQUIRE", NULL },
873{ SADB_REGISTER, "REGISTER", NULL },
874{ SADB_EXPIRE, "EXPIRE", NULL },
875{ SADB_FLUSH, "FLUSH", NULL },
876{ SADB_DUMP, "DUMP", NULL },
d1e348cf 877{ SADB_X_PROMISC, "X_PROMISC", NULL },
52b7d2ce
A
878{ SADB_X_PCHANGE, "X_PCHANGE", NULL },
879{ SADB_X_SPDUPDATE, "X_SPDUPDATE", NULL },
880{ SADB_X_SPDADD, "X_SPDADD", NULL },
881{ SADB_X_SPDDELETE, "X_SPDDELETE", NULL },
882{ SADB_X_SPDGET, "X_SPDGET", NULL },
883{ SADB_X_SPDACQUIRE, "X_SPDACQUIRE", NULL },
884{ SADB_X_SPDDUMP, "X_SPDDUMP", NULL },
885{ SADB_X_SPDFLUSH, "X_SPDFLUSH", NULL },
886{ SADB_X_SPDSETIDX, "X_SPDSETIDX", NULL },
887{ SADB_X_SPDEXPIRE, "X_SPDEXPIRE", NULL },
888{ SADB_X_SPDDELETE2, "X_SPDDELETE2", NULL },
d1e348cf
A
889{ SADB_GETSASTAT, "X_GETSASTAT", NULL },
890#ifdef SADB_X_NAT_T_NEW_MAPPING
52b7d2ce
A
891{ SADB_X_NAT_T_NEW_MAPPING, "X_NAT_T_NEW_MAPPING", NULL },
892#endif
d1e348cf
A
893#ifdef SADB_X_MIGRATE
894{ SADB_X_MIGRATE, "X_MIGRATE", NULL },
52b7d2ce
A
895#endif
896};
897
898char *
899s_pfkey_type(k)
900 int k;
901{
902 int i;
903 for (i = 0; i < ARRAYLEN(name_pfkey_type); i++)
904 if (name_pfkey_type[i].key == k)
905 return name_pfkey_type[i].str;
906 return num2str(k);
907}
908
909static struct ksmap name_pfkey_satype[] = {
910{ SADB_SATYPE_UNSPEC, "UNSPEC", NULL },
911{ SADB_SATYPE_AH, "AH", NULL },
912{ SADB_SATYPE_ESP, "ESP", NULL },
913{ SADB_SATYPE_RSVP, "RSVP", NULL },
914{ SADB_SATYPE_OSPFV2, "OSPFV2", NULL },
915{ SADB_SATYPE_RIPV2, "RIPV2", NULL },
916{ SADB_SATYPE_MIP, "MIP", NULL },
917{ SADB_X_SATYPE_IPCOMP, "IPCOMP", NULL },
918};
919
920char *
921s_pfkey_satype(k)
922 int k;
923{
924 int i;
925 for (i = 0; i < ARRAYLEN(name_pfkey_satype); i++)
926 if (name_pfkey_satype[i].key == k)
927 return name_pfkey_satype[i].str;
928 return num2str(k);
929}
930
931static struct ksmap name_direction[] = {
932{ IPSEC_DIR_INBOUND, "in", NULL },
933{ IPSEC_DIR_OUTBOUND, "out", NULL },
934#ifdef HAVE_POLICY_FWD
935{ IPSEC_DIR_FWD, "fwd", NULL },
936#endif
937};
938
939char *
940s_direction(k)
941 int k;
942{
943 int i;
944 for (i = 0; i < ARRAYLEN(name_direction); i++)
945 if (name_direction[i].key == k)
946 return name_direction[i].str;
947 return num2str(k);
948}
949
950char *
951s_proto(k)
952 int k;
953{
954 switch (k) {
955 case IPPROTO_ICMP:
956 return "icmp";
957 case IPPROTO_TCP:
958 return "tcp";
959 case IPPROTO_UDP:
960 return "udp";
961 case IPPROTO_ICMPV6:
962 return "icmpv6";
963 case IPSEC_ULPROTO_ANY:
964 return "any";
965 }
966
967 return num2str(k);
968}
969
970char *
971s_doi(int k)
972{
973 switch (k) {
974 case IPSEC_DOI:
975 return "ipsec_doi";
976 default:
977 return num2str(k);
978 }
979}
980
981char *
982s_etype (int k)
983{
984 switch (k) {
985 case ISAKMP_ETYPE_NONE:
986 return "_none";
987 case ISAKMP_ETYPE_BASE:
988 return "base";
989 case ISAKMP_ETYPE_IDENT:
990 return "main";
991 case ISAKMP_ETYPE_AUTH:
992 return "_auth";
993 case ISAKMP_ETYPE_AGG:
994 return "aggressive";
995 case ISAKMP_ETYPE_INFO:
996 return "_info";
997 case ISAKMP_ETYPE_QUICK:
998 return "_quick";
999 case ISAKMP_ETYPE_NEWGRP:
1000 return "_newgrp";
1001 case ISAKMP_ETYPE_ACKINFO:
1002 return "_ackinfo";
1003 default:
1004 return num2str(k);
1005 }
1006}
1007
1008char *
1009s_idtype (int k)
1010{
1011 switch (k) {
1012 case IDTYPE_FQDN:
1013 return "fqdn";
1014 case IDTYPE_USERFQDN:
1015 return "user_fqdn";
1016 case IDTYPE_KEYID:
1017 return "keyid";
1018 case IDTYPE_ADDRESS:
1019 return "address";
1020 case IDTYPE_ASN1DN:
1021 return "asn1dn";
1022 default:
1023 return num2str(k);
1024 }
1025}
1026
1027char *
1028s_switch (int k)
1029{
1030 switch (k) {
1031 case FALSE:
1032 return "off";
1033 case TRUE:
1034 return "on";
1035 default:
1036 return num2str(k);
1037 }
1038}