forked from CAIDA/mper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mper_keywords.c
358 lines (340 loc) · 11.5 KB
/
mper_keywords.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
/* C code produced by gperf version 3.0.4 */
/* Command-line: gperf mper_keywords.gperf */
/* Computed positions: -k'1,12,$' */
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
error "gperf generated tables don't work with this execution character set. Please report a bug to <[email protected]>."
#endif
#line 6 "mper_keywords.gperf"
/*
** gperf-generated perfect hashing for keywords used in the control socket
** request/response exchanges.
**
** --------------------------------------------------------------------------
** Author: Young Hyun
** Copyright (C) 2009 The Regents of the University of California.
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#include "mper_keywords.h"
const char* keyword_code_names[] = {
"<NONE>",
"<ERROR>",
"<REQNUM>",
"<CMD_MIN>",
"ping",
"cmd_error",
"send_error",
"resp_timeout",
"ping_resp",
"<CMD_MAX>",
"<OPT_MIN>",
"txt",
"pkt",
"src",
"dest",
"net",
"ttl",
"meth",
"cksum",
"sport",
"dport",
"spacing",
"reply_count",
"timeout",
"tos",
"rr",
"tsonly",
"tsandaddr",
"tsps_ip1",
"tsps_ip2",
"tsps_ip3",
"tsps_ip4",
"udata",
"tx",
"rx",
"probe_ttl",
"probe_ipid",
"reply_src",
"reply_ttl",
"reply_ipid",
"reply_icmp",
"reply_qttl",
"reply_tcp",
"reply_ipopt_cmp",
"reply_rr",
"reply_tsps_ts1",
"reply_tsps_ip1",
"reply_tsps_ts2",
"reply_tsps_ip2",
"reply_tsps_ts3",
"reply_tsps_ip3",
"reply_tsps_ts4",
"reply_tsps_ip4",
"stop_reason",
"stop_data",
"<OPT_MAX>"
};
const char* keyword_type_names[] = {
"<none>",
"integer",
"string",
"blob",
"symbol",
"IP address",
"IP prefix",
"timeval"
};
#line 108 "mper_keywords.gperf"
struct keyword;
#define TOTAL_KEYWORDS 49
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 15
#define MIN_HASH_VALUE 2
#define MAX_HASH_VALUE 89
/* maximum key range = 88, duplicates = 0 */
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)
inline
#elif defined(__GNUC__)
__inline
#endif
static unsigned int
hash (str, len)
register const char *str;
register unsigned int len;
{
static const unsigned char asso_values[] =
{
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 50,
45, 35, 20, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 35, 90, 0, 90, 27,
30, 0, 90, 60, 41, 25, 90, 90, 20, 10,
5, 30, 10, 15, 10, 0, 5, 5, 0, 90,
0, 0, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
90, 90, 90, 90, 90, 90, 90
};
register int hval = len;
switch (hval)
{
default:
hval += asso_values[(unsigned char)str[11]];
/*FALLTHROUGH*/
case 11:
case 10:
case 9:
case 8:
case 7:
case 6:
case 5:
case 4:
case 3:
case 2:
case 1:
hval += asso_values[(unsigned char)str[0]+1];
break;
}
return hval + asso_values[(unsigned char)str[len - 1]];
}
#ifdef __GNUC__
__inline
#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const struct keyword *
in_word_set (str, len)
register const char *str;
register unsigned int len;
{
static const struct keyword wordlist[] =
{
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 142 "mper_keywords.gperf"
{"rx", KC_RX_OPT, KT_TIMEVAL},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 140 "mper_keywords.gperf"
{"udata", KC_UDATA_OPT, KT_UINT},
{"",KC_NONE,KT_NONE},
#line 141 "mper_keywords.gperf"
{"tx", KC_TX_OPT, KT_TIMEVAL},
#line 132 "mper_keywords.gperf"
{"tos", KC_TOS_OPT, KT_UINT},
#line 122 "mper_keywords.gperf"
{"dest", KC_DEST_OPT, KT_ADDRESS},
#line 128 "mper_keywords.gperf"
{"dport", KC_DPORT_OPT, KT_UINT},
#line 134 "mper_keywords.gperf"
{"tsonly", KC_TSONLY_OPT, KT_UINT},
#line 133 "mper_keywords.gperf"
{"rr", KC_RR_OPT, KT_UINT},
#line 119 "mper_keywords.gperf"
{"txt", KC_TXT_OPT, KT_STR},
#line 164 "mper_keywords.gperf"
{"stop_data", KC_STOP_DATA_OPT, KT_UINT},
#line 127 "mper_keywords.gperf"
{"sport", KC_SPORT_OPT, KT_UINT},
#line 130 "mper_keywords.gperf"
{"reply_count", KC_REPLY_COUNT_OPT, KT_UINT},
#line 131 "mper_keywords.gperf"
{"timeout", KC_TIMEOUT_OPT, KT_UINT},
#line 154 "mper_keywords.gperf"
{"reply_rr", KC_REPLY_RR_OPT, KT_STR},
#line 152 "mper_keywords.gperf"
{"reply_tcp", KC_REPLY_TCP_OPT, KT_UINT},
#line 150 "mper_keywords.gperf"
{"reply_icmp", KC_REPLY_ICMP_OPT, KT_UINT},
#line 163 "mper_keywords.gperf"
{"stop_reason", KC_STOP_REASON_OPT, KT_UINT},
#line 115 "mper_keywords.gperf"
{"resp_timeout", KC_RESP_TIMEOUT_CMD, KT_NONE},
#line 120 "mper_keywords.gperf"
{"pkt", KC_PKT_OPT, KT_BLOB},
#line 135 "mper_keywords.gperf"
{"tsandaddr", KC_TSANDADDR_OPT, KT_UINT},
#line 114 "mper_keywords.gperf"
{"send_error", KC_SEND_ERROR_CMD, KT_NONE},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 124 "mper_keywords.gperf"
{"ttl", KC_TTL_OPT, KT_UINT},
#line 148 "mper_keywords.gperf"
{"reply_ttl", KC_REPLY_TTL_OPT, KT_UINT},
#line 151 "mper_keywords.gperf"
{"reply_qttl", KC_REPLY_QTTL_OPT, KT_UINT},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 139 "mper_keywords.gperf"
{"tsps_ip4", KC_TSPS_IP4_OPT, KT_ADDRESS},
#line 116 "mper_keywords.gperf"
{"ping_resp", KC_PING_RESP_CMD, KT_NONE},
#line 121 "mper_keywords.gperf"
{"src", KC_SRC_OPT, KT_ADDRESS},
#line 147 "mper_keywords.gperf"
{"reply_src", KC_REPLY_SRC_OPT, KT_ADDRESS},
{"",KC_NONE,KT_NONE},
#line 123 "mper_keywords.gperf"
{"net", KC_NET_OPT, KT_PREFIX},
#line 161 "mper_keywords.gperf"
{"reply_tsps_ts4", KC_REPLY_TSPS_TS4_OPT, KT_UINT},
#line 149 "mper_keywords.gperf"
{"reply_ipid", KC_REPLY_IPID_OPT, KT_UINT},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
{"",KC_NONE,KT_NONE},
#line 145 "mper_keywords.gperf"
{"probe_ttl", KC_PROBE_TTL_OPT, KT_UINT},
#line 126 "mper_keywords.gperf"
{"cksum", KC_CKSUM_OPT, KT_UINT},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 138 "mper_keywords.gperf"
{"tsps_ip3", KC_TSPS_IP3_OPT, KT_ADDRESS},
#line 113 "mper_keywords.gperf"
{"cmd_error", KC_CMD_ERROR_CMD, KT_NONE},
#line 125 "mper_keywords.gperf"
{"meth", KC_METH_OPT, KT_SYMBOL},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
{"",KC_NONE,KT_NONE},
#line 159 "mper_keywords.gperf"
{"reply_tsps_ts3", KC_REPLY_TSPS_TS3_OPT, KT_UINT},
#line 146 "mper_keywords.gperf"
{"probe_ipid", KC_PROBE_IPID_OPT, KT_UINT},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 137 "mper_keywords.gperf"
{"tsps_ip2", KC_TSPS_IP2_OPT, KT_ADDRESS},
#line 162 "mper_keywords.gperf"
{"reply_tsps_ip4", KC_REPLY_TSPS_IP4_OPT, KT_ADDRESS},
#line 153 "mper_keywords.gperf"
{"reply_ipopt_cmp", KC_REPLY_IPOPT_CMP_OPT, KT_UINT},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 136 "mper_keywords.gperf"
{"tsps_ip1", KC_TSPS_IP1_OPT, KT_ADDRESS},
#line 157 "mper_keywords.gperf"
{"reply_tsps_ts2", KC_REPLY_TSPS_TS2_OPT, KT_UINT},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 155 "mper_keywords.gperf"
{"reply_tsps_ts1", KC_REPLY_TSPS_TS1_OPT, KT_UINT},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 129 "mper_keywords.gperf"
{"spacing", KC_SPACING_OPT, KT_UINT},
{"",KC_NONE,KT_NONE},
#line 160 "mper_keywords.gperf"
{"reply_tsps_ip3", KC_REPLY_TSPS_IP3_OPT, KT_ADDRESS},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 112 "mper_keywords.gperf"
{"ping", KC_PING_CMD, KT_NONE},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 158 "mper_keywords.gperf"
{"reply_tsps_ip2", KC_REPLY_TSPS_IP2_OPT, KT_ADDRESS},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
{"",KC_NONE,KT_NONE}, {"",KC_NONE,KT_NONE},
#line 156 "mper_keywords.gperf"
{"reply_tsps_ip1", KC_REPLY_TSPS_IP1_OPT, KT_ADDRESS}
};
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash (str, len);
if (key <= MAX_HASH_VALUE && key >= 0)
{
register const char *s = wordlist[key].name;
if (*str == *s && !strcmp (str + 1, s + 1))
return &wordlist[key];
}
}
return 0;
}
#line 165 "mper_keywords.gperf"
/* functions */