aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dfilter/dfunctions.c
blob: 22af385f1fbc0325986c608d75da236c3e314fd0 (plain)
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
/*
 * Wireshark - Network traffic analyzer
 *
 * Copyright 2006 Gilbert Ramirez <gram@alumni.rice.edu>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"
#define WS_LOG_DOMAIN LOG_DOMAIN_DFILTER

#include <wireshark.h>

#include "dfilter-int.h"
#include "dfunctions.h"
#include "dfilter-plugin.h"
#include "sttype-field.h"
#include "sttype-pointer.h"
#include "semcheck.h"

#include <string.h>

#include <ftypes/ftypes.h>
#include <epan/exceptions.h>
#include <wsutil/ws_assert.h>


static GHashTable *registered_functions = NULL;

static GPtrArray *registered_names = NULL;

/* Convert an FT_STRING using a callback function */
static bool
string_walk(GSList *stack, uint32_t arg_count _U_, df_cell_t *retval, char(*conv_func)(char))
{
    GPtrArray   *arg1;
    fvalue_t    *arg_fvalue;
    fvalue_t    *new_ft_string;
    const wmem_strbuf_t *src;
    wmem_strbuf_t       *dst;

    ws_assert(arg_count == 1);
    arg1 = stack->data;
    if (arg1 == NULL)
        return false;

    for (unsigned i = 0; i < arg1->len; i++) {
        arg_fvalue = arg1->pdata[i];
        /* XXX - it would be nice to handle FT_TVBUFF, too */
        if (FT_IS_STRING(fvalue_type_ftenum(arg_fvalue))) {
            src = fvalue_get_strbuf(arg_fvalue);
            dst = wmem_strbuf_new_sized(NULL, src->len);
            for (size_t j = 0; j < src->len; j++) {
                    wmem_strbuf_append_c(dst, conv_func(src->str[j]));
            }
            new_ft_string = fvalue_new(FT_STRING);
            fvalue_set_strbuf(new_ft_string, dst);
            df_cell_append(retval, new_ft_string);
        }
    }

    return true;
}

/* dfilter function: lower() */
static bool
df_func_lower(GSList *stack, uint32_t arg_count, df_cell_t *retval)
{
    return string_walk(stack, arg_count, retval, g_ascii_tolower);
}

/* dfilter function: upper() */
static bool
df_func_upper(GSList *stack, uint32_t arg_count, df_cell_t *retval)
{
    return string_walk(stack, arg_count, retval, g_ascii_toupper);
}

/* dfilter function: count() */
static bool
df_func_count(GSList *stack, uint32_t arg_count _U_, df_cell_t *retval)
{
    GPtrArray *arg1;
    fvalue_t *ft_ret;
    uint32_t  num_items;

    ws_assert(arg_count == 1);
    arg1 = stack->data;
    if (arg1 == NULL)
        return false;

    num_items = arg1->len;
    ft_ret = fvalue_new(FT_UINT32);
    fvalue_set_uinteger(ft_ret, num_items);
    df_cell_append(retval, ft_ret);

    return true;
}

/* dfilter function: string() */
static bool
df_func_string(GSList *stack, uint32_t arg_count _U_, df_cell_t *retval)
{
    GPtrArray *arg1;
    fvalue_t *arg_fvalue;
    fvalue_t *new_ft_string;
    char     *s;

    ws_assert(arg_count == 1);
    arg1 = stack->data;
    if (arg1 == NULL)
        return false;

    for (unsigned i = 0; i < arg1->len; i++) {
        arg_fvalue = arg1->pdata[i];
        switch (fvalue_type_ftenum(arg_fvalue))
        {
        case FT_UINT8:
        case FT_UINT16:
        case FT_UINT24:
        case FT_UINT32:
        case FT_UINT40:
        case FT_UINT48:
        case FT_UINT56:
        case FT_UINT64:
        case FT_INT8:
        case FT_INT16:
        case FT_INT32:
        case FT_INT40:
        case FT_INT48:
        case FT_INT56:
        case FT_INT64:
        case FT_IPv4:
        case FT_IPv6:
        case FT_FLOAT:
        case FT_DOUBLE:
        case FT_ETHER:
        case FT_FRAMENUM:
        case FT_AX25:
        case FT_IPXNET:
        case FT_GUID:
        case FT_OID:
        case FT_EUI64:
        case FT_VINES:
        case FT_REL_OID:
        case FT_SYSTEM_ID:
        case FT_FCWWN:
        case FT_IEEE_11073_SFLOAT:
        case FT_IEEE_11073_FLOAT:
            s = fvalue_to_string_repr(NULL, arg_fvalue, FTREPR_DFILTER, BASE_NONE);
            /* Ensure we have an allocated string here */
            if (!s)
                s = wmem_strdup(NULL, "");
            break;
        default:
            return true;
        }

        new_ft_string = fvalue_new(FT_STRING);
        fvalue_set_string(new_ft_string, s);
        wmem_free(NULL, s);
        df_cell_append(retval, new_ft_string);
    }

    return true;
}

