/* * Name: isis_dissect_clvs() * * Description: * Dispatch routine to shred all the CLVs in a packet. We just * walk through the clv entries in the packet. For each one, we * search the passed in valid clv's for this protocol (opts) for * a matching code. If found, we add to the display tree and * then call the dissector. If it is not, we just post an * "unknown" clv entry using the passed in unknown clv tree id. * * Input: * tvbuff_t * : tvbuffer for packet data * proto_tree * : protocol display tree to fill out. May be NULL * int : offset into packet data where we are. * isis_clv_handle_t * : NULL dissector terminated array of codes * and handlers (along with tree text and tree id's). * int : length of CLV area. * int : length of IDs in packet. * int : unknown clv tree id * * Output: * void, but we will add to proto tree if !NULL. */ void isis_dissect_clvs(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset, const isis_clv_handle_t *opts, expert_field* expert_short_len, int len, int id_length, int unknown_tree_id _U_, int tree_type, int tree_length) { guint8 code; guint8 length; int q; proto_tree *clv_tree; while ( len > 0 ) { code = tvb_get_guint8(tvb, offset); offset += 1; len -= 1; if (len == 0) break; length = tvb_get_guint8(tvb, offset); offset += 1; len -= 1; if (len == 0) break; if ( len < length ) { proto_tree_add_expert_format(tree, pinfo, expert_short_len, tvb, offset, -1, "Short CLV header (%d vs %d)", length, len ); return; } q = 0; while ((opts[q].dissect != NULL )&&( opts[q].optcode != code )){ q++; } if ( opts[q].dissect ) { /* adjust by 2 for code/len octets */ clv_tree = proto_tree_add_subtree_format(tree, tvb, offset - 2, length + 2, *opts[q].tree_id, NULL, "%s (t=%u, l=%u)", opts[q].tree_text, opts[q].optcode, length); proto_tree_add_item(clv_tree, tree_type, tvb, offset - 2, 1, ENC_BIG_ENDIAN); proto_tree_add_item(clv_tree, tree_length, tvb, offset - 1, 1, ENC_BIG_ENDIAN); opts[q].dissect(tvb, pinfo, clv_tree, offset, id_length, length); } else { #if 0 /* XXX: Left as commented out in case info about "unknown code" is ever to be displayed under a sub-tree */ clv_tree = proto_tree_add_subtree_format(tree, tvb, offset - 2, length + 2, unknown_tree_id, NULL, "Unknown code %u (%u)", code, length); #else if (tree) { proto_tree_add_text(tree, tvb, offset - 2, length + 2, "Unknown code %u (%u)", code, length); } #endif } offset += length; len -= length; } }
/* * dissector function of connect data (request and response) * * input: tree, buffer (block data), flags (req or rsp) * return: nothing */ static void dissect_bcp_connect_data(proto_tree *bcp_tree, tvbuff_t *tvb, gint flags) { proto_tree *bcp_subtree = NULL; guint offset = 0; guint offset_base = offset; guint len = tvb_reported_length(tvb); if (flags & BCP_PROT_FLG_REQ) { bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, offset, len, ett_bcp_data, NULL, "BCP Connect Request: Name=%s IpAddr=%s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 16, BCP_NAME_LEN, ENC_ASCII), tvb_ip_to_str(tvb, offset + 12)); proto_tree_add_item(bcp_subtree, hf_bcp_connectreq_lenin, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(bcp_subtree, hf_bcp_connectreq_lenout, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(bcp_subtree, hf_bcp_connectreq_cycletime, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(bcp_subtree, hf_bcp_connectreq_offlinefactor, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(bcp_subtree, hf_bcp_connectreq_ipaddr, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(bcp_subtree, hf_bcp_connectreq_name, tvb, offset, BCP_NAME_LEN, ENC_ASCII|ENC_NA); offset += BCP_NAME_LEN; proto_tree_add_item(bcp_subtree, hf_bcp_connectreq_ethaddr, tvb, offset, BCP_ETHADDR_LEN, ENC_NA); offset += BCP_ETHADDR_LEN; if((len-(offset-offset_base))) { proto_tree_add_item(bcp_subtree, hf_bcp_connectreq_ethaddr2, tvb, offset, BCP_ETHADDR_LEN, ENC_NA); offset += BCP_ETHADDR_LEN; } } if (flags & BCP_PROT_FLG_RSP) { bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, offset, len, ett_bcp_data, NULL, "BCP Connect Response: Error=%d", tvb_get_ntohl(tvb, offset)); proto_tree_add_item(bcp_subtree, hf_bcp_connectrsp_error, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(bcp_subtree, hf_bcp_connectrsp_lenin, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(bcp_subtree, hf_bcp_connectrsp_lenout, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; } }
static void dissect_mx_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, int offset) { guint i, curr; guint /*len, namelen,*/ priority, dlen; const guchar *dname; proto_tree* mx_rec_tree, *rec_tree; if(tree == NULL) return; mx_rec_tree = proto_tree_add_subtree_format(tree, tvb, offset, offset, ett_mx_rec, NULL, "MX records (%d)", nrec); curr = offset; for(i=0; i < nrec; i++) { /*len = tvb_get_ntohs(tvb, curr);*/ priority = tvb_get_ntohs(tvb, curr + 2); /*namelen = len - 4;*/ dlen = get_dns_name(tvb, curr + 4, 0, curr + 4, &dname); rec_tree = proto_tree_add_subtree_format(mx_rec_tree, tvb, curr,6,ett_mx_rec_item,NULL, "MX record: pri=%d,dname=%s", priority,dname); proto_tree_add_item(rec_tree, hf_srv_prio, tvb, curr + 2, 2, ENC_BIG_ENDIAN); proto_tree_add_string(rec_tree, hf_srv_dname, tvb, curr + 4, dlen, dname); curr+=(int)((sizeof(short)*2) + dlen); } }
int call_ros_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, struct SESSION_DATA_STRUCTURE* session) { tvbuff_t *next_tvb; int len; next_tvb = tvb_new_subset_remaining(tvb, offset); if(((len = ros_try_string(oid, next_tvb, pinfo, tree, session)) == 0) && ((len = dissector_try_string(ros_oid_dissector_table, oid, next_tvb, pinfo, tree, session)) == 0)) { proto_item *item; proto_tree *next_tree; next_tree = proto_tree_add_subtree_format(tree, next_tvb, 0, -1, ett_ros_unknown, &item, "ROS: Dissector for OID:%s not implemented. Contact Wireshark developers if you want this supported", oid); expert_add_info_format(pinfo, item, &ei_ros_dissector_oid_not_implemented, "ROS: Dissector for OID %s not implemented", oid); len = dissect_unknown_ber(pinfo, next_tvb, offset, next_tree); } offset += len; return offset; }
static int call_rtse_oid_callback(const char *oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, void* data) { tvbuff_t *next_tvb; next_tvb = tvb_new_subset_remaining(tvb, offset); if(!dissector_try_string(rtse_oid_dissector_table, oid, next_tvb, pinfo, tree, data)){ proto_item *item; proto_tree *next_tree; next_tree = proto_tree_add_subtree_format(tree, next_tvb, 0, -1, ett_rtse_unknown, &item, "RTSE: Dissector for OID:%s not implemented. Contact Wireshark developers if you want this supported", oid); expert_add_info_format(pinfo, item, &ei_rtse_dissector_oid_not_implemented, "RTSE: Dissector for OID %s not implemented", oid); dissect_unknown_ber(pinfo, next_tvb, offset, next_tree); } /*XXX until we change the #.REGISTER signature for _PDU()s * into new_dissector_t we have to do this kludge with * manually step past the content in the ANY type. */ offset+=tvb_captured_length_remaining(tvb, offset); return offset; }
static void dissect_request_resolve(tvbuff_t *tvb, int offset, proto_tree *tree) { /* dissect the request resolve structure */ /* display a string with a length, characters encoding */ /* they are displayed under a tree with the name in Label variable */ /* return the length of the string and the length byte */ proto_tree *name_tree; int length = tvb_get_guint8( tvb, offset); if ( tree){ name_tree = proto_tree_add_subtree_format(tree, tvb, offset, length + 1, ett_msproxy_name, NULL, "Host Name: %.*s", length, tvb_get_string_enc( wmem_packet_scope(), tvb, offset + 18, length, ENC_ASCII)); proto_tree_add_text( name_tree, tvb, offset, 1, "Length: %d", length); ++offset; offset += 17; proto_tree_add_text( name_tree, tvb, offset, length, "String: %s", tvb_get_string_enc( wmem_packet_scope(), tvb, offset, length, ENC_ASCII)); } }
static void dissect_vektor_igrp (tvbuff_t *tvb, proto_tree *igrp_vektor_tree, guint8 network) { guint8 *ptr_addr,addr[5]; address ip_addr; addr[0]=network; addr[1]=tvb_get_guint8(tvb,0); addr[2]=tvb_get_guint8(tvb,1); addr[3]=tvb_get_guint8(tvb,2); addr[4]=0; ptr_addr=addr; if (network==0) ptr_addr=&addr[1]; SET_ADDRESS(&ip_addr, AT_IPv4, 4, ptr_addr); igrp_vektor_tree = proto_tree_add_subtree_format(igrp_vektor_tree, tvb, 0 ,14, ett_igrp_net, NULL, "Entry for network %s", address_to_str(wmem_packet_scope(), &ip_addr)); proto_tree_add_ipv4(igrp_vektor_tree, hf_igrp_network, tvb, 0, 3, *((guint32*)ptr_addr)); proto_tree_add_item(igrp_vektor_tree, hf_igrp_delay, tvb, 3, 3, ENC_BIG_ENDIAN); proto_tree_add_item(igrp_vektor_tree, hf_igrp_bandwidth, tvb, 6, 3, ENC_BIG_ENDIAN); proto_tree_add_uint_format_value(igrp_vektor_tree, hf_igrp_mtu, tvb, 9, 2, tvb_get_ntohs(tvb,9), "%d bytes", tvb_get_ntohs(tvb,9)); proto_tree_add_item(igrp_vektor_tree, hf_igrp_reliability, tvb, 11, 1, ENC_BIG_ENDIAN); proto_tree_add_item(igrp_vektor_tree, hf_igrp_load, tvb, 12, 1, ENC_BIG_ENDIAN); proto_tree_add_item(igrp_vektor_tree, hf_igrp_hop_count, tvb, 13, 1, ENC_BIG_ENDIAN); }
void dissect_umts_cell_broadcast_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint8 sms_encoding; guint32 offset = 0; guint32 len; proto_item *cbs_item; proto_tree *cbs_tree, *cbs_subtree; guint msg_len; guint8 *msg; tvbuff_t * cbs_msg_tvb = NULL; len = tvb_length(tvb); col_append_str(pinfo->cinfo, COL_PROTOCOL, " Cell Broadcast"); col_append_str(pinfo->cinfo, COL_INFO, " (CBS Message)"); cbs_item = proto_tree_add_protocol_format(proto_tree_get_root(tree), proto_cell_broadcast, tvb, 0, len, "Cell Broadcast"); cbs_tree = proto_item_add_subtree(cbs_item, ett_cbs_msg); sms_encoding = dissect_cbs_data_coding_scheme(tvb, pinfo, cbs_tree, 0); offset++; cbs_msg_tvb = dissect_cbs_data(sms_encoding, tvb, cbs_tree, pinfo, offset ); msg_len = tvb_length(cbs_msg_tvb); cbs_subtree = proto_tree_add_subtree_format(cbs_tree, tvb, offset, -1, ett_cbs_msg, NULL, "Cell Broadcast Message Contents (length: %d)", msg_len); msg = tvb_get_string_enc(wmem_packet_scope(), cbs_msg_tvb, 0, msg_len, ENC_ASCII); proto_tree_add_string_format(cbs_subtree, hf_gsm_cbs_message_content, cbs_msg_tvb, 0, -1, msg, "%s", msg); }
static void dissect_componentstatusprotocol_componentstatusreport_message(tvbuff_t *message_tvb, proto_tree *message_tree) { tvbuff_t *association_tvb; proto_tree *association_tree; /* gint associations; - variable set but not used, so commented out */ int i; gint offset; proto_tree_add_item(message_tree, hf_componentstatusreport_reportinterval, message_tvb, COMPONENTSTATUSREPORT_REPORTINTERVAL_OFFSET, COMPONENTSTATUSREPORT_REPORTINTERVAL_LENGTH, ENC_BIG_ENDIAN); proto_tree_add_item(message_tree, hf_componentstatusreport_location, message_tvb, COMPONENTSTATUSREPORT_LOCATION_OFFSET, COMPONENTSTATUSREPORT_LOCATION_LENGTH, ENC_ASCII|ENC_NA); proto_tree_add_item(message_tree, hf_componentstatusreport_status, message_tvb, COMPONENTSTATUSREPORT_STATUS_OFFSET, COMPONENTSTATUSREPORT_STATUS_LENGTH, ENC_ASCII|ENC_NA); proto_tree_add_item(message_tree, hf_componentstatusreport_workload, message_tvb, COMPONENTSTATUSREPORT_WORKLOAD_OFFSET, COMPONENTSTATUSREPORT_WORKLOAD_LENGTH, ENC_BIG_ENDIAN); proto_tree_add_item(message_tree, hf_componentstatusreport_associations, message_tvb, COMPONENTSTATUSREPORT_ASSOCIATIONS_OFFSET, COMPONENTSTATUSREPORT_ASSOCIATIONS_LENGTH, ENC_BIG_ENDIAN); /* associations = tvb_get_ntohs(message_tvb, COMPONENTSTATUSREPORT_ASSOCIATIONS_OFFSET); */ offset = COMPONENTSTATUSREPORT_ASSOCIATIONARRAY_OFFSET; i = 1; while(tvb_reported_length_remaining(message_tvb, offset) >= COMPONENTASSOCIATION_LENGTH) { association_tree = proto_tree_add_subtree_format(message_tree, message_tvb, offset, COMPONENTASSOCIATION_LENGTH, ett_association, NULL, "Association #%d", i++); association_tvb = tvb_new_subset(message_tvb, offset, MIN(COMPONENTASSOCIATION_LENGTH, tvb_reported_length_remaining(message_tvb, offset)), COMPONENTASSOCIATION_LENGTH); dissect_componentstatusprotocol_componentassociation_message(association_tvb, association_tree); offset += COMPONENTASSOCIATION_LENGTH; } }
static void dissect_bfd_authentication(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { int offset = 24; guint8 auth_type; guint8 auth_len; proto_item *ti = NULL; proto_item *auth_item = NULL; proto_tree *auth_tree = NULL; guint8 *password; auth_type = tvb_get_guint8(tvb, offset); auth_len = tvb_get_guint8(tvb, offset + 1); if (tree) { auth_tree = proto_tree_add_subtree_format(tree, tvb, offset, auth_len, ett_bfd_auth, NULL, "Authentication: %s", val_to_str(auth_type, bfd_control_auth_type_values, "Unknown Authentication Type (%d)") ); proto_tree_add_item(auth_tree, hf_bfd_auth_type, tvb, offset, 1, ENC_BIG_ENDIAN); ti = proto_tree_add_item(auth_tree, hf_bfd_auth_len, tvb, offset + 1, 1, ENC_BIG_ENDIAN); proto_item_append_text(ti, " bytes"); proto_tree_add_item(auth_tree, hf_bfd_auth_key, tvb, offset + 2, 1, ENC_BIG_ENDIAN); } switch (auth_type) { case BFD_AUTH_SIMPLE: if (tree) { password = tvb_get_string_enc(wmem_packet_scope(), tvb, offset+3, auth_len-3, ENC_ASCII); proto_tree_add_string(auth_tree, hf_bfd_auth_password, tvb, offset+3, auth_len-3, password); proto_item_append_text(auth_item, ": %s", password); } break; case BFD_AUTH_MD5: case BFD_AUTH_MET_MD5: case BFD_AUTH_SHA1: case BFD_AUTH_MET_SHA1: if (auth_len != get_bfd_required_auth_len(auth_type)) { proto_tree_add_expert_format(auth_tree, pinfo, &ei_bfd_auth_len_invalid, tvb, offset, auth_len, "Length of authentication section (%d) is invalid for Authentication Type: %s", auth_len, val_to_str(auth_type, bfd_control_auth_type_values, "Unknown Authentication Type (%d)") ); proto_item_append_text(auth_item, ": Invalid Authentication Section"); } if (tree) { proto_tree_add_item(auth_tree, hf_bfd_auth_seq_num, tvb, offset+4, 4, ENC_BIG_ENDIAN); proto_tree_add_item(auth_tree, hf_bfd_checksum, tvb, offset+8, get_bfd_checksum_len(auth_type), ENC_NA); } break; default: break; } }
/* * dissector function of protocol header * * input: tree, buffer (data), offset (data pointer) * output: flags, block count, segcode from header * return: updated offset */ static guint dissect_bcp_protocol_header(proto_tree *bcp_tree, tvbuff_t *tvb, guint offset, gint *flags, guint *blocknb, guint *segcode) { proto_tree *bcp_subtree = NULL; *flags = tvb_get_guint8(tvb, offset + 2); *blocknb = tvb_get_guint8(tvb, offset + 3); *segcode = tvb_get_ntohs(tvb, offset + 4); bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, 0, BCP_PROTOCOL_HDR_LEN, ett_bcp_header, NULL, "BCP Protocol Header: BlockNb=%d, SegCode=%d", *blocknb, *segcode); proto_tree_add_item(bcp_subtree, hf_bcp_hdr_version, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(bcp_subtree, hf_bcp_hdr_format, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(bcp_subtree, hf_bcp_hdr_protflags, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(bcp_subtree, hf_bcp_hdr_blocknb, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(bcp_subtree, hf_bcp_hdr_segcode, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(bcp_subtree, hf_bcp_hdr_auth, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; return offset; }
/* * dissector function of sync data * * input: tree, buffer (block data) * return: nothing */ static void dissect_bcp_sync_data(proto_tree *bcp_tree, tvbuff_t *tvb) { proto_tree *bcp_subtree = NULL; guint offset = 0; guint offset_base = offset; guint len = tvb_reported_length(tvb); bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, offset, len, ett_bcp_data, NULL, "BCP Sync Data: Identify=%s", BOOLSTR(tvb_get_guint8(tvb, offset + 9))); proto_tree_add_item(bcp_subtree, hf_bcp_sync_starttime, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(bcp_subtree, hf_bcp_sync_cycletime, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(bcp_subtree, hf_bcp_sync_dataratio, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(bcp_subtree, hf_bcp_sync_identify, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(bcp_subtree, hf_bcp_sync_vlantag, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; /* protocol expansion*/ if((len-(offset-offset_base))) { proto_tree_add_item(bcp_subtree, hf_bcp_sync_ethaddr, tvb, offset, BCP_ETHADDR_LEN, ENC_NA); offset += BCP_ETHADDR_LEN; proto_tree_add_item(bcp_subtree, hf_bcp_sync_ethaddr2, tvb, offset, BCP_ETHADDR_LEN, ENC_NA); offset += BCP_ETHADDR_LEN; } }
/* * dissector function of identify data (request) * * input: tree, buffer (block data), flags (req or rsp) * return: nothing */ static void dissect_bcp_identify_data(proto_tree *bcp_tree, tvbuff_t *tvb) { proto_tree *bcp_subtree = NULL; guint offset = 0; guint offset_base = offset; guint len = tvb_reported_length(tvb); bcp_subtree = proto_tree_add_subtree_format(bcp_tree, tvb, offset, len, ett_bcp_data, NULL, "BCP Identify Request: Name=%s, IpAddr=%s", tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 12, BCP_NAME_LEN, ENC_ASCII), tvb_ip_to_str(tvb, offset + 8) ); proto_tree_add_item(bcp_subtree, hf_bcp_identify_error, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(bcp_subtree, hf_bcp_identify_starttime, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(bcp_subtree, hf_bcp_identify_ipaddr, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(bcp_subtree, hf_bcp_identify_name, tvb, offset, BCP_NAME_LEN, ENC_ASCII|ENC_NA); offset += BCP_NAME_LEN; proto_tree_add_item(bcp_subtree, hf_bcp_identify_ethaddr, tvb, offset, BCP_ETHADDR_LEN, ENC_NA); offset += BCP_ETHADDR_LEN; if((len-(offset-offset_base))) { proto_tree_add_item(bcp_subtree, hf_bcp_identify_ethaddr2, tvb, offset, BCP_ETHADDR_LEN, ENC_NA); offset += BCP_ETHADDR_LEN; } }
static void dissect_a_records(tvbuff_t* tvb, proto_tree* tree,guint32 nrec,int offset) { guint32 i, curr; const gchar* addrs; proto_tree* a_rec_tree; proto_tree* addr_tree; if(tree == NULL) return; a_rec_tree = proto_tree_add_subtree(tree,tvb,offset, (int)((sizeof(guint32) + sizeof(guint16)) * nrec), ett_a_rec, NULL, "A records"); for(i=0; i<nrec; i++) { curr = offset + (int)((sizeof(guint32)+sizeof(guint16)) * i); addrs = tvb_ip_to_str(tvb, curr+2); addr_tree = proto_tree_add_subtree_format(a_rec_tree, tvb, curr, 6, ett_a_rec_addr, NULL, "Address %s", addrs); proto_tree_add_item(addr_tree, hf_a_rec_len, tvb, curr, sizeof(guint16), ENC_BIG_ENDIAN); proto_tree_add_item(addr_tree, hf_a_record, tvb, curr + 2, 4, ENC_BIG_ENDIAN); } }
static void redbackli_dissect_avp(guint8 avptype, guint8 avplen, tvbuff_t *tvb, gint offset, proto_tree *tree) { const char *avpname; proto_tree *st = NULL; avpname = val_to_str_const(avptype, avp_names, "Unknown"); st = proto_tree_add_subtree_format(tree, tvb, offset, avplen+2, ett_redbackli, NULL, "%s AVP", avpname); proto_tree_add_uint(st, hf_redbackli_avptype, tvb, offset, 1, avptype); proto_tree_add_uint(st, hf_redbackli_avplen, tvb, offset+1, 1, avplen); if (!avplen) return; /* XXX: ToDo: Validate the length (avplen) of the fixed length fields before calling proto_tree_add_item(). Note that the field lengths have been validated when dissect_avp() is called from redbackli_dissect_heur(). */ switch (avptype) { case(RB_AVP_SEQNO): proto_tree_add_item(st, hf_redbackli_seqno, tvb, offset+2, avplen, ENC_BIG_ENDIAN); break; case(RB_AVP_LIID): proto_tree_add_item(st, hf_redbackli_liid, tvb, offset+2, avplen, ENC_BIG_ENDIAN); break; case(RB_AVP_SESSID): proto_tree_add_item(st, hf_redbackli_sessid, tvb, offset+2, avplen, ENC_BIG_ENDIAN); break; case(RB_AVP_LABEL): proto_tree_add_item(st, hf_redbackli_label, tvb, offset+2, avplen, ENC_ASCII|ENC_NA); break; case(RB_AVP_EOH): proto_tree_add_item(st, hf_redbackli_eohpad, tvb, offset+2, avplen, ENC_NA); break; case(RB_AVP_DIR): proto_tree_add_item(st, hf_redbackli_dir, tvb, offset+2, avplen, ENC_NA); break; case(RB_AVP_ACCTID): proto_tree_add_item(st, hf_redbackli_acctid, tvb, offset+2, avplen, ENC_NA); break; default: proto_tree_add_item(st, hf_redbackli_unknownavp, tvb, offset+2, avplen, ENC_NA); break; } return; }
static void dissect_dccreq_sf_sub (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len) { guint8 type, length; proto_tree *dcc_tree; int pos; pos = start; dcc_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dccreq_sf_sub, NULL, "7 DCC-REQ Service Flow Substitution Encodings (Length = %u)", len); while ( pos < ( start + len) ) { type = tvb_get_guint8 (tvb, pos++); length = tvb_get_guint8 (tvb, pos++); switch (type) { case DCCREQ_SF_SFID: if (length == 8) { proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sfid_cur, tvb, pos, 4, ENC_BIG_ENDIAN); proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sfid_new, tvb, pos + 4, 4, ENC_BIG_ENDIAN); } else { THROW (ReportedBoundsError); } break; case DCCREQ_SF_SID: if (length == 4) { proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sid_cur, tvb, pos, 2, ENC_BIG_ENDIAN); proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_sid_new, tvb, pos + 2, 2, ENC_BIG_ENDIAN); } else { THROW (ReportedBoundsError); } break; case DCCREQ_SF_UNSOL_GRANT_TREF: if (length == 4) { proto_tree_add_item (dcc_tree, hf_docsis_dccreq_sf_unsol_grant_tref, tvb, pos, length, ENC_BIG_ENDIAN); } else { THROW (ReportedBoundsError); } break; } pos = pos + length; } }
static void dissect_mojito_store_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset) { proto_tree *dht_tree, *version_tree; proto_item *dht_item, *version_item; guint8 ii, contactcount; guint8 sectokenlen = tvb_get_guint8(tvb, offset); guint16 dhtvaluelength; int contact_offset, start_offset; proto_tree_add_item(tree, hf_mojito_sectokenlen, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tree, hf_mojito_sectoken, tvb, offset, sectokenlen, ENC_NA); offset += sectokenlen; /* Contact count */ proto_tree_add_item(tree, hf_mojito_dhtvaluecount, tvb, offset, 1, ENC_BIG_ENDIAN); contactcount = tvb_get_guint8(tvb, offset); offset += 1; /* For each Contact, display the info */ for (ii = 0; ii < contactcount; ii++) { dht_tree = proto_tree_add_subtree_format(tree, tvb, offset, 1, ett_mojito_dht, &dht_item, "DHTValue #%d", ii+1); start_offset = offset; contact_offset = dissect_mojito_contact(tvb, pinfo, dht_tree, offset, -1); if (contact_offset == 0) return; offset += contact_offset; proto_tree_add_item(dht_tree, hf_mojito_dhtvalue_kuid, tvb, offset, 20, ENC_NA); offset += 20; proto_tree_add_item(dht_tree, hf_mojito_dhtvalue_valuetype, tvb, offset, 4, ENC_ASCII|ENC_NA); offset += 4; /* Version */ version_item = proto_tree_add_item(dht_tree, hf_mojito_dhtvalue_version, tvb, offset, 2, ENC_BIG_ENDIAN); version_tree = proto_item_add_subtree(version_item, ett_mojito_dht_version); proto_tree_add_item(version_tree, hf_mojito_mjrversion, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(version_tree, hf_mojito_mnrversion, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; dhtvaluelength = tvb_get_ntohs(tvb, offset); proto_tree_add_item(dht_tree, hf_mojito_dhtvalue_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; proto_tree_add_item(dht_tree, hf_mojito_dhtvalue_value, tvb, offset, dhtvaluelength, ENC_ASCII|ENC_NA); offset += dhtvaluelength; proto_item_set_len(dht_item, offset-start_offset); } }
/* * Handles one Auto-RP map entry. Returns the new offset. */ static int do_auto_rp_map(tvbuff_t *tvb, int offset, proto_tree *auto_rp_tree) { proto_tree *map_tree; guint8 group_count; int i; group_count = tvb_get_guint8(tvb, offset + 5); /* sizeof map header + n * sizeof encoded group addresses */ map_tree = proto_tree_add_subtree_format(auto_rp_tree, tvb, offset, 6 + group_count * 6, ett_auto_rp_map, NULL, "RP %s: %u group%s", tvb_ip_to_str(tvb, offset), group_count, plurality(group_count, "", "s")); proto_tree_add_item(map_tree, hf_auto_rp_rp_addr, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; proto_tree_add_item(map_tree, hf_auto_rp_pim_ver, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; proto_tree_add_uint(map_tree, hf_auto_rp_group_num, tvb, offset, 1, group_count); offset++; for (i = 0; i < group_count; i++) { proto_tree *grp_tree; guint8 sign, mask_len; sign = tvb_get_guint8(tvb, offset); mask_len = tvb_get_guint8(tvb, offset + 1); grp_tree = proto_tree_add_subtree_format(map_tree, tvb, offset, 6, ett_auto_rp_group, NULL, "Group %s/%u (%s)", tvb_ip_to_str(tvb, offset + 2), mask_len, val_to_str_const(sign&AUTO_RP_SIGN_MASK, auto_rp_mask_sign_vals, "")); proto_tree_add_uint(grp_tree, hf_auto_rp_prefix_sgn, tvb, offset, 1, sign); offset++; proto_tree_add_uint(grp_tree, hf_auto_rp_mask_len, tvb, offset, 1, mask_len); offset++; proto_tree_add_item(grp_tree, hf_auto_rp_group_prefix, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4; } return offset; }
static proto_tree * add_charstring_tree(proto_tree *tree, tvbuff_t *tvb, int offset, int name_length, int value_length) { return proto_tree_add_subtree_format(tree, tvb, offset, 1 + 2 + name_length + 2 + value_length, ett_ipp_attr, NULL, "%s: %s", tvb_format_text(tvb, offset + 1 + 2, name_length), tvb_format_text(tvb, offset + 1 + 2 + name_length + 2, value_length)); }
static int dissect_tapa_discover_unknown_new_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tapa_discover_tree, guint32 offset, gint remaining) { proto_tree *tapa_discover_item_tree; guint8 item_type; gint item_length; const gchar *item_text; /*const gchar *item_type_text;*/ gboolean is_ascii; while (remaining > 3) { /* type(1) + flags(1) + length(2) */ item_type = tvb_get_guint8(tvb, offset); /*item_type_text = val_to_str(item_type, tapa_discover_unknown_vals, "%d");*/ item_length = tvb_get_ntohs(tvb, offset + 2) - 4; DISSECTOR_ASSERT(item_length > 0); is_ascii = check_ascii(tvb, offset + 4, item_length); if (is_ascii) item_text = tvb_format_text(tvb, offset + 4, item_length); else item_text = "BINARY-DATA"; col_append_fstr(pinfo->cinfo, COL_INFO, ", T=%d L=%d", item_type, item_length); tapa_discover_item_tree = proto_tree_add_subtree_format(tapa_discover_tree, tvb, offset, 4 + item_length, ett_tapa_discover_req, NULL, "Type %d, length %d, value %s", item_type, item_length, item_text); proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_type, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_pad, tvb, offset, 1, ENC_BIG_ENDIAN); offset += 1; proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_length, tvb, offset, 2, ENC_BIG_ENDIAN); offset += 2; if (is_ascii) proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_valuetext, tvb, offset, item_length, ENC_ASCII|ENC_NA); else proto_tree_add_item(tapa_discover_item_tree, hf_tapa_discover_newtlv_valuehex, tvb, offset, item_length, ENC_NA); offset += item_length; remaining -= (item_length + 4); } return offset; }
/* * Insert common descriptor type and length fields. */ static proto_tree* fip_desc_type_len(proto_tree *tree, tvbuff_t *tvb, guint8 dtype, int ett, proto_item** item) { proto_tree* ret_tree; ret_tree = proto_tree_add_subtree_format(tree, tvb, 0, -1, ett, item, "Descriptor: %s ", val_to_str_ext_const(dtype, &fip_desc_types_ext, "Unknown 0x%x")); proto_tree_add_item(ret_tree, hf_fip_desc_type, tvb, 0, 1, ENC_BIG_ENDIAN); proto_tree_add_item(ret_tree, hf_fip_desc_len, tvb, 1, 1, ENC_BIG_ENDIAN); return ret_tree; }
static void dissect_auto_rp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { guint8 ver_type, rp_count; col_set_str(pinfo->cinfo, COL_PROTOCOL, "Auto-RP"); col_clear(pinfo->cinfo, COL_INFO); ver_type = tvb_get_guint8(tvb, 0); rp_count = tvb_get_guint8(tvb, 1); col_add_fstr(pinfo->cinfo, COL_INFO, "%s (v%s) for %u RP%s", val_to_str_const(lo_nibble(ver_type), auto_rp_type_vals, "Unknown"), val_to_str_const(hi_nibble(ver_type), auto_rp_ver_vals, "Unknown"), rp_count, plurality(rp_count, "", "s")); if (tree) { proto_item *ti; proto_tree *auto_rp_tree, *ver_type_tree; int i, offset; guint16 holdtime; offset = 0; ti = proto_tree_add_item(tree, proto_auto_rp, tvb, offset, -1, ENC_NA); auto_rp_tree = proto_item_add_subtree(ti, ett_auto_rp); ver_type_tree = proto_tree_add_subtree_format(auto_rp_tree, tvb, offset, 1, ett_auto_rp_ver_type, NULL, "Version: %s, Packet type: %s", val_to_str_const(hi_nibble(ver_type), auto_rp_ver_vals, "Unknown"), val_to_str_const(lo_nibble(ver_type), auto_rp_type_vals, "Unknown")); proto_tree_add_uint(ver_type_tree, hf_auto_rp_version, tvb, offset, 1, ver_type); proto_tree_add_uint(ver_type_tree, hf_auto_rp_type, tvb, offset, 1, ver_type); offset++; proto_tree_add_uint(auto_rp_tree, hf_auto_rp_count, tvb, offset, 1, rp_count); offset++; holdtime = tvb_get_ntohs(tvb, offset); proto_tree_add_uint_format_value(auto_rp_tree, hf_auto_rp_holdtime, tvb, offset, 2, holdtime, "%u second%s", holdtime, plurality(holdtime, "", "s")); offset+=2; proto_tree_add_item(auto_rp_tree, hf_auto_rp_reserved, tvb, offset, 4, ENC_BIG_ENDIAN); offset+=4; for (i = 0; i < rp_count; i++) offset = do_auto_rp_map(tvb, offset, auto_rp_tree); if (tvb_reported_length_remaining(tvb, offset) > 0) proto_tree_add_item(tree, hf_auto_rp_trailing_junk, tvb, offset, -1, ENC_NA); } return; }
static void dissect_ns_records(tvbuff_t* tvb, proto_tree* tree, guint32 nrec, int offset) { guint i, curr; guint /*len, namelen,*/ dlen; const guchar *dname; proto_tree* ns_rec_tree, *rec_tree; if(tree == NULL) return; ns_rec_tree = proto_tree_add_subtree_format(tree, tvb, offset, offset, ett_ns_rec, NULL, "NS record (%d)", nrec); curr=offset; for(i=0;i<nrec;i++) { /*len = tvb_get_ntohs(tvb, curr);*/ /*namelen = len - 2;*/ dlen = get_dns_name(tvb, curr + 2, 0, curr + 2, &dname); rec_tree = proto_tree_add_subtree_format(ns_rec_tree, tvb, curr,4, ett_ns_rec_item, NULL, "NS record: dname=%s",dname); proto_tree_add_string(rec_tree, hf_ns_dname, tvb, curr + 2, dlen, dname); curr+=(int)(sizeof(short) + dlen); } }
static int dissect_object_id(tvbuff_t *tvb, proto_tree *tree, int offset, guint8 flags, enum OID_USAGE oid_usage) { guint8 n_subid; guint8 prefix; guint8 include; proto_tree* subtree; guint32 oid[2048]; char str_oid[2048]; int i; memset(oid, '\0', sizeof(oid)); memset(str_oid, '\0', sizeof(str_oid)); n_subid = tvb_get_guint8(tvb, offset); prefix = tvb_get_guint8(tvb, offset + 1); include = tvb_get_guint8(tvb, offset + 2); tvb_get_guint8(tvb, offset + 3); for(i=0; i<n_subid; i++) { NORLEL(flags, oid[i], tvb, (offset+4) + (i*4)); } if(!convert_oid_to_str(&oid[0], n_subid, &str_oid[0], 2048, prefix)) g_snprintf(&str_oid[0], 2048, "(null)"); if(tree) { const char *range = ""; const char *inclusion = (include) ? " (Inclusive)" : " (Exclusive)"; switch (oid_usage) { case OID_START_RANGE: range = "(Range Start) "; break; case OID_END_RANGE: range = " (Range End) "; break; default: inclusion = ""; break; } subtree = proto_tree_add_subtree_format(tree, tvb, offset, 4 + (n_subid * 4) , ett_obj_ident, NULL, "Object Identifier: %s%s%s", range, str_oid, inclusion); } else return offset; proto_tree_add_uint(subtree, hf_oid_sub, tvb, offset, 1, n_subid); proto_tree_add_uint(subtree, hf_oid_prefix, tvb, offset + 1, 1, prefix); proto_tree_add_boolean(subtree, hf_oid_include, tvb, offset + 2, 1, include); proto_tree_add_string(subtree, hf_oid_str, tvb, offset + 4, (n_subid * 4), str_oid); return 4 + (n_subid * 4); }
static proto_item * decode_ip_elements(nsip_ip_element_info_t *element, nsip_ie_t *ie, build_info_t *bi, int ie_start_offset) { int i; int num_elements = ie->value_length / element->total_length; proto_item *tf; proto_tree *field_tree; field_tree = proto_tree_add_subtree_format(bi->nsip_tree, bi->tvb, ie_start_offset, ie->total_length, ett_nsip_ip_element_list, &tf, "List of IP%u Elements (%u Elements)", element->version, num_elements); for (i = 0; i < num_elements; i++) { decode_ip_element(element, bi, field_tree); } return tf; }
static void tftp_dissect_options(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, guint16 opcode, tftp_conv_info_t *tftp_info) { int option_len, value_len; int value_offset; const char *optionname; const char *optionvalue; proto_tree *opt_tree; while (tvb_offset_exists(tvb, offset)) { /* option_len and value_len include the trailing 0 byte */ option_len = tvb_strsize(tvb, offset); value_offset = offset + option_len; value_len = tvb_strsize(tvb, value_offset); /* use xxx_len-1 to exclude the trailing 0 byte, it would be displayed as nonprinting character tvb_format_text() creates a temporary 0-terminated buffer */ optionname = tvb_format_text(tvb, offset, option_len-1); optionvalue = tvb_format_text(tvb, value_offset, value_len-1); opt_tree = proto_tree_add_subtree_format(tree, tvb, offset, option_len+value_len, ett_tftp_option, NULL, "Option: %s = %s", optionname, optionvalue); proto_tree_add_item(opt_tree, hf_tftp_option_name, tvb, offset, option_len, ENC_ASCII|ENC_NA); proto_tree_add_item(opt_tree, hf_tftp_option_value, tvb, value_offset, value_len, ENC_ASCII|ENC_NA); offset += option_len + value_len; col_append_fstr(pinfo->cinfo, COL_INFO, ", %s=%s", optionname, optionvalue); /* Special code to handle individual options */ if (!g_ascii_strcasecmp((const char *)optionname, "blksize") && opcode == TFTP_OACK) { gint blocksize = (gint)strtol((const char *)optionvalue, NULL, 10); if (blocksize < 8 || blocksize > 65464) { expert_add_info(pinfo, NULL, &ei_tftp_blocksize_range); } else { tftp_info->blocksize = blocksize; } } } }
static void gog_attrs_tree(proto_tree* tree, tvbuff_t *tvb, mate_gog* gog) { AVPN* c; proto_tree *avpl_t; int* hfi_p; avpl_t = proto_tree_add_subtree_format(tree,tvb,0,0,gog->cfg->ett_attr,NULL,"%s Attributes",gog->cfg->name); for ( c = gog->avpl->null.next; c->avp; c = c->next) { hfi_p = (int *)g_hash_table_lookup(gog->cfg->my_hfids,(char*)c->avp->n); if (hfi_p) { proto_tree_add_string(avpl_t,*hfi_p,tvb,0,0,c->avp->v); } else { g_warning("MATE: error: undefined attribute: mate.%s.%s",gog->cfg->name,c->avp->n); proto_tree_add_text(avpl_t,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v); } } }
/* 3GPP TS 23.041 version 11.4.0 * 9.4.2.2.5 CB Data */ static void dissect_sabp_cb_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *cbs_page_item; proto_tree *subtree; tvbuff_t *page_tvb, *unpacked_tvb; int offset = 0; int n; guint8 nr_pages, len, cb_inf_msg_len; /* Octet 1 Number-of-Pages */ nr_pages = tvb_get_guint8(tvb, offset); proto_tree_add_item(tree, hf_sabp_no_of_pages, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; /* * NOTE: n equal to or less than 15 */ if(nr_pages > 15){ /* Error */ return; } for (n = 0; n < nr_pages; n++) { subtree = proto_tree_add_subtree_format(tree, tvb, offset, 83, ett_sabp_cbs_page, NULL, "CB page %u data", n+1); /* octet 2 - 83 CBS-Message-Information-Page 1 */ cbs_page_item = proto_tree_add_item(subtree, hf_sabp_cb_msg_inf_page, tvb, offset, 82, ENC_NA); cb_inf_msg_len = tvb_get_guint8(tvb,offset+82); page_tvb = tvb_new_subset_length(tvb, offset, cb_inf_msg_len); unpacked_tvb = dissect_cbs_data(sms_encoding, page_tvb, subtree, pinfo, 0); len = tvb_captured_length(unpacked_tvb); if (unpacked_tvb != NULL){ if (tree != NULL){ proto_tree *cbs_page_subtree = proto_item_add_subtree(cbs_page_item, ett_sabp_cbs_page_content); proto_tree_add_item(cbs_page_subtree, hf_sabp_cbs_page_content, unpacked_tvb, 0, len, ENC_UTF_8|ENC_NA); } } offset = offset+82; /* 84 CBS-Message-Information-Length 1 */ proto_tree_add_item(subtree, hf_sabp_cb_inf_len, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; } }
/* Dissection */ static void dissect_dccrsp_cm_jump_time (tvbuff_t * tvb, proto_tree * tree, int start, guint16 len) { guint8 type, length; proto_tree *dcc_tree; int pos; pos = start; dcc_tree = proto_tree_add_subtree_format( tree, tvb, start, len, ett_docsis_dccrsp_cm_jump_time, NULL, "2 DCC-RSP CM Time Jump Encodings (Length = %u)", len); while ( pos < ( start + len) ) { type = tvb_get_guint8 (tvb, pos++); length = tvb_get_guint8 (tvb, pos++); switch (type) { case DCCRSP_CM_JUMP_TIME_LENGTH: if (length == 4) { proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_cm_jump_time_length, tvb, pos, length, ENC_BIG_ENDIAN); } else { THROW (ReportedBoundsError); } break; case DCCRSP_CM_JUMP_TIME_START: if (length == 8) { proto_tree_add_item (dcc_tree, hf_docsis_dccrsp_cm_jump_time_start, tvb, pos, length, ENC_BIG_ENDIAN); } else { THROW (ReportedBoundsError); } break; } pos = pos + length; } }
static void gog_attrs_tree(proto_tree* tree, packet_info *pinfo, tvbuff_t *tvb, mate_gog* gog) { AVPN* c; proto_tree *avpl_t; int* hfi_p; avpl_t = proto_tree_add_subtree_format(tree,tvb,0,0,gog->cfg->ett_attr,NULL,"%s Attributes",gog->cfg->name); for ( c = gog->avpl->null.next; c->avp; c = c->next) { hfi_p = (int *)g_hash_table_lookup(gog->cfg->my_hfids,(char*)c->avp->n); if (hfi_p) { proto_tree_add_string(avpl_t,*hfi_p,tvb,0,0,c->avp->v); } else { proto_tree_add_expert_format(avpl_t,pinfo,&ei_mate_undefined_attribute,tvb,0,0,"Undefined attribute: %s=%s",c->avp->n, c->avp->v); } } }