本文整理汇总了C++中DISSECTOR_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ DISSECTOR_ASSERT函数的具体用法?C++ DISSECTOR_ASSERT怎么用?C++ DISSECTOR_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DISSECTOR_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dissect_ldss_transfer
/* Transfers happen in response to broadcasts, they are always TCP and are
* used to send the file to the port mentioned in the broadcast. There are
* 2 types of transfers: Pushes, which are direct responses to searches,
* in which the peer that has the file connects to the peer that doesn't and
* sends it, then disconnects. The other type of transfer is a pull, where
* the peer that doesn't have the file connects to the peer that does and
* requests it be sent.
*
* Pulls have a file request which identifies the desired file,
* while pushes simply send the file. In practice this works because every
* file the implementation sends searches for is on a different TCP port
* on the searcher's machine. */
static int
dissect_ldss_transfer (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
conversation_t *transfer_conv;
ldss_transfer_info_t *transfer_info;
struct tcpinfo *transfer_tcpinfo;
proto_tree *ti, *line_tree = NULL, *ldss_tree = NULL;
nstime_t broadcast_response_time;
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
transfer_tcpinfo = (struct tcpinfo *)data;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "LDSS");
/* Look for the transfer conversation; this was created during
* earlier broadcast dissection (see prepare_ldss_transfer_conv) */
transfer_conv = find_conversation (pinfo->num, &pinfo->src, &pinfo->dst,
PT_TCP, pinfo->srcport, pinfo->destport, 0);
DISSECTOR_ASSERT(transfer_conv);
transfer_info = (ldss_transfer_info_t *)conversation_get_proto_data(transfer_conv, proto_ldss);
DISSECTOR_ASSERT(transfer_info);
/* For a pull, the first packet in the TCP connection is the file request.
* First packet is identified by relative seq/ack numbers of 1.
* File request only appears on a pull (triggered by an offer - see above
* about broadcasts) */
if (transfer_tcpinfo->seq == 1 &&
transfer_tcpinfo->lastackseq == 1 &&
transfer_info->broadcast->message_id == MESSAGE_ID_WILLSEND) {
/* LDSS pull transfers look a lot like HTTP.
* Sample request:
* md5:01234567890123...
* Size: 2550
* Start: 0
* Compression: 0
* (remote end sends the file identified by the digest) */
guint offset = 0;
gboolean already_dissected = TRUE;
col_set_str(pinfo->cinfo, COL_INFO, "LDSS File Transfer (Requesting file - pull)");
if (highest_num_seen == 0 ||
highest_num_seen < pinfo->num) {
already_dissected = FALSE;
transfer_info->req = wmem_new0(wmem_file_scope(), ldss_file_request_t);
transfer_info->req->file = wmem_new0(wmem_file_scope(), ldss_file_t);
highest_num_seen = pinfo->num;
}
ti = proto_tree_add_item(tree, proto_ldss,
tvb, 0, tvb_reported_length(tvb), ENC_NA);
ldss_tree = proto_item_add_subtree(ti, ett_ldss_transfer);
/* Populate digest data into the file struct in the request */
transfer_info->file = transfer_info->req->file;
/* Grab each line from the packet, there should be 4 but lets
* not walk off the end looking for more. */
while (tvb_offset_exists(tvb, offset)) {
gint next_offset;
const guint8 *line;
int linelen;
gboolean is_digest_line;
guint digest_type_len;
linelen = tvb_find_line_end(tvb, offset, -1, &next_offset, FALSE);
/* Include new-line in line */
line = (guint8 *)tvb_memdup(wmem_packet_scope(), tvb, offset, linelen+1); /* XXX - memory leak? */
line_tree = proto_tree_add_subtree(ldss_tree, tvb, offset, linelen,
ett_ldss_transfer_req, NULL,
tvb_format_text(tvb, offset, next_offset-offset));
/* Reduce code duplication processing digest lines.
* There are too many locals to pass to a function - the signature
* looked pretty ugly when I tried! */
is_digest_line = FALSE;
if (strncmp(line,"md5:",4)==0) {
is_digest_line = TRUE;
digest_type_len = 4;
transfer_info->file->digest_type = DIGEST_TYPE_MD5;
}
else if (strncmp(line, "sha1:", 5)==0) {
//.........这里部分代码省略.........
示例2: dissect_adb
static gint
dissect_adb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
proto_item *main_item;
proto_tree *main_tree;
proto_item *arg0_item;
proto_tree *arg0_tree;
proto_item *arg1_item;
proto_tree *arg1_tree;
proto_item *magic_item;
proto_item *crc_item;
proto_tree *crc_tree = NULL;
proto_item *sub_item;
gint offset = 0;
guint32 command;
guint32 arg0;
guint32 arg1;
guint32 data_length = 0;
guint32 crc32 = 0;
usb_conv_info_t *usb_conv_info = NULL;
wmem_tree_key_t key[5];
guint32 interface_id;
guint32 bus_id;
guint32 device_address;
guint32 side_id;
guint32 frame_number;
gboolean is_command = TRUE;
gboolean is_next_fragment = FALSE;
gboolean is_service = FALSE;
gint proto;
gint direction = P2P_DIR_UNKNOWN;
wmem_tree_t *wmem_tree;
command_data_t *command_data = NULL;
service_data_t *service_data = NULL;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ADB");
col_clear(pinfo->cinfo, COL_INFO);
main_item = proto_tree_add_item(tree, proto_adb, tvb, offset, -1, ENC_NA);
main_tree = proto_item_add_subtree(main_item, ett_adb);
frame_number = pinfo->fd->num;
/* XXX: Why? If interface is USB only first try is correct
* (and seems strange...), in other cases standard check for
* previous protocol is correct */
proto = (gint) GPOINTER_TO_INT(wmem_list_frame_data(/*wmem_list_frame_prev*/(wmem_list_tail(pinfo->layers))));
if (proto != proto_usb) {
proto = (gint) GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_frame_prev(wmem_list_tail(pinfo->layers))));
}
if (proto == proto_usb) {
usb_conv_info = (usb_conv_info_t *) data;
DISSECTOR_ASSERT(usb_conv_info);
direction = usb_conv_info->direction;
} else if (proto == proto_tcp) {
if (pinfo->destport == ADB_TCP_PORT)
direction = P2P_DIR_SENT;
else
direction = P2P_DIR_RECV;
} else {
return offset;
}
if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID)
interface_id = pinfo->phdr->interface_id;
else
interface_id = 0;
if (proto == proto_usb) {
bus_id = usb_conv_info->bus_id;
device_address = usb_conv_info->device_address;
key[0].length = 1;
key[0].key = &interface_id;
key[1].length = 1;
key[1].key = &bus_id;
key[2].length = 1;
key[2].key = &device_address;
key[3].length = 0;
key[3].key = NULL;
} else { /* tcp */
key[0].length = 1;
key[0].key = &interface_id;
key[1].length = 1;
key[2].length = 1;
if (direction == P2P_DIR_SENT) {
key[1].key = &pinfo->srcport;
key[2].key = &pinfo->destport;
} else {
key[1].key = &pinfo->destport;
key[2].key = &pinfo->srcport;
}
key[3].length = 0;
key[3].key = NULL;
}
wmem_tree = (wmem_tree_t *) wmem_tree_lookup32_array(command_info, key);
if (wmem_tree) {
//.........这里部分代码省略.........
示例3: socks_udp_dissector
static void
socks_udp_dissector(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
/* Conversation dissector called from UDP dissector. Decode and display */
/* the socks header, the pass the rest of the data to the udp port */
/* decode routine to handle the payload. */
int offset = 0;
guint32 *ptr;
socks_hash_entry_t *hash_info;
conversation_t *conversation;
proto_tree *socks_tree;
proto_item *ti;
conversation = find_conversation( pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
pinfo->srcport, pinfo->destport, 0);
DISSECTOR_ASSERT( conversation); /* should always find a conversation */
hash_info = (socks_hash_entry_t *)conversation_get_proto_data(conversation, proto_socks);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "Socks");
col_set_str(pinfo->cinfo, COL_INFO, "Version: 5, UDP Associated packet");
if ( tree) {
ti = proto_tree_add_protocol_format( tree, proto_socks, tvb, offset, -1, "Socks" );
socks_tree = proto_item_add_subtree(ti, ett_socks);
proto_tree_add_item(socks_tree, hf_socks_reserved2, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item(socks_tree, hf_socks_fragment_number, tvb, offset, 1, ENC_NA);
offset += 1;
offset = display_address( tvb, offset, socks_tree);
hash_info->udp_remote_port = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint( socks_tree, hf_socks_dstport, tvb,
offset, 2, hash_info->udp_remote_port);
offset += 2;
}
else { /* no tree, skip past the socks header */
offset += 3;
offset = get_address_v5( tvb, offset, 0) + 2;
}
/* set pi src/dst port and call the udp sub-dissector lookup */
if ( pinfo->srcport == hash_info->port)
ptr = &pinfo->destport;
else
ptr = &pinfo->srcport;
*ptr = hash_info->udp_remote_port;
decode_udp_ports( tvb, offset, pinfo, tree, pinfo->srcport, pinfo->destport, -1);
*ptr = hash_info->udp_port;
}
示例4: DISSECTOR_ASSERT
fragment_head *stream_get_frag_data( const stream_pdu_fragment_t *frag)
{
DISSECTOR_ASSERT( frag );
return frag->pdu->fd_head;
}
示例5: dissect_xmpp
//.........这里部分代码省略.........
if(xmpp_tree)
xmpp_proto_tree_hide_first_child(xmpp_tree);
return;
}
if(!pinfo->private_data)
return;
/*data from XML dissector*/
xml_frame = ((xml_frame_t*)pinfo->private_data)->first_child;
if(!xml_frame)
return;
if (!xmpp_info) {
xmpp_info = se_new(xmpp_conv_info_t);
xmpp_info->req_resp = se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "xmpp_req_resp");
xmpp_info->jingle_sessions = se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "xmpp_jingle_sessions");
xmpp_info->ibb_sessions = se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "xmpp_ibb_sessions");
xmpp_info->gtalk_sessions = se_tree_create_non_persistent(EMEM_TREE_TYPE_RED_BLACK, "xmpp_gtalk_sessions");
xmpp_info->ssl_start = 0;
xmpp_info->ssl_proceed = 0;
conversation_add_proto_data(conversation, proto_xmpp, (void *) xmpp_info);
}
if (pinfo->match_uint == pinfo->destport)
out_packet = TRUE;
else
out_packet = FALSE;
while(xml_frame)
{
packet = xmpp_xml_frame_to_element_t(xml_frame, NULL, tvb);
DISSECTOR_ASSERT(packet);
if (strcmp(packet->name, "iq") == 0) {
xmpp_iq_reqresp_track(pinfo, packet, xmpp_info);
xmpp_jingle_session_track(pinfo, packet, xmpp_info);
xmpp_gtalk_session_track(pinfo, packet, xmpp_info);
}
if (strcmp(packet->name, "iq") == 0 || strcmp(packet->name, "message") == 0) {
xmpp_ibb_session_track(pinfo, packet, xmpp_info);
}
if (tree) { /* we are being asked for details */
proto_item *outin_item;
if (out_packet)
outin_item = proto_tree_add_boolean(xmpp_tree, hf_xmpp_out, tvb, 0, 0, TRUE);
else
outin_item = proto_tree_add_boolean(xmpp_tree, hf_xmpp_in, tvb, 0, 0, TRUE);
PROTO_ITEM_SET_HIDDEN(outin_item);
/*it hides tree generated by XML dissector*/
xmpp_proto_tree_hide_first_child(xmpp_tree);
if (strcmp(packet->name, "iq") == 0) {
xmpp_iq(xmpp_tree, tvb, pinfo, packet);
} else if (strcmp(packet->name, "presence") == 0) {
xmpp_presence(xmpp_tree, tvb, pinfo, packet);
} else if (strcmp(packet->name, "message") == 0) {
xmpp_message(xmpp_tree, tvb, pinfo, packet);
} else if (strcmp(packet->name, "auth") == 0) {
示例6: asn1_stack_frame_pop
void asn1_stack_frame_pop(asn1_ctx_t *actx, const gchar *name) {
DISSECTOR_ASSERT(actx->stack);
DISSECTOR_ASSERT(!strcmp(actx->stack->name, name));
actx->stack = actx->stack->next;
}
示例7: gcp_trx
gcp_trx_t* gcp_trx(gcp_msg_t* m ,guint32 t_id , gcp_trx_type_t type, gboolean keep_persistent_data) {
gcp_trx_t* t = NULL;
gcp_trx_msg_t* trxmsg;
if ( !m ) return NULL;
if (keep_persistent_data) {
if (m->committed) {
for ( trxmsg = m->trxs; trxmsg; trxmsg = trxmsg->next) {
if (trxmsg->trx && trxmsg->trx->id == t_id) {
return trxmsg->trx;
}
}
DISSECTOR_ASSERT_NOT_REACHED();
} else {
wmem_tree_key_t key[4];
key[0].length = 1;
key[0].key = &(m->hi_addr);
key[1].length = 1;
key[1].key = &(m->lo_addr);
key[2].length = 1;
key[2].key = &(t_id);
key[3].length = 0;
key[3].key = NULL;
trxmsg = wmem_new(wmem_file_scope(), gcp_trx_msg_t);
t = (gcp_trx_t *)wmem_tree_lookup32_array(trxs,key);
if (!t) {
t = wmem_new(wmem_file_scope(), gcp_trx_t);
t->initial = m;
t->id = t_id;
t->type = type;
t->pendings = 0;
t->error = 0;
t->cmds = NULL;
wmem_tree_insert32_array(trxs,key,t);
}
/* XXX: request, reply and ack + point to frames where they are */
switch ( type ) {
case GCP_TRX_PENDING:
t->pendings++;
break;
default:
break;
}
}
} else {
t = wmem_new(wmem_packet_scope(), gcp_trx_t);
trxmsg = wmem_new(wmem_packet_scope(), gcp_trx_msg_t);
t->initial = NULL;
t->id = t_id;
t->type = type;
t->pendings = 0;
t->error = 0;
t->cmds = NULL;
}
DISSECTOR_ASSERT(trxmsg);
trxmsg->trx = t;
trxmsg->next = NULL;
trxmsg->last = trxmsg;
if (m->trxs) {
m->trxs->last = m->trxs->last->next = trxmsg;
} else {
m->trxs = trxmsg;
}
return t;
}
示例8: _try_val_to_str_ext_init
/* Initializes an extended value string. Behaves like a match function to
* permit lazy initialization of extended value strings.
* - Goes through the value_string array to determine the fastest possible
* access method.
* - Verifies that the value_string contains no NULL string pointers.
* - Verifies that the value_string is terminated by {0, NULL}
*/
const value_string *
_try_val_to_str_ext_init(const guint32 val, const value_string_ext *a_vse)
{
/* Cast away the constness!
* It's better if the prototype for this function matches the other
* _try_val_to_str_* functions (so we don't have to cast it when storing it
* in _try_val_to_str so the compiler will notice if the prototypes get out
* of sync), but the init function is unique in that it does actually
* modify the vse.
*/
value_string_ext *vse = (value_string_ext *)a_vse;
const value_string *vs_p = vse->_vs_p;
const guint vs_num_entries = vse->_vs_num_entries;
/* The matching algorithm used:
* VS_SEARCH - slow sequential search (as in a normal value string)
* VS_BIN_TREE - log(n)-time binary search, the values must be sorted
* VS_INDEX - constant-time index lookup, the values must be contiguous
*/
enum { VS_SEARCH, VS_BIN_TREE, VS_INDEX } type = VS_INDEX;
/* Note: The value_string 'value' is *unsigned*, but we do a little magic
* to help with value strings that have negative values.
*
* { -3, -2, -1, 0, 1, 2 }
* will be treated as "ascending ordered" (although it isn't technically),
* thus allowing constant-time index search
*
* { -3, -2, 0, 1, 2 } and { -3, -2, -1, 0, 2 }
* will both be considered as "out-of-order with gaps", thus falling
* back to the slow linear search
*
* { 0, 1, 2, -3, -2 } and { 0, 2, -3, -2, -1 }
* will be considered "ascending ordered with gaps" thus allowing
* a log(n)-time 'binary' search
*
* If you're confused, think of how negative values are represented, or
* google two's complement.
*/
guint32 prev_value;
guint first_value;
guint i;
DISSECTOR_ASSERT((vs_p[vs_num_entries].value == 0) &&
(vs_p[vs_num_entries].strptr == NULL));
vse->_vs_first_value = vs_p[0].value;
first_value = vs_p[0].value;
prev_value = first_value;
for (i = 0; i < vs_num_entries; i++) {
DISSECTOR_ASSERT(vs_p[i].strptr != NULL);
if ((type == VS_INDEX) && (vs_p[i].value != (i + first_value))) {
type = VS_BIN_TREE;
}
/* XXX: Should check for dups ?? */
if (type == VS_BIN_TREE) {
if (prev_value > vs_p[i].value) {
g_warning("Extended value string %s forced to fall back to linear search: entry %u, value %u < previous entry, value %u",
vse->_vs_name, i, vs_p[i].value, prev_value);
type = VS_SEARCH;
break;
}
if (first_value > vs_p[i].value) {
g_warning("Extended value string %s forced to fall back to linear search: entry %u, value %u < first entry, value %u",
vse->_vs_name, i, vs_p[i].value, first_value);
type = VS_SEARCH;
break;
}
}
prev_value = vs_p[i].value;
}
switch (type) {
case VS_SEARCH:
vse->_vs_match2 = _try_val_to_str_linear;
break;
case VS_BIN_TREE:
vse->_vs_match2 = _try_val_to_str_bsearch;
break;
case VS_INDEX:
vse->_vs_match2 = _try_val_to_str_index;
break;
default:
g_assert_not_reached();
break;
}
return vse->_vs_match2(val, vse);
}
示例9: print_field_value
static gboolean print_field_value(field_info *finfo, int cmd_line_index)
{
header_field_info *hfinfo;
static char *fs_buf = NULL;
char *fs_ptr = fs_buf;
static GString *label_s = NULL;
int fs_buf_len = FIELD_STR_INIT_LEN, fs_len;
guint i;
string_fmt_t *sf;
guint32 uvalue;
gint32 svalue;
const true_false_string *tfstring = &tfs_true_false;
hfinfo = finfo->hfinfo;
if (!fs_buf) {
fs_buf = g_malloc(fs_buf_len + 1);
fs_ptr = fs_buf;
}
if (!label_s) {
label_s = g_string_new("");
}
if(finfo->value.ftype->val_to_string_repr)
{
/*
* this field has an associated value,
* e.g: ip.hdr_len
*/
fs_len = fvalue_string_repr_len(&finfo->value, FTREPR_DFILTER);
while (fs_buf_len < fs_len) {
fs_buf_len *= 2;
fs_buf = g_realloc(fs_buf, fs_buf_len + 1);
fs_ptr = fs_buf;
}
fvalue_to_string_repr(&finfo->value,
FTREPR_DFILTER,
fs_buf);
/* String types are quoted. Remove them. */
if ((finfo->value.ftype->ftype == FT_STRING || finfo->value.ftype->ftype == FT_STRINGZ) && fs_len > 2) {
fs_buf[fs_len - 1] = '\0';
fs_ptr++;
}
}
if (string_fmts->len > 0 && finfo->hfinfo->strings) {
g_string_truncate(label_s, 0);
for (i = 0; i < string_fmts->len; i++) {
sf = g_ptr_array_index(string_fmts, i);
if (sf->plain) {
g_string_append(label_s, sf->plain);
} else {
switch (sf->format) {
case SF_NAME:
g_string_append(label_s, hfinfo->name);
break;
case SF_NUMVAL:
g_string_append(label_s, fs_ptr);
break;
case SF_STRVAL:
switch(hfinfo->type) {
case FT_BOOLEAN:
uvalue = fvalue_get_uinteger(&finfo->value);
tfstring = (const struct true_false_string*) hfinfo->strings;
g_string_append(label_s, uvalue ? tfstring->true_string : tfstring->false_string);
break;
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
DISSECTOR_ASSERT(!hfinfo->bitmask);
svalue = fvalue_get_sinteger(&finfo->value);
if (hfinfo->display & BASE_RANGE_STRING) {
g_string_append(label_s, rval_to_str(svalue, hfinfo->strings, "Unknown"));
} else {
g_string_append(label_s, val_to_str(svalue, cVALS(hfinfo->strings), "Unknown"));
}
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
uvalue = fvalue_get_uinteger(&finfo->value);
if (!hfinfo->bitmask && hfinfo->display & BASE_RANGE_STRING) {
g_string_append(label_s, rval_to_str(uvalue, hfinfo->strings, "Unknown"));
} else {
g_string_append(label_s, val_to_str(uvalue, cVALS(hfinfo->strings), "Unknown"));
}
break;
default:
break;
}
break;
default:
break;
}
}
}
printf(" %u=\"%s\"", cmd_line_index, label_s->str);
//.........这里部分代码省略.........
示例10: dissect_pcap_pktdata
static int
dissect_pcap_pktdata(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
gint offset = 0;
guint32 *link_type;
guint32 length = 0;
tvbuff_t *next_tvb;
proto_item *pseudoheader_item;
proto_tree *pseudoheader_tree = NULL;
proto_item *packet_item;
proto_tree *packet_tree;
DISSECTOR_ASSERT(data);
link_type = (guint32 *) data;
pinfo->phdr->pkt_encap = wtap_pcap_encap_to_wtap_encap(*link_type);
switch (*link_type) {
case 139:
/* TODO no description for pseudoheader at http://www.tcpdump.org/linktypes.html */
break;
case 196:
length = 5;
break;
case 197:
/* TODO no description for pseudoheader at http://www.tcpdump.org/linktypes.html */
break;
case 201:
length = 4;
break;
case 204:
length = 1;
break;
case 205:
length = 1;
break;
case 206:
length = 1;
break;
case 209:
length = 6;
break;
case 226:
length = 24;
break;
case 227:
/* TODO no description for pseudoheader at http://www.tcpdump.org/linktypes.html */
break;
case 240:
case 241:
length = 4;
break;
case 244:
length = 20;
break;
case 245:
length = 20;
break;
}
if (length > 0) {
pseudoheader_item = proto_tree_add_item(tree, hf_pcap_pktdata_pseudoheader, tvb, offset, length, ENC_NA);
pseudoheader_tree = proto_item_add_subtree(pseudoheader_item, ett_pcap_pktdata_pseudoheader);
}
switch (*link_type) {
case 201:
proto_tree_add_item(pseudoheader_tree, hf_pcap_pktdata_pseudoheader_bluetooth_direction, tvb, offset, 4, ENC_BIG_ENDIAN);
if (tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN) == 0)
pinfo->p2p_dir = P2P_DIR_SENT;
else if (tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN) == 1)
pinfo->p2p_dir = P2P_DIR_RECV;
else
pinfo->p2p_dir = P2P_DIR_UNKNOWN;
offset += 4;
break;
default:
offset += length;
}
next_tvb = tvb_new_subset_remaining(tvb, offset);
packet_item = proto_tree_add_item(tree, hf_pcap_pktdata_data, tvb, offset, tvb_reported_length(next_tvb), ENC_NA);
packet_tree = proto_item_add_subtree(packet_item, ett_pcap_pktdata_data);
offset = dissector_try_uint_new(wtap_encap_table, pinfo->phdr->pkt_encap, next_tvb, pinfo, packet_tree, TRUE, NULL);
return offset;
}
示例11: dissect_pbb_addressblock
static int dissect_pbb_addressblock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, guint maxoffset,
guint8 addressType, guint8 addressSize) {
guint8 addr[MAX_ADDR_SIZE];
guint8 numAddr;
guint8 address_flags;
guint8 head_length = 0, tail_length = 0;
guint block_length = 0, midSize = 0;
guint block_index = 0, head_index = 0, tail_index = 0, mid_index = 0, prefix_index = 0;
proto_tree *addr_tree = NULL;
proto_tree *addrFlags_tree = NULL;
proto_tree *addrValue_tree = NULL;
proto_item *addr_item = NULL;
proto_item *addrFlags_item = NULL;
proto_item *addrValue_item = NULL;
int i = 0;
if (maxoffset - offset < 2) {
proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset,
"Not enough octets for minimal addressblock header");
return tvb_reported_length(tvb);
}
DISSECTOR_ASSERT(addressSize <= MAX_ADDR_SIZE);
memset(addr, 0, addressSize);
block_length = 2;
block_index = offset;
midSize = addressSize;
numAddr = tvb_get_guint8(tvb, offset++);
address_flags = tvb_get_guint8(tvb, offset++);
if ((address_flags & ADDR_HASHEAD) != 0) {
head_index = offset;
if (maxoffset - offset <= 0) {
proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset,
"Not enough octets for addressblock head");
return tvb_reported_length(tvb);
}
head_length = tvb_get_guint8(tvb, offset++);
if (head_length > addressSize-1) {
proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset,
"address head length is too long");
return tvb_reported_length(tvb);
}
if (maxoffset - offset < head_length) {
proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset,
"Not enough octets for addressblock head");
return tvb_reported_length(tvb);
}
tvb_memcpy(tvb, addr, offset, head_length);
midSize -= head_length;
block_length += (head_length+1);
offset += head_length;
}
if ((address_flags & ADDR_HASZEROTAIL) != 0) {
tail_index = offset;
if (maxoffset - offset <= 0) {
proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset,
"Not enough octets for addressblock tail");
return tvb_reported_length(tvb);
}
tail_length = tvb_get_guint8(tvb, offset++);
if (tail_length > addressSize-1-head_length) {
proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset,
"address tail length is too long");
return tvb_reported_length(tvb);
}
midSize -= tail_length;
block_length++;
}
else if ((address_flags & ADDR_HASFULLTAIL) != 0) {
tail_index = offset;
if (maxoffset - offset <= 0) {
proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset,
"Not enough octets for addressblock tail");
return tvb_reported_length(tvb);
}
tail_length = tvb_get_guint8(tvb, offset++);
if (tail_length > addressSize-1-head_length) {
proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset,
"address tail length is too long");
return tvb_reported_length(tvb);
}
if (maxoffset - offset < tail_length) {
proto_tree_add_expert_format(tree, pinfo, &ei_packetbb_error, tvb, offset, maxoffset - offset,
"Not enough octets for addressblock tail");
return tvb_reported_length(tvb);
}
//.........这里部分代码省略.........
示例12: gcp_ctx
gcp_ctx_t* gcp_ctx(gcp_msg_t* m, gcp_trx_t* t, guint32 c_id, gboolean persistent) {
gcp_ctx_t* context = NULL;
gcp_ctx_t** context_p = NULL;
if ( !m || !t ) return NULL;
if (persistent) {
wmem_tree_key_t ctx_key[4];
wmem_tree_key_t trx_key[4];
ctx_key[0].length = 1;
ctx_key[0].key = &(m->hi_addr);
ctx_key[1].length = 1;
ctx_key[1].key = &(m->lo_addr);
ctx_key[2].length = 1;
ctx_key[2].key = &(c_id);
ctx_key[3].length = 0;
ctx_key[3].key = NULL;
trx_key[0].length = 1;
trx_key[0].key = &(m->hi_addr);
trx_key[1].length = 1;
trx_key[1].key = &(m->lo_addr);
trx_key[2].length = 1;
trx_key[2].key = &(t->id);
trx_key[3].length = 0;
trx_key[3].key = NULL;
if (m->committed) {
if (( context = (gcp_ctx_t *)wmem_tree_lookup32_array(ctxs_by_trx,trx_key) )) {
return context;
} if ((context_p = (gcp_ctx_t **)wmem_tree_lookup32_array(ctxs,ctx_key))) {
context = *context_p;
do {
if (context->initial->framenum <= m->framenum) {
return context;
}
} while(( context = context->prev ));
DISSECTOR_ASSERT(! "a context should exist");
}
} else {
if (c_id == CHOOSE_CONTEXT) {
if (! ( context = (gcp_ctx_t *)wmem_tree_lookup32_array(ctxs_by_trx,trx_key))) {
context = wmem_new(wmem_file_scope(), gcp_ctx_t);
context->initial = m;
context->cmds = NULL;
context->id = c_id;
context->terms.last = &(context->terms);
context->terms.next = NULL;
context->terms.term = NULL;
wmem_tree_insert32_array(ctxs_by_trx,trx_key,context);
}
} else {
if (( context = (gcp_ctx_t *)wmem_tree_lookup32_array(ctxs_by_trx,trx_key) )) {
if (( context_p = (gcp_ctx_t **)wmem_tree_lookup32_array(ctxs,ctx_key) )) {
if (context != *context_p) {
if(context->id != CHOOSE_CONTEXT) {
context = wmem_new(wmem_file_scope(), gcp_ctx_t);
}
context->initial = m;
context->id = c_id;
context->cmds = NULL;
context->terms.last = &(context->terms);
context->terms.next = NULL;
context->terms.term = NULL;
context->prev = *context_p;
*context_p = context;
}
} else {
context_p = wmem_new(wmem_file_scope(), gcp_ctx_t*);
*context_p = context;
context->initial = m;
context->id = c_id;
wmem_tree_insert32_array(ctxs,ctx_key,context_p);
}
} else if (! ( context_p = (gcp_ctx_t**)wmem_tree_lookup32_array(ctxs,ctx_key) )) {
context = wmem_new(wmem_file_scope(), gcp_ctx_t);
context->initial = m;
context->id = c_id;
context->cmds = NULL;
context->terms.last = &(context->terms);
context->terms.next = NULL;
context->terms.term = NULL;
context_p = wmem_new(wmem_file_scope(), gcp_ctx_t*);
*context_p = context;
wmem_tree_insert32_array(ctxs,ctx_key,context_p);
} else {
context = *context_p;
}
}
示例13: stream_get_frag_length
guint32 stream_get_frag_length( const stream_pdu_fragment_t *frag)
{
DISSECTOR_ASSERT( frag );
return frag->len;
}
示例14: dissect_q932_ros
/*--- dissect_q932_ros -----------------------------------------------------*/
static int dissect_q932_ros(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
rose_ctx_tmp = get_rose_ctx(pinfo->private_data);
DISSECTOR_ASSERT(rose_ctx_tmp);
return dissect_ROS_PDU(tvb, pinfo, tree);
}
示例15: stream_get_pdu_no
guint32 stream_get_pdu_no( const stream_pdu_fragment_t *frag)
{
DISSECTOR_ASSERT( frag );
return frag->pdu->pdu_number;
}