/* dfilter functions: dec(), hex(), */
static bool
df_func_base(GSList *stack, uint32_t arg_count _U_, df_cell_t *retval, int base)
{
    GPtrArray *arg1;
    fvalue_t *arg_fvalue;
    fvalue_t *new_ft_string;
    char     *s;

    ws_assert(arg_count == 1);
    arg1 = stack->data;
    if (arg1 == NULL)
        return false;

    for (unsigned i = 0; i < arg1->len; i++) {
        arg_fvalue = arg1->pdata[i];

        if (FT_IS_UINT(fvalue_type_ftenum(arg_fvalue))) {
            s = fvalue_to_string_repr(NULL, arg_fvalue, FTREPR_DFILTER, base);
            /* Ensure we have an allocated string here */
            if (!s)
                s = wmem_strdup(NULL, "");
        } else {
            /* XXX - We have, unfortunately, some field abbreviations which are
             * re-used with incompatible types, some of which support different
             * bases and some which don't.
             */
            s = wmem_strdup(NULL, "");
        }

        new_ft_string = fvalue_new(FT_STRING);
        fvalue_set_string(new_ft_string, s);
        wmem_free(NULL, s);
        df_cell_append(retval, new_ft_string);
    }

    return true;
}

static bool
df_func_hex(GSList *stack, uint32_t arg_count _U_, df_cell_t *retval)
{
    return df_func_base(stack, arg_count, retval, BASE_HEX);
}

static bool
df_func_dec(GSList *stack, uint32_t arg_count _U_, df_cell_t *retval)
{
    return df_func_base(stack, arg_count, retval, BASE_DEC);
}

#if 0
// XXX - BASE_OCT isn't handled by fvalue_to_string_repr; it probably
// should at least for FTREPR_DISPLAY (the filter language doesn't
// support it due to possible notation confusion, I assume.)
// Add that first before offering it.
static bool
df_func_oct(GSList *stack, uint32_t arg_count _U_, df_cell_t *retval)
{
    return df_func_base(stack, arg_count, retval, BASE_OCT);
}
#endif

static bool
df_func_compare(GSList *stack, uint32_t arg_count, df_cell_t *retval,
                    bool (*fv_cmp)(const fvalue_t *a, const fvalue_t *b))
{
    fvalue_t *fv_ret = NULL;
    GSList   *args;
    GPtrArray *arg1;
    fvalue_t *arg_fvalue;
    uint32_t i;

    for (args = stack, i = 0; i < arg_count; args = args->next, i++) {
        arg1 = args->data;
        if (arg1 != NULL) {
            for (unsigned j = 0; j < arg1->len; j++) {
                arg_fvalue = arg1->pdata[j];
                if (fv_ret == NULL || fv_cmp(arg_fvalue, fv_ret)) {
                    fv_ret = arg_fvalue;
                }
            }
        }
    }

    if (fv_ret == NULL)
        return false;

    df_cell_append(retval, fvalue_dup(fv_ret));

    return true;
}

/* Find maximum value. */
static bool
df_func_max(GSList *stack, uint32_t arg_count, df_cell_t *retval)
{
    return df_func_compare(stack, arg_count, retval, fvalue_gt);
}

/* Find minimum value. */
static bool
df_func_min(GSList *stack, uint32_t arg_count, df_cell_t *retval)
{
    return df_func_compare(stack, arg_count, retval, fvalue_lt);
}

