Remove C++ incompatibilities in c1222 dissector.

Also addresses an implicit cast in the epan/uat.h file

Bug 8342 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=8342)

svn path=/trunk/; revision=47721
This commit is contained in:
Michael Mann 2013-02-17 22:15:16 +00:00
parent 73ef143f95
commit fd44f9a339
4 changed files with 25 additions and 41 deletions

View File

@ -23,7 +23,7 @@ Calling-authentication-value-c1222/_untag/iv-element BLURB="c1222.iv-element"
Calling-authentication-value-c1222/_untag/key-id-element BLURB = "c1222.key-id-element"
#.FN_BODY User-information
gint8 class;
gint8 end_device_class;
gboolean pc, ind;
gint32 tag;
guint32 len;
@ -32,11 +32,11 @@ Calling-authentication-value-c1222/_untag/key-id-element BLURB = "c1222.key-id-e
FILL_START;
/* get Tag and Length */
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &class, &pc, &tag);
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &end_device_class, &pc, &tag);
offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind);
FILL_TABLE_TRUNCATE(user_information, len+offset-start_offset);
if (tag == 0x8) { /* BER_TAG_EXTERNAL */
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &class, &pc, &tag);
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &end_device_class, &pc, &tag);
offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind);
if (tag == 0x1) { /* implicit octet string */
tf = proto_tree_add_item(tree, hf_c1222_user_information, tvb, offset, len, ENC_NA);

View File

@ -27,7 +27,6 @@
#include <glib.h>
#include <epan/conversation.h>
#include <wsutil/crc16.h>
#include <epan/expert.h>
#include <epan/packet.h>
#include <epan/prefs.h>
@ -115,7 +114,6 @@ static int hf_c1222_epsem_total = -1;
static int hf_c1222_cmd = -1;
static int hf_c1222_err = -1;
static int hf_c1222_data = -1;
static int hf_c1222_crc = -1;
/* individual epsem fields */
static int hf_c1222_logon_id = -1;
static int hf_c1222_logon_user = -1;
@ -286,11 +284,11 @@ static uat_t *c1222_uat;
#define FILL_START int length, start_offset = offset;
#define FILL_TABLE(fieldname) \
length = offset - start_offset; \
fieldname = tvb_memdup(tvb, start_offset, length); \
fieldname = (guint8 *)tvb_memdup(tvb, start_offset, length); \
fieldname##_len = length;
#define FILL_TABLE_TRUNCATE(fieldname, len) \
length = 1 + 2*(offset - start_offset); \
fieldname = tvb_memdup(tvb, start_offset, length); \
fieldname = (guint8 *)tvb_memdup(tvb, start_offset, length); \
fieldname##_len = len;
#else /* HAVE_LIBGCRYPT */
#define FILL_TABLE(fieldname)
@ -669,7 +667,7 @@ encode_ber_len(guint8 *ptr, guint32 n, int maxsize)
static void
c1222_uat_data_update_cb(void* n, const char** err)
{
c1222_uat_data_t* new_rec = n;
c1222_uat_data_t* new_rec = (c1222_uat_data_t *)n;
if (new_rec->keynum > 0xff) {
*err = "Invalid key number; must be less than 256";
@ -889,7 +887,7 @@ dissect_epsem(tvbuff_t *tvb, int offset, guint32 len, packet_info *pinfo, proto_
return offset;
encrypted = TRUE;
if (c1222_decrypt) {
buffer = tvb_memdup(tvb, offset, len2);
buffer = (guchar *)tvb_memdup(tvb, offset, len2);
if (!decrypt_packet(buffer, len2, TRUE)) {
g_free(buffer);
crypto_bad = TRUE;
@ -908,7 +906,7 @@ dissect_epsem(tvbuff_t *tvb, int offset, guint32 len, packet_info *pinfo, proto_
len2 = tvb_length_remaining(tvb, offset);
if (len2 <= 0)
return offset;
buffer = tvb_memdup(tvb, offset, len2);
buffer = (guchar *)tvb_memdup(tvb, offset, len2);
epsem_buffer = tvb_new_subset(tvb, offset, -1, -1);
if (c1222_decrypt) {
if (!decrypt_packet(buffer, len2, FALSE)) {
@ -1249,12 +1247,6 @@ void proto_register_c1222(void) {
NULL, 0x0,
NULL, HFILL }
},
{ &hf_c1222_crc,
{ "C12.22 CRC", "c1222.crc",
FT_UINT16, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_c1222_epsem_crypto_good,
{ "Crypto good", "c1222.crypto_good",
FT_BOOLEAN, BASE_NONE,
@ -1310,7 +1302,7 @@ void proto_register_c1222(void) {
sizeof(c1222_uat_data_t), /* record size */
"c1222_decryption_table", /* filename */
TRUE, /* from_profile */
(void*)&c1222_uat_data, /* data_ptr */
(void**)&c1222_uat_data, /* data_ptr */
&num_c1222_uat_data, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */

View File

@ -35,7 +35,6 @@
#include <glib.h>
#include <epan/conversation.h>
#include <wsutil/crc16.h>
#include <epan/expert.h>
#include <epan/packet.h>
#include <epan/prefs.h>
@ -121,7 +120,7 @@ static int hf_c1222_c1221_auth_request = -1; /* OCTET_STRING_SIZE_1_255 */
static int hf_c1222_c1221_auth_response = -1; /* OCTET_STRING_SIZE_CONSTR002 */
/*--- End of included file: packet-c1222-hf.c ---*/
#line 91 "../../asn1/c1222/packet-c1222-template.c"
#line 90 "../../asn1/c1222/packet-c1222-template.c"
/* These are the EPSEM pieces */
/* first, the flag components */
static int hf_c1222_epsem_flags = -1;
@ -149,7 +148,6 @@ static int hf_c1222_epsem_total = -1;
static int hf_c1222_cmd = -1;
static int hf_c1222_err = -1;
static int hf_c1222_data = -1;
static int hf_c1222_crc = -1;
/* individual epsem fields */
static int hf_c1222_logon_id = -1;
static int hf_c1222_logon_user = -1;
@ -225,7 +223,7 @@ static gint ett_c1222_Calling_authentication_value_c1222_U = -1;
static gint ett_c1222_Calling_authentication_value_c1221_U = -1;
/*--- End of included file: packet-c1222-ett.c ---*/
#line 184 "../../asn1/c1222/packet-c1222-template.c"
#line 182 "../../asn1/c1222/packet-c1222-template.c"
/*------------------------------
@ -331,11 +329,11 @@ static uat_t *c1222_uat;
#define FILL_START int length, start_offset = offset;
#define FILL_TABLE(fieldname) \
length = offset - start_offset; \
fieldname = tvb_memdup(tvb, start_offset, length); \
fieldname = (guint8 *)tvb_memdup(tvb, start_offset, length); \
fieldname##_len = length;
#define FILL_TABLE_TRUNCATE(fieldname, len) \
length = 1 + 2*(offset - start_offset); \
fieldname = tvb_memdup(tvb, start_offset, length); \
fieldname = (guint8 *)tvb_memdup(tvb, start_offset, length); \
fieldname##_len = len;
#else /* HAVE_LIBGCRYPT */
#define FILL_TABLE(fieldname)
@ -714,7 +712,7 @@ encode_ber_len(guint8 *ptr, guint32 n, int maxsize)
static void
c1222_uat_data_update_cb(void* n, const char** err)
{
c1222_uat_data_t* new_rec = n;
c1222_uat_data_t* new_rec = (c1222_uat_data_t *)n;
if (new_rec->keynum > 0xff) {
*err = "Invalid key number; must be less than 256";
@ -934,7 +932,7 @@ dissect_epsem(tvbuff_t *tvb, int offset, guint32 len, packet_info *pinfo, proto_
return offset;
encrypted = TRUE;
if (c1222_decrypt) {
buffer = tvb_memdup(tvb, offset, len2);
buffer = (guchar *)tvb_memdup(tvb, offset, len2);
if (!decrypt_packet(buffer, len2, TRUE)) {
g_free(buffer);
crypto_bad = TRUE;
@ -953,7 +951,7 @@ dissect_epsem(tvbuff_t *tvb, int offset, guint32 len, packet_info *pinfo, proto_
len2 = tvb_length_remaining(tvb, offset);
if (len2 <= 0)
return offset;
buffer = tvb_memdup(tvb, offset, len2);
buffer = (guchar *)tvb_memdup(tvb, offset, len2);
epsem_buffer = tvb_new_subset(tvb, offset, -1, -1);
if (c1222_decrypt) {
if (!decrypt_packet(buffer, len2, FALSE)) {
@ -1388,7 +1386,7 @@ dissect_c1222_Calling_authentication_value(gboolean implicit_tag _U_, tvbuff_t *
static int
dissect_c1222_User_information(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 26 "../../asn1/c1222/c1222.cnf"
gint8 class;
gint8 end_device_class;
gboolean pc, ind;
gint32 tag;
guint32 len;
@ -1397,11 +1395,11 @@ dissect_c1222_User_information(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int
FILL_START;
/* get Tag and Length */
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &class, &pc, &tag);
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &end_device_class, &pc, &tag);
offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind);
FILL_TABLE_TRUNCATE(user_information, len+offset-start_offset);
if (tag == 0x8) { /* BER_TAG_EXTERNAL */
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &class, &pc, &tag);
offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &end_device_class, &pc, &tag);
offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind);
if (tag == 0x1) { /* implicit octet string */
tf = proto_tree_add_item(tree, hf_c1222_user_information, tvb, offset, len, ENC_NA);
@ -1458,7 +1456,7 @@ static void dissect_C1222_MESSAGE_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_,
/*--- End of included file: packet-c1222-fn.c ---*/
#line 989 "../../asn1/c1222/packet-c1222-template.c"
#line 987 "../../asn1/c1222/packet-c1222-template.c"
/**
* Dissects a a full (reassembled) C12.22 message.
@ -1722,12 +1720,6 @@ void proto_register_c1222(void) {
NULL, 0x0,
NULL, HFILL }
},
{ &hf_c1222_crc,
{ "C12.22 CRC", "c1222.crc",
FT_UINT16, BASE_HEX,
NULL, 0x0,
NULL, HFILL }
},
{ &hf_c1222_epsem_crypto_good,
{ "Crypto good", "c1222.crypto_good",
FT_BOOLEAN, BASE_NONE,
@ -1829,7 +1821,7 @@ void proto_register_c1222(void) {
"OCTET_STRING_SIZE_CONSTR002", HFILL }},
/*--- End of included file: packet-c1222-hfarr.c ---*/
#line 1271 "../../asn1/c1222/packet-c1222-template.c"
#line 1263 "../../asn1/c1222/packet-c1222-template.c"
};
/* List of subtrees */
@ -1850,7 +1842,7 @@ void proto_register_c1222(void) {
&ett_c1222_Calling_authentication_value_c1221_U,
/*--- End of included file: packet-c1222-ettarr.c ---*/
#line 1281 "../../asn1/c1222/packet-c1222-template.c"
#line 1273 "../../asn1/c1222/packet-c1222-template.c"
};
module_t *c1222_module;
@ -1883,7 +1875,7 @@ void proto_register_c1222(void) {
sizeof(c1222_uat_data_t), /* record size */
"c1222_decryption_table", /* filename */
TRUE, /* from_profile */
(void*)&c1222_uat_data, /* data_ptr */
(void**)&c1222_uat_data, /* data_ptr */
&num_c1222_uat_data, /* numitems_ptr */
UAT_AFFECTS_DISSECTION, /* affects dissection of packets, but not set of named fields */
NULL, /* help */

View File

@ -421,12 +421,12 @@ static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out
*/
#define UAT_BUFFER_CB_DEF(basename,field_name,rec_t,ptr_element,len_element) \
static void basename ## _ ## field_name ## _set_cb(void* rec, const char* buf, guint len, const void* u1 _U_, const void* u2 _U_) {\
char* new_buf = len ? g_memdup(buf,len) : NULL; \
char* new_buf = len ? (char *)g_memdup(buf,len) : NULL; \
g_free((((rec_t*)rec)->ptr_element)); \
(((rec_t*)rec)->ptr_element) = new_buf; \
(((rec_t*)rec)->len_element) = len; } \
static void basename ## _ ## field_name ## _tostr_cb(void* rec, const char** out_ptr, unsigned* out_len, const void* u1 _U_, const void* u2 _U_) {\
*out_ptr = ((rec_t*)rec)->ptr_element ? ep_memdup(((rec_t*)rec)->ptr_element,((rec_t*)rec)->len_element) : ""; \
*out_ptr = ((rec_t*)rec)->ptr_element ? (const char*)ep_memdup(((rec_t*)rec)->ptr_element,((rec_t*)rec)->len_element) : ""; \
*out_len = ((rec_t*)rec)->len_element; }
#define UAT_FLD_BUFFER(basename,field_name,title,desc) \