static int avb_1722_1_entity_database_add(avb_1722_1_adp_packet_t* pkt)
{
	guid_t guid;
	int found_slot_index = AVB_1722_1_MAX_ENTITIES;
	int i;
	int entity_update = 0;

	GET_LONG_WORD(guid, pkt->entity_guid);

	for (i=0; i < AVB_1722_1_MAX_ENTITIES; ++i)
	{
		if (entities[i].guid.l == 0) found_slot_index = i;	// Found an empty entry in the database
		if (entities[i].guid.l == guid.l)
		{
			// Entity is already in the database - break from loop early and update it
			found_slot_index = i;
			entity_update = 1;
			break;
		}
	}

	if (found_slot_index != AVB_1722_1_MAX_ENTITIES)
	{
		entities[found_slot_index].guid.l = guid.l;
		entities[found_slot_index].vendor_id = NTOH_U32(pkt->vendor_id);
		entities[found_slot_index].model_id = NTOH_U32(pkt->model_id);
		entities[found_slot_index].capabilities = NTOH_U32(pkt->entity_capabilities);
		entities[found_slot_index].talker_stream_sources = NTOH_U16(pkt->talker_stream_sources);
		entities[found_slot_index].talker_capabilities = NTOH_U16(pkt->talker_capabilities);
		entities[found_slot_index].listener_stream_sinks = NTOH_U16(pkt->listener_stream_sinks);
		entities[found_slot_index].listener_capabilites = NTOH_U16(pkt->listener_capabilites);
		entities[found_slot_index].controller_capabilities = NTOH_U32(pkt->controller_capabilities);
		entities[found_slot_index].available_index = NTOH_U32(pkt->available_index);
		GET_LONG_WORD(entities[found_slot_index].as_grandmaster_id, pkt->as_grandmaster_id)
		entities[found_slot_index].default_audio_format = NTOH_U32(pkt->default_audio_format);
		entities[found_slot_index].default_video_format = NTOH_U32(pkt->default_video_format);
		entities[found_slot_index].association_id = NTOH_U32(pkt->association_id);
		entities[found_slot_index].type = NTOH_U32(pkt->entity_type);
		entities[found_slot_index].timeout = GET_1722_1_VALID_TIME(&pkt->header) + adp_two_second_counter;

		if (entity_update)
		{
			return 0;
		}
		else
		{
			adp_latest_entity_added_index = found_slot_index;
			return 1;
		}
	}

	return 0;
}
static void store_rcvd_cmd_resp(avb_1722_1_acmp_cmd_resp* store, avb_1722_1_acmp_packet_t* pkt)
{
    get_64(store->stream_id.c, pkt->stream_id);
    get_64(store->controller_guid.c, pkt->controller_guid);
    get_64(store->listener_guid.c, pkt->listener_guid);
    get_64(store->talker_guid.c, pkt->talker_guid);
    store->talker_unique_id = ntoh_16(pkt->talker_unique_id);
    store->listener_unique_id = ntoh_16(pkt->listener_unique_id);
    store->connection_count = ntoh_16(pkt->connection_count);
    store->sequence_id = ntoh_16(pkt->sequence_id);
    store->flags = ntoh_16(pkt->flags);
    store->vlan_id = ntoh_16(pkt->vlan_id);
    memcpy(store->stream_dest_mac, pkt->dest_mac, 6);
    store->message_type = GET_1722_1_MSG_TYPE(&(pkt->header));
    store->status = GET_1722_1_VALID_TIME(&(pkt->header));
}