您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ try_val_to_str函数代码示例

51自学网 2021-06-03 08:59:19
  C++
这篇教程C++ try_val_to_str函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中try_val_to_str函数的典型用法代码示例。如果您正苦于以下问题:C++ try_val_to_str函数的具体用法?C++ try_val_to_str怎么用?C++ try_val_to_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了try_val_to_str函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: csm_to_host

/* check to see if the message is an exclusive message send to host */static gbooleancsm_to_host(guint16 fc, guint16 ct){    if (fc == 0x0000) {        return (try_val_to_str(ct, exclusive_to_host_ct_vals) != NULL);    } else {        return (try_val_to_str(fc, exclusive_to_host_vals) != NULL);    }}
开发者ID:DHODoS,项目名称:wireshark,代码行数:10,


示例2: dissect_qsig_arg

/*--- dissect_qsig_arg ------------------------------------------------------*/static intdissect_qsig_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {  int offset = 0;  rose_ctx_t *rctx;  gint32 opcode = 0, service;  const qsig_op_t *op_ptr;  const gchar *p;  proto_item *ti, *ti_tmp;  proto_tree *qsig_tree;  /* Reject the packet if data is NULL */  if (data == NULL)    return 0;  rctx = get_rose_ctx(data);  DISSECTOR_ASSERT(rctx);  if (rctx->d.pdu != 1)  /* invoke */    return offset;  if (rctx->d.code == 0) {  /* local */    opcode = rctx->d.code_local;    op_ptr = get_op(opcode);  } else if (rctx->d.code == 1) {  /* global */    op_ptr = (qsig_op_t *)g_hash_table_lookup(qsig_oid2op_hashtable, rctx->d.code_global);    if (op_ptr) opcode = op_ptr->opcode;  } else {    return offset;  }  if (!op_ptr)    return offset;  service = get_service(opcode);  ti = proto_tree_add_item(tree, proto_qsig, tvb, offset, tvb_captured_length(tvb), ENC_NA);  qsig_tree = proto_item_add_subtree(ti, ett_qsig);  proto_tree_add_uint(qsig_tree, hf_qsig_operation, tvb, 0, 0, opcode);  p = try_val_to_str(opcode, VALS(qsig_str_operation));  if (p) {    proto_item_append_text(ti, ": %s", p);    proto_item_append_text(rctx->d.code_item, " - %s", p);    if (rctx->apdu_depth >= 0)      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rctx->apdu_depth), " %s", p);  }  ti_tmp = proto_tree_add_uint(qsig_tree, hf_qsig_service, tvb, 0, 0, service);  p = try_val_to_str(service, VALS(qsig_str_service_name));  if (p) proto_item_append_text(ti_tmp, " - %s", p);  if (op_ptr->arg_pdu)    offset = op_ptr->arg_pdu(tvb, pinfo, qsig_tree, NULL);  else    if (tvb_reported_length_remaining(tvb, offset) > 0) {      proto_tree_add_expert(tree, pinfo, &ei_qsig_unsupported_error_type, tvb, offset, -1);      offset += tvb_captured_length_remaining(tvb, offset);    }  return offset;}
开发者ID:CharaD7,项目名称:wireshark,代码行数:58,


示例3: GET_VALSV

/** Here we get a special value_string, that return another value_string* pointer instead of string value. This let us use the try_val_to_str* to get val_to_str value from the value of a parameter on a more* easier way than using switch cases*/static const guint8 *dissect_mqpcf_parm_getintval(guint uPrm, guint uVal){    const value_string *pVs;    pVs = (const value_string *)try_val_to_str(uPrm, GET_VALSV(MQCFINT_Parse));    if (pVs)    {        return (const guint8 *)try_val_to_str(uVal, pVs);    }    return NULL;}
开发者ID:hekmati,项目名称:spyshark,代码行数:17,


示例4: check_xdlc_control

/* * Check whether the control field of the packet looks valid. */gbooleancheck_xdlc_control(tvbuff_t *tvb, int offset,  const value_string *u_modifier_short_vals_cmd,  const value_string *u_modifier_short_vals_resp, gboolean is_response,  gboolean is_extended _U_){    guint16 control;    if (!tvb_bytes_exist(tvb, offset, 1))	return FALSE;	/* not enough data to check */    switch (tvb_get_guint8(tvb, offset) & 0x03) {    case XDLC_S:        /*	 * Supervisory frame.	 * No fields to check for validity here.	 */	return TRUE;    case XDLC_U:	/*	 * Unnumbered frame.	 *	 * XXX - is this two octets, with a P/F bit, in HDLC extended	 * operation?  It's one octet in LLC, even though the control	 * field of I and S frames is a 2-byte extended-operation field	 * in LLC.  Given that there are no sequence numbers in the	 * control field of a U frame, there doesn't appear to be any	 * need for it to be 2 bytes in extended operation.	 */	if (u_modifier_short_vals_cmd == NULL)		u_modifier_short_vals_cmd = modifier_short_vals_cmd;	if (u_modifier_short_vals_resp == NULL)		u_modifier_short_vals_resp = modifier_short_vals_resp;	control = tvb_get_guint8(tvb, offset);	if (is_response) {		if (try_val_to_str(control & XDLC_U_MODIFIER_MASK,		    u_modifier_short_vals_resp) == NULL)			return FALSE;	/* unknown modifier */	} else {		if (try_val_to_str(control & XDLC_U_MODIFIER_MASK,		    u_modifier_short_vals_cmd) == NULL)			return FALSE;	/* unknown modifier */	}	return TRUE;    default:	/*	 * Information frame.	 * No fields to check for validity here.	 */	return TRUE;    }}
开发者ID:P1sec,项目名称:LTE_monitor_c2xx,代码行数:57,


示例5: dissect_kt

