source: mainline/uspace/app/nettest1/nettest.h@ f63a591d

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f63a591d was d9e2e0e, checked in by Jakub Jermar <jakub@…>, 15 years ago

Move the client socket code to the standard library.

  • Property mode set to 100644
File size: 6.1 KB
Line 
1/*
2 * Copyright (c) 2009 Lukas Mejdrech
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup nettest
30 * @{
31 */
32
33/** @file
34 * Networking test support functions.
35 */
36
37#ifndef __NET_TEST__
38#define __NET_TEST__
39
40#include <net/socket.h>
41
42/** Prints a mark.
43 * If the index is a multiple of ten, a different mark is printed.
44 * @param[in] index The index of the mark to be printed.
45 */
46extern void print_mark(int index);
47
48/** Creates new sockets.
49 * @param[in] verbose A value indicating whether to print out verbose information.
50 * @param[out] socket_ids A field to store the socket identifiers.
51 * @param[in] sockets The number of sockets to create. Should be at most the size of the field.
52 * @param[in] family The socket address family.
53 * @param[in] type The socket type.
54 * @returns EOK on success.
55 * @returns Other error codes as defined for the socket() function.
56 */
57extern int sockets_create(int verbose, int * socket_ids, int sockets, int family, sock_type_t type);
58
59/** Closes sockets.
60 * @param[in] verbose A value indicating whether to print out verbose information.
61 * @param[in] socket_ids A field of stored socket identifiers.
62 * @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
63 * @returns EOK on success.
64 * @returns Other error codes as defined for the closesocket() function.
65 */
66extern int sockets_close(int verbose, int * socket_ids, int sockets);
67
68/** Connects sockets.
69 * @param[in] verbose A value indicating whether to print out verbose information.
70 * @param[in] socket_ids A field of stored socket identifiers.
71 * @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
72 * @param[in] address The destination host address to connect to.
73 * @param[in] addrlen The length of the destination address in bytes.
74 * @returns EOK on success.
75 * @returns Other error codes as defined for the connect() function.
76 */
77extern int sockets_connect(int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen);
78
79/** Sends data via sockets.
80 * @param[in] verbose A value indicating whether to print out verbose information.
81 * @param[in] socket_ids A field of stored socket identifiers.
82 * @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
83 * @param[in] address The destination host address to send data to.
84 * @param[in] addrlen The length of the destination address in bytes.
85 * @param[in] data The data to be sent.
86 * @param[in] size The data size in bytes.
87 * @param[in] messages The number of datagrams per socket to be sent.
88 * @returns EOK on success.
89 * @returns Other error codes as defined for the sendto() function.
90 */
91extern int sockets_sendto(int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen, char * data, int size, int messages);
92
93/** Receives data via sockets.
94 * @param[in] verbose A value indicating whether to print out verbose information.
95 * @param[in] socket_ids A field of stored socket identifiers.
96 * @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
97 * @param[in] address The source host address of received datagrams.
98 * @param[in,out] addrlen The maximum length of the source address in bytes. The actual size of the source address is set instead.
99 * @param[out] data The received data.
100 * @param[in] size The maximum data size in bytes.
101 * @param[in] messages The number of datagrams per socket to be received.
102 * @returns EOK on success.
103 * @returns Other error codes as defined for the recvfrom() function.
104 */
105extern int sockets_recvfrom(int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t * addrlen, char * data, int size, int messages);
106
107/** Sends and receives data via sockets.
108 * Each datagram is sent and a reply read consequently.
109 * The next datagram is sent after the reply is received.
110 * @param[in] verbose A value indicating whether to print out verbose information.
111 * @param[in] socket_ids A field of stored socket identifiers.
112 * @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
113 * @param[in,out] address The destination host address to send data to. The source host address of received datagrams is set instead.
114 * @param[in] addrlen The length of the destination address in bytes.
115 * @param[in,out] data The data to be sent. The received data are set instead.
116 * @param[in] size The data size in bytes.
117 * @param[in] messages The number of datagrams per socket to be received.
118 * @returns EOK on success.
119 * @returns Other error codes as defined for the recvfrom() function.
120 */
121extern int sockets_sendto_recvfrom(int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t * addrlen, char * data, int size, int messages);
122
123#endif
124
125/** @}
126 */
Note: See TracBrowser for help on using the repository browser.