static bool
df_func_abs(GSList *stack, uint32_t arg_count _U_, df_cell_t *retval)
{
    GPtrArray *arg1;
    fvalue_t *fv_arg, *new_fv;
    char     *err_msg = NULL;

    ws_assert(arg_count == 1);
    arg1 = stack->data;
    if (arg1 == NULL)
        return false;

    for (unsigned i = 0; i < arg1->len; i++) {
        fv_arg = arg1->pdata[i];
        if (fvalue_is_negative(fv_arg)) {
            new_fv = fvalue_unary_minus(fv_arg, &err_msg);
            if (new_fv == NULL) {
                ws_debug("abs: %s", err_msg);
                g_free(err_msg);
                err_msg = NULL;
            }
        }
        else {
            new_fv = fvalue_dup(fv_arg);
        }
        df_cell_append(retval, new_fv);
    }

    return !df_cell_is_empty(retval);
}

ftenum_t
df_semcheck_param(dfwork_t *dfw, const char *func_name _U_, ftenum_t logical_ftype,
                            stnode_t *param, df_loc_t func_loc _U_)
{
    ftenum_t ftype = FT_NONE;

    resolve_unparsed(dfw, param, false);

    switch (stnode_type_id(param)) {
        case STTYPE_ARITHMETIC:
            ftype = check_arithmetic(dfw, param, logical_ftype);
            break;

        case STTYPE_LITERAL:
            dfilter_fvalue_from_literal(dfw, logical_ftype, param, false, NULL);
            ftype = sttype_pointer_ftenum(param);
            break;

        case STTYPE_STRING:
            dfilter_fvalue_from_string(dfw, logical_ftype, param, NULL);
            ftype = sttype_pointer_ftenum(param);
            break;

        case STTYPE_CHARCONST:
            dfilter_fvalue_from_charconst(dfw, logical_ftype, param);
            ftype = sttype_pointer_ftenum(param);
            break;

        case STTYPE_NUMBER:
            dfilter_fvalue_from_number(dfw, logical_ftype, param);
            ftype = sttype_pointer_ftenum(param);
            break;

        case STTYPE_FUNCTION:
            ftype = check_function(dfw, param, logical_ftype);
            break;

        case STTYPE_FIELD:
            dfw->field_count++;
            /* fall-through */
        case STTYPE_REFERENCE:
            ftype = sttype_field_ftenum(param);
            break;

        case STTYPE_SLICE:
            ftype = check_slice(dfw, param, logical_ftype);
            break;

        case STTYPE_UNPARSED:
        case STTYPE_TEST:
        case STTYPE_FVALUE:
        case STTYPE_PCRE:
        case STTYPE_SET:
        case STTYPE_UNINITIALIZED:
        case STTYPE_NUM_TYPES:
            ASSERT_STTYPE_NOT_REACHED(stnode_type_id(param));
    }

    return ftype;
}

/* For upper() and lower() checks that the parameter passed to
 * it is an FT_STRING */
static ftenum_t
ul_semcheck_is_string(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype _U_,
                            GSList *param_list, df_loc_t func_loc _U_)
{
    ws_assert(g_slist_length(param_list) == 1);
    stnode_t *param = param_list->data;
    ftenum_t ftype;

    resolve_unparsed(dfw, param, true);

    ftype = df_semcheck_param(dfw, func_name, logical_ftype, param, func_loc);
    if (!FT_IS_STRING(ftype)) {
        dfunc_fail(dfw, param, "Only string type fields can be used as parameter for %s()", func_name);
    }
    return FT_STRING;
}

static ftenum_t
ul_semcheck_is_field(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype _U_,
                            GSList *param_list, df_loc_t func_loc _U_)
{
    ws_assert(g_slist_length(param_list) == 1);
    stnode_t *param = param_list->data;

    resolve_unparsed(dfw, param, true);

    if (stnode_type_id(param) != STTYPE_FIELD) {
        dfunc_fail(dfw, param, "Only fields can be used as parameter for %s()", func_name);
    }
    df_semcheck_param(dfw, func_name, logical_ftype, param, func_loc);
    return FT_UINT32;
}

static ftenum_t
ul_semcheck_can_length(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype,
                            GSList *param_list, df_loc_t func_loc)
{
    ws_assert(g_slist_length(param_list) == 1);
    stnode_t *param = param_list->data;
    ftenum_t ftype;

    ftype = df_semcheck_param(dfw, func_name, logical_ftype, param, func_loc);
    if (!ftype_can_length(ftype)) {
        dfunc_fail(dfw, param, "Argument does not support the %s() function", func_name);
    }
    return FT_UINT32;
}

