COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
Collaboration diagram for File Transfer functions:

Functions

bool IS_MESSAGE (const unsigned char)
 
bool IS_REQUEST (const unsigned char)
 
bool IS_METADATA (const unsigned char)
 
bool IS_DATA (const unsigned char)
 
bool IS_REQDATA (const unsigned char)
 
bool IS_REQMETA (const unsigned char)
 
bool IS_COMPLETE (const unsigned char)
 
bool IS_GET_REQUEST (const unsigned char)
 
bool IS_PUT_REQUEST (const unsigned char)
 
bool IS_DELETE_REQUEST (const unsigned char)
 
void make_metadata_packet (vector< PACKET_BYTE > &packet, packet_struct_metalong meta)
 
void make_metadata_packet (vector< PACKET_BYTE > &packet, PACKET_TX_ID_TYPE tx_id, char *file_name, PACKET_FILE_SIZE_TYPE file_size, char *node_name, char *agent_name)
 
void make_metadata_packet (vector< PACKET_BYTE > &packet, packet_struct_metashort meta)
 
void make_metadata_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, PACKET_TX_ID_TYPE tx_id, char *file_name, PACKET_FILE_SIZE_TYPE file_size, char *agent_name)
 
void extract_metadata (vector< PACKET_BYTE > &packet, packet_struct_metalong &meta)
 
void extract_metadata (vector< PACKET_BYTE > &packet, PACKET_TX_ID_TYPE &tx_id, char *file_name, PACKET_FILE_SIZE_TYPE &file_size, char *node_name, char *agent_name)
 
void extract_metadata (vector< PACKET_BYTE > &packet, packet_struct_metashort &meta)
 
void extract_metadata (vector< PACKET_BYTE > &packet, PACKET_TX_ID_TYPE &tx_id, char *file_name, PACKET_FILE_SIZE_TYPE &file_size, PACKET_NODE_ID_TYPE &node_id, char *agent_name)
 
void make_data_packet (vector< PACKET_BYTE > &packet, packet_struct_data data)
 
void make_data_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, PACKET_TX_ID_TYPE tx_id, PACKET_CHUNK_SIZE_TYPE byte_count, PACKET_FILE_SIZE_TYPE chunk_start, PACKET_BYTE *chunk)
 
void extract_data (vector< PACKET_BYTE > &packet, packet_struct_data &data)
 
void extract_data (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE &node_id, PACKET_TX_ID_TYPE &tx_id, PACKET_CHUNK_SIZE_TYPE &byte_count, PACKET_FILE_SIZE_TYPE &chunk_start, PACKET_BYTE *chunk)
 
void make_reqdata_packet (vector< PACKET_BYTE > &packet, packet_struct_reqdata reqdata)
 
void make_reqdata_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, PACKET_TX_ID_TYPE tx_id, PACKET_FILE_SIZE_TYPE hole_start, PACKET_FILE_SIZE_TYPE hole_end)
 
void extract_reqdata (vector< PACKET_BYTE > &packet, packet_struct_reqdata &reqdata)
 
void extract_reqdata (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE &node_id, PACKET_TX_ID_TYPE &tx_id, PACKET_FILE_SIZE_TYPE &hole_start, PACKET_FILE_SIZE_TYPE &hole_end)
 
void make_reqmeta_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, string node_name, vector< PACKET_TX_ID_TYPE > reqmeta)
 
void extract_reqmeta (vector< PACKET_BYTE > &packet, packet_struct_reqmeta &reqmeta)
 
void make_complete_packet (vector< PACKET_BYTE > &packet, packet_struct_complete complete)
 
void make_complete_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, PACKET_TX_ID_TYPE tx_id)
 
void extract_complete (vector< PACKET_BYTE > &packet, packet_struct_complete &complete)
 
void extract_complete (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE &node_id, PACKET_TX_ID_TYPE &tx_id)
 
void make_cancel_packet (vector< PACKET_BYTE > &packet, packet_struct_cancel cancel)
 
void make_cancel_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, PACKET_TX_ID_TYPE tx_id)
 
void extract_cancel (vector< PACKET_BYTE > &packet, packet_struct_cancel &cancel)
 
void extract_cancel (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE &node_id, PACKET_TX_ID_TYPE &tx_id)
 
void make_reqqueue_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, string node_name)
 
void extract_reqqueue (vector< PACKET_BYTE > &packet, packet_struct_reqqueue &reqqueue)
 
void make_queue_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, string node_name, vector< PACKET_TX_ID_TYPE > queue)
 
void extract_queue (vector< PACKET_BYTE > &packet, packet_struct_queue &queue)
 
void make_heartbeat_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, string node_name, uint8_t beat_period, uint32_t throughput, uint32_t funixtime)
 
void extract_heartbeat (vector< PACKET_BYTE > &packet, packet_struct_heartbeat &heartbeat)
 
void make_message_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, string message)
 
void extract_message (vector< PACKET_BYTE > &packet, packet_struct_message &message)
 
void make_command_packet (vector< PACKET_BYTE > &packet, PACKET_NODE_ID_TYPE node_id, string command)
 
void extract_command (vector< PACKET_BYTE > &packet, packet_struct_command &command)
 
int32_t check_node_id (PACKET_NODE_ID_TYPE node_id)
 
int32_t lookup_node_id (string node_name)
 
int32_t set_node_id (PACKET_NODE_ID_TYPE node_id, string node_name)
 
string lookup_node_id_name (PACKET_NODE_ID_TYPE node_id)
 
int32_t load_nodeids ()
 
vector< string > get_nodeids ()
 
void show_fstream_state (std::ifstream &out)
 ------------— code above this line has be checked and de-Jonny-fied More...
 
int32_t get_file_size (string filename)
 Get size of file. More...
 
int32_t get_file_size (const char *filename)
 
void print_cstring (uint8_t *buf, int siz)
 
void print_cstring_with_index (uint8_t *buf, int siz)
 
void print_cstring_hex (uint8_t *buf, int siz)
 
void print_cstring_hex_with_index (uint8_t *buf, int siz)
 
void unable_to_remove (string filename)
 
PACKET_TYPE salt_type (PACKET_TYPE type)
 

Detailed Description

Function Documentation

