removed NAT_TRAVERSAL compile option
[strongswan.git] / src / libfreeswan / pfkey_v2_debug.c
1 /*
2 * @(#) pfkey version 2 debugging messages
3 *
4 * Copyright (C) 2001 Richard Guy Briggs <rgb@freeswan.org>
5 * and Michael Richardson <mcr@freeswan.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 *
17 * RCSID $Id: pfkey_v2_debug.c,v 1.2 2004/03/22 21:53:18 as Exp $
18 *
19 */
20
21 #ifdef __KERNEL__
22
23 # include <linux/kernel.h> /* for printk */
24
25 # include "freeswan/ipsec_kversion.h" /* for malloc switch */
26 # ifdef MALLOC_SLAB
27 # include <linux/slab.h> /* kmalloc() */
28 # else /* MALLOC_SLAB */
29 # include <linux/malloc.h> /* kmalloc() */
30 # endif /* MALLOC_SLAB */
31 # include <linux/errno.h> /* error codes */
32 # include <linux/types.h> /* size_t */
33 # include <linux/interrupt.h> /* mark_bh */
34
35 # include <linux/netdevice.h> /* struct device, and other headers */
36 # include <linux/etherdevice.h> /* eth_type_trans */
37 extern int debug_pfkey;
38
39 #else /* __KERNEL__ */
40
41 # include <sys/types.h>
42 # include <linux/types.h>
43 # include <linux/errno.h>
44
45 #endif /* __KERNEL__ */
46
47 #include "freeswan.h"
48 #include "pfkeyv2.h"
49 #include "pfkey.h"
50
51 /*
52 * This file provides ASCII translations of PF_KEY magic numbers.
53 *
54 */
55
56 static char *pfkey_sadb_ext_strings[]={
57 "reserved", /* SADB_EXT_RESERVED 0 */
58 "security-association", /* SADB_EXT_SA 1 */
59 "lifetime-current", /* SADB_EXT_LIFETIME_CURRENT 2 */
60 "lifetime-hard", /* SADB_EXT_LIFETIME_HARD 3 */
61 "lifetime-soft", /* SADB_EXT_LIFETIME_SOFT 4 */
62 "source-address", /* SADB_EXT_ADDRESS_SRC 5 */
63 "destination-address", /* SADB_EXT_ADDRESS_DST 6 */
64 "proxy-address", /* SADB_EXT_ADDRESS_PROXY 7 */
65 "authentication-key", /* SADB_EXT_KEY_AUTH 8 */
66 "cipher-key", /* SADB_EXT_KEY_ENCRYPT 9 */
67 "source-identity", /* SADB_EXT_IDENTITY_SRC 10 */
68 "destination-identity", /* SADB_EXT_IDENTITY_DST 11 */
69 "sensitivity-label", /* SADB_EXT_SENSITIVITY 12 */
70 "proposal", /* SADB_EXT_PROPOSAL 13 */
71 "supported-auth", /* SADB_EXT_SUPPORTED_AUTH 14 */
72 "supported-cipher", /* SADB_EXT_SUPPORTED_ENCRYPT 15 */
73 "spi-range", /* SADB_EXT_SPIRANGE 16 */
74 "X-kmpprivate", /* SADB_X_EXT_KMPRIVATE 17 */
75 "X-satype2", /* SADB_X_EXT_SATYPE2 18 */
76 "X-security-association", /* SADB_X_EXT_SA2 19 */
77 "X-destination-address2", /* SADB_X_EXT_ADDRESS_DST2 20 */
78 "X-source-flow-address", /* SADB_X_EXT_ADDRESS_SRC_FLOW 21 */
79 "X-dest-flow-address", /* SADB_X_EXT_ADDRESS_DST_FLOW 22 */
80 "X-source-mask", /* SADB_X_EXT_ADDRESS_SRC_MASK 23 */
81 "X-dest-mask", /* SADB_X_EXT_ADDRESS_DST_MASK 24 */
82 "X-set-debug", /* SADB_X_EXT_DEBUG 25 */
83 "X-NAT-T-type", /* SADB_X_EXT_NAT_T_TYPE 26 */
84 "X-NAT-T-sport", /* SADB_X_EXT_NAT_T_SPORT 27 */
85 "X-NAT-T-dport", /* SADB_X_EXT_NAT_T_DPORT 28 */
86 "X-NAT-T-OA", /* SADB_X_EXT_NAT_T_OA 29 */
87 };
88
89 const char *
90 pfkey_v2_sadb_ext_string(int ext)
91 {
92 if(ext <= SADB_EXT_MAX) {
93 return pfkey_sadb_ext_strings[ext];
94 } else {
95 return "unknown-ext";
96 }
97 }
98
99
100 static char *pfkey_sadb_type_strings[]={
101 "reserved", /* SADB_RESERVED */
102 "getspi", /* SADB_GETSPI */
103 "update", /* SADB_UPDATE */
104 "add", /* SADB_ADD */
105 "delete", /* SADB_DELETE */
106 "get", /* SADB_GET */
107 "acquire", /* SADB_ACQUIRE */
108 "register", /* SADB_REGISTER */
109 "expire", /* SADB_EXPIRE */
110 "flush", /* SADB_FLUSH */
111 "dump", /* SADB_DUMP */
112 "x-promisc", /* SADB_X_PROMISC */
113 "x-pchange", /* SADB_X_PCHANGE */
114 "x-groupsa", /* SADB_X_GRPSA */
115 "x-addflow(eroute)", /* SADB_X_ADDFLOW */
116 "x-delflow(eroute)", /* SADB_X_DELFLOW */
117 "x-debug", /* SADB_X_DEBUG */
118 };
119
120 const char *
121 pfkey_v2_sadb_type_string(int sadb_type)
122 {
123 if(sadb_type <= SADB_MAX) {
124 return pfkey_sadb_type_strings[sadb_type];
125 } else {
126 return "unknown-sadb-type";
127 }
128 }
129
130
131
132
133 /*
134 * $Log: pfkey_v2_debug.c,v $
135 * Revision 1.2 2004/03/22 21:53:18 as
136 * merged alg-0.8.1 branch with HEAD
137 *
138 * Revision 1.1.2.1 2004/03/15 22:30:06 as
139 * nat-0.6c patch merged
140 *
141 * Revision 1.1 2004/03/15 20:35:26 as
142 * added files from freeswan-2.04-x509-1.5.3
143 *
144 * Revision 1.7 2002/09/20 05:01:26 rgb
145 * Fixed limit inclusion error in both type and ext string conversion.
146 *
147 * Revision 1.6 2002/04/24 07:55:32 mcr
148 * #include patches and Makefiles for post-reorg compilation.
149 *
150 * Revision 1.5 2002/04/24 07:36:40 mcr
151 * Moved from ./lib/pfkey_v2_debug.c,v
152 *
153 * Revision 1.4 2002/01/29 22:25:36 rgb
154 * Re-add ipsec_kversion.h to keep MALLOC happy.
155 *
156 * Revision 1.3 2002/01/29 01:59:09 mcr
157 * removal of kversions.h - sources that needed it now use ipsec_param.h.
158 * updating of IPv6 structures to match latest in6.h version.
159 * removed dead code from freeswan.h that also duplicated kversions.h
160 * code.
161 *
162 * Revision 1.2 2002/01/20 20:34:50 mcr
163 * added pfkey_v2_sadb_type_string to decode sadb_type to string.
164 *
165 * Revision 1.1 2001/11/27 05:30:06 mcr
166 * initial set of debug strings for pfkey debugging.
167 * this will eventually only be included for debug builds.
168 *
169 * Revision 1.1 2001/09/21 04:12:03 mcr
170 * first compilable version.
171 *
172 *
173 * Local variables:
174 * c-file-style: "linux"
175 * End:
176 *
177 */