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