Files | |
file | nettest.c |
Networking test support functions implementation. | |
file | nettest.h |
Networking test support functions. | |
file | nettest1.c |
Networking test 1 application - sockets. | |
file | nettest2.c |
Networking test 2 application - transfer. | |
Defines | |
#define | NAME "Nettest1" |
Echo module name. | |
#define | NETTEST1_TEXT "Networking test 1 - sockets" |
Packet data pattern. | |
#define | NAME "Nettest2" |
Echo module name. | |
#define | NETTEST2_TEXT "Networking test 2 - transfer" |
Packet data pattern. | |
Functions | |
int | sockets_create (int verbose, int *socket_ids, int sockets, int family, sock_type_t type) |
Creates new sockets. | |
int | sockets_close (int verbose, int *socket_ids, int sockets) |
Closes sockets. | |
int | sockets_connect (int verbose, int *socket_ids, int sockets, struct sockaddr *address, socklen_t addrlen) |
Connects sockets. | |
int | sockets_sendto (int verbose, int *socket_ids, int sockets, struct sockaddr *address, socklen_t addrlen, char *data, int size, int messages) |
Sends data via sockets. | |
int | sockets_recvfrom (int verbose, int *socket_ids, int sockets, struct sockaddr *address, socklen_t *addrlen, char *data, int size, int messages) |
Receives data via sockets. | |
int | sockets_sendto_recvfrom (int verbose, int *socket_ids, int sockets, struct sockaddr *address, socklen_t *addrlen, char *data, int size, int messages) |
Sends and receives data via sockets. | |
void | print_mark (int index) |
Prints a mark. | |
int | main (int argc, char *argv[]) |
Module entry point. | |
void | nettest1_print_help (void) |
Prints the application help. | |
void | nettest1_refresh_data (char *data, size_t size) |
Refreshes the data. | |
void | nettest2_print_help (void) |
Prints the application help. | |
void | nettest2_refresh_data (char *data, size_t size) |
Refreshes the data. |
#define NAME "Nettest2" |
Echo module name.
#define NAME "Nettest1" |
Echo module name.
#define NETTEST1_TEXT "Networking test 1 - sockets" |
Packet data pattern.
Referenced by nettest1_refresh_data().
#define NETTEST2_TEXT "Networking test 2 - transfer" |
Packet data pattern.
Referenced by nettest2_refresh_data().
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Module entry point.
Starts testing.
[in] | argc | The number of command line parameters. |
[in] | argv | The command line parameters. |
References AF_INET, AF_INET6, EAFNOSUPPORT, ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, ERROR_PROPAGATE, htons, inet_pton(), NAME, nettest2_print_help(), nettest2_refresh_data(), parse_parameter_int(), parse_parameter_name_int(), parse_protocol_family(), parse_socket_type(), PF_INET, PF_INET6, print_unrecognized(), in6_addr::s6_addr, in_addr::s_addr, sockaddr_in6::sin6_addr, sockaddr_in6::sin6_family, sockaddr_in6::sin6_port, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_DGRAM, SOCK_STREAM, sockets_close(), sockets_connect(), sockets_create(), sockets_recvfrom(), sockets_sendto(), and sockets_sendto_recvfrom().
void nettest1_print_help | ( | void | ) |
Prints the application help.
void nettest1_refresh_data | ( | char * | data, | |
size_t | size | |||
) |
Refreshes the data.
Fills the data block with the NETTEST1_TEXT pattern.
[out] | data | The data block. |
[in] | size | The data block size in bytes. |
References NETTEST1_TEXT.
void nettest2_print_help | ( | void | ) |
void nettest2_refresh_data | ( | char * | data, | |
size_t | size | |||
) |
Refreshes the data.
Fills the data block with the NETTEST1_TEXT pattern.
[out] | data | The data block. |
[in] | size | The data block size in bytes. |
References NETTEST2_TEXT.
Referenced by main().
void print_mark | ( | int | index | ) |
Prints a mark.
If the index is a multiple of ten, a different mark is printed.
[in] | index | The index of the mark to be printed. |
int sockets_close | ( | int | verbose, | |
int * | socket_ids, | |||
int | sockets | |||
) |
Closes sockets.
[in] | verbose | A value indicating whether to print out verbose information. |
[in] | socket_ids | A field of stored socket identifiers. |
[in] | sockets | The number of sockets in the field. Should be at most the size of the field. |
Referenced by main().
int sockets_connect | ( | int | verbose, | |
int * | socket_ids, | |||
int | sockets, | |||
struct sockaddr * | address, | |||
socklen_t | addrlen | |||
) |
Connects sockets.
[in] | verbose | A value indicating whether to print out verbose information. |
[in] | socket_ids | A field of stored socket identifiers. |
[in] | sockets | The number of sockets in the field. Should be at most the size of the field. |
[in] | address | The destination host address to connect to. |
[in] | addrlen | The length of the destination address in bytes. |
Referenced by main().
int sockets_create | ( | int | verbose, | |
int * | socket_ids, | |||
int | sockets, | |||
int | family, | |||
sock_type_t | type | |||
) |
Creates new sockets.
[in] | verbose | A value indicating whether to print out verbose information. |
[out] | socket_ids | A field to store the socket identifiers. |
[in] | sockets | The number of sockets to create. Should be at most the size of the field. |
[in] | family | The socket address family. |
[in] | type | The socket type. |
Referenced by main().
int sockets_recvfrom | ( | int | verbose, | |
int * | socket_ids, | |||
int | sockets, | |||
struct sockaddr * | address, | |||
socklen_t * | addrlen, | |||
char * | data, | |||
int | size, | |||
int | messages | |||
) |
Receives data via sockets.
[in] | verbose | A value indicating whether to print out verbose information. |
[in] | socket_ids | A field of stored socket identifiers. |
[in] | sockets | The number of sockets in the field. Should be at most the size of the field. |
[in] | address | The source host address of received datagrams. |
[in,out] | addrlen | The maximum length of the source address in bytes. The actual size of the source address is set instead. |
[out] | data | The received data. |
[in] | size | The maximum data size in bytes. |
[in] | messages | The number of datagrams per socket to be received. |
Referenced by main().
int sockets_sendto | ( | int | verbose, | |
int * | socket_ids, | |||
int | sockets, | |||
struct sockaddr * | address, | |||
socklen_t | addrlen, | |||
char * | data, | |||
int | size, | |||
int | messages | |||
) |
Sends data via sockets.
[in] | verbose | A value indicating whether to print out verbose information. |
[in] | socket_ids | A field of stored socket identifiers. |
[in] | sockets | The number of sockets in the field. Should be at most the size of the field. |
[in] | address | The destination host address to send data to. |
[in] | addrlen | The length of the destination address in bytes. |
[in] | data | The data to be sent. |
[in] | size | The data size in bytes. |
[in] | messages | The number of datagrams per socket to be sent. |
Referenced by main().
int sockets_sendto_recvfrom | ( | int | verbose, | |
int * | socket_ids, | |||
int | sockets, | |||
struct sockaddr * | address, | |||
socklen_t * | addrlen, | |||
char * | data, | |||
int | size, | |||
int | messages | |||
) |
Sends and receives data via sockets.
Each datagram is sent and a reply read consequently. The next datagram is sent after the reply is received.
[in] | verbose | A value indicating whether to print out verbose information. |
[in] | socket_ids | A field of stored socket identifiers. |
[in] | sockets | The number of sockets in the field. Should be at most the size of the field. |
[in,out] | address | The destination host address to send data to. The source host address of received datagrams is set instead. |
[in] | addrlen | The length of the destination address in bytes. |
[in,out] | data | The data to be sent. The received data are set instead. |
[in] | size | The data size in bytes. |
[in] | messages | The number of datagrams per socket to be received. |
Referenced by main().