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