bool IS_MESSAGE ( const unsigned  char)
bool IS_REQUEST ( const unsigned  char)
bool IS_METADATA ( const unsigned  char)
41 { return (((P_TYPE & 0x0f) & PACKET_METADATA) != 0); }
static const unsigned char PACKET_METADATA
Definition: transferlib.h:103
bool IS_DATA ( const unsigned  char)
42 { return (((P_TYPE & 0x0f) & PACKET_DATA) != 0); }
static const unsigned char PACKET_DATA
Definition: transferlib.h:104
bool IS_REQDATA ( const unsigned  char)
43 { return (((P_TYPE & 0x0f) & PACKET_REQDATA) != 0); }
static const unsigned char PACKET_REQDATA
Definition: transferlib.h:105
bool IS_REQMETA ( const unsigned  char)
44 { return (((P_TYPE & 0x0f) & PACKET_REQMETA) != 0); }
static const unsigned char PACKET_REQMETA
Definition: transferlib.h:106
bool IS_COMPLETE ( const unsigned  char)
45 { return (((P_TYPE & 0x0f) & PACKET_COMPLETE) != 0); }
static const unsigned char PACKET_COMPLETE
Definition: transferlib.h:107
bool IS_GET_REQUEST ( const unsigned  char)
bool IS_PUT_REQUEST ( const unsigned  char)
bool IS_DELETE_REQUEST ( const unsigned  char)
void make_metadata_packet ( vector< PACKET_BYTE > &  packet,
packet_struct_metalong  meta 
)
164 {
165  make_metadata_packet(packet, meta.tx_id, meta.file_name, meta.file_size, meta.node_name, meta.agent_name);
166 }
char node_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:231
char file_name[128]
Definition: transferlib.h:234
char agent_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:233
PACKET_FILE_SIZE_TYPE file_size
Definition: transferlib.h:235
void make_metadata_packet(vector< PACKET_BYTE > &packet, packet_struct_metalong meta)
Definition: transferlib.cpp:163
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:232
void make_metadata_packet ( vector< PACKET_BYTE > &  packet,
PACKET_TX_ID_TYPE  tx_id,
char *  file_name,
PACKET_FILE_SIZE_TYPE  file_size,
char *  node_name,
char *  agent_name 
)
169 {
171 
172  packet.resize(PACKET_METALONG_OFFSET_TOTAL);
173  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
174  memmove(&packet[0]+PACKET_METALONG_OFFSET_TX_ID, &tx_id, sizeof(PACKET_TX_ID_TYPE));
175  memmove(&packet[0]+PACKET_METALONG_OFFSET_FILE_NAME, file_name, TRANSFER_MAX_FILENAME);
176  memmove(&packet[0]+PACKET_METALONG_OFFSET_FILE_SIZE, &file_size, sizeof(file_size));
179  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
180  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
181 }
uint8_t PACKET_TYPE
Definition: transferlib.h:141
#define TRANSFER_MAX_FILENAME
Definition: transferlib.h:78
#define PACKET_METALONG_OFFSET_FILE_SIZE
Definition: transferlib.h:242
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
#define PACKET_METALONG_OFFSET_NODE_NAME
Definition: transferlib.h:238
#define PACKET_METALONG_OFFSET_AGENT_NAME
Definition: transferlib.h:240
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
static const unsigned char PACKET_METADATA
Definition: transferlib.h:103
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
string node_name
Definition: agent_001.cpp:46
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_METALONG_OFFSET_FILE_NAME
Definition: transferlib.h:241
#define PACKET_METALONG_OFFSET_TOTAL
Definition: transferlib.h:243
string agent_name
Definition: agent_001.cpp:47
#define PACKET_METALONG_OFFSET_TX_ID
Definition: transferlib.h:239
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
void make_metadata_packet ( vector< PACKET_BYTE > &  packet,
packet_struct_metashort  meta 
)
184 {
185  make_metadata_packet(packet, meta.node_id, meta.tx_id, meta.file_name, meta.file_size, meta.agent_name);
186 }
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:248
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:247
char file_name[128]
Definition: transferlib.h:250
char agent_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:249
void make_metadata_packet(vector< PACKET_BYTE > &packet, packet_struct_metalong meta)
Definition: transferlib.cpp:163
PACKET_FILE_SIZE_TYPE file_size
Definition: transferlib.h:251
void make_metadata_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
PACKET_TX_ID_TYPE  tx_id,
char *  file_name,
PACKET_FILE_SIZE_TYPE  file_size,
char *  agent_name 
)
189 {
191 
192  packet.resize(PACKET_METASHORT_OFFSET_TOTAL);
193 
194  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
195  memmove(&packet[0]+PACKET_METASHORT_OFFSET_NODE_ID, &node_id, sizeof(PACKET_NODE_ID_TYPE));
196  memmove(&packet[0]+PACKET_METASHORT_OFFSET_TX_ID, &tx_id, sizeof(PACKET_TX_ID_TYPE));
197  memmove(&packet[0]+PACKET_METASHORT_OFFSET_FILE_NAME, file_name, TRANSFER_MAX_FILENAME);
198  memmove(&packet[0]+PACKET_METASHORT_OFFSET_FILE_SIZE, &file_size, sizeof(file_size));
200  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
201  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
202 }
#define PACKET_METASHORT_OFFSET_TX_ID
Definition: transferlib.h:255
uint8_t PACKET_TYPE
Definition: transferlib.h:141
#define TRANSFER_MAX_FILENAME
Definition: transferlib.h:78
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
static const unsigned char PACKET_METADATA
Definition: transferlib.h:103
#define PACKET_METASHORT_OFFSET_AGENT_NAME
Definition: transferlib.h:256
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
#define PACKET_METASHORT_OFFSET_NODE_ID
Definition: transferlib.h:254
#define PACKET_METASHORT_OFFSET_TOTAL
Definition: transferlib.h:259
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_METASHORT_OFFSET_FILE_SIZE
Definition: transferlib.h:258
string agent_name
Definition: agent_001.cpp:47
#define PACKET_METASHORT_OFFSET_FILE_NAME
Definition: transferlib.h:257
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
void extract_metadata ( vector< PACKET_BYTE > &  packet,
packet_struct_metalong meta 
)
205 {
206  extract_metadata(packet, meta.tx_id, meta.file_name, meta.file_size, meta.node_name, meta.agent_name);
207 }
char node_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:231
char file_name[128]
Definition: transferlib.h:234
void extract_metadata(vector< PACKET_BYTE > &packet, packet_struct_metalong &meta)
Definition: transferlib.cpp:204
char agent_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:233
PACKET_FILE_SIZE_TYPE file_size
Definition: transferlib.h:235
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:232
void extract_metadata ( vector< PACKET_BYTE > &  packet,
PACKET_TX_ID_TYPE tx_id,
char *  file_name,
PACKET_FILE_SIZE_TYPE file_size,
char *  node_name,
char *  agent_name 
)
210 {
211  memmove(&tx_id, &packet[0]+PACKET_METALONG_OFFSET_TX_ID, sizeof(PACKET_TX_ID_TYPE));
213  memmove(file_name, &packet[0]+PACKET_METALONG_OFFSET_FILE_NAME, TRANSFER_MAX_FILENAME);
214  memmove(&file_size, &packet[0]+PACKET_METALONG_OFFSET_FILE_SIZE, sizeof(file_size));
216 }
#define TRANSFER_MAX_FILENAME
Definition: transferlib.h:78
#define PACKET_METALONG_OFFSET_FILE_SIZE
Definition: transferlib.h:242
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
#define PACKET_METALONG_OFFSET_NODE_NAME
Definition: transferlib.h:238
#define PACKET_METALONG_OFFSET_AGENT_NAME
Definition: transferlib.h:240
string node_name
Definition: agent_001.cpp:46
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_METALONG_OFFSET_FILE_NAME
Definition: transferlib.h:241
string agent_name
Definition: agent_001.cpp:47
#define PACKET_METALONG_OFFSET_TX_ID
Definition: transferlib.h:239
void extract_metadata ( vector< PACKET_BYTE > &  packet,
packet_struct_metashort meta 
)
219 {
220  extract_metadata(packet, meta.tx_id, meta.file_name, meta.file_size, meta.node_id, meta.agent_name);
221 }
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:248
void extract_metadata(vector< PACKET_BYTE > &packet, packet_struct_metalong &meta)
Definition: transferlib.cpp:204
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:247
char file_name[128]
Definition: transferlib.h:250
char agent_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:249
PACKET_FILE_SIZE_TYPE file_size
Definition: transferlib.h:251
void extract_metadata ( vector< PACKET_BYTE > &  packet,
PACKET_TX_ID_TYPE tx_id,
char *  file_name,
PACKET_FILE_SIZE_TYPE file_size,
PACKET_NODE_ID_TYPE node_id,
char *  agent_name 
)
224 {
225  memmove(&tx_id, &packet[0]+PACKET_METASHORT_OFFSET_TX_ID, sizeof(PACKET_TX_ID_TYPE));
226  memmove(file_name, &packet[0]+PACKET_METASHORT_OFFSET_FILE_NAME, TRANSFER_MAX_FILENAME);
227  memmove(&file_size, &packet[0]+PACKET_METASHORT_OFFSET_FILE_SIZE, sizeof(file_size));
228  memmove(&node_id, &packet[0]+PACKET_METASHORT_OFFSET_NODE_ID, COSMOS_MAX_NAME);
230 }
#define PACKET_METASHORT_OFFSET_TX_ID
Definition: transferlib.h:255
#define TRANSFER_MAX_FILENAME
Definition: transferlib.h:78
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
#define PACKET_METASHORT_OFFSET_AGENT_NAME
Definition: transferlib.h:256
#define PACKET_METASHORT_OFFSET_NODE_ID
Definition: transferlib.h:254
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_METASHORT_OFFSET_FILE_SIZE
Definition: transferlib.h:258
string agent_name
Definition: agent_001.cpp:47
#define PACKET_METASHORT_OFFSET_FILE_NAME
Definition: transferlib.h:257
void make_data_packet ( vector< PACKET_BYTE > &  packet,
packet_struct_data  data 
)
void make_data_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
PACKET_TX_ID_TYPE  tx_id,
PACKET_CHUNK_SIZE_TYPE  byte_count,
PACKET_FILE_SIZE_TYPE  chunk_start,
PACKET_BYTE chunk 
)
233 {
235 
236  packet.resize(PACKET_DATA_OFFSET_HEADER_TOTAL+byte_count);
237  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
238  memmove(&packet[0]+PACKET_DATA_OFFSET_NODE_ID, &node_id, sizeof(PACKET_NODE_ID_TYPE));
239  memmove(&packet[0]+PACKET_DATA_OFFSET_TX_ID, &tx_id, sizeof(PACKET_TX_ID_TYPE));
240  memmove(&packet[0]+PACKET_DATA_OFFSET_BYTE_COUNT, &byte_count, sizeof(PACKET_CHUNK_SIZE_TYPE));
241  memmove(&packet[0]+PACKET_DATA_OFFSET_CHUNK_START, &chunk_start, sizeof(chunk_start));
242  memmove(&packet[0]+PACKET_DATA_OFFSET_CHUNK, chunk, byte_count);
243  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
244  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
245 }
uint8_t PACKET_TYPE
Definition: transferlib.h:141
uint16_t PACKET_CHUNK_SIZE_TYPE
Definition: transferlib.h:145
#define PACKET_DATA_OFFSET_CHUNK
Definition: transferlib.h:288
#define PACKET_DATA_OFFSET_TX_ID
Definition: transferlib.h:285
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
#define PACKET_DATA_OFFSET_HEADER_TOTAL
Definition: transferlib.h:289
#define PACKET_DATA_OFFSET_BYTE_COUNT
Definition: transferlib.h:286
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
#define PACKET_DATA_OFFSET_CHUNK_START
Definition: transferlib.h:287
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_DATA_OFFSET_NODE_ID
Definition: transferlib.h:284
static const unsigned char PACKET_DATA
Definition: transferlib.h:104
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
void extract_data ( vector< PACKET_BYTE > &  packet,
packet_struct_data data 
)
void extract_data ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE node_id,
PACKET_TX_ID_TYPE tx_id,
PACKET_CHUNK_SIZE_TYPE byte_count,
PACKET_FILE_SIZE_TYPE chunk_start,
PACKET_BYTE chunk 
)
249 {
250  memmove(&node_id, &packet[0]+PACKET_DATA_OFFSET_NODE_ID, sizeof(PACKET_NODE_ID_TYPE));
251  memmove(&tx_id, &packet[0]+PACKET_DATA_OFFSET_TX_ID, sizeof(PACKET_TX_ID_TYPE));
252  memmove(&byte_count, &packet[0]+PACKET_DATA_OFFSET_BYTE_COUNT, sizeof(byte_count));
253  memmove(&chunk_start, &packet[0]+PACKET_DATA_OFFSET_CHUNK_START, sizeof(chunk_start));
254  memmove(chunk, &packet[0]+PACKET_DATA_OFFSET_CHUNK, byte_count);
255 }
#define PACKET_DATA_OFFSET_CHUNK
Definition: transferlib.h:288
#define PACKET_DATA_OFFSET_TX_ID
Definition: transferlib.h:285
#define PACKET_DATA_OFFSET_BYTE_COUNT
Definition: transferlib.h:286
#define PACKET_DATA_OFFSET_CHUNK_START
Definition: transferlib.h:287
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_DATA_OFFSET_NODE_ID
Definition: transferlib.h:284
void make_reqdata_packet ( vector< PACKET_BYTE > &  packet,
packet_struct_reqdata  reqdata 
)
132 {
133  make_reqdata_packet(packet, reqdata.node_id, reqdata.tx_id, reqdata.hole_start, reqdata.hole_end);
134 }
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:263
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:264
void make_reqdata_packet(vector< PACKET_BYTE > &packet, packet_struct_reqdata reqdata)
Definition: transferlib.cpp:131
PACKET_FILE_SIZE_TYPE hole_start
Definition: transferlib.h:265
PACKET_FILE_SIZE_TYPE hole_end
Definition: transferlib.h:266
void make_reqdata_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
PACKET_TX_ID_TYPE  tx_id,
PACKET_FILE_SIZE_TYPE  hole_start,
PACKET_FILE_SIZE_TYPE  hole_end 
)
137 {
139 
140  packet.resize(PACKET_REQDATA_OFFSET_TOTAL);
141  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
142  memmove(&packet[0]+PACKET_REQDATA_OFFSET_NODE_ID, &node_id, sizeof(PACKET_NODE_ID_TYPE));
143  memmove(&packet[0]+PACKET_REQDATA_OFFSET_TX_ID, &tx_id, sizeof(PACKET_TX_ID_TYPE));
144  memmove(&packet[0]+PACKET_REQDATA_OFFSET_HOLE_START, &hole_start, sizeof(PACKET_FILE_SIZE_TYPE));
145  memmove(&packet[0]+PACKET_REQDATA_OFFSET_HOLE_END, &hole_end, sizeof(PACKET_FILE_SIZE_TYPE));
146  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
147  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
148 }
uint8_t PACKET_TYPE
Definition: transferlib.h:141
#define PACKET_REQDATA_OFFSET_NODE_ID
Definition: transferlib.h:269
#define PACKET_REQDATA_OFFSET_HOLE_END
Definition: transferlib.h:272
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
int32_t PACKET_FILE_SIZE_TYPE
Definition: transferlib.h:146
#define PACKET_REQDATA_OFFSET_TX_ID
Definition: transferlib.h:270
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
static const unsigned char PACKET_REQDATA
Definition: transferlib.h:105
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_REQDATA_OFFSET_HOLE_START
Definition: transferlib.h:271
#define PACKET_REQDATA_OFFSET_TOTAL
Definition: transferlib.h:273
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
void extract_reqdata ( vector< PACKET_BYTE > &  packet,
packet_struct_reqdata reqdata 
)
151 {
152  extract_reqdata(packet, reqdata.node_id, reqdata.tx_id, reqdata.hole_start, reqdata.hole_end);
153 }
void extract_reqdata(vector< PACKET_BYTE > &packet, packet_struct_reqdata &reqdata)
Definition: transferlib.cpp:150
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:263
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:264
PACKET_FILE_SIZE_TYPE hole_start
Definition: transferlib.h:265
PACKET_FILE_SIZE_TYPE hole_end
Definition: transferlib.h:266
void extract_reqdata ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE node_id,
PACKET_TX_ID_TYPE tx_id,
PACKET_FILE_SIZE_TYPE hole_start,
PACKET_FILE_SIZE_TYPE hole_end 
)
156 {
157  memmove(&node_id, &packet[0]+PACKET_REQDATA_OFFSET_NODE_ID, sizeof(PACKET_NODE_ID_TYPE));
158  memmove(&tx_id, &packet[0]+PACKET_REQDATA_OFFSET_TX_ID, sizeof(PACKET_TX_ID_TYPE));
159  memmove(&hole_start, &packet[0]+PACKET_REQDATA_OFFSET_HOLE_START, sizeof(hole_start));
160  memmove(&hole_end, &packet[0]+PACKET_REQDATA_OFFSET_HOLE_END, sizeof(hole_end));
161 }
#define PACKET_REQDATA_OFFSET_NODE_ID
Definition: transferlib.h:269
#define PACKET_REQDATA_OFFSET_HOLE_END
Definition: transferlib.h:272
#define PACKET_REQDATA_OFFSET_TX_ID
Definition: transferlib.h:270
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_REQDATA_OFFSET_HOLE_START
Definition: transferlib.h:271
void make_reqmeta_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
string  node_name,
vector< PACKET_TX_ID_TYPE reqmeta 
)
111 {
113 
114  packet.resize(PACKET_REQMETA_OFFSET_TOTAL);
115  memset(&packet[0], 0, PACKET_REQMETA_OFFSET_TOTAL);
116  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, COSMOS_SIZEOF(PACKET_TYPE));
117  memmove(&packet[0]+PACKET_REQMETA_OFFSET_NODE_ID, &node_id, COSMOS_SIZEOF(PACKET_NODE_ID_TYPE));
118  memmove(&packet[0]+PACKET_REQMETA_OFFSET_NODE_NAME, node_name.c_str(), node_name.size());
120  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
121  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
122 }
uint8_t PACKET_TYPE
Definition: transferlib.h:141
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
#define PACKET_REQMETA_OFFSET_NODE_NAME
Definition: transferlib.h:225
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
string node_name
Definition: agent_001.cpp:46
#define PACKET_REQMETA_OFFSET_TX_ID
Definition: transferlib.h:226
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
#define PACKET_REQMETA_OFFSET_TOTAL
Definition: transferlib.h:227
#define TRANSFER_QUEUE_LIMIT
Definition: transferlib.h:80
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
static const unsigned char PACKET_REQMETA
Definition: transferlib.h:106
#define PACKET_REQMETA_OFFSET_NODE_ID
Definition: transferlib.h:224
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
void extract_reqmeta ( vector< PACKET_BYTE > &  packet,
packet_struct_reqmeta reqmeta 
)
125 {
127  memmove(&reqmeta.node_name, &packet[0]+PACKET_REQMETA_OFFSET_NODE_NAME, COSMOS_MAX_NAME);
129 }
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:219
#define PACKET_REQMETA_OFFSET_NODE_NAME
Definition: transferlib.h:225
#define PACKET_REQMETA_OFFSET_TX_ID
Definition: transferlib.h:226
#define TRANSFER_QUEUE_LIMIT
Definition: transferlib.h:80
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
PACKET_TX_ID_TYPE tx_id[((225-(COSMOS_SIZEOF(PACKET_TYPE)+COSMOS_SIZEOF(PACKET_NODE_ID_TYPE)+COSMOS_SIZEOF(PACKET_TX_ID_TYPE)+COSMOS_MAX_NAME))/(COSMOS_SIZEOF(PACKET_TX_ID_TYPE)))]
Definition: transferlib.h:221
char node_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:220
#define PACKET_REQMETA_OFFSET_NODE_ID
Definition: transferlib.h:224
void make_complete_packet ( vector< PACKET_BYTE > &  packet,
packet_struct_complete  complete 
)
55 {
56  make_complete_packet(packet, complete.node_id, complete.tx_id);
57 }
void make_complete_packet(vector< PACKET_BYTE > &packet, packet_struct_complete complete)
Definition: transferlib.cpp:54
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:294
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:293
void make_complete_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
PACKET_TX_ID_TYPE  tx_id 
)
60 {
62 
63  packet.resize(PACKET_COMPLETE_OFFSET_TOTAL);
64  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
65  memmove(&packet[0]+PACKET_COMPLETE_OFFSET_NODE_ID, &node_id, sizeof(PACKET_NODE_ID_TYPE));
66  memmove(&packet[0]+PACKET_COMPLETE_OFFSET_TX_ID, &tx_id, sizeof(PACKET_TX_ID_TYPE));
67  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
68  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
69 }
uint8_t PACKET_TYPE
Definition: transferlib.h:141
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
#define PACKET_COMPLETE_OFFSET_TX_ID
Definition: transferlib.h:298
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
#define PACKET_COMPLETE_OFFSET_NODE_ID
Definition: transferlib.h:297
#define PACKET_COMPLETE_OFFSET_TOTAL
Definition: transferlib.h:299
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
static const unsigned char PACKET_COMPLETE
Definition: transferlib.h:107
void extract_complete ( vector< PACKET_BYTE > &  packet,
packet_struct_complete complete 
)
72 {
73  extract_complete(packet, complete.node_id, complete.tx_id);
74 }
void extract_complete(vector< PACKET_BYTE > &packet, packet_struct_complete &complete)
Definition: transferlib.cpp:71
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:294
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:293
void extract_complete ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE node_id,
PACKET_TX_ID_TYPE tx_id 
)
77 {
78  memmove(&node_id, &packet[0]+PACKET_COMPLETE_OFFSET_NODE_ID, sizeof(PACKET_NODE_ID_TYPE));
79  memmove(&tx_id, &packet[0]+PACKET_COMPLETE_OFFSET_TX_ID, sizeof(PACKET_TX_ID_TYPE));
80 }
#define PACKET_COMPLETE_OFFSET_TX_ID
Definition: transferlib.h:298
#define PACKET_COMPLETE_OFFSET_NODE_ID
Definition: transferlib.h:297
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
void make_cancel_packet ( vector< PACKET_BYTE > &  packet,
packet_struct_cancel  cancel 
)
83 {
84  make_cancel_packet(packet, cancel.node_id, cancel.tx_id);
85 }
void make_cancel_packet(vector< PACKET_BYTE > &packet, packet_struct_cancel cancel)
Definition: transferlib.cpp:82
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:303
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:304
void make_cancel_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
PACKET_TX_ID_TYPE  tx_id 
)
88 {
90 
91  packet.resize(PACKET_CANCEL_OFFSET_TOTAL);
92  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
93  memmove(&packet[0]+PACKET_CANCEL_OFFSET_NODE_ID, &node_id, sizeof(PACKET_NODE_ID_TYPE));
94  memmove(&packet[0]+PACKET_CANCEL_OFFSET_TX_ID, &tx_id, sizeof(PACKET_TX_ID_TYPE));
95  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
96  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
97 }
#define PACKET_CANCEL_OFFSET_NODE_ID
Definition: transferlib.h:307
uint8_t PACKET_TYPE
Definition: transferlib.h:141
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
#define PACKET_CANCEL_OFFSET_TOTAL
Definition: transferlib.h:309
#define PACKET_CANCEL_OFFSET_TX_ID
Definition: transferlib.h:308
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
static const unsigned char PACKET_CANCEL
Definition: transferlib.h:108
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
void extract_cancel ( vector< PACKET_BYTE > &  packet,
packet_struct_cancel cancel 
)
100 {
101  extract_cancel(packet, cancel.node_id, cancel.tx_id);
102 }
void extract_cancel(vector< PACKET_BYTE > &packet, packet_struct_cancel &cancel)
Definition: transferlib.cpp:99
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:303
PACKET_TX_ID_TYPE tx_id
Definition: transferlib.h:304
void extract_cancel ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE node_id,
PACKET_TX_ID_TYPE tx_id 
)
105 {
106  memmove(&node_id, &packet[0]+PACKET_CANCEL_OFFSET_NODE_ID, sizeof(PACKET_NODE_ID_TYPE));
107  memmove(&tx_id, &packet[0]+PACKET_CANCEL_OFFSET_TX_ID, sizeof(PACKET_TX_ID_TYPE));
108 }
#define PACKET_CANCEL_OFFSET_NODE_ID
Definition: transferlib.h:307
#define PACKET_CANCEL_OFFSET_TX_ID
Definition: transferlib.h:308
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
void make_reqqueue_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
string  node_name 
)
258 {
260 
261  packet.resize(PACKET_REQQUEUE_OFFSET_TOTAL);
262  memset(&packet[0], 0, PACKET_REQQUEUE_OFFSET_TOTAL);
263  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
264  memmove(&packet[0]+PACKET_REQQUEUE_OFFSET_NODE_ID, &node_id, COSMOS_SIZEOF(PACKET_NODE_ID_TYPE));
265  memmove(&packet[0]+PACKET_REQQUEUE_OFFSET_NODE_NAME, node_name.c_str(), node_name.size());
266  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
267  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
268 }
uint8_t PACKET_TYPE
Definition: transferlib.h:141
#define PACKET_REQQUEUE_OFFSET_NODE_ID
Definition: transferlib.h:201
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
#define PACKET_REQQUEUE_OFFSET_TOTAL
Definition: transferlib.h:203
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
string node_name
Definition: agent_001.cpp:46
#define PACKET_REQQUEUE_OFFSET_NODE_NAME
Definition: transferlib.h:202
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
static const unsigned char PACKET_REQQUEUE
Definition: transferlib.h:110
void extract_reqqueue ( vector< PACKET_BYTE > &  packet,
packet_struct_reqqueue reqqueue 
)
272 {
274  memmove(&reqqueue.node_name, &packet[0]+PACKET_REQQUEUE_OFFSET_NODE_NAME, COSMOS_MAX_NAME);
275 }
#define PACKET_REQQUEUE_OFFSET_NODE_ID
Definition: transferlib.h:201
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:197
#define PACKET_REQQUEUE_OFFSET_NODE_NAME
Definition: transferlib.h:202
char node_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:198
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
void make_queue_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
string  node_name,
vector< PACKET_TX_ID_TYPE queue 
)
278 {
280 
281  packet.resize(PACKET_QUEUE_OFFSET_TOTAL);
282  memset(&packet[0], 0, PACKET_QUEUE_OFFSET_TOTAL);
283  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
284  memmove(&packet[0]+PACKET_QUEUE_OFFSET_NODE_ID, &node_id, COSMOS_SIZEOF(PACKET_NODE_ID_TYPE));
285  memmove(&packet[0]+PACKET_QUEUE_OFFSET_NODE_NAME, node_name.c_str(), node_name.size());
287  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
288  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
289 }
uint8_t PACKET_TYPE
Definition: transferlib.h:141
#define PACKET_QUEUE_OFFSET_TX_ID
Definition: transferlib.h:214
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
#define PACKET_QUEUE_OFFSET_TOTAL
Definition: transferlib.h:215
static const unsigned char PACKET_QUEUE
Definition: transferlib.h:109
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
string node_name
Definition: agent_001.cpp:46
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
#define TRANSFER_QUEUE_LIMIT
Definition: transferlib.h:80
#define PACKET_QUEUE_OFFSET_NODE_NAME
Definition: transferlib.h:213
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_QUEUE_OFFSET_NODE_ID
Definition: transferlib.h:212
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
void extract_queue ( vector< PACKET_BYTE > &  packet,
packet_struct_queue queue 
)
293 {
295  memmove(&queue.node_name, &packet[0]+PACKET_QUEUE_OFFSET_NODE_NAME, COSMOS_MAX_NAME);
297 }
PACKET_TX_ID_TYPE tx_id[((225-(COSMOS_SIZEOF(PACKET_TYPE)+COSMOS_SIZEOF(PACKET_NODE_ID_TYPE)+COSMOS_SIZEOF(PACKET_TX_ID_TYPE)+COSMOS_MAX_NAME))/(COSMOS_SIZEOF(PACKET_TX_ID_TYPE)))]
Definition: transferlib.h:209
#define PACKET_QUEUE_OFFSET_TX_ID
Definition: transferlib.h:214
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
char node_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:208
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:207
#define TRANSFER_QUEUE_LIMIT
Definition: transferlib.h:80
#define PACKET_QUEUE_OFFSET_NODE_NAME
Definition: transferlib.h:213
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
uint8_t PACKET_TX_ID_TYPE
Definition: transferlib.h:144
#define PACKET_QUEUE_OFFSET_NODE_ID
Definition: transferlib.h:212
void make_heartbeat_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
string  node_name,
uint8_t  beat_period,
uint32_t  throughput,
uint32_t  funixtime 
)
300 {
302 
303  packet.resize(PACKET_HEARTBEAT_OFFSET_TOTAL);
304  memset(&packet[0], 0, PACKET_HEARTBEAT_OFFSET_TOTAL);
305  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
306  memmove(&packet[0]+PACKET_HEARTBEAT_OFFSET_NODE_ID, &node_id, COSMOS_SIZEOF(PACKET_NODE_ID_TYPE));
307  memmove(&packet[0]+PACKET_HEARTBEAT_OFFSET_NODE_NAME, node_name.c_str(), node_name.size());
308  memmove(&packet[0]+PACKET_HEARTBEAT_OFFSET_BEAT_PERIOD, &beat_period, 1);
309  memmove(&packet[0]+PACKET_HEARTBEAT_OFFSET_THROUGHPUT, &throughput, 4);
310  memmove(&packet[0]+PACKET_HEARTBEAT_OFFSET_FUNIXTIME, &funixtime, 4);
311  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
312  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
313 }
uint8_t PACKET_TYPE
Definition: transferlib.h:141
#define PACKET_HEARTBEAT_OFFSET_BEAT_PERIOD
Definition: transferlib.h:166
#define PACKET_HEARTBEAT_OFFSET_FUNIXTIME
Definition: transferlib.h:168
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
#define PACKET_HEARTBEAT_OFFSET_NODE_ID
Definition: transferlib.h:164
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
string node_name
Definition: agent_001.cpp:46
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
#define PACKET_HEARTBEAT_OFFSET_NODE_NAME
Definition: transferlib.h:165
static const unsigned char PACKET_HEARTBEAT
Definition: transferlib.h:111
#define PACKET_HEARTBEAT_OFFSET_TOTAL
Definition: transferlib.h:169
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
#define PACKET_HEARTBEAT_OFFSET_THROUGHPUT
Definition: transferlib.h:167
void extract_heartbeat ( vector< PACKET_BYTE > &  packet,
packet_struct_heartbeat heartbeat 
)
317 {
319  memmove(&heartbeat.node_name, &packet[0]+PACKET_HEARTBEAT_OFFSET_NODE_NAME, COSMOS_MAX_NAME);
320  memmove(&heartbeat.beat_period, &packet[0]+PACKET_HEARTBEAT_OFFSET_BEAT_PERIOD, 1);
321  memmove(&heartbeat.throughput, &packet[0]+PACKET_HEARTBEAT_OFFSET_THROUGHPUT, 4);
322  memmove(&heartbeat.funixtime, &packet[0]+PACKET_HEARTBEAT_OFFSET_FUNIXTIME, 4);
323 }
PACKET_UNIXTIME_TYPE throughput
Definition: transferlib.h:160
PACKET_UNIXTIME_TYPE funixtime
Definition: transferlib.h:161
#define PACKET_HEARTBEAT_OFFSET_BEAT_PERIOD
Definition: transferlib.h:166
#define PACKET_HEARTBEAT_OFFSET_FUNIXTIME
Definition: transferlib.h:168
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
#define COSMOS_MAX_NAME
Largest JSON name.
Definition: cosmos-defs.h:55
char node_name[COSMOS_MAX_NAME+1]
Definition: transferlib.h:158
#define PACKET_HEARTBEAT_OFFSET_NODE_ID
Definition: transferlib.h:164
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
#define PACKET_HEARTBEAT_OFFSET_NODE_NAME
Definition: transferlib.h:165
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:157
PACKET_BYTE beat_period
Definition: transferlib.h:159
#define PACKET_HEARTBEAT_OFFSET_THROUGHPUT
Definition: transferlib.h:167
void make_message_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
string  message 
)
326 {
328 
329  packet.resize(PACKET_MESSAGE_OFFSET_TOTAL);
330  memset(&packet[0], 0, PACKET_MESSAGE_OFFSET_TOTAL);
331  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
332  memmove(&packet[0]+PACKET_MESSAGE_OFFSET_NODE_ID, &node_id, COSMOS_SIZEOF(PACKET_NODE_ID_TYPE));
333  PACKET_BYTE length = message.size();
334  memmove(&packet[0]+PACKET_MESSAGE_OFFSET_LENGTH, &length, 1);
336  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
337  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
338 }
#define TRANSFER_MAX_PROTOCOL_PACKET
Definition: transferlib.h:77
uint8_t PACKET_TYPE
Definition: transferlib.h:141
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
#define PACKET_MESSAGE_OFFSET_TOTAL
Definition: transferlib.h:181
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
#define PACKET_MESSAGE_OFFSET_NODE_ID
Definition: transferlib.h:178
#define PACKET_MESSAGE_OFFSET_BYTES
Definition: transferlib.h:180
uint8_t message[300]
Definition: kpc9612p_send.cpp:36
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
#define PACKET_MESSAGE_OFFSET_LENGTH
Definition: transferlib.h:179
static const unsigned char PACKET_MESSAGE
Definition: transferlib.h:112
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
png_uint_32 length
Definition: png.c:2173
uint8_t PACKET_BYTE
Definition: transferlib.h:140
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
void extract_message ( vector< PACKET_BYTE > &  packet,
packet_struct_message message 
)
342 {
344  memmove(&message.length, &packet[0]+PACKET_MESSAGE_OFFSET_LENGTH, 1);
345  memmove(&message.bytes[0], &packet[0]+PACKET_MESSAGE_OFFSET_BYTES, message.length);
346 }
PACKET_BYTE length
Definition: transferlib.h:174
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
PACKET_BYTE bytes[225-2]
Definition: transferlib.h:175
#define PACKET_MESSAGE_OFFSET_NODE_ID
Definition: transferlib.h:178
#define PACKET_MESSAGE_OFFSET_BYTES
Definition: transferlib.h:180
#define PACKET_MESSAGE_OFFSET_LENGTH
Definition: transferlib.h:179
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:173
void make_command_packet ( vector< PACKET_BYTE > &  packet,
PACKET_NODE_ID_TYPE  node_id,
string  command 
)
349 {
351 
352  packet.resize(PACKET_COMMAND_OFFSET_TOTAL);
353  memset(&packet[0], 0, PACKET_COMMAND_OFFSET_TOTAL);
354  memmove(&packet[0]+PACKET_HEADER_OFFSET_TYPE, &type, sizeof(PACKET_TYPE));
355  memmove(&packet[0]+PACKET_COMMAND_OFFSET_NODE_ID, &node_id, COSMOS_SIZEOF(PACKET_NODE_ID_TYPE));
356  PACKET_BYTE length = command.size();
357  memmove(&packet[0]+PACKET_COMMAND_OFFSET_LENGTH, &length, 1);
359  uint16_t crc = calc_crc16ccitt(&packet[3], packet.size()-3);
360  memmove(&packet[0]+PACKET_HEADER_OFFSET_CRC, &crc, sizeof(PACKET_CRC));
361 }
#define TRANSFER_MAX_PROTOCOL_PACKET
Definition: transferlib.h:77
uint8_t PACKET_TYPE
Definition: transferlib.h:141
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
png_uint_32 crc
Definition: png.c:2173
uint16_t PACKET_CRC
Definition: transferlib.h:142
PACKET_TYPE salt_type(PACKET_TYPE type)
Definition: transferlib.cpp:485
#define PACKET_COMMAND_OFFSET_TOTAL
Definition: transferlib.h:193
#define PACKET_COMMAND_OFFSET_NODE_ID
Definition: transferlib.h:190
#define PACKET_HEADER_OFFSET_CRC
Definition: transferlib.h:150
#define PACKET_HEADER_OFFSET_TYPE
Definition: transferlib.h:149
string command
Definition: add_radio.cpp:27
#define PACKET_COMMAND_OFFSET_LENGTH
Definition: transferlib.h:191
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
static const unsigned char PACKET_COMMAND
Definition: transferlib.h:113
png_uint_32 length
Definition: png.c:2173
uint8_t PACKET_BYTE
Definition: transferlib.h:140
#define PACKET_COMMAND_OFFSET_BYTES
Definition: transferlib.h:192
uint16_t calc_crc16ccitt(uint8_t *buf, int size, bool lsb)
Calculate CRC-16-CCITT.
Definition: mathlib.cpp:2206
void extract_command ( vector< PACKET_BYTE > &  packet,
packet_struct_command command 
)
365 {
367  memmove(&command.length, &packet[0]+PACKET_COMMAND_OFFSET_LENGTH, 1);
368  memmove(&command.bytes[0], &packet[0]+PACKET_COMMAND_OFFSET_BYTES, command.length);
369 }
PACKET_NODE_ID_TYPE node_id
Definition: transferlib.h:185
#define COSMOS_SIZEOF(element)
Definition: configCosmos.h:139
PACKET_BYTE bytes[225-2]
Definition: transferlib.h:187
PACKET_BYTE length
Definition: transferlib.h:186
#define PACKET_COMMAND_OFFSET_NODE_ID
Definition: transferlib.h:190
#define PACKET_COMMAND_OFFSET_LENGTH
Definition: transferlib.h:191
uint8_t PACKET_NODE_ID_TYPE
Definition: transferlib.h:143
#define PACKET_COMMAND_OFFSET_BYTES
Definition: transferlib.h:192
int32_t check_node_id ( PACKET_NODE_ID_TYPE  node_id)
495 {
496  int32_t iretn;
497 
498  if ((iretn=load_nodeids()) <= 0)
499  {
500  return iretn;
501  }
502 
503 
504  if (node_id > 0 && nodeids[node_id].size())
505  {
506  return node_id;
507  }
508  else
509  {
510  return 0;
511  }
512 }
int32_t load_nodeids()
Definition: transferlib.cpp:549
int iretn
Definition: rw_test.cpp:37
static vector< string > nodeids
Definition: transferlib.cpp:50
int32_t lookup_node_id ( string  node_name)
515 {
516  int32_t iretn;
517 
518  if ((iretn=load_nodeids()) <= 0)
519  {
520  return iretn;
521  }
522 
523  uint8_t node_id = 0;
524  for (uint8_t i=1; i<nodeids.size(); ++i)
525  {
526  if (nodeids[i] == node_name)
527  {
528  node_id = i;
529  break;
530  }
531  }
532 
533  return node_id;
534 }
int32_t load_nodeids()
Definition: transferlib.cpp:549
int i
Definition: rw_test.cpp:37
int iretn
Definition: rw_test.cpp:37
string node_name
Definition: agent_001.cpp:46
static vector< string > nodeids
Definition: transferlib.cpp:50
int32_t set_node_id ( PACKET_NODE_ID_TYPE  node_id,
string  node_name 
)
string lookup_node_id_name ( PACKET_NODE_ID_TYPE  node_id)
537 {
538  string name;
539  if (load_nodeids() > 0 && node_id > 0 && nodeids[node_id].size())
540  {
541  return nodeids[node_id];
542  }
543  else
544  {
545  return "";
546  }
547 }
int32_t load_nodeids()
Definition: transferlib.cpp:549
string name
Definition: cubesat2obj.cpp:6
static vector< string > nodeids
Definition: transferlib.cpp:50
int32_t load_nodeids ( )
550 {
551  char buf[103];
552  if (nodeids.size() == 0)
553  {
554  FILE *fp = data_open(get_cosmosnodes()+"/nodeids.ini", "rb");
555  if (fp)
556  {
557  uint16_t max_index = 0;
558  vector<uint16_t> tindex;
559  vector<string> tnodeid;
560  while (fgets(buf, 102, fp) != nullptr)
561  {
562  uint16_t index = 0;
563  string nodeid;
564  if (buf[strlen(buf)-1] == '\n')
565  {
566  buf[strlen(buf)-1] = 0;
567  }
568  if (buf[1] == ' ')
569  {
570  buf[1] = 0;
571  index = atoi(buf);
572  nodeid = &buf[2];
573  }
574  else if (buf[2] == ' ')
575  {
576  buf[2] = 0;
577  index = atoi(buf);
578  nodeid = &buf[3];
579  }
580  else if (buf[3] == ' ')
581  {
582  buf[3] = 0;
583  index = atoi(buf);
584  nodeid = &buf[4];
585  }
586  else
587  {
588  index = 0;
589  }
590  if (index)
591  {
592  if (index > max_index)
593  {
594  max_index = index;
595  }
596  tindex.push_back(index);
597  tnodeid.push_back(nodeid);
598  }
599  }
600  fclose(fp);
601  nodeids.resize(max_index+1);
602  for (uint16_t i=0; i<tindex.size(); ++i)
603  {
604  nodeids[tindex[i]] = tnodeid[i];
605  }
606  }
607  else
608  {
609  return -errno;
610  }
611  }
612 
613  return nodeids.size();
614 }
int i
Definition: rw_test.cpp:37
FILE * data_open(string path, const char *mode)
Open file from path.
Definition: datalib.cpp:1019
string get_cosmosnodes(bool create_flag)
Return COSMOS Nodes Directory.
Definition: datalib.cpp:1532
FILE * fp
Definition: rw_test.cpp:38
char buf[128]
Definition: rw_test.cpp:40
static vector< string > nodeids
Definition: transferlib.cpp:50
vector<string> get_nodeids ( )
617 {
618  return nodeids;
619 }
static vector< string > nodeids
Definition: transferlib.cpp:50
void show_fstream_state ( std::ifstream &  out)

