diff options
Diffstat (limited to 'epan/dissectors/packet-cups.c')
-rw-r--r-- | epan/dissectors/packet-cups.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/epan/dissectors/packet-cups.c b/epan/dissectors/packet-cups.c index 1603668bbb..f01e04c627 100644 --- a/epan/dissectors/packet-cups.c +++ b/epan/dissectors/packet-cups.c @@ -19,6 +19,8 @@ void proto_register_cups(void); void proto_reg_handoff_cups(void); +static dissector_handle_t cups_handle; + /* From cups/cups.h, GNU GPL, Copyright 1997-2001 by Easy Software Products. */ typedef guint32 cups_ptype_t; /**** Printer Type/Capability Bits ****/ enum /* Not a typedef'd enum so we can OR */ @@ -62,34 +64,34 @@ static const value_string cups_state_values[] = { static const true_false_string tfs_implicit_explicit = { "Implicit class", "Explicit class" }; static const true_false_string tfs_printer_class = { "Printer class", "Single printer" }; -static int proto_cups = -1; -static int hf_cups_ptype = -1; -static int hf_cups_ptype_default = -1; -static int hf_cups_ptype_implicit = -1; -static int hf_cups_ptype_variable = -1; -static int hf_cups_ptype_large = -1; -static int hf_cups_ptype_medium = -1; -static int hf_cups_ptype_small = -1; -static int hf_cups_ptype_sort = -1; -static int hf_cups_ptype_bind = -1; -static int hf_cups_ptype_cover = -1; -static int hf_cups_ptype_punch = -1; -static int hf_cups_ptype_collate = -1; -static int hf_cups_ptype_copies = -1; -static int hf_cups_ptype_staple = -1; -static int hf_cups_ptype_duplex = -1; -static int hf_cups_ptype_color = -1; -static int hf_cups_ptype_bw = -1; -static int hf_cups_ptype_remote = -1; -static int hf_cups_ptype_class = -1; -static int hf_cups_state = -1; -static int hf_cups_uri = -1; -static int hf_cups_location = -1; -static int hf_cups_information = -1; -static int hf_cups_make_model = -1; - -static gint ett_cups = -1; -static gint ett_cups_ptype = -1; +static int proto_cups; +static int hf_cups_ptype; +static int hf_cups_ptype_default; +static int hf_cups_ptype_implicit; +static int hf_cups_ptype_variable; +static int hf_cups_ptype_large; +static int hf_cups_ptype_medium; +static int hf_cups_ptype_small; +static int hf_cups_ptype_sort; +static int hf_cups_ptype_bind; +static int hf_cups_ptype_cover; +static int hf_cups_ptype_punch; +static int hf_cups_ptype_collate; +static int hf_cups_ptype_copies; +static int hf_cups_ptype_staple; +static int hf_cups_ptype_duplex; +static int hf_cups_ptype_color; +static int hf_cups_ptype_bw; +static int hf_cups_ptype_remote; +static int hf_cups_ptype_class; +static int hf_cups_state; +static int hf_cups_uri; +static int hf_cups_location; +static int hf_cups_information; +static int hf_cups_make_model; + +static gint ett_cups; +static gint ett_cups_ptype; /* patterns used for tvb_ws_mempbrk_pattern_guint8 */ static ws_mempbrk_pattern pbrk_whitespace; @@ -101,9 +103,9 @@ static ws_mempbrk_pattern pbrk_whitespace; static guint get_hex_uint(tvbuff_t *tvb, gint offset, gint *next_offset); static gboolean skip_space(tvbuff_t *tvb, gint offset, gint *next_offset); -static const guint8* get_quoted_string(tvbuff_t *tvb, gint offset, +static const guint8* get_quoted_string(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *next_offset, guint *len); -static const guint8* get_unquoted_string(tvbuff_t *tvb, gint offset, +static const guint8* get_unquoted_string(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *next_offset, guint *len); /**********************************************************************/ @@ -171,13 +173,13 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ return offset; /* end of packet */ offset = next_offset; - str = get_unquoted_string(tvb, offset, &next_offset, &len); + str = get_unquoted_string(pinfo->pool, tvb, offset, &next_offset, &len); if (str == NULL) return offset; /* separator/terminator not found */ proto_tree_add_string(cups_tree, hf_cups_uri, tvb, offset, len, str); - col_add_fstr(pinfo->cinfo, COL_INFO, "%.*s (%s)", - (guint16) len, str, val_to_str(state, cups_state_values, "0x%x")); + col_add_fstr(pinfo->cinfo, COL_INFO, "%s (%s)", + str, val_to_str(state, cups_state_values, "0x%x")); offset = next_offset; if (!cups_tree) @@ -187,7 +189,7 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ return offset; /* end of packet */ offset = next_offset; - str = get_quoted_string(tvb, offset, &next_offset, &len); + str = get_quoted_string(pinfo->pool, tvb, offset, &next_offset, &len); if (str == NULL) return offset; /* separator/terminator not found */ proto_tree_add_string(cups_tree, hf_cups_location, tvb, offset+1, len, str); @@ -197,7 +199,7 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ return offset; /* end of packet */ offset = next_offset; - str = get_quoted_string(tvb, offset, &next_offset, &len); + str = get_quoted_string(pinfo->pool, tvb, offset, &next_offset, &len); if (str == NULL) return offset; /* separator/terminator not found */ proto_tree_add_string(cups_tree, hf_cups_information, tvb, offset+1, len, str); @@ -207,7 +209,7 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_ return offset; /* end of packet */ offset = next_offset; - str = get_quoted_string(tvb, offset, &next_offset, &len); + str = get_quoted_string(pinfo->pool, tvb, offset, &next_offset, &len); if (str == NULL) return offset; /* separator/terminator not found */ proto_tree_add_string(cups_tree, hf_cups_make_model, tvb, offset+1, len, str); @@ -248,7 +250,7 @@ skip_space(tvbuff_t *tvb, gint offset, gint *next_offset) } static const guint8* -get_quoted_string(tvbuff_t *tvb, gint offset, gint *next_offset, guint *len) +get_quoted_string(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *next_offset, guint *len) { int c; const guint8* s = NULL; @@ -261,7 +263,7 @@ get_quoted_string(tvbuff_t *tvb, gint offset, gint *next_offset, guint *len) if (o != -1) { offset++; l = o - offset; - s = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, l, ENC_UTF_8); + s = tvb_get_string_enc(scope, tvb, offset, l, ENC_UTF_8); offset = o + 1; } } @@ -273,7 +275,7 @@ get_quoted_string(tvbuff_t *tvb, gint offset, gint *next_offset, guint *len) } static const guint8* -get_unquoted_string(tvbuff_t *tvb, gint offset, gint *next_offset, guint *len) +get_unquoted_string(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *next_offset, guint *len) { const guint8* s = NULL; guint l = 0; @@ -282,7 +284,7 @@ get_unquoted_string(tvbuff_t *tvb, gint offset, gint *next_offset, guint *len) o = tvb_ws_mempbrk_pattern_guint8(tvb, offset, -1, &pbrk_whitespace, NULL); if (o != -1) { l = o - offset; - s = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, l, ENC_UTF_8); + s = tvb_get_string_enc(scope, tvb, offset, l, ENC_UTF_8); offset = o; } @@ -359,16 +361,16 @@ proto_register_cups(void) { "State", "cups.state", FT_UINT8, BASE_HEX, VALS(cups_state_values), 0x0, NULL, HFILL }}, { &hf_cups_uri, - { "URI", "cups.uri", FT_STRING, STR_UNICODE, + { "URI", "cups.uri", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_cups_location, - { "Location", "cups.location", FT_STRING, STR_UNICODE, + { "Location", "cups.location", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_cups_information, - { "Information", "cups.information", FT_STRING, STR_UNICODE, + { "Information", "cups.information", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, { &hf_cups_make_model, - { "Make and model", "cups.make_model", FT_STRING, STR_UNICODE, + { "Make and model", "cups.make_model", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }}, }; @@ -378,6 +380,7 @@ proto_register_cups(void) }; proto_cups = proto_register_protocol("Common Unix Printing System (CUPS) Browsing Protocol", "CUPS", "cups"); + cups_handle = register_dissector("cups", dissect_cups, proto_cups); proto_register_field_array(proto_cups, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); @@ -388,9 +391,6 @@ proto_register_cups(void) void proto_reg_handoff_cups(void) { - dissector_handle_t cups_handle; - - cups_handle = create_dissector_handle(dissect_cups, proto_cups); dissector_add_uint_with_preference("udp.port", UDP_PORT_CUPS, cups_handle); } |