コード例 #1
0
ファイル: v_man_pack_node.c プロジェクト: ffforks/verse
void verse_send_t_text_set(VNodeID node_id, VBufferID buffer_id, uint32 pos, uint32 length, const char *text)
{
	uint8 *buf;
	VOrderedStorage *s;
	unsigned int buffer_pos = 0;
	VCMDBufHead *head;
	head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
	buf = ((VCMDBuffer10 *)head)->buf;

	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 99);/* Packing the command */
#if defined V_PRINT_SEND_COMMANDS
	printf("send: verse_send_t_text_set(node_id = %u buffer_id = %u pos = %u length = %u text = %s );\n", node_id, buffer_id, pos, length, text);
#endif
	s = v_con_get_ordered_storage();
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], buffer_id);
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], pos);
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], length);	
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], s->text_send_id++);
	if(text == NULL)
		buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);
	else
		buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], text, VN_T_MAX_TEXT_CMD_SIZE);
	v_cmd_buf_set_unique_address_size(head, buffer_pos);
	v_cmd_buf_set_size(head, buffer_pos);
	v_noq_send_buf(v_con_get_network_queue(), head);
}
コード例 #2
0
ファイル: v_man_pack_node.c プロジェクト: ffforks/verse
static unsigned int pack_b_tile_set_head(VCMDBufHead *head, VNodeID node_id, VLayerID layer_id, uint16 tile_x, uint16 tile_y, uint16 z, VNBLayerType type, const VNBTile *tile)
{
	unsigned int buffer_pos = 0;
	uint8 *buf;
	buf = ((VCMDBuffer30 *)head)->buf;
	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 83);	/* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
	printf("send: verse_send_b_tile_set(node_id = %u layer_id = %u tile_x = %u tile_y = %u z = %u type = %u tile = %p );\n", node_id, layer_id, tile_x, tile_y, z, type, tile);
#endif
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tile_x);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], tile_y);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], z);
	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)type);
	return buffer_pos;
	v_cmd_buf_set_address_size(head, 13);
	v_cmd_buf_set_size(head, buffer_pos);
	v_noq_send_buf(v_con_get_network_queue(), head);
}
コード例 #3
0
ファイル: v_gen_pack_b_node.c プロジェクト: ffforks/verse
void verse_send_b_dimensions_set(VNodeID node_id, uint16 width, uint16 height, uint16 depth)
{
	uint8 *buf;
	unsigned int buffer_pos = 0;
	VCMDBufHead *head;
	head = v_cmd_buf_allocate(VCMDBS_20);/* Allocating the buffer */
	buf = ((VCMDBuffer10 *)head)->buf;

	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 80);	/* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
	printf("send: verse_send_b_dimensions_set(node_id = %u width = %u height = %u depth = %u );\n", node_id, width, height, depth);
#endif
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], width);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], height);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], depth);
	if(node_id == (uint32) ~0u)
		v_cmd_buf_set_unique_address_size(head, 5);
	else
		v_cmd_buf_set_address_size(head, 5);
	v_cmd_buf_set_size(head, buffer_pos);
	v_noq_send_buf(v_con_get_network_queue(), head);
}
コード例 #4
0
ファイル: v_network.c プロジェクト: donno/verse
/**
 * \brief Pack header of VMessage to the buffer
 * \param[in]	vmessage	The structure with data for message
 * \param[out]	buffer		The buffer, that will be sent to the peer.
 * \return This function return of bytes packed to the buffer.
 */
int v_pack_message_header(const VMessage *vmessage, char *buffer)
{
	unsigned short buffer_pos=0;
	unsigned char ver;

	/* Pack version */
	ver = (vmessage->header.version << 4) & 0xF0;
	buffer_pos += vnp_raw_pack_uint8(&buffer[buffer_pos], ver);
	/* Pack zeros for reservation space */
	buffer_pos += vnp_raw_pack_uint8(&buffer[buffer_pos], 0);
	/* Pack length of command */
	buffer_pos += vnp_raw_pack_uint16(&buffer[buffer_pos], vmessage->header.len);

	return buffer_pos;
}
コード例 #5
0
ファイル: v_man_pack_node.c プロジェクト: ffforks/verse
void verse_send_c_key_destroy(VNodeID node_id, VLayerID curve_id, uint32 key_id)
{
	uint8 *buf;
	unsigned int buffer_pos = 0;
	VCMDBufHead *head;
	head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
	buf = ((VCMDBuffer10 *)head)->buf;

	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 130);/* Packing the command */
