diff options
author | Michal Labedzki <michal.labedzki@tieto.com> | 2014-12-09 18:55:44 +0100 |
---|---|---|
committer | Michal Labedzki <michal.labedzki@tieto.com> | 2014-12-18 11:02:37 +0000 |
commit | ee4a7f2c5d22fa240beebe5f3cbf610cc3e28bc9 (patch) | |
tree | 217390a5946e037519711ccdece4a54f9091f01e /epan | |
parent | a73b89bec1f5a33e45b2a47c66f3200059d56db8 (diff) |
DisplayFilter: Check also another fields with the same name
This adds possibility to have two fields with the same abbrev name
but different type, for example FT_ETHER and FT_STRING.
That allows to compare each one to find a valid field.
Change-Id: I8b2a1708ac9648b7a4289777c72a0f3b18f3d8f8
Reviewed-on: https://code.wireshark.org/review/5702
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dfilter/semcheck.c | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c index 8e1d9b5bf6..39174e4e7c 100644 --- a/epan/dfilter/semcheck.c +++ b/epan/dfilter/semcheck.c @@ -593,49 +593,34 @@ check_relation_LHS_FIELD(const char *relation_string, FtypeCanFunc can_func, THROW(TypeError); } } - else if (type2 == STTYPE_STRING) { + else if (type2 == STTYPE_STRING || type2 == STTYPE_UNPARSED) { s = (char *)stnode_data(st_arg2); if (strcmp(relation_string, "matches") == 0) { /* Convert to a FT_PCRE */ - fvalue = fvalue_from_string(FT_PCRE, s, dfilter_fail); + if (type2 == STTYPE_STRING) + fvalue = fvalue_from_string(FT_PCRE, s, dfilter_fail); + else + fvalue = fvalue_from_unparsed(FT_PCRE, s, FALSE, dfilter_fail); } else { - fvalue = fvalue_from_string(ftype1, s, dfilter_fail); + /* Skip incompatible fields */ + while (hfinfo1->same_name_prev_id != -1 && + ((type2 == STTYPE_STRING && ftype1 != FT_STRING && ftype1!= FT_STRINGZ) || + (type2 != STTYPE_STRING && (ftype1 == FT_STRING || ftype1== FT_STRINGZ)))) { + hfinfo1 = proto_registrar_get_nth(hfinfo1->same_name_prev_id); + ftype1 = hfinfo1->type; + } + + if (type2 == STTYPE_STRING) + fvalue = fvalue_from_string(ftype1, s, dfilter_fail); + else + fvalue = fvalue_from_unparsed(ftype1, s, allow_partial_value, dfilter_fail); + if (!fvalue) { /* check value_string */ fvalue = mk_fvalue_from_val_string(hfinfo1, s); } } - if (!fvalue) { - THROW(TypeError); - } - new_st = stnode_new(STTYPE_FVALUE, fvalue); - sttype_test_set2_args(st_node, st_arg1, new_st); - stnode_free(st_arg2); - } - else if (type2 == STTYPE_UNPARSED) { - s = (char *)stnode_data(st_arg2); - if (strcmp(relation_string, "matches") == 0) { - /* Convert to a FT_PCRE */ - fvalue = fvalue_from_unparsed(FT_PCRE, s, FALSE, dfilter_fail); - } else { - do { - fvalue = fvalue_from_unparsed(ftype1, s, allow_partial_value, dfilter_fail); - if (!fvalue) { - /* check value_string */ - fvalue = mk_fvalue_from_val_string(hfinfo1, s); - } - if (!fvalue) { - /* Try another field with the same name */ - if (hfinfo1->same_name_prev_id != -1) { - hfinfo1 = proto_registrar_get_nth(hfinfo1->same_name_prev_id); - ftype1 = hfinfo1->type; - } else { - break; - } - } - } while (!fvalue); - } if (!fvalue) { THROW(TypeError); } |