COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
transferlib.h File Reference

File Transfer Support header file. More...

Include dependency graph for transferlib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  packet_struct_heartbeat
 
struct  packet_struct_message
 
struct  packet_struct_command
 
struct  packet_struct_reqqueue
 
struct  packet_struct_queue
 
struct  packet_struct_reqmeta
 
struct  packet_struct_metalong
 
struct  packet_struct_metashort
 
struct  packet_struct_reqdata
 
struct  packet_struct_data
 
struct  packet_struct_complete
 
struct  packet_struct_cancel
 
struct  packet_struct_raw
 
union  packet_struct_all
 
struct  file_progress
 
struct  tx_progress
 

Namespaces

 STATE_TYPE
 
 PACKET_TYPE_STUFF
 
 STATUS_TYPE
 

Macros

#define PACKET_MAX_LENGTH   1500
 
#define TRANSFER_MAX_PROTOCOL_PACKET   225
 
#define TRANSFER_MAX_FILENAME   128
 
#define TRANSFER_QUEUE_LIMIT   ((TRANSFER_MAX_PROTOCOL_PACKET-(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)))
 
#define PACKET_HEADER_OFFSET_TYPE   0
 
#define PACKET_HEADER_OFFSET_CRC   (PACKET_HEADER_OFFSET_TYPE + COSMOS_SIZEOF(PACKET_TYPE))
 
#define PACKET_HEADER_OFFSET_TOTAL   (PACKET_HEADER_OFFSET_CRC + COSMOS_SIZEOF(PACKET_CRC))
 
#define PACKET_HEADER_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_HEADER_OFFSET_NODE_NAME   (PACKET_HEADER_OFFSET_TOTAL + COSMOS_SIZEOF(PACKET_NODE_ID_TYPE))
 
#define PACKET_HEARTBEAT_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_HEARTBEAT_OFFSET_NODE_NAME   (PACKET_HEADER_OFFSET_NODE_NAME)
 
#define PACKET_HEARTBEAT_OFFSET_BEAT_PERIOD   (PACKET_HEARTBEAT_OFFSET_NODE_NAME + COSMOS_MAX_NAME)
 
#define PACKET_HEARTBEAT_OFFSET_THROUGHPUT   (PACKET_HEARTBEAT_OFFSET_BEAT_PERIOD + 1)
 
#define PACKET_HEARTBEAT_OFFSET_FUNIXTIME   (PACKET_HEARTBEAT_OFFSET_THROUGHPUT + 4)
 
#define PACKET_HEARTBEAT_OFFSET_TOTAL   (PACKET_HEARTBEAT_OFFSET_FUNIXTIME + 8)
 
#define PACKET_MESSAGE_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_MESSAGE_OFFSET_LENGTH   (PACKET_MESSAGE_OFFSET_NODE_ID + 1)
 
#define PACKET_MESSAGE_OFFSET_BYTES   (PACKET_MESSAGE_OFFSET_LENGTH + 1)
 
#define PACKET_MESSAGE_OFFSET_TOTAL   (PACKET_MESSAGE_OFFSET_BYTES + TRANSFER_MAX_PROTOCOL_PACKET - 2)
 
#define PACKET_COMMAND_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_COMMAND_OFFSET_LENGTH   (PACKET_COMMAND_OFFSET_NODE_ID + 1)
 
#define PACKET_COMMAND_OFFSET_BYTES   (PACKET_COMMAND_OFFSET_LENGTH + 1)
 
#define PACKET_COMMAND_OFFSET_TOTAL   (PACKET_COMMAND_OFFSET_BYTES + TRANSFER_MAX_PROTOCOL_PACKET - 2)
 
#define PACKET_REQQUEUE_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_REQQUEUE_OFFSET_NODE_NAME   (PACKET_HEADER_OFFSET_NODE_NAME)
 
#define PACKET_REQQUEUE_OFFSET_TOTAL   (PACKET_REQQUEUE_OFFSET_NODE_ID + COSMOS_MAX_NAME)
 
#define PACKET_QUEUE_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_QUEUE_OFFSET_NODE_NAME   (PACKET_HEADER_OFFSET_NODE_NAME)
 
