diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-01-18 02:22:19 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-01-18 10:22:59 +0000 |
commit | cfcbb286712ae392689e7cd1a640b57b611dd277 (patch) | |
tree | c41ab4705bb0b790da02bc8b29768b5879543474 /epan/ftypes/ftype-ipv6.c | |
parent | c60fb3038e4a449c5488a32574d838a6599cb33f (diff) | |
download | wireshark-cfcbb286712ae392689e7cd1a640b57b611dd277.tar.gz |
Clean up ftype-conversion and dfilter error message string handling.
Have dfilter_compile() take an additional gchar ** argument, pointing to
a gchar * item that, on error, gets set to point to a g_malloc()ed error
string. That removes one bit of global state from the display filter
parser, and doesn't impose a fixed limit on the error message strings.
Have fvalue_from_string() and fvalue_from_unparsed() take a gchar **
argument, pointer to a gchar * item, rather than an error-reporting
function, and set the gchar * item to point to a g_malloc()ed error
string on an error.
Allow either gchar ** argument to be null; if the argument is null, no
error message is allocated or provided.
Change-Id: Ibd36b8aaa9bf4234aa6efa1e7fb95f7037493b4c
Reviewed-on: https://code.wireshark.org/review/6608
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/ftypes/ftype-ipv6.c')
-rw-r--r-- | epan/ftypes/ftype-ipv6.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/epan/ftypes/ftype-ipv6.c b/epan/ftypes/ftype-ipv6.c index bc72f58144..b69139df11 100644 --- a/epan/ftypes/ftype-ipv6.c +++ b/epan/ftypes/ftype-ipv6.c @@ -34,7 +34,7 @@ ipv6_fvalue_set(fvalue_t *fv, const guint8 *value) } static gboolean -ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, LogFunc logfunc) +ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, gchar **err_msg) { const char *has_slash; char *addr_str; @@ -51,7 +51,8 @@ ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_ addr_str = (char*)s; if (!get_host_ipaddr6(addr_str, &(fv->value.ipv6.addr))) { - logfunc("\"%s\" is not a valid hostname or IPv6 address.", s); + if (err_msg != NULL) + *err_msg = g_strdup_printf("\"%s\" is not a valid hostname or IPv6 address.", s); if (free_addr_str) wmem_free(NULL, addr_str); return FALSE; @@ -63,7 +64,7 @@ ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_ /* If prefix */ if (has_slash) { /* XXX - this is inefficient */ - nmask_fvalue = fvalue_from_unparsed(FT_UINT32, has_slash+1, FALSE, logfunc); + nmask_fvalue = fvalue_from_unparsed(FT_UINT32, has_slash+1, FALSE, err_msg); if (!nmask_fvalue) { return FALSE; } @@ -71,8 +72,10 @@ ipv6_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_ FVALUE_FREE(nmask_fvalue); if (nmask_bits > 128) { - logfunc("Prefix in a IPv6 address should be <= 128, not %u", - nmask_bits); + if (err_msg != NULL) { + *err_msg = g_strdup_printf("Prefix in a IPv6 address should be <= 128, not %u", + nmask_bits); + } return FALSE; } fv->value.ipv6.prefix = nmask_bits; |