Networking tests
[Applications]


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   "Nettest2"
 Echo module name.
#define NAME   "Nettest1"
 Echo module name.
#define NETTEST1_TEXT   "Networking test 1 - sockets"
 Packet data pattern.
#define NETTEST2_TEXT   "Networking test 2 - transfer"
 Packet data pattern.

Functions

int main (int argc, char *argv[])
static void nettest1_fill_buffer (char *buffer, size_t size)
 Fill buffer with the NETTEST1_TEXT pattern.
static int nettest1_parse_opt (int argc, char *argv[], int *index)
 Parse one command-line option.
static void nettest1_print_help (void)
static int nettest1_test (int *socket_ids, int nsockets, int nmessages)
static void nettest2_fill_buffer (char *buffer, size_t size)
 Fill buffer with the NETTEST2_TEXT pattern.
static int nettest2_parse_opt (int argc, char *argv[], int *index)
 Parse one command-line option.
static void nettest2_print_help (void)
void print_mark (int index)
 Prints a mark.
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_create (int verbose, int *socket_ids, int sockets, int family, sock_type_t type)
 Creates new 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 (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_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.

Variables

static struct sockaddraddress
static socklen_t addrlen
static char * data
static int family
static int family = PF_INET
static int messages
static int messages
static uint16_t port
static uint16_t port
static size_t size
static size_t size = 27
static int sockets
static int sockets
static sock_type_t type
static sock_type_t type = SOCK_DGRAM
static bool verbose
static int verbose = 0

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 287 of file nettest1.c.

static void nettest1_fill_buffer ( char *  buffer,
size_t  size 
) [static]

Fill buffer with the NETTEST1_TEXT pattern.

Parameters:
buffer Data buffer.
size Buffer size in bytes.

Definition at line 209 of file nettest1.c.

static int nettest1_parse_opt ( int  argc,
char *  argv[],
int *  index 
) [static]

Parse one command-line option.

Parameters:
argc Number of all command-line arguments.
argv All command-line arguments.
index Current argument index (in, out).

Definition at line 110 of file nettest1.c.

static void nettest2_fill_buffer ( char *  buffer,
size_t  size 
) [static]

Fill buffer with the NETTEST2_TEXT pattern.

Parameters:
buffer Data buffer.
size Buffer size in bytes.

Definition at line 105 of file nettest2.c.

static int nettest2_parse_opt ( int  argc,
char *  argv[],
int *  index 
) [static]

Parse one command-line option.

Parameters:
argc Number of all command-line arguments.
argv All command-line arguments.
index Current argument index (in, out).

Definition at line 126 of file nettest2.c.

void print_mark ( int  index  ) 

Prints a mark.

If the index is a multiple of ten, a different mark is printed.

Parameters:
[in] index The index of the mark to be printed.

Definition at line 277 of file nettest.c.

int sockets_close ( int  verbose,
int *  socket_ids,
int  sockets 
)

Closes sockets.

Parameters:
[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.
Returns:
EOK on success.

Other error codes as defined for the closesocket() function.

Definition at line 85 of file nettest.c.

int sockets_connect ( int  verbose,
int *  socket_ids,
int  sockets,
struct sockaddr address,
socklen_t  addrlen 
)

Connects sockets.

Parameters:
[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.
Returns:
EOK on success.

Other error codes as defined for the connect() function.

Definition at line 119 of file nettest.c.

int sockets_create ( int  verbose,
int *  socket_ids,
int  sockets,
int  family,
sock_type_t  type 
)

Creates new sockets.

Parameters:
[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.
Returns:
EOK on success.

Other error codes as defined for the socket() function.

Definition at line 54 of file nettest.c.

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.

Parameters:
[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.
Returns:
EOK on success.

Other error codes as defined for the recvfrom() function.

Definition at line 195 of file nettest.c.

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.

Parameters:
[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.
Returns:
EOK on success.

Other error codes as defined for the sendto() function.

Definition at line 155 of file nettest.c.

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.

Parameters:
[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.
Returns:
EOK on success.

Other error codes as defined for the recvfrom() function.

Definition at line 237 of file nettest.c.


Generated on Thu Jun 2 07:45:55 2011 for HelenOS/USB by  doxygen 1.4.7