#define PACKET_QUEUE_OFFSET_TX_ID   (PACKET_QUEUE_OFFSET_NODE_NAME + COSMOS_MAX_NAME)
 
#define PACKET_QUEUE_OFFSET_TOTAL   (PACKET_QUEUE_OFFSET_TX_ID + COSMOS_SIZEOF(PACKET_TX_ID_TYPE) * TRANSFER_QUEUE_LIMIT)
 
#define PACKET_REQMETA_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_REQMETA_OFFSET_NODE_NAME   (PACKET_HEADER_OFFSET_NODE_NAME)
 
#define PACKET_REQMETA_OFFSET_TX_ID   (PACKET_REQMETA_OFFSET_NODE_NAME + COSMOS_MAX_NAME)
 
#define PACKET_REQMETA_OFFSET_TOTAL   (PACKET_REQMETA_OFFSET_TX_ID + COSMOS_SIZEOF(PACKET_TX_ID_TYPE) * TRANSFER_QUEUE_LIMIT)
 
#define PACKET_METALONG_OFFSET_NODE_NAME   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_METALONG_OFFSET_TX_ID   (PACKET_METALONG_OFFSET_NODE_NAME + COSMOS_MAX_NAME)
 
#define PACKET_METALONG_OFFSET_AGENT_NAME   (PACKET_METALONG_OFFSET_TX_ID + COSMOS_SIZEOF(PACKET_TX_ID_TYPE))
 
#define PACKET_METALONG_OFFSET_FILE_NAME   (PACKET_METALONG_OFFSET_AGENT_NAME + COSMOS_MAX_NAME)
 
#define PACKET_METALONG_OFFSET_FILE_SIZE   (PACKET_METALONG_OFFSET_FILE_NAME + TRANSFER_MAX_FILENAME)
 
#define PACKET_METALONG_OFFSET_TOTAL   (PACKET_METALONG_OFFSET_FILE_SIZE + COSMOS_SIZEOF(PACKET_FILE_SIZE_TYPE))
 
#define PACKET_METASHORT_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_METASHORT_OFFSET_TX_ID   (PACKET_METASHORT_OFFSET_NODE_ID + COSMOS_SIZEOF(PACKET_NODE_ID_TYPE))
 
#define PACKET_METASHORT_OFFSET_AGENT_NAME   (PACKET_METASHORT_OFFSET_TX_ID + COSMOS_SIZEOF(PACKET_TX_ID_TYPE))
 
#define PACKET_METASHORT_OFFSET_FILE_NAME   (PACKET_METASHORT_OFFSET_AGENT_NAME + COSMOS_MAX_NAME)
 
#define PACKET_METASHORT_OFFSET_FILE_SIZE   (PACKET_METASHORT_OFFSET_FILE_NAME + TRANSFER_MAX_FILENAME)
 
#define PACKET_METASHORT_OFFSET_TOTAL   (PACKET_METASHORT_OFFSET_FILE_SIZE + COSMOS_SIZEOF(PACKET_FILE_SIZE_TYPE))
 
#define PACKET_REQDATA_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_REQDATA_OFFSET_TX_ID   (PACKET_REQDATA_OFFSET_NODE_ID + COSMOS_SIZEOF(PACKET_NODE_ID_TYPE))
 
#define PACKET_REQDATA_OFFSET_HOLE_START   (PACKET_REQDATA_OFFSET_TX_ID + COSMOS_SIZEOF(PACKET_TX_ID_TYPE))
 
#define PACKET_REQDATA_OFFSET_HOLE_END   (PACKET_REQDATA_OFFSET_HOLE_START + COSMOS_SIZEOF(PACKET_FILE_SIZE_TYPE))
 
#define PACKET_REQDATA_OFFSET_TOTAL   (PACKET_REQDATA_OFFSET_HOLE_END + COSMOS_SIZEOF(PACKET_FILE_SIZE_TYPE))
 
#define PACKET_DATA_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_DATA_OFFSET_TX_ID   (PACKET_DATA_OFFSET_NODE_ID + COSMOS_SIZEOF(PACKET_NODE_ID_TYPE))
 
#define PACKET_DATA_OFFSET_BYTE_COUNT   (PACKET_DATA_OFFSET_TX_ID + COSMOS_SIZEOF(PACKET_TX_ID_TYPE))
 