static ftenum_t
ul_semcheck_string(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype _U_,
                            GSList *param_list, df_loc_t func_loc _U_)
{
    header_field_info *hfinfo;

    ws_assert(g_slist_length(param_list) == 1);
    stnode_t *param = param_list->data;

    resolve_unparsed(dfw, param, true);

    if (stnode_type_id(param) == STTYPE_FIELD) {
        dfw->field_count++;
        hfinfo = sttype_field_hfinfo(param);
        switch (hfinfo->type) {
            case FT_UINT8:
            case FT_UINT16:
            case FT_UINT24:
            case FT_UINT32:
            case FT_UINT40:
            case FT_UINT48:
            case FT_UINT56:
            case FT_UINT64:
            case FT_INT8:
            case FT_INT16:
            case FT_INT32:
            case FT_INT40:
            case FT_INT48:
            case FT_INT56:
            case FT_INT64:
            case FT_IPv4:
            case FT_IPv6:
            case FT_FLOAT:
            case FT_DOUBLE:
            case FT_ETHER:
            case FT_FRAMENUM:
            case FT_AX25:
            case FT_IPXNET:
            case FT_GUID:
            case FT_OID:
            case FT_EUI64:
            case FT_VINES:
            case FT_REL_OID:
            case FT_SYSTEM_ID:
            case FT_FCWWN:
            case FT_IEEE_11073_SFLOAT:
            case FT_IEEE_11073_FLOAT:
                return FT_STRING;
            default:
                break;
        }
        dfunc_fail(dfw, param, "String conversion for field \"%s\" is not supported", hfinfo->abbrev);
    }
    dfunc_fail(dfw, param, "Only fields can be used as parameter for %s()", func_name);
}

static ftenum_t
ul_semcheck_base(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype _U_,
                            GSList *param_list, df_loc_t func_loc _U_)
{
    header_field_info *hfinfo;

    ws_assert(g_slist_length(param_list) == 1);
    stnode_t *param = param_list->data;

    resolve_unparsed(dfw, param, true);

    if (stnode_type_id(param) == STTYPE_FIELD) {
        dfw->field_count++;
        hfinfo = sttype_field_hfinfo(param);
        /* FT_CHAR also supports BASE_, but for what sort of escaped
         * values to use for non-printable ASCII. BASE_HEX uses hex,
         * all other bases will use octal.
         * That's a little confusing, so don't support it for now.
         * More useful might be to display all possible values as
         * HEX or DEC, i.e. convert to a FT_UINT8 first. */
        if (FT_IS_UINT(hfinfo->type)) {
            return FT_STRING;
        }
        dfunc_fail(dfw, param, "Base conversion for field \"%s\" is not supported", hfinfo->abbrev);
    }
    dfunc_fail(dfw, param, "Only fields can be used as parameter for %s()", func_name);
}

static ftenum_t
ul_semcheck_value_string(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype _U_,
                            GSList *param_list, df_loc_t func_loc _U_)
{
    header_field_info *hfinfo;

    ws_assert(g_slist_length(param_list) == 1);
    stnode_t *param = param_list->data;

    resolve_unparsed(dfw, param, true);

    if (stnode_type_id(param) == STTYPE_FIELD) {
        dfw->field_count++;
        hfinfo = sttype_field_hfinfo(param);
        if (hfinfo->strings != NULL && hfinfo->type != FT_FRAMENUM && hfinfo->type != FT_PROTOCOL) {
            sttype_field_set_value_string(param, true);
            return FT_STRING;
        }
        dfunc_fail(dfw, param, "Field \"%s\" does not have a value string.",
				hfinfo->abbrev);
    }
    dfunc_fail(dfw, param, "Only fields can be used as parameter for %s()", func_name);
}

/* Check arguments are all the same type and they can be compared. */
static ftenum_t
ul_semcheck_compare(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype,
                        GSList *param_list, df_loc_t func_loc)
{
    stnode_t *param;
    ftenum_t ftype;
    GSList *l;

    for (l = param_list; l != NULL; l = l->next) {
        param = l->data;
        ftype = df_semcheck_param(dfw, func_name, logical_ftype, param, func_loc);

        if (!compatible_ftypes(ftype, logical_ftype)) {
            dfunc_fail(dfw, param, "Arguments to '%s' must be of compatible type (expected %s, got %s)",
                                        func_name, ftype_pretty_name(logical_ftype), ftype_pretty_name(ftype));
        }
        if (!ftype_can_cmp(ftype)) {
            dfunc_fail(dfw, param, "Argument '%s' to '%s' cannot be ordered",
                                    stnode_todisplay(param), func_name);
        }
    }

    return logical_ftype;
}

