TReK ANSI-C  5.3.3
All ANSI-C APIs
network_tcp/main.c
// ////////////////////////////////////////////////////////////////////////////
//
// Sample program sends and receives four packets via two TCP sockets and logs
// info and error messages. Program uses RegisterPrintMessage,
// StartLoggingMessages, CreateTCPClientSocketDevice, SetTCPKeepalive,
// CreateTCPListenerSocketDevice, CreateDeviceKeyAlias, ConnectSocketDevice,
// RegisterReceivePacketFromSocket, DefinePhpSyncHexPattern,
// DefinePhpPacketSizeField, RegisterAcceptConnection,
// RegisterDropConnectionFromClient, AddPacketHeaderProcessor and
// SendPacket API functions.
//
// ////////////////////////////////////////////////////////////////////////////
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include "ds_shared.h"
#include "trek_error.h"
#ifdef __linux__
#include <unistd.h>
#else
#include <windows.h>
#endif
// ////////////////////////////////////////////////////////////////////////////
//
// PrintTheMessage controls how messages are processed and displayed to
// the user.
//
// ////////////////////////////////////////////////////////////////////////////
void PrintTheMessage(message_struct_type *mess_struct_ptr)
{
if (mess_struct_ptr->category == MSG_CAT_INFO ||
mess_struct_ptr->category == MSG_CAT_INFO_ALERT ||
mess_struct_ptr->category == MSG_CAT_ERROR ||
mess_struct_ptr->category == MSG_CAT_WARNING ||
mess_struct_ptr->category == MSG_CAT_ERROR_ALERT)
{
printf("%s\t%s\n",GetMessageCategoryAsString(mess_struct_ptr->category),
mess_struct_ptr->message);
}
}
// ////////////////////////////////////////////////////////////////////////////
//
// ReceivePacket's packet_buffer_ptr points to the newly received packet.
//
// ////////////////////////////////////////////////////////////////////////////
void ReceivePacket (const char *device_key,
int packet_length,
unsigned char *packet_buffer_ptr,
const char *received_from_ip_address,
unsigned short recieved_from_port)
{
// Print the data zone packets.
printf("Data\t%s\n", (char *)packet_buffer_ptr + 5);
}
// ////////////////////////////////////////////////////////////////////////////
//
// AcceptConnection provides ip_address and port information about the client
// socket that is requesting a connection. Returning SUCCESS to accept the
// connection request, return FAIL to reject the connection request.
//
// ////////////////////////////////////////////////////////////////////////////
int AcceptConnection (const char *listener_device_key,
const char *server_device_key,
const char *connected_ip_address,
unsigned short connected_port)
{
printf("Info\tConnection request from IP address: %s and port: %d\n",
connected_ip_address,connected_port);
return(SUCCESS);
}
// ////////////////////////////////////////////////////////////////////////////
//
// DropConnection provides ip_address and port information about the client
// socket that is dropping a connection.
//
// ////////////////////////////////////////////////////////////////////////////
void DropConnection (const char *disconnected_client_device_key,
const char *disconnected_remote_ip_address,
unsigned short disconnected_remote_port)
{
printf("Info\tConnection dropped from IP address: %s and port: %d\n",
disconnected_remote_ip_address,disconnected_remote_port);
return;
}
// ////////////////////////////////////////////////////////////////////////////
//
// CreateDataPackets creates the data packets with a three byte header.
// The first three header bytes contains a sync hex pattern = fafbfc.
// The fourth and fifth header bytes contain the overall packet length in
// big endian byte order.
//
// ////////////////////////////////////////////////////////////////////////////
void CreateDataPackets(unsigned char *packet1_ptr,
unsigned char *packet2_ptr,
unsigned char *packet3_ptr,
unsigned char *packet4_ptr,
unsigned short *length1_ptr,
unsigned short *length2_ptr,
unsigned short *length3_ptr,
unsigned short *length4_ptr)
{
// Determine if this is a little endian or big endian platform.
unsigned short tester= 1;
unsigned char tester_byte[1];
unsigned char sync_pattern[3];
unsigned short big_endian_order = 1;
memcpy(tester_byte,&tester,1);
if (tester_byte[0] == 0x01)
{
big_endian_order = 0;
}
// Zero fill the packets prior to populating.
memset(packet1_ptr,0x00,50);
memset(packet2_ptr,0x00,50);
memset(packet3_ptr,0x00,50);
memset(packet4_ptr,0x00,50);
// Create a five byte header for all the packets. The header is populated
// with the sync bytes and a big endian two byte overall packet length.
// Populate packet data zone
strcpy((char *)packet1_ptr+5,"Mary had a little lamb");
strcpy((char *)packet2_ptr+5,"Its feet were black as soot");
strcpy((char *)packet3_ptr+5,"And into Mary's bread and jam ");
strcpy((char *)packet4_ptr+5,"Its sooty foot it put");
// Get packet length including 5 byte header and null terminator.
*length1_ptr = strlen((char *)packet1_ptr+5) + 6;
*length2_ptr = strlen((char *)packet2_ptr+5) + 6;
*length3_ptr = strlen((char *)packet3_ptr+5) + 6;
*length4_ptr = strlen((char *)packet4_ptr+5) + 6;
// Populate headers.
// Populate packet length field.
if (big_endian_order == 1)
{
memmove(packet1_ptr+3,length1_ptr,2);
memmove(packet2_ptr+3,length2_ptr,2);
memmove(packet3_ptr+3,length3_ptr,2);
memmove(packet4_ptr+3,length4_ptr,2);
}
else
{
memmove(packet1_ptr+4,length1_ptr,1);
memmove(packet2_ptr+4,length2_ptr,1);
memmove(packet3_ptr+4,length3_ptr,1);
memmove(packet4_ptr+4,length4_ptr,1);
}
// Populate sync field.
sync_pattern[0] = 0xfa;
sync_pattern[1] = 0xfb;
sync_pattern[2] = 0xfc;
memcpy(packet1_ptr,sync_pattern,3);
memcpy(packet2_ptr,sync_pattern,3);
memcpy(packet3_ptr,sync_pattern,3);
memcpy(packet4_ptr,sync_pattern,3);
return;
}
// ////////////////////////////////////////////////////////////////////////////
//
// PrintAvailableIPAddesses uses the PopulateIPAddressStructArray function to
// identify and print the host's available IPv4 and IPv6 addresses.
//
// ////////////////////////////////////////////////////////////////////////////
void PrintAvailableIPAddesses()
{
unsigned int number_of_ip_address_structs;
ip_address_struct_type *ip_address_struct_array_ptr = NULL;
ip_address_struct_type ip_address_struct;
unsigned int i;
PopulateIPAddressStructArray(&number_of_ip_address_structs,
&ip_address_struct_array_ptr);
printf("\nIP Addresses:\n\n");
for (i=0; i<number_of_ip_address_structs; i++)
{
ip_address_struct = ip_address_struct_array_ptr[i];
if (ip_address_struct_array_ptr[i].ip_address_version == IPV4)
{
printf("IPv4 address: %s\n",
ip_address_struct_array_ptr[i].ip_address);
}
else
{
switch (ip_address_struct_array_ptr[i].ip_address_v6_category)
{
printf("IPv6 address: %s\tIPv6 category: GLOBAL_FIXED\n",
ip_address_struct_array_ptr[i].ip_address);
break;
printf("IPv6 address: %s\tIPv6 category: GLOBAL_TEMPORARY\n",
ip_address_struct_array_ptr[i].ip_address);
break;
case LINK_LOCAL:
printf("IPv6 address: %s\tIPv6 category: LINK_LOCAL\n",
ip_address_struct_array_ptr[i].ip_address);
break;
printf("IPv6 address: %s\tIPv6 category: TAREDO_TUNNELING\n",
ip_address_struct_array_ptr[i].ip_address);
break;
printf("IPv6 address: %s\tIPv6 category: IPV6_TO_IPV4_TUNNELING\n",
ip_address_struct_array_ptr[i].ip_address);
break;
case MULTICAST:
printf("IPv6 address: %s\tIPv6 category: MULTICAST\n",
ip_address_struct_array_ptr[i].ip_address);
break;
case OTHER:
printf("IPv6 address: %s\tIPv6 category: OTHER\n",
ip_address_struct_array_ptr[i].ip_address);
break;
default:
printf("IPv6 address: %s\tIPv6 category: UNDEFINED_IP_ADDRESS_V6_CATEGORY\n",
ip_address_struct_array_ptr[i].ip_address);
break;
}
}
}
// NOTE: 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. The code, "free(ip_address_struct_array_ptr)"
// will work if the library and application code's compilers
// are the same.
FreeIPAddressStructArrayMemoryAlloc(ip_address_struct_array_ptr);
}
// ////////////////////////////////////////////////////////////////////////////
//
// Sample program sends and receives four packets via two TCP sockets and logs
// info and error messages. Program uses RegisterPrintMessage,
// StartLoggingMessages, CreateTCPClientSocketDevice, SetTCPKeepalive,
// CreateTCPListenerSocketDevice, CreateDeviceKeyAlias, ConnectSocketDevice,
// RegisterReceivePacketFromSocket, DefinePhpSyncHexPattern,
// DefinePhpPacketSizeField, RegisterAcceptConnection,
// RegisterDropConnectionFromClient, AddPacketHeaderProcessor and
// SendPacket API functions.
//
// ////////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[])
{
char ip_address[50];
unsigned short source_port;
unsigned short receive_port;
unsigned int receive_queue_size;
unsigned int receive_buffer_size;
char source_device_key[50];
char source_device_name[50];
char receive_device_key[50];
char receive_device_name[50];
unsigned char packet1[50];
unsigned char packet2[50];
unsigned char packet3[50];
unsigned char packet4[50];
unsigned char packets1_thru_4[200];
unsigned short length1;
unsigned short length2;
unsigned short length3;
unsigned short length4;
unsigned int key_buffer_size;
unsigned int byte_offset;
unsigned int bit_offset;
unsigned int length_in_bits;
long size_offset_value;
endian_byte_order byte_order;
char log_path[256];
char log_filename[256];
boolean_type start_of_packet_sync_flag;
char sync_hex_pattern[10];
char php_name[10];
unsigned long keepalive_time;
unsigned long keepalive_interval;
unsigned long keepalive_probes;
unsigned int connection_timeout_msec = 2100;
// Example code using the PopulateIPAddressStructArray function to print
// the host's available ip addresses.
PrintAvailableIPAddesses();
// Create data packets.
CreateDataPackets(packet1,
packet2,
packet3,
packet4,
&length1,
&length2,
&length3,
&length4);
// Register the PrintMessage callback function prior to InitToolkitCfdp
// to process error messages that may be generated during initialization.
RegisterMessage(&PrintTheMessage);
printf("\nNetwork TCP\n\n");
// Create a log file in the home/<username> or Users/<username> directory
// by passing a empty string for directory path. Only log error and
// information messages.
strcpy(log_path,"");
strcpy(log_filename,"network_tcp_log_file");
log_filename,
// Create a statistics file in the home/<username> or Users/<username> directory
// by passing a empty string for directory path. Only record device statistics
// and not packet statisitics.
strcpy(log_path,"");
strcpy(log_filename,"network_tcp_statistics_file");
log_filename,
// Create a TCP client source socket device
strcpy(ip_address,"127.0.0.1"); // Use loopback address
source_port = 20170; //20130;
// A receive queue is not required since this socket is only
// sending packets
receive_queue_size = 0;
receive_buffer_size = 0;
key_buffer_size = sizeof(source_device_key);
source_port,
receive_queue_size,
receive_buffer_size,
&key_buffer_size,
source_device_key) != SUCCESS)
{
return 0;
}
// Define a user friendly device name and associate the name with a device
// key. The device name is an alias for the device key and may
// be used in functions requiring a device key. The name must be unique
// for all devices. A device may not have multiple names.
strcpy(source_device_name,"TCP_client");
if (CreateDeviceKeyAlias(source_device_key,
source_device_name) != SUCCESS)
{
return 0;
}
// Sets the TCP keepalive parameters to determine whether the TCP
// connection is still up and running or if it has broken.
//
// keepalive_time The timeout, in seconds, with no activity until the first
// keepalive packet is sent.
// keepalive_interval The interval, in seconds, when successive keep-alive
// packets are sent if no acknowledgement is received.
// keepalive_probes The number of consecutive probes/packets that are sent
// without an acknowledgement prior to declaring the
// connection broken.
keepalive_time= 3600;
keepalive_interval = 300;
keepalive_probes = 10;
if (SetTCPKeepalive(source_device_key,
keepalive_time,
keepalive_interval,
keepalive_probes) != SUCCESS)
{
return 0;
}
// Create a TCP listener receive socket device.
receive_port = 20180; //20140;
// If the receive socket is receiving hundreds of packets a second and
// receive buffer minimizes the chances of packets being dropped.
receive_queue_size = 100;
receive_buffer_size = 100;
key_buffer_size = sizeof(receive_device_key);
receive_port,
receive_queue_size,
receive_buffer_size,
&key_buffer_size,
receive_device_key) != SUCCESS)
{
return 0;
}
// Define a user friendly device name and associate the name with a
// device key. The device name is an alias for the device key and may
// be used in functions requiring a device key. The name must be unique
// for all devices. A device may not have multiple names.
strcpy(receive_device_name,"TCP_listener");
if (CreateDeviceKeyAlias(receive_device_key,
receive_device_name) != SUCCESS)
{
return 0;
}
if (SetTCPKeepalive(receive_device_key,
keepalive_time,
keepalive_interval,
keepalive_probes) != SUCCESS)
{
return 0;
}
// Define a packet header processor by identifying the sync pattern
// (if any) and the location of the packet size field (if available) in
// the packet header associated with the packets that will be received by
// the receive device. The data packets for this example contain a five
// byte packet header that contains a three byte sync and two byte
// packet size field. The packet size field is populated with a 16 bit
// packet length value using big endian or network byte ordering.
// The given name of the packet header processor or php is "EXAMPLE".
byte_offset = 3; // Byte offset to first byte of the packet size
// field.
bit_offset = 0; // Bit offset to the beginning of the packet size
// field.
// NOTE: Byte and bit offsets are combined to
// determine the overall offset to the packet size.
length_in_bits = 16; // Length of the packet size field.
size_offset_value = 0; // Additional bytes that need to be added to the
// packet length contained in the header to get an
// overall packet length.
byte_order = BIG_ENDIAN_ORDER;
strcpy(sync_hex_pattern,"fafbfc");
strcpy(php_name,"EXAMPLE");
start_of_packet_sync_flag = TRUE_OR_YES;
// Create an instance of the "EXAMPE" packet header processor and define
// its sync pattern and packet size field.
sync_hex_pattern,
start_of_packet_sync_flag) != SUCCESS)
{
return 0;
}
byte_offset,
bit_offset,
length_in_bits,
size_offset_value,
byte_order) != SUCCESS)
{
return 0;
}
// Add the "EXAMPLE" php to the recieve socket device so the device can
// extract the packets from the TCP packet segments.
receive_device_name) != SUCCESS)
{
return 0;
}
// Associate the AcceptConnection callback function with the receive
// socket device so all connections are identified.
if (RegisterAcceptConnection (receive_device_name,
&AcceptConnection) != SUCCESS)
{
return 0;
}
// Associate the RegisterDropConnectionFromClient callback function with
// the receive socket device so all drop connections are identified.
if (RegisterDropConnectionFromClient (source_device_name,
&DropConnection) != SUCCESS)
{
return 0;
}
// Associate the RecieveDeviceData callback function with the receive
// socket device so all packets received by the device will
// be processed by RecieveDeviceData.
if (RegisterReceivePacketFromSocket (receive_device_name,
&ReceivePacket) != SUCCESS)
{
return 0;
}
// Connect the source or client socket to the recieve or listener socket.
// The listener socket will accept the client socket connection and create
// a server socket that is connected
// to the client socket.
if (ConnectSocketDevice(source_device_name,
ip_address,
receive_port,
connection_timeout_msec) != SUCCESS)
{
return 0;
}
// Sleep to allow connection to complete
#ifdef __linux__
sleep(1);
#else
Sleep(1000);
#endif
// Simulate TCP packet segmentation by combining packet 1 thru 4 in a
// single buffer which is sent in two packet segments. The receiving socket
// will assemble the four individual packets using the sync and packet size
// field in the header of each packet. Each assembled packet will be
// processed by the ReceiveDeviceData callback function. The source socket
// is connected to the receive socket so the SendPacket function does
// not requires a destination IP address and port for each transmission.
memcpy(packets1_thru_4,packet1,length1);
memcpy(packets1_thru_4+length1,packet2,length2);
memcpy(packets1_thru_4+length1+length2,packet3,length3);
memcpy(packets1_thru_4+length1+length2+length3,packet4,length4);
if (SendPacket (source_device_name,
length1+
length2+
length3/2,
packets1_thru_4) != SUCCESS)
{
return 0;
}
// Allow time to process seperate segments.
#ifdef __linux__
sleep(1);
#else
Sleep(1000);
#endif
if (SendPacket (source_device_name,
length3/2+length4,
packets1_thru_4+
length1+
length2+
length3/2) != SUCCESS)
{
return 0;
}
// Allow time to print messages.
#ifdef __linux__
sleep(1);
#else
Sleep(1000);
#endif
// Close the statistics file. A timetag is appended to the filename.
// Drop the connection by deleting the listener/receive socket instead
// of the client/sender socket so the Windows OS may immediately reuse
// the port to create another client socket. If a client socket is
// deleted or its connection is closed, the Windows OS will not release
// the port for reuse for 30 to 240 seconds.
DeleteDevice(receive_device_name);
// Allow time to print and log messages.
#ifdef __linux__
sleep(1);
#else
Sleep(1000);
#endif
// Close the log file. A timetag is appended to the log filename.
return 0;
}
Message codes and structure definition for the Device Service library.
endian_byte_order
Byte order enumeration.
Definition: ds_shared.h:97
@ BIG_ENDIAN_ORDER
Also known as network byte order. Most significant byte is first.
Definition: ds_shared.h:98
@ GLOBAL_FIXED
Global fixed.
Definition: ds_shared.h:130
@ MULTICAST
Multicast.
Definition: ds_shared.h:135
@ TAREDO_TUNNELING
Taredo tunneling.
Definition: ds_shared.h:133
@ IPV6_TO_IPV4_TUNNELING
IPv6 to IPv4 tunneling.
Definition: ds_shared.h:134
@ LINK_LOCAL
Link local.
Definition: ds_shared.h:132
@ OTHER
Other.
Definition: ds_shared.h:136
@ GLOBAL_TEMPORARY
GLobal temporary.
Definition: ds_shared.h:131
boolean_type
Boolean enumeration.
Definition: ds_shared.h:104
@ FALSE_OR_NO
False.
Definition: ds_shared.h:105
@ TRUE_OR_YES
True.
Definition: ds_shared.h:106
@ IPV4
IP version 4 address.
Definition: ds_shared.h:112
Structure of parameters needed for IP address identification.
Definition: ds_shared.h:180
Structure of parameters needed for message support.
Definition: trek_toolkit_common_api_ansi_c.h:74
char message[MAX_MESSAGE_SIZE]
Message.
Definition: trek_toolkit_common_api_ansi_c.h:77
enum message_category category
Message category (e.g., MSG_CAT_ERROR, MSG_CAT_ERROR_ALERT, MSG_CAT_WARNING, MSG_CAT_WARNING_ALERT,...
Definition: trek_toolkit_common_api_ansi_c.h:76
An ANSI C Data Service API.
void EXPORT_THIS_TOOLKIT_DS_C_FUNCTION StopRecordingStatSnapshot()
Stops recording statisitics to a file, closes the record file and renames the record file by concaten...
Definition: toolkit_ds_api_ansi_c.cpp:3621
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 offs...
Definition: toolkit_ds_api_ansi_c.cpp:2101
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 ...
Definition: toolkit_ds_api_ansi_c.cpp:1274
int EXPORT_THIS_TOOLKIT_DS_C_FUNCTION DSCleanUp()
Initiates a graceful shutdown of the Device Service library and all supporting device libraries,...
Definition: toolkit_ds_api_ansi_c.cpp:3843
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 fr...
Definition: toolkit_ds_api_ansi_c.cpp:2758
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 p...
Definition: toolkit_ds_api_ansi_c.cpp:2218
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 PopulateIPAddre...
Definition: toolkit_ds_api_ansi_c.cpp:3804
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.
Definition: toolkit_ds_api_ansi_c.cpp:4183
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 con...
Definition: toolkit_ds_api_ansi_c.cpp:4363
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.
Definition: toolkit_ds_api_ansi_c.cpp:3573
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 liste...
Definition: toolkit_ds_api_ansi_c.cpp:837
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 l...
Definition: toolkit_ds_api_ansi_c.cpp:3479
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.
Definition: toolkit_ds_api_ansi_c.cpp:1759
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.
Definition: toolkit_ds_api_ansi_c.cpp:3951
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 creat...
Definition: toolkit_ds_api_ansi_c.cpp:529
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 devic...
Definition: toolkit_ds_api_ansi_c.cpp:1329
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.
Definition: toolkit_ds_api_ansi_c.cpp:4088
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.
Definition: toolkit_ds_api_ansi_c.cpp:3760
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.
Definition: toolkit_ds_api_ansi_c.cpp:987
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.
Definition: toolkit_ds_api_ansi_c.cpp:3339
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.
Definition: toolkit_ds_api_ansi_c.cpp:910
Error codes for the DS API (starts at 50001)
Command codes for TReK.
#define SUCCESS
The function completed successfully.
Definition: trek_error.h:8
The commonly shared macros, structures and functions.
@ MSG_CAT_WARNING
Error warning.
Definition: trek_toolkit_common_api_ansi_c.h:58
@ MSG_CAT_INFO_ALERT
Information alert message (supports information alert pop up dialog box)
Definition: trek_toolkit_common_api_ansi_c.h:61
@ MSG_CAT_INFO
Information message.
Definition: trek_toolkit_common_api_ansi_c.h:60
@ MSG_CAT_ERROR
Error message.
Definition: trek_toolkit_common_api_ansi_c.h:56
@ MSG_CAT_ERROR_ALERT
Error alert message (supports error alert pop up dialog box)
Definition: trek_toolkit_common_api_ansi_c.h:57
const char EXPORT_THIS_TREK_TOOLKIT_COMMON_API_FUNCTION * GetMessageCategoryAsString(enum message_category input)
Converts an enumerated message category value into its equivalent character string.
Definition: trek_toolkit_common_api_ansi_c.cpp:45