2f2ddd3b1a3e8afe7912fbda7a4d6f72e36d3000
[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 #ifdef NAT_TRAVERSAL
84 "X-NAT-T-type", /* SADB_X_EXT_NAT_T_TYPE 26 */
85 "X-NAT-T-sport", /* SADB_X_EXT_NAT_T_SPORT 27 */
86 "X-NAT-T-dport", /* SADB_X_EXT_NAT_T_DPORT 28 */
87 "X-NAT-T-OA", /* SADB_X_EXT_NAT_T_OA 29 */
88 #endif
89 };
90
91 const char *
92 pfkey_v2_sadb_ext_string(int ext)
93 {
94 if(ext <= SADB_EXT_MAX) {
95 return pfkey_sadb_ext_strings[ext];
96 } else {
97 return "unknown-ext";
98 }
99 }
100
101
102 static char *pfkey_sadb_type_strings[]={
103 "reserved", /* SADB_RESERVED */
104 "getspi", /* SADB_GETSPI */
105 "update", /* SADB_UPDATE */
106 "add", /* SADB_ADD */
107 "delete", /* SADB_DELETE */
108 "get", /* SADB_GET */
109 "acquire", /* SADB_ACQUIRE */
110 "register", /* SADB_REGISTER */
111 "expire", /* SADB_EXPIRE */
112 "flush", /* SADB_FLUSH */
113 "dump", /* SADB_DUMP */
114 "x-promisc", /* SADB_X_PROMISC */
115 "x-pchange", /* SADB_X_PCHANGE */
116 "x-groupsa", /* SADB_X_GRPSA */
117 "x-addflow(eroute)", /* SADB_X_ADDFLOW */
118 "x-delflow(eroute)", /* SADB_X_DELFLOW */
119 "x-debug", /* SADB_X_DEBUG */
120 };
121
122 const char *
123 pfkey_v2_sadb_type_string(int sadb_type)
124 {
125 if(sadb_type <= SADB_MAX) {
126 return pfkey_sadb_type_strings[sadb_type];
127 } else {
128 return "unknown-sadb-type";
129 }
130 }
131
132
133
134
135 /*
136 * $Log: pfkey_v2_debug.c,v $
137 * Revision 1.2 2004/03/22 21:53:18 as
138 * merged alg-0.8.1 branch with HEAD
139 *
140 * Revision 1.1.2.1 2004/03/15 22:30:06 as
141 * nat-0.6c patch merged
142 *
143 * Revision 1.1 2004/03/15 20:35:26 as
144 * added files from freeswan-2.04-x509-1.5.3
145 *
146 * Revision 1.7 2002/09/20 05:01:26 rgb
147 * Fixed limit inclusion error in both type and ext string conversion.
148 *
149 * Revision 1.6 2002/04/24 07:55:32 mcr
150 * #include patches and Makefiles for post-reorg compilation.
151 *
152 * Revision 1.5 2002/04/24 07:36:40 mcr
153 * Moved from ./lib/pfkey_v2_debug.c,v
154 *
155 * Revision 1.4 2002/01/29 22:25:36 rgb
156 * Re-add ipsec_kversion.h to keep MALLOC happy.
157 *
158 * Revision 1.3 2002/01/29 01:59:09 mcr
159 * removal of kversions.h - sources that needed it now use ipsec_param.h.
160 * updating of IPv6 structures to match latest in6.h version.
161 * removed dead code from freeswan.h that also duplicated kversions.h
162 * code.
163 *
164 * Revision 1.2 2002/01/20 20:34:50 mcr
165 * added pfkey_v2_sadb_type_string to decode sadb_type to string.
166 *
167 * Revision 1.1 2001/11/27 05:30:06 mcr
168 * initial set of debug strings for pfkey debugging.
169 * this will eventually only be included for debug builds.
170 *
171 * Revision 1.1 2001/09/21 04:12:03 mcr
172 * first compilable version.
173 *
174 *
175 * Local variables:
176 * c-file-style: "linux"
177 * End:
178 *
179 */