static voiddissect_kt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){    gint      magic;    proto_item *ti;    proto_tree *kt_tree;    gint offset, offset_start;    offset = 0;    while (tvb_reported_length_remaining(tvb, offset) > 0) {        magic = tvb_get_guint8(tvb, offset);        /* If the magic is not one of the known values, exit */        if (try_val_to_str(magic, kt_magic_vals) == NULL)            return;        /* Otherwise, the magic value is known. Continue */        col_set_str(pinfo->cinfo, COL_PROTOCOL, "KT");        col_set_str(pinfo->cinfo, COL_INFO, try_val_to_str(magic, kt_magic_vals));        ti = proto_tree_add_item(tree, proto_kt, tvb, offset, -1, ENC_NA);        kt_tree = proto_item_add_subtree(ti, ett_kt);        offset_start=offset;        switch (magic) {        case KT_MAGIC_REPL_WAIT:            offset = dissect_kt_replication_wait(tvb, kt_tree, offset);            break;        case KT_MAGIC_REPLICATION:            offset = dissect_kt_replication(tvb, pinfo, kt_tree, offset);            break;        case KT_MAGIC_PLAY_SCRIPT:            offset = dissect_kt_play_script(tvb, pinfo, kt_tree, offset);            break;        case KT_MAGIC_SET_BULK:            offset = dissect_kt_set_bulk(tvb, pinfo, kt_tree, offset);            break;        case KT_MAGIC_REMOVE_BULK:            offset = dissect_kt_remove_bulk(tvb, pinfo, kt_tree, offset);            break;        case KT_MAGIC_GET_BULK:            offset = dissect_kt_get_bulk(tvb, pinfo, kt_tree, offset);            break;        case KT_MAGIC_ERROR:            offset = dissect_kt_error(tvb, kt_tree, offset);            break;        }        proto_item_set_len(ti, offset-offset_start);    }}
开发者ID:RayHightower,项目名称:wireshark,代码行数:53,


示例6: dissect_operation_tlv

static voiddissect_operation_tlv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset, gint length_count){    proto_item *ti;    proto_tree *oper_tree;    guint       type, length;    while (tvb_reported_length_remaining(tvb, offset) >= TLV_TL_LENGTH)    {        oper_tree = proto_tree_add_subtree(tree, tvb, offset, length_count,            ett_forces_lfbselect_tlv_type_operation, &ti, "Operation TLV");        type = tvb_get_ntohs(tvb,offset);        ti = proto_tree_add_item(oper_tree, hf_forces_lfbselect_tlv_type_operation_type,                                 tvb, offset, 2, ENC_BIG_ENDIAN);        if (try_val_to_str(type, operation_type_vals) == NULL)            expert_add_info_format(pinfo, ti, &ei_forces_lfbselect_tlv_type_operation_type,                "Bogus: ForCES Operation TLV (Type:0x%04x) is not supported", type);        proto_tree_add_item_ret_uint(oper_tree, hf_forces_lfbselect_tlv_type_operation_length,                                   tvb, offset+2, 2, ENC_BIG_ENDIAN, &length);        dissect_path_data_tlv(tvb, pinfo, oper_tree, offset+TLV_TL_LENGTH);        if (length == 0)            break;        offset += length;    }}
开发者ID:acaceres2176,项目名称:wireshark,代码行数:28,


示例7: spx_conn_ctrl

static const char*spx_conn_ctrl(guint8 ctrl){	const char *p;	static const value_string conn_vals[] = {		{ 0x00,                        "Data, No Ack Required" },		{ SPX_EOM,                     "End-of-Message" },		{ SPX_ATTN,                    "Attention" },		{ SPX_SEND_ACK,                "Acknowledgment Required"},		{ SPX_SEND_ACK|SPX_EOM,        "Send Ack: End Message"},		{ SPX_SYS_PACKET,              "System Packet"},		{ SPX_SYS_PACKET|SPX_SEND_ACK, "System Packet: Send Ack"},		{ 0x00,                        NULL }	};	p = try_val_to_str((ctrl & 0xf0), conn_vals );	if (p) {		return p;	}	else {		return "Unknown";	}}
开发者ID:zonquan,项目名称:dumphttp,代码行数:25,


示例8: is_armagetronad_packet

static gbooleanis_armagetronad_packet(tvbuff_t * tvb){	gint offset = 0;	/* For each message in the frame */	while (tvb_captured_length_remaining(tvb, offset) > 2) {		gint data_len = tvb_get_ntohs(tvb, offset + 4) * 2;#if 0		/*		 * If the descriptor_id is not in the table it's possibly		 * because the protocol evoluated, losing synchronization		 * with the table, that's why we don't consider that as		 * a heuristic		 */		if (!try_val_to_str(tvb_get_ntohs(tvb, offset), descriptors))			/* DescriptorID not found in the table */			return FALSE;#endif		if (!tvb_bytes_exist(tvb, offset + 6, data_len))			/* Advertised length too long */			return FALSE;		offset += 6 + data_len;	}	/* The packed should end with a 2 bytes ID */	return tvb_captured_length_remaining(tvb, offset) == 2;}
开发者ID:CharaD7,项目名称:wireshark,代码行数:31,


示例9: val_to_str_wmem

gchar *val_to_str_wmem(wmem_allocator_t *scope, const guint32 val, const value_string *vs, const char *fmt){    const gchar *ret;    DISSECTOR_ASSERT(fmt != NULL);    ret = try_val_to_str(val, vs);    if (ret != NULL)        return wmem_strdup(scope, ret);    return wmem_strdup_printf(scope, fmt, val);}
开发者ID:Matt-Texier,项目名称:wireshark,代码行数:13,


示例10: val_to_str

/* Tries to match val against each element in the value_string array vs.   Returns the associated string ptr on a match.   Formats val with fmt, and returns the resulting string, on failure. */const gchar *val_to_str(const guint32 val, const value_string *vs, const char *fmt){    const gchar *ret;    DISSECTOR_ASSERT(fmt != NULL);    ret = try_val_to_str(val, vs);    if (ret != NULL)        return ret;    return wmem_strdup_printf(wmem_packet_scope(), fmt, val);}
开发者ID:Matt-Texier,项目名称:wireshark,代码行数:16,


示例11: dissect_netlink_attributes

intdissect_netlink_attributes(tvbuff_t *tvb, header_field_info *hfi_type, int ett, void *data, proto_tree *tree, int offset, netlink_attributes_cb_t cb){	/* align to 4 */	offset = (offset + 3) & ~3;	while (tvb_length_remaining(tvb, offset) >= 4) {		guint16 rta_len, rta_type;		int end_offset;		proto_item *ti;		proto_tree *attr_tree;		rta_len = tvb_get_letohs(tvb, offset);		if (rta_len < 4) {			/* XXX invalid expert */			break;		}		end_offset = (offset + rta_len + 3) & ~3;		ti = proto_tree_add_text(tree, tvb, offset, end_offset - offset, "Attribute");		attr_tree = proto_item_add_subtree(ti, ett);		proto_tree_add_text(attr_tree, tvb, offset, 2, "Len: %d", rta_len);		offset += 2;		rta_type = tvb_get_letohs(tvb, offset);		proto_tree_add_item(attr_tree, hfi_type, tvb, offset, 2, ENC_LITTLE_ENDIAN);		offset += 2;		if (hfi_type->strings) {			/* XXX, export hf_try_val_to_str */			const char *rta_str = try_val_to_str(rta_type, (const value_string *) hfi_type->strings);			if (rta_str)				proto_item_append_text(ti, ": %s", rta_str);		}		if (!cb(tvb, data, attr_tree, rta_type, offset, rta_len - 4)) {			/* not handled */		}		if (end_offset <= offset)			break;		offset = end_offset;	}	return offset;}
开发者ID:pvons,项目名称:wireshark,代码行数:51,


示例12: val_to_str_const

/* Tries to match val against each element in the value_string array vs.   Returns the associated string ptr on a match.   Returns 'unknown_str', on failure. */const gchar *val_to_str_const(const guint32 val, const value_string *vs,        const char *unknown_str){    const gchar *ret;    DISSECTOR_ASSERT(unknown_str != NULL);    ret = try_val_to_str(val, vs);    if (ret != NULL)        return ret;    return unknown_str;}
开发者ID:Matt-Texier,项目名称:wireshark,代码行数:17,


示例13: dissect_isdn_sup_arg

/*--- dissect_isdn_sup_arg ------------------------------------------------------*/static intdissect_isdn_sup_arg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {  int offset = 0;  rose_ctx_t *rctx;  gint32 opcode = 0;  const gchar *p;  const isdn_sup_op_t *op_ptr;  proto_item *ti;  proto_tree *isdn_sup_tree;  /* Reject the packet if data is NULL */  if (data == NULL)    return 0;  rctx = get_rose_ctx(data);  DISSECTOR_ASSERT(rctx);  if (rctx->d.pdu != 1)  /* invoke */    return offset;  if (rctx->d.code == 0) {  /* local */    opcode = rctx->d.code_local;  } else {    return offset;  }  op_ptr = get_op(opcode);  if (!op_ptr)    return offset;  ti = proto_tree_add_item(tree, proto_isdn_sup, tvb, offset, -1, ENC_NA);  isdn_sup_tree = proto_item_add_subtree(ti, ett_isdn_sup);  proto_tree_add_uint(isdn_sup_tree, hf_isdn_sup_operation, tvb, 0, 0, opcode);  p = try_val_to_str(opcode, VALS(isdn_sup_str_operation));  if (p) {    proto_item_append_text(ti, ": %s", p);    proto_item_append_text(rctx->d.code_item, " - %s", p);    if (rctx->apdu_depth >= 0)      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rctx->apdu_depth), " %s", p);  }  if (op_ptr->arg_pdu)    offset = op_ptr->arg_pdu(tvb, pinfo, isdn_sup_tree, NULL);  else    if (tvb_reported_length_remaining(tvb, offset) > 0) {      proto_tree_add_expert(tree, pinfo, &ei_isdn_sup_unsupported_error_type, tvb, offset, -1);      offset += tvb_reported_length_remaining(tvb, offset);    }  return offset;}
开发者ID:DuLerWeil,项目名称:wireshark,代码行数:50,


