diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2001-02-01 20:21:25 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2001-02-01 20:21:25 +0000 |
commit | 8f1fff2e6a5c114c6beafd2983afb55acd3d66ae (patch) | |
tree | e33c08662c708dcfe71591897fe6ffab53bce135 /epan/ftypes/ftype-ipv4.c | |
parent | 07a925ef8b0568a2c5b8098d5734364a40eeb2f6 (diff) |
Create a more modular type system for the FT_* types. Put them
into epan/ftypes.
Re-write display filter routines using Lemon parser instead of yacc.
Besides using a different tool, the new grammar is much simpler, while
the display filter engine itself is more powerful and more easily extended.
Add dftest executable, to test display filter "bytecode" generation.
Add option to "configure" to build dftest or randpkt, both of which are not
built by default.
Implement Ed Warnicke's ideas about dranges in the new display filter and
ftype code.
Remove type FT_TEXT_ONLY in favor of FT_NONE, and have protocols registered
as FT_PROTOCOL. Thus, FT_NONE is used only for simple labels in the proto tree,
while FT_PROTOCOL is used for protocols. This was necessary for being
able to make byte slices (ranges) out of protocols, like "frame[0:3]"
Win32 Makefile.nmake's will be added tonight.
svn path=/trunk/; revision=2967
Diffstat (limited to 'epan/ftypes/ftype-ipv4.c')
-rw-r--r-- | epan/ftypes/ftype-ipv4.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c new file mode 100644 index 0000000000..eae5677a25 --- /dev/null +++ b/epan/ftypes/ftype-ipv4.c @@ -0,0 +1,114 @@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <ftypes-int.h> +#include "ipv4.h" +#include "resolv.h" + +static void +ftype_from_tvbuff(field_info *fi, tvbuff_t *tvb, int start, int length, + gboolean little_endian) +{ + /* XXX */ + g_assert_not_reached(); +} + + + +static void +set_integer(fvalue_t *fv, guint32 value) +{ + ipv4_addr_set_net_order_addr(&(fv->value.ipv4), value); + ipv4_addr_set_netmask_bits(&(fv->value.ipv4), 32); +} + +static gpointer +value_get(fvalue_t *fv) +{ + return &(fv->value.ipv4); +} + +static gboolean +val_from_string(fvalue_t *fv, char *s, LogFunc log) +{ + guint32 addr; + + if (!get_host_ipaddr(s, &addr)) { + log("\"%s\" is not a valid hostname or IPv4 address.", s); + return FALSE; + } + ipv4_addr_set_host_order_addr(&(fv->value.ipv4), addr); + /*ipv4_addr_set_netmask_bits(&node->value.ipv4, nmask_bits);*/ + ipv4_addr_set_netmask_bits(&(fv->value.ipv4), 32); + return TRUE; +} + +static gboolean +cmp_eq(fvalue_t *a, fvalue_t *b) +{ + return ipv4_addr_eq(&a->value.ipv4, &b->value.ipv4); +} + +static gboolean +cmp_ne(fvalue_t *a, fvalue_t *b) +{ + return ipv4_addr_ne(&a->value.ipv4, &b->value.ipv4); +} + +static gboolean +cmp_gt(fvalue_t *a, fvalue_t *b) +{ + return ipv4_addr_gt(&a->value.ipv4, &b->value.ipv4); +} + +static gboolean +cmp_ge(fvalue_t *a, fvalue_t *b) +{ + return ipv4_addr_ge(&a->value.ipv4, &b->value.ipv4); +} + +static gboolean +cmp_lt(fvalue_t *a, fvalue_t *b) +{ + return ipv4_addr_lt(&a->value.ipv4, &b->value.ipv4); +} + +static gboolean +cmp_le(fvalue_t *a, fvalue_t *b) +{ + return ipv4_addr_le(&a->value.ipv4, &b->value.ipv4); +} + +void +ftype_register_ipv4(void) +{ + + static ftype_t ipv4_type = { + "FT_IPv4", + "IPv4 address", + 4, + NULL, + NULL, + ftype_from_tvbuff, + val_from_string, + + NULL, + set_integer, + NULL, + + value_get, + NULL, + NULL, + + cmp_eq, + cmp_ne, + cmp_gt, + cmp_ge, + cmp_lt, + cmp_le, + }; + + ftype_register(FT_IPv4, &ipv4_type); +} |