* Charles Levert <charles@comm.polymtl.ca>
* Copyright 2001 Charles Levert
*
-* $Id: packet-cups.c,v 1.4 2001/03/15 07:03:13 guy Exp $
-*
+* $Id: packet-cups.c,v 1.11 2002/08/02 23:35:48 jmayer Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
#include "config.h"
#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
#include <string.h>
#include <ctype.h>
#include <glib.h>
-#include "packet.h"
-#include "strutil.h"
+#include <epan/packet.h>
+#include <epan/strutil.h>
/**********************************************************************/
static const value_string cups_state_values[] = {
{ CUPS_IDLE, "idle" },
{ CUPS_PROCESSING, "processing" },
- { CUPS_STOPPED, "stopped" }
+ { CUPS_STOPPED, "stopped" },
+ { 0, NULL }
};
static int proto_cups = -1;
cups_ptype_t ptype;
unsigned int state;
- if (check_col(pinfo->fd, COL_PROTOCOL))
- col_set_str(pinfo->fd, COL_PROTOCOL, PROTO_TAG_CUPS);
- if (check_col(pinfo->fd, COL_INFO))
- col_clear(pinfo->fd, COL_INFO);
+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, PROTO_TAG_CUPS);
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_clear(pinfo->cinfo, COL_INFO);
if (tree) {
- ti = proto_tree_add_item(tree, proto_cups, tvb, offset,
- tvb_length_remaining(tvb, offset), FALSE);
+ ti = proto_tree_add_item(tree, proto_cups, tvb, offset, -1,
+ FALSE);
cups_tree = proto_item_add_subtree(ti, ett_cups);
}
ptype = get_hex_uint(tvb, offset, &next_offset);
len = next_offset - offset;
- if (cups_tree) {
- ti = proto_tree_add_uint(cups_tree, hf_cups_ptype,
- tvb, offset, len, ptype);
- ptype_subtree = proto_item_add_subtree(ti, ett_cups_ptype);
- for (u = 0; u < N_CUPS_PTYPE_BITS; u++) {
- proto_tree_add_text(ptype_subtree, tvb, offset, len,
- "%s",
- decode_boolean_bitfield(ptype,
- cups_ptype_bits[u].bit, sizeof (ptype)*8,
- cups_ptype_bits[u].on_string,
- cups_ptype_bits[u].off_string));
+ if (len != 0) {
+ if (cups_tree) {
+ ti = proto_tree_add_uint(cups_tree, hf_cups_ptype,
+ tvb, offset, len, ptype);
+ ptype_subtree = proto_item_add_subtree(ti,
+ ett_cups_ptype);
+ for (u = 0; u < N_CUPS_PTYPE_BITS; u++) {
+ proto_tree_add_text(ptype_subtree, tvb,
+ offset, len, "%s",
+ decode_boolean_bitfield(ptype,
+ cups_ptype_bits[u].bit, sizeof (ptype)*8,
+ cups_ptype_bits[u].on_string,
+ cups_ptype_bits[u].off_string));
+ }
}
}
offset = next_offset;
state = get_hex_uint(tvb, offset, &next_offset);
len = next_offset - offset;
- if (cups_tree)
- proto_tree_add_uint(cups_tree, hf_cups_state,
- tvb, offset, len, state);
+ if (len != 0) {
+ if (cups_tree)
+ proto_tree_add_uint(cups_tree, hf_cups_state,
+ tvb, offset, len, state);
+ }
offset = next_offset;
if (!skip_space(tvb, offset, &next_offset))
offset = next_offset;
str = get_unquoted_string(tvb, offset, &next_offset, &len);
+ if (str == NULL)
+ return; /* separator/terminator not found */
if (cups_tree)
proto_tree_add_text(cups_tree, tvb, offset, len,
"URI: %.*s",
(guint16) len, str);
- if (check_col(pinfo->fd, COL_INFO))
- col_add_fstr(pinfo->fd, COL_INFO,
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_add_fstr(pinfo->cinfo, COL_INFO,
"%.*s (%s)",
(guint16) len, str,
val_to_str(state, cups_state_values, "0x%x"));
offset = next_offset;
str = get_quoted_string(tvb, offset, &next_offset, &len);
+ if (str == NULL)
+ return; /* separator/terminator not found */
proto_tree_add_text(cups_tree, tvb, offset+1, len,
"Location: \"%.*s\"",
(guint16) len, str);
offset = next_offset;
str = get_quoted_string(tvb, offset, &next_offset, &len);
+ if (str == NULL)
+ return; /* separator/terminator not found */
proto_tree_add_text(cups_tree, tvb, offset+1, len,
"Information: \"%.*s\"",
(guint16) len, str);
offset = next_offset;
str = get_quoted_string(tvb, offset, &next_offset, &len);
+ if (str == NULL)
+ return; /* separator/terminator not found */
proto_tree_add_text(cups_tree, tvb, offset+1, len,
"Make and model: \"%.*s\"",
(guint16) len, str);
/* This one could be split in separate fields. */
{ &hf_cups_ptype,
{ "Type", "cups.ptype", FT_UINT32, BASE_HEX,
- NULL, 0x0, ""}},
+ NULL, 0x0, "", HFILL }},
{ &hf_cups_state,
{ "State", "cups.state", FT_UINT8, BASE_HEX,
- VALS(cups_state_values), 0x0, "" }}
+ VALS(cups_state_values), 0x0, "", HFILL }}
};
static gint *ett[] = {
void
proto_reg_handoff_cups(void)
{
- dissector_add("udp.port", UDP_PORT_CUPS, dissect_cups, proto_cups);
+ dissector_handle_t cups_handle;
+
+ cups_handle = create_dissector_handle(dissect_cups, proto_cups);
+ dissector_add("udp.port", UDP_PORT_CUPS, cups_handle);
}