TReK ANSI-C
5.3.3
All ANSI-C APIs
|
An ANSI C Data Service API. More...
Functions | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | CreateUnicastUDPSocketDevice (const char *ip_address, unsigned short port, unsigned int receive_queue_size, unsigned int receive_buffer_size, unsigned int *device_key_buffer_size_ptr, char *device_key) |
Creates a UDP socket to send and receive packets at the specified IP address and port. UDP protocal does not guarantee delivery of the packet or packets being received in the order they were sent. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | CreateUnixLocalClientSocketDevice (const char *name, unsigned int receive_queue_size, unsigned int receive_buffer_size, unsigned int *device_key_buffer_size_ptr, char *device_key) |
Creates a Unix local client socket for interprocess communication on a Linux operating system using a unique name and an abstract name space. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | CreateIPv4MulticastUDPSocketDevice (unsigned short port, unsigned int receive_queue_size, unsigned int receive_buffer_size, boolean_type disable_loopback_flag, unsigned int *device_key_buffer_size_ptr, char *device_key) |
Creates a UDP socket to send and receive IP version 4 multicast packets at the specified port. UDP protocal does not guarantee delivery of the packet or packets being received in the order they were sent. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | CreateTCPListenerSocketDevice (const char *ip_address, unsigned short port, unsigned int receive_queue_size, unsigned int receive_buffer_size, unsigned int *device_key_buffer_size_ptr, char *device_key) |
Creates a TCP listener socket. The listener socket accepts and connects client sockets to newly created server sockets. TCP protocal guarantees delivery of the packets in the order they were sent although it may break the packets up into segments that must be reassembled by the receiving application. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | CreateTCPClientSocketDevice (const char *ip_address, unsigned short port, unsigned int receive_queue_size, unsigned int receive_buffer_size, unsigned int *device_key_buffer_size_ptr, char *device_key) |
Creates a TCP client socket. The client socket must make a separate connection request to a TCP listener sockets and connect to the listener's server socket. TCP protocal guarantees delivery of the packets in the order they were sent although it may break the packets up into segments that must be reassembled by the receiving application. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | CreateBPDevice (unsigned int source_service_number, unsigned int lifespan, bp_class_of_service_type cos, unsigned int ordinal, bp_transmission_mode_type mode, bp_criticality_type criticality, unsigned int *device_key_buffer_size_ptr, char *device_key) |
Creates a Bundle Protocol (BP) device that attaches to ION's BP library. ION's BP application must be running prior to creating the BP device. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | CreateDeviceKeyAlias (const char *device_key, const char *device_key_alias) |
Create a user friendly name/alias and associate it with a device key. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | ConnectSocketDevice (const char *device_key, const char *ip_address_to_connect_to, unsigned short port_to_connect_to, unsigned int connection_timeout_msec) |
Connect a TCP client socket to a TCP listener's server socket. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | JoinMulticastGroup (const char *ip_address, const char *multicast_group_address, const char *device_key) |
Associates a mulitcast socket with a multicast group address. A multicast socket must join a multicast group by calling JoinMulticastGroup prior to receiving packets sent to the IP multicast group address. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | SetMulticastTTL (const char *device_key, unsigned short multicast_ttl) |
Sets the time to live for a socket that is sending packets to a multicast address. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | SetTCPKeepalive (const char *device_key, unsigned long keepalive_time, unsigned long keepalive_interval, unsigned long keepalive_probes) |
Sets the TCP keepalive parameters to determine whether the TCP connection is still up and running or has broken. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | DeleteDevice (const char *device_key) |
Decrements the device's use counter and if the device use counter is zero, all reference to the device are deleted and all device resources are released. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | ReceivePacketFromDevice (const char *device_key, unsigned int receive_timeout, unsigned int *packet_buffer_size_ptr, int *packet_length_ptr, unsigned char *packet_buffer_ptr, unsigned int *message_code_ptr) |
Receive a packet from a device within a specified time period. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | ReceivePacketFromSocketDevice (const char *device_key, unsigned int receive_timeout, unsigned int *packet_buffer_size_ptr, int *packet_length_ptr, unsigned char *packet_buffer_ptr, unsigned int *message_code_ptr, unsigned int *receive_from_ip_address_buffer_size_ptr, char *received_from_ip_address, unsigned short *received_from_port_ptr) |
Receive a packet from a socket device within a specified time period. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | SendPacket (const char *device_key, int packet_length, unsigned char *packet_buffer_ptr) |
Sends a packet to a device. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | SendPacketFromTCPServerSocketDevice (const char *listener_device_key, const char *server_device_key, int packet_length, unsigned char *packet_buffer_ptr) |
Sends a packet from a TCP server socket device to the connected client socket device. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | SendPacketFromUDPSocketDevice (const char *device_key, int packet_length, unsigned char *packet_buffer_ptr, const char *send_to_ip_address, unsigned short send_to_port) |
Sends a packet from UDP socket device to the IP address and port number of a corresponding UDP socket device. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | SendPacketFromBPDevice (const char *device_key, int packet_length, unsigned char *packet_buffer_ptr, long long destination_node_number, unsigned int destination_service_number) |
Sends a packet from a bundle protocol device to the destination node. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | DefinePHPPacketSizeField (const char *php_name, unsigned int byte_offset, unsigned int bit_offset, unsigned int length_in_bits, long size_offset_value, endian_byte_order byte_order) |
Defines the location of a packet size field in a new or existing packet header. All byte and bit offsets start at zero and are numbered from from left to right. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | DefinePHPSyncHexPattern (const char *php_name, const char *sync_hex_pattern, boolean_type start_of_packet_sync_flag) |
Defines a synch pattern for packets that require synchronization in a new or existing packet header processor. The sync pattern is described in hexadecimal format. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | DefinePHPFixedPacketSize (const char *php_name, unsigned int fixed_packet_size) |
Defines the size of all the packets that will be recieved by a device that is associated with this new or existing packet header processor. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | DefinePHPPacketSequenceCountField (const char *php_name, unsigned int byte_offset, unsigned int bit_offset, unsigned int length_in_bits, endian_byte_order byte_order) |
Defines the location of a packet sequence count in a new or existing packet header. All byte and bit offsets start at zero and are numbered from from left to right. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | DefinePHPPacketKeyField (const char *php_name, const char *packet_key_name, unsigned int byte_offset, unsigned int bit_offset, unsigned int length_in_bits, endian_byte_order byte_order) |
Defines the location of a packet key field in a new or existing packet header. All byte and bit offsets start at zero and are numbered from from left to right. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | AddPacketHeaderProcessor (const char *php_name, const char *device_key) |
Adds or associates an existing packet header processor with a device to support retreiving packets from packet segments or deterimining packets statistics. Only one uniquely defined packet header processor may be added to a device. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | GeneratePublicPrivateKeyPair (const char *public_key_pathname, const char *private_key_pathname) |
Generates a public/private key pair based on Elliptic Curve Cryptography (ECC) using curve P-256. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | GeneratePublicPrivateKeyPairWithPassphrase (const char *public_key_pathname, const char *private_key_pathname, const char *crypt_user_passphrase) |
Generates a public/private key pair based on Elliptic Curve Cryptography (ECC) using curve P-256. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | AddCipherToDevice (const char *device_key, cipher_class_type cipher_class, const char *public_key_pathname, const char *private_key_pathname, const char *peer_public_key_pathname, int pkt_key_encrypt_time_interval_sec, const char *crypt_user_passphrase) |
The AddCipherToDevice function encrypts all data being sent by a device and decrypts all data prior to being processed by a device. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | AddCipherToDeviceWithPeerIPAddress (const char *device_key, cipher_class_type cipher_class, const char *public_key_pathname, const char *private_key_pathname, const char *peer_public_key_pathname, int pkt_key_encrypt_time_interval_sec, const char *peer_ip_address, const char *crypt_user_passphrase) |
The AddCipherToDeviceWithPeerIPAddress function encrypts all data being sent by a device to the peer IP address and decrypts all data received by device from the peer IP address. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | AddCipherToDeviceWithPeerBPNodeNumber (const char *device_key, cipher_class_type cipher_class, const char *public_key_pathname, const char *private_key_pathname, const char *peer_public_key_pathname, int bundle_key_encrypt_time_interval_sec, unsigned int peer_bp_node_number, const char *crypt_user_passphrase) |
The AddCipherToDeviceWithPeerBPNodeNumber function encrypts all data being sent by a device to the peer BP node number and decrypts all data received by device from the peer BP node number. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | StartLoggingMessages (const char *log_file_path, const char *log_filename, boolean_type log_debug_messages) |
Starts logging messages to a file. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | LogMessage (enum message_category category, const char *message) |
Logs a user message in the log file. The maximum null terminated message size is 512 bytes. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | StopLoggingMessages () |
Stops logging messages to a file, closes the log file and renames the log file by concatenating the log file name with a GMT time string. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | StopLoggingMessagesEx (char *time_tagged_log_file_name) |
Stops logging messages to a file, closes the log file and renames the log file by concatenating the log file name with a GMT time string and returns the new file name. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | StartRecordingStatSnapshot (const char *record_file_path, const char *record_filename, boolean_type record_packet_statistics_flag) |
Starts recording a snapshot of the current statistics to a file. More... | |
void EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | StopRecordingStatSnapshot () |
Stops recording statisitics to a file, closes the record file and renames the record file by concatenating the record file name with a GMT time string. More... | |
void EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | ResetStatistics () |
Resets or zero's the device and packet statistics. More... | |
void EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | PopulateIPAddressStructArray (unsigned int *number_of_ip_address_structs_ptr, ip_address_struct_type **ip_address_struct_array_ptr) |
Populates an array of ip_address_struct with the valid IP addresses of the host platform. More... | |
void EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | FreeIPAddressStructArrayMemoryAlloc (ip_address_struct_type *ip_address_struct_array_ptr) |
Frees the memory associated with the ip_address_struct_array_ptr that was returned by PopulateIPAddressStructArray. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | DSCleanUp () |
Initiates a graceful shutdown of the Device Service library and all supporting device libraries, exits threads, and deallocates memory. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | RegisterMessage (void(*function_ptr)(message_struct_type *message_struct_ptr)) |
Register a callback function to receive and process messages issued by the DS library. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | RegisterReceivePacket (const char *device_key, void(*function_ptr)(const char *key, int packet_length, unsigned char *packet_buffer_ptr)) |
Register a callback function to receive packets from a device. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | RegisterReceivePacketFromSocket (const char *device_key, void(*function_ptr)(const char *device_key, int packet_length, unsigned char *packet_buffer_ptr, const char *received_from_ip_address, unsigned short received_from_port)) |
Register a callback function to receive packets from a socket device. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | RegisterAcceptConnection (const char *listener_device_key, int(*function_ptr)(const char *listener_device_key, const char *server_device_key, const char *connected_ip_address, unsigned short connected_port)) |
Register a callback function to accept a connection request from a client socket. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | RegisterDropConnectionFromListener (const char *listener_device_key, void(*function_ptr)(const char *listener_device_key, const char *disconnected_server_device_key, const char *disconnected_remote_ip_address, unsigned short disconnected_remote_port)) |
Register a callback function to receive notification of a dropped connection when a listener's server socket connection is dropped by its client. More... | |
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION | RegisterDropConnectionFromClient (const char *client_device_key, void(*function_ptr)(const char *disconnected_client_device_key, const char *disconnected_remote_ip_address, unsigned short disconnected_remote_port)) |
Register a callback function to receive notification of a dropped connection when a client socket connection is dropped by its server. More... | |
An ANSI C Data Service API.
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION AddCipherToDevice | ( | const char * | device_key, |
cipher_class_type | cipher_class, | ||
const char * | public_key_pathname, | ||
const char * | private_key_pathname, | ||
const char * | peer_public_key_pathname, | ||
int | pkt_key_encrypt_time_interval_sec, | ||
const char * | crypt_user_passphrase | ||
) |
The AddCipherToDevice function encrypts all data being sent by a device and decrypts all data prior to being processed by a device.
[in] | device_key | A character string that uniquely identifies each device. | |||||
[in] | cipher_class | The cipher package that the TReK encryption library will use to encrypt and decrypt data. The cyphers support either a 128 bit or 256 bit symmetric key. The cipher_class_type is defined in the file "ds_shared.h" as follows:
| |||||
[in] | public_key_pathname | The path and file name of the public key. | |||||
[in] | private_key_pathname | The path and file name of the private key. | |||||
[in] | peer_public_key_pathname | The path and file name of the peer public key. The peer public key is the public key of the remote/destination platform. | |||||
[in] | pkt_key_encrypt_time_interval_sec | Determines how often the packet encryption key is changed while encrypting a stream of packets. If the packet encryption key time interval is set to zero, the TReK encryption library will generate a new packet encryption key for every packet in the stream. | |||||
[in] | crypt_user_passphrase | The passphrase that is used to wrap/encrypt the private key prior to storing the key in the private key file. Pass an empty string (i.e., "") if no crypt_user_passphrase was defined when the public/private key pair was created. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION AddCipherToDeviceWithPeerBPNodeNumber | ( | const char * | device_key, |
cipher_class_type | cipher_class, | ||
const char * | public_key_pathname, | ||
const char * | private_key_pathname, | ||
const char * | peer_public_key_pathname, | ||
int | bundle_key_encrypt_time_interval_sec, | ||
unsigned int | peer_bp_node_number, | ||
const char * | crypt_user_passphrase | ||
) |
The AddCipherToDeviceWithPeerBPNodeNumber function encrypts all data being sent by a device to the peer BP node number and decrypts all data received by device from the peer BP node number.
The peer public key is the public key of the remote/destination platform. The peer BP node number is the DTN ION node number of the remote/destination platform. If the data is sent to or received from a BP node number that does not match the peer BP node number, the device will not encrypt the sent data or decrypt the received data.
[in] | device_key | A character string that uniquely identifies each device. | |||||
[in] | cipher_class | The cipher package that the TReK encryption library will use to encrypt and decrypt data. The cyphers support either a 128 bit or 256 bit symmetric key. The cipher_class_type is defined in the file "ds_shared.h" as follows:
| |||||
[in] | public_key_pathname | The path and file name of the public key. | |||||
[in] | private_key_pathname | The path and file name of the private key. | |||||
[in] | peer_public_key_pathname | The path and file name of the peer public key. The peer public key is the public key of the remote/destination platform. | |||||
[in] | bundle_key_encrypt_time_interval_sec | Determines how often the bundle encryption key is changed while encrypting a stream of bundles. If the bundle encryption key time interval is set to zero, the TReK encryption library will generate a new bundle encryption key for every bundle in the stream. | |||||
[in] | peer_bp_node_number | The DTN ION node number of the remote/destination platform that is receiving the encrypted data or sending the encrypted data (i.e., the DTN ION node number of the remote/destination platform whose public key is represented by the peer public key). | |||||
[in] | crypt_user_passphrase | The passphrase that is used to wrap/encrypt the private key prior to storing the key in the private key file. Pass an empty string (i.e., "") if no crypt_user_passphrase was defined when the public/private key pair was created. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION AddCipherToDeviceWithPeerIPAddress | ( | const char * | device_key, |
cipher_class_type | cipher_class, | ||
const char * | public_key_pathname, | ||
const char * | private_key_pathname, | ||
const char * | peer_public_key_pathname, | ||
int | pkt_key_encrypt_time_interval_sec, | ||
const char * | peer_ip_address, | ||
const char * | crypt_user_passphrase | ||
) |
The AddCipherToDeviceWithPeerIPAddress function encrypts all data being sent by a device to the peer IP address and decrypts all data received by device from the peer IP address.
The peer public key is the public key of the remote/destination platform. The peer IP address is the IP address of the remote/destination platform. If the data is sent to or received from an IP address that does not match the peer IP address, the device will not encrypt the sent data or decrypt the received data.
[in] | device_key | A character string that uniquely identifies each device. | |||||
[in] | cipher_class | The cipher package that the TReK encryption library will use to encrypt and decrypt data. The cyphers support either a 128 bit or 256 bit symmetric key. The cipher_class_type is defined in the file "ds_shared.h" as follows:
| |||||
[in] | public_key_pathname | The path and file name of the public key. | |||||
[in] | private_key_pathname | The path and file name of the private key. | |||||
[in] | peer_public_key_pathname | The path and file name of the peer public key. The peer public key is the public key of the remote/destination platform. | |||||
[in] | pkt_key_encrypt_time_interval_sec | Determines how often the packet encryption key is changed while encrypting a stream of packets. If the packet encryption key time interval is set to zero, the TReK encryption library will generate a new packet encryption key for every packet in the stream. | |||||
[in] | peer_ip_address | The IP address of the remote/destination platform that is receiving the encrypted data or sending the encrypted data (i.e., the IP address of the remote/destination platform whose public key is represented by the peer public key). | |||||
[in] | crypt_user_passphrase | The passphrase that is used to wrap/encrypt the private key prior to storing the key in the private key file. Pass an empty string (i.e., "") if no crypt_user_passphrase was defined when the public/private key pair was created. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION AddPacketHeaderProcessor | ( | const char * | php_name, |
const char * | device_key | ||
) |
Adds or associates an existing packet header processor with a device to support retreiving packets from packet segments or deterimining packets statistics. Only one uniquely defined packet header processor may be added to a device.
If a TCP socket device is receiving packets the protocol may group or divide packets into segments which must be processed to retrieve inidividual packets.
If each packet has a predefined header with a packet size parameter, then the packets may be retrieved from the segments by defining the location of the packet size parameter using the DefinePHPPacketSizeField function or packets may be retrieved by defining a packet sync pattern using the DefinePHPSyncHexPattern function or by defining both a size field and sync hex pattern using the same packet header processor name in the DefinePHPPacketSizeField and DefinePHPSyncHexPattern functions. If the TCP socket does not have an associated packet header processor, it can only provide packet segments and not complete packets to the user. Packet statistics may be gathered by using the DefinePHPPacketKeyField function and the DefinePHPPacketSequenceCountField function.
[in] | php_name | A user friendly name for the packet header processor. |
[in] | device_key | A character string that uniquely identifies each device. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION ConnectSocketDevice | ( | const char * | device_key, |
const char * | ip_address_to_connect_to, | ||
unsigned short | port_to_connect_to, | ||
unsigned int | connection_timeout_msec | ||
) |
Connect a TCP client socket to a TCP listener's server socket.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | ip_address_to_connect_to | A character string containing the IP address of the socket that will accept the connection request. |
[in] | port_to_connect_to | The port number of the the socket that will accept the connection request. |
[in] | connection_timeout_msec | The length of time to wait for a connection to complete (2000 milli-seconds is an appropriate default value). |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION CreateBPDevice | ( | unsigned int | source_service_number, |
unsigned int | lifespan, | ||
bp_class_of_service_type | cos, | ||
unsigned int | ordinal, | ||
bp_transmission_mode_type | mode, | ||
bp_criticality_type | criticality, | ||
unsigned int * | device_key_buffer_size_ptr, | ||
char * | device_key | ||
) |
Creates a Bundle Protocol (BP) device that attaches to ION's BP library. ION's BP application must be running prior to creating the BP device.
[in] | source_service_number | The unsigned integer value service number that associates the device with ION's configured BP service. | ||||||||
[in] | lifespan | The bundle's time to live. | ||||||||
[in] | cos | The BP class of service priority. The bp_class_of_service_type is defined in the file "bp_shared.h" as follows:
| ||||||||
[in] | ordinal | Only valid for expedited priority bundle transfer. Range from 0-254 with 254 as highest priority | ||||||||
[in] | mode | The BP transmission mode. The bp_transmission_mode_type is defined in the file "bp_shared.h" as follows:
| ||||||||
[in] | criticality | The BP cricality. The bp_criticality_type is defined in the file "bp_shared.h" as follows:
| ||||||||
[in,out] | device_key_buffer_size_ptr | The size of the buffer that will hold the device key character string. Set to MAX_DEVICE_KEY_SIZE of 100 bytes. | ||||||||
[out] | device_key | A character string that uniquely identifies each device. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION CreateDeviceKeyAlias | ( | const char * | device_key, |
const char * | device_key_alias | ||
) |
Create a user friendly name/alias and associate it with a device key.
All subsequent function calls that require a device key may use the alias instead of the device key.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | device_key_alias | A character string containing the alias for the device key. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION CreateIPv4MulticastUDPSocketDevice | ( | unsigned short | port, |
unsigned int | receive_queue_size, | ||
unsigned int | receive_buffer_size, | ||
boolean_type | disable_loopback_flag, | ||
unsigned int * | device_key_buffer_size_ptr, | ||
char * | device_key | ||
) |
Creates a UDP socket to send and receive IP version 4 multicast packets at the specified port. UDP protocal does not guarantee delivery of the packet or packets being received in the order they were sent.
An optional receive queue may be created and associated with a UDP socket to minimizes the chances of the UDP socket dropping packets due to high packet rates or a bursty network. If the expected packet rate exceeds 100 packets per second, a receive queue may be required to avoid dropping packets. However, a receive queue does require additional memory allocations. A general rule is to size the queue to match the maximum number of packets per second.
The multicast socket must join a multicast group by calling JoinMulticastGroup prior to receiving packets sent to the IP multicast group address.
[in] | port | The port number that is used to create the socket. Avoid most reserved port number by picking values greater than 6000 or if the port is just being used to send packets use 0 which lets the computer choose any available port number. | ||||||
[in] | receive_queue_size | The maximum number of packets that can be received from the network and stored in the queue prior to dropping packets. | ||||||
[in] | receive_buffer_size | The size of each individual buffer in the queue. Set to the maximum expected receive packet size in bytes. | ||||||
[in] | disable_loopback_flag | Set this boolean_type variable to TRUE_OR_YES to prevent this socket from receiving multicast packets that it sends to a multicast group that it has joined. In addition, this variable will prevent this socket from receving multicast packets that are sent from other sockets that are using this socket's network interface card. The boolean_type is defined in the file "ds_shared.h" as follows:
| ||||||
[in,out] | device_key_buffer_size_ptr | The size of the buffer that will hold the device key character string. Set to MAX_DEVICE_KEY_SIZE of 100 bytes. | ||||||
[out] | device_key | A character string that uniquely identifies each device. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION CreateTCPClientSocketDevice | ( | const char * | ip_address, |
unsigned short | port, | ||
unsigned int | receive_queue_size, | ||
unsigned int | receive_buffer_size, | ||
unsigned int * | device_key_buffer_size_ptr, | ||
char * | device_key | ||
) |
Creates a TCP client socket. The client socket must make a separate connection request to a TCP listener sockets and connect to the listener's server socket. TCP protocal guarantees delivery of the packets in the order they were sent although it may break the packets up into segments that must be reassembled by the receiving application.
An optional receive queue may be created and associated with a TCP socket to improve performance due to high packet rates or a bursty network. If the expected packet rate exceeds 100 packets per second, a receive queue may help peformance. However, a receive queue does require additional memory allocations. A general rule is to size the queue to match the maximum number of packets per second.
A TCP client socket must send a connection request to a listener socket by calling ConnectSocketDevice prior to sending or receiving packets. In addition, if the TCP client socket is receiving packets the protocol may group or divide packets into segments which must be processed to retrieve individual packets.
If each packet has a predefined header with a packet size parameter, then the packets may be retrieved from the segments by defining the location of the packet size parameter using the DefinePHPPacketSizeField or by defining a packet sync pattern using DefinePHPSyncHexPattern function. A Packet Header Processor or PHP is associatied the with the TCP client socket using the AddPacketHeaderProcessor function. If the TCP client socket does not have an associated packet header processor, it can only provide packet segments and not complete packets to the user.
[in] | ip_address | The IP addess used to create the socket. |
[in] | port | The port number that is used to create the socket. Avoid most reserved port numbers by picking values greater than 6000 or use zero and let the computer choose an available port number. |
[in] | receive_queue_size | The maximum number of packets that can be received from the network and stored in the queue prior to dropping packets. |
[in] | receive_buffer_size | The size of each individual buffer in the queue. Set to the maximum expected receive packet size in bytes. |
[in,out] | device_key_buffer_size_ptr | The size of the buffer that will hold the device key character string. Set to MAX_DEVICE_KEY_SIZE of 100 bytes. |
[out] | device_key | A character string that uniquely identifies each device. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION CreateTCPListenerSocketDevice | ( | const char * | ip_address, |
unsigned short | port, | ||
unsigned int | receive_queue_size, | ||
unsigned int | receive_buffer_size, | ||
unsigned int * | device_key_buffer_size_ptr, | ||
char * | device_key | ||
) |
Creates a TCP listener socket. The listener socket accepts and connects client sockets to newly created server sockets. TCP protocal guarantees delivery of the packets in the order they were sent although it may break the packets up into segments that must be reassembled by the receiving application.
An optional receive queue may be created and associated with a TCP socket to improve performance due to high packet rates or a bursty network. If the expected packet rate exceeds 100 packets per second, a receive queue may help peformance. However, a receive queue does require additional memory allocations. A general rule is to size the queue to match the maximum number of packets per second.
If the TCP server sockets created by the listener are receiving packets the protocol may group or divide packets into segments which must be processed to retrieve individual packets.
If each packet has a predefined header with a packet size parameter, then the packets may be retrieved from the segments by defining the location of the packet size parameter using the DefinePHPPacketSizeField function or by defining a packet sync pattern using DefinePHPSyncHexPattern function. A Packet Header Processor or PHP is associatied with the the TCP listener socket using the AddPacketHeaderProcessor function. If the TCP listener socket does not have an asscoiated packet header processor, it can only provide packet segments and not complete packets to the user.
[in] | ip_address | The IP addess used to create the socket. |
[in] | port | The port number that is used to create the socket. Avoid most reserved port number by picking values greater than 6000 or if the port is just being used to send packets use 0 which lets the computer choose any available port number. |
[in] | receive_queue_size | The maximum number of packets that can be received from the network and stored in the queue prior to dropping packets. |
[in] | receive_buffer_size | The size of each individual buffer in the queue. Set to the maximum expected receive packet size in bytes. |
[in,out] | device_key_buffer_size_ptr | The size of the buffer that will hold the device key character string. Set to MAX_DEVICE_KEY_SIZE of 100 bytes. |
[out] | device_key | A character string that uniquely identifies each device. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION CreateUnicastUDPSocketDevice | ( | const char * | ip_address, |
unsigned short | port, | ||
unsigned int | receive_queue_size, | ||
unsigned int | receive_buffer_size, | ||
unsigned int * | device_key_buffer_size_ptr, | ||
char * | device_key | ||
) |
Creates a UDP socket to send and receive packets at the specified IP address and port. UDP protocal does not guarantee delivery of the packet or packets being received in the order they were sent.
An optional receive queue may be created and associated with a UDP socket to minimizes the chances of the UDP socket dropping packets due to high packet rates or a bursty network. If the expected packet rate exceeds 100 packets per second, a receive queue may be required to avoid dropping packets. However, a receive queue does require additional memory allocations. A general rule is to size the queue to match the maximum number of packets per second.
[in] | ip_address | The IP addess used to create the socket. |
[in] | port | The port number that is used to create the socket. Avoid most reserved port number by picking values greater than 6000 or if the port is just being used to send packets use 0 which lets the computer choose any available port number. |
[in] | receive_queue_size | The maximum number of packets that can be received from the network and stored in the queue prior to dropping packets. |
[in] | receive_buffer_size | The size of each individual buffer in the queue. Set to the maximum expected receive packet size in bytes. |
[in,out] | device_key_buffer_size_ptr | The size of the buffer that will hold the device key character string. Set to MAX_DEVICE_KEY_SIZE of 100 bytes. |
[out] | device_key | A character string that uniquely identifies each device. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION CreateUnixLocalClientSocketDevice | ( | const char * | name, |
unsigned int | receive_queue_size, | ||
unsigned int | receive_buffer_size, | ||
unsigned int * | device_key_buffer_size_ptr, | ||
char * | device_key | ||
) |
Creates a Unix local client socket for interprocess communication on a Linux operating system using a unique name and an abstract name space.
An optional receive queue may be created and associated with the socket.
[in] | name | A unique name defining the communication endpoints. |
[in] | receive_queue_size | The maximum number of packets that can be received from the server and stored in the queue prior to blocking. |
[in] | receive_buffer_size | The size of each individual buffer in the queue. Set to the maximum expected receive packet size in bytes. |
[in,out] | device_key_buffer_size_ptr | The size of the buffer that will hold the device key character string. Set to MAX_DEVICE_KEY_SIZE of 100 bytes. |
[out] | device_key | A character string that uniquely identifies each device. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION DefinePHPFixedPacketSize | ( | const char * | php_name, |
unsigned int | fixed_packet_size | ||
) |
Defines the size of all the packets that will be recieved by a device that is associated with this new or existing packet header processor.
If a TCP socket is receiving packets the protocol may group or divide packets into segments which must be processed to retrieve inidividual packets.
If each packet is a fixed size, then the packets may be retrieved from packet segments by associating the TCP socket with the packet header processor using the AddPacketHeaderProcessor function. If the socket does not have an asscoiated packet header processor, it can only provide packet segments and not complete packets to the user.
[in] | php_name | A user friendly name for the packet header processor. |
[in] | fixed_packet_size | The fixed size of the packet. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION DefinePHPPacketKeyField | ( | const char * | php_name, |
const char * | packet_key_name, | ||
unsigned int | byte_offset, | ||
unsigned int | bit_offset, | ||
unsigned int | length_in_bits, | ||
endian_byte_order | byte_order | ||
) |
Defines the location of a packet key field in a new or existing packet header. All byte and bit offsets start at zero and are numbered from from left to right.
By defining the location of one or more packet keys in a packet header, it is possible to identify and record packet statistics for different packets
during packet reception by a device such as a socket. The socket device must be associated with the packet header processor using the AddPacketHeaderProcessor function and statistics recording must be turned on using the StartRecordingStatSnapshot function. The packet key string that is associated with the packet is a dotted numeric string of key field values.
[in] | php_name | A user friendly name for the packet header processor. | ||||||
[in] | packet_key_name | A name for the packet key field. | ||||||
[in] | byte_offset | The byte offset to the start of the packet sequence count field starting at byte zero. | ||||||
[in] | bit_offset | The bit offset to the start of the packet sequence count field starting at bit zero. | ||||||
[in] | length_in_bits | The length of the packet sequence count field in bits. The length may not exceed 32 bits. | ||||||
[in] | byte_order | Set the endian_byte_order variable to BIG_ENDIAN_ORDER or LITTLE_ENDIAN_ORDER to define multi-byte parameters in the packet header. The endian_byte_order is defined in the file "ds_shared.h" as follows:
|
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION DefinePHPPacketSequenceCountField | ( | const char * | php_name, |
unsigned int | byte_offset, | ||
unsigned int | bit_offset, | ||
unsigned int | length_in_bits, | ||
endian_byte_order | byte_order | ||
) |
Defines the location of a packet sequence count in a new or existing packet header. All byte and bit offsets start at zero and are numbered from from left to right.
By defining the location of a packet sequence count in a packet header, it is possible to detect and record the number of packet sequence errors that occur during packet reception by a device such as a socket. The socket device must be associated with the packet header processor using the AddPacketHeaderProcessor function and statistics recording must be turned on using the StartRecordingStatSnapshot function.
[in] | php_name | A user friendly name for the packet header processor. | ||||||
[in] | byte_offset | The byte offset to the start of the packet sequence count field starting at byte zero. | ||||||
[in] | bit_offset | The bit offset to the start of the packet sequence count field starting at bit zero. | ||||||
[in] | length_in_bits | The length of the packet sequence count field in bits. The length may not exceed 32 bits. | ||||||
[in] | byte_order | Set the endian_byte_order variable to BIG_ENDIAN_ORDER or LITTLE_ENDIAN_ORDER to define multi-byte parameters in the packet header. The endian_byte_order is defined in the file "ds_shared.h" as follows:
|
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION DefinePHPPacketSizeField | ( | const char * | php_name, |
unsigned int | byte_offset, | ||
unsigned int | bit_offset, | ||
unsigned int | length_in_bits, | ||
long | size_offset_value, | ||
endian_byte_order | byte_order | ||
) |
Defines the location of a packet size field in a new or existing packet header. All byte and bit offsets start at zero and are numbered from from left to right.
If a TCP socket is receiving packets the protocol may group or divide packets into segments which must be processed to retrieve inidividual packets.
If each packet has a predefined header with a packet size parameter, then the packets may be retrieved from packet segments by defining the location of the packet size parameter or field. The TCP socket must then be associated with the packet header processor using the AddPacketHeaderProcessor function. If the socket does not have an associated packet header processor, it can only provide packet segments and not complete packets to the user.
[in] | php_name | A user friendly name for the packet header processor. | ||||||
[in] | byte_offset | The byte offset to the start of the packet size field starting at byte zero. | ||||||
[in] | bit_offset | The bit offset to the start of the packet size field starting at bit zero. | ||||||
[in] | length_in_bits | The length of the packet size field in bits. The length may not exceed 32 bits. | ||||||
[in] | size_offset_value | A value added to the packet size to account for additional bytes that were not included in the packet size parameter. | ||||||
[in] | byte_order | Set the endian_byte_order variable to BIG_ENDIAN_ORDER or LITTLE_ENDIAN_ORDER to define multi-byte parameters in the packet header. The endian_byte_order is defined in the file "ds_shared.h" as follows:
|
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION DefinePHPSyncHexPattern | ( | const char * | php_name, |
const char * | sync_hex_pattern, | ||
boolean_type | start_of_packet_sync_flag | ||
) |
Defines a synch pattern for packets that require synchronization in a new or existing packet header processor. The sync pattern is described in hexadecimal format.
Valid hexadecimal input formats include upper or lower case (e.g., FFAA1122 or ffaa1122), may not exceed eight bytes and must be on a byte boundary. The sync pattern may be at the start or end of the packet. If a sync pattern is at the start of a packet and no packet size field is defined, the last packet received by the socket will not be processed since a sync pattern must be received to identify the end of a packet.
[in] | php_name | A user friendly name for the packet header processor. | ||||||
[in] | sync_hex_pattern | The hexadecimal representation of the sync pattern. Input formats may be upper or lower case (e.g., FFAA1122 or ffaa1122), may not exceed eight bytes and must be on a byte boundary. | ||||||
[in] | start_of_packet_sync_flag | Set this boolean_type variable to TRUE_OR_YES if the sync pattern is at the start of the packet and not the end of the packet. The boolean_type is defined in the file "ds_shared.h" as follows:
|
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION DeleteDevice | ( | const char * | device_key | ) |
Decrements the device's use counter and if the device use counter is zero, all reference to the device are deleted and all device resources are released.
[in] | device_key | A character string that uniquely identifies each device. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION DSCleanUp | ( | ) |
Initiates a graceful shutdown of the Device Service library and all supporting device libraries, exits threads, and deallocates memory.
Example:
void EXPORT_THIS_TOOLKIT_DS_C_FUNCTION FreeIPAddressStructArrayMemoryAlloc | ( | ip_address_struct_type * | ip_address_struct_array_ptr | ) |
Frees the memory associated with the ip_address_struct_array_ptr that was returned by PopulateIPAddressStructArray.
Problems may develop when freeing the memory associated with the ip_address_struct_array_ptr if the DS library's compiler or run time environment does not match the application code's compiler or run time environment. This method is provided to avoid those problems by freeing the memory in the same library that allocated it.
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION GeneratePublicPrivateKeyPair | ( | const char * | public_key_pathname, |
const char * | private_key_pathname | ||
) |
Generates a public/private key pair based on Elliptic Curve Cryptography (ECC) using curve P-256.
The private key is wrapped/encrypted, prior to being stored in the private key file, using a default passphrase.
[in] | public_key_pathname | The path and file name of the file that will be created to store the public key. |
[in] | private_key_pathname | The path and file name of the file that will be created to store the private key. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION GeneratePublicPrivateKeyPairWithPassphrase | ( | const char * | public_key_pathname, |
const char * | private_key_pathname, | ||
const char * | crypt_user_passphrase | ||
) |
Generates a public/private key pair based on Elliptic Curve Cryptography (ECC) using curve P-256.
The private key is wrapped/encrypted, prior to being stored in the private key file, using a default passphrase or an optional user passphrase. If the user passphrase is an empty string, the private key will be wrapped using the default passphrase.
[in] | public_key_pathname | The path and file name of the file that will be created to store the public key. |
[in] | private_key_pathname | The path and file name of the file that will be created to store the private key. |
[in] | crypt_user_passphrase | The passphrase that is used to wrap/encrypt the private key prior to storing the key in the private key file. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION JoinMulticastGroup | ( | const char * | ip_address, |
const char * | multicast_group_address, | ||
const char * | device_key | ||
) |
Associates a mulitcast socket with a multicast group address. A multicast socket must join a multicast group by calling JoinMulticastGroup prior to receiving packets sent to the IP multicast group address.
[in] | ip_address | The default IP addess for packet transmission. | ||||||||||||||||||||
[in] | multicast_group_address | The multicast group address for receiving multicast packets.
| ||||||||||||||||||||
[in] | device_key | A character string that uniquely identifies each device. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION LogMessage | ( | message_category | category, |
const char * | message | ||
) |
Logs a user message in the log file. The maximum null terminated message size is 512 bytes.
[in] | category | The pertinent enum message_category are defined in the file "trek_toolkit_common_api_ansi.h" as follows:
| ||||||||||||
[in] | message | The message to be logged. |
Example:
void EXPORT_THIS_TOOLKIT_DS_C_FUNCTION PopulateIPAddressStructArray | ( | unsigned int * | number_of_ip_address_structs_ptr, |
ip_address_struct_type ** | ip_address_struct_array_ptr | ||
) |
Populates an array of ip_address_struct with the valid IP addresses of the host platform.
[out] | number_of_ip_address_structs_ptr | The number of ip_address_structs that are in the ip_address_struct_array. | ||||||||||||||||||||||||||||||
[out] | ip_address_struct_array_ptr | An array of ip_address_structs. The ip_address_struct_type is defined in the file "ds_shared.h" as follows:
|
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION ReceivePacketFromDevice | ( | const char * | device_key, |
unsigned int | receive_timeout, | ||
unsigned int * | packet_buffer_size_ptr, | ||
int * | packet_length_ptr, | ||
unsigned char * | packet_buffer_ptr, | ||
unsigned int * | message_code_ptr | ||
) |
Receive a packet from a device within a specified time period.
If the packet buffer is not large enough to hold the received packet then DS_PACKET_BUFFER_SIZE_ERROR is returned, the packet_buffer_size is updated with correct value for the packet buffer and the packet is dropped.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | receive_timeout | The time, in milli seconds, to wait for a packet from a device. |
[in] | packet_buffer_size_ptr | The size of the packet buffer. |
[out] | packet_length_ptr | The length of the packet. |
[out] | packet_buffer_ptr | The buffer containing the packet. |
[out] | message_code_ptr | An unsigned integer value describing the packet and defined in ds_shared.h |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION ReceivePacketFromSocketDevice | ( | const char * | device_key, |
unsigned int | receive_timeout, | ||
unsigned int * | packet_buffer_size_ptr, | ||
int * | packet_length_ptr, | ||
unsigned char * | packet_buffer_ptr, | ||
unsigned int * | message_code_ptr, | ||
unsigned int * | receive_from_ip_address_buffer_size_ptr, | ||
char * | received_from_ip_address, | ||
unsigned short * | received_from_port_ptr | ||
) |
Receive a packet from a socket device within a specified time period.
If the packet buffer is not large enough to hold the received packet then DS_PACKET_BUFFER_SIZE_ERROR is returned, the packet_buffer_size is updated with correct value for the packet buffer and the packet is dropped.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | receive_timeout | The time, in milli seconds, to wait for a packet from a device. |
[in] | packet_buffer_size_ptr | The size of the packet buffer. |
[out] | packet_length_ptr | The length of the packet. |
[in,out] | packet_buffer_ptr | The buffer containing the packet. |
[out] | message_code_ptr | An unsigned integer value describing the packet and defined in ds_shared.h |
[in,out] | receive_from_ip_address_buffer_size_ptr | The size of the received_from_ip_address buffer. |
[out] | received_from_ip_address | The IP address of the socket that sent the packet. |
[out] | received_from_port_ptr | The port number of the socket that sent the packet. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION RegisterAcceptConnection | ( | const char * | listener_device_key, |
int(*)(const char *listener_device_key, const char *server_device_key, const char *connected_ip_address, unsigned short connected_port) | function_ptr | ||
) |
Register a callback function to accept a connection request from a client socket.
[in] | listener_device_key | A character string that uniquely identifies a listener socket device. |
[in] | function_ptr | A pointer to the callback function. |
Callback function:
[out] | listener_device_key | A character string that uniquely identifies the listener socket device that created server server that received the connection request. |
[out] | server_device_key | A character string that uniquely identifies the server socket device that received the connection request. |
[out] | connected_ip_address | The IP address of the client socket that is making the connection request. |
[out] | connected_port | The port number of the client socket that is making the connection request. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION RegisterDropConnectionFromClient | ( | const char * | client_device_key, |
void(*)(const char *disconnected_client_device_key, const char *disconnected_remote_ip_address, unsigned short disconnected_remote_port) | function_ptr | ||
) |
Register a callback function to receive notification of a dropped connection when a client socket connection is dropped by its server.
[in] | client_device_key | A character string that uniquely identifies the client socket device. |
[in] | function_ptr | A pointer to the callback function. |
Callback function:
[out] | disconnected_client_device_key | A character string that uniquely identifies the client socket device that was disconnected. |
[out] | disconnected_remote_ip_address | The IP address of the listener socket that accepted the connection. |
[out] | disconnected_remote_port | The port number of the listener socket that accepted the connection. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION RegisterDropConnectionFromListener | ( | const char * | listener_device_key, |
void(*)(const char *listener_device_key, const char *disconnected_server_device_key, const char *disconnected_remote_ip_address, unsigned short disconnected_remote_port) | function_ptr | ||
) |
Register a callback function to receive notification of a dropped connection when a listener's server socket connection is dropped by its client.
[in] | listener_device_key | A character string that uniquely identifies the listener socket device that created server socket. |
[in] | function_ptr | A pointer to the callback function. |
Callback function:
[out] | listener_device_key | A character string that uniquely identifies the listener socket device that created the server socket that was disconnected. |
[out] | disconnected_server_device_key | A character string that uniquely identifies the server socket device that was disconnected. |
[out] | disconnected_remote_ip_address | The IP address of the client socket that dropped the connection. |
[out] | disconnected_remote_port | The port number of the client socket that dropped the connection. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION RegisterMessage | ( | void(*)(message_struct_type *message_struct_ptr) | function_ptr | ) |
Register a callback function to receive and process messages issued by the DS library.
[in] | function_ptr | A pointer to the callback function. |
Callback function:
[out] | message_struct_ptr | message structure defined in trek_toolkit_common_api_ansi_c.h as follows:
|
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION RegisterReceivePacket | ( | const char * | device_key, |
void(*)(const char *key, int packet_length, unsigned char *packet_buffer_ptr) | function_ptr | ||
) |
Register a callback function to receive packets from a device.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | function_ptr | A pointer to the callback function. |
Callback function:
[out] | key | A character string that is defined by the device that is receiving packets (for BP devices the key string is formatted as follows: <source node number>.<source service number> (e.g., 1.64) |
[out] | packet_length | The length of the packet. |
[out] | packet_buffer_ptr | The buffer containing the packet. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION RegisterReceivePacketFromSocket | ( | const char * | device_key, |
void(*)(const char *device_key, int packet_length, unsigned char *packet_buffer_ptr, const char *received_from_ip_address, unsigned short received_from_port) | function_ptr | ||
) |
Register a callback function to receive packets from a socket device.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | function_ptr | A pointer to the callback function. |
Callback function:
[out] | device_key | A character string that uniquely identifies each device. |
[out] | packet_length | The length of the packet. |
[out] | packet_buffer_ptr | The buffer containing the packet. |
[out] | received_from_ip_address | The IP address of the socket that sent the packet. |
[out] | recieved_from_port | The port number of the socket that sent the packet. |
Example:
void EXPORT_THIS_TOOLKIT_DS_C_FUNCTION ResetStatistics | ( | ) |
Resets or zero's the device and packet statistics.
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION SendPacket | ( | const char * | device_key, |
int | packet_length, | ||
unsigned char * | packet_buffer_ptr | ||
) |
Sends a packet to a device.
If the device is a TCP client socket, a packet is sent to the connected server socket. If the device is a TCP listener socket a packet is sent from all the TCP listener socket's server sockets to the each server's connected client socket.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | packet_length | The length of the packet. |
[in] | packet_buffer_ptr | A buffer containing the packet. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION SendPacketFromBPDevice | ( | const char * | device_key, |
int | packet_length, | ||
unsigned char * | packet_buffer_ptr, | ||
long long | destination_node_number, | ||
unsigned int | destination_service_number | ||
) |
Sends a packet from a bundle protocol device to the destination node.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | packet_length | The length of the packet. |
[in] | packet_buffer_ptr | A buffer containing the packet. |
[in] | destination_node_number | The node number that will receive the bundle. |
[in] | destination_service_number | The unsigned integer value service number that associates the destination device with ION's configured BP service. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION SendPacketFromTCPServerSocketDevice | ( | const char * | listener_device_key, |
const char * | server_device_key, | ||
int | packet_length, | ||
unsigned char * | packet_buffer_ptr | ||
) |
Sends a packet from a TCP server socket device to the connected client socket device.
[in] | listener_device_key | A character string that identifies listener socket device. |
[in] | server_device_key | A character string that identifies server socket device. Set to "" to send packet from all server devices currently associated with the listener device. |
[in] | packet_length | The length of the packet. |
[in] | packet_buffer_ptr | A buffer containing the packet. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION SendPacketFromUDPSocketDevice | ( | const char * | device_key, |
int | packet_length, | ||
unsigned char * | packet_buffer_ptr, | ||
const char * | send_to_ip_address, | ||
unsigned short | send_to_port | ||
) |
Sends a packet from UDP socket device to the IP address and port number of a corresponding UDP socket device.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | packet_length | The length of the packet. |
[in] | packet_buffer_ptr | A buffer containing the packet. |
[in] | send_to_ip_address | The IP address of the UDP socket that will receive the packet. |
[in] | send_to_port | The port number of the UDP socket that will receive the packet. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION SetMulticastTTL | ( | const char * | device_key, |
unsigned short | multicast_ttl | ||
) |
Sets the time to live for a socket that is sending packets to a multicast address.
Multicast time-to-live indicates the scope or range in which a packet may be forwarded. The default value is one.
[in] | device_key | A character string that uniquely identifies each device. | ||||||||||||||
[in] | multicast_ttl | Time to live for multicast packet.
|
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION SetTCPKeepalive | ( | const char * | device_key, |
unsigned long | keepalive_time, | ||
unsigned long | keepalive_interval, | ||
unsigned long | keepalive_probes | ||
) |
Sets the TCP keepalive parameters to determine whether the TCP connection is still up and running or has broken.
[in] | device_key | A character string that uniquely identifies each device. |
[in] | keepalive_time | The timeout, in seconds, with no activity until the first keepalive packet is sent. |
[in] | keepalive_interval | The interval, in seconds, when successive keep-alive packets are sent if no acknowledgement is received. |
[in] | keepalive_probes | The number of consecutive probes/packets that are sent without an acknowledgement prior to declaring the connection broken. |
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION StartLoggingMessages | ( | const char * | log_file_path, |
const char * | log_filename, | ||
boolean_type | log_debug_messages | ||
) |
Starts logging messages to a file.
[in] | log_file_path | The path of the log file. If an empty string is provided, the default path is the user's home directory. | ||||||
[in] | log_filename | The base file name of the log file. When logging is stopped, this name will be concatenated with a GMT time string. | ||||||
[in] | log_debug_messages | Set this boolean_type variable to TRUE_OR_YES to log debug messages. The boolean_type is defined in the file "ds_shared.h" as follows:
|
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION StartRecordingStatSnapshot | ( | const char * | record_file_path, |
const char * | record_filename, | ||
boolean_type | record_packet_statistics_flag | ||
) |
Starts recording a snapshot of the current statistics to a file.
The snapshot is updated once a second with the latest statistics. Previous statistic snapshots are overwritten.
[in] | record_file_path | The path of the record file. If an empty string is provided, the default path is the user's home directory. | ||||||
[in] | record_filename | The base filename of the log file. When recording is stopped, this name will be concatenated with a GMT time string. | ||||||
[in] | record_packet_statistics_flag | Set this boolean_type variable to TRUE_OR_YES to log both device and packet statistics messages. The boolean_type is defined in the file "ds_shared.h" as follows:
|
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION StopLoggingMessages | ( | ) |
Stops logging messages to a file, closes the log file and renames the log file by concatenating the log file name with a GMT time string.
Example:
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION StopLoggingMessagesEx | ( | char * | time_tagged_log_file_name | ) |
Stops logging messages to a file, closes the log file and renames the log file by concatenating the log file name with a GMT time string and returns the new file name.
Example:
void EXPORT_THIS_TOOLKIT_DS_C_FUNCTION StopRecordingStatSnapshot | ( | ) |
Stops recording statisitics to a file, closes the record file and renames the record file by concatenating the record file name with a GMT time string.
Example: