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