示例14: dissect_qsig_err

/*--- dissect_qsig_err ------------------------------------------------------*/static intdissect_qsig_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {  int offset = 0;  rose_ctx_t *rctx;  gint32 errcode;  const qsig_err_t *err_ptr;  const gchar *p;  proto_item *ti;  proto_tree *qsig_tree;  /* Reject the packet if data is NULL */  if (data == NULL)    return 0;  rctx = get_rose_ctx(data);  DISSECTOR_ASSERT(rctx);  if (rctx->d.pdu != 3)  /* returnError */    return offset;  if (rctx->d.code != 0)  /* local */    return offset;  errcode = rctx->d.code_local;  err_ptr = get_err(errcode);  if (!err_ptr)    return offset;  ti = proto_tree_add_item(tree, proto_qsig, tvb, offset, tvb_captured_length(tvb), ENC_NA);  qsig_tree = proto_item_add_subtree(ti, ett_qsig);  proto_tree_add_uint(qsig_tree, hf_qsig_error, tvb, 0, 0, errcode);  p = try_val_to_str(errcode, VALS(qsig_str_error));  if (p) {    proto_item_append_text(ti, ": %s", p);    proto_item_append_text(rctx->d.code_item, " - %s", p);    if (rctx->apdu_depth >= 0)      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rctx->apdu_depth), " %s", p);  }  if (err_ptr->err_pdu)    offset = err_ptr->err_pdu(tvb, pinfo, qsig_tree, NULL);  else    if (tvb_reported_length_remaining(tvb, offset) > 0) {      proto_tree_add_expert(tree, pinfo, &ei_qsig_unsupported_error_type, tvb, offset, -1);      offset += tvb_captured_length_remaining(tvb, offset);    }  return offset;}
开发者ID:CharaD7,项目名称:wireshark,代码行数:48,


示例15: dissect_h450_err