static ftenum_t
ul_semcheck_absolute_value(dfwork_t *dfw, const char *func_name, ftenum_t logical_ftype,
                        GSList *param_list, df_loc_t func_loc)
{
    ws_assert(g_slist_length(param_list) == 1);
    stnode_t *param = param_list->data;
    ftenum_t ftype;

    ftype = df_semcheck_param(dfw, func_name, logical_ftype, param, func_loc);
    if (!ftype_can_is_negative(ftype) || !ftype_can_unary_minus(ftype)) {
        dfunc_fail(dfw, param, "Argument cannot be negated");
    }
    return ftype;
}

/* The table of all display-filter functions */
static df_func_def_t
df_functions[] = {
    { "lower",  df_func_lower,  1, 1, FT_STRING, ul_semcheck_is_string },
    { "upper",  df_func_upper,  1, 1, FT_STRING, ul_semcheck_is_string },
    /* Length function is implemented as a DFVM instruction. */
    { "len",    NULL,           1, 1, FT_UINT32, ul_semcheck_can_length },
    { "count",  df_func_count,  1, 1, FT_UINT32, ul_semcheck_is_field },
    { "string", df_func_string, 1, 1, FT_STRING, ul_semcheck_string },
    { "dec",    df_func_dec,    1, 1, FT_STRING, ul_semcheck_base },
    { "hex",    df_func_hex,    1, 1, FT_STRING, ul_semcheck_base },
    //{ "oct",    df_func_oct,    1, 1, FT_STRING, ul_semcheck_base },
    /* VALUE STRING function is implemented as a DFVM instruction. */
    { "vals",   NULL,           1, 1, FT_STRING, ul_semcheck_value_string },
    { "max",    df_func_max,    1, 0, FT_NONE, ul_semcheck_compare },
    { "min",    df_func_min,    1, 0, FT_NONE, ul_semcheck_compare },
    { "abs",    df_func_abs,    1, 1, FT_NONE, ul_semcheck_absolute_value },
    { NULL, NULL, 0, 0, FT_NONE, NULL }
};

/* Returns NULL for success. */
static const char *
check_valid_func_name(const char *name)
{
    if (!g_ascii_isalpha(name[0]) && name[0] != '_') {
        return "first character must be a letter or underscore";
    }
    for (int i = 1; name[i] != '\0'; i++) {
        if (!g_ascii_isalnum(name[0]) && name[0] != '_') {
            return "function names must be alphanumeric plus underscore";
        }
    }
    return NULL;
}

void
df_func_init(void)
{
    df_func_def_t *func;

    registered_functions = g_hash_table_new(g_str_hash, g_str_equal);
    registered_names = g_ptr_array_new();

    /* Register built-in functions. */
    for (func = df_functions; func->name != NULL; func++) {
        df_func_register(func);
    }
}

bool
df_func_register(df_func_def_t *func)
{
    ws_assert(registered_functions);
    ws_assert(registered_names);
    const char *err;
    if ((err = check_valid_func_name(func->name)) != NULL) {
        ws_critical("Function name \"%s\" is invalid: %s",
                    func->name, err);
        return false;
    }
    if (g_hash_table_contains(registered_functions, func->name)) {
        ws_critical("Trying to register display filter function \"%s\" but "
                    "it already exists", func->name);
        return false;
    }

    g_ptr_array_add(registered_names, (gpointer)func->name);
    return g_hash_table_insert(registered_functions, (gpointer)func->name, func);
}

bool
df_func_deregister(df_func_def_t *func)
{
    ws_assert(registered_functions);
    df_func_def_t *value;

    value = g_hash_table_lookup(registered_functions, func->name);
    if (value != func) {
        ws_critical("Trying to deregister display filter function name \"%s\" but "
                    "it doesn't match the existing function", func->name);
        return false;
    }

    g_ptr_array_remove_fast(registered_names, (void *)func->name);
    return g_hash_table_remove(registered_functions, func->name);
}

/* Lookup a display filter function record by name */
df_func_def_t*
df_func_lookup(const char *name)
{
    return g_hash_table_lookup(registered_functions, name);
}

GPtrArray *
df_func_name_list(void)
{
    return g_ptr_array_ref(registered_names);
}

void
df_func_cleanup(void)
{
    g_hash_table_destroy(registered_functions);
    registered_functions = NULL;
    g_ptr_array_unref(registered_names);
    registered_names = NULL;
}

/*
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * vi: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */