blob: 59ff010dd129eda12eaee763714c40baed8b54c8 [file] [log] [blame]
Emeric Brun107ca302010-01-04 16:16:05 +01001/*
2 * Patterns management functions.
3 *
4 * Copyright 2009-2010 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 */
12
13#include <string.h>
14#include <arpa/inet.h>
Emeric Brun107ca302010-01-04 16:16:05 +010015
16#include <proto/pattern.h>
Emeric Brun485479d2010-09-23 18:02:19 +020017#include <proto/buffers.h>
Emeric Brun107ca302010-01-04 16:16:05 +010018#include <common/standard.h>
19
20/* static structure used on pattern_process if <p> is NULL*/
21static struct pattern spattern;
22
23/* trash chunk used for pattern conversions */
24static struct chunk trash_chunk;
25
26/* trash buffers used or pattern conversions */
27static char pattern_trash_buf1[BUFSIZE];
28static char pattern_trash_buf2[BUFSIZE];
29
30/* pattern_trash_buf point on used buffer*/
31static char *pattern_trash_buf = pattern_trash_buf1;
32
Emeric Brun107ca302010-01-04 16:16:05 +010033/* list head of all known pattern fetch keywords */
34static struct pattern_fetch_kw_list pattern_fetches = {
35 .list = LIST_HEAD_INIT(pattern_fetches.list)
36};
37
38/* list head of all known pattern format conversion keywords */
39static struct pattern_conv_kw_list pattern_convs = {
40 .list = LIST_HEAD_INIT(pattern_convs.list)
41};
42
43/*
44 * Registers the pattern fetch keyword list <kwl> as a list of valid keywords for next
45 * parsing sessions.
46 */
47void pattern_register_fetches(struct pattern_fetch_kw_list *pfkl)
48{
49 LIST_ADDQ(&pattern_fetches.list, &pfkl->list);
50}
51
52/*
53 * Registers the pattern format coverstion keyword list <pckl> as a list of valid keywords for next
54 * parsing sessions.
55 */
56void pattern_register_convs(struct pattern_conv_kw_list *pckl)
57{
58 LIST_ADDQ(&pattern_convs.list, &pckl->list);
59}
60
61/*
62 * Returns the pointer on pattern fetch keyword structure identified by
63 * string of <len> in buffer <kw>.
64 *
65 */
66struct pattern_fetch *find_pattern_fetch(const char *kw, int len)
67{
68 int index;
69 struct pattern_fetch_kw_list *kwl;
70
71 list_for_each_entry(kwl, &pattern_fetches.list, list) {
72 for (index = 0; kwl->kw[index].kw != NULL; index++) {
73 if (strncmp(kwl->kw[index].kw, kw, len) == 0 &&
74 kwl->kw[index].kw[len] == '\0')
75 return &kwl->kw[index];
76 }
77 }
78 return NULL;
79}
80
81/*
82 * Returns the pointer on pattern format conversion keyword structure identified by
83 * string of <len> in buffer <kw>.
84 *
85 */
86struct pattern_conv *find_pattern_conv(const char *kw, int len)
87{
88 int index;
89 struct pattern_conv_kw_list *kwl;
90
91 list_for_each_entry(kwl, &pattern_convs.list, list) {
92 for (index = 0; kwl->kw[index].kw != NULL; index++) {
93 if (strncmp(kwl->kw[index].kw, kw, len) == 0 &&
94 kwl->kw[index].kw[len] == '\0')
95 return &kwl->kw[index];
96 }
97 }
98 return NULL;
99}
100
101
102/*
103* Returns a static trash struct chunk to use in pattern casts or format conversions
104* Swiths the 2 available trash buffers to protect data during convert
105*/
106static struct chunk *get_trash_chunk(void)
107{
108 if (pattern_trash_buf == pattern_trash_buf1)
109 pattern_trash_buf = pattern_trash_buf2;
110 else
111 pattern_trash_buf = pattern_trash_buf1;
112
Emeric Brun485479d2010-09-23 18:02:19 +0200113 chunk_init(&trash_chunk, pattern_trash_buf, BUFSIZE);
Emeric Brun107ca302010-01-04 16:16:05 +0100114
115 return &trash_chunk;
116}
117
118/*
119* Used to set pattern data from a struct chunk, could be the trash struct chunk
120*/
121static void pattern_data_setstring(union pattern_data *data, struct chunk *c)
122{
Emeric Brun485479d2010-09-23 18:02:19 +0200123 chunk_initlen(&data->str, c->str, c->size, c->len);
Emeric Brun107ca302010-01-04 16:16:05 +0100124}
125
126/******************************************************************/
127/* Pattern casts functions */
128/******************************************************************/
129
130static int c_ip2int(union pattern_data *data)
131{
132 data->integer = ntohl(data->ip.s_addr);
133 return 1;
134}
135
136static int c_ip2str(union pattern_data *data)
137{
138 struct chunk *trash = get_trash_chunk();
139
140 if (!inet_ntop(AF_INET, (void *)&data->ip, trash->str, trash->size))
141 return 0;
142
143 trash->len = strlen(trash->str);
144 pattern_data_setstring(data, trash);
145
146 return 1;
147}
148
David du Colombier4f92d322011-03-24 11:09:31 +0100149static int c_ip2ipv6(union pattern_data *data)
150{
151 v4tov6(&data->ipv6, &data->ip);
152 return 1;
153}
154
155static int c_ipv62str(union pattern_data *data)
156{
157 struct chunk *trash = get_trash_chunk();
158
159 if (!inet_ntop(AF_INET6, (void *)&data->ipv6, trash->str, trash->size))
160 return 0;
161
162 trash->len = strlen(trash->str);
163 pattern_data_setstring(data, trash);
164
165 return 1;
166}
167
168/*
169static int c_ipv62ip(union pattern_data *data)
170{
171 return v6tov4(&data->ip, &data->ipv6);
172}
173*/
174
Emeric Brun107ca302010-01-04 16:16:05 +0100175static int c_int2ip(union pattern_data *data)
176{
177 data->ip.s_addr = htonl(data->integer);
178 return 1;
179}
180
Emeric Brun107ca302010-01-04 16:16:05 +0100181static int c_str2ip(union pattern_data *data)
182{
183 if (!buf2ip(data->str.str, data->str.len, &data->ip))
184 return 0;
185 return 1;
186}
187
David du Colombier4f92d322011-03-24 11:09:31 +0100188static int c_str2ipv6(union pattern_data *data)
189{
190 return inet_pton(AF_INET6, data->str.str, &data->ipv6);
191}
192
Emeric Brun107ca302010-01-04 16:16:05 +0100193static int c_int2str(union pattern_data *data)
194{
195 struct chunk *trash = get_trash_chunk();
196 char *pos;
197
198 pos = ultoa_r(data->integer, trash->str, trash->size);
199
200 if (!pos)
201 return 0;
202
Emeric Brun485479d2010-09-23 18:02:19 +0200203 trash->size = trash->size - (pos - trash->str);
Emeric Brun107ca302010-01-04 16:16:05 +0100204 trash->str = pos;
205 trash->len = strlen(pos);
206
207 pattern_data_setstring(data, trash);
208
209 return 1;
210}
211
Emeric Brun485479d2010-09-23 18:02:19 +0200212static int c_datadup(union pattern_data *data)
213{
214 struct chunk *trash = get_trash_chunk();
215
216 trash->len = data->str.len < trash->size ? data->str.len : trash->size;
217 memcpy(trash->str, data->str.str, trash->len);
218
219 pattern_data_setstring(data, trash);
220
221 return 1;
222}
223
224
Emeric Brun107ca302010-01-04 16:16:05 +0100225static int c_donothing(union pattern_data *data)
226{
227 return 1;
228}
229
230static int c_str2int(union pattern_data *data)
231{
232 int i;
233 uint32_t ret = 0;
234
235 for (i = 0; i < data->str.len; i++) {
236 uint32_t val = data->str.str[i] - '0';
237
238 if (val > 9)
239 break;
240
241 ret = ret * 10 + val;
242 }
243
244 data->integer = ret;
245 return 1;
246}
247
248/*****************************************************************/
249/* Pattern casts matrix: */
250/* pattern_casts[from type][to type] */
251/* NULL pointer used for impossible pattern casts */
252/*****************************************************************/
Emeric Brun107ca302010-01-04 16:16:05 +0100253
Willy Tarreauf0b38bf2010-06-06 13:22:23 +0200254typedef int (*pattern_cast_fct)(union pattern_data *data);
255static pattern_cast_fct pattern_casts[PATTERN_TYPES][PATTERN_TYPES] = {
David du Colombier4f92d322011-03-24 11:09:31 +0100256/* to: IP IPV6 INTEGER STRING DATA CONSTSTRING CONSTDATA */
257/* from: IP */ { c_donothing, c_ip2ipv6, c_ip2int, c_ip2str, NULL, c_ip2str, NULL },
258/* IPV6 */ { NULL, c_donothing, NULL, c_ipv62str, NULL, c_ipv62str, NULL },
259/* INTEGER */ { c_int2ip, NULL, c_donothing, c_int2str, NULL, c_int2str, NULL },
260/* STRING */ { c_str2ip, c_str2ipv6, c_str2int, c_donothing, c_donothing, c_donothing, c_donothing },
261/* DATA */ { NULL, NULL, NULL, NULL, c_donothing, NULL, c_donothing },
262/* CONSTSTRING */ { c_str2ip, c_str2ipv6, c_str2int, c_datadup, c_datadup, c_donothing, c_donothing },
263/* CONSTDATA */ { NULL, NULL, NULL, NULL, c_datadup, NULL, c_donothing },
Willy Tarreauf0b38bf2010-06-06 13:22:23 +0200264};
Emeric Brun107ca302010-01-04 16:16:05 +0100265
Emeric Brun107ca302010-01-04 16:16:05 +0100266
Emeric Brun107ca302010-01-04 16:16:05 +0100267/*
268 * Parse a pattern expression configuration:
269 * fetch keyword followed by format conversion keywords.
270 * Returns a pointer on allocated pattern expression structure.
271 */
Emeric Brun485479d2010-09-23 18:02:19 +0200272struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err_size)
Emeric Brun107ca302010-01-04 16:16:05 +0100273{
274 const char *endw;
275 const char *end;
276 struct pattern_expr *expr;
277 struct pattern_fetch *fetch;
278 struct pattern_conv *conv;
279 unsigned long prev_type;
Emeric Brun485479d2010-09-23 18:02:19 +0200280 char *p;
Emeric Brun107ca302010-01-04 16:16:05 +0100281
Emeric Brun485479d2010-09-23 18:02:19 +0200282 snprintf(err, err_size, "memory error.");
283 if (!str[*idx]) {
284
285 snprintf(err, err_size, "missing fetch method.");
Emeric Brun107ca302010-01-04 16:16:05 +0100286 goto out_error;
Emeric Brun485479d2010-09-23 18:02:19 +0200287 }
Emeric Brun107ca302010-01-04 16:16:05 +0100288
289 end = str[*idx] + strlen(str[*idx]);
290 endw = strchr(str[*idx], '(');
291
292 if (!endw)
293 endw = end;
Emeric Brun485479d2010-09-23 18:02:19 +0200294 else if ((end-1)[0] != ')') {
295 p = my_strndup(str[*idx], endw - str[*idx]);
296 if (p) {
297 snprintf(err, err_size, "syntax error: missing ')' after keyword '%s'.", p);
298 free(p);
299 }
Emeric Brun107ca302010-01-04 16:16:05 +0100300 goto out_error;
Emeric Brun485479d2010-09-23 18:02:19 +0200301 }
Emeric Brun107ca302010-01-04 16:16:05 +0100302
303 fetch = find_pattern_fetch(str[*idx], endw - str[*idx]);
Emeric Brun485479d2010-09-23 18:02:19 +0200304 if (!fetch) {
305 p = my_strndup(str[*idx], endw - str[*idx]);
306 if (p) {
307 snprintf(err, err_size, "unknown fetch method '%s'.", p);
308 free(p);
309 }
Emeric Brun107ca302010-01-04 16:16:05 +0100310 goto out_error;
Emeric Brun485479d2010-09-23 18:02:19 +0200311 }
312 if (fetch->out_type >= PATTERN_TYPES) {
Emeric Brun107ca302010-01-04 16:16:05 +0100313
Emeric Brun485479d2010-09-23 18:02:19 +0200314 p = my_strndup(str[*idx], endw - str[*idx]);
315 if (p) {
316 snprintf(err, err_size, "returns type of fetch method '%s' is unknown.", p);
317 free(p);
318 }
Emeric Brun107ca302010-01-04 16:16:05 +0100319 goto out_error;
Emeric Brun485479d2010-09-23 18:02:19 +0200320 }
Emeric Brun107ca302010-01-04 16:16:05 +0100321
322 prev_type = fetch->out_type;
323 expr = calloc(1, sizeof(struct pattern_expr));
Emeric Brun485479d2010-09-23 18:02:19 +0200324 if (!expr)
325 goto out_error;
Emeric Brun107ca302010-01-04 16:16:05 +0100326
327 LIST_INIT(&(expr->conv_exprs));
328 expr->fetch = fetch;
329
330 if (end != endw) {
Emeric Brun485479d2010-09-23 18:02:19 +0200331 int i = end - endw - 2;
332
333 if (!fetch->parse_args) {
334 p = my_strndup(str[*idx], endw - str[*idx]);
335 if (p) {
336 snprintf(err, err_size, "fetch method '%s' does not support any args.", p);
337 free(p);
338 }
339 goto out_error;
340 }
341 p = my_strndup(endw + 1, i);
342 if (!p)
343 goto out_error;
344 i = fetch->parse_args(p, &expr->arg_p, &expr->arg_i);
345 free(p);
346 if (!i) {
347 p = my_strndup(str[*idx], endw - str[*idx]);
348 if (p) {
349 snprintf(err, err_size, "invalid args in fetch method '%s'.", p);
350 free(p);
351 }
352 goto out_error;
353 }
354 }
355 else if (fetch->parse_args) {
356 p = my_strndup(str[*idx], endw - str[*idx]);
357 if (p) {
358 snprintf(err, err_size, "missing args for fetch method '%s'.", p);
359 free(p);
360 }
361 goto out_error;
Emeric Brun107ca302010-01-04 16:16:05 +0100362 }
363
364 for (*idx += 1; *(str[*idx]); (*idx)++) {
365 struct pattern_conv_expr *conv_expr;
366
367 end = str[*idx] + strlen(str[*idx]);
368 endw = strchr(str[*idx], '(');
369
370 if (!endw)
371 endw = end;
Emeric Brun485479d2010-09-23 18:02:19 +0200372 else if ((end-1)[0] != ')') {
373 p = my_strndup(str[*idx], endw - str[*idx]);
374 if (p) {
375 snprintf(err, err_size, "syntax error, missing ')' after keyword '%s'.", p);
376 free(p);
377 }
Emeric Brun107ca302010-01-04 16:16:05 +0100378 goto out_error;
Emeric Brun485479d2010-09-23 18:02:19 +0200379 }
Emeric Brun107ca302010-01-04 16:16:05 +0100380
381 conv = find_pattern_conv(str[*idx], endw - str[*idx]);
382 if (!conv)
383 break;
384
385 if (conv->in_type >= PATTERN_TYPES ||
Emeric Brun485479d2010-09-23 18:02:19 +0200386 conv->out_type >= PATTERN_TYPES) {
387 p = my_strndup(str[*idx], endw - str[*idx]);
388 if (p) {
389 snprintf(err, err_size, "returns type of conv method '%s' is unknown.", p);
390 free(p);
391 }
Emeric Brun107ca302010-01-04 16:16:05 +0100392 goto out_error;
Emeric Brun485479d2010-09-23 18:02:19 +0200393 }
Emeric Brun107ca302010-01-04 16:16:05 +0100394
395 /* If impossible type conversion */
Emeric Brun485479d2010-09-23 18:02:19 +0200396 if (!pattern_casts[prev_type][conv->in_type]) {
397 p = my_strndup(str[*idx], endw - str[*idx]);
398 if (p) {
399 snprintf(err, err_size, "conv method '%s' cannot be applied.", p);
400 free(p);
401 }
Emeric Brun107ca302010-01-04 16:16:05 +0100402 goto out_error;
Emeric Brun485479d2010-09-23 18:02:19 +0200403 }
Emeric Brun107ca302010-01-04 16:16:05 +0100404
405 prev_type = conv->out_type;
406 conv_expr = calloc(1, sizeof(struct pattern_conv_expr));
Emeric Brun485479d2010-09-23 18:02:19 +0200407 if (!conv_expr)
408 goto out_error;
Emeric Brun107ca302010-01-04 16:16:05 +0100409
410 LIST_ADDQ(&(expr->conv_exprs), &(conv_expr->list));
411 conv_expr->conv = conv;
412
413 if (end != endw) {
Willy Tarreau9e92d322010-01-26 17:58:06 +0100414 int i = end - endw - 2;
Emeric Brun485479d2010-09-23 18:02:19 +0200415
416 if (!conv->parse_args) {
417 p = my_strndup(str[*idx], endw - str[*idx]);
418
419 if (p) {
420 snprintf(err, err_size, "conv method '%s' does not support any args.", p);
421 free(p);
422 }
423 goto out_error;
424 }
Willy Tarreau9e92d322010-01-26 17:58:06 +0100425
Emeric Brun485479d2010-09-23 18:02:19 +0200426 p = my_strndup(endw + 1, i);
427 if (!p)
428 goto out_error;
429 i = conv->parse_args(p, &conv_expr->arg_p, &conv_expr->arg_i);
430 free(p);
431 if (!i) {
432 p = my_strndup(str[*idx], endw - str[*idx]);
433 if (p) {
434 snprintf(err, err_size, "invalid args in conv method '%s'.", p);
435 free(p);
436 }
437 goto out_error;
438 }
439 }
440 else if (conv->parse_args) {
441 p = my_strndup(str[*idx], endw - str[*idx]);
442 if (p) {
443 snprintf(err, err_size, "missing args for conv method '%s'.", p);
Willy Tarreau9e92d322010-01-26 17:58:06 +0100444 free(p);
Willy Tarreau9e92d322010-01-26 17:58:06 +0100445 }
Emeric Brun485479d2010-09-23 18:02:19 +0200446 goto out_error;
Emeric Brun107ca302010-01-04 16:16:05 +0100447 }
Emeric Brun485479d2010-09-23 18:02:19 +0200448
Emeric Brun107ca302010-01-04 16:16:05 +0100449 }
Emeric Brun485479d2010-09-23 18:02:19 +0200450
Emeric Brun107ca302010-01-04 16:16:05 +0100451 return expr;
452
453out_error:
454 /* TODO: prune_pattern_expr(expr); */
455 return NULL;
456}
457
458/*
459 * Process a fetch + format conversion of defined by the pattern expression <expr>
460 * on request or response considering the <dir> parameter.
461 * Returns a pointer on a typed pattern structure containing the result or NULL if
462 * pattern is not found or when format conversion failed.
463 * If <p> is not null, function returns results in structure pointed by <p>.
464 * If <p> is null, functions returns a pointer on a static pattern structure.
465 */
466struct pattern *pattern_process(struct proxy *px, struct session *l4, void *l7, int dir,
467 struct pattern_expr *expr, struct pattern *p)
468{
469 struct pattern_conv_expr *conv_expr;
470
471 if (p == NULL)
472 p = &spattern;
473
Emeric Brun485479d2010-09-23 18:02:19 +0200474 if (!expr->fetch->process(px, l4, l7, dir, expr->arg_p, expr->arg_i, &p->data))
Emeric Brun107ca302010-01-04 16:16:05 +0100475 return NULL;
476
477 p->type = expr->fetch->out_type;
478
479 list_for_each_entry(conv_expr, &expr->conv_exprs, list) {
480 if (!pattern_casts[p->type][conv_expr->conv->in_type](&p->data))
481 return NULL;
482
483 p->type = conv_expr->conv->in_type;
Willy Tarreau1a51b632010-01-26 17:17:56 +0100484 if (!conv_expr->conv->process(conv_expr->arg_p, conv_expr->arg_i, &p->data))
Emeric Brun107ca302010-01-04 16:16:05 +0100485 return NULL;
486
487 p->type = conv_expr->conv->out_type;
488 }
489 return p;
490}
491
Emeric Brun485479d2010-09-23 18:02:19 +0200492/* Converts an argument string mask to a pattern_arg type IP.
493 * Returns non-zero in case of success, 0 on error.
Willy Tarreaud31d6eb2010-01-26 18:01:41 +0100494 */
Emeric Brun485479d2010-09-23 18:02:19 +0200495int pattern_arg_ipmask(const char *arg_str, struct pattern_arg **arg_p, int *arg_i)
Willy Tarreaud31d6eb2010-01-26 18:01:41 +0100496{
Emeric Brun485479d2010-09-23 18:02:19 +0200497 *arg_i = 1;
498 *arg_p = calloc(1, *arg_i*sizeof(struct pattern_arg));
499 (*arg_p)->type = PATTERN_ARG_TYPE_IP;
Willy Tarreaud31d6eb2010-01-26 18:01:41 +0100500
Emeric Brun485479d2010-09-23 18:02:19 +0200501 if (!str2mask(arg_str, &(*arg_p)->data.ip))
Willy Tarreaud31d6eb2010-01-26 18:01:41 +0100502 return 0;
503
Willy Tarreaud31d6eb2010-01-26 18:01:41 +0100504 return 1;
505}
506
Emeric Brun485479d2010-09-23 18:02:19 +0200507
508/* Converts an argument string to a pattern_arg type STRING.
509 * Returns non-zero in case of success, 0 on error.
510 */
511int pattern_arg_str(const char *arg_str, struct pattern_arg **arg_p, int *arg_i)
512{
513 *arg_i = 1;
514 *arg_p = calloc(1, *arg_i*sizeof(struct pattern_arg));
515 (*arg_p)->type = PATTERN_ARG_TYPE_STRING;
516 (*arg_p)->data.str.str = strdup(arg_str);
517 (*arg_p)->data.str.len = strlen(arg_str);
518
519
520 return 1;
521}
522
523
Emeric Brun107ca302010-01-04 16:16:05 +0100524/*****************************************************************/
525/* Pattern format convert functions */
526/*****************************************************************/
527
Emeric Brun485479d2010-09-23 18:02:19 +0200528static int pattern_conv_str2lower(const struct pattern_arg *arg_p, int arg_i, union pattern_data *data)
Emeric Brun107ca302010-01-04 16:16:05 +0100529{
530 int i;
531
Emeric Brun485479d2010-09-23 18:02:19 +0200532 if (!data->str.size)
533 return 0;
534
Emeric Brun107ca302010-01-04 16:16:05 +0100535 for (i = 0; i < data->str.len; i++) {
536 if ((data->str.str[i] >= 'A') && (data->str.str[i] <= 'Z'))
537 data->str.str[i] += 'a' - 'A';
538 }
539 return 1;
540}
541
Emeric Brun485479d2010-09-23 18:02:19 +0200542static int pattern_conv_str2upper(const struct pattern_arg *arg_p, int arg_i, union pattern_data *data)
Emeric Brun107ca302010-01-04 16:16:05 +0100543{
544 int i;
545
Emeric Brun485479d2010-09-23 18:02:19 +0200546 if (!data->str.size)
547 return 0;
548
Emeric Brun107ca302010-01-04 16:16:05 +0100549 for (i = 0; i < data->str.len; i++) {
550 if ((data->str.str[i] >= 'a') && (data->str.str[i] <= 'z'))
551 data->str.str[i] += 'A' - 'a';
552 }
553 return 1;
554}
555
Willy Tarreaud31d6eb2010-01-26 18:01:41 +0100556/* takes the netmask in arg_i */
Emeric Brun485479d2010-09-23 18:02:19 +0200557static int pattern_conv_ipmask(const struct pattern_arg *arg_p, int arg_i, union pattern_data *data)
Willy Tarreaud31d6eb2010-01-26 18:01:41 +0100558{
Simon Hormand281eed2011-08-13 08:03:49 +0900559 data->ip.s_addr &= arg_p->data.ip.s_addr;
Willy Tarreaud31d6eb2010-01-26 18:01:41 +0100560 return 1;
561}
562
Emeric Brun107ca302010-01-04 16:16:05 +0100563/* Note: must not be declared <const> as its list will be overwritten */
564static struct pattern_conv_kw_list pattern_conv_kws = {{ },{
Emeric Brun485479d2010-09-23 18:02:19 +0200565 { "upper", pattern_conv_str2upper, NULL, PATTERN_TYPE_STRING, PATTERN_TYPE_STRING },
566 { "lower", pattern_conv_str2lower, NULL, PATTERN_TYPE_STRING, PATTERN_TYPE_STRING },
567 { "ipmask", pattern_conv_ipmask, pattern_arg_ipmask, PATTERN_TYPE_IP, PATTERN_TYPE_IP },
568 { NULL, NULL, NULL, 0, 0 },
Emeric Brun107ca302010-01-04 16:16:05 +0100569}};
570
571__attribute__((constructor))
572static void __pattern_init(void)
573{
574 /* register pattern format convert keywords */
575 pattern_register_convs(&pattern_conv_kws);
576}