Ejemplo n.º 1
0
/* Parses a ts2 player list (TS2T_PLAYERLIST) and adds it to the tree */
static void ts2_parse_playerlist(tvbuff_t *tvb, proto_tree *ts2_tree)
{
    gint32 offset;
    gint32 number_of_players;
    gint32 x;
    offset=0;
    x=0;
    proto_tree_add_item(ts2_tree, hf_ts2_number_of_players, tvb, offset, 4, ENC_LITTLE_ENDIAN);
    number_of_players = tvb_get_letohl(tvb, 0);
    offset+=4;
    while(offset<tvb_length_remaining(tvb, 0) && x<number_of_players)
    {
        proto_tree_add_item(ts2_tree, hf_ts2_player_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
        offset+=4;
        proto_tree_add_item(ts2_tree, hf_ts2_channel_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
        offset+=4;
        proto_tree_add_item(ts2_tree, hf_ts2_unknown, tvb, offset, 4, ENC_NA);
        offset+=4;
        proto_tree_add_item(ts2_tree, hf_ts2_player_status_flags, tvb, offset, 2, ENC_LITTLE_ENDIAN);
        ts2_add_statusflags(tvb, ts2_tree, offset);
        offset+=2;
        proto_tree_add_item(ts2_tree, hf_ts2_nick, tvb, offset, 1, ENC_ASCII|ENC_NA);
        offset+=30;
        x++;
    }
    proto_tree_add_item(ts2_tree, hf_ts2_emptyspace, tvb, offset, tvb_length_remaining(tvb, 0), ENC_NA);
}
Ejemplo n.º 2
0
guint32 getExtensionObjectType(tvbuff_t *tvb, gint *pOffset)
{
    gint    iOffset = *pOffset;
    guint8  EncodingMask;
    guint32 Numeric = 0;

    EncodingMask = tvb_get_guint8(tvb, iOffset);
    iOffset++;

    switch(EncodingMask)
    {
    case 0x00: /* two byte node id */
        Numeric = tvb_get_guint8(tvb, iOffset);
        /*iOffset+=1;*/
        break;
    case 0x01: /* four byte node id */
        iOffset+=1;
        Numeric = tvb_get_letohs(tvb, iOffset);
        break;
    case 0x02: /* numeric, that does not fit into four bytes */
        iOffset+=4;
        Numeric = tvb_get_letohl(tvb, iOffset);
        break;
    case 0x03: /* string */
    case 0x04: /* uri */
    case 0x05: /* guid */
    case 0x06: /* byte string */
        /* NOT USED */
        break;
    };

    return Numeric;
}
Ejemplo n.º 3
0
/*
 *  get a Lilliputian signed 64 bit integer from a tvb
 */
WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
    /* Get a Little Endian signed 64 bit integer from a `TvbRange`, as an `Int64` object.
       The range must be 1, 2, 4 or 8 octets long. */
    TvbRange tvbr = checkTvbRange(L,1);
    if (!(tvbr && tvbr->tvb)) return 0;
    if (tvbr->tvb->expired) {
        luaL_error(L,"expired tvb");
        return 0;
    }

    switch (tvbr->len) {
        case 1:
            pushInt64(L,(gint8)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
            return 1;
        case 2:
            pushInt64(L,(gint16)tvb_get_letohs(tvbr->tvb->ws_tvb,tvbr->offset));
            return 1;
        case 4:
            pushInt64(L,(gint32)tvb_get_letohl(tvbr->tvb->ws_tvb,tvbr->offset));
            return 1;
        case 8:
            pushInt64(L,(gint64)tvb_get_letoh64(tvbr->tvb->ws_tvb,tvbr->offset));
            WSLUA_RETURN(1); /* The `Int64` object. */
        default:
            luaL_error(L,"TvbRange:le_int64() does not handle %d byte integers",tvbr->len);
            return 0;
    }
}
Ejemplo n.º 4
0
/** General parsing function for arrays of enums.
 * All arrays have one 4 byte signed integer length information,
 * followed by n data elements.
 */
void parseArrayEnum(proto_tree *tree, tvbuff_t *tvb, gint *pOffset, fctEnumParser pParserFunction)
{
    static const char szFieldName[] = "Array of Enum Type";
    proto_item *ti = proto_tree_add_text(tree, tvb, *pOffset, -1, "%s", szFieldName);
    proto_tree *subtree = proto_item_add_subtree(ti, ett_opcua_array);
    int i;
    gint32 iLen;

    /* read array length */
    iLen = tvb_get_letohl(tvb, *pOffset);
    proto_tree_add_item(subtree, hf_opcua_ArraySize, tvb, *pOffset, 4, ENC_LITTLE_ENDIAN);

    if (iLen > MAX_ARRAY_LEN)
    {
        proto_item *pi;
        pi = proto_tree_add_text(tree, tvb, *pOffset, 4, "Array length %d too large to process", iLen);
        PROTO_ITEM_SET_GENERATED(pi);
        return;
    }

    *pOffset += 4;
    for (i=0; i<iLen; i++)
    {
        (*pParserFunction)(subtree, tvb, pOffset);
    }
    proto_item_set_end(ti, tvb, *pOffset);
}
Ejemplo n.º 5
0
/** General parsing function for arrays of complex types.
 * All arrays have one 4 byte signed integer length information,
 * followed by n data elements.
 */
void parseArrayComplex(proto_tree *tree, tvbuff_t *tvb, gint *pOffset, const char *szFieldName, fctComplexTypeParser pParserFunction)
{
    proto_item *ti = proto_tree_add_text(tree, tvb, *pOffset, -1, "Array of %s", szFieldName);
    proto_tree *subtree = proto_item_add_subtree(ti, ett_opcua_array);
    int i;
    gint32 iLen;

    /* read array length */
    iLen = tvb_get_letohl(tvb, *pOffset);
    proto_tree_add_item(subtree, hf_opcua_ArraySize, tvb, *pOffset, 4, ENC_LITTLE_ENDIAN);

    if (iLen > MAX_ARRAY_LEN)
    {
        proto_item *pi;
        pi = proto_tree_add_text(tree, tvb, *pOffset, 4, "Array length %d too large to process", iLen);
        PROTO_ITEM_SET_GENERATED(pi);
        return;
    }

    *pOffset += 4;
    for (i=0; i<iLen; i++)
    {
        char szNum[20];
        g_snprintf(szNum, 20, "[%i]", i);
        (*pParserFunction)(subtree, tvb, pOffset, szNum);
    }
    proto_item_set_end(ti, tvb, *pOffset);
}
Ejemplo n.º 6
0
static void
dissect_election_criterion(tvbuff_t *tvb, proto_tree *parent_tree, int offset)
{
	proto_tree *tree = NULL;
	proto_item *item = NULL;
	guint32 criterion;

	criterion = tvb_get_letohl(tvb, offset);

	if (parent_tree) {
		item = proto_tree_add_uint(parent_tree, hf_election_criteria, tvb, offset, 4, criterion);
	      	tree = proto_item_add_subtree(item, ett_browse_election_criteria);
	}

	/* election desire */
	dissect_election_criterion_desire(tvb, tree, offset);
	offset += 1;

	/* browser protocol major version */
	proto_tree_add_item(tree, hf_proto_major, tvb, offset, 1, ENC_LITTLE_ENDIAN);
	offset += 1;

	/* browser protocol minor version */
	proto_tree_add_item(tree, hf_proto_minor, tvb, offset, 1, ENC_LITTLE_ENDIAN);
	offset += 1;

	/* election os */
	dissect_election_criterion_os(tvb, tree, offset);

}
Ejemplo n.º 7
0
void parseByteString(proto_tree *tree, tvbuff_t *tvb, gint *pOffset, int hfIndex)
{
    char *szValue;
    int iOffset = *pOffset;
    gint32 iLen = tvb_get_letohl(tvb, iOffset);
    iOffset += 4;

    if (iLen == -1)
    {
        proto_item *item = proto_tree_add_item(tree, hfIndex, tvb, *pOffset, 0, ENC_NA);
        proto_item_append_text(item, "[OpcUa Null ByteString]");
        proto_item_set_end(item, tvb, *pOffset + 4);
    }
    else if (iLen == 0)
    {
        proto_item *item = proto_tree_add_item(tree, hfIndex, tvb, *pOffset, 0, ENC_NA);
        proto_item_append_text(item, "[OpcUa Empty ByteString]");
        proto_item_set_end(item, tvb, *pOffset + 4);
    }
    else if (iLen > 0)
    {
        proto_tree_add_item(tree, hfIndex, tvb, iOffset, iLen, ENC_NA);
        iOffset += iLen; /* eat the whole bytestring */
    }
    else
    {
        proto_item *item = proto_tree_add_item(tree, hfIndex, tvb, *pOffset, 0, ENC_NA);
        szValue = wmem_strdup_printf(wmem_packet_scope(), "[Invalid ByteString] Invalid length: %d", iLen);
        proto_item_append_text(item, "%s", szValue);
        proto_item_set_end(item, tvb, *pOffset + 4);
    }

    *pOffset = iOffset;
}
Ejemplo n.º 8
0
static int
dissect_mongo_reply(tvbuff_t *tvb, guint offset, proto_tree *tree)
{
	proto_item *ti;
	proto_tree *flags_tree;
	gint  i, number_returned;

	ti = proto_tree_add_item(tree, hf_mongo_reply_flags, tvb, offset, 4, ENC_NA);
	flags_tree = proto_item_add_subtree(ti, ett_mongo_flags);
	proto_tree_add_item(flags_tree, hf_mongo_reply_flags_cursornotfound, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	proto_tree_add_item(flags_tree, hf_mongo_reply_flags_queryfailure, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	proto_tree_add_item(flags_tree, hf_mongo_reply_flags_sharedconfigstale, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	proto_tree_add_item(flags_tree, hf_mongo_reply_flags_awaitcapable, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	offset += 4;

	proto_tree_add_item(tree, hf_mongo_cursor_id, tvb, offset, 8, ENC_LITTLE_ENDIAN);
	offset += 8;

	proto_tree_add_item(tree, hf_mongo_starting_from, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	offset += 4;

	proto_tree_add_item(tree, hf_mongo_number_returned, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	number_returned = tvb_get_letohl(tvb, offset);
	offset += 4;

	for (i=1; i <= number_returned; i++)
	{
		offset += dissect_bson_document(tvb, offset, tree, hf_mongo_documents);
	}
	return offset;
}
Ejemplo n.º 9
0
/* this tree keeps track of CONTROL request/responses */
static emem_tree_t *ctdb_controls=NULL;
typedef struct _ctdb_control_t {
	guint32 opcode;
	guint32 request_in;
	guint32 response_in;
	nstime_t req_time;
} ctdb_control_t;

#define CTDB_REQ_CALL			0
#define CTDB_REPLY_CALL			1
#define CTDB_REQ_DMASTER		2
#define CTDB_REPLY_DMASTER		3
#define CTDB_REPLY_ERROR		4
#define CTDB_REQ_MESSAGE		5
#define CTDB_REQ_CONTROL		7
#define CTDB_REPLY_CONTROL		8
#define CTDB_REQ_KEEPALIVE		9
static const value_string ctdb_opcodes[] = {
	{CTDB_REQ_CALL,			"REQ_CALL"},
	{CTDB_REPLY_CALL,		"REPLY_CALL"},
	{CTDB_REQ_DMASTER,		"REQ_DMASTER"},
	{CTDB_REPLY_DMASTER,		"REPLY_DMASTER"},
	{CTDB_REPLY_ERROR,		"REPLY_ERROR"},
	{CTDB_REQ_MESSAGE,		"REQ_MESSAGE"},
	{CTDB_REQ_CONTROL,		"REQ_CONTROL"},
	{CTDB_REPLY_CONTROL,		"REPLY_CONTROL"},
	{CTDB_REQ_KEEPALIVE,		"REQ_KEEPALIVE"},
	{0,NULL}
};


#define CTDB_CONTROL_PROCESS_EXISTS		0
#define CTDB_CONTROL_STATISTICS			1
#define CTDB_CONTROL_CONFIG			2
#define CTDB_CONTROL_PING			3
#define CTDB_CONTROL_GETDBPATH			4
#define CTDB_CONTROL_GETVNNMAP			5
#define CTDB_CONTROL_SETVNNMAP			6
#define CTDB_CONTROL_GET_DEBUG			7
#define CTDB_CONTROL_SET_DEBUG			8
#define CTDB_CONTROL_GET_DBMAP			9
#define CTDB_CONTROL_GET_NODEMAP		10
#define CTDB_CONTROL_SET_DMASTER		11
#define CTDB_CONTROL_CLEAR_DB			12
#define CTDB_CONTROL_PULL_DB			13
#define CTDB_CONTROL_PUSH_DB			14
#define CTDB_CONTROL_GET_RECMODE		15
#define CTDB_CONTROL_SET_RECMODE		16
#define CTDB_CONTROL_STATISTICS_RESET		17
#define CTDB_CONTROL_DB_ATTACH			18
#define CTDB_CONTROL_SET_CALL			19
#define CTDB_CONTROL_TRAVERSE_START		20
#define CTDB_CONTROL_TRAVERSE_ALL		21
#define CTDB_CONTROL_TRAVERSE_DATA		22
#define CTDB_CONTROL_REGISTER_SRVID		23
#define CTDB_CONTROL_DEREGISTER_SRVID		24
#define CTDB_CONTROL_GET_DBNAME			25
#define CTDB_CONTROL_ENABLE_SEQNUM		26
#define CTDB_CONTROL_UPDATE_SEQNUM		27
#define CTDB_CONTROL_SET_SEQNUM_FREQUENCY	28
#define CTDB_CONTROL_DUMP_MEMORY		29
#define CTDB_CONTROL_GET_PID			30
#define CTDB_CONTROL_GET_RECMASTER		31
#define CTDB_CONTROL_SET_RECMASTER		32
#define CTDB_CONTROL_FREEZE			33
#define CTDB_CONTROL_THAW			34
#define CTDB_CONTROL_GET_VNN			35
#define CTDB_CONTROL_SHUTDOWN			36
#define CTDB_CONTROL_GET_MONMODE		37
#define CTDB_CONTROL_SET_MONMODE		38
#define CTDB_CONTROL_MAX_RSN			39
#define CTDB_CONTROL_SET_RSN_NONEMPTY		40
#define CTDB_CONTROL_DELETE_LOW_RSN		41
#define CTDB_CONTROL_TAKEOVER_IP		42
#define CTDB_CONTROL_RELEASE_IP			43
#define CTDB_CONTROL_TCP_CLIENT			44
#define CTDB_CONTROL_TCP_ADD			45
#define CTDB_CONTROL_TCP_REMOVE			46
#define CTDB_CONTROL_STARTUP			47
#define CTDB_CONTROL_SET_TUNABLE		48
#define CTDB_CONTROL_GET_TUNABLE		49
#define CTDB_CONTROL_LIST_TUNABLES		50
#define CTDB_CONTROL_GET_PUBLIC_IPS		51
#define CTDB_CONTROL_MODIFY_FLAGS		52
#define CTDB_CONTROL_GET_ALL_TUNABLES		53
#define CTDB_CONTROL_KILL_TCP			54
#define CTDB_CONTROL_GET_TCP_TICKLE_LIST	55
#define CTDB_CONTROL_SET_TCP_TICKLE_LIST	56
#define CTDB_CONTROL_REGISTER_SERVER_ID		57
#define CTDB_CONTROL_UNREGISTER_SERVER_ID	58
#define CTDB_CONTROL_CHECK_SERVER_ID		59
#define CTDB_CONTROL_GET_SERVER_ID_LIST		60
#define CTDB_CONTROL_DB_ATTACH_PERSISTENT  	61
#define CTDB_CONTROL_PERSISTENT_STORE      	62
#define CTDB_CONTROL_UPDATE_RECORD         	63

static const value_string ctrl_opcode_vals[] = {
	{CTDB_CONTROL_PROCESS_EXISTS,	"PROCESS_EXISTS"},
	{CTDB_CONTROL_STATISTICS,	"STATISTICS"},
	{CTDB_CONTROL_CONFIG,		"CONFIG"},
	{CTDB_CONTROL_PING,		"PING"},
	{CTDB_CONTROL_GETDBPATH,	"GETDBPATH"},
	{CTDB_CONTROL_GETVNNMAP,	"GETVNNMAP"},
	{CTDB_CONTROL_SETVNNMAP,	"SETVNNMAP"},
	{CTDB_CONTROL_GET_DEBUG,	"GET_DEBUG"},
	{CTDB_CONTROL_SET_DEBUG,	"SET_DEBUG"},
	{CTDB_CONTROL_GET_DBMAP,	"GET_DBMAP"},
	{CTDB_CONTROL_GET_NODEMAP,	"GET_NODEMAP"},
	{CTDB_CONTROL_SET_DMASTER,	"SET_DMASTER"},
	{CTDB_CONTROL_CLEAR_DB,		"CLEAR_DB"},
	{CTDB_CONTROL_PULL_DB,		"PULL_DB"},
	{CTDB_CONTROL_PUSH_DB,		"PUSH_DB"},
	{CTDB_CONTROL_GET_RECMODE,	"GET_RECMODE"},
	{CTDB_CONTROL_SET_RECMODE,	"SET_RECMODE"},
	{CTDB_CONTROL_STATISTICS_RESET,	"STATISTICS_RESET"},
	{CTDB_CONTROL_DB_ATTACH,	"DB_ATTACH"},
	{CTDB_CONTROL_SET_CALL,		"SET_CALL"},
	{CTDB_CONTROL_TRAVERSE_START,	"TRAVERSE_START"},
	{CTDB_CONTROL_TRAVERSE_ALL,	"TRAVERSE_ALL"},
	{CTDB_CONTROL_TRAVERSE_DATA,	"TRAVERSE_DATA"},
	{CTDB_CONTROL_REGISTER_SRVID,	"REGISTER_SRVID"},
	{CTDB_CONTROL_DEREGISTER_SRVID,	"DEREGISTER_SRVID"},
	{CTDB_CONTROL_GET_DBNAME,	"GET_DBNAME"},
	{CTDB_CONTROL_ENABLE_SEQNUM,	"ENABLE_SEQNUM"},
	{CTDB_CONTROL_UPDATE_SEQNUM,	"UPDATE_SEQNUM"},
	{CTDB_CONTROL_SET_SEQNUM_FREQUENCY,	"SET_SEQNUM_FREQUENCY"},
	{CTDB_CONTROL_DUMP_MEMORY,	"DUMP_MEMORY"},
	{CTDB_CONTROL_GET_PID,		"GET_PID"},
	{CTDB_CONTROL_GET_RECMASTER,	"GET_RECMASTER"},
	{CTDB_CONTROL_SET_RECMASTER,	"SET_RECMASTER"},
	{CTDB_CONTROL_FREEZE,		"FREEZE"},
	{CTDB_CONTROL_THAW,		"THAW"},
	{CTDB_CONTROL_GET_VNN,		"GET_VNN"},
	{CTDB_CONTROL_SHUTDOWN,		"SHUTDOWN"},
	{CTDB_CONTROL_GET_MONMODE,	"GET_MONMODE"},
	{CTDB_CONTROL_SET_MONMODE,	"SET_MONMODE"},
	{CTDB_CONTROL_MAX_RSN,		"MAX_RSN"},
	{CTDB_CONTROL_SET_RSN_NONEMPTY,	"SET_RSN_NONEMPTY"},
	{CTDB_CONTROL_DELETE_LOW_RSN,	"DELETE_LOW_RSN"},
	{CTDB_CONTROL_TAKEOVER_IP,	"TAKEOVER_IP"},
	{CTDB_CONTROL_RELEASE_IP,	"RELEASE_IP"},
	{CTDB_CONTROL_TCP_CLIENT,	"TCP_CLIENT"},
	{CTDB_CONTROL_TCP_ADD,		"TCP_ADD"},
	{CTDB_CONTROL_TCP_REMOVE,	"TCP_REMOVE"},
	{CTDB_CONTROL_STARTUP,		"STARTUP"},
	{CTDB_CONTROL_SET_TUNABLE,	"SET_TUNABLE"},
	{CTDB_CONTROL_GET_TUNABLE,	"GET_TUNABLE"},
	{CTDB_CONTROL_LIST_TUNABLES,	"LIST_TUNABLES"},
	{CTDB_CONTROL_GET_PUBLIC_IPS,	"GET_PUBLIC_IPS"},
	{CTDB_CONTROL_MODIFY_FLAGS,	"MODIFY_FLAGS"},
	{CTDB_CONTROL_GET_ALL_TUNABLES,	"GET_ALL_TUNABLES"},
	{CTDB_CONTROL_KILL_TCP,		"KILL_TCP"},
	{CTDB_CONTROL_GET_TCP_TICKLE_LIST,	"GET_TCP_TICKLE_LIST"},
	{CTDB_CONTROL_SET_TCP_TICKLE_LIST,	"SET_TCP_TICKLE_LIST"},
	{CTDB_CONTROL_REGISTER_SERVER_ID,	"REGISTER_SERVER_ID"},
	{CTDB_CONTROL_UNREGISTER_SERVER_ID,	"UNREGISTER_SERVER_ID"},
	{CTDB_CONTROL_CHECK_SERVER_ID,		"CHECK_SERVER_ID"},
	{CTDB_CONTROL_GET_SERVER_ID_LIST,	"GET_SERVER_ID_LIST"},
	{CTDB_CONTROL_DB_ATTACH_PERSISTENT,	"DB_ATTACH_PERSISTENT"},
	{CTDB_CONTROL_PERSISTENT_STORE,		"PERSISTENT_STORE"},
	{CTDB_CONTROL_UPDATE_RECORD,		"UPDATE_RECORD"},
	{0, NULL}
};



static int dissect_control_get_recmaster_reply(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint32 status, int endianess _U_)
{
	proto_tree_add_uint(tree, hf_ctdb_recmaster, tvb, 0, 0, status);

	col_append_fstr(pinfo->cinfo, COL_INFO, " RecMaster:%d", status);

	return offset;
}

static const value_string recmode_vals[] = {
	{0,"NORMAL"},
	{1,"RECOVERY ACTIVE"},
	{0,NULL}
};

static int dissect_control_get_recmode_reply(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint32 status, int endianess _U_)
{
	proto_tree_add_uint(tree, hf_ctdb_recmode, tvb, 0, 0, status);

	col_append_fstr(pinfo->cinfo, COL_INFO, " RecMode:%s",
		val_to_str(status, recmode_vals, "Unknown:%d"));

	return offset;
}

#define CTDB_MAX_NODES 500 /* Arbitrary. */
static int dissect_control_get_nodemap_reply(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, guint32 status _U_, int endianess)
{
	guint32 num_nodes;
	proto_item *item;

	/* num nodes */
	item = proto_tree_add_item(tree, hf_ctdb_num_nodes, tvb, offset, 4, endianess);
	if(endianess){
		num_nodes=tvb_get_letohl(tvb, offset);
	} else {
		num_nodes=tvb_get_ntohl(tvb, offset);
	}
	offset+=4;

	if (num_nodes > CTDB_MAX_NODES) {
		expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN, "Too many nodes (%u). Stopping dissection.", num_nodes);
		THROW(ReportedBoundsError);
	}

	while(num_nodes--){
		/* vnn */
		proto_tree_add_item(tree, hf_ctdb_vnn, tvb, offset, 4, endianess);
		offset+=4;

		/* node flags */
		proto_tree_add_item(tree, hf_ctdb_node_flags, tvb, offset, 4, endianess);
		offset+=4;

		/* here comes a sockaddr_in but we only store ipv4 addresses in it */
		proto_tree_add_item(tree, hf_ctdb_node_ip, tvb, offset+4, 4, ENC_BIG_ENDIAN);
		offset+=16;
	}

	return offset;
}
Ejemplo n.º 10
0
static int
dissect_dtpt_wstring(tvbuff_t *tvb, guint offset, proto_tree *tree, int hfindex)
{
	guint32	wstring_length;
	guint32	wstring_size;
	char	*wstring_data = NULL;
	guint32	wstring_padding = 0;

	wstring_length = tvb_get_letohl(tvb, offset);
	wstring_data = tvb_get_string_enc(wmem_packet_scope(), tvb, offset+4, wstring_length, ENC_UTF_16|ENC_LITTLE_ENDIAN);
	wstring_size = wstring_length;
	if (wstring_size%4) {
		wstring_padding = (4-wstring_size%4);
		wstring_size += wstring_padding;
	}
	if (tree) {
		proto_item	*dtpt_wstring_item;
		proto_tree	*dtpt_wstring_tree;
		dtpt_wstring_item = proto_tree_add_string(tree, hfindex,
			tvb, offset+0, 4+wstring_size, wstring_data);
		dtpt_wstring_tree = proto_item_add_subtree(dtpt_wstring_item, ett_dtpt_wstring);
		if (dtpt_wstring_tree) {
			proto_tree_add_uint(dtpt_wstring_tree, hf_dtpt_wstring_length,
				tvb, offset+0, 4, wstring_length);
			if (wstring_length)
				proto_tree_add_string(dtpt_wstring_tree, hf_dtpt_wstring_data,
					tvb, offset+4, wstring_length, wstring_data);
			if (wstring_padding)
				proto_tree_add_item(dtpt_wstring_tree, hf_dtpt_padding, tvb,
					offset+4+wstring_length,wstring_padding, ENC_NA);
		}
	}
	offset += 4+wstring_size;
	return offset;
}
static void
dissect_nsimulator(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  guint32 signature;
  tvbuff_t *payload_tvb;
  proto_item *ns_tree = NULL;
  proto_item *ns_subtree = NULL;

  if (tvb_captured_length(tvb) > 4) {
    signature = tvb_get_letohl(tvb, 0);
    if ( signature == 0xFF77DE02 || signature == 0xFF77DE82 )
    {
      col_set_str(pinfo->cinfo, COL_PROTOCOL, "Network Simulator");
      if (tree)
      {
        ns_tree = proto_tree_add_item(tree, proto_nsimulator, tvb, 0, 4, ENC_NA);
        ns_subtree = proto_item_add_subtree(ns_tree, ett_nsimulator);
        proto_tree_add_item(ns_subtree, hf_nsimulator_dir, tvb, 0, sizeof(guint8),
          ENC_LITTLE_ENDIAN);
        proto_tree_add_item(ns_subtree, hf_nsimulator_sig, tvb, 1, 3 * sizeof(guint8),
          ENC_LITTLE_ENDIAN);
      }
      payload_tvb = tvb_new_subset(tvb, 4, -1, tvb_reported_length(tvb) - 4);
      TRY
      {
        call_dissector(wpan_handle, payload_tvb, pinfo, tree);
      }
      CATCH_ALL {
        show_exception(payload_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
      }
      ENDTRY;
    } else {
Ejemplo n.º 12
0
static int
dissect_account_control(tvbuff_t *tvb, proto_tree *tree, int offset)
{
	/* display the Allowable Account control bits */

	proto_item *ti = NULL;
	proto_tree *flags_tree = NULL;
	guint32 flags;

	flags = tvb_get_letohl(tvb, offset);

	if (tree) {
		ti = proto_tree_add_text(tree, tvb, offset, 4,
			"Account control  = 0x%04x", flags);

		flags_tree = proto_item_add_subtree(ti, ett_smb_account_flags);
	}

	proto_tree_add_boolean(flags_tree, hf_flags_autolock, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_expire, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_server_trust, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_workstation_trust, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_interdomain_trust, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_mns_user, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_normal_user, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_temp_dup_user, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_password_required, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_homedir_required, tvb, offset, 4, flags);
	proto_tree_add_boolean(flags_tree, hf_flags_enabled, tvb, offset, 4, flags);

	offset += 4;

	return offset;
}
Ejemplo n.º 13
0
/*
 *  get a Lilliputian unsigned integer from a tvb
 */
WSLUA_METHOD TvbRange_le_uint(lua_State* L) {
	/* Get a Little Endian unsigned integer from a TvbRange. The range must be 1, 2, 3 or 4 octets long. */
    TvbRange tvbr = checkTvbRange(L,1);
    if (!(tvbr && tvbr->tvb)) return 0;
    if (tvbr->tvb->expired) {
        luaL_error(L,"expired tvb");
        return 0;
    }

    switch (tvbr->len) {
        case 1:
            /* XXX unsigned anyway */
            lua_pushnumber(L,(lua_Number)(guint)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
            return 1;
        case 2:
            lua_pushnumber(L,tvb_get_letohs(tvbr->tvb->ws_tvb,tvbr->offset));
            return 1;
        case 3:
            lua_pushnumber(L,tvb_get_letoh24(tvbr->tvb->ws_tvb,tvbr->offset));
            return 1;
        case 4:
            lua_pushnumber(L,tvb_get_letohl(tvbr->tvb->ws_tvb,tvbr->offset));
            WSLUA_RETURN(1); /* The unsigned integer value */
        default:
            luaL_error(L,"TvbRange:le_uint() does not handle %d byte integers",tvbr->len);
            return 0;
    }
}
Ejemplo n.º 14
0
static int
dissect_yami_data(tvbuff_t *tvb, gboolean data, proto_tree *tree, int offset)
{
	const int orig_offset = offset;

	proto_tree *yami_data_tree;
	proto_item *ti;

	guint32 count;
	guint i;

	ti = proto_tree_add_item(tree, (data) ? hf_yami_message_data : hf_yami_message_hdr, tvb, offset, 0, ENC_NA);
	yami_data_tree = proto_item_add_subtree(ti, (data) ? ett_yami_msg_data : ett_yami_msg_hdr);

	count = tvb_get_letohl(tvb, offset);
	proto_tree_add_item(yami_data_tree, hf_yami_params_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);
	offset += 4;

	proto_item_append_text(ti, ", %u parameters: ", count);

	for (i = 0; i < count; i++) {
		offset = dissect_yami_parameter(tvb, yami_data_tree, offset, ti);
		/* smth went wrong */
		if (offset == -1)
			return -1;
	}

	proto_item_set_len(ti, offset - orig_offset);

	return offset;
}
Ejemplo n.º 15
0
/*
 * Check if a packet is in order and if it is set its fragmentation details into the passed pointers.
 * Returns TRUE if the packet is fragmented.
 * Must be run sequentially
 * */
static gboolean ts2_standard_find_fragments(tvbuff_t *tvb, guint32 *last_inorder_frame, guint32 *frag_size, guint32 *frag_num, gboolean *outoforder)
{
    guint32 frag_count;
    gboolean ret;
    frag_count=tvb_get_letohs(tvb, 18);
    ret=FALSE;
    *outoforder=FALSE;

    /* if last_inorder_frame is zero, then this is the first reliable packet */
    if(*last_inorder_frame==0)
    {
        *last_inorder_frame=tvb_get_letohl(tvb, 12);
        *frag_size=tvb_get_letohs(tvb, 18);
        *frag_num=0;
        if(*frag_size>0)
            ret=TRUE;
        else
            ret=FALSE;
    }
    /* This packet is in order */
    else if(*last_inorder_frame==tvb_get_letohl(tvb, 12)-1)
    {
        if(*frag_size>0)
        {
            *frag_num=*frag_size-frag_count;
            if(frag_count==0)
            {
                *frag_size=0;
            }
            ret=TRUE;
        }
        else
        {
            *frag_size=tvb_get_letohs(tvb, 18);
            *frag_num=*frag_size-frag_count;
            if(*frag_size>0)
                ret=TRUE;
            else
                ret=FALSE;
        }
        *last_inorder_frame=tvb_get_letohl(tvb, 12);
    }
    else /* out of order */
        *outoforder=TRUE;
    return ret;
}
static guint32
corosync_totemsrp_get_guint32(tvbuff_t* tvb, gint offset, const guint encoding)
{
  if (encoding == ENC_LITTLE_ENDIAN)
    return tvb_get_letohl(tvb, offset);

  return tvb_get_ntohl(tvb, offset);
}
static guint32
tvb_get_enctohl(tvbuff_t *tvb, int offset, guint encoding)
{
    if (encoding == ENC_BIG_ENDIAN)
        return tvb_get_ntohl(tvb, offset);
    else
        return tvb_get_letohl(tvb, offset);
}
Ejemplo n.º 18
0
/* dissect a bt dht values list from tvb, start at offset. it's like "l6:....6:....e" */
static int
dissect_bt_dht_values(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, char **result, char *label )
{
  proto_item *ti;
  proto_tree *sub_tree;
  proto_item *value_ti;
  proto_tree *value_tree;
  address     addr;

  guint       peer_index;
  guint       string_len_start;
  guint       string_len;
  guint16     port;

  ti = proto_tree_add_item( tree, hf_bt_dht_peers, tvb, offset, 0, ENC_NA );
  sub_tree = proto_item_add_subtree( ti, ett_bt_dht_peers);

  peer_index = 0;
  /* we has confirmed that the first byte is 'l' */
  offset += 1;

  /* dissect bt-dht values */
  while( tvb_get_guint8(tvb,offset)!='e' )
  {
    string_len_start = offset;
    while( tvb_get_guint8(tvb,offset) != ':' )
      offset += 1;

    string_len = atoi( tvb_get_ephemeral_string(tvb,string_len_start,offset-string_len_start) );
    /* skip the ':' */
    offset += 1;
    /* 4 bytes ip, 2 bytes port */
    for( ; string_len>=6; string_len-=6, offset+=6 )
    {
      peer_index += 1;
      SET_ADDRESS( &addr, AT_IPv4, 4, tvb_get_ptr( tvb, offset, 4) );
      port = tvb_get_letohl( tvb, offset+4 );

      value_ti = proto_tree_add_none_format( sub_tree, hf_bt_dht_peer, tvb, offset, 6,
          "%d\t%s:%u", peer_index, ep_address_to_str( &addr ), port );
      value_tree = proto_item_add_subtree( value_ti, ett_bt_dht_peers);

      proto_tree_add_item( value_tree, hf_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
      proto_tree_add_item( value_tree, hf_port, tvb, offset+4, 2, ENC_BIG_ENDIAN);
    }
    /* truncated data */
    if( string_len>0 )
    {
      proto_tree_add_item( tree, hf_truncated_data, tvb, offset, string_len, ENC_NA );
      offset += string_len;
    }
  }
  proto_item_set_text( ti, "%s: %d peers", label, peer_index );
  col_append_fstr( pinfo->cinfo, COL_INFO, "reply=%d peers  ", peer_index );
  *result = ep_strdup_printf("%d peers", peer_index);

  return offset;
}
Ejemplo n.º 19
0
static guint32 tvb_get_guint32_endian(tvbuff_t *a_tvb, gint a_iOffset, gboolean a_bLittleEndian)
{
	guint32 iResult;
	if (a_bLittleEndian)
		iResult = tvb_get_letohl(a_tvb, a_iOffset);
	else
		iResult =  tvb_get_ntohl(a_tvb, a_iOffset);
	return iResult;
}
Ejemplo n.º 20
0
static void
dissect_event_counter(tvbuff_t *tvb, proto_tree *tree)
{
	guint32 aa;
	aa 			= tvb_get_letohl(tvb, get_header_length());
	if (aa != adv_aa)
	{
		proto_tree_add_item(tree, hf_nordic_ble_event_counter, tvb, get_ec_index(), 2, ENC_LITTLE_ENDIAN);
	}
}
Ejemplo n.º 21
0
/* Calculates a CRC32 checksum from the tvb zeroing out four bytes at the offset and checks it with the given crc32 and adds the result to the tree
 * Returns true if the calculated CRC32 matches the passed CRC32.
 * */
static gboolean ts2_add_checked_crc32(proto_tree *tree, int hf_item, tvbuff_t *tvb, guint16 offset, guint32 icrc32 )
{
	guint8 *zero;
	guint32 ocrc32;
	zero = ep_alloc0(4);
	ocrc32 = crc32_ccitt_tvb(tvb, offset);
	ocrc32 = crc32_ccitt_seed(zero, 4, 0xffffffff-ocrc32);
	ocrc32 = crc32_ccitt_tvb_offset_seed(tvb, offset+4, tvb_reported_length_remaining(tvb, offset+4), 0xffffffff-ocrc32);
	if(icrc32==ocrc32)
	{
		proto_tree_add_uint_format(tree, hf_item, tvb, offset, 4, tvb_get_letohl(tvb, 16), "crc32: 0x%04x [correct]", tvb_get_letohl(tvb, offset));
		return TRUE;
	}
	else
	{
		proto_tree_add_uint_format(tree, hf_item, tvb, offset, 4, tvb_get_letohl(tvb,16), "crc32: 0x%04x [incorrect, should be 0x%04x]", tvb_get_letohl(tvb, offset),ocrc32);
		return FALSE;
	}
}
Ejemplo n.º 22
0
static gboolean is_rrac_command_stream(tvbuff_t *tvb, int offset)
{
  guint16 maybe_command = tvb_get_letohs(tvb, offset);

  if (maybe_command >= 0x65 && maybe_command <= 0x70)
    return TRUE;
  
#if 0
  if (tvb_get_letohl(tvb, offset) == 0xffffffff || tvb_length_remaining(tvb, offset) >= 14) {
    guint32 test_value = tvb_get_letohl(tvb, offset + 4);

    if (test_value >= 10000 && test_value <= 10050) {
      return TRUE;
    }
  }
#endif

  return FALSE;
}
Ejemplo n.º 23
0
static int
dissect_bt_dht_nodes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint offset, char **result, char *label )
{
  proto_item *ti;
  proto_tree *sub_tree;
  proto_item *node_ti;
  proto_tree *node_tree;

  guint       node_index;
  guint       string_len_start;
  guint       string_len;
  address     addr;
  guint16     port;
  guint8     *id;

  ti = proto_tree_add_item( tree, hf_bt_dht_nodes, tvb, offset, 0, ENC_NA );
  sub_tree = proto_item_add_subtree( ti, ett_bt_dht_nodes);
  node_index = 0;

  string_len_start = offset;
  while( tvb_get_guint8(tvb,offset) != ':' )
    offset += 1;

  string_len = atoi( tvb_get_ephemeral_string(tvb,string_len_start,offset-string_len_start) );
  /* skip the ':' */
  offset += 1;

  /* 20 bytes id, 4 bytes ip, 2 bytes port */
  for( ; string_len>=26; string_len-=26, offset+=26 )
  {
    node_index += 1;

    id = tvb_bytes_to_str(tvb, offset, 20 );
    SET_ADDRESS( &addr, AT_IPv4, 4, tvb_get_ptr( tvb, offset, 4) );
    port = tvb_get_letohl( tvb, offset+24 );

    node_ti = proto_tree_add_none_format( sub_tree, hf_bt_dht_node, tvb, offset, 26,
        "%d\t%s %s:%u", node_index, id, ep_address_to_str( &addr ), port );
    node_tree = proto_item_add_subtree( node_ti, ett_bt_dht_peers);

    proto_tree_add_item( node_tree, hf_bt_dht_id, tvb, offset, 20, ENC_NA);
    proto_tree_add_item( node_tree, hf_ip, tvb, offset+20, 4, ENC_BIG_ENDIAN);
    proto_tree_add_item( node_tree, hf_port, tvb, offset+24, 2, ENC_BIG_ENDIAN);
  }
  if( string_len>0 )
  {
    proto_tree_add_item( tree, hf_truncated_data, tvb, offset, string_len, ENC_NA );
    offset += string_len;
  }
  proto_item_set_text( ti, "%s: %d nodes", label, node_index );
  col_append_fstr( pinfo->cinfo, COL_INFO, "reply=%d nodes  ", node_index );
  *result = ep_strdup_printf("%d", node_index);

  return offset;
}
Ejemplo n.º 24
0
static void
dissect_aoe_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
  guint8 flags, cmd;
  guint32 tag;
  proto_item *flags_item=NULL;
  proto_tree *flags_tree=NULL;

  /* read and dissect the flags */
  flags=tvb_get_guint8(tvb, 0)&0x0f;
  if(tree){
    flags_item=proto_tree_add_text(tree, tvb, 0, 1, "Flags:");
    flags_tree=proto_item_add_subtree(flags_item, ett_aoe_flags);
  }
  proto_tree_add_item(flags_tree, hf_aoe_flags_response, tvb, 0, 1, ENC_BIG_ENDIAN);
  proto_tree_add_item(flags_tree, hf_aoe_flags_error, tvb, 0, 1, ENC_BIG_ENDIAN);
  if(flags_item){
    proto_item_append_text(flags_item,(flags&AOE_FLAGS_RESPONSE)?" Response":" Request");
    if(flags&AOE_FLAGS_ERROR){
      proto_item_append_text(flags_item, " Error");
    }
  }


  /* error */
  if(flags&AOE_FLAGS_ERROR){
    proto_tree_add_item(tree, hf_aoe_error, tvb, 1, 1, ENC_BIG_ENDIAN);
	col_append_fstr(pinfo->cinfo, COL_INFO, "Error:%s ", val_to_str(tvb_get_guint8(tvb, 1), error_vals, "Unknown error<%d>"));
  }

  /* major/minor address */
  proto_tree_add_item(tree, hf_aoe_major, tvb, 2, 2, ENC_BIG_ENDIAN);
  proto_tree_add_item(tree, hf_aoe_minor, tvb, 4, 1, ENC_BIG_ENDIAN);

  /* command */
  cmd=tvb_get_guint8(tvb, 5);
  proto_tree_add_item(tree, hf_aoe_cmd, tvb, 5, 1, ENC_BIG_ENDIAN);
  col_append_fstr(pinfo->cinfo, COL_INFO, "%s %s", val_to_str(cmd, cmd_vals, "Unknown command<%d>"), (flags&AOE_FLAGS_RESPONSE)?"Response":"Request");


  /* tag */
  tag=tvb_get_letohl(tvb, 6);
  proto_tree_add_item(tree, hf_aoe_tag, tvb, 6, 4, ENC_BIG_ENDIAN);


  switch(cmd){
  case AOE_CMD_ISSUE_ATA_COMMAND:
    dissect_ata_pdu(pinfo, tree, tvb, 10, flags&AOE_FLAGS_RESPONSE, tag);
    break;
  case AOE_CMD_QUERY_CONFIG_INFO:
    break;
  }

}
Ejemplo n.º 25
0
static gint
dissect_ros_message_header(tvbuff_t *tvb, proto_tree *root_tree, packet_info *pinfo, gint offset)
{
	proto_item *ti;
	proto_tree *sub_tree;

	gint consumed_len = 0;
	guint32 frame_id_len;
	guint32 seq;
	guint header_len;


	frame_id_len = tvb_get_letohl(tvb, offset + consumed_len + SIZE_OF_LENGTH_FIELD + SIZE_OF_LENGTH_STAMP);
	header_len = SIZE_OF_LENGTH_FIELD + SIZE_OF_LENGTH_STAMP + SIZE_OF_LENGTH_FIELD + frame_id_len;

	/** Header */
	ti = proto_tree_add_item(root_tree, hf_tcpros_message_header, tvb, offset + consumed_len, header_len, ENC_NA);
	sub_tree = proto_item_add_subtree(ti, ett_tcpros);

	/** Sequence number */
	proto_tree_add_item(sub_tree, hf_tcpros_message_header_seq, tvb, offset + consumed_len, SIZE_OF_LENGTH_FIELD, ENC_LITTLE_ENDIAN);
	seq = tvb_get_letohl(tvb, offset + consumed_len);
	consumed_len += SIZE_OF_LENGTH_FIELD;
	col_append_fstr(pinfo->cinfo, COL_INFO, "Seq: %d ", seq);

	/** Timestamp */
	consumed_len += dissect_ros_message_header_stamp(tvb, sub_tree, pinfo, offset + consumed_len);

	/** Frame ID */
	ti = proto_tree_add_item(sub_tree, hf_tcpros_message_header_frame, tvb, offset + consumed_len, SIZE_OF_LENGTH_FIELD, ENC_UTF_8|ENC_LITTLE_ENDIAN);
	sub_tree = proto_item_add_subtree(ti, ett_tcpros);

	proto_tree_add_item(sub_tree, hf_tcpros_message_header_frame_length, tvb, offset + consumed_len, SIZE_OF_LENGTH_FIELD, ENC_LITTLE_ENDIAN);
	consumed_len += SIZE_OF_LENGTH_FIELD;

	proto_tree_add_item(sub_tree, hf_tcpros_message_header_frame_value, tvb, offset + consumed_len, frame_id_len, ENC_UTF_8|ENC_NA);
	col_append_fstr(pinfo->cinfo, COL_INFO, "Frame: '%s' ",	tvb_get_string_enc(wmem_packet_scope(), tvb, offset + consumed_len, frame_id_len, ENC_UTF_8) );
	consumed_len += frame_id_len;

	return consumed_len;
}
Ejemplo n.º 26
0
static gint dissect_counted_values(tvbuff_t *tvb, gint offset, int hf_id,  packet_info *pinfo, proto_tree *tree, gboolean single, gboolean unicode, guint encoding)
{
	 proto_item *item;
	 guint32 length, count, i;

	 count = tvb_get_letohl(tvb, offset);
	 proto_tree_add_item(tree, hf_tnef_values_count, tvb, offset, 4, ENC_LITTLE_ENDIAN);

	 if(count > 1) {
		 if(single) {
			 item = proto_tree_add_expert_format(tree, pinfo, &ei_tnef_expect_single_item, tvb, offset, 4,
						    "Expecting a single item but found %d", count);
			 tree = proto_item_add_subtree(item, ett_tnef_counted_items);
		 }
	 }

	 offset += 4;

	 for(i = 0; i < count; i++) {

		 length = tvb_get_letohl(tvb, offset);
		 proto_tree_add_item(tree, hf_tnef_value_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
		 offset += 4;

		 if (unicode) {
			 char *unicode_str = tvb_get_unicode_string(wmem_packet_scope(), tvb, offset, length, ENC_LITTLE_ENDIAN);
			 proto_tree_add_string(tree, hf_id, tvb, offset, length, unicode_str);
		 } else {
			 proto_tree_add_item(tree, hf_id, tvb, offset, length, encoding);
		 }
		 offset += length;

		 /* XXX: may be padding ? */

	 }

	 return offset;
}
Ejemplo n.º 27
0
static void
dissect_UDPR3(tvbuff_t *tvb, packet_info *pinfo,
	      proto_tree *adwin_tree, proto_tree *adwin_debug_tree)
{
	guint32 i, seq_num;

	/* Get the transaction identifier */
	seq_num = tvb_get_letohl(tvb, 0);
	adwin_request_response_handling(tvb, pinfo, adwin_tree, seq_num, ADWIN_RESPONSE);

	if (! adwin_tree)
		return;

	SET_PACKET_TYPE(adwin_tree, APT_UDPR3);
	ADWIN_ADD_LE(adwin_tree, packet_index,   0,  4);
	ADWIN_ADD_LE(adwin_tree, packet_no,      4,  4);

	if (! global_adwin_dissect_data) {
		proto_tree_add_text(adwin_debug_tree, tvb, 8, 350 * 4, "Data");
		return;
	}

	for (i = 0; i < 350; i++) {
		proto_item *item;
		guint32 offset = 8 + i * sizeof(guint32);
		gint32 value = tvb_get_letohl(tvb, offset);
		void * fvalue = &value;
		proto_tree_add_text(adwin_debug_tree, tvb, offset, 4,
				    "Data[%3d]: %10d - %10f - 0x%08x",
				    i, value, *(float*)fvalue, value);
		item = ADWIN_ADD_LE(adwin_debug_tree, data_int,   offset, 4);
		PROTO_ITEM_SET_HIDDEN(item);
		item = ADWIN_ADD_LE(adwin_debug_tree, data_float, offset, 4);
		PROTO_ITEM_SET_HIDDEN(item);
		item = ADWIN_ADD_LE(adwin_debug_tree, data_hex,   offset, 4);
		PROTO_ITEM_SET_HIDDEN(item);
	}
}
Ejemplo n.º 28
0
static int
dissect_bson_document(tvbuff_t *tvb, guint offset, proto_tree *tree, int hf_mongo_document)
{
	gint32 document_length;
	proto_item *ti;
	proto_tree *doc_tree;

	document_length = tvb_get_letohl(tvb, offset);
	/* TODO Implement BSON spec to correctly see BSON document type and not in Bytes format... */
	ti = proto_tree_add_item(tree, hf_mongo_document, tvb, offset+4, document_length-4, ENC_NA);
	doc_tree = proto_item_add_subtree(ti, ett_mongo_doc);

	proto_tree_add_item(doc_tree, hf_mongo_document_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);

	return document_length;
}
Ejemplo n.º 29
0
static void
dissect_ble_delta_time(tvbuff_t *tvb, proto_tree *tree)
{
  static guint8 previous_ble_packet_length = 0;
	guint32 delta_time, delta_time_ss;
  
  /* end - start */
	delta_time 			= (guint32)tvb_get_letohl(tvb, get_td_index());
	proto_tree_add_item(tree, hf_nordic_ble_delta_time, tvb, get_td_index(), 4, ENC_LITTLE_ENDIAN);
  
  /* start - start */
  delta_time_ss = get_metadata_transfer_time() + (get_us_per_byte() * previous_ble_packet_length) + delta_time;
	proto_tree_add_uint(tree, hf_nordic_ble_delta_time_ss, tvb, get_td_index(), 4, delta_time_ss);  
  
  previous_ble_packet_length = tvb_get_guint8(tvb, get_packet_length_index());
}
Ejemplo n.º 30
0
static int
dissect_dtpt_guid(tvbuff_t *tvb, guint offset, proto_tree *tree, int hfindex)
{
	guint32	guid_length;

	guid_length = tvb_get_letohl(tvb, offset);
	if (tree) {
		e_guid_t	guid;
		proto_item	*dtpt_guid_item = NULL;
		proto_tree	*dtpt_guid_tree = NULL;
		const gchar	*guid_name = NULL;

		if (guid_length) {
			tvb_get_guid(tvb, offset+4, &guid, ENC_LITTLE_ENDIAN);
		}
		else {
			memset(&guid, 0, sizeof(guid));
		}
		dtpt_guid_item = proto_tree_add_guid(tree, hfindex, tvb, offset, 4 + guid_length, &guid);
		if (dtpt_guid_item) {
			guid_name = guids_get_guid_name(&guid);
			if (guid_name != NULL)
				proto_item_set_text(dtpt_guid_item, "%s: %s (%s)",
				proto_registrar_get_name(hfindex), guid_name, guid_to_str(&guid));
			dtpt_guid_tree = proto_item_add_subtree(dtpt_guid_item, ett_dtpt_guid);
		}
		if (dtpt_guid_tree) {
			proto_item	*dtpt_guid_data_item = NULL;

			proto_tree_add_uint(dtpt_guid_tree, hf_dtpt_guid_length,
				tvb, offset, 4, guid_length);
			if (guid_length) {
				dtpt_guid_data_item = proto_tree_add_guid(dtpt_guid_tree, hf_dtpt_guid_data,
					tvb, offset+4, guid_length, &guid);
				if (guid_name != NULL && dtpt_guid_data_item != NULL) {
					proto_item_set_text(dtpt_guid_data_item, "%s: %s (%s)",
					proto_registrar_get_name(hf_dtpt_guid_data),
					guid_name, guid_to_str(&guid));
				}
			}
		}
	}
	offset+=4;
	offset+=guid_length;

	return offset;
}