#if defined V_PRINT_SEND_COMMANDS
	printf("send: verse_send_c_key_destroy(node_id = %u curve_id = %u key_id = %u );\n", node_id, curve_id, key_id);
#endif
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id);
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], key_id);
	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 0);
	v_cmd_buf_set_address_size(head, 11);
	v_cmd_buf_set_size(head, buffer_pos);
	v_noq_send_buf(v_con_get_network_queue(), head);
}
コード例 #6
0
ファイル: v_network.c プロジェクト: donno/verse
/**
 * \brief Pack header of VPacket to the buffer
 * \return This function return of bytes packed to the buffer.
 */
int v_pack_packet_header(const VPacket *vpacket, char *buffer)
{
	unsigned short buffer_pos=0;
	unsigned char ver;

	/* Pack version */
	ver = (vpacket->header.version << 4) & 0xF0;
	buffer_pos += vnp_raw_pack_uint8(&buffer[buffer_pos], ver);
	/* Flags */
	buffer_pos += vnp_raw_pack_uint8(&buffer[buffer_pos], vpacket->header.flags);
	/* Flow control window */
	buffer_pos += vnp_raw_pack_uint16(&buffer[buffer_pos], vpacket->header.window);
	/* Payload ID */
	buffer_pos += vnp_raw_pack_uint32(&buffer[buffer_pos], vpacket->header.payload_id);
	/* ACK NAK ID */
	buffer_pos += vnp_raw_pack_uint32(&buffer[buffer_pos], vpacket->header.ack_nak_id);
	/* ANK ID */
	buffer_pos += vnp_raw_pack_uint32(&buffer[buffer_pos], vpacket->header.ank_id);

	return buffer_pos;
}
コード例 #7
0
ファイル: v_gen_pack_c_node.c プロジェクト: ffforks/verse
void verse_send_c_curve_unsubscribe(VNodeID node_id, VLayerID curve_id)
{
	uint8 *buf;
	unsigned int buffer_pos = 0;
	VCMDBufHead *head;
	head = v_cmd_buf_allocate(VCMDBS_10);/* Allocating the buffer */
	buf = ((VCMDBuffer10 *)head)->buf;

	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 129);	/* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
	printf("send: verse_send_c_curve_unsubscribe(node_id = %u curve_id = %u );\n", node_id, curve_id);
#endif
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id);
	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], FALSE);
	if(node_id == (uint32) ~0u || curve_id == (uint16) ~0u)
		v_cmd_buf_set_unique_address_size(head, 7);
	else
		v_cmd_buf_set_address_size(head, 7);
	v_cmd_buf_set_size(head, buffer_pos);
	v_noq_send_buf(v_con_get_network_queue(), head);
}
コード例 #8
0
ファイル: v_gen_pack_b_node.c プロジェクト: ffforks/verse
void verse_send_b_layer_destroy(VNodeID node_id, VLayerID layer_id)
{
	uint8 *buf;
	unsigned int buffer_pos = 0;
	VCMDBufHead *head;
	head = v_cmd_buf_allocate(VCMDBS_30);/* Allocating the buffer */
	buf = ((VCMDBuffer10 *)head)->buf;

	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 81);	/* Pack the command. */
#if defined V_PRINT_SEND_COMMANDS
	printf("send: verse_send_b_layer_destroy(node_id = %u layer_id = %u );\n", node_id, layer_id);
