summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-memcache.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:53 +0000
commita86c5f7cae7ec9a3398300555a0b644689d946a1 (patch)
tree39fe4b107c71174fd1e8a8ceb9a4d2aa14116248 /epan/dissectors/packet-memcache.c
parentReleasing progress-linux version 4.2.6-1~progress7.99u1. (diff)
downloadwireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.tar.xz
wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.zip
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/packet-memcache.c')
-rw-r--r--epan/dissectors/packet-memcache.c468
1 files changed, 234 insertions, 234 deletions
diff --git a/epan/dissectors/packet-memcache.c b/epan/dissectors/packet-memcache.c
index 186bdbfd..eba5aaaf 100644
--- a/epan/dissectors/packet-memcache.c
+++ b/epan/dissectors/packet-memcache.c
@@ -90,59 +90,59 @@ void proto_reg_handoff_memcache(void);
/* Data Types */
#define DT_RAW_BYTES 0x00
-static int proto_memcache = -1;
+static int proto_memcache;
static dissector_handle_t memcache_tcp_handle;
static dissector_handle_t memcache_udp_handle;
-static int hf_magic = -1;
-static int hf_opcode = -1;
-static int hf_extras_length = -1;
-static int hf_key_length = -1;
-static int hf_value_length = -1;
-static int hf_data_type = -1;
-static int hf_reserved = -1;
-static int hf_status = -1;
-static int hf_total_body_length = -1;
-static int hf_opaque = -1;
-static int hf_cas = -1;
-static int hf_extras = -1;
-static int hf_extras_flags = -1;
-static int hf_extras_expiration = -1;
-static int hf_extras_delta = -1;
-static int hf_extras_initial = -1;
-static int hf_extras_unknown = -1;
-static int hf_key = -1;
-static int hf_value = -1;
-static int hf_uint64_response = -1;
-
-static int hf_command = -1;
-static int hf_subcommand = -1;
-static int hf_flags = -1;
-static int hf_expiration = -1;
-static int hf_noreply = -1;
-
-static int hf_response = -1;
-
-static int hf_version = -1;
-static int hf_slabclass = -1;
-static int hf_name = -1;
-static int hf_name_value = -1;
-
-static gint ett_memcache = -1;
-static gint ett_extras = -1;
-
-static expert_field ei_value_missing = EI_INIT;
-static expert_field ei_extras_missing = EI_INIT;
-static expert_field ei_value_length = EI_INIT;
-static expert_field ei_key_missing = EI_INIT;
-static expert_field ei_key_unknown = EI_INIT;
-static expert_field ei_extras_unknown = EI_INIT;
-static expert_field ei_value_unknown = EI_INIT;
-static expert_field ei_status_response = EI_INIT;
-static expert_field ei_opcode_unknown = EI_INIT;
-static expert_field ei_reserved_value = EI_INIT;
-static expert_field ei_magic_unknown = EI_INIT;
+static int hf_magic;
+static int hf_opcode;
+static int hf_extras_length;
+static int hf_key_length;
+static int hf_value_length;
+static int hf_data_type;
+static int hf_reserved;
+static int hf_status;
+static int hf_total_body_length;
+static int hf_opaque;
+static int hf_cas;
+static int hf_extras;
+static int hf_extras_flags;
+static int hf_extras_expiration;
+static int hf_extras_delta;
+static int hf_extras_initial;
+static int hf_extras_unknown;
+static int hf_key;
+static int hf_value;
+static int hf_uint64_response;
+
+static int hf_command;
+static int hf_subcommand;
+static int hf_flags;
+static int hf_expiration;
+static int hf_noreply;
+
+static int hf_response;
+
+static int hf_version;
+static int hf_slabclass;
+static int hf_name;
+static int hf_name_value;
+
+static int ett_memcache;
+static int ett_extras;
+
+static expert_field ei_value_missing;
+static expert_field ei_extras_missing;
+static expert_field ei_value_length;
+static expert_field ei_key_missing;
+static expert_field ei_key_unknown;
+static expert_field ei_extras_unknown;
+static expert_field ei_value_unknown;
+static expert_field ei_status_response;
+static expert_field ei_opcode_unknown;
+static expert_field ei_reserved_value;
+static expert_field ei_magic_unknown;
static const value_string magic_vals[] = {
{ MAGIC_REQUEST, "Request" },
@@ -207,29 +207,29 @@ typedef enum _memcache_type {
} memcache_type_t;
/* desegmentation of MEMCACHE header */
-static gboolean memcache_desegment_headers = TRUE;
+static bool memcache_desegment_headers = true;
/* desegmentation of MEMCACHE payload */
-static gboolean memcache_desegment_body = TRUE;
+static bool memcache_desegment_body = true;
/* should refer to either the request or the response dissector.
*/
typedef int (*ReqRespDissector)(tvbuff_t*, packet_info *, proto_tree *,
- int, const guchar*, const guchar*, guint8);
+ int, const unsigned char*, const unsigned char*, uint8_t);
/* determines if a packet contains a memcache
* request or reply by looking at its first token.
*/
static int
-is_memcache_request_or_reply(const gchar *data, int linelen, guint8 *opcode,
- memcache_type_t *type, int *expect_content_length,
+is_memcache_request_or_reply(const char *data, int linelen, uint8_t *opcode,
+ memcache_type_t *type, bool *expect_content_length,
ReqRespDissector *reqresp_dissector);
-static guint
+static unsigned
get_memcache_pdu_len (packet_info *pinfo _U_, tvbuff_t *tvb,
int offset, void *data _U_)
{
- guint32 body_len;
+ uint32_t body_len;
/* Get the length of the memcache body */
body_len = tvb_get_ntohl(tvb, offset+8);
@@ -240,13 +240,13 @@ get_memcache_pdu_len (packet_info *pinfo _U_, tvbuff_t *tvb,
static void
dissect_extras (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- gint offset, guint8 extras_len, guint8 opcode, gboolean request)
+ int offset, uint8_t extras_len, uint8_t opcode, bool request)
{
proto_tree *extras_tree = NULL;
proto_item *extras_item = NULL, *ti;
- gint save_offset = offset;
- gboolean illegal = FALSE; /* Set when extras shall not be present */
- gboolean missing = FALSE; /* Set when extras is missing */
+ int save_offset = offset;
+ bool illegal = false; /* Set when extras shall not be present */
+ bool missing = false; /* Set when extras is missing */
if (extras_len) {
extras_item = proto_tree_add_item (tree, hf_extras, tvb, offset, extras_len, ENC_NA);
@@ -262,14 +262,14 @@ dissect_extras (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (extras_len) {
if (request) {
/* Request shall not have extras */
- illegal = TRUE;
+ illegal = true;
} else {
proto_tree_add_item (extras_tree, hf_extras_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
}
} else if (!request) {
/* Response must have extras */
- missing = TRUE;
+ missing = true;
}
break;
@@ -288,11 +288,11 @@ dissect_extras (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
offset += 4;
} else {
/* Response shall not have extras */
- illegal = TRUE;
+ illegal = true;
}
} else if (request) {
/* Request must have extras */
- missing = TRUE;
+ missing = true;
}
break;
@@ -312,11 +312,11 @@ dissect_extras (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
offset += 4;
} else {
/* Response must not have extras (response is in Value) */
- illegal = TRUE;
+ illegal = true;
}
} else if (request) {
/* Request must have extras */
- missing = TRUE;
+ missing = true;
}
break;
@@ -340,7 +340,7 @@ dissect_extras (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
case OP_STAT:
/* Must not have extras */
if (extras_len) {
- illegal = TRUE;
+ illegal = true;
}
break;
@@ -372,11 +372,11 @@ dissect_extras (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
static void
dissect_key (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- gint offset, int key_len, guint8 opcode, gboolean request)
+ int offset, int key_len, uint8_t opcode, bool request)
{
proto_item *ti = NULL;
- gboolean illegal = FALSE; /* Set when key shall not be present */
- gboolean missing = FALSE; /* Set when key is missing */
+ bool illegal = false; /* Set when key shall not be present */
+ bool missing = false; /* Set when key is missing */
if (key_len) {
ti = proto_tree_add_item (tree, hf_key, tvb, offset, key_len, ENC_ASCII);
@@ -384,7 +384,7 @@ dissect_key (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if ((opcode == OP_QUIT) || (opcode == OP_QUIT_Q) || (opcode == OP_NO_OP) || (opcode == OP_VERSION)) {
/* Request and Response must not have key */
- illegal = TRUE;
+ illegal = true;
}
if ((opcode == OP_SET) || (opcode == OP_ADD) || (opcode == OP_REPLACE) || (opcode == OP_DELETE) ||
(opcode == OP_SET_Q) || (opcode == OP_ADD_Q) || (opcode == OP_REPLACE_Q) || (opcode == OP_DELETE_Q) ||
@@ -393,7 +393,7 @@ dissect_key (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
{
/* Response must not have a key */
if (!request) {
- illegal = TRUE;
+ illegal = true;
}
}
} else {
@@ -404,7 +404,7 @@ dissect_key (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
{
/* Request must have key */
if (request) {
- missing = TRUE;
+ missing = true;
}
}
}
@@ -421,11 +421,11 @@ dissect_key (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
static void
dissect_value (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- gint offset, guint32 value_len, guint8 opcode, gboolean request)
+ int offset, uint32_t value_len, uint8_t opcode, bool request)
{
proto_item *ti = NULL;
- gboolean illegal = FALSE; /* Set when value shall not be present */
- gboolean missing = FALSE; /* Set when value is missing */
+ bool illegal = false; /* Set when value shall not be present */
+ bool missing = false; /* Set when value is missing */
if (value_len > 0) {
if (!request && ((opcode == OP_INCREMENT) || (opcode == OP_DECREMENT))) {
@@ -447,14 +447,14 @@ dissect_value (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
{
/* Request must not have value */
if (request) {
- illegal = TRUE;
+ illegal = true;
}
}
if ((opcode == OP_DELETE) || (opcode == OP_QUIT) || (opcode == OP_FLUSH) || (opcode == OP_NO_OP) ||
(opcode == OP_DELETE_Q) || (opcode == OP_QUIT_Q) || (opcode == OP_FLUSH_Q))
{
/* Request and Response must not have value */
- illegal = TRUE;
+ illegal = true;
}
if ((opcode == OP_SET) || (opcode == OP_ADD) || (opcode == OP_REPLACE) ||
(opcode == OP_SET_Q) || (opcode == OP_ADD_Q) || (opcode == OP_REPLACE_Q) ||
@@ -462,7 +462,7 @@ dissect_value (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
{
/* Response must not have value */
if (!request) {
- illegal = TRUE;
+ illegal = true;
}
}
} else {
@@ -472,7 +472,7 @@ dissect_value (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
{
/* Request must have a value */
if (request) {
- missing = TRUE;
+ missing = true;
}
}
}
@@ -493,11 +493,11 @@ dissect_memcache (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
{
proto_tree *memcache_tree;
proto_item *memcache_item, *ti;
- gint offset = 0;
- guint8 magic, opcode, extras_len;
- guint16 key_len, status = 0;
- guint32 body_len, value_len;
- gboolean request;
+ int offset = 0;
+ uint8_t magic, opcode, extras_len;
+ uint16_t key_len, status = 0;
+ uint32_t body_len, value_len;
+ bool request;
col_set_str (pinfo->cinfo, COL_PROTOCOL, PSNAME);
col_clear (pinfo->cinfo, COL_INFO);
@@ -505,7 +505,7 @@ dissect_memcache (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
memcache_item = proto_tree_add_item (tree, proto_memcache, tvb, offset, -1, ENC_NA);
memcache_tree = proto_item_add_subtree (memcache_item, ett_memcache);
- magic = tvb_get_guint8 (tvb, offset);
+ magic = tvb_get_uint8 (tvb, offset);
ti = proto_tree_add_item (memcache_tree, hf_magic, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
@@ -513,7 +513,7 @@ dissect_memcache (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
expert_add_info_format(pinfo, ti, &ei_magic_unknown, "Unknown magic byte: %d", magic);
}
- opcode = tvb_get_guint8 (tvb, offset);
+ opcode = tvb_get_uint8 (tvb, offset);
ti = proto_tree_add_item (memcache_tree, hf_opcode, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
@@ -532,7 +532,7 @@ dissect_memcache (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
proto_tree_add_item (memcache_tree, hf_key_length, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
- extras_len = tvb_get_guint8 (tvb, offset);
+ extras_len = tvb_get_uint8 (tvb, offset);
proto_tree_add_item (memcache_tree, hf_extras_length, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
@@ -541,7 +541,7 @@ dissect_memcache (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
status = tvb_get_ntohs (tvb, offset);
if (magic & 0x01) { /* We suppose this is a response, even when unknown magic byte */
- request = FALSE;
+ request = false;
ti = proto_tree_add_item (memcache_tree, hf_status, tvb, offset, 2, ENC_BIG_ENDIAN);
if (status != 0) {
expert_add_info_format(pinfo, ti, &ei_status_response, "%s: %s",
@@ -549,7 +549,7 @@ dissect_memcache (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
val_to_str (status, status_vals, "Status: %d"));
}
} else {
- request = TRUE;
+ request = true;
ti = proto_tree_add_item (memcache_tree, hf_reserved, tvb, offset, 2, ENC_BIG_ENDIAN);
if (status != 0) {
expert_add_info_format(pinfo, ti, &ei_reserved_value, "Reserved value: %d", status);
@@ -597,21 +597,21 @@ dissect_memcache (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* dat
/* Obtain the content length by peeping into the header.
*/
-static gboolean
+static bool
get_payload_length (tvbuff_t *tvb, packet_info *pinfo, const int token_number, int offset,
- guint32 *bytes, gboolean *content_length_found)
+ uint32_t *bytes, bool *content_length_found)
{
- const guchar *next_token;
- const guchar *line, *lineend;
- guchar *bytes_val;
+ const unsigned char *next_token;
+ const unsigned char *line, *lineend;
+ unsigned char *bytes_val;
int tokenlen, i = 0, linelen;
- gint next_offset;
+ int next_offset;
/* get the header line. */
linelen = tvb_find_line_end (tvb, offset, -1, &next_offset,
- FALSE);
+ false);
if (linelen < 0) {
- return FALSE;
+ return false;
}
line = tvb_get_ptr (tvb, offset, linelen);
@@ -620,7 +620,7 @@ get_payload_length (tvbuff_t *tvb, packet_info *pinfo, const int token_number, i
while (++i < token_number) {
tokenlen = get_token_len (line, lineend, &next_token);
if (tokenlen == 0) {
- return FALSE;
+ return false;
}
offset += (int) (next_token - line);
line = next_token;
@@ -629,30 +629,30 @@ get_payload_length (tvbuff_t *tvb, packet_info *pinfo, const int token_number, i
/* line or the next_token has the value we want. */
tokenlen = get_token_len (line, lineend, &next_token);
if (tokenlen == 0) {
- return FALSE;
+ return false;
}
bytes_val = tvb_get_string_enc(pinfo->pool, tvb, offset, tokenlen, ENC_ASCII);
if (bytes_val) {
if (sscanf (bytes_val, "%u", bytes) == 1) {
- *content_length_found = TRUE;
+ *content_length_found = true;
} else {
- return FALSE;
+ return false;
}
} else {
- return FALSE;
+ return false;
}
/* reached this far, we got what we want. */
- return TRUE;
+ return true;
}
/* check if a PDU needs to be desegmented. */
-static gboolean
+static bool
desegment_pdus (tvbuff_t *tvb, packet_info *pinfo, const int offset,
- const int data_offset, guint32 content_length)
+ const int data_offset, uint32_t content_length)
{
- gint length_remaining, reported_length_remaining;
+ int length_remaining, reported_length_remaining;
/* data_offset has been set to start of the data block. */
if (!tvb_bytes_exist (tvb, data_offset, content_length)) {
@@ -664,7 +664,7 @@ desegment_pdus (tvbuff_t *tvb, packet_info *pinfo, const int offset,
/* It's a waste of time asking for more
* data, because that data wasn't captured.
*/
- return FALSE;
+ return false;
}
if (length_remaining == -1) {
@@ -674,27 +674,27 @@ desegment_pdus (tvbuff_t *tvb, packet_info *pinfo, const int offset,
pinfo->desegment_offset = offset; /* start of the packet. */
pinfo->desegment_len = (content_length + 2) - length_remaining; /* add 2 for /r/n */
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
/*
* Optionally do reassembly of the requests, responses and data.
*/
-static gboolean
+static bool
memcache_req_resp_hdrs_do_reassembly (
tvbuff_t *tvb, const int offset, packet_info *pinfo,
- const gboolean desegment_headers, const gboolean desegment_body,
- const memcache_type_t type, const int expect_content_length)
+ const bool desegment_headers, const bool desegment_body,
+ const memcache_type_t type, const bool expect_content_length)
{
int linelen;
- gint next_offset;
- gint length_remaining;
- gint reported_length_remaining;
- guint32 content_length = 0;
- gboolean content_length_found = FALSE;
- gboolean ret = FALSE;
+ int next_offset;
+ int length_remaining;
+ int reported_length_remaining;
+ uint32_t content_length = 0;
+ bool content_length_found = false;
+ bool ret = false;
/*
* If header desegmentation is activated, check the
@@ -716,7 +716,7 @@ memcache_req_resp_hdrs_do_reassembly (
if (reported_length_remaining < 1) {
pinfo->desegment_offset = offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
- return FALSE;
+ return false;
}
length_remaining = tvb_captured_length_remaining (tvb, next_offset);
@@ -724,12 +724,12 @@ memcache_req_resp_hdrs_do_reassembly (
/* Request one more byte if we cannot find a
* header (i.e. a line end).
*/
- linelen = tvb_find_line_end (tvb, next_offset, -1, &next_offset, TRUE);
+ linelen = tvb_find_line_end (tvb, next_offset, -1, &next_offset, true);
if (linelen == -1 && length_remaining >= reported_length_remaining) {
/* Not enough data; ask for one more byte. */
pinfo->desegment_offset = offset;
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
- return FALSE;
+ return false;
}
/* Browse through the header to find the content length.
@@ -742,14 +742,14 @@ memcache_req_resp_hdrs_do_reassembly (
* VALUE <key> <flags> <bytes> [<cas unique>]\r\n
* <data block>\r\n
*/
- if (expect_content_length == TRUE) {
+ if (expect_content_length == true) {
switch (type) {
case MEMCACHE_REQUEST:
/* Get the fifth token in the header.*/
ret = get_payload_length (tvb, pinfo, 5 , offset, &content_length, &content_length_found);
if (!ret) {
- return FALSE;
+ return false;
}
break;
@@ -757,13 +757,13 @@ memcache_req_resp_hdrs_do_reassembly (
/* Get the fourth token in the header.*/
ret = get_payload_length (tvb, pinfo, 4 , offset, &content_length, &content_length_found);
if (!ret) {
- return FALSE;
+ return false;
}
break;
default:
/* Unrecognized message type. */
- return FALSE;
+ return false;
}
}
}
@@ -778,27 +778,27 @@ memcache_req_resp_hdrs_do_reassembly (
}
/* No further desegmentation needed. */
- return TRUE;
+ return true;
}
/* Dissect a memcache message. */
static int
dissect_memcache_message (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
- const guchar *line;
- const guchar *lineend;
+ const unsigned char *line;
+ const unsigned char *lineend;
int orig_offset;
int first_linelen;
int datalen;
- int expect_content_length = FALSE;
- gint next_offset;
+ bool expect_content_length = false;
+ int next_offset;
- gboolean is_request_or_reply;
+ bool is_request_or_reply;
memcache_type_t memcache_type;
ReqRespDissector reqresp_dissector = NULL;
proto_tree *memcache_tree = NULL;
proto_item *memcache_item = NULL;
- guint8 opcode = 0xff; /* set to something that is not in the list. */
+ uint8_t opcode = 0xff; /* set to something that is not in the list. */
/* Find a line end in the packet.
* Note that "tvb_find_line_end ()" will return a value that
@@ -806,7 +806,7 @@ dissect_memcache_message (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t
* "tvb_get_ptr ()" call won't throw an exception.
*/
first_linelen = tvb_find_line_end (tvb, offset, -1, &next_offset,
- FALSE);
+ false);
if (first_linelen < 0) {
return -1;
}
@@ -820,7 +820,7 @@ dissect_memcache_message (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t
* determine if it is a request or a response?
*/
is_request_or_reply =
- is_memcache_request_or_reply ((const gchar *)line,
+ is_memcache_request_or_reply ((const char *)line,
first_linelen, &opcode, &memcache_type,
&expect_content_length, &reqresp_dissector);
if (is_request_or_reply) {
@@ -899,10 +899,10 @@ dissect_memcache_message (tvbuff_t *tvb, int offset, packet_info *pinfo, proto_t
*/
static int
content_data_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
- int content_length, guint8 opcode)
+ int content_length, uint8_t opcode)
{
- gint datalen;
- gboolean short_pkt = FALSE;
+ int datalen;
+ bool short_pkt = false;
/*
* Expecting to read 'content_length' number of bytes from
@@ -916,12 +916,12 @@ content_data_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
if (datalen >= (content_length + 2)) { /* also consider \r\n*/
datalen = content_length;
} else {
- short_pkt = TRUE;
+ short_pkt = true;
}
}
/* dissect the data block. */
- dissect_value (tvb, pinfo, tree, offset, datalen, opcode, TRUE);
+ dissect_value (tvb, pinfo, tree, offset, datalen, opcode, true);
if (datalen > 0) {
/*
* We've processed "datalen" bytes worth of data
@@ -940,13 +940,13 @@ content_data_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
}
/* Find the occurrences of a ':' in a stat response. */
-static guint
-find_stat_colon (const guchar *line, const guchar *lineend,
- const guchar **first_colon, const guchar **last_colon)
+static unsigned
+find_stat_colon (const unsigned char *line, const unsigned char *lineend,
+ const unsigned char **first_colon, const unsigned char **last_colon)
{
- const guchar *linep, *temp;
- guint occurrences = 0;
- guchar c;
+ const unsigned char *linep, *temp;
+ unsigned occurrences = 0;
+ unsigned char c;
linep = line;
while (linep < lineend) {
@@ -979,17 +979,17 @@ find_stat_colon (const guchar *line, const guchar *lineend,
static int
incr_dissector (tvbuff_t *tvb, proto_tree *tree, int offset)
{
- gint next_offset;
+ int next_offset;
int linelen;
- const guchar *line, *lineend;
+ const unsigned char *line, *lineend;
- const guchar *next_token;
+ const unsigned char *next_token;
int tokenlen;
/* expecting to read 'bytes' number of bytes from the buffer. */
if (tvb_offset_exists (tvb, offset)) {
/* Find the end of the line. */
- linelen = tvb_find_line_end (tvb, offset, -1, &next_offset, FALSE);
+ linelen = tvb_find_line_end (tvb, offset, -1, &next_offset, false);
if (linelen < 0) {
/* header is out of the packet limits. */
return -1;
@@ -1027,19 +1027,19 @@ incr_dissector (tvbuff_t *tvb, proto_tree *tree, int offset)
static int
stat_dissector (tvbuff_t *tvb, proto_tree *tree, int offset)
{
- guint occurrences = 0;
- const guchar *first_colon = NULL, *last_colon = NULL;
+ unsigned occurrences = 0;
+ const unsigned char *first_colon = NULL, *last_colon = NULL;
int tokenlen, linelen;
- gint next_offset;
- const guchar *next_token;
- const guchar *line, *lineend;
- guint32 slabclass;
- guchar response_chars[21];
+ int next_offset;
+ const unsigned char *next_token;
+ const unsigned char *line, *lineend;
+ uint32_t slabclass;
+ unsigned char response_chars[21];
while (tvb_offset_exists (tvb, offset)) {
/* Find the end of the line. */
linelen = tvb_find_line_end (tvb, offset, -1, &next_offset,
- FALSE);
+ false);
if (linelen < 0) {
return -1;
}
@@ -1080,7 +1080,7 @@ stat_dissector (tvbuff_t *tvb, proto_tree *tree, int offset)
memcpy (response_chars, first_colon + 1, tokenlen);
response_chars[tokenlen] = '\0';
- slabclass = (guint32) strtoul (response_chars, NULL, 10);
+ slabclass = (uint32_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint (tree, hf_slabclass, tvb, offset, tokenlen, slabclass);
offset += tokenlen + 1;
line = last_colon + 1;
@@ -1094,7 +1094,7 @@ stat_dissector (tvbuff_t *tvb, proto_tree *tree, int offset)
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- slabclass = (guint32) strtoul (response_chars, NULL, 10);
+ slabclass = (uint32_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint (tree, hf_slabclass, tvb, offset, tokenlen, slabclass);
offset += (int) (tokenlen + 1);
@@ -1136,22 +1136,22 @@ stat_dissector (tvbuff_t *tvb, proto_tree *tree, int offset)
static int
get_response_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
{
- gint next_offset;
+ int next_offset;
int linelen;
- const guchar *line, *lineend;
- const guchar *next_token;
+ const unsigned char *line, *lineend;
+ const unsigned char *next_token;
int tokenlen;
- guint16 flags;
- guint32 bytes;
- guint64 cas;
- guint8 opcode = 0xff;
- gchar response_chars[21]; /* cover uint64 (20 + 1) bytes*/
+ uint16_t flags;
+ uint32_t bytes;
+ uint64_t cas;
+ uint8_t opcode = 0xff;
+ char response_chars[21]; /* cover uint64 (20 + 1) bytes*/
/* expecting to read 'bytes' number of bytes from the buffer. */
while (tvb_offset_exists (tvb, offset)) {
/* Find the end of the line. */
linelen = tvb_find_line_end (tvb, offset, -1, &next_offset,
- FALSE);
+ false);
if (linelen < 0) {
/* header is out of the packet limits. */
return -1;
@@ -1191,7 +1191,7 @@ get_response_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
if (tokenlen == 0) {
return -1;
}
- dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, TRUE);
+ dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, true);
offset += (int) (next_token - line);
line = next_token;
@@ -1203,7 +1203,7 @@ get_response_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- flags = (guint16) strtoul (response_chars, NULL, 10);
+ flags = (uint16_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint (tree, hf_flags, tvb, offset, tokenlen, flags);
offset += (int) (next_token - line);
@@ -1217,7 +1217,7 @@ get_response_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- bytes = (guint32) strtoul (response_chars, NULL, 10);
+ bytes = (uint32_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint (tree, hf_value_length, tvb, offset, tokenlen, bytes);
offset += (int) (next_token - line);
@@ -1233,7 +1233,7 @@ get_response_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- cas = (guint64) strtoul (response_chars, NULL, 10);
+ cas = (uint64_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint64 (tree, hf_cas, tvb, offset, tokenlen, cas);
/* CRLF */
@@ -1257,9 +1257,9 @@ get_response_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
/* Basic memcache response dissector. */
static int
memcache_response_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
- const guchar *line, const guchar *lineend, guint8 opcode)
+ const unsigned char *line, const unsigned char *lineend, uint8_t opcode)
{
- const guchar *next_token;
+ const unsigned char *next_token;
int tokenlen;
switch (opcode) {
@@ -1349,16 +1349,16 @@ memcache_response_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
/* Basic memcache request dissector. */
static int
memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset,
- const guchar *line, const guchar *lineend, guint8 opcode)
+ const unsigned char *line, const unsigned char *lineend, uint8_t opcode)
{
- const guchar *next_token;
+ const unsigned char *next_token;
int tokenlen;
- guint16 flags;
- guint32 expiration;
- guint32 bytes;
- guint64 cas;
- gchar response_chars[21]; /* cover uint64 (20 + 1) bytes*/
+ uint16_t flags;
+ uint32_t expiration;
+ uint32_t bytes;
+ uint64_t cas;
+ char response_chars[21]; /* cover uint64 (20 + 1) bytes*/
/* command. */
tokenlen = get_token_len (line, lineend, &next_token);
@@ -1384,7 +1384,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
return -1;
}
- dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, TRUE);
+ dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, true);
offset += (int) (next_token - line);
line = next_token;
@@ -1396,7 +1396,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- flags = (guint16) strtoul (response_chars, NULL, 10);
+ flags = (uint16_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint (tree, hf_flags, tvb, offset, tokenlen, flags);
offset += (int) (next_token - line);
@@ -1410,7 +1410,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- expiration = (guint32) strtoul (response_chars, NULL, 10);
+ expiration = (uint32_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint (tree, hf_expiration, tvb, offset, tokenlen, expiration);
offset += (int) (next_token - line);
@@ -1424,7 +1424,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- bytes = (guint32) strtoul (response_chars, NULL, 10);
+ bytes = (uint32_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint (tree, hf_value_length, tvb, offset, tokenlen, bytes);
offset += (int) (next_token - line);
@@ -1439,7 +1439,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- cas = (guint64) strtoul (response_chars, NULL, 10);
+ cas = (uint64_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint64 (tree, hf_cas, tvb, offset, tokenlen, cas);
offset += (int) (next_token - line);
@@ -1472,7 +1472,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (tokenlen == 0) {
return -1;
}
- dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, TRUE);
+ dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, true);
offset += (int) (next_token - line);
line = next_token;
@@ -1515,7 +1515,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
return -1;
}
/* dissect key. */
- dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, TRUE);
+ dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, true);
offset += (int) (next_token - line);
line = next_token;
@@ -1533,7 +1533,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- expiration = (guint32) strtoul (response_chars, NULL, 10);
+ expiration = (uint32_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint (tree, hf_expiration, tvb, offset, tokenlen, expiration);
}
offset += (int) (next_token - line);
@@ -1563,7 +1563,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (tokenlen == 0) {
return offset; /* CRLF */
}
- dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, TRUE);
+ dissect_key (tvb, pinfo, tree, offset, tokenlen, opcode, true);
offset += (int) (next_token - line);
line = next_token;
}
@@ -1604,7 +1604,7 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
memcpy (response_chars, line, tokenlen);
response_chars[tokenlen] = '\0';
- expiration = (guint32) strtoul (response_chars, NULL, 10);
+ expiration = (uint32_t) strtoul (response_chars, NULL, 10);
proto_tree_add_uint (tree, hf_expiration, tvb, offset, tokenlen, expiration);
}
offset += (int) (next_token - line);
@@ -1655,12 +1655,12 @@ memcache_request_dissector (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
* is a response.
*/
static int
-is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
- memcache_type_t *type, int *expect_content_length,
+is_memcache_request_or_reply (const char *data, int linelen, uint8_t *opcode,
+ memcache_type_t *type, bool *expect_content_length,
ReqRespDissector *reqresp_dissector)
{
- const guchar *ptr = (const guchar *)data;
- int is_request_or_response = FALSE;
+ const unsigned char *ptr = (const unsigned char *)data;
+ bool is_request_or_response = false;
int indx = 0;
/* look for a space */
@@ -1677,14 +1677,14 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
case 2:
if (strncmp (data, "OK", indx) == 0) {
*type = MEMCACHE_RESPONSE;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
case 3:
if (strncmp (data, "END", indx) == 0) {
*type = MEMCACHE_RESPONSE;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
@@ -1692,7 +1692,7 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "STAT", indx) == 0) {
*opcode = OP_STAT;
*type = MEMCACHE_RESPONSE;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
@@ -1700,8 +1700,8 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "VALUE", indx) == 0) {
*opcode = OP_GET;
*type = MEMCACHE_RESPONSE;
- *expect_content_length = TRUE;
- is_request_or_response = TRUE;
+ *expect_content_length = true;
+ is_request_or_response = true;
}
break;
@@ -1709,7 +1709,7 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "EXISTS", indx) == 0 ||
strncmp (data, "STORED", indx) == 0) {
*type = MEMCACHE_RESPONSE;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
@@ -1717,25 +1717,25 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "VERSION", indx) == 0) {
*opcode = OP_VERSION;
*type = MEMCACHE_RESPONSE;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
} else if (strncmp (data, "DELETED", indx) == 0) {
*opcode = OP_DELETE;
*type = MEMCACHE_RESPONSE;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
case 9:
if (strncmp (data, "NOT_FOUND", indx) == 0) {
*type = MEMCACHE_RESPONSE;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
case 10:
if (strncmp (data, "NOT_STORED", indx) == 0) {
*type = MEMCACHE_RESPONSE;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
@@ -1754,22 +1754,22 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "get", indx) == 0) {
*opcode = OP_GET;
*type = MEMCACHE_REQUEST;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
} else if (strncmp (data, "set", indx) == 0) {
*opcode = OP_SET;
*type = MEMCACHE_REQUEST;
- *expect_content_length = TRUE;
- is_request_or_response = TRUE;
+ *expect_content_length = true;
+ is_request_or_response = true;
} else if (strncmp (data, "add", indx) == 0) {
*opcode = OP_ADD;
*type = MEMCACHE_REQUEST;
- *expect_content_length = TRUE;
- is_request_or_response = TRUE;
+ *expect_content_length = true;
+ is_request_or_response = true;
} else if (strncmp (data, "cas", indx) == 0) {
*opcode = OP_CAS;
*type = MEMCACHE_REQUEST;
- *expect_content_length = TRUE;
- is_request_or_response = TRUE;
+ *expect_content_length = true;
+ is_request_or_response = true;
}
break;
@@ -1777,19 +1777,19 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "gets", indx) == 0) {
*opcode = OP_GETS;
*type = MEMCACHE_REQUEST;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
} else if (strncmp (data, "incr", indx) == 0) {
*opcode = OP_INCREMENT;
*type = MEMCACHE_REQUEST;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
} else if (strncmp (data, "decr", indx) == 0) {
*opcode = OP_DECREMENT;
*type = MEMCACHE_REQUEST;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
} else if (strncmp (data, "quit", indx) == 0) {
*opcode = OP_QUIT;
*type = MEMCACHE_REQUEST;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
@@ -1797,7 +1797,7 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "stats", indx) == 0) {
*opcode = OP_STAT;
*type = MEMCACHE_REQUEST;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
@@ -1805,12 +1805,12 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "append", indx) == 0) {
*opcode = OP_APPEND;
*type = MEMCACHE_REQUEST;
- *expect_content_length = TRUE;
- is_request_or_response = TRUE;
+ *expect_content_length = true;
+ is_request_or_response = true;
} else if (strncmp (data, "delete", indx) == 0) {
*opcode = OP_DELETE;
*type = MEMCACHE_REQUEST;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
@@ -1818,17 +1818,17 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "replace", indx) == 0) {
*opcode = OP_REPLACE;
*type = MEMCACHE_REQUEST;
- *expect_content_length = TRUE;
- is_request_or_response = TRUE;
+ *expect_content_length = true;
+ is_request_or_response = true;
} else if (strncmp (data, "prepend", indx) == 0) {
*opcode = OP_PREPEND;
*type = MEMCACHE_REQUEST;
- *expect_content_length = TRUE;
- is_request_or_response = TRUE;
+ *expect_content_length = true;
+ is_request_or_response = true;
} else if (strncmp (data, "version", indx) == 0) {
*opcode = OP_VERSION;
*type = MEMCACHE_REQUEST;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
@@ -1836,7 +1836,7 @@ is_memcache_request_or_reply (const gchar *data, int linelen, guint8 *opcode,
if (strncmp (data, "flush_all", indx) == 0) {
*opcode = OP_FLUSH;
*type = MEMCACHE_REQUEST;
- is_request_or_response = TRUE;
+ is_request_or_response = true;
}
break;
@@ -1884,10 +1884,10 @@ dissect_memcache_text (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static int
dissect_memcache_tcp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
- gint offset = 0;
- guint8 magic;
+ int offset = 0;
+ uint8_t magic;
- magic = tvb_get_guint8 (tvb, offset);
+ magic = tvb_get_uint8 (tvb, offset);
if (try_val_to_str (magic, magic_vals) != NULL) {
tcp_dissect_pdus (tvb, pinfo, tree, memcache_desegment_body, 12,
@@ -1903,10 +1903,10 @@ dissect_memcache_tcp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void*
static int
dissect_memcache_udp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
- gint offset = 0;
- guint8 magic;
+ int offset = 0;
+ uint8_t magic;
- magic = tvb_get_guint8 (tvb, offset);
+ magic = tvb_get_uint8 (tvb, offset);
if (try_val_to_str (magic, magic_vals) != NULL) {
dissect_memcache (tvb, pinfo, tree, data);
@@ -2076,7 +2076,7 @@ proto_register_memcache (void)
"Value of a stat", HFILL } },
};
- static gint *ett[] = {
+ static int *ett[] = {
&ett_memcache,
&ett_extras
};