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); }
/** * \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; }
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); }
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); }
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); }
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); }
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); }
boolean v_noq_send_queue(VNetOutQueue *queue, void *address) { static unsigned int my_counter = 0; VCMDBufHead *buf; unsigned int size; uint8 *data; uint32 seconds, fractions; double delta; data = queue->packet_buffer; v_n_get_current_time(&seconds, &fractions); delta = seconds - queue->seconds + (fractions - queue->fractions) / (double) 0xffffffff; if(queue->unsorted != NULL) v_noq_sort_unsorted(queue); if(queue->unsent_size == 0 && delta < 1.0 && (queue->ack_nak == NULL || queue->ack_nak->next == NULL)) return FALSE; if(delta > 3.0 && queue->unsent_size == 0 && queue->ack_nak == NULL && queue->packet_buffer_use != 0) { /* printf("A) re-sending last delta=%g\n", delta);*/ v_n_send_data(address, data, queue->packet_buffer_use); queue->seconds = seconds; queue->fractions = fractions; return TRUE; } size = 4; buf = queue->ack_nak; while(buf != NULL && size + buf->size < V_NOQ_MAX_PACKET_SIZE) { vnp_raw_pack_uint32(data, queue->packet_id); queue->ack_nak = buf->next; buf->next = queue->history[queue->slot]; queue->history[queue->slot] = buf; buf->packet = queue->packet_id; v_e_data_encrypt_command(data, size, ((VCMDBuffer1500 *)buf)->buf, buf->size, v_con_get_data_key()); size += buf->size; queue->sent_size += buf->size; buf = queue->ack_nak; } if(queue->unsent_size == 0 || queue->sent_size >= V_NOQ_WINDOW_SIZE) { if(size > 5) { /* printf("ACK: sending actual size=%u id=%u\n", size, queue->packet_id);*/ v_n_send_data(address, data, size); queue->packet_buffer_use = size; queue->seconds = seconds; queue->fractions = fractions; queue->packet_id++; return TRUE; } /* printf("returning FALSE from send_queue()\n");*/ return FALSE; } /* if(queue->sent_size < V_NOQ_WINDOW_SIZE && queue->unsent_size != 0)*/ { vnp_raw_pack_uint32(data, queue->packet_id); while(queue->unsent_size != 0) { queue->slot = ((1 + queue->slot) % V_NOQ_OPTIMIZATION_SLOTS); buf = queue->unsent[queue->slot]; if(buf != NULL) { if(buf->size + size > V_NOQ_MAX_PACKET_SIZE) break; queue->unsent[queue->slot] = buf->next; buf->next = queue->history[queue->slot]; queue->history[queue->slot] = buf; buf->packet = queue->packet_id; v_e_data_encrypt_command(data, size, ((VCMDBuffer1500 *)buf)->buf, buf->size, v_con_get_data_key()); size += buf->size; queue->unsent_comands--; queue->unsent_size -= buf->size; queue->sent_size += buf->size; my_counter++; } } v_n_send_data(address, data, size); queue->packet_buffer_use = size; queue->packet_id++; /* size = vnp_raw_pack_uint32(data, queue->packet_id);*/ queue->seconds = seconds; queue->fractions = fractions; } return TRUE; }