summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-cups.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-cups.c')
-rw-r--r--epan/dissectors/packet-cups.c141
1 files changed, 71 insertions, 70 deletions
diff --git a/epan/dissectors/packet-cups.c b/epan/dissectors/packet-cups.c
index 0890e856..6d854133 100644
--- a/epan/dissectors/packet-cups.c
+++ b/epan/dissectors/packet-cups.c
@@ -12,6 +12,7 @@
#include "config.h"
#include <epan/packet.h>
+#include <epan/tfs.h>
#include <wsutil/str_util.h>
/**********************************************************************/
@@ -22,7 +23,7 @@ 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 ****/
+typedef uint32_t cups_ptype_t; /**** Printer Type/Capability Bits ****/
enum /* Not a typedef'd enum so we can OR */
{
CUPS_PRINTER_LOCAL = 0x0000, /* Local printer or class */
@@ -64,36 +65,36 @@ 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;
-
-/* patterns used for tvb_ws_mempbrk_pattern_guint8 */
+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 int ett_cups;
+static int ett_cups_ptype;
+
+/* patterns used for tvb_ws_mempbrk_pattern_uint8 */
static ws_mempbrk_pattern pbrk_whitespace;
/* This protocol is heavily related to IPP, but it is CUPS-specific
@@ -101,12 +102,12 @@ static ws_mempbrk_pattern pbrk_whitespace;
#define UDP_PORT_CUPS 631
#define PROTO_TAG_CUPS "CUPS"
-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,
- gint *next_offset, guint *len);
-static const guint8* get_unquoted_string(tvbuff_t *tvb, gint offset,
- gint *next_offset, guint *len);
+static unsigned get_hex_uint(tvbuff_t *tvb, int offset, int *next_offset);
+static bool skip_space(tvbuff_t *tvb, int offset, int *next_offset);
+static const uint8_t* get_quoted_string(wmem_allocator_t *scope, tvbuff_t *tvb, int offset,
+ int *next_offset, unsigned *len);
+static const uint8_t* get_unquoted_string(wmem_allocator_t *scope, tvbuff_t *tvb, int offset,
+ int *next_offset, unsigned *len);
/**********************************************************************/
@@ -116,10 +117,10 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
proto_tree *cups_tree = NULL;
proto_tree *ptype_subtree = NULL;
proto_item *ti = NULL;
- gint offset = 0;
- gint next_offset;
- guint len;
- const guint8 *str;
+ int offset = 0;
+ int next_offset;
+ unsigned len;
+ const uint8_t *str;
cups_ptype_t ptype;
unsigned int state;
@@ -173,7 +174,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_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 */
@@ -189,7 +190,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);
@@ -199,7 +200,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);
@@ -209,7 +210,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);
@@ -217,13 +218,13 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
return next_offset;
}
-static guint
-get_hex_uint(tvbuff_t *tvb, gint offset, gint *next_offset)
+static unsigned
+get_hex_uint(tvbuff_t *tvb, int offset, int *next_offset)
{
int c;
- guint u = 0;
+ unsigned u = 0;
- while (g_ascii_isxdigit(c = tvb_get_guint8(tvb, offset))) {
+ while (g_ascii_isxdigit(c = tvb_get_uint8(tvb, offset))) {
u = 16*u + ws_xton(c);
offset++;
@@ -234,36 +235,36 @@ get_hex_uint(tvbuff_t *tvb, gint offset, gint *next_offset)
return u;
}
-static gboolean
-skip_space(tvbuff_t *tvb, gint offset, gint *next_offset)
+static bool
+skip_space(tvbuff_t *tvb, int offset, int *next_offset)
{
int c;
- while ((c = tvb_get_guint8(tvb, offset)) == ' ')
+ while ((c = tvb_get_uint8(tvb, offset)) == ' ')
offset++;
if (c == '\r' || c == '\n')
- return FALSE; /* end of packet */
+ return false; /* end of packet */
*next_offset = offset;
- return TRUE;
+ return true;
}
-static const guint8*
-get_quoted_string(tvbuff_t *tvb, gint offset, gint *next_offset, guint *len)
+static const uint8_t*
+get_quoted_string(wmem_allocator_t *scope, tvbuff_t *tvb, int offset, int *next_offset, unsigned *len)
{
int c;
- const guint8* s = NULL;
- guint l = 0;
- gint o;
+ const uint8_t* s = NULL;
+ unsigned l = 0;
+ int o;
- c = tvb_get_guint8(tvb, offset);
+ c = tvb_get_uint8(tvb, offset);
if (c == '"') {
- o = tvb_find_guint8(tvb, offset+1, -1, '"');
+ o = tvb_find_uint8(tvb, offset+1, -1, '"');
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;
}
}
@@ -274,17 +275,17 @@ get_quoted_string(tvbuff_t *tvb, gint offset, gint *next_offset, guint *len)
return s;
}
-static const guint8*
-get_unquoted_string(tvbuff_t *tvb, gint offset, gint *next_offset, guint *len)
+static const uint8_t*
+get_unquoted_string(wmem_allocator_t *scope, tvbuff_t *tvb, int offset, int *next_offset, unsigned *len)
{
- const guint8* s = NULL;
- guint l = 0;
- gint o;
+ const uint8_t* s = NULL;
+ unsigned l = 0;
+ int o;
- o = tvb_ws_mempbrk_pattern_guint8(tvb, offset, -1, &pbrk_whitespace, NULL);
+ o = tvb_ws_mempbrk_pattern_uint8(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;
}
@@ -374,7 +375,7 @@ proto_register_cups(void)
NULL, 0x0, NULL, HFILL }},
};
- static gint *ett[] = {
+ static int *ett[] = {
&ett_cups,
&ett_cups_ptype
};