这篇教程C++ DISSECTOR_ASSERT函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中DISSECTOR_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ DISSECTOR_ASSERT函数的具体用法?C++ DISSECTOR_ASSERT怎么用?C++ DISSECTOR_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了DISSECTOR_ASSERT函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 intdissect_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) {//.........这里部分代码省略.........
开发者ID:crondaemon,项目名称:wireshark,代码行数:101,
示例2: dissect_adbstatic gintdissect_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) {//.........这里部分代码省略.........
开发者ID:ARK1988,项目名称:wireshark,代码行数:101,
示例3: socks_udp_dissectorstatic voidsocks_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;}
开发者ID:pvons,项目名称:wireshark,代码行数:61,
示例4: DISSECTOR_ASSERTfragment_head *stream_get_frag_data( const stream_pdu_fragment_t *frag){ DISSECTOR_ASSERT( frag ); return frag->pdu->fd_head;}
开发者ID:acaceres2176,项目名称:wireshark,代码行数:5,
示例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) {
开发者ID:drower,项目名称:wireshark-1.10.0,代码行数:67,
示例6: asn1_stack_frame_popvoid 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;}
开发者ID:nehaahir,项目名称:wireshark,代码行数:5,
示例7: gcp_trxgcp_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;}
开发者ID:koyeen,项目名称:wireshark,代码行数:77,
示例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);}
开发者ID:qnofae,项目名称:wireshark,代码行数:100,
示例9: print_field_valuestatic 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);//.........这里部分代码省略.........
开发者ID:RazZziel,项目名称:wireshark-dplay,代码行数:101,
示例10: dissect_pcap_pktdatastatic intdissect_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;}
开发者ID:appneta,项目名称:wireshark,代码行数:89,
示例11: dissect_pbb_addressblockstatic 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); }//.........这里部分代码省略.........
开发者ID:JudsonWilson,项目名称:wireshark,代码行数:101,
示例12: gcp_ctxgcp_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; } }
开发者ID:koyeen,项目名称:wireshark,代码行数:96,
示例13: stream_get_frag_lengthguint32 stream_get_frag_length( const stream_pdu_fragment_t *frag){ DISSECTOR_ASSERT( frag ); return frag->len;}
开发者ID:acaceres2176,项目名称:wireshark,代码行数:5,
示例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);}
开发者ID:asriadi,项目名称:wireshark,代码行数:6,
示例15: stream_get_pdu_noguint32 stream_get_pdu_no( const stream_pdu_fragment_t *frag){ DISSECTOR_ASSERT( frag ); return frag->pdu->pdu_number;}
开发者ID:acaceres2176,项目名称:wireshark,代码行数:5,
示例16: dissect_usb_i1d3_commandstatic void dissect_usb_i1d3_command( tvbuff_t *tvb, packet_info *pinfo, usb_i1d3_conversation_t *conversation, proto_tree *tree) { // Parsing the command code is a bit tricky: if the most significant // byte is non-zero, the command code is the most significant byte, // *and* the next byte is the first byte of the payload. guint32 command_code = tvb_get_ntohs(tvb, 0); guint32 command_code_msb = command_code & 0xff00; gint command_code_length = 2; if (command_code_msb) { command_code = command_code_msb; command_code_length = 1; } proto_item *command_code_item = proto_tree_add_uint( tree, hf_usb_i1d3_command_code, tvb, 0, command_code_length, command_code); usb_i1d3_transaction_t *transaction; if (!PINFO_FD_VISITED(pinfo)) { transaction = usb_i1d3_create_transaction(conversation, pinfo->num); transaction->command_code = command_code; } else { transaction = (usb_i1d3_transaction_t *)wmem_map_lookup( conversation->request_to_transaction, GUINT_TO_POINTER(pinfo->num)); } DISSECTOR_ASSERT(transaction); if (transaction->response != 0) { proto_item *response_item = proto_tree_add_uint( tree, hf_usb_i1d3_response_in, tvb, 0, 0, transaction->response); PROTO_ITEM_SET_GENERATED(response_item); } const gchar *command_code_string = try_val_to_str( command_code, usb_i1d3_command_code_strings); if (command_code_string) { col_set_str(pinfo->cinfo, COL_INFO, command_code_string); } else { expert_add_info(pinfo, command_code_item, &ei_usb_i1d3_unknown_command); col_set_str(pinfo->cinfo, COL_INFO, "Unknown command"); } switch (command_code) { case USB_I1D3_LOCKRESP: { // TODO: verify that the challenge response is correct proto_tree_add_item( tree, hf_usb_i1d3_challenge_response, tvb, 24, 16, ENC_NA); break; } case USB_I1D3_READINTEE: { guint32 offset, length; proto_tree_add_item_ret_uint( tree, hf_usb_i1d3_readintee_offset, tvb, 1, 1, ENC_NA, &offset); proto_tree_add_item_ret_uint( tree, hf_usb_i1d3_readintee_length, tvb, 2, 1, ENC_NA, &length); col_add_fstr(pinfo->cinfo, COL_INFO, "%s (offset: %u, length: %u)", command_code_string, offset, length); if (!PINFO_FD_VISITED(pinfo)) { transaction->offset = offset; transaction->length = length; } break; } case USB_I1D3_READEXTEE: { guint32 offset, length; proto_tree_add_item_ret_uint( tree, hf_usb_i1d3_readextee_offset, tvb, 1, 2, ENC_BIG_ENDIAN, &offset); proto_tree_add_item_ret_uint( tree, hf_usb_i1d3_readextee_length, tvb, 3, 1, ENC_NA, &length); col_add_fstr(pinfo->cinfo, COL_INFO, "%s (offset: %u, length: %u)", command_code_string, offset, length); if (!PINFO_FD_VISITED(pinfo)) { transaction->offset = offset; transaction->length = length; } break; } case USB_I1D3_MEASURE1: { guint32 integration_time; proto_item *integration_time_item = proto_tree_add_item_ret_uint( tree, hf_usb_i1d3_requested_integration_time, tvb, 1, 4, ENC_LITTLE_ENDIAN, &integration_time); double integration_time_seconds = integration_time / USB_I1D3_CLOCK_FREQUENCY; proto_item_append_text( integration_time_item, " [%.6f seconds]", integration_time_seconds); col_add_fstr(pinfo->cinfo, COL_INFO, "Measure for %.6fs", integration_time_seconds); break;//.........这里部分代码省略.........
开发者ID:HeartFlying,项目名称:wireshark,代码行数:101,
示例17: proto_reg_handoff_gsm_sms_udvoidproto_reg_handoff_gsm_sms_ud(void){ wsp_handle = find_dissector("wsp-cl"); DISSECTOR_ASSERT(wsp_handle);}
开发者ID:MultipathDTLS,项目名称:wireshark,代码行数:6,
示例18: dissect_usb_i1d3_responsestatic void dissect_usb_i1d3_response( tvbuff_t *tvb, packet_info *pinfo, usb_i1d3_conversation_t *conversation, proto_tree *tree) { // The response packet does not contain any information about the command // it is a response to, so we need to reconstruct this information using the // previous packet that we saw. // // Note: currently, for simplicity's sake, this assumes that there is only // one inflight request at any given time - in other words, that there is no // pipelining going on. It is not clear if the device would even be able to // service more than one request at the same time in the first place. usb_i1d3_transaction_t *transaction; if (!PINFO_FD_VISITED(pinfo)) { transaction = (usb_i1d3_transaction_t *)wmem_map_lookup( conversation->request_to_transaction, GUINT_TO_POINTER(conversation->previous_packet)); if (transaction) { DISSECTOR_ASSERT(transaction->response == 0); transaction->response = pinfo->num; wmem_map_insert( conversation->response_to_transaction, GUINT_TO_POINTER(transaction->response), (void *)transaction); } } else { // After the first pass, we can't use previous_packet anymore since // there is no guarantee the dissector is called in order, so we use // the reverse mapping that we populated above. transaction = (usb_i1d3_transaction_t *)wmem_map_lookup( conversation->response_to_transaction, GUINT_TO_POINTER(pinfo->num)); } if (transaction) { DISSECTOR_ASSERT(transaction->response == pinfo->num); DISSECTOR_ASSERT(transaction->request != 0); } proto_item *request_item = proto_tree_add_uint( tree, hf_usb_i1d3_request_in, tvb, 0, 0, transaction ? transaction->request : 0); PROTO_ITEM_SET_GENERATED(request_item); if (!transaction) { expert_add_info(pinfo, request_item, &ei_usb_i1d3_unexpected_response); } else { proto_item *command_code_item = proto_tree_add_uint( tree, hf_usb_i1d3_command_code, tvb, 0, 0, transaction->command_code); PROTO_ITEM_SET_GENERATED(command_code_item); } const gchar *command_string = transaction ? try_val_to_str( transaction->command_code, usb_i1d3_command_code_strings) : NULL; if (!command_string) command_string = "unknown"; guint32 response_code; proto_item *response_code_item = proto_tree_add_item_ret_uint( tree, hf_usb_i1d3_response_code, tvb, 0, 1, ENC_NA, &response_code); proto_item_append_text( response_code_item, " (%s)", (response_code == 0) ? "OK" : "error"); if (response_code != 0) { col_add_fstr( pinfo->cinfo, COL_INFO, "Error code %u (%s)", response_code, command_string); expert_add_info(pinfo, response_code_item, &ei_usb_i1d3_error); return; } col_add_fstr(pinfo->cinfo, COL_INFO, "OK (%s)", command_string); if (!transaction) return; // As mentioned in ArgyllCMS spectro/i1d3.c, the second byte is usually the // first byte of the command code, except for GET_DIFF. if (transaction->command_code != USB_I1D3_GET_DIFF) { guint32 echoed_command_code; proto_item *echoed_command_code_item = proto_tree_add_item_ret_uint( tree, hf_usb_i1d3_echoed_command_code, tvb, 1, 1, ENC_NA, &echoed_command_code); guint8 expected_command_code = transaction->command_code >> 8; proto_item_append_text( echoed_command_code_item, " [expected 0x%02x]", expected_command_code); if (echoed_command_code != expected_command_code) { expert_add_info( pinfo, echoed_command_code_item, &ei_usb_i1d3_echoed_command_code_mismatch); } }
开发者ID:HeartFlying,项目名称:wireshark,代码行数:88,
示例19: dissect_cpfi_header/* Header */static voiddissect_cpfi_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){ guint32 word1;#if 0 guint32 word2;#endif guint32 tda; guint32 src; guint8 src_instance = 0; guint8 src_board = 0; guint8 src_port = 0; guint32 dst; guint8 dst_instance = 0; guint8 dst_board = 0; guint8 dst_port = 0; proto_tree *extra_tree = NULL; /* add a tree for the header */ if ( tree != NULL) { proto_item *extra_item; extra_item = proto_tree_add_protocol_format(tree, proto_cpfi, tvb, 0, -1, "Header"); extra_tree = proto_item_add_subtree(extra_item, ett_cpfi_header); } /* Extract the common header, and get the bits we need */ word1 = tvb_get_ntohl (tvb, 0);#if 0 word2 = tvb_get_ntohl (tvb, sizeof(word1));#endif /* Figure out where the frame came from. dstTDA is source of frame! */ tda = (word1 & CPFI_DEST_MASK) >> CPFI_DEST_SHIFT; if ( tda >= FIRST_TIO_CARD_ADDRESS ) { g_strlcpy(src_str, " CPFI", sizeof(src_str)); src = 0; /* Make it smallest */ } else { const guint8 *srcmac; /* Make sure this is an Ethernet address. */ DISSECTOR_ASSERT(pinfo->src.type == AT_ETHER); srcmac = (const guint8 *)pinfo->src.data; src_instance = srcmac[2]-1; src_board = tda >> 4; src_port = tda & 0x0f; src = (1 << 24) + (src_instance << 16) + (src_board << 8) + src_port; g_snprintf(src_str, sizeof(src_str), "%u.%u.%u", src_instance, src_board, src_port); } /* Figure out where the frame is going. srcTDA is destination of frame! */ tda = (word1 & CPFI_SOURCE_MASK) >> CPFI_SOURCE_SHIFT; if ( tda >= FIRST_TIO_CARD_ADDRESS ) { g_strlcpy(dst_str, " CPFI", sizeof(dst_str)); dst = 0; /* Make it smallest */ } else { const guint8 *dstmac; /* Make sure this is an Ethernet address. */ DISSECTOR_ASSERT(pinfo->dst.type == AT_ETHER); dstmac = (const guint8 *)pinfo->dst.data; dst_instance = dstmac[2]-1; dst_board = tda >> 4; dst_port = tda & 0x0f; dst = (1 << 24) + (dst_instance << 16) + (dst_board << 8) + dst_port; g_snprintf(dst_str, sizeof(dst_str), "%u.%u.%u", dst_instance, dst_board, dst_port); } /* Set up the source and destination and arrow per user configuration. */ if ( cpfi_arrow_moves && (dst < src) ) { left = dst_str; arrow = r_to_l_arrow; right = src_str; } else { left = src_str; arrow = l_to_r_arrow; right = dst_str; } if (extra_tree) { proto_item *hidden_item; /* For "real" TDAs (i.e. not for microTDAs), add hidden addresses to allow filtering */ if ( src != 0 ) { hidden_item = proto_tree_add_bytes(extra_tree, hf_cpfi_t_instance, tvb, 0, 1, &src_instance); PROTO_ITEM_SET_HIDDEN(hidden_item); hidden_item = proto_tree_add_bytes(extra_tree, hf_cpfi_t_src_instance, tvb, 0, 1, &src_instance); PROTO_ITEM_SET_HIDDEN(hidden_item);//.........这里部分代码省略.........
开发者ID:MichaelQQ,项目名称:Wireshark-PE,代码行数:101,
示例20: save_commandstatic voidsave_command(guint32 cmd, guint32 arg0, guint32 arg1, guint32 data_length, guint32 crc32, service_data_t *service_data, gint proto, void *data, packet_info *pinfo, service_data_t **returned_service_data, command_data_t **returned_command_data){ wmem_tree_key_t key[6]; guint32 interface_id; guint32 bus_id; guint32 device_address; guint32 side_id; guint32 frame_number; command_data_t *command_data; wmem_tree_t *wmem_tree; gint direction = P2P_DIR_UNKNOWN; usb_conv_info_t *usb_conv_info = (usb_conv_info_t *) data; frame_number = pinfo->fd->num; if (pinfo->phdr->presence_flags & WTAP_HAS_INTERFACE_ID) interface_id = pinfo->phdr->interface_id; else interface_id = 0; if (proto == proto_usb) { usb_conv_info = (usb_conv_info_t *) data; DISSECTOR_ASSERT(usb_conv_info); direction = usb_conv_info->direction; 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 = 1; key[3].key = &side_id; key[4].length = 1; key[4].key = &frame_number; key[5].length = 0; key[5].key = NULL; } else { /* tcp */ if (pinfo->destport == ADB_TCP_PORT) direction = P2P_DIR_SENT; else direction = P2P_DIR_RECV; 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 = 1; key[3].key = &side_id; key[4].length = 1; key[4].key = &frame_number; key[5].length = 0; key[5].key = NULL; } if (direction == P2P_DIR_SENT) if (cmd == A_CLSE) side_id = arg1; /* OUT: local id */ else side_id = arg0; /* OUT: local id */ else side_id = arg1; /* IN: remote id */ if (cmd == A_OPEN) { service_data = wmem_new(wmem_file_scope(), service_data_t); service_data->start_in_frame = pinfo->fd->num; service_data->close_local_in_frame = max_in_frame; service_data->close_remote_in_frame = max_in_frame; service_data->local_id = arg0; service_data->remote_id = arg1; service_data->service = "unknown"; wmem_tree_insert32_array(service_info, key, service_data); } command_data = wmem_new(wmem_file_scope(), command_data_t); command_data->command = cmd; command_data->arg0 = arg0; command_data->arg1 = arg1; command_data->command_in_frame = pinfo->fd->num;//.........这里部分代码省略.........
开发者ID:ARK1988,项目名称:wireshark,代码行数:101,
示例21: _try_val64_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 val64_string array to determine the fastest possible * access method. * - Verifies that the val64_string contains no NULL string pointers. * - Verifies that the val64_string is terminated by {0, NULL} */const val64_string *_try_val64_to_str_ext_init(const guint64 val, val64_string_ext *vse){ const val64_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 val64_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. */ guint64 prev_value; guint64 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:/n" " entry %u, value %" G_GINT64_MODIFIER "u [%#" G_GINT64_MODIFIER "x] < previous entry, value %" G_GINT64_MODIFIER "u [%#" G_GINT64_MODIFIER "x]", vse->_vs_name, i, vs_p[i].value, vs_p[i].value, prev_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:/n" " entry %u, value %" G_GINT64_MODIFIER "u [%#" G_GINT64_MODIFIER "x] < first entry, value %" G_GINT64_MODIFIER "u [%#" G_GINT64_MODIFIER "x]", vse->_vs_name, i, vs_p[i].value, vs_p[i].value, first_value, first_value); type = VS_SEARCH; break; } } prev_value = vs_p[i].value; } switch (type) { case VS_SEARCH: vse->_vs_match2 = _try_val64_to_str_linear; break; case VS_BIN_TREE: vse->_vs_match2 = _try_val64_to_str_bsearch; break; case VS_INDEX: vse->_vs_match2 = _try_val64_to_str_index; break; default: g_assert_not_reached(); break; } return vse->_vs_match2(val, vse);}
开发者ID:ljakab,项目名称:wireshark,代码行数:93,
示例22: dissect_hci_usbstatic gintdissect_hci_usb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data){ proto_item *ttree = NULL; proto_tree *titem = NULL; proto_item *pitem = NULL; gint offset = 0; usb_conv_info_t *usb_conv_info = (usb_conv_info_t *)data; tvbuff_t *next_tvb = NULL; hci_data_t *hci_data; gint p2p_dir_save; guint32 session_id; fragment_head *reassembled; if (tvb_length_remaining(tvb, offset) <= 0) return 0; titem = proto_tree_add_item(tree, proto_hci_usb, tvb, offset, -1, ENC_NA); ttree = proto_item_add_subtree(titem, ett_hci_usb); col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCI_USB"); DISSECTOR_ASSERT(usb_conv_info); p2p_dir_save = pinfo->p2p_dir; pinfo->p2p_dir = usb_conv_info->direction; switch (pinfo->p2p_dir) { case P2P_DIR_SENT: col_set_str(pinfo->cinfo, COL_INFO, "Sent"); break; case P2P_DIR_RECV: col_set_str(pinfo->cinfo, COL_INFO, "Rcvd"); break; default: col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown direction"); break; } session_id = usb_conv_info->bus_id << 16 | usb_conv_info->device_address << 8 | ((pinfo->p2p_dir == P2P_DIR_RECV) ? 1 : 0 ) << 7 | usb_conv_info->endpoint; hci_data = (hci_data_t *) wmem_new(wmem_packet_scope(), hci_data_t); hci_data->interface_id = HCI_INTERFACE_USB; hci_data->adapter_id = usb_conv_info->bus_id << 8 | usb_conv_info->device_address; hci_data->chandle_to_bdaddr_table = chandle_to_bdaddr_table; hci_data->bdaddr_to_name_table = bdaddr_to_name_table; hci_data->localhost_bdaddr = localhost_bdaddr; hci_data->localhost_name = localhost_name; pinfo->ptype = PT_BLUETOOTH; next_tvb = tvb_new_subset_remaining(tvb, offset); if (!pinfo->fd->flags.visited && usb_conv_info->endpoint <= 0x02) { fragment_info_t *fragment_info; fragment_info = (fragment_info_t *) wmem_tree_lookup32(fragment_info_table, session_id); if (fragment_info == NULL) { fragment_info = (fragment_info_t *) wmem_new(wmem_file_scope(), fragment_info_t); fragment_info->fragment_id = 0; fragment_info->remaining_length = 0; wmem_tree_insert32(fragment_info_table, session_id, fragment_info); } if (fragment_info->fragment_id == 0) { switch(usb_conv_info->endpoint) { case 0: fragment_info->remaining_length = tvb_get_guint8(tvb, offset + 2) + 3; break; case 1: fragment_info->remaining_length = tvb_get_guint8(tvb, offset + 1) + 2; break; case 2: fragment_info->remaining_length = tvb_get_letohs(tvb, offset + 2) + 4; break; } } fragment_info->remaining_length -= tvb_ensure_length_remaining(tvb, offset); fragment_add_seq_check(&hci_usb_reassembly_table, tvb, offset, pinfo, session_id, NULL, fragment_info->fragment_id, tvb_length_remaining(tvb, offset), (fragment_info->remaining_length == 0) ? FALSE : TRUE); if (fragment_info->remaining_length > 0) fragment_info->fragment_id += 1; else fragment_info->fragment_id = 0; } reassembled = fragment_get_reassembled_id(&hci_usb_reassembly_table, pinfo, session_id); if (reassembled && pinfo->fd->num < reassembled->reassembled_in) { pitem = proto_tree_add_item(ttree, hf_bthci_usb_packet_fragment, tvb, offset, -1, ENC_NA); PROTO_ITEM_SET_GENERATED(pitem); col_append_str(pinfo->cinfo, COL_INFO, " Fragment"); } else if (reassembled && pinfo->fd->num == reassembled->reassembled_in) {//.........这里部分代码省略.........
开发者ID:RayHightower,项目名称:wireshark,代码行数:101,
示例23: dissect_tlvstatic intdissect_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *mndp_tree, guint32 offset, guint32 length _U_, const ext_value_string *value_array){ guint32 tlv_type; guint32 tlv_length; proto_item *tlv_item; proto_item *tlv_tree; proto_item *type_item; int type_index; guint32 tlv_end; guint encoding_info; tlv_type = tvb_get_ntohs(tvb, offset); tlv_length = tvb_get_ntohs(tvb, offset + 2); /* DISSECTOR_ASSERT(tlv_length >= 4); */ tlv_item = proto_tree_add_text(mndp_tree, tvb, offset, tlv_length+4, "T %d, L %d: %s", tlv_type, tlv_length, extval_to_str_idx(tlv_type, value_array, NULL, "Unknown")); tlv_tree = proto_item_add_subtree(tlv_item, ett_mndp_tlv_header); type_item = proto_tree_add_item(tlv_tree, hf_mndp_tlv_type, tvb, offset, 2, ENC_BIG_ENDIAN); proto_item_append_text(type_item, " = %s", extval_to_str_idx(tlv_type, value_array, &type_index, "Unknown")); offset += 2; proto_tree_add_item(tlv_tree, hf_mndp_tlv_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* tlv_length -= 4; */ if (tlv_length == 0) return offset; tlv_end = offset + tlv_length; /* Make hf_ handling independent of specialfuncion */ /* FIXME: Properly handle encoding info */ if ( type_index != -1 && !value_array[type_index].specialfunction && value_array[type_index].evs != NULL ) { encoding_info = value_array[type_index].evs ? TRUE : FALSE; } else { encoding_info = FALSE; } if ( type_index != -1 && value_array[type_index].hf_element) { proto_tree_add_item(tlv_tree, *(value_array[type_index].hf_element), tvb, offset, tlv_length, encoding_info); } else { proto_tree_add_item(tlv_tree, hf_mndp_tlv_data, tvb, offset, tlv_length, ENC_NA); } if ( type_index != -1 && value_array[type_index].specialfunction ) { guint32 newoffset; while (offset < tlv_end) { newoffset = value_array[type_index].specialfunction ( tvb, pinfo, tlv_tree, offset, tlv_length, value_array[type_index].evs); DISSECTOR_ASSERT(newoffset > offset); offset = newoffset; } } return tlv_end;}
开发者ID:dogphilly,项目名称:wireshark,代码行数:72,
示例24: gcp_trxgcp_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->commited) { for ( trxmsg = m->trxs; trxmsg; trxmsg = trxmsg->next) { if (trxmsg->trx && trxmsg->trx->id == t_id) { return trxmsg->trx; } } DISSECTOR_ASSERT_NOT_REACHED(); } else { emem_tree_key_t key[] = { {1,&(m->hi_addr)}, {1,&(m->lo_addr)}, {1,&(t_id)}, {0,NULL} }; trxmsg = se_alloc(sizeof(gcp_trx_msg_t)); t = se_tree_lookup32_array(trxs,key); if (!t) { t = se_alloc(sizeof(gcp_trx_t)); t->initial = m; t->id = t_id; t->type = type; t->pendings = 0; t->error = 0; t->cmds = NULL; se_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 = ep_new(gcp_trx_t); trxmsg = ep_new(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;}
开发者ID:AkhilaAG,项目名称:gluster-wireshark-1.4,代码行数:73,
示例25: dissect_adb_servicestatic gintdissect_adb_service(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data){ proto_item *main_item; proto_tree *main_tree; proto_item *sub_item; proto_tree *sub_tree; gint offset = 0; adb_service_data_t *adb_service_data = (adb_service_data_t *) data; const guint8 *service; wmem_tree_key_t key[5]; wmem_tree_t *subtree; guint32 i_key; main_item = proto_tree_add_item(tree, proto_adb_service, tvb, offset, -1, ENC_NA); main_tree = proto_item_add_subtree(main_item, ett_adb_service); DISSECTOR_ASSERT(adb_service_data); service = adb_service_data->service; sub_item = proto_tree_add_string(main_tree, hf_service, tvb, offset, 0, service); PROTO_ITEM_SET_GENERATED(sub_item); if (g_strcmp0(service, "host:version") == 0) { guint32 version; guint32 data_length; continuation_data_t *continuation_data; DISSECTOR_ASSERT_HINT(adb_service_data->session_key_length + 1 <= sizeof(key) / sizeof(key[0]), "Tree session key is too small"); for (i_key = 0; i_key < adb_service_data->session_key_length; i_key += 1) { key[i_key].length = 1; key[i_key].key = &adb_service_data->session_key[i_key]; } key[i_key].length = 0; key[i_key].key = NULL; subtree = (wmem_tree_t *) wmem_tree_lookup32_array(continuation_infos, key); continuation_data = (subtree) ? (continuation_data_t *) wmem_tree_lookup32_le(subtree, pinfo->num) : NULL; if (continuation_data && continuation_data->completed_in_frame < pinfo->num) continuation_data = NULL; if (!continuation_data || (continuation_data && continuation_data->length_in_frame == pinfo->num)) offset = dissect_ascii_uint32(main_tree, hf_hex_ascii_length, ett_length, hf_length, tvb, offset, &data_length); if (!pinfo->fd->flags.visited && !continuation_data && tvb_reported_length_remaining(tvb, offset) < 4) { key[i_key].length = 1; key[i_key++].key = &pinfo->num; key[i_key].length = 0; key[i_key].key = NULL; continuation_data = wmem_new(wmem_file_scope(), continuation_data_t); continuation_data->length_in_frame = pinfo->num; continuation_data->completed_in_frame = G_MAXUINT32; continuation_data->length = data_length; wmem_tree_insert32_array(continuation_infos, key, continuation_data); continuation_data = NULL; } if (tvb_reported_length_remaining(tvb, offset) >= 4 || (continuation_data && continuation_data->completed_in_frame == pinfo->num)) { if (!pinfo->fd->flags.visited && continuation_data) { continuation_data->completed_in_frame = pinfo->num; } offset = dissect_ascii_uint32(main_tree, hf_hex_ascii_version, ett_version, hf_version, tvb, offset, &version); col_append_fstr(pinfo->cinfo, COL_INFO, " Version=%u", version); } } else if (g_strcmp0(service, "host:devices") == 0 || g_strcmp0(service, "host:devices-l") == 0 || g_strcmp0(service, "host:track-devices") == 0) { guint32 data_length; offset = dissect_ascii_uint32(main_tree, hf_hex_ascii_length, ett_length, hf_length, tvb, offset, &data_length); sub_item = proto_tree_add_item(main_tree, hf_devices, tvb, offset, -1, ENC_NA | ENC_ASCII); if ((gint64) data_length < tvb_reported_length_remaining(tvb, offset)) { expert_add_info(pinfo, sub_item, &ei_incomplete_message); } } else if (g_strcmp0(service, "host:get-state") == 0 || g_strcmp0(service, "host:get-serialno") == 0 || g_strcmp0(service, "host:get-devpath") == 0 || g_str_has_prefix(service, "connect:") || g_str_has_prefix(service, "disconnect:")) { guint32 data_length; offset = dissect_ascii_uint32(main_tree, hf_hex_ascii_length, ett_length, hf_length, tvb, offset, &data_length); sub_item = proto_tree_add_item(main_tree, hf_result, tvb, offset, -1, ENC_NA | ENC_ASCII); if ((gint64) data_length < tvb_reported_length_remaining(tvb, offset)) { expert_add_info(pinfo, sub_item, &ei_incomplete_message); } } else if (g_str_has_prefix(service, "framebuffer:")) { framebuffer_data_t *framebuffer_data = NULL; DISSECTOR_ASSERT_HINT(adb_service_data->session_key_length + 1 <= sizeof(key) / sizeof(key[0]), "Tree session key is too small"); for (i_key = 0; i_key < adb_service_data->session_key_length; i_key += 1) { key[i_key].length = 1;//.........这里部分代码省略.........
开发者ID:HeartFlying,项目名称:wireshark,代码行数:101,
注:本文中的DISSECTOR_ASSERT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ DIS_tcp_setup函数代码示例 C++ DISP_REG_SET_FIELD函数代码示例 |