#define PACKET_DATA_OFFSET_CHUNK_START   (PACKET_DATA_OFFSET_BYTE_COUNT + COSMOS_SIZEOF(PACKET_CHUNK_SIZE_TYPE))
 
#define PACKET_DATA_OFFSET_CHUNK   (PACKET_DATA_OFFSET_CHUNK_START + COSMOS_SIZEOF(PACKET_FILE_SIZE_TYPE))
 
#define PACKET_DATA_OFFSET_HEADER_TOTAL   (PACKET_DATA_OFFSET_CHUNK)
 
#define PACKET_COMPLETE_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_COMPLETE_OFFSET_TX_ID   (PACKET_COMPLETE_OFFSET_NODE_ID + COSMOS_SIZEOF(PACKET_NODE_ID_TYPE))
 
#define PACKET_COMPLETE_OFFSET_TOTAL   (PACKET_COMPLETE_OFFSET_TX_ID + COSMOS_SIZEOF(PACKET_TX_ID_TYPE))
 
#define PACKET_CANCEL_OFFSET_NODE_ID   (PACKET_HEADER_OFFSET_TOTAL)
 
#define PACKET_CANCEL_OFFSET_TX_ID   (PACKET_CANCEL_OFFSET_NODE_ID + COSMOS_SIZEOF(PACKET_NODE_ID_TYPE))
 
#define PACKET_CANCEL_OFFSET_TOTAL   (PACKET_CANCEL_OFFSET_TX_ID + COSMOS_SIZEOF(PACKET_TX_ID_TYPE))
 

Typedefs

typedef uint8_t PACKET_BYTE
 
typedef uint8_t PACKET_TYPE
 
typedef uint16_t PACKET_CRC
 
typedef uint8_t PACKET_NODE_ID_TYPE
 
typedef uint8_t PACKET_TX_ID_TYPE
 
typedef uint16_t PACKET_CHUNK_SIZE_TYPE
 
typedef int32_t PACKET_FILE_SIZE_TYPE
 
typedef uint32_t PACKET_UNIXTIME_TYPE
 

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)
 

Variables

static const unsigned char STATE_TYPE::STATE_NONE = 0x00
 
static const unsigned char STATE_TYPE::STATE_REQQUEUE = 0x01
 
static const unsigned char STATE_TYPE::STATE_QUEUE = 0x02
 
static const unsigned char STATE_TYPE::STATE_REQMETA = 0x03
 
static const unsigned char STATE_TYPE::STATE_METADATA = 0x04
 
static const unsigned char STATE_TYPE::STATE_REQDATA = 0x05
 
static const unsigned char STATE_TYPE::STATE_DATA = 0x06
 
static const unsigned char STATE_TYPE::STATE_CANCEL = 0x07
 
static const unsigned char STATE_TYPE::STATE_COMPLETE = 0x08
 
static const unsigned char STATE_TYPE::STATE_SIZE = 0x09
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_METADATA = 0xf
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_DATA = 0xe
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_REQDATA = 0xd
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_REQMETA = 0xc
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_COMPLETE = 0xb
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_CANCEL = 0xa
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_QUEUE = 0x9
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_REQQUEUE = 0x8
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_HEARTBEAT = 0x7
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_MESSAGE = 0x6
 
static const unsigned char PACKET_TYPE_STUFF::PACKET_COMMAND = 0x5
 
static const unsigned char STATUS_TYPE::STATUS_ALL_GOOD = 128
 
static const unsigned char STATUS_TYPE::STATUS_BAD_TX_ID = 64
 
static const unsigned char STATUS_TYPE::STATUS_NO_FILE_FOUND = 32
 
static const unsigned char STATUS_TYPE::STATUS_HOLES_TO_FILL = 16
 
static const unsigned char STATUS_TYPE::STATUS_SUCCESS = 8
 
static const unsigned char STATUS_TYPE::STATUS_NEED_METADATA = 4
 
static const unsigned char STATUS_TYPE::STATUS_2 = 2
 
static const unsigned char STATUS_TYPE::STATUS_3 = 1
 

Detailed Description

File Transfer Support header file.