/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.119 2003/12/02 10:23:18 sahlberg Exp $
+ * $Id: proto.c,v 1.120 2003/12/02 21:15:47 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
if(finfo->rep){ \
ITEM_LABEL_FREE(finfo->rep); \
} \
- FVALUE_FREE(finfo->value); \
+ FVALUE_CLEANUP(&finfo->value); \
FIELD_INFO_FREE(finfo);
static gboolean
static void
proto_tree_set_protocol_tvb(field_info *fi, tvbuff_t *tvb)
{
- fvalue_set(fi->value, tvb, TRUE);
+ fvalue_set(&fi->value, tvb, TRUE);
}
/* Add a FT_PROTOCOL to a proto_tree */
if (length > 0) {
g_byte_array_append(bytes, start_ptr, length);
}
- fvalue_set(fi->value, bytes, TRUE);
+ fvalue_set(&fi->value, bytes, TRUE);
}
static void
proto_tree_set_time(field_info *fi, nstime_t *value_ptr)
{
- fvalue_set(fi->value, value_ptr, FALSE);
+ fvalue_set(&fi->value, value_ptr, FALSE);
}
/* Add a FT_IPXNET to a proto_tree */
static void
proto_tree_set_ipxnet(field_info *fi, guint32 value)
{
- fvalue_set_integer(fi->value, value);
+ fvalue_set_integer(&fi->value, value);
}
/* Add a FT_IPv4 to a proto_tree */
static void
proto_tree_set_ipv4(field_info *fi, guint32 value)
{
- fvalue_set_integer(fi->value, value);
+ fvalue_set_integer(&fi->value, value);
}
/* Add a FT_IPv6 to a proto_tree */
static void
proto_tree_set_ipv6(field_info *fi, const guint8* value_ptr)
{
- fvalue_set(fi->value, (gpointer) value_ptr, FALSE);
+ fvalue_set(&fi->value, (gpointer) value_ptr, FALSE);
}
static void
for(i=0;i<8;i++){
buffer[i]=value_ptr[7-i];
}
- fvalue_set(fi->value, (gpointer)buffer, FALSE);
+ fvalue_set(&fi->value, (gpointer)buffer, FALSE);
} else {
- fvalue_set(fi->value, (gpointer)value_ptr, FALSE);
+ fvalue_set(&fi->value, (gpointer)value_ptr, FALSE);
}
}
fi = PITEM_FINFO(pi);
hfinfo = fi->ptr_u.hfinfo;
g_assert(hfinfo->type == FT_STRING || hfinfo->type == FT_STRINGZ);
- old_str = fvalue_get(fi->value);
+ old_str = fvalue_get(&fi->value);
new_str = g_malloc(strlen(old_str) + strlen(str) + 1);
sprintf(new_str, "%s%s", old_str, str);
- fvalue_set(fi->value, new_str, TRUE);
+ fvalue_set(&fi->value, new_str, TRUE);
}
/* Set the FT_STRING value */
proto_tree_set_string(field_info *fi, const char* value,
gboolean already_allocated)
{
- fvalue_set(fi->value, (gpointer) value, already_allocated);
+ fvalue_set(&fi->value, (gpointer) value, already_allocated);
}
static void
static void
proto_tree_set_ether(field_info *fi, const guint8* value)
{
- fvalue_set(fi->value, (gpointer) value, FALSE);
+ fvalue_set(&fi->value, (gpointer) value, FALSE);
}
static void
static void
proto_tree_set_float(field_info *fi, float value)
{
- fvalue_set_floating(fi->value, value);
+ fvalue_set_floating(&fi->value, value);
}
/* Add a FT_DOUBLE to a proto_tree */
static void
proto_tree_set_double(field_info *fi, double value)
{
- fvalue_set_floating(fi->value, value);
+ fvalue_set_floating(&fi->value, value);
}
/* Add any FT_UINT* to a proto_tree */
integer >>= hfinfo->bitshift;
}
}
- fvalue_set_integer(fi->value, integer);
+ fvalue_set_integer(&fi->value, integer);
}
/* Add any FT_INT* to a proto_tree */
integer >>= hfinfo->bitshift;
}
}
- fvalue_set_integer(fi->value, integer);
+ fvalue_set_integer(&fi->value, integer);
}
fi->length = *length;
fi->tree_type = -1;
fi->visible = PTREE_DATA(tree)->visible;
+ fvalue_init(&fi->value, fi->ptr_u.hfinfo->type);
fi->rep = NULL;
- fi->value = fvalue_new(fi->ptr_u.hfinfo->type);
-
/* add the data source tvbuff */
fi->ds_tvb=tvb?TVB_GET_DS_TVB(tvb):NULL;
case FT_BYTES:
case FT_UINT_BYTES:
- bytes = fvalue_get(fi->value);
+ bytes = fvalue_get(&fi->value);
if (bytes) {
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name,
- bytes_to_str(bytes, fvalue_length(fi->value)));
+ bytes_to_str(bytes, fvalue_length(&fi->value)));
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
label_str[ITEM_LABEL_LENGTH - 1] = '\0';
}
case FT_FLOAT:
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %." STRINGIFY(FLT_DIG) "f",
- hfinfo->name, fvalue_get_floating(fi->value));
+ hfinfo->name, fvalue_get_floating(&fi->value));
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
label_str[ITEM_LABEL_LENGTH - 1] = '\0';
break;
case FT_DOUBLE:
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %." STRINGIFY(DBL_DIG) "g",
- hfinfo->name, fvalue_get_floating(fi->value));
+ hfinfo->name, fvalue_get_floating(&fi->value));
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
label_str[ITEM_LABEL_LENGTH - 1] = '\0';
break;
case FT_ABSOLUTE_TIME:
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name,
- abs_time_to_str(fvalue_get(fi->value)));
+ abs_time_to_str(fvalue_get(&fi->value)));
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
label_str[ITEM_LABEL_LENGTH - 1] = '\0';
break;
case FT_RELATIVE_TIME:
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s seconds", hfinfo->name,
- rel_time_to_secs_str(fvalue_get(fi->value)));
+ rel_time_to_secs_str(fvalue_get(&fi->value)));
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
label_str[ITEM_LABEL_LENGTH - 1] = '\0';
break;
case FT_IPXNET:
- integer = fvalue_get_integer(fi->value);
+ integer = fvalue_get_integer(&fi->value);
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: 0x%08X (%s)", hfinfo->name,
integer, get_ipxnet_name(integer));
break;
case FT_ETHER:
- bytes = fvalue_get(fi->value);
+ bytes = fvalue_get(&fi->value);
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (%s)", hfinfo->name,
ether_to_str(bytes),
break;
case FT_IPv4:
- ipv4 = fvalue_get(fi->value);
+ ipv4 = fvalue_get(&fi->value);
n_addr = ipv4_get_net_order_addr(ipv4);
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (%s)", hfinfo->name,
break;
case FT_IPv6:
- bytes = fvalue_get(fi->value);
+ bytes = fvalue_get(&fi->value);
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s (%s)", hfinfo->name,
get_hostname6((struct e_in6_addr *)bytes),
case FT_STRING:
case FT_STRINGZ:
case FT_UINT_STRING:
- bytes = fvalue_get(fi->value);
+ bytes = fvalue_get(&fi->value);
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
"%s: %s", hfinfo->name,
format_text(bytes, strlen(bytes)));
header_field_info *hfinfo = fi->ptr_u.hfinfo;
int ret; /*tmp return value */
- bytes=fvalue_get(fi->value);
+ bytes=fvalue_get(&fi->value);
switch(hfinfo->display){
case BASE_DEC:
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
header_field_info *hfinfo = fi->ptr_u.hfinfo;
int ret; /*tmp return value */
- bytes=fvalue_get(fi->value);
+ bytes=fvalue_get(&fi->value);
switch(hfinfo->display){
case BASE_DEC:
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
tfstring = (const struct true_false_string*) hfinfo->strings;
}
- value = fvalue_get_integer(fi->value);
+ value = fvalue_get_integer(&fi->value);
if (hfinfo->bitmask) {
/* Figure out the bit width */
bitwidth = hfinfo_bitwidth(hfinfo);
format = hfinfo_uint_vals_format(hfinfo);
/* Un-shift bits */
- unshifted_value = fvalue_get_integer(fi->value);
+ unshifted_value = fvalue_get_integer(&fi->value);
value = unshifted_value;
if (hfinfo->bitshift > 0) {
unshifted_value <<= hfinfo->bitshift;
format = hfinfo_uint_format(hfinfo);
/* Un-shift bits */
- unshifted_value = fvalue_get_integer(fi->value);
+ unshifted_value = fvalue_get_integer(&fi->value);
value = unshifted_value;
if (hfinfo->bitshift > 0) {
unshifted_value <<= hfinfo->bitshift;
/* Pick the proper format string */
format = hfinfo_uint_vals_format(hfinfo);
- value = fvalue_get_integer(fi->value);
+ value = fvalue_get_integer(&fi->value);
/* Fill in the textual info */
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
/* Pick the proper format string */
format = hfinfo_uint_format(hfinfo);
- value = fvalue_get_integer(fi->value);
+ value = fvalue_get_integer(&fi->value);
/* Fill in the textual info */
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
/* Pick the proper format string */
format = hfinfo_int_vals_format(hfinfo);
- value = fvalue_get_integer(fi->value);
+ value = fvalue_get_integer(&fi->value);
/* Fill in the textual info */
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
/* Pick the proper format string */
format = hfinfo_int_format(hfinfo);
- value = fvalue_get_integer(fi->value);
+ value = fvalue_get_integer(&fi->value);
/* Fill in the textual info */
ret = snprintf(label_str, ITEM_LABEL_LENGTH,
dfilter_len = abbrev_len + 4 + 11 + 1;
buf = g_malloc0(dfilter_len);
format = hfinfo_numeric_format(hfinfo);
- snprintf(buf, dfilter_len, format, hfinfo->abbrev, fvalue_get_integer(finfo->value));
+ snprintf(buf, dfilter_len, format, hfinfo->abbrev, fvalue_get_integer(&finfo->value));
break;
case FT_UINT64:
* N bytes for the string for the number.
* 1 byte for the trailing '\0'.
*/
- stringified = u64toa(fvalue_get(finfo->value));
+ stringified = u64toa(fvalue_get(&finfo->value));
dfilter_len = abbrev_len + 4 + strlen(stringified) +1;
buf = g_malloc0(dfilter_len);
snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev,
* N bytes for the string for the number.
* 1 byte for the trailing '\0'.
*/
- stringified = i64toa(fvalue_get(finfo->value));
+ stringified = i64toa(fvalue_get(&finfo->value));
dfilter_len = abbrev_len + 4 + strlen(stringified) +1;
buf = g_malloc0(dfilter_len);
snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev,
dfilter_len = abbrev_len + 4 + 2 + 8 + 1;
buf = g_malloc0(dfilter_len);
snprintf(buf, dfilter_len, "%s == 0x%08x", hfinfo->abbrev,
- fvalue_get_integer(finfo->value));
+ fvalue_get_integer(&finfo->value));
break;
case FT_IPv6:
* N bytes for the string for the address.
* 1 byte for the trailing '\0'.
*/
- stringified = ip6_to_str((struct e_in6_addr*) fvalue_get(finfo->value));
+ stringified = ip6_to_str((struct e_in6_addr*) fvalue_get(&finfo->value));
dfilter_len = abbrev_len + 4 + strlen(stringified) + 1;
buf = g_malloc0(dfilter_len);
snprintf(buf, dfilter_len, "%s == %s", hfinfo->abbrev,
* 4 bytes for " == ".
* 1 byte for trailing NUL.
*/
- dfilter_len = fvalue_string_repr_len(finfo->value,
+ dfilter_len = fvalue_string_repr_len(&finfo->value,
FTREPR_DFILTER);
dfilter_len += abbrev_len + 4 + 1;
buf = g_malloc0(dfilter_len);
/* Create the string */
snprintf(buf, dfilter_len, "%s == ", hfinfo->abbrev);
- fvalue_to_string_repr(finfo->value,
+ fvalue_to_string_repr(&finfo->value,
FTREPR_DFILTER,
&buf[abbrev_len + 4]);
break;
* Portions Copyright (c) Gilbert Ramirez 2000-2002
* Portions Copyright (c) Novell, Inc. 2000-2003
*
- * $Id: packet-ncp2222.inc,v 1.66 2003/11/24 22:11:53 guy Exp $
+ * $Id: packet-ncp2222.inc,v 1.67 2003/12/02 21:15:45 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
guint
get_item_value(proto_item *item)
{
- return fvalue_get_integer(PITEM_FINFO(item)->value);
+ return fvalue_get_integer(&PITEM_FINFO(item)->value);
}
char *
get_item_string(proto_item *item)
{
- return fvalue_get(PITEM_FINFO(item)->value);
+ return fvalue_get(&PITEM_FINFO(item)->value);
}
char *
if (info_type != 0) { /* Is this a string or not? */
if (info_type == 1) { /* Is this bytes? */
- byte_string = bytes_to_str(fvalue_get(finfo->value), fvalue_length(finfo->value));
+ byte_string = bytes_to_str(fvalue_get(&finfo->value), fvalue_length(&finfo->value));
col_append_fstr(pinfo->cinfo, COL_INFO,
(const gchar*) ncp_rec->req_info_str->first_string,
byte_string);
else
{
if (info_type == 2) { /* Is this a String? */
- uni_to_string(fvalue_get(finfo->value), fvalue_length(finfo->value), non_uni_string);
+ uni_to_string(fvalue_get(&finfo->value), fvalue_length(&finfo->value), non_uni_string);
col_append_fstr(pinfo->cinfo, COL_INFO,
(const gchar*) ncp_rec->req_info_str->first_string,
non_uni_string);
{
col_append_fstr(pinfo->cinfo, COL_INFO,
(const gchar*) ncp_rec->req_info_str->first_string,
- fvalue_get(finfo->value));
+ fvalue_get(&finfo->value));
}
}
}
{
col_append_fstr(pinfo->cinfo, COL_INFO,
(const gchar*) ncp_rec->req_info_str->first_string,
- fvalue_get_integer(finfo->value));
+ fvalue_get_integer(&finfo->value));
}
}
if (len > 1) {
if (info_type != 0) { /* Is this a string or not? */
if (info_type == 1)
{ /* Is this bytes? */
- byte_string = bytes_to_str(fvalue_get(finfo->value), fvalue_length(finfo->value));
+ byte_string = bytes_to_str(fvalue_get(&finfo->value), fvalue_length(&finfo->value));
col_append_fstr(pinfo->cinfo, COL_INFO,
(const gchar*) ncp_rec->req_info_str->repeat_string,
byte_string);
else
{
if (info_type == 2) { /* Is this a String? */
- uni_to_string(fvalue_get(finfo->value), fvalue_length(finfo->value), non_uni_string);
+ uni_to_string(fvalue_get(&finfo->value), fvalue_length(&finfo->value), non_uni_string);
col_append_fstr(pinfo->cinfo, COL_INFO,
(const gchar*) ncp_rec->req_info_str->repeat_string,
non_uni_string);
{
col_append_fstr(pinfo->cinfo, COL_INFO,
(const gchar*) ncp_rec->req_info_str->repeat_string,
- fvalue_get(finfo->value));
+ fvalue_get(&finfo->value));
}
}
}
{
col_append_fstr(pinfo->cinfo, COL_INFO,
(const gchar*) ncp_rec->req_info_str->repeat_string,
- fvalue_get_integer(finfo->value));
+ fvalue_get_integer(&finfo->value));
}
}
}