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