#endif
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], layer_id);
	buffer_pos += vnp_raw_pack_string(&buf[buffer_pos], NULL, 16);
	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], (uint8)-1);
	if(node_id == (uint32) ~0u || layer_id == (uint16) ~0u)
		v_cmd_buf_set_unique_address_size(head, 7);
	else
		v_cmd_buf_set_address_size(head, 7);
	v_cmd_buf_set_size(head, buffer_pos);
	v_noq_send_buf(v_con_get_network_queue(), head);
}
コード例 #9
0
ファイル: v_man_pack_node.c プロジェクト: ffforks/verse
void verse_send_c_key_set(VNodeID node_id, VLayerID curve_id, uint32 key_id, uint8 dimensions,
			  const real64 *pre_value, const uint32 *pre_pos,
			  const real64 *value, real64 pos,
			  const real64 *post_value, const uint32 *post_pos)
{
	uint8 *buf;
	unsigned int i, buffer_pos = 0;
	VCMDBufHead *head;
	head = v_cmd_buf_allocate(VCMDBS_1500);/* Allocating the buffer */
	buf = ((VCMDBuffer10 *)head)->buf;

	if(dimensions == 0 || dimensions > 4)
		return;
	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], 130);/* Packing the command */
#if defined V_PRINT_SEND_COMMANDS
	switch(dimensions)
	{
	case 1:
		printf("send: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = %f pre_pos = %u value = %f pos = %f, pre_value = %f pre_pos = %u ); callback = %p\n", node_id, curve_id, key_id, dimensions, pre_value[0], pre_pos[0], value[0], pos, pre_value[0], pre_pos[0], v_fs_get_user_func(130));
	break;
	case 2:
		printf("sende: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f} pre_pos = {%u, %u} value = {%f, %f} pos = %f, pre_value = {%f, %f} pre_pos = {%u, %u}); callback = %p\n",
			node_id, curve_id, key_id, dimensions, 
			pre_value[0], pre_value[1], 
			pre_pos[0], pre_pos[1], 
			value[0], value[1], pos,
			pre_value[0], pre_value[1],  
			pre_pos[0], pre_pos[1], v_fs_get_user_func(130));
	break;
	case 3:
		printf("send: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u} value = {%f, %f, %f} pos = %f, pre_value = {%f, %f, %f} pre_pos = {%u, %u, %u}); callback = %p\n",
			node_id, curve_id, key_id, dimensions, 
			pre_value[0], pre_value[1], pre_value[2],  
			pre_pos[0], pre_pos[1], pre_pos[2],  
			value[0], value[1], value[2], pos,
			pre_value[0], pre_value[1], pre_value[2],  
			pre_pos[0], pre_pos[1], pre_pos[2], v_fs_get_user_func(130));
		
	break;
	case 4:
		printf("send: verse_send_c_key_set(node_id = %u curve_id = %u key_id = %u dimensions = %u pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u} value = {%f, %f, %f, %f} pos = %f, pre_value = {%f, %f, %f, %f} pre_pos = {%u, %u, %u, %u}); callback = %p\n",
			node_id, curve_id, key_id, dimensions, 
			pre_value[0], pre_value[1], pre_value[2], pre_value[3], 
			pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3], 
			value[0], value[1], value[2], value[3], pos, 
			pre_value[0], pre_value[1], pre_value[2], pre_value[3], 
			pre_pos[0], pre_pos[1], pre_pos[2], pre_pos[3], v_fs_get_user_func(130));		
	break;
	}
#endif
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], node_id);
	buffer_pos += vnp_raw_pack_uint16(&buf[buffer_pos], curve_id);
	buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], key_id);
	buffer_pos += vnp_raw_pack_uint8(&buf[buffer_pos], dimensions);

	for(i = 0; i < dimensions; i++)
		buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pre_value[i]);	
	for(i = 0; i < dimensions; i++)
		buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], pre_pos[i]);	
	for(i = 0; i < dimensions; i++)
		buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], value[i]);	
	buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], pos);	
	for(i = 0; i < dimensions; i++)
		buffer_pos += vnp_raw_pack_real64(&buf[buffer_pos], post_value[i]);	
	for(i = 0; i < dimensions; i++)
		buffer_pos += vnp_raw_pack_uint32(&buf[buffer_pos], post_pos[i]);	

	if(key_id == (uint32) ~0u)
		v_cmd_buf_set_unique_address_size(head, 11);
	else
		v_cmd_buf_set_address_size(head, 11);
	v_cmd_buf_set_size(head, buffer_pos);
	v_noq_send_buf(v_con_get_network_queue(), head);
}