------------— code above this line has be checked and de-Jonny-fied

371  {
372  std::cout<<"eobit =\t"<<std::ios_base::eofbit<<std::endl;
373  std::cout<<"failbit =\t"<<std::ios_base::failbit<<std::endl;
374  std::cout<<"badbit =\t"<<std::ios_base::badbit<<std::endl;
375  std::cout<<"goodbit =\t"<<std::ios_base::goodbit<<std::endl;
376  return;
377 }
int32_t get_file_size ( string  filename)

Get size of file.

Looks up the size of the file on the filesystem. This returns a 32 bit signed integer so that it works for most files we want to transfer. If the file is larger than 2^32/2, then it will turn negative and be treated as an error.

Parameters
filenameFull path to file
Returns
Size, or negative error.
403 {
404  int32_t iretn;
405  struct stat stat_buf;
406 
407  if ((stat(filename.c_str(), &stat_buf)) == 0)
408  {
409  iretn = stat_buf.st_size;
410  return iretn;
411  }
412  else
413  {
414  return -errno;
415  }
416 }
int iretn
Definition: rw_test.cpp:37
int32_t get_file_size ( const char *  filename)
419 {
420  string sfilename = filename;
421  return get_file_size(sfilename);
422 }
int32_t get_file_size(string filename)
Get size of file.
Definition: transferlib.cpp:402
void print_cstring ( uint8_t *  buf,
int  siz 
)
425 {
426  for(int i=0; i<siz; ++i)
427  printf("%c", buf[i]);
428  printf("\n");
429  printf("\n");
430  return;
431 }
int i
Definition: rw_test.cpp:37
char buf[128]
Definition: rw_test.cpp:40
void print_cstring_with_index ( uint8_t *  buf,
int  siz 
)
434 {
435  using std::min;
436  int start = 0;
437  int linesize = 40;
438  while(start < siz) {
439  for(int i=start; i<min(start+linesize,siz); ++i)
440  printf("%2c", buf[i]);
441  printf("\n");
442  for(int i=start; i<min(start+linesize,siz); ++i)
443  printf("%02d", i%100);
444  printf("\n");
445  printf("\n");
446 
447  start+=linesize;
448  }
449  return;
450 }
int i
Definition: rw_test.cpp:37
char buf[128]
Definition: rw_test.cpp:40
void print_cstring_hex ( uint8_t *  buf,
int  siz 
)
453 {
454  for(int i=0; i<siz; ++i)
455  printf("%02x", buf[i]);
456  printf("\n");
457  printf("\n");
458  return;
459 }
int i
Definition: rw_test.cpp:37
char buf[128]
Definition: rw_test.cpp:40
void print_cstring_hex_with_index ( uint8_t *  buf,
int  siz 
)
462 {
463  using std::min;
464  int start = 0;
465  int linesize = 40;
466  while(start < siz) {
467  for(int i=start; i<min(start+linesize,siz); ++i)
468  printf("%02x", buf[i]);
469  printf("\n");
470  for(int i=start; i<min(start+linesize,siz); ++i)
471  printf("%02d", i%100);
472  printf("\n");
473  printf("\n");
474 
475  start+=linesize;
476  }
477  return;
478 }
int i
Definition: rw_test.cpp:37
char buf[128]
Definition: rw_test.cpp:40
void unable_to_remove ( string  filename)
480  {
481  std::cout<<"ERROR:\tunable to remove file <"<<filename<<">"<<std::endl;
482  return;
483 }
PACKET_TYPE salt_type ( PACKET_TYPE  type)
486 {
487  double cmjd = currentmjd();
488  uint8_t time_salt = (uint32_t)((cmjd-(int)cmjd) * 86400.) % 16;
489  type &= 0xf;
490  type |= time_salt << 4;
491  return type;
492 }
static double cmjd
Definition: agent_monitor.cpp:121
double currentmjd(double offset)
Current UTC in Modified Julian Days.
Definition: timelib.cpp:65