/*--- dissect_h450_err ------------------------------------------------------*/static intdissect_h450_err(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {  proto_item *hidden_item;  int offset = 0;  rose_ctx_t *rctx;  gint32 errcode;  const h450_err_t *err_ptr;  const gchar *p;  /* Reject the packet if data is NULL */  if (data == NULL)    return 0;  rctx = get_rose_ctx(data);  DISSECTOR_ASSERT(rctx);  if (rctx->d.pdu != 3)  /* returnError */    return offset;  if (rctx->d.code != 0)  /* local */    return offset;  errcode = rctx->d.code_local;  err_ptr = get_err(errcode);  if (!err_ptr)    return offset;  hidden_item = proto_tree_add_uint(tree, hf_h450_error, tvb, 0, 0, errcode);  PROTO_ITEM_SET_HIDDEN(hidden_item);  p = try_val_to_str(errcode, VALS(h450_str_error));  if (p) {    proto_item_append_text(rctx->d.code_item, " - %s", p);    if (rctx->apdu_depth >= 0)      proto_item_append_text(proto_item_get_parent_nth(proto_tree_get_parent(tree), rctx->apdu_depth), " %s", p);  }  if (err_ptr->err_pdu && (tvb_reported_length_remaining(tvb, offset) > 0))    offset = err_ptr->err_pdu(tvb, pinfo, tree, NULL);  else    if (tvb_reported_length_remaining(tvb, offset) > 0) {      proto_tree_add_expert(tree, pinfo, &ei_h450_unsupported_error_type, tvb, offset, -1);      offset += tvb_reported_length_remaining(tvb, offset);    }  return offset;}
开发者ID:DHODoS,项目名称:wireshark,代码行数:44,


示例16: dissect_cbs_message_identifier

guint dissect_cbs_message_identifier(tvbuff_t *tvb, proto_tree *tree, guint offset){   guint16 msg_id;   const char *msg_id_string = NULL;   msg_id = tvb_get_ntohs(tvb, offset);   msg_id_string = try_val_to_str(msg_id, message_id_values);   if (msg_id_string == NULL)   {      if (msg_id < 1000)      {         msg_id_string = "Message ID to be allocated by GSMA";      }      else if (msg_id < 4096)      {         msg_id_string = "Message ID intended for standardization in future versions of 3GPP TS 23.041";      }      else if (msg_id < 4224)      {         msg_id_string = "Message ID reserved for Cell Broadcast Data Download (unsecured) to the SIM ";      }      else if (msg_id < 4352)      {         msg_id_string = "Message ID reserved for Cell Broadcast Data Download (secured) to the SIM ";      }      else if (msg_id < 4360)      {         msg_id_string = "ETWS CBS Message Identifier for future extension";      }      else if (msg_id < 4400)      {         msg_id_string = "CMAS CBS Message Identifier for future extension";      }      else if (msg_id < 6400)      {         msg_id_string = "CBS Message Identifier for future PWS use";      }      else if (msg_id < 40960)      {         msg_id_string = "Intended for standardization in future versions of 3GPP TS 23.041";      }      else if (msg_id < 43500)      {         msg_id_string = "Message ID in PLMN operator specific range";      }      else if (msg_id < 43530)      {         msg_id_string = "Traffic Information Traffic Master UK";      }      else if (msg_id < 43585)      {         msg_id_string = "Traffic information Mannesmann Telecommerce";      }      else if (msg_id < 45056)      {         msg_id_string = "Message ID in PLMN operator specific range";      }      else      {         msg_id_string = "Message ID intended as PLMN operator specific range in future versions of 3GPP TS 23.041";      }   }   proto_tree_add_uint_format_value(tree, hf_gsm_cbs_message_identifier, tvb, offset, 2, msg_id, "%s (%d)", msg_id_string, msg_id);   offset += 2;   return offset;}
开发者ID:CharaD7,项目名称:wireshark,代码行数:66,


示例17: ethertype

/*voidethertype(guint16 etype, tvbuff_t *tvb, int offset_after_etype,	  packet_info *pinfo, proto_tree *tree, proto_tree *fh_tree,	  int etype_id, int trailer_id, int fcs_len)*/static intdissect_ethertype(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data){	const char	  *description;	tvbuff_t	  *volatile next_tvb;	guint		   length_before;	gint		   captured_length, reported_length;	volatile int  dissector_found = 0;	const char	  *volatile saved_proto;	ethertype_data_t  *ethertype_data;	/* Reject the packet if data is NULL */	if (data == NULL)		return 0;	ethertype_data = (ethertype_data_t*)data;	/* Add the Ethernet type to the protocol tree */	proto_tree_add_uint(ethertype_data->fh_tree, ethertype_data->etype_id, tvb,				    ethertype_data->offset_after_ethertype - 2, 2, ethertype_data->etype);	/* Get the captured length and reported length of the data	   after the Ethernet type. */	captured_length = tvb_captured_length_remaining(tvb, ethertype_data->offset_after_ethertype);	reported_length = tvb_reported_length_remaining(tvb,							ethertype_data->offset_after_ethertype);	/* Remember how much data there is after the Ethernet type,	   including any trailer and FCS. */	length_before = reported_length;	/* Construct a tvbuff for the payload after the Ethernet type.	   If the FCS length is positive, remove the FCS.	   (If it's zero, there's no FCS; if it's negative,	   we don't know whether there's an FCS, so we'll	   guess based on the length of the trailer.) */	if (ethertype_data->fcs_len > 0) {		if (captured_length >= 0 && reported_length >= 0) {			if (reported_length >= ethertype_data->fcs_len)				reported_length -= ethertype_data->fcs_len;			if (captured_length > reported_length)				captured_length = reported_length;		}	}	next_tvb = tvb_new_subset(tvb, ethertype_data->offset_after_ethertype, captured_length,				  reported_length);	p_add_proto_data(pinfo->pool, pinfo, proto_ethertype, 0, GUINT_TO_POINTER((guint)ethertype_data->etype));	/* Look for sub-dissector, and call it if found.	   Catch exceptions, so that if the reported length of "next_tvb"	   was reduced by some dissector before an exception was thrown,	   we can still put in an item for the trailer. */	saved_proto = pinfo->current_proto;	TRY {		dissector_found = dissector_try_uint(ethertype_dissector_table,						     ethertype_data->etype, next_tvb, pinfo, tree);	}	CATCH_NONFATAL_ERRORS {		/* Somebody threw an exception that means that there		   was a problem dissecting the payload; that means		   that a dissector was found, so we don't need to		   dissect the payload as data or update the protocol		   or info columns.		   Just show the exception and then drive on to show		   the trailer, after noting that a dissector was found		   and restoring the protocol value that was in effect		   before we called the subdissector. */		show_exception(next_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);		dissector_found = 1;		pinfo->current_proto = saved_proto;	}	ENDTRY;	if (!dissector_found) {		/* No sub-dissector found.		   Label rest of packet as "Data" */		call_data_dissector(next_tvb, pinfo, tree);		/* Label protocol */		col_add_fstr(pinfo->cinfo, COL_PROTOCOL, "0x%04x", ethertype_data->etype);		description = try_val_to_str(ethertype_data->etype, etype_vals);		if (description) {			col_add_str(pinfo->cinfo, COL_INFO, description);		}	}	add_dix_trailer(pinfo, tree, ethertype_data->fh_tree, ethertype_data->trailer_id, tvb, next_tvb, ethertype_data->offset_after_ethertype,			length_before, ethertype_data->fcs_len);	return tvb_captured_length(tvb);}
开发者ID:ajmohan,项目名称:wireshark,代码行数:100,


示例18: dissect_ncp_common

static voiddissect_ncp_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,    gboolean is_tcp){    proto_tree            *ncp_tree = NULL;    proto_item            *ti;    struct ncp_ip_header  ncpiph;    struct ncp_ip_rqhdr   ncpiphrq;    guint16               ncp_burst_seqno, ncp_ack_seqno;    guint16               flags = 0;    proto_tree            *flags_tree = NULL;    int                   hdr_offset = 0;    int                   commhdr = 0;    int                   offset = 0;    gint                  length_remaining;    tvbuff_t              *next_tvb;    guint32               testvar = 0, ncp_burst_command, burst_len, burst_off, burst_file;    guint8                subfunction;    guint32               nw_connection = 0, data_offset;    guint16               data_len = 0;    guint16               missing_fraglist_count = 0;    mncp_rhash_value      *request_value = NULL;    conversation_t        *conversation;    proto_item            *expert_item;    col_set_str(pinfo->cinfo, COL_PROTOCOL, "NCP");    col_clear(pinfo->cinfo, COL_INFO);    ncp_hdr = &header;    ti = proto_tree_add_item(tree, proto_ncp, tvb, 0, -1, ENC_NA);    ncp_tree = proto_item_add_subtree(ti, ett_ncp);    if (is_tcp) {        if (tvb_get_ntohl(tvb, hdr_offset) != NCPIP_RQST && tvb_get_ntohl(tvb, hdr_offset) != NCPIP_RPLY)            commhdr += 1;        /* Get NCPIP Header data */        ncpiph.signature = tvb_get_ntohl(tvb, commhdr);        proto_tree_add_uint(ncp_tree, hf_ncp_ip_sig, tvb, commhdr, 4, ncpiph.signature);        ncpiph.length = (0x7fffffff & tvb_get_ntohl(tvb, commhdr+4));        proto_tree_add_uint(ncp_tree, hf_ncp_ip_length, tvb, commhdr+4, 4, ncpiph.length);        commhdr += 8;        if (ncpiph.signature == NCPIP_RQST) {            ncpiphrq.version = tvb_get_ntohl(tvb, commhdr);            proto_tree_add_uint(ncp_tree, hf_ncp_ip_ver, tvb, commhdr, 4, ncpiphrq.version);            commhdr += 4;            ncpiphrq.rplybufsize = tvb_get_ntohl(tvb, commhdr);            proto_tree_add_uint(ncp_tree, hf_ncp_ip_rplybufsize, tvb, commhdr, 4, ncpiphrq.rplybufsize);            commhdr += 4;        }        /* Check to see if this is a valid offset, otherwise increment for packet signature */        if (try_val_to_str(tvb_get_ntohs(tvb, commhdr), ncp_type_vals)==NULL) {            /* Check to see if we have a valid type after packet signature length */            if (try_val_to_str(tvb_get_ntohs(tvb, commhdr+8), ncp_type_vals)!=NULL) {                proto_tree_add_item(ncp_tree, hf_ncp_ip_packetsig, tvb, commhdr, 8, ENC_NA);                commhdr += 8;            }        }    } else {        /* Initialize this structure, we use it below */        memset(&ncpiph, 0, sizeof(ncpiph));    }    header.type         = tvb_get_ntohs(tvb, commhdr);    header.sequence     = tvb_get_guint8(tvb, commhdr+2);    header.conn_low     = tvb_get_guint8(tvb, commhdr+3);    header.task         = tvb_get_guint8(tvb, commhdr+4);    header.conn_high    = tvb_get_guint8(tvb, commhdr+5);    proto_tree_add_uint(ncp_tree, hf_ncp_type, tvb, commhdr, 2, header.type);    nw_connection = (header.conn_high*256)+header.conn_low;    /* Ok, we need to track the conversation so that we can     * determine if a new server session is occuring for this     * connection.     */    conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,        PT_NCP, (guint32) pinfo->srcport, (guint32) pinfo->destport,        0);    if ((ncpiph.length & 0x80000000) || ncpiph.signature == NCPIP_RPLY) {        /* First time through we will record the initial connection and task         * values         */        if (!pinfo->fd->flags.visited) {            if (conversation != NULL) {                /* find the record telling us the                 * request made that caused this                 * reply                 */                request_value = mncp_hash_lookup(conversation, nw_connection, header.task);                /* if for some reason we have no                 * conversation in our hash, create                 * one */                if (request_value == NULL) {                    mncp_hash_insert(conversation, nw_connection, header.task, pinfo);                }            } else {                /* It's not part of any conversation                 * - create a new one.                 */                conversation = conversation_new(pinfo->fd->num, &pinfo->src,                    &pinfo->dst, PT_NCP, (guint32) pinfo->srcport, (guint32) pinfo->destport, 0);//.........这里部分代码省略.........
开发者ID:hashbrowncipher,项目名称:wireshark,代码行数:101,


示例19: dissect_pw_cesopsn

//.........这里部分代码省略.........			 * will be overwritten if no errors found:			 */			payload_size = payload_size_from_packet;			padding_size = 0;			if (payload_size_from_cw < 0)			{				properties |= PWC_CW_BAD_PAYLEN_LT_0;			}			else if (payload_size_from_cw > payload_size_from_packet)			{				properties |= PWC_CW_BAD_PAYLEN_GT_PACKET;			}			else if (payload_size_from_packet >= 64)			{				properties |= PWC_CW_BAD_LEN_MUST_BE_0;			}			else /* ok */			{				payload_size = payload_size_from_cw;				padding_size = payload_size_from_packet - payload_size_from_cw; /* >=0 */			}		}		else		{			payload_size = payload_size_from_packet;			padding_size = 0;		}	}	{		guint8 cw_lm;		cw_lm = tvb_get_guint8(tvb_original, 0) & 0x0b /*l+mod*/;		if (NULL == try_val_to_str(cw_lm, vals_cw_lm))		{			properties |= PWC_CW_SUSPECT_LM;		}		{			guint8 l_bit, m_bits;			l_bit  = (cw_lm & 0x08) >> 3;			m_bits = (cw_lm & 0x03) >> 0;			if ((l_bit == 0 && m_bits == 0x0) /*CESoPSN data packet - normal situation*/			    ||(l_bit == 0 && m_bits == 0x2) /*CESoPSN data packet - RDI on the AC*/ )			{				if ((payload_size == 0) || ((payload_size % 8) != 0))				{					properties |= PWC_PAY_SIZE_BAD;				}			}			else if (l_bit == 1 && m_bits == 0x0) /*TDM data is invalid; payload MAY be omitted*/			{				/*allow any size of payload*/			}			else /*reserved combinations*/			{				/*allow any size of payload*/			}		}	}	/* fill up columns*/	col_set_str(pinfo->cinfo, COL_PROTOCOL, shortname);	col_clear(pinfo->cinfo, COL_INFO);	if (properties & PWC_ANYOF_CW_BAD)	{
开发者ID:huzhiren,项目名称:wireshark,代码行数:67,


示例20: dissect_ipa

/* Code to actually dissect the packets */static gbooleandissect_ipa(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_udp){	gint remaining;	gint header_length = 3;	int offset = 0;	guint16 len, msg_type;	if (tvb_reported_length(tvb) < 4)		return FALSE;	//sanity check the message type	msg_type = tvb_get_guint8(tvb, 2);	if ((try_val_to_str(msg_type, ipa_protocol_vals) == NULL) &&		(msg_type >= ABISIP_RSL_MAX))		return FALSE;	col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPA");	col_clear(pinfo->cinfo, COL_INFO);	while ((remaining = tvb_reported_length_remaining(tvb, offset)) > 0) {		proto_item *ti;		proto_tree *ipa_tree = NULL;		tvbuff_t *next_tvb;		len = tvb_get_ntohs(tvb, offset);		msg_type = tvb_get_guint8(tvb, offset+2);		col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",		                val_to_str(msg_type, ipa_protocol_vals,		                           "unknown 0x%02x"));		/*		 * The IPA header is different depending on the transport protocol.		 * With UDP there seems to be a fourth byte for the IPA header.		 * We attempt to detect this by checking if the length from the		 * header + four bytes of the IPA header equals the remaining size.		 */		if (is_udp && (len + 4 == remaining)) {			header_length++;		}		ti = proto_tree_add_protocol_format(tree, proto_ipa,				tvb, offset, len+header_length,				"IPA protocol ip.access, type: %s",				val_to_str(msg_type, ipa_protocol_vals,					"unknown 0x%02x"));		ipa_tree = proto_item_add_subtree(ti, ett_ipa);		proto_tree_add_item(ipa_tree, hf_ipa_data_len,				tvb, offset, 2, ENC_BIG_ENDIAN);		proto_tree_add_item(ipa_tree, hf_ipa_protocol,				tvb, offset+2, 1, ENC_BIG_ENDIAN);		next_tvb = tvb_new_subset_length(tvb, offset+header_length, len);		switch (msg_type) {		case ABISIP_OML:			/* hand this off to the standard A-bis OML dissector */			if (sub_handles[SUB_OML])				call_dissector(sub_handles[SUB_OML], next_tvb,						 pinfo, tree);			break;		case ABISIP_IPACCESS:			dissect_ipaccess(next_tvb, pinfo, tree);			break;		case AIP_SCCP:			/* hand this off to the standard SCCP dissector */			call_dissector(sub_handles[SUB_SCCP], next_tvb, pinfo, tree);			break;		case IPA_MGCP:			/* hand this off to the standard MGCP dissector */			call_dissector(sub_handles[SUB_MGCP], next_tvb, pinfo, tree);			break;		case OSMO_EXT:			dissect_osmo(next_tvb, pinfo, ipa_tree, tree, ti);			break;		case HSL_DEBUG:			proto_tree_add_item(ipa_tree, hf_ipa_hsl_debug,					next_tvb, 0, len, ENC_ASCII|ENC_NA);			if (global_ipa_in_root == TRUE)				proto_tree_add_item(tree, hf_ipa_hsl_debug,						next_tvb, 0, len, ENC_ASCII|ENC_NA);			if (global_ipa_in_info == TRUE)				col_append_fstr(pinfo->cinfo, COL_INFO, "%s ",						tvb_get_stringz_enc(wmem_packet_scope(), next_tvb, 0, NULL, ENC_ASCII));			break;		default:			if (msg_type < ABISIP_RSL_MAX) {				/* hand this off to the standard A-bis RSL dissector */				call_dissector(sub_handles[SUB_RSL], next_tvb, pinfo, tree);			}			break;		}		offset += len + header_length;	}	return TRUE;}
开发者ID:ssyram,项目名称:wireshark,代码行数:99,


示例21: dissect_nmas_reply

//.........这里部分代码省略.........            case 4:             /* Client Get Data */                proto_tree_add_item(atree, hf_opaque, tvb, foffset, msg_length, ENC_NA);                /*foffset += msg_length;*/                break;            case 6:             /* Client Get User NDS Credentials */                proto_tree_add_item(atree, hf_num_creds, tvb, foffset, 4, ENC_LITTLE_ENDIAN);                foffset += 4;                proto_tree_add_item(atree, hf_cred_type, tvb, foffset, 4, ENC_LITTLE_ENDIAN);                foffset += 4;                proto_tree_add_item(atree, hf_login_state, tvb, foffset, 4, ENC_LITTLE_ENDIAN);                foffset += 4;                msg_length -= 12;                proto_tree_add_item(atree, hf_enc_cred, tvb, foffset, msg_length, ENC_NA);                /*foffset += msg_length;*/                break;            case 8:             /* Login Store Management */                proto_tree_add_uint_format(atree, hf_lsm_verb, tvb, foffset, -1, msgverb,                                           "Subverb: %s", val_to_str(msgverb, nmas_lsmverb_enum, "Unknown (%u)"));                switch(msgverb) {                /* The data within these structures is all encrypted. */                case 1:                case 3:                case 5:                case 7:                case 9:                    proto_tree_add_item(atree, hf_enc_data, tvb, foffset, msg_length, ENC_NA);                    /*foffset += msg_length;*/                    break;                default:                    break;                }                break;            case 10:            /* Writable Object Check */                proto_tree_add_item(atree, hf_nmas_version, tvb, foffset, 4, ENC_LITTLE_ENDIAN);                /*foffset += 4;*/                break;            case 1242:          /* Message Handler */                proto_tree_add_uint_format(atree, hf_msg_verb, tvb, foffset, 1, msgverb,                                           "Subverb: %s", val_to_str(msgverb, nmas_msgverb_enum, "Unknown (%u)"));                switch(msgverb) {                case 1:                    msg_length = tvb_get_ntohl(tvb, foffset);                    proto_tree_add_item(atree, hf_length, tvb, foffset, 4, ENC_BIG_ENDIAN);                    foffset += 4;                    proto_tree_add_item(atree, hf_data, tvb, foffset, msg_length, ENC_NA);                    /*foffset += msg_length;*/                    break;                case 3:                    proto_tree_add_item(atree, hf_session_ident, tvb, foffset, 4, ENC_BIG_ENDIAN);                    /*foffset += 4;*/                    break;                case 5:                    /* No Op */                    break;                case 7:                    encrypt_error = tvb_get_ntohl(tvb, foffset);                    str = try_val_to_str(encrypt_error, nmas_errors_enum);                    if (str) {                        col_add_fstr(pinfo->cinfo, COL_INFO, "R Payload Error - %s", str);                        expert_item = proto_tree_add_item(atree, hf_encrypt_error, tvb, foffset, 4, ENC_BIG_ENDIAN);                        expert_add_info_format(pinfo, expert_item, &ei_encrypt_error, "NMAS Payload Error: %s", str);                    } else {                        proto_tree_add_item(atree, hf_opaque, tvb, foffset, msg_length, ENC_NA);                    }                    /*foffset += msg_length;*/                    break;                case 9:                    /* No Op */                    break;                default:                    break;                }                break;            default:                break;            }        }        str = try_val_to_str(return_code, nmas_errors_enum);        if (str) {            expert_item = proto_tree_add_item(atree, hf_return_code, tvb, roffset, 4, ENC_LITTLE_ENDIAN);            expert_add_info_format(pinfo, expert_item, &ei_return_error, "NMAS Error: 0x%08x %s", return_code, str);            col_add_fstr(pinfo->cinfo, COL_INFO, "R Error - %s", str);        } else {            if (return_code!=0) {                expert_item = proto_tree_add_item(atree, hf_return_code, tvb, roffset, 4, ENC_LITTLE_ENDIAN);                expert_add_info_format(pinfo, expert_item, &ei_return_error, "NMAS Error: 0x%08x is unknown", return_code);                col_add_fstr(pinfo->cinfo, COL_INFO, "R Unknown NMAS Error - 0x%08x", return_code);            }        }        if (return_code == 0) {            proto_tree_add_uint_format_value(atree, hf_return_code, tvb, roffset, 4, return_code, "Success (0x00000000)");        }        break;    case 3:        break;    default:        break;    }}
开发者ID:bearxiong99,项目名称:wireshark,代码行数:101,


示例22: display_xip_serval

static voiddisplay_xip_serval(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){	proto_tree *xip_serval_tree;	proto_item *ti, *check_ti, *hl_ti;	tvbuff_t *next_tvb;	vec_t cksum_vec;	gint offset;	guint16 packet_checksum, actual_checksum;	guint8 xsh_len, protocol, bytes_remaining;	/* Get XIP Serval header length, stored as number of 32-bit words. */	xsh_len = tvb_get_guint8(tvb, XSRVL_LEN) << 2;	/* Create XIP Serval header tree. */	ti = proto_tree_add_item(tree, proto_xip_serval, tvb,		0, xsh_len, ENC_NA);	xip_serval_tree = proto_item_add_subtree(ti, ett_xip_serval_tree);	/* Add XIP Serval header length. */	hl_ti = proto_tree_add_item(xip_serval_tree, hf_xip_serval_hl, tvb,		XSRVL_LEN, 1, ENC_BIG_ENDIAN);	proto_item_append_text(hl_ti, " bytes");	if (tvb_captured_length(tvb) < xsh_len)		expert_add_info_format(pinfo, hl_ti, &ei_xip_serval_bad_len,			"Header Length field (%d bytes) cannot be greater than actual number of bytes left in packet (%d bytes)",			xsh_len, tvb_captured_length(tvb));	/* Add XIP Serval protocol. If it's not data, TCP, or UDP, the	 * packet is malformed.	 */	proto_tree_add_item(xip_serval_tree, hf_xip_serval_proto, tvb,		XSRVL_PRO, 1, ENC_BIG_ENDIAN);	protocol = tvb_get_guint8(tvb, XSRVL_PRO);	if (!try_val_to_str(protocol, xip_serval_proto_vals))		expert_add_info_format(pinfo, ti, &ei_xip_serval_bad_proto,			"Unrecognized protocol type: %d", protocol);	/* Compute checksum. */	SET_CKSUM_VEC_TVB(cksum_vec, tvb, 0, xsh_len);	actual_checksum = in_cksum(&cksum_vec, 1);	/* Get XIP Serval checksum. */	packet_checksum = tvb_get_ntohs(tvb, XSRVL_CHK);	if (actual_checksum == 0) {		/* Add XIP Serval checksum as correct. */		proto_tree_add_uint_format(xip_serval_tree,			hf_xip_serval_check, tvb, XSRVL_CHK, 2, packet_checksum,			"Header checksum: 0x%04x [correct]", packet_checksum);	} else {		/* Add XIP Serval checksum as incorrect. */		check_ti = proto_tree_add_uint_format(xip_serval_tree,			hf_xip_serval_check, tvb, XSRVL_CHK, 2, packet_checksum,			"Header checksum: 0x%04x [incorrect, should be 0x%04x]",			packet_checksum,			in_cksum_shouldbe(packet_checksum, actual_checksum));		expert_add_info_format(pinfo, check_ti,			&ei_xip_serval_bad_checksum, "Bad checksum");	}	offset = XSRVL_EXT;	/* If there's still more room, check for extension headers. */	bytes_remaining = xsh_len - offset;	while (bytes_remaining >= XIP_SERVAL_EXT_MIN_LEN) {		gint8 bytes_displayed = display_xip_serval_ext(tvb, pinfo, ti,			xip_serval_tree, offset);		/* Extension headers are malformed, so we can't say		 * what the rest of the packet holds. Stop dissecting.		 */		if (bytes_displayed <= 0)			return;		offset += bytes_displayed;		bytes_remaining -= bytes_displayed;	}	switch (protocol) {	case XIP_SERVAL_PROTO_DATA:		next_tvb = tvb_new_subset_remaining(tvb, offset);		call_dissector(data_handle, next_tvb, pinfo, tree);		break;	case IP_PROTO_TCP: {		/* Get the Data Offset field of the TCP header, which is		 * the high nibble of the 12th octet and represents the		 * size of the TCP header of 32-bit words.		 */		guint8 tcp_len = hi_nibble(tvb_get_guint8(tvb, offset + 12))*4;		next_tvb = tvb_new_subset(tvb, offset, tcp_len, tcp_len);		call_dissector(tcp_handle, next_tvb, pinfo, tree);		break;	}	case IP_PROTO_UDP:		/* The UDP header is always 8 bytes. */		next_tvb = tvb_new_subset(tvb, offset, 8, 8);		call_dissector(udp_handle, next_tvb, pinfo, tree);		break;//.........这里部分代码省略.........
开发者ID:DuLerWeil,项目名称:wireshark,代码行数:101,


示例23: dissect_bfcp

/* Code to actually dissect BFCP packets */static voiddissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree){	int          offset = 0;	guint8       primitive;	const gchar *str;	gint         bfcp_payload_length;	proto_tree  *bfcp_tree = NULL;	primitive = tvb_get_guint8(tvb, 1);	str = try_val_to_str(primitive, map_bfcp_primitive);	/* Make entries in Protocol column and Info column on summary display*/	col_set_str(pinfo->cinfo, COL_PROTOCOL, "BFCP");	col_add_str(pinfo->cinfo, COL_INFO, str);	if (tree) {		proto_item	*ti;		ti = proto_tree_add_item(tree, proto_bfcp, tvb, 0, -1, ENC_NA);		bfcp_tree = proto_item_add_subtree(ti, ett_bfcp);/*  The following is the format of the common header.     0                   1                   2                   3     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    | Ver |R|F| Res |  Primitive    |        Payload Length         |    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    |                         Conference ID                         |    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    |         Transaction ID        |            User ID            |    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    | Fragment Offset (if F is set) | Fragment Length (if F is set) |    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+*/		/* Add items to BFCP tree */		proto_tree_add_item(bfcp_tree, hf_bfcp_version, tvb, offset, 1, ENC_BIG_ENDIAN);		proto_tree_add_item(bfcp_tree, hf_bfcp_hdr_r_bit, tvb, offset, 1, ENC_BIG_ENDIAN);		proto_tree_add_item(bfcp_tree, hf_bfcp_hdr_f_bit, tvb, offset, 1, ENC_BIG_ENDIAN);		offset++;		proto_tree_add_item(bfcp_tree, hf_bfcp_primitive, tvb, offset, 1, ENC_BIG_ENDIAN);		offset++;		proto_tree_add_item(bfcp_tree, hf_bfcp_payload_length, tvb, offset, 2, ENC_BIG_ENDIAN);		offset+=2;		proto_tree_add_item(bfcp_tree, hf_bfcp_conference_id, tvb, offset, 4, ENC_BIG_ENDIAN);		offset+=4;		proto_tree_add_item(bfcp_tree, hf_bfcp_transaction_id, tvb, offset, 2, ENC_BIG_ENDIAN);		offset+=2;		proto_tree_add_item(bfcp_tree, hf_bfcp_user_id, tvb, offset, 2, ENC_BIG_ENDIAN);		offset+=2;		bfcp_payload_length = tvb_get_ntohs(tvb,							BFCP_OFFSET_PAYLOAD_LENGTH) * 4;		/*offset = */dissect_bfcp_attributes(tvb, pinfo, bfcp_tree, offset, bfcp_payload_length);	} /* if(tree) */}
开发者ID:bearxiong99,项目名称:wireshark,代码行数:62,


示例24: dissect_usb_i1d3_command

static 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,


示例25: dissect_usb_i1d3_response

static 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,


示例26: dissect_aarp

static voiddissect_aarp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {  guint16     ar_hrd;  guint16     ar_pro;  guint8      ar_hln;  guint8      ar_pln;  guint16     ar_op;  proto_tree  *aarp_tree;  proto_item  *ti;  const gchar *op_str;  int         sha_offset, spa_offset, tha_offset, tpa_offset;  const gchar *sha_str, *spa_str, /* *tha_str, */ *tpa_str;  col_set_str(pinfo->cinfo, COL_PROTOCOL, "AARP");  col_clear(pinfo->cinfo, COL_INFO);  ar_hrd = tvb_get_ntohs(tvb, AR_HRD);  ar_pro = tvb_get_ntohs(tvb, AR_PRO);  ar_hln = tvb_get_guint8(tvb, AR_HLN);  ar_pln = tvb_get_guint8(tvb, AR_PLN);  ar_op  = tvb_get_ntohs(tvb, AR_OP);  /* Get the offsets of the addresses. */  sha_offset = MIN_AARP_HEADER_SIZE;  spa_offset = sha_offset + ar_hln;  tha_offset = spa_offset + ar_pln;  tpa_offset = tha_offset + ar_hln;  /* Extract the addresses.  */  sha_str = tvb_aarphrdaddr_to_str(tvb, sha_offset, ar_hln, ar_hrd);  spa_str = tvb_aarpproaddr_to_str(tvb, spa_offset, ar_pln, ar_pro);#if 0  /* TODO: tha_str is currently not shown nor parsed */  tha_str = tvb_aarphrdaddr_to_str(tvb, tha_offset, ar_hln, ar_hrd);#endif  tpa_str = tvb_aarpproaddr_to_str(tvb, tpa_offset, ar_pln, ar_pro);  switch (ar_op) {    case AARP_REQUEST:    case AARP_REQUEST_SWAPPED:      col_add_fstr(pinfo->cinfo, COL_INFO, "Who has %s?  Tell %s", tpa_str, spa_str);      break;    case AARP_REPLY:    case AARP_REPLY_SWAPPED:      col_add_fstr(pinfo->cinfo, COL_INFO, "%s is at %s", spa_str, sha_str);      break;    case AARP_PROBE:    case AARP_PROBE_SWAPPED:      col_add_fstr(pinfo->cinfo, COL_INFO, "Is there a %s", tpa_str);      break;    default:      col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown AARP opcode 0x%04x", ar_op);      break;  }  if (tree) {    if ((op_str = try_val_to_str(ar_op, op_vals)))      ti = proto_tree_add_protocol_format(tree, proto_aarp, tvb, 0,				      MIN_AARP_HEADER_SIZE + 2*ar_hln +				      2*ar_pln, "AppleTalk Address Resolution Protocol (%s)", op_str);    else      ti = proto_tree_add_protocol_format(tree, proto_aarp, tvb, 0,				      MIN_AARP_HEADER_SIZE + 2*ar_hln +				      2*ar_pln,				      "AppleTalk Address Resolution Protocol (opcode 0x%04x)", ar_op);    aarp_tree = proto_item_add_subtree(ti, ett_aarp);    proto_tree_add_uint(aarp_tree, hf_aarp_hard_type, tvb, AR_HRD, 2,			       ar_hrd);    proto_tree_add_uint(aarp_tree, hf_aarp_proto_type, tvb, AR_PRO, 2,			       ar_pro);    proto_tree_add_uint(aarp_tree, hf_aarp_hard_size, tvb, AR_HLN, 1,			       ar_hln);    proto_tree_add_uint(aarp_tree, hf_aarp_proto_size, tvb, AR_PLN, 1,			       ar_pln);    proto_tree_add_uint(aarp_tree, hf_aarp_opcode, tvb, AR_OP, 2,			       ar_op);    if (ar_hln != 0) {      proto_tree_add_item(aarp_tree,	AARP_HW_IS_ETHER(ar_hrd, ar_hln) ? hf_aarp_src_hw_mac : hf_aarp_src_hw,	tvb, sha_offset, ar_hln, ENC_NA);    }    if (ar_pln != 0) {      if (AARP_PRO_IS_ATALK(ar_pro, ar_pln)) {        proto_tree_add_bytes_format_value(aarp_tree, hf_aarp_src_proto_id, tvb,					  spa_offset, ar_pln, NULL,					  "%s", spa_str);      } else {        proto_tree_add_bytes_format_value(aarp_tree, hf_aarp_src_proto, tvb,					  spa_offset, ar_pln, NULL,					  "%s", spa_str);      }    }    if (ar_hln != 0) {      proto_tree_add_item(aarp_tree,	AARP_HW_IS_ETHER(ar_hrd, ar_hln) ? hf_aarp_dst_hw_mac : hf_aarp_dst_hw,	tvb, tha_offset, ar_hln, ENC_NA);    }//.........这里部分代码省略.........
开发者ID:Biamp-Systems,项目名称:wireshark,代码行数:101,



注:本文中的try_val_to_str函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ trylock函数代码示例
C++ try_return函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。