Index: epan/tvbuff.c =================================================================== --- epan/tvbuff.c (revision 31659) +++ epan/tvbuff.c (working copy) @@ -52,11 +52,11 @@ #include "proto.h" /* XXX - only used for DISSECTOR_ASSERT, probably a new header file? */ static const guint8* -ensure_contiguous_no_exception(tvbuff_t *tvb, gint offset, gint length, +ensure_contiguous_no_exception(tvbuff_t *tvb, const gint offset, const gint length, int *exception); static const guint8* -ensure_contiguous(tvbuff_t *tvb, gint offset, gint length); +ensure_contiguous(tvbuff_t *tvb, const gint offset, const gint length); #if GLIB_CHECK_VERSION(2,10,0) #else @@ -87,7 +87,7 @@ } static void -tvb_init(tvbuff_t *tvb, tvbuff_type type) +tvb_init(tvbuff_t *tvb, const tvbuff_type type) { tvb_backing_t *backing; tvb_comp_t *composite; @@ -130,7 +130,7 @@ tvbuff_t* -tvb_new(tvbuff_type type) +tvb_new(const tvbuff_type type) { tvbuff_t *tvb; @@ -146,7 +146,7 @@ } static tvbuff_t* -tvb_new_with_subset(guint subset_tvb_offset, guint subset_tvb_length) +tvb_new_with_subset(const guint subset_tvb_offset, const guint subset_tvb_length) { tvbuff_t *tvb = tvb_new(TVBUFF_SUBSET); tvb->tvbuffs.subset.offset = subset_tvb_offset; @@ -217,7 +217,7 @@ } guint -tvb_increment_usage_count(tvbuff_t* tvb, guint count) +tvb_increment_usage_count(tvbuff_t* tvb, const guint count) { tvb->usage_count += count; @@ -225,7 +225,7 @@ } guint -tvb_decrement_usage_count(tvbuff_t* tvb, guint count) +tvb_decrement_usage_count(tvbuff_t* tvb, const guint count) { if (tvb->usage_count <= count) { tvb->usage_count = 1; @@ -256,7 +256,7 @@ void -tvb_set_free_cb(tvbuff_t* tvb, tvbuff_free_cb_t func) +tvb_set_free_cb(tvbuff_t* tvb, const tvbuff_free_cb_t func) { DISSECTOR_ASSERT(tvb); DISSECTOR_ASSERT(tvb->type == TVBUFF_REAL_DATA); @@ -281,7 +281,7 @@ } static void -tvb_set_real_data_no_exceptions(tvbuff_t* tvb, const guint8* data, guint length, gint reported_length) +tvb_set_real_data_no_exceptions(tvbuff_t* tvb, const guint8* data, const guint length, const gint reported_length) { tvb->real_data = data; tvb->length = length; @@ -290,7 +290,7 @@ } void -tvb_set_real_data(tvbuff_t* tvb, const guint8* data, guint length, gint reported_length) +tvb_set_real_data(tvbuff_t* tvb, const guint8* data, const guint length, const gint reported_length) { DISSECTOR_ASSERT(tvb); DISSECTOR_ASSERT(tvb->type == TVBUFF_REAL_DATA); @@ -302,7 +302,7 @@ } tvbuff_t* -tvb_new_real_data(const guint8* data, guint length, gint reported_length) +tvb_new_real_data(const guint8* data, const guint length, const gint reported_length) { tvbuff_t *tvb; @@ -322,7 +322,7 @@ } tvbuff_t* -tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, guint length, gint reported_length) +tvb_new_child_real_data(tvbuff_t *parent, const guint8* data, const guint length, const gint reported_length) { tvbuff_t *tvb = tvb_new_real_data(data, length, reported_length); if (tvb) { @@ -346,7 +346,7 @@ * that gets an exception, so the error is reported as an error in that * protocol rather than the containing protocol. */ static gboolean -compute_offset_length(guint tvb_length, guint tvb_reported_length, gint offset, gint length, +compute_offset_length(guint tvb_length, const guint tvb_reported_length, const gint offset, const gint length, guint *offset_ptr, guint *length_ptr, int *exception) { DISSECTOR_ASSERT(offset_ptr); @@ -410,7 +410,7 @@ static gboolean -check_offset_length_no_exception(guint tvb_length, guint tvb_reported_length, gint offset, gint length, +check_offset_length_no_exception(guint tvb_length, const guint tvb_reported_length, const gint offset, const gint length, guint *offset_ptr, guint *length_ptr, int *exception) { guint end_offset; @@ -460,7 +460,7 @@ * either is out of bounds. Sets integer ptrs to the new offset * and length. */ static void -check_offset_length(guint tvb_length, guint tvb_reported_length, gint offset, gint length, +check_offset_length(guint tvb_length, const guint tvb_reported_length, const gint offset, const gint length, guint *offset_ptr, guint *length_ptr) { int exception = 0; @@ -472,7 +472,7 @@ } static void -tvb_set_subset_no_exceptions(tvbuff_t *tvb, tvbuff_t *backing, gint reported_length) +tvb_set_subset_no_exceptions(tvbuff_t *tvb, tvbuff_t *backing, const gint reported_length) { tvb->tvbuffs.subset.tvb = backing; tvb->length = tvb->tvbuffs.subset.length; @@ -495,7 +495,7 @@ void tvb_set_subset(tvbuff_t *tvb, tvbuff_t *backing, - gint backing_offset, gint backing_length, gint reported_length) + const gint backing_offset, const gint backing_length, const gint reported_length) { DISSECTOR_ASSERT(tvb); DISSECTOR_ASSERT(tvb->type == TVBUFF_SUBSET); @@ -511,7 +511,7 @@ } tvbuff_t* -tvb_new_subset(tvbuff_t *backing, gint backing_offset, gint backing_length, gint reported_length) +tvb_new_subset(tvbuff_t *backing, const gint backing_offset, const gint backing_length, const gint reported_length) { tvbuff_t *tvb; guint subset_tvb_offset; @@ -539,7 +539,7 @@ } tvbuff_t* -tvb_new_subset_remaining(tvbuff_t *backing, gint backing_offset) +tvb_new_subset_remaining(tvbuff_t *backing, const gint backing_offset) { tvbuff_t *tvb; guint subset_tvb_offset; @@ -626,7 +626,7 @@ guint -tvb_length(tvbuff_t* tvb) +tvb_length(const tvbuff_t* tvb) { DISSECTOR_ASSERT(tvb && tvb->initialized); @@ -634,7 +634,7 @@ } gint -tvb_length_remaining(tvbuff_t *tvb, gint offset) +tvb_length_remaining(const tvbuff_t *tvb, const gint offset) { guint abs_offset, abs_length; @@ -649,7 +649,7 @@ } guint -tvb_ensure_length_remaining(tvbuff_t *tvb, gint offset) +tvb_ensure_length_remaining(const tvbuff_t *tvb, const gint offset) { guint abs_offset, abs_length; int exception; @@ -679,7 +679,7 @@ /* Validates that 'length' bytes are available starting from * offset (pos/neg). Does not throw an exception. */ gboolean -tvb_bytes_exist(tvbuff_t *tvb, gint offset, gint length) +tvb_bytes_exist(const tvbuff_t *tvb, const gint offset, const gint length) { guint abs_offset, abs_length; @@ -699,7 +699,7 @@ /* Validates that 'length' bytes are available starting from * offset (pos/neg). Throws an exception if they aren't. */ void -tvb_ensure_bytes_exist(tvbuff_t *tvb, gint offset, gint length) +tvb_ensure_bytes_exist(const tvbuff_t *tvb, const gint offset, const gint length) { guint abs_offset, abs_length; @@ -722,7 +722,7 @@ } gboolean -tvb_offset_exists(tvbuff_t *tvb, gint offset) +tvb_offset_exists(const tvbuff_t *tvb, const gint offset) { guint abs_offset, abs_length; @@ -739,7 +739,7 @@ } guint -tvb_reported_length(tvbuff_t* tvb) +tvb_reported_length(const tvbuff_t* tvb) { DISSECTOR_ASSERT(tvb && tvb->initialized); @@ -747,7 +747,7 @@ } gint -tvb_reported_length_remaining(tvbuff_t *tvb, gint offset) +tvb_reported_length_remaining(const tvbuff_t *tvb, const gint offset) { guint abs_offset, abs_length; @@ -771,7 +771,7 @@ Also adjusts the data length. */ void -tvb_set_reported_length(tvbuff_t* tvb, guint reported_length) +tvb_set_reported_length(tvbuff_t* tvb, const guint reported_length) { DISSECTOR_ASSERT(tvb && tvb->initialized); @@ -807,7 +807,7 @@ #endif static guint -offset_from_real_beginning(tvbuff_t *tvb, guint counter) +offset_from_real_beginning(const tvbuff_t *tvb, const guint counter) { tvbuff_t *member; @@ -827,14 +827,14 @@ } guint -tvb_offset_from_real_beginning(tvbuff_t *tvb) +tvb_offset_from_real_beginning(const tvbuff_t *tvb) { return offset_from_real_beginning(tvb, 0); } static const guint8* -composite_ensure_contiguous_no_exception(tvbuff_t *tvb, guint abs_offset, - guint abs_length) +composite_ensure_contiguous_no_exception(tvbuff_t *tvb, const guint abs_offset, + const guint abs_length) { guint i, num_members; tvb_comp_t *composite; @@ -877,7 +877,7 @@ } static const guint8* -ensure_contiguous_no_exception(tvbuff_t *tvb, gint offset, gint length, +ensure_contiguous_no_exception(tvbuff_t *tvb, const gint offset, const gint length, int *exception) { guint abs_offset, abs_length; @@ -912,7 +912,7 @@ } static const guint8* -ensure_contiguous(tvbuff_t *tvb, gint offset, gint length) +ensure_contiguous(tvbuff_t *tvb, const gint offset, const gint length) { int exception; const guint8 *p; @@ -926,7 +926,7 @@ } static const guint8* -fast_ensure_contiguous(tvbuff_t *tvb, gint offset, guint length) +fast_ensure_contiguous(tvbuff_t *tvb, const gint offset, const guint length) { guint end_offset; guint u_offset; @@ -955,7 +955,7 @@ } static const guint8* -guint8_find(const guint8* haystack, size_t haystacklen, guint8 needle) +guint8_find(const guint8* haystack, const size_t haystacklen, const guint8 needle) { const guint8 *b; int i; @@ -1053,7 +1053,7 @@ } void* -tvb_memcpy(tvbuff_t *tvb, void* target, gint offset, size_t length) +tvb_memcpy(tvbuff_t *tvb, void* target, const gint offset, size_t length) { guint abs_offset, abs_length; @@ -1106,7 +1106,7 @@ * meaning "to the end of the buffer"? */ void* -tvb_memdup(tvbuff_t *tvb, gint offset, size_t length) +tvb_memdup(tvbuff_t *tvb, const gint offset, size_t length) { guint abs_offset, abs_length; void *duped; @@ -1136,7 +1136,7 @@ * after the current packet has been dissected. */ void* -ep_tvb_memdup(tvbuff_t *tvb, gint offset, size_t length) +ep_tvb_memdup(tvbuff_t *tvb, const gint offset, size_t length) { guint abs_offset, abs_length; void *duped; @@ -1152,14 +1152,14 @@ const guint8* -tvb_get_ptr(tvbuff_t *tvb, gint offset, gint length) +tvb_get_ptr(tvbuff_t *tvb, const gint offset, const gint length) { return ensure_contiguous(tvb, offset, length); } /* ---------------- */ guint8 -tvb_get_guint8(tvbuff_t *tvb, gint offset) +tvb_get_guint8(tvbuff_t *tvb, const gint offset) { const guint8* ptr; @@ -1168,7 +1168,7 @@ } guint16 -tvb_get_ntohs(tvbuff_t *tvb, gint offset) +tvb_get_ntohs(tvbuff_t *tvb, const gint offset) { const guint8* ptr; @@ -1177,7 +1177,7 @@ } guint32 -tvb_get_ntoh24(tvbuff_t *tvb, gint offset) +tvb_get_ntoh24(tvbuff_t *tvb, const gint offset) { const guint8* ptr; @@ -1186,7 +1186,7 @@ } guint32 -tvb_get_ntohl(tvbuff_t *tvb, gint offset) +tvb_get_ntohl(tvbuff_t *tvb, const gint offset) { const guint8* ptr; @@ -1195,7 +1195,7 @@ } guint64 -tvb_get_ntoh64(tvbuff_t *tvb, gint offset) +tvb_get_ntoh64(tvbuff_t *tvb, const gint offset) { const guint8* ptr; @@ -1245,13 +1245,13 @@ #define IEEE_SP_BIAS ((1 << (IEEE_SP_EXP_WIDTH - 1)) - 1) static int -ieee_float_is_zero(guint32 w) +ieee_float_is_zero(const guint32 w) { return ((w & ~IEEE_SP_SIGN_MASK) == 0); } static gfloat -get_ieee_float(guint32 w) +get_ieee_float(const guint32 w) { long sign; long exponent; @@ -1306,13 +1306,13 @@ #define IEEE_DP_BIAS ((1 << (IEEE_DP_EXP_WIDTH - 1)) - 1) static int -ieee_double_is_zero(guint64 w) +ieee_double_is_zero(const guint64 w) { return ((w & ~IEEE_SP_SIGN_MASK) == 0); } static gdouble -get_ieee_double(guint64 w) +get_ieee_double(const guint64 w) { gint64 sign; gint64 exponent; @@ -1358,7 +1358,7 @@ * "float" format? */ gfloat -tvb_get_ntohieee_float(tvbuff_t *tvb, int offset) +tvb_get_ntohieee_float(tvbuff_t *tvb, const int offset) { #if defined(vax) return get_ieee_float(tvb_get_ntohl(tvb, offset)); @@ -1378,7 +1378,7 @@ * big-endian form, and returns a "double". */ gdouble -tvb_get_ntohieee_double(tvbuff_t *tvb, int offset) +tvb_get_ntohieee_double(tvbuff_t *tvb, const int offset) { #if defined(vax) union { @@ -1407,7 +1407,7 @@ } guint16 -tvb_get_letohs(tvbuff_t *tvb, gint offset) +tvb_get_letohs(tvbuff_t *tvb, const gint offset) { const guint8* ptr; @@ -1416,7 +1416,7 @@ } guint32 -tvb_get_letoh24(tvbuff_t *tvb, gint offset) +tvb_get_letoh24(tvbuff_t *tvb, const gint offset) { const guint8* ptr; @@ -1425,7 +1425,7 @@ } guint32 -tvb_get_letohl(tvbuff_t *tvb, gint offset) +tvb_get_letohl(tvbuff_t *tvb, const gint offset) { const guint8* ptr; @@ -1434,7 +1434,7 @@ } guint64 -tvb_get_letoh64(tvbuff_t *tvb, gint offset) +tvb_get_letoh64(tvbuff_t *tvb, const gint offset) { const guint8* ptr; @@ -1451,7 +1451,7 @@ * "float" format? */ gfloat -tvb_get_letohieee_float(tvbuff_t *tvb, int offset) +tvb_get_letohieee_float(tvbuff_t *tvb, const int offset) { #if defined(vax) return get_ieee_float(tvb_get_letohl(tvb, offset)); @@ -1471,7 +1471,7 @@ * little-endian form, and returns a "double". */ gdouble -tvb_get_letohieee_double(tvbuff_t *tvb, int offset) +tvb_get_letohieee_double(tvbuff_t *tvb, const int offset) { #if defined(vax) union { @@ -1503,7 +1503,7 @@ * We do *not* convert them to host byte order; we leave them in * network byte order. */ guint32 -tvb_get_ipv4(tvbuff_t *tvb, gint offset) +tvb_get_ipv4(tvbuff_t *tvb, const gint offset) { const guint8* ptr; guint32 addr; @@ -1515,7 +1515,7 @@ /* Fetch an IPv6 address. */ void -tvb_get_ipv6(tvbuff_t *tvb, gint offset, struct e_in6_addr *addr) +tvb_get_ipv6(tvbuff_t *tvb, const gint offset, struct e_in6_addr *addr) { const guint8* ptr; @@ -1525,7 +1525,7 @@ /* Fetch a GUID. */ void -tvb_get_ntohguid(tvbuff_t *tvb, gint offset, e_guid_t *guid) +tvb_get_ntohguid(tvbuff_t *tvb, const gint offset, e_guid_t *guid) { ensure_contiguous(tvb, offset, sizeof(*guid)); guid->data1 = tvb_get_ntohl(tvb, offset); @@ -1535,7 +1535,7 @@ } void -tvb_get_letohguid(tvbuff_t *tvb, gint offset, e_guid_t *guid) +tvb_get_letohguid(tvbuff_t *tvb, const gint offset, e_guid_t *guid) { ensure_contiguous(tvb, offset, sizeof(*guid)); guid->data1 = tvb_get_letohl(tvb, offset); @@ -1545,7 +1545,7 @@ } void -tvb_get_guid(tvbuff_t *tvb, gint offset, e_guid_t *guid, gboolean little_endian) +tvb_get_guid(tvbuff_t *tvb, const gint offset, e_guid_t *guid, const gboolean little_endian) { if (little_endian) { tvb_get_letohguid(tvb, offset, guid); @@ -1579,7 +1579,7 @@ /* Get 1 - 8 bits */ guint8 -tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, gint no_of_bits) +tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits) { gint offset; guint16 value = 0; @@ -1624,7 +1624,7 @@ }; guint16 -tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, gint no_of_bits,gboolean little_endian) +tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits,const gboolean little_endian) { gint offset; guint16 value = 0; @@ -1678,7 +1678,7 @@ }; guint32 -tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian) +tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian) { gint offset; guint32 value = 0; @@ -1720,7 +1720,7 @@ } guint64 -tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian) +tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian) { gint offset; guint64 value = 0; @@ -1762,7 +1762,7 @@ } guint32 -tvb_get_bits(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian) +tvb_get_bits(tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const gboolean little_endian) { /* This function can handle only up to 32 requested bits */ if (no_of_bits > 32) @@ -1791,7 +1791,7 @@ * in that case, -1 will be returned if the boundary is reached before * finding needle. */ gint -tvb_find_guint8(tvbuff_t *tvb, gint offset, gint maxlength, guint8 needle) +tvb_find_guint8(tvbuff_t *tvb, const gint offset, const gint maxlength, const guint8 needle) { const guint8 *result; guint abs_offset, junk_length; @@ -1856,7 +1856,7 @@ * in that case, -1 will be returned if the boundary is reached before * finding needle. */ gint -tvb_pbrk_guint8(tvbuff_t *tvb, gint offset, gint maxlength, const guint8 *needles) +tvb_pbrk_guint8(tvbuff_t *tvb, const gint offset, const gint maxlength, const guint8 *needles) { const guint8 *result; guint abs_offset, junk_length; @@ -1919,7 +1919,7 @@ * If the NUL isn't found, it throws the appropriate exception. */ guint -tvb_strsize(tvbuff_t *tvb, gint offset) +tvb_strsize(tvbuff_t *tvb, const gint offset) { guint abs_offset, junk_length; gint nul_offset; @@ -1953,7 +1953,7 @@ * of tvbuff. * Returns -1 if 'maxlength' reached before finding EOS. */ gint -tvb_strnlen(tvbuff_t *tvb, gint offset, guint maxlength) +tvb_strnlen(tvbuff_t *tvb, const gint offset, const guint maxlength) { gint result_offset; guint abs_offset, junk_length; @@ -1981,7 +1981,7 @@ * it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1. */ gint -tvb_strneql(tvbuff_t *tvb, gint offset, const gchar *str, gint size) +tvb_strneql(tvbuff_t *tvb, const gint offset, const gchar *str, const gint size) { const guint8 *ptr; @@ -2008,7 +2008,7 @@ * 0 if it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1. */ gint -tvb_strncaseeql(tvbuff_t *tvb, gint offset, const gchar *str, gint size) +tvb_strncaseeql(tvbuff_t *tvb, const gint offset, const gchar *str, const gint size) { const guint8 *ptr; @@ -2035,7 +2035,7 @@ * it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1. */ gint -tvb_memeql(tvbuff_t *tvb, gint offset, const guint8 *str, size_t size) +tvb_memeql(tvbuff_t *tvb, const gint offset, const guint8 *str, size_t size) { const guint8 *ptr; @@ -2062,7 +2062,7 @@ * free the result returned. The len parameter is the number of guint16's * to convert from Unicode. */ char * -tvb_fake_unicode(tvbuff_t *tvb, int offset, int len, gboolean little_endian) +tvb_fake_unicode(tvbuff_t *tvb, int offset, const int len, const gboolean little_endian) { char *buffer; int i; @@ -2097,7 +2097,7 @@ * when wireshark starts decoding the next packet. */ char * -tvb_get_ephemeral_faked_unicode(tvbuff_t *tvb, int offset, int len, gboolean little_endian) +tvb_get_ephemeral_faked_unicode(tvbuff_t *tvb, int offset, const int len, const gboolean little_endian) { char *buffer; int i; @@ -2128,7 +2128,7 @@ */ gchar * -tvb_format_text(tvbuff_t *tvb, gint offset, gint size) +tvb_format_text(tvbuff_t *tvb, const gint offset, const gint size) { const guint8 *ptr; gint len = size; @@ -2146,7 +2146,7 @@ */ gchar * -tvb_format_text_wsp(tvbuff_t *tvb, gint offset, gint size) +tvb_format_text_wsp(tvbuff_t *tvb, const gint offset, const gint size) { const guint8 *ptr; gint len = size; @@ -2167,7 +2167,7 @@ * the null padding characters as "\000". */ gchar * -tvb_format_stringzpad(tvbuff_t *tvb, gint offset, gint size) +tvb_format_stringzpad(tvbuff_t *tvb, const gint offset, const gint size) { const guint8 *ptr, *p; gint len = size; @@ -2191,7 +2191,7 @@ * the null padding characters as "\000". */ gchar * -tvb_format_stringzpad_wsp(tvbuff_t *tvb, gint offset, gint size) +tvb_format_stringzpad_wsp(tvbuff_t *tvb, const gint offset, const gint size) { const guint8 *ptr, *p; gint len = size; @@ -2219,7 +2219,7 @@ * Throws an exception if the tvbuff ends before the string does. */ guint8 * -tvb_get_string(tvbuff_t *tvb, gint offset, gint length) +tvb_get_string(tvbuff_t *tvb, const gint offset, const gint length) { const guint8 *ptr; guint8 *strbuf = NULL; @@ -2249,7 +2249,7 @@ * after the current packet has been dissected. */ guint8 * -tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, gint length) +tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset, const gint length) { const guint8 *ptr; guint8 *strbuf = NULL; @@ -2278,7 +2278,7 @@ * when wireshark starts or opens a new capture. */ guint8 * -tvb_get_seasonal_string(tvbuff_t *tvb, gint offset, gint length) +tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const gint length) { const guint8 *ptr; guint8 *strbuf = NULL; @@ -2303,7 +2303,7 @@ * string (including the terminating null) through a pointer. */ guint8 * -tvb_get_stringz(tvbuff_t *tvb, gint offset, gint *lengthp) +tvb_get_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) { guint size; guint8 *strptr; @@ -2330,7 +2330,7 @@ * after the current packet has been dissected. */ guint8 * -tvb_get_ephemeral_stringz(tvbuff_t *tvb, gint offset, gint *lengthp) +tvb_get_ephemeral_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) { guint size; guint8 *strptr; @@ -2356,7 +2356,7 @@ * when wireshark starts or opens a new capture. */ guint8 * -tvb_get_seasonal_stringz(tvbuff_t *tvb, gint offset, gint *lengthp) +tvb_get_seasonal_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp) { guint size; guint8 *strptr; @@ -2388,7 +2388,7 @@ * including the terminating-NUL. */ static gint -_tvb_get_nstringz(tvbuff_t *tvb, gint offset, guint bufsize, guint8* buffer, +_tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* buffer, gint *bytes_copied) { gint stringlen; @@ -2472,7 +2472,7 @@ * at the correct spot, terminating the string. */ gint -tvb_get_nstringz(tvbuff_t *tvb, gint offset, guint bufsize, guint8* buffer) +tvb_get_nstringz(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* buffer) { gint bytes_copied; @@ -2486,7 +2486,7 @@ * a NUL is placed at the end of buffer to terminate it. */ gint -tvb_get_nstringz0(tvbuff_t *tvb, gint offset, guint bufsize, guint8* buffer) +tvb_get_nstringz0(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* buffer) { gint len, bytes_copied; @@ -2524,7 +2524,7 @@ */ gint tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, gint *next_offset, - gboolean desegment) + const gboolean desegment) { gint eob_offset; gint eol_offset; @@ -2780,7 +2780,7 @@ * character following offset or offset + maxlength -1 whichever * is smaller. */ -gint tvb_skip_wsp(tvbuff_t* tvb, gint offset, gint maxlength) +gint tvb_skip_wsp(tvbuff_t* tvb, const gint offset, const gint maxlength) { gint counter = offset; gint end = offset + maxlength,tvb_len; @@ -2804,7 +2804,7 @@ return (counter); } -gint tvb_skip_wsp_return(tvbuff_t* tvb, gint offset){ +gint tvb_skip_wsp_return(tvbuff_t* tvb, const gint offset){ gint counter = offset; gint end; guint8 tempchar; @@ -2824,7 +2824,7 @@ * separator. */ gchar * -tvb_bytes_to_str_punct(tvbuff_t *tvb, gint offset, gint len, gchar punct) +tvb_bytes_to_str_punct(tvbuff_t *tvb, const gint offset, const gint len, const gchar punct) { return bytes_to_str_punct(tvb_get_ptr(tvb, offset, len), len, punct); } @@ -2834,14 +2834,14 @@ * to the string with the formatted data. */ gchar * -tvb_bytes_to_str(tvbuff_t *tvb, gint offset, gint len) +tvb_bytes_to_str(tvbuff_t *tvb, const gint offset, const gint len) { return bytes_to_str(tvb_get_ptr(tvb, offset, len), len); } /* Find a needle tvbuff within a haystack tvbuff. */ gint -tvb_find_tvb(tvbuff_t *haystack_tvb, tvbuff_t *needle_tvb, gint haystack_offset) +tvb_find_tvb(tvbuff_t *haystack_tvb, tvbuff_t *needle_tvb, const gint haystack_offset) { guint haystack_abs_offset, haystack_abs_length; const guint8 *haystack_data; @@ -2884,7 +2884,7 @@ #undef TVB_Z_DEBUG tvbuff_t * -tvb_uncompress(tvbuff_t *tvb, int offset, int comprlen) +tvb_uncompress(tvbuff_t *tvb, const int offset, int comprlen) { gint err = Z_OK; guint bytes_out = 0; @@ -3136,13 +3136,17 @@ } #else tvbuff_t * -tvb_uncompress(tvbuff_t *tvb _U_, int offset _U_, int comprlen _U_) +tvb_uncompress(tvbuff_t *tvb _U_, const int offset _U_, int comprlen _U_) { return NULL; } #endif +<<<<<<< .mine +tvbuff_t* tvb_child_uncompress(tvbuff_t *parent _U_, tvbuff_t *tvb, const int offset, int comprlen) +======= tvbuff_t* tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb, int offset, int comprlen) +>>>>>>> .r31659 { tvbuff_t *new_tvb = tvb_uncompress(tvb, offset, comprlen); if (new_tvb) Index: epan/tvbuff.h =================================================================== --- epan/tvbuff.h (revision 31659) +++ epan/tvbuff.h (working copy) @@ -266,35 +266,35 @@ /* Get total length of buffer */ -extern guint tvb_length(tvbuff_t*); +extern guint tvb_length(const tvbuff_t*); /** Computes bytes to end of buffer, from offset (which can be negative, * to indicate bytes from end of buffer). Function returns -1 to * indicate that offset is out of bounds. No exception is thrown. */ -extern gint tvb_length_remaining(tvbuff_t*, gint offset); +extern gint tvb_length_remaining(const tvbuff_t*, const gint offset); /** Same as above, but throws an exception if the offset is out of bounds. */ -extern guint tvb_ensure_length_remaining(tvbuff_t*, gint offset); +extern guint tvb_ensure_length_remaining(const tvbuff_t*, const gint offset); /* Checks (w/o throwing exception) that the bytes referred to by * 'offset'/'length' actually exist in the buffer */ -extern gboolean tvb_bytes_exist(tvbuff_t*, gint offset, gint length); +extern gboolean tvb_bytes_exist(const tvbuff_t*, const gint offset, const gint length); /** Checks that the bytes referred to by 'offset'/'length' actually exist * in the buffer, and throws an exception if they aren't. */ -extern void tvb_ensure_bytes_exist(tvbuff_t *tvb, gint offset, gint length); +extern void tvb_ensure_bytes_exist(const tvbuff_t *tvb, const gint offset, const gint length); /* Checks (w/o throwing exception) that offset exists in buffer */ -extern gboolean tvb_offset_exists(tvbuff_t*, gint offset); +extern gboolean tvb_offset_exists(const tvbuff_t*, const gint offset); /* Get reported length of buffer */ -extern guint tvb_reported_length(tvbuff_t*); +extern guint tvb_reported_length(const tvbuff_t*); /** Computes bytes of reported packet data to end of buffer, from offset * (which can be negative, to indicate bytes from end of buffer). Function * returns -1 to indicate that offset is out of bounds. No exception is * thrown. */ -extern gint tvb_reported_length_remaining(tvbuff_t *tvb, gint offset); +extern gint tvb_reported_length_remaining(const tvbuff_t *tvb, const gint offset); /** Set the reported length of a tvbuff to a given value; used for protocols whose headers contain an explicit length and where the calling @@ -302,9 +302,9 @@ this protocol. Also adjusts the data length. */ -extern void tvb_set_reported_length(tvbuff_t*, guint); +extern void tvb_set_reported_length(tvbuff_t*, const guint); -extern guint tvb_offset_from_real_beginning(tvbuff_t *tvb); +extern guint tvb_offset_from_real_beginning(const tvbuff_t *tvb); /* Returns the offset from the first byte of real data. */ #define TVB_RAW_OFFSET(tvb) \ @@ -313,48 +313,48 @@ /************** START OF ACCESSORS ****************/ /* All accessors will throw an exception if appropriate */ -extern guint8 tvb_get_guint8(tvbuff_t*, gint offset); +extern guint8 tvb_get_guint8(tvbuff_t*, const gint offset); -extern guint16 tvb_get_ntohs(tvbuff_t*, gint offset); -extern guint32 tvb_get_ntoh24(tvbuff_t*, gint offset); -extern guint32 tvb_get_ntohl(tvbuff_t*, gint offset); -extern guint64 tvb_get_ntoh64(tvbuff_t*, gint offset); -extern gfloat tvb_get_ntohieee_float(tvbuff_t*, gint offset); -extern gdouble tvb_get_ntohieee_double(tvbuff_t*, gint offset); +extern guint16 tvb_get_ntohs(tvbuff_t*, const gint offset); +extern guint32 tvb_get_ntoh24(tvbuff_t*, const gint offset); +extern guint32 tvb_get_ntohl(tvbuff_t*, const gint offset); +extern guint64 tvb_get_ntoh64(tvbuff_t*, const gint offset); +extern gfloat tvb_get_ntohieee_float(tvbuff_t*, const gint offset); +extern gdouble tvb_get_ntohieee_double(tvbuff_t*, const gint offset); -extern guint16 tvb_get_letohs(tvbuff_t*, gint offset); -extern guint32 tvb_get_letoh24(tvbuff_t*, gint offset); -extern guint32 tvb_get_letohl(tvbuff_t*, gint offset); -extern guint64 tvb_get_letoh64(tvbuff_t*, gint offset); -extern gfloat tvb_get_letohieee_float(tvbuff_t*, gint offset); -extern gdouble tvb_get_letohieee_double(tvbuff_t*, gint offset); +extern guint16 tvb_get_letohs(tvbuff_t*, const gint offset); +extern guint32 tvb_get_letoh24(tvbuff_t*, const gint offset); +extern guint32 tvb_get_letohl(tvbuff_t*, const gint offset); +extern guint64 tvb_get_letoh64(tvbuff_t*, const gint offset); +extern gfloat tvb_get_letohieee_float(tvbuff_t*, const gint offset); +extern gdouble tvb_get_letohieee_double(tvbuff_t*, const gint offset); /** * Fetch an IPv4 address, in network byte order. * We do *not* convert it to host byte order; we leave it in * network byte order, as that's what its callers expect. */ -extern guint32 tvb_get_ipv4(tvbuff_t*, gint offset); +extern guint32 tvb_get_ipv4(tvbuff_t*, const gint offset); /* Fetch an IPv6 address. */ -extern void tvb_get_ipv6(tvbuff_t*, gint offset, struct e_in6_addr *addr); +extern void tvb_get_ipv6(tvbuff_t*, const gint offset, struct e_in6_addr *addr); /* Fetch a GUID. */ -extern void tvb_get_ntohguid(tvbuff_t *tvb, gint offset, e_guid_t *guid); -extern void tvb_get_letohguid(tvbuff_t *tvb, gint offset, e_guid_t *guid); -extern void tvb_get_guid(tvbuff_t *tvb, gint offset, e_guid_t *guid, gboolean little_endian); +extern void tvb_get_ntohguid(tvbuff_t *tvb, const gint offset, e_guid_t *guid); +extern void tvb_get_letohguid(tvbuff_t *tvb, const gint offset, e_guid_t *guid); +extern void tvb_get_guid(tvbuff_t *tvb, const gint offset, e_guid_t *guid, const gboolean little_endian); /* Fetch a specified number of bits from bit offset in a tvb */ -extern guint8 tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, gint no_of_bits); -extern guint16 tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian); -extern guint32 tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian); -extern guint64 tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian); +extern guint8 tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits); +extern guint16 tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian); +extern guint32 tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian); +extern guint64 tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, const gint no_of_bits, const gboolean little_endian); /* Fetch a specified number of bits from bit offset in a tvb, but allow number * of bits to range between 1 and 32. If the requested number of bits is known * beforehand, or its range can be handled by a single function of the group * above, use one of them instead. */ -extern guint32 tvb_get_bits(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian); +extern guint32 tvb_get_bits(tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const gboolean little_endian); /** Returns target for convenience. Does not suffer from possible * expense of tvb_get_ptr(), since this routine is smart enough @@ -362,17 +362,17 @@ * different TVBUFF_REAL_DATA tvbuffs. This function assumes that the * target memory is already allocated; it does not allocate or free the * target memory. */ -extern void* tvb_memcpy(tvbuff_t*, void* target, gint offset, size_t length); +extern void* tvb_memcpy(tvbuff_t*, void* target, const gint offset, size_t length); /** It is the user's responsibility to g_free() the memory allocated by * tvb_memdup(). Calls tvb_memcpy() */ -extern void* tvb_memdup(tvbuff_t*, gint offset, size_t length); +extern void* tvb_memdup(tvbuff_t*, const gint offset, size_t length); /* Same as above but the buffer returned from this function does not have to * be freed. It will be automatically freed after the packet is dissected. * Buffers allocated by this function are NOT persistent. */ -extern void* ep_tvb_memdup(tvbuff_t *tvb, gint offset, size_t length); +extern void* ep_tvb_memdup(tvbuff_t *tvb, const gint offset, size_t length); /** WARNING! This function is possibly expensive, temporarily allocating * another copy of the packet data. Furthermore, it's dangerous because once @@ -399,7 +399,7 @@ * and the pointer to the newly-contiguous data is returned. This dynamically- * allocated memory will be freed when the tvbuff is freed, after the * tvbuff_free_cb_t() is called, if any. */ -extern const guint8* tvb_get_ptr(tvbuff_t*, gint offset, gint length); +extern const guint8* tvb_get_ptr(tvbuff_t*, const gint offset, const gint length); /** Find first occurence of any of the needles in tvbuff, starting at offset. * Searches at most maxlength number of bytes; if maxlength is -1, searches @@ -408,15 +408,15 @@ * Will not throw an exception, even if maxlength exceeds boundary of tvbuff; * in that case, -1 will be returned if the boundary is reached before * finding needle. */ -extern gint tvb_find_guint8(tvbuff_t*, gint offset, gint maxlength, - guint8 needle); +extern gint tvb_find_guint8(tvbuff_t*, const gint offset, const gint maxlength, + const guint8 needle); /** Find first occurence of any of the needles in tvbuff, starting at offset. * Searches at most maxlength number of bytes. Returns the offset of the * found needle, or -1 if not found. Will not throw an exception, even if * maxlength exceeds boundary of tvbuff; in that case, -1 will be returned if * the boundary is reached before finding needle. */ -extern gint tvb_pbrk_guint8(tvbuff_t *, gint offset, gint maxlength, +extern gint tvb_pbrk_guint8(tvbuff_t *, const gint offset, const gint maxlength, const guint8 *needles); /** Find size of stringz (NUL-terminated string) by looking for terminating @@ -424,13 +424,13 @@ * * If the NUL isn't found, it throws the appropriate exception. */ -extern guint tvb_strsize(tvbuff_t *tvb, gint offset); +extern guint tvb_strsize(tvbuff_t *tvb, const gint offset); /** Find length of string by looking for end of zero terminated string, up to * 'maxlength' characters'; if 'maxlength' is -1, searches to end * of tvbuff. * Returns -1 if 'maxlength' reached before finding EOS. */ -extern gint tvb_strnlen(tvbuff_t*, gint offset, guint maxlength); +extern gint tvb_strnlen(tvbuff_t*, const gint offset, const guint maxlength); /** Convert a string from Unicode to ASCII. At the moment we fake it by * assuming all characters are ASCII )-: The len parameter is the number @@ -443,33 +443,33 @@ * automatically freed when wireshark starts dissecting * the next packet. */ -extern char *tvb_fake_unicode(tvbuff_t *tvb, int offset, int len, - gboolean little_endian); -extern char *tvb_get_ephemeral_faked_unicode(tvbuff_t *tvb, int offset, int len, - gboolean little_endian); +extern char *tvb_fake_unicode(tvbuff_t *tvb, int offset, const int len, + const gboolean little_endian); +extern char *tvb_get_ephemeral_faked_unicode(tvbuff_t *tvb, int offset, const int len, + const gboolean little_endian); /** * Format the data in the tvb from offset for size ... */ -extern gchar * tvb_format_text(tvbuff_t *tvb, gint offset, gint size); +extern gchar * tvb_format_text(tvbuff_t *tvb, const gint offset, const gint size); /** * Like "tvb_format_text()", but for 'wsp'; don't show * the characters as C-style escapes. */ -extern gchar * tvb_format_text_wsp(tvbuff_t *tvb, gint offset, gint size); +extern gchar * tvb_format_text_wsp(tvbuff_t *tvb, const gint offset, const gint size); /** * Like "tvb_format_text()", but for null-padded strings; don't show * the null padding characters as "\000". */ -extern gchar *tvb_format_stringzpad(tvbuff_t *tvb, gint offset, gint size); +extern gchar *tvb_format_stringzpad(tvbuff_t *tvb, const gint offset, const gint size); /** * Like "tvb_format_text_wsp()", but for null-padded strings; don't show * the null padding characters as "\000". */ -extern gchar *tvb_format_stringzpad_wsp(tvbuff_t *tvb, gint offset, gint size); +extern gchar *tvb_format_stringzpad_wsp(tvbuff_t *tvb, const gint offset, const gint size); /** @@ -492,9 +492,9 @@ * instead it will automatically be freed when a new capture * or file is opened. */ -extern guint8 *tvb_get_string(tvbuff_t *tvb, gint offset, gint length); -extern guint8 *tvb_get_ephemeral_string(tvbuff_t *tvb, gint offset, gint length); -extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, gint offset, gint length); +extern guint8 *tvb_get_string(tvbuff_t *tvb, const gint offset, const gint length); +extern guint8 *tvb_get_ephemeral_string(tvbuff_t *tvb, const gint offset, const gint length); +extern guint8 *tvb_get_seasonal_string(tvbuff_t *tvb, const gint offset, const gint length); /** @@ -519,7 +519,7 @@ */ extern guint8 *tvb_get_stringz(tvbuff_t *tvb, gint offset, gint *lengthp); extern guint8 *tvb_get_ephemeral_stringz(tvbuff_t *tvb, gint offset, gint *lengthp); -extern guint8 *tvb_get_seasonal_stringz(tvbuff_t *tvb, gint offset, gint *lengthp); +extern guint8 *tvb_get_seasonal_stringz(tvbuff_t *tvb, const gint offset, gint *lengthp); /** Looks for a stringz (NUL-terminated string) in tvbuff and copies * no more than bufsize number of bytes, including terminating NUL, to buffer. @@ -534,7 +534,7 @@ * is truncated with a NUL, albeit not at buffer[bufsize - 1], but * at the correct spot, terminating the string. */ -extern gint tvb_get_nstringz(tvbuff_t *tvb, gint offset, guint bufsize, +extern gint tvb_get_nstringz(tvbuff_t *tvb, const gint offset, guint bufsize, guint8* buffer); /** Like tvb_get_nstringz(), but never returns -1. The string is guaranteed to @@ -543,7 +543,7 @@ * * bufsize MUST be greater than 0. */ -extern gint tvb_get_nstringz0(tvbuff_t *tvb, gint offset, guint bufsize, +extern gint tvb_get_nstringz0(tvbuff_t *tvb, const gint offset, const guint bufsize, guint8* buffer); /** @@ -566,7 +566,7 @@ * terminator. (It's not set if we return -1.) */ extern gint tvb_find_line_end(tvbuff_t *tvb, gint offset, int len, - gint *next_offset, gboolean desegment); + gint *next_offset, const gboolean desegment); /** * Given a tvbuff, an offset into the tvbuff, and a length that starts @@ -606,16 +606,16 @@ * is smaller. */ -extern gint tvb_skip_wsp(tvbuff_t* tvb, gint offset, gint maxlength); +extern gint tvb_skip_wsp(tvbuff_t* tvb, const gint offset, const gint maxlength); -extern gint tvb_skip_wsp_return(tvbuff_t* tvb, gint offset); +extern gint tvb_skip_wsp_return(tvbuff_t* tvb, const gint offset); /** * Call strncmp after checking if enough chars left, returning 0 if * it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1. */ -extern gint tvb_strneql(tvbuff_t *tvb, gint offset, const gchar *str, - gint size); +extern gint tvb_strneql(tvbuff_t *tvb, const gint offset, const gchar *str, + const gint size); /** * Call g_ascii_strncasecmp after checking if enough chars left, returning @@ -628,7 +628,7 @@ * Call memcmp after checking if enough chars left, returning 0 if * it returns 0 (meaning "equal") and -1 otherwise, otherwise return -1. */ -extern gint tvb_memeql(tvbuff_t *tvb, gint offset, const guint8 *str, +extern gint tvb_memeql(tvbuff_t *tvb, const gint offset, const guint8 *str, size_t size); /** @@ -636,14 +636,14 @@ * to the string with the formatted data, with "punct" as a byte * separator. */ -extern gchar *tvb_bytes_to_str_punct(tvbuff_t *tvb, gint offset, gint len, - gchar punct); +extern gchar *tvb_bytes_to_str_punct(tvbuff_t *tvb, const gint offset, const gint len, + const gchar punct); /* * Format a bunch of data from a tvbuff as bytes, returning a pointer * to the string with the formatted data. */ -extern gchar *tvb_bytes_to_str(tvbuff_t *tvb, gint offset, gint len); +extern gchar *tvb_bytes_to_str(tvbuff_t *tvb, const gint offset, const gint len); #define TVB_GET_DS_TVB(tvb) \ (tvb->ds_tvb) @@ -653,21 +653,21 @@ * 'haystack', or -1 if 'needle' is not found. The index is relative * to the start of 'haystack', not 'haystack_offset'. */ extern gint tvb_find_tvb(tvbuff_t *haystack_tvb, tvbuff_t *needle_tvb, - gint haystack_offset); + const gint haystack_offset); /** * Uncompresses a zlib compressed packet inside a tvbuff at offset with * length comprlen. Returns an uncompressed tvbuffer if uncompression * succeeded or NULL if uncompression failed. */ -extern tvbuff_t* tvb_uncompress(tvbuff_t *tvb, int offset, int comprlen); +extern tvbuff_t* tvb_uncompress(tvbuff_t *tvb, const int offset, int comprlen); /** * Uncompresses a zlib compressed packet inside a tvbuff at offset with * length comprlen. Returns an uncompressed tvbuffer attached to tvb if uncompression * succeeded or NULL if uncompression failed. */ -extern tvbuff_t* tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb, int offset, int comprlen); +extern tvbuff_t* tvb_child_uncompress(tvbuff_t *parent, tvbuff_t *tvb, const int offset, int comprlen); /************** END OF ACCESSORS ****************/ Index: epan/proto.c =================================================================== --- epan/proto.c (revision 31659) +++ epan/proto.c (working copy) @@ -73,7 +73,7 @@ /* Candidates for assembler */ static int -wrs_count_bitshift(guint32 bitmask) +wrs_count_bitshift(const guint32 bitmask) { int bitshift = 0; @@ -143,20 +143,20 @@ static void fill_label_int(field_info *fi, gchar *label_str); static void fill_label_int64(field_info *fi, gchar *label_str); -static const char* hfinfo_uint_vals_format(header_field_info *hfinfo); -static const char* hfinfo_uint_format(header_field_info *hfinfo); -static const char* hfinfo_uint_value_format(header_field_info *hfinfo); -static const char* hfinfo_uint64_format(header_field_info *hfinfo); -static const char* hfinfo_int_vals_format(header_field_info *hfinfo); -static const char* hfinfo_int_format(header_field_info *hfinfo); -static const char* hfinfo_int_value_format(header_field_info *hfinfo); -static const char* hfinfo_int64_format(header_field_info *hfinfo); +static const char* hfinfo_uint_vals_format(const header_field_info *hfinfo); +static const char* hfinfo_uint_format(const header_field_info *hfinfo); +static const char* hfinfo_uint_value_format(const header_field_info *hfinfo); +static const char* hfinfo_uint64_format(const header_field_info *hfinfo); +static const char* hfinfo_int_vals_format(const header_field_info *hfinfo); +static const char* hfinfo_int_format(const header_field_info *hfinfo); +static const char* hfinfo_int_value_format(const header_field_info *hfinfo); +static const char* hfinfo_int64_format(const header_field_info *hfinfo); static proto_item* proto_tree_add_node(proto_tree *tree, field_info *fi); static header_field_info * -get_hfi_and_length(int hfindex, tvbuff_t *tvb, gint start, gint *length, +get_hfi_and_length(int hfindex, tvbuff_t *tvb, const gint start, gint *length, gint *item_length); static field_info * @@ -1470,8 +1470,8 @@ /* Add an item to a proto_tree, using the text label registered to that item; the item is extracted from the tvbuff handed to it. */ proto_item * -proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb, - gint start, gint length, gboolean little_endian) +proto_tree_add_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb, + const gint start, gint length, const gboolean little_endian) { field_info *new_fi; header_field_info *hfinfo; @@ -1489,7 +1489,7 @@ /* Add a FT_NONE to a proto_tree */ proto_item * -proto_tree_add_none_format(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, +proto_tree_add_none_format(proto_tree *tree, const int hfindex, tvbuff_t *tvb, const gint start, gint length, const char *format, ...) { proto_item *pi; @@ -3149,7 +3149,7 @@ static field_info * new_field_info(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb, - gint start, gint item_length) + const gint start, const gint item_length) { field_info *fi; @@ -3176,7 +3176,7 @@ } static field_info * -alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start, +alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, const gint start, gint *length) { header_field_info *hfinfo; @@ -3281,9 +3281,9 @@ /* -------------------------- */ const gchar * -proto_custom_set(proto_tree* tree, int field_id, +proto_custom_set(proto_tree* tree, const int field_id, gchar *result, - gchar *expr, int size ) + gchar *expr, const int size ) { guint32 u_integer; gint32 integer; @@ -3525,7 +3525,7 @@ } void -proto_item_set_len(proto_item *pi, gint length) +proto_item_set_len(proto_item *pi, const gint length) { field_info *fi; @@ -3568,7 +3568,7 @@ } int -proto_item_get_len(proto_item *pi) +proto_item_get_len(const proto_item *pi) { field_info *fi = PITEM_FINFO(pi); return fi ? fi->length : -1; @@ -3582,7 +3582,7 @@ } gboolean -proto_item_set_expert_flags(proto_item *pi, int group, guint severity) +proto_item_set_expert_flags(proto_item *pi, const int group, const guint severity) { if(pi == NULL || PITEM_FINFO(pi) == NULL) return FALSE; @@ -3631,7 +3631,7 @@ /* "prime" a proto_tree with a single hfid that a dfilter * is interested in. */ void -proto_tree_prime_hfid(proto_tree *tree _U_, gint hfid) +proto_tree_prime_hfid(proto_tree *tree _U_, const gint hfid) { header_field_info *hfinfo; @@ -3657,7 +3657,7 @@ } proto_tree* -proto_item_add_subtree(proto_item *pi, gint idx) { +proto_item_add_subtree(proto_item *pi, const gint idx) { field_info *fi; if (!pi) @@ -3675,7 +3675,7 @@ } proto_tree* -proto_item_get_subtree(proto_item *pi) { +proto_item_get_subtree(const proto_item *pi) { field_info *fi; if (!pi) @@ -3687,7 +3687,7 @@ } proto_item* -proto_item_get_parent(proto_item *ti) { +proto_item_get_parent(const proto_item *ti) { if (!ti) return (NULL); return ti->parent; @@ -3707,7 +3707,7 @@ proto_item* -proto_tree_get_parent(proto_tree *tree) { +proto_tree_get_parent(const proto_tree *tree) { if (!tree) return (NULL); return (proto_item*) tree; @@ -3770,7 +3770,7 @@ } void -proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, gint length) +proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, const gint length) { field_info *fi; @@ -3889,7 +3889,7 @@ } void -proto_mark_private(int proto_id) +proto_mark_private(const int proto_id) { protocol_t *protocol = find_protocol_by_id(proto_id); if (protocol) @@ -3897,7 +3897,7 @@ } gboolean -proto_is_private(int proto_id) +proto_is_private(const int proto_id) { protocol_t *protocol = find_protocol_by_id(proto_id); if (protocol) @@ -3940,7 +3940,7 @@ } header_field_info * -proto_get_first_protocol_field(int proto_id, void **cookie) +proto_get_first_protocol_field(const int proto_id, void **cookie) { protocol_t *protocol = find_protocol_by_id(proto_id); hf_register_info *ptr; @@ -3969,7 +3969,7 @@ } protocol_t * -find_protocol_by_id(int proto_id) +find_protocol_by_id(const int proto_id) { header_field_info *hfinfo; @@ -3991,7 +3991,7 @@ } int -proto_get_id(protocol_t *protocol) +proto_get_id(const protocol_t *protocol) { return protocol->proto_id; } @@ -4011,7 +4011,7 @@ } const char * -proto_get_protocol_name(int proto_id) +proto_get_protocol_name(const int proto_id) { protocol_t *protocol; @@ -4020,7 +4020,7 @@ } const char * -proto_get_protocol_short_name(protocol_t *protocol) +proto_get_protocol_short_name(const protocol_t *protocol) { if (protocol == NULL) return "(none)"; @@ -4028,7 +4028,7 @@ } const char * -proto_get_protocol_long_name(protocol_t *protocol) +proto_get_protocol_long_name(const protocol_t *protocol) { if (protocol == NULL) return "(none)"; @@ -4036,7 +4036,7 @@ } const char * -proto_get_protocol_filter_name(int proto_id) +proto_get_protocol_filter_name(const int proto_id) { protocol_t *protocol; @@ -4047,13 +4047,13 @@ } gboolean -proto_is_protocol_enabled(protocol_t *protocol) +proto_is_protocol_enabled(const protocol_t *protocol) { return protocol->is_enabled; } gboolean -proto_can_toggle_protocol(int proto_id) +proto_can_toggle_protocol(const int proto_id) { protocol_t *protocol; @@ -4062,7 +4062,7 @@ } void -proto_set_decoding(int proto_id, gboolean enabled) +proto_set_decoding(const int proto_id, const gboolean enabled) { protocol_t *protocol; @@ -4089,7 +4089,7 @@ } void -proto_set_cant_toggle(int proto_id) +proto_set_cant_toggle(const int proto_id) { protocol_t *protocol; @@ -4100,7 +4100,7 @@ /* for use with static arrays only, since we don't allocate our own copies of the header_field_info struct contained within the hf_register_info struct */ void -proto_register_field_array(int parent, hf_register_info *hf, int num_records) +proto_register_field_array(const int parent, hf_register_info *hf, const int num_records) { int field_id, i; hf_register_info *ptr = hf; @@ -4242,7 +4242,7 @@ } static int -proto_register_field_init(header_field_info *hfinfo, int parent) +proto_register_field_init(header_field_info *hfinfo, const int parent) { tmp_fld_check_assert(hfinfo); @@ -4322,7 +4322,7 @@ } void -proto_register_subtree_array(gint *const *indices, int num_indices) +proto_register_subtree_array(gint *const *indices, const int num_indices) { int i; gint *const *ptr = indices; @@ -4784,7 +4784,7 @@ } int -hfinfo_bitwidth(header_field_info *hfinfo) +hfinfo_bitwidth(const header_field_info *hfinfo) { int bitwidth = 0; @@ -4820,7 +4820,7 @@ } static const char* -hfinfo_uint_vals_format(header_field_info *hfinfo) +hfinfo_uint_vals_format(const header_field_info *hfinfo) { const char *format = NULL; @@ -4864,7 +4864,7 @@ } static const char* -hfinfo_uint_format(header_field_info *hfinfo) +hfinfo_uint_format(const header_field_info *hfinfo) { const char *format = NULL; @@ -4948,7 +4948,7 @@ } static const char* -hfinfo_uint_value_format(header_field_info *hfinfo) +hfinfo_uint_value_format(const header_field_info *hfinfo) { const char *format = NULL; @@ -5032,7 +5032,7 @@ } static const char* -hfinfo_int_vals_format(header_field_info *hfinfo) +hfinfo_int_vals_format(const header_field_info *hfinfo) { const char *format = NULL; @@ -5076,7 +5076,7 @@ } static const char* -hfinfo_uint64_format(header_field_info *hfinfo) +hfinfo_uint64_format(const header_field_info *hfinfo) { const char *format = NULL; @@ -5105,7 +5105,7 @@ } static const char* -hfinfo_int_format(header_field_info *hfinfo) +hfinfo_int_format(const header_field_info *hfinfo) { const char *format = NULL; @@ -5182,7 +5182,7 @@ } static const char* -hfinfo_int_value_format(header_field_info *hfinfo) +hfinfo_int_value_format(const header_field_info *hfinfo) { const char *format = NULL; @@ -5259,7 +5259,7 @@ } static const char* -hfinfo_int64_format(header_field_info *hfinfo) +hfinfo_int64_format(const header_field_info *hfinfo) { const char *format = NULL; @@ -5294,7 +5294,7 @@ } const char* -proto_registrar_get_name(int n) +proto_registrar_get_name(const int n) { header_field_info *hfinfo; @@ -5303,7 +5303,7 @@ } const char* -proto_registrar_get_abbrev(int n) +proto_registrar_get_abbrev(const int n) { header_field_info *hfinfo; @@ -5312,7 +5312,7 @@ } int -proto_registrar_get_ftype(int n) +proto_registrar_get_ftype(const int n) { header_field_info *hfinfo; @@ -5321,7 +5321,7 @@ } int -proto_registrar_get_parent(int n) +proto_registrar_get_parent(const int n) { header_field_info *hfinfo; @@ -5330,7 +5330,7 @@ } gboolean -proto_registrar_is_protocol(int n) +proto_registrar_is_protocol(const int n) { header_field_info *hfinfo; @@ -5343,7 +5343,7 @@ * 0 means undeterminable at time of registration * -1 means the field is not registered. */ gint -proto_registrar_get_length(int n) +proto_registrar_get_length(const int n) { header_field_info *hfinfo; @@ -5354,7 +5354,7 @@ /* Looks for a protocol or a field in a proto_tree. Returns TRUE if * it exists anywhere, or FALSE if it exists nowhere. */ gboolean -proto_check_for_protocol_or_field(proto_tree* tree, int id) +proto_check_for_protocol_or_field(const proto_tree* tree, const int id) { GPtrArray *ptrs = proto_get_finfo_ptr_array(tree, id); @@ -5375,7 +5375,7 @@ * The caller should *not* free the GPtrArray*; proto_tree_free_node() * handles that. */ GPtrArray* -proto_get_finfo_ptr_array(proto_tree *tree, int id) +proto_get_finfo_ptr_array(const proto_tree *tree, const int id) { if (!tree) return NULL; @@ -5388,7 +5388,7 @@ } gboolean -proto_tracking_interesting_fields(proto_tree *tree) +proto_tracking_interesting_fields(const proto_tree *tree) { if (!tree) return FALSE; @@ -5424,7 +5424,7 @@ * g_ptr_array_free(, TRUE). */ GPtrArray* -proto_find_finfo(proto_tree *tree, int id) +proto_find_finfo(proto_tree *tree, const int id) { ffdata_t ffdata; @@ -5471,7 +5471,7 @@ } offset_search_t; static gboolean -check_for_offset(proto_node *node, gpointer data) +check_for_offset(proto_node *node, const gpointer data) { field_info *fi = PNODE_FINFO(node); offset_search_t *offsearch = data; @@ -5726,7 +5726,7 @@ * Field 8 = bitmask: format: hex: 0x.... */ void -proto_registrar_dump_fields(int format) +proto_registrar_dump_fields(const int format) { header_field_info *hfinfo, *parent_hfinfo; int i, len; @@ -5846,7 +5846,7 @@ } static const char* -hfinfo_numeric_format(header_field_info *hfinfo) +hfinfo_numeric_format(const header_field_info *hfinfo) { const char *format = NULL; @@ -6186,8 +6186,8 @@ * proto_tree_add_bitmask_text() functions. */ static gboolean -proto_item_add_bitmask_tree(proto_item *item, tvbuff_t *tvb, int offset, int len, gint ett, - const int **fields, gboolean little_endian, int flags, gboolean first) +proto_item_add_bitmask_tree(proto_item *item, tvbuff_t *tvb, const int offset, const int len, const gint ett, + const int **fields, const gboolean little_endian, const int flags, gboolean first) { guint32 value = 0, tmpval; proto_tree *tree = NULL; @@ -6322,8 +6322,8 @@ * matched string displayed on the expansion line. */ proto_item * -proto_tree_add_bitmask(proto_tree *parent_tree, tvbuff_t *tvb, guint offset, int hf_hdr, - gint ett, const int **fields, gboolean little_endian) +proto_tree_add_bitmask(proto_tree *parent_tree, tvbuff_t *tvb, const guint offset, const int hf_hdr, + const gint ett, const int **fields, const gboolean little_endian) { proto_item *item = NULL; header_field_info *hf; @@ -6344,9 +6344,9 @@ /* The same as proto_tree_add_bitmask(), but using an arbitrary text as a top-level item */ proto_item * -proto_tree_add_bitmask_text(proto_tree *parent_tree, tvbuff_t *tvb, guint offset, guint len, +proto_tree_add_bitmask_text(proto_tree *parent_tree, tvbuff_t *tvb, const guint offset, const guint len, const char *name, const char *fallback, - gint ett, const int **fields, gboolean little_endian, int flags) + const gint ett, const int **fields, const gboolean little_endian, const int flags) { proto_item *item = NULL; @@ -6363,7 +6363,7 @@ } proto_item * -proto_tree_add_bits_item(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian) +proto_tree_add_bits_item(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const gboolean little_endian) { header_field_info *hfinfo; @@ -6377,7 +6377,7 @@ * in bits and also which parts of an octet are used. E.g. '..11 100.' */ gchar * -prepare_bits_string(guint64 value, gint bit_offset, gint no_of_bits) +prepare_bits_string(guint64 value, const gint bit_offset, const gint no_of_bits) { guint64 mask, tmp; gchar *str; @@ -6431,7 +6431,7 @@ */ proto_item * -proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint64 *return_value, gboolean little_endian) +proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, guint64 *return_value, const gboolean little_endian) { const char *format = NULL; gint offset; @@ -6547,7 +6547,7 @@ } proto_item * -proto_tree_add_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, void *value_ptr, gchar *value_str) +proto_tree_add_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, void *value_ptr, gchar *value_str) { gint offset; guint length; @@ -6649,7 +6649,7 @@ va_end(ap); proto_item * -proto_tree_add_uint_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, +proto_tree_add_uint_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, guint32 value, const char *format, ...) { va_list ap; @@ -6677,7 +6677,7 @@ } proto_item * -proto_tree_add_float_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, +proto_tree_add_float_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, float value, const char *format, ...) { va_list ap; @@ -6694,7 +6694,7 @@ } proto_item * -proto_tree_add_int_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, +proto_tree_add_int_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, gint32 value, const char *format, ...) { va_list ap; @@ -6722,7 +6722,7 @@ } proto_item * -proto_tree_add_boolean_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, +proto_tree_add_boolean_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, guint32 value, const char *format, ...) { va_list ap; Index: epan/proto.h =================================================================== --- epan/proto.h (revision 31659) +++ epan/proto.h (working copy) @@ -418,17 +418,17 @@ @param ti the parent item of the new subtree @param idx one of the ett_ array elements registered with proto_register_subtree_array() @return the new subtree */ -extern proto_tree* proto_item_add_subtree(proto_item *ti, gint idx); +extern proto_tree* proto_item_add_subtree(proto_item *ti, const gint idx); /** Get an existing subtree under an item. @param ti the parent item of the subtree @return the subtree or NULL */ -extern proto_tree* proto_item_get_subtree(proto_item *ti); +extern proto_tree* proto_item_get_subtree(const proto_item *ti); /** Get the parent of a subtree item. @param ti the child item in the subtree @return parent item or NULL */ -extern proto_item* proto_item_get_parent(proto_item *ti); +extern proto_item* proto_item_get_parent(const proto_item *ti); /** Get Nth generation parent item. @param ti the child item in the subtree @@ -453,7 +453,7 @@ /** Set proto_item's length inside tvb, after it has already been created. @param ti the item to set the length @param length the new length ot the item */ -extern void proto_item_set_len(proto_item *ti, gint length); +extern void proto_item_set_len(proto_item *ti, const gint length); /** * Sets the length of the item based on its start and on the specified @@ -471,7 +471,7 @@ * to add a variable-length field (e.g., FT_NSTRING_UINT8). @param ti the item to get the length from @return the current length */ -extern int proto_item_get_len(proto_item *ti); +extern int proto_item_get_len(const proto_item *ti); /** * Sets an expert info to the proto_item. @@ -480,7 +480,7 @@ @param severity of this info (e.g. PI_ERROR) @return TRUE if value was written */ -extern gboolean proto_item_set_expert_flags(proto_item *ti, int group, guint severity); +extern gboolean proto_item_set_expert_flags(proto_item *ti, const int group, const guint severity); @@ -514,12 +514,12 @@ @param hfid the interesting field id @todo what *does* interesting mean? */ extern void -proto_tree_prime_hfid(proto_tree *tree, int hfid); +proto_tree_prime_hfid(proto_tree *tree, const int hfid); /** Get a parent item of a subtree. @param tree the tree to get the parent from @return parent item */ -extern proto_item* proto_tree_get_parent(proto_tree *tree); +extern proto_item* proto_tree_get_parent(const proto_tree *tree); /** Get the root tree from any subtree. @param tree the tree to get the root from @@ -538,7 +538,7 @@ @param tvb the tv buffer of the current data @param start the start offset of the appendix @param length the length of the appendix */ -extern void proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, gint length); +extern void proto_tree_set_appendix(proto_tree *tree, tvbuff_t *tvb, gint start, const gint length); /** Add an item to a proto_tree, using the text label registered to that item. @@ -551,8 +551,8 @@ @param little_endian big or little endian byte representation @return the newly created item */ extern proto_item * -proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb, - gint start, gint length, gboolean little_endian); +proto_tree_add_item(proto_tree *tree, const int hfindex, tvbuff_t *tvb, + const gint start, gint length, const gboolean little_endian); /** Add a text-only node to a proto_tree. @param tree the tree to append this item to @@ -1365,13 +1365,13 @@ /** Mark protocol as private @param proto_id the handle of the protocol */ extern void -proto_mark_private(int proto_id); +proto_mark_private(const int proto_id); /** Return if protocol is private @param proto_id the handle of the protocol @return TRUE if it is a private protocol, FALSE is not. */ extern gboolean -proto_is_private(int proto_id); +proto_is_private(const int proto_id); /** This is the type of function can be registered to get called whenever a given field was not found but a its prefix is matched @@ -1393,7 +1393,7 @@ @param hf the hf_register_info array @param num_records the number of records in hf */ extern void -proto_register_field_array(int parent, hf_register_info *hf, int num_records); +proto_register_field_array(const int parent, hf_register_info *hf, const int num_records); /** Register a protocol subtree (ett) array. @param indices array of ett indices @@ -1408,12 +1408,12 @@ /** Get name of registered header_field number n. @param n item # n (0-indexed) @return the name of this registered item */ -extern const char* proto_registrar_get_name(int n); +extern const char* proto_registrar_get_name(const int n); /** Get abbreviation of registered header_field number n. @param n item # n (0-indexed) @return the abbreviation of this registered item */ -extern const char* proto_registrar_get_abbrev(int n); +extern const char* proto_registrar_get_abbrev(const int n); /** Get the header_field information based upon a field or protocol id. @param hfindex item # n (0-indexed) @@ -1428,22 +1428,22 @@ /** Get enum ftenum FT_ of registered header_field number n. @param n item # n (0-indexed) @return the registered item */ -extern int proto_registrar_get_ftype(int n); +extern int proto_registrar_get_ftype(const int n); /** Get parent protocol of registered header_field number n. @param n item # n (0-indexed) @return -1 if item _is_ a protocol */ -extern int proto_registrar_get_parent(int n); +extern int proto_registrar_get_parent(const int n); /** Is item # n a protocol? @param n item # n (0-indexed) @return TRUE if it's a protocol, FALSE if it's not */ -extern gboolean proto_registrar_is_protocol(int n); +extern gboolean proto_registrar_is_protocol(const int n); /** Get length of registered field according to field type. @param n item # n (0-indexed) @return 0 means undeterminable at registration time, -1 means unknown field */ -extern gint proto_registrar_get_length(int n); +extern gint proto_registrar_get_length(const int n); /** Routines to use to iterate over the protocols and their fields; @@ -1451,7 +1451,7 @@ * appropriate hfinfo pointer, and keep state in "*cookie". */ extern int proto_get_first_protocol(void **cookie); extern int proto_get_next_protocol(void **cookie); -extern header_field_info *proto_get_first_protocol_field(int proto_id, void **cookle); +extern header_field_info *proto_get_first_protocol_field(const int proto_id, void **cookle); extern header_field_info *proto_get_next_protocol_field(void **cookle); /** Given a protocol's filter_name. @@ -1466,66 +1466,66 @@ /** Get the "protocol_t" structure for the given protocol's item number. @param proto_id protocol id (0-indexed) */ -extern protocol_t *find_protocol_by_id(int proto_id); +extern protocol_t *find_protocol_by_id(const int proto_id); /** Get the protocol's name for the given protocol's item number. @param proto_id protocol id (0-indexed) @return its name */ -extern const char *proto_get_protocol_name(int proto_id); +extern const char *proto_get_protocol_name(const int proto_id); /** Get the protocol's item number, for the given protocol's "protocol_t". @return its proto_id */ -extern int proto_get_id(protocol_t *protocol); +extern int proto_get_id(const protocol_t *protocol); /** Get the protocol's short name, for the given protocol's "protocol_t". @return its short name. */ -extern const char *proto_get_protocol_short_name(protocol_t *protocol); +extern const char *proto_get_protocol_short_name(const protocol_t *protocol); /** Get the protocol's long name, for the given protocol's "protocol_t". @return its long name. */ -extern const char *proto_get_protocol_long_name(protocol_t *protocol); +extern const char *proto_get_protocol_long_name(const protocol_t *protocol); /** Is protocol's decoding enabled ? @param protocol @return TRUE if decoding is enabled, FALSE if not */ -extern gboolean proto_is_protocol_enabled(protocol_t *protocol); +extern gboolean proto_is_protocol_enabled(const protocol_t *protocol); /** Get a protocol's filter name by it's item number. @param proto_id protocol id (0-indexed) @return its filter name. */ -extern const char *proto_get_protocol_filter_name(int proto_id); +extern const char *proto_get_protocol_filter_name(const int proto_id); /** Enable / Disable protocol of the given item number. @param proto_id protocol id (0-indexed) @param enabled enable / disable the protocol */ -extern void proto_set_decoding(int proto_id, gboolean enabled); +extern void proto_set_decoding(const int proto_id, const gboolean enabled); /** Enable all protocols */ extern void proto_enable_all(void); /** Disable disabling/enabling of protocol of the given item number. @param proto_id protocol id (0-indexed) */ -extern void proto_set_cant_toggle(int proto_id); +extern void proto_set_cant_toggle(const int proto_id); /** Checks for existence any protocol or field within a tree. @param tree "Protocols" are assumed to be a child of the [empty] root node. @param id hfindex of protocol or field @return TRUE = found, FALSE = not found @todo add explanation of id parameter */ -extern gboolean proto_check_for_protocol_or_field(proto_tree* tree, int id); +extern gboolean proto_check_for_protocol_or_field(const proto_tree* tree, const int id); /** Return GPtrArray* of field_info pointers for all hfindex that appear in tree. Only works with primed trees, and is fast. @param tree tree of interest @param hfindex primed hfindex @return GPtrArry pointer */ -extern GPtrArray* proto_get_finfo_ptr_array(proto_tree *tree, int hfindex); +extern GPtrArray* proto_get_finfo_ptr_array(const proto_tree *tree, const int hfindex); /** Return whether we're tracking any interesting fields. Only works with primed trees, and is fast. @param tree tree of interest @return TRUE if we're tracking interesting fields */ -extern gboolean proto_tracking_interesting_fields(proto_tree *tree); +extern gboolean proto_tracking_interesting_fields(const proto_tree *tree); /** Return GPtrArray* of field_info pointers for all hfindex that appear in tree. Works with any tree, primed or unprimed, and is slower than @@ -1533,7 +1533,7 @@ @param tree tree of interest @param hfidex index of field info of interest @return GPtrArry pointer */ -extern GPtrArray* proto_find_finfo(proto_tree *tree, int hfindex); +extern GPtrArray* proto_find_finfo(proto_tree *tree, const int hfindex); /** Return GPtrArray* of field_info pointers containg all hfindexes that appear in tree. @@ -1550,7 +1550,7 @@ /** Dumps a glossary of the protocol and field registrations to STDOUT. * Format 1 is the original format. Format 2 includes the base (for integers) * and the blurb. */ -extern void proto_registrar_dump_fields(int format); +extern void proto_registrar_dump_fields(const int format); @@ -1573,7 +1573,7 @@ @param hfinfo header_field @return the bitwidth */ extern int -hfinfo_bitwidth(header_field_info *hfinfo); +hfinfo_bitwidth(const header_field_info *hfinfo); @@ -1621,8 +1621,8 @@ @param little_endian big or little endian byte representation @return the newly created item */ extern proto_item * -proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, guint offset, - int hf_hdr, gint ett, const int **fields, gboolean little_endian); +proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, const guint offset, + const int hf_hdr, const gint ett, const int **fields, const gboolean little_endian); /** Add a text with a subtree of bitfields. @param tree the tree to append this item to @@ -1635,9 +1635,9 @@ @param little_endian big or little endian byte representation @return the newly created item */ extern proto_item * -proto_tree_add_bitmask_text(proto_tree *tree, tvbuff_t *tvb, guint offset, guint len, +proto_tree_add_bitmask_text(proto_tree *tree, tvbuff_t *tvb, const guint offset, const guint len, const char *name, const char *fallback, - gint ett, const int **fields, gboolean little_endian, int flags); + const gint ett, const int **fields, const gboolean little_endian, const int flags); #define BMT_NO_APPEND 0x01 /**< Don't change the title at all */ #define BMT_NO_INT 0x02 /**< Don't add integral (non-boolean) fields to title */ @@ -1654,7 +1654,7 @@ @param little_endian big or little endian byte representation @return the newly created item */ extern proto_item * -proto_tree_add_bits_item(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean little_endian); +proto_tree_add_bits_item(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, const gboolean little_endian); /** Add bits to a proto_tree, using the text label registered to that item. The item is extracted from the tvbuff handed to it. @@ -1667,7 +1667,7 @@ @param little_endian big or little endian byte representation @return the newly created item */ extern proto_item * -proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint64 *return_value, gboolean little_endian); +proto_tree_add_bits_ret_val(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, guint64 *return_value, const gboolean little_endian); /** Add bits for a FT_UINT8, FT_UINT16, FT_UINT24 or FT_UINT32 header field to a proto_tree, with the format generating the @@ -1682,8 +1682,13 @@ @param ... printf like parameters @return the newly created item */ extern proto_item * +<<<<<<< .mine +proto_tree_add_uint_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, + const guint32 value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8); +======= proto_tree_add_uint_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8); +>>>>>>> .r31659 /** Add bits for a FT_BOOLEAN header field to a proto_tree, with the format generating the string for the value and with the field @@ -1698,7 +1703,7 @@ @param ... printf like parameters @return the newly created item */ extern proto_item * -proto_tree_add_boolean_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, +proto_tree_add_boolean_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, guint32 value, const char *format, ...) G_GNUC_PRINTF(7,8); /** Add bits for a FT_INT8, FT_INT16, FT_INT24 or FT_INT32 @@ -1714,7 +1719,7 @@ @param ... printf like parameters @return the newly created item */ extern proto_item * -proto_tree_add_int_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, +proto_tree_add_int_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, gint32 value, const char *format, ...) G_GNUC_PRINTF(7,8); /** Add bits for a FT_FLOAT header field to a proto_tree, with @@ -1730,8 +1735,13 @@ @param ... printf like parameters @return the newly created item */ extern proto_item * +<<<<<<< .mine +proto_tree_add_float_bits_format_value(proto_tree *tree, const int hf_index, tvbuff_t *tvb, const gint bit_offset, const gint no_of_bits, + const float value, const char *format, ...) GNUC_FORMAT_CHECK(printf,7,8); +======= proto_tree_add_float_bits_format_value(proto_tree *tree, int hf_index, tvbuff_t *tvb, gint bit_offset, gint no_of_bits, float value, const char *format, ...) G_GNUC_PRINTF(7,8); +>>>>>>> .r31659 /** Check if given string is a valid field name @param field_name the field name to check @@ -1746,9 +1756,9 @@ @param expr the filter expression @param aize the size of the string buffer */ const gchar * -proto_custom_set(proto_tree* tree, int field_id, +proto_custom_set(proto_tree* tree, const int field_id, gchar *result, - gchar *expr, int size ); + gchar *expr, const int size ); #ifdef __cplusplus } Index: epan/dissectors/packet-vnc.c =================================================================== --- epan/dissectors/packet-vnc.c (revision 31659) +++ epan/dissectors/packet-vnc.c (working copy) @@ -94,15 +94,23 @@ { 1, "Yes" }, { 0, NULL } }; +typedef enum { + SET_PIXEL_FORMAT = 0, + SET_ENCODING = 2, + FRAMEBUF_UPDATE_REQ = 3, + KEY_EVENT = 4, + POINTER_EVENT = 5, + CLIENT_CUT_TEXT = 6, +} client_message_types_e; static const value_string client_message_types_vs[] = { - { 0, "Set Pixel Format" }, - { 2, "Set Encodings" }, - { 3, "Framebuffer Update Request" }, - { 4, "Key Event" }, - { 5, "Pointer Event" }, - { 6, "Cut Text" }, - { 0, NULL } + { SET_PIXEL_FORMAT, "Set Pixel Format" }, + { SET_ENCODING, "Set Encodings" }, + { FRAMEBUF_UPDATE_REQ, "Framebuffer Update Request"}, + { KEY_EVENT, "Key Event" }, + { POINTER_EVENT, "Pointer Event" }, + { CLIENT_CUT_TEXT, "Cut Text" }, + { 0, NULL } }; typedef enum { @@ -126,11 +134,11 @@ }; typedef enum { - ENCODING_DESKTOP_SIZE = -223, - ENCODING_LAST_RECT = -224, - ENCODING_POINTER_POS = -232, - ENCODING_RICH_CURSOR = -239, - ENCODING_X_CURSOR = -240, + ENCODING_DESKTOP_SIZE = 0xFFFFFF21, + ENCODING_LAST_RECT = 0xFFFFFF20, + ENCODING_POINTER_POS = 0xFFFFFF18, + ENCODING_RICH_CURSOR = 0xFFFFFF11, + ENCODING_X_CURSOR = 0xFFFFFF10, ENCODING_RAW = 0, ENCODING_COPY_RECT = 1, ENCODING_RRE = 2, @@ -139,8 +147,47 @@ ENCODING_ZLIB = 6, ENCODING_TIGHT = 7, ENCODING_ZLIBHEX = 8, + ENCODING_ULTRA = 9, + ENCODING_TRLE = 15, ENCODING_RLE = 16, - ENCODING_HITACHI_ZYWRLE = 17 + ENCODING_HITACHI_ZYWRLE = 17, + ENCODING_JPEG_0 = -32, + ENCODING_JPEG_1 = -31, + ENCODING_JPEG_2 = -30, + ENCODING_JPEG_3 = -29, + ENCODING_JPEG_4 = -28, + ENCODING_JPEG_5 = -27, + ENCODING_JPEG_6 = -26, + ENCODING_JPEG_7 = -25, + ENCODING_JPEG_8 = -24, + ENCODING_JPEG_9 = -23, + ENCODING_COMPRESSION_0 = 0xFFFFFF00, + ENCODING_COMPRESSION_1 = 0xFFFFFF01, + ENCODING_COMPRESSION_2 = 0xFFFFFF02, + ENCODING_COMPRESSION_3 = 0xFFFFFF03, + ENCODING_COMPRESSION_4 = 0xFFFFFF04, + ENCODING_COMPRESSION_5 = 0xFFFFFF05, + ENCODING_COMPRESSION_6 = 0xFFFFFF06, + ENCODING_COMPRESSION_7 = 0xFFFFFF07, + ENCODING_COMPRESSION_8 = 0xFFFFFF08, + ENCODING_COMPRESSION_9 = 0xFFFFFF09, + ENCODING_WMVi = 0x574D5669, + ENCODING_CACHE = 0xFFFF0000, + ENCODING_CACHE_ENABLE = 0xFFFF0001, + ENCODING_XOR_ZLIB = 0xFFFF0002, + ENCODING_XOR_MONO_ZLIB = 0xFFFF0003, + ENCODING_XOR_MULTI_ZLIB = 0xFFFF0004, + ENCODING_SOLID_COLOR = 0xFFFF0005, + ENCODING_XOR_ENABLE = 0xFFFF0006, + ENCODING_CACHE_ZIP = 0xFFFF0007, + ENCODING_SOL_MONO_ZIP = 0xFFFF0008, + ENCODING_ULTRA_ZIP = 0xFFFF0009, + ENCODING_SERVER_STATE = 0xFFFF8000, + ENCODING_ENABLE_KEEP_ALIVE = 0xFFFF8001, + ENCODING_FTP_PROTO_VER = 0xFFFF8002, + ENCODING_POINTER_CHANGE = -257, + ENCODING_EXT_KEY_EVENT = -258, + ENCODING_AUDIO = 259 } encoding_type_e; static const value_string encoding_types_vs[] = { @@ -157,8 +204,43 @@ { ENCODING_ZLIB, "Zlib" }, { ENCODING_TIGHT, "Tight" }, { ENCODING_ZLIBHEX, "ZlibHex" }, + { ENCODING_ULTRA, "Ultra" }, { ENCODING_RLE, "ZRLE" }, { ENCODING_HITACHI_ZYWRLE, "Hitachi ZYWRLE" }, + { ENCODING_JPEG_0, "JPEG quality level 0"}, + { ENCODING_JPEG_1, "JPEG quality level 1"}, + { ENCODING_JPEG_2, "JPEG quality level 2"}, + { ENCODING_JPEG_3, "JPEG quality level 3"}, + { ENCODING_JPEG_4, "JPEG quality level 4"}, + { ENCODING_JPEG_5, "JPEG quality level 5"}, + { ENCODING_JPEG_6, "JPEG quality level 6"}, + { ENCODING_JPEG_7, "JPEG quality level 7"}, + { ENCODING_JPEG_8, "JPEG quality level 8"}, + { ENCODING_JPEG_9, "JPEG quality level 9"}, + { ENCODING_COMPRESSION_0, "Compression level 0"}, + { ENCODING_COMPRESSION_1, "Compression level 1"}, + { ENCODING_COMPRESSION_2, "Compression level 2"}, + { ENCODING_COMPRESSION_3, "Compression level 3"}, + { ENCODING_COMPRESSION_4, "Compression level 4"}, + { ENCODING_COMPRESSION_5, "Compression level 5"}, + { ENCODING_COMPRESSION_6, "Compression level 6"}, + { ENCODING_COMPRESSION_7, "Compression level 7"}, + { ENCODING_COMPRESSION_8, "Compression level 8"}, + { ENCODING_COMPRESSION_9, "Compression level 9"}, + /* FIXME understand for real what the below mean. Taken from Ultra VNC source code */ +// { ENCODING_CACHE, + { ENCODING_CACHE_ENABLE, "Enable Caching"}, +/* { ENCODING_XOR_ZLIB, + { ENCODING_XOR_MONO_ZLIB, + { ENCODING_XOR_MULTI_ZLIB, + { ENCODING_SOLID_COLOR, + { ENCODING_XOR_ENABLE, + { ENCODING_CACHE_ZIP, + { ENCODING_SOL_MONO_ZIP, + { ENCODING_ULTRA_ZIP, +*/ { ENCODING_SERVER_STATE, "Server State"}, + { ENCODING_ENABLE_KEEP_ALIVE, "Enable Keep Alive"}, + { ENCODING_FTP_PROTO_VER, "FTP protocol version"}, { 0, NULL } }; @@ -219,7 +301,6 @@ /* This structure will be tied to each conversation. */ typedef struct { - guint8 security_type_selected; gdouble server_proto_ver, client_proto_ver; vnc_session_state_e vnc_next_state; guint32 server_port; @@ -227,14 +308,15 @@ gint num_server_message_types; gint num_client_message_types; gint num_encoding_types; + guint8 security_type_selected; } vnc_conversation_t; /* This structure will be tied to each packet */ typedef struct { + vnc_session_state_e state; + gint preferred_encoding; guint8 bytes_per_pixel; guint8 depth; - vnc_session_state_e state; - gint preferred_encoding; } vnc_packet_t; void proto_reg_handoff_vnc(void); @@ -597,16 +679,18 @@ gchar *vendor; proto_item *ti; - vendor = tvb_get_ephemeral_string(tvb, offset, 4); + if (tree) { + vendor = tvb_get_ephemeral_string(tvb, offset, 4); - ti = proto_tree_add_string(tree, hfindex, tvb, offset, 4, vendor); + ti = proto_tree_add_string(tree, hfindex, tvb, offset, 4, vendor); - if(g_ascii_strcasecmp(vendor, "STDV") == 0) - proto_item_append_text(ti, " (Standard VNC vendor)"); - else if(g_ascii_strcasecmp(vendor, "TRDV") == 0) - proto_item_append_text(ti, " (Tridia VNC vendor)"); - else if(g_ascii_strcasecmp(vendor, "TGHT") == 0) - proto_item_append_text(ti, " (Tight VNC vendor)"); + if(g_ascii_strcasecmp(vendor, "STDV") == 0) + proto_item_append_text(ti, " (Standard VNC vendor)"); + else if(g_ascii_strcasecmp(vendor, "TRDV") == 0) + proto_item_append_text(ti, " (Tridia VNC vendor)"); + else if(g_ascii_strcasecmp(vendor, "TGHT") == 0) + proto_item_append_text(ti, " (Tight VNC vendor)"); + } offset += 4; return offset; @@ -1137,32 +1221,32 @@ switch(message_type) { - case 0 : + case SET_PIXEL_FORMAT : vnc_client_set_pixel_format(tvb, pinfo, offset, vnc_client_message_type_tree); break; - case 2 : + case SET_ENCODING : vnc_client_set_encodings(tvb, pinfo, offset, vnc_client_message_type_tree); break; - case 3 : + case FRAMEBUF_UPDATE_REQ : vnc_client_framebuffer_update_request(tvb, pinfo, offset, vnc_client_message_type_tree); break; - case 4 : + case KEY_EVENT : vnc_client_key_event(tvb, pinfo, offset, vnc_client_message_type_tree); break; - case 5: + case POINTER_EVENT: vnc_client_pointer_event(tvb, pinfo, offset, vnc_client_message_type_tree); break; - case 6 : + case CLIENT_CUT_TEXT : vnc_client_cut_text(tvb, pinfo, offset, vnc_client_message_type_tree); break; @@ -1454,7 +1538,7 @@ gint num_rects, i; guint16 width, height; guint bytes_needed = 0; - gint32 encoding_type; + guint32 encoding_type; proto_item *ti, *ti_x, *ti_y, *ti_width, *ti_height; proto_tree *vnc_rect_tree, *vnc_encoding_type_tree; Index: epan/dissectors/Makefile.common =================================================================== --- epan/dissectors/Makefile.common (revision 31659) +++ epan/dissectors/Makefile.common (working copy) @@ -45,6 +45,7 @@ # PIDL-generated DCE RPC dissectors without warnings. # PIDL_DISSECTOR_SRC = \ + packet-redc.c \ packet-dcerpc-atsvc.c \ packet-dcerpc-budb.c \ packet-dcerpc-butc.c \ Index: epan/dissectors/packet-x11.c =================================================================== --- epan/dissectors/packet-x11.c (revision 31659) +++ epan/dissectors/packet-x11.c (working copy) @@ -2619,7 +2619,7 @@ /* We assume the order to be consistent, until proven wrong. */ -static gboolean consistentWithOrder(int length, tvbuff_t *tvb, int offset, guint16 (*v16)(tvbuff_t *, gint)) +static gboolean consistentWithOrder(int length, tvbuff_t *tvb, int offset, guint16 (*v16)(tvbuff_t *, const gint)) { switch(tvb_get_guint8(tvb, offset)) { case X_CreateWindow: @@ -2835,7 +2835,7 @@ /* -1 means doesn't match, +1 means match, 0 means don't know */ -static int x_endian_match(tvbuff_t *tvb, guint16 (*v16)(tvbuff_t *, gint)) +static int x_endian_match(tvbuff_t *tvb, guint16 (*v16)(tvbuff_t *, const gint)) { int offset, nextoffset; int atLeastOne = 0; Index: epan/dissectors/packet-ssl.c =================================================================== --- epan/dissectors/packet-ssl.c (revision 31659) +++ epan/dissectors/packet-ssl.c (working copy) @@ -271,7 +271,7 @@ static gchar* ssl_keys_list = NULL; #if defined(SSL_DECRYPT_DEBUG) || defined(HAVE_LIBGNUTLS) -static gchar* ssl_debug_file_name = NULL; +static gchar* ssl_debug_file_name = "/tmp/ssl.txt"; #endif