Subversion Repositories HelenOS

Rev

Rev 4749 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4749 Rev 4756
Line 58... Line 58...
58
 */
58
 */
59
#define NETTEST1_TEXT   "Networking test 1 - sockets"
59
#define NETTEST1_TEXT   "Networking test 1 - sockets"
60
 
60
 
61
/** Module entry point.
61
/** Module entry point.
62
 *  Starts testing.
62
 *  Starts testing.
63
 *  @param argc The number of command line parameters. Input parameter.
63
 *  @param[in] argc The number of command line parameters.
64
 *  @param argv The command line parameters. Input parameter.
64
 *  @param[in] argv The command line parameters.
65
 *  @returns EOK on success.
65
 *  @returns EOK on success.
66
 */
66
 */
67
int     main( int argc, char * argv[] );
67
int     main( int argc, char * argv[] );
68
 
68
 
69
/** Prints the application help.
69
/** Prints the application help.
70
 */
70
 */
71
void    print_help( void );
71
void    print_help( void );
72
 
72
 
73
/** Translates the character string to the protocol family number.
73
/** Translates the character string to the protocol family number.
74
 *  @param name The protocol family name. Input parameter.
74
 *  @param[in] name The protocol family name.
75
 *  @returns The corresponding protocol family number.
75
 *  @returns The corresponding protocol family number.
76
 *  @returns EPFNOSUPPORTED if the protocol family is not supported.
76
 *  @returns EPFNOSUPPORTED if the protocol family is not supported.
77
 */
77
 */
78
int     parse_protocol_family( const char * name );
78
int     parse_protocol_family( const char * name );
79
 
79
 
80
/** Translates the character string to the socket type number.
80
/** Translates the character string to the socket type number.
81
 *  @param name The socket type name. Input parameter.
81
 *  @param[in] name The socket type name.
82
 *  @returns The corresponding socket type number.
82
 *  @returns The corresponding socket type number.
83
 *  @returns ESOCKNOSUPPORTED if the socket type is not supported.
83
 *  @returns ESOCKNOSUPPORTED if the socket type is not supported.
84
 */
84
 */
85
int     parse_socket_type( const char * name );
85
int     parse_socket_type( const char * name );
86
 
86
 
87
/** Refreshes the data.
87
/** Refreshes the data.
88
 *  Fills the data block with the NETTEST1_TEXT pattern.
88
 *  Fills the data block with the NETTEST1_TEXT pattern.
89
 *  @param data The data block. Output parameter.
89
 *  @param[out] data The data block.
90
 *  @param size The data block size in bytes. Input parameter
90
 *  @param[in] size The data block size in bytes.
91
 */
91
 */
92
void    refresh_data( char * data, size_t size );
92
void    refresh_data( char * data, size_t size );
93
 
93
 
94
/** Creates new sockets.
94
/** Creates new sockets.
95
 *  @param verbose A value indicating whether to print out verbose information. Input parameter.
95
 *  @param[in] verbose A value indicating whether to print out verbose information.
96
 *  @param socket_ids A field to store the socket identifiers. Output parameter.
96
 *  @param[out] socket_ids A field to store the socket identifiers.
97
 *  @param sockets The number of sockets to create. Should be at most the size of the field. Input parameter.
97
 *  @param[in] sockets The number of sockets to create. Should be at most the size of the field.
98
 *  @param family The socket address family. Input parameter.
98
 *  @param[in] family The socket address family.
99
 *  @param type The socket type. Input parameter.
99
 *  @param[in] type The socket type.
100
 *  @returns EOK on success.
100
 *  @returns EOK on success.
101
 *  @returns Other error codes as defined for the socket() function.
101
 *  @returns Other error codes as defined for the socket() function.
102
 */
102
 */
103
int sockets_create( int verbose, int * socket_ids, int sockets, int family, sock_type_t type );
103
int sockets_create( int verbose, int * socket_ids, int sockets, int family, sock_type_t type );
104
 
104
 
105
/** Closes sockets.
105
/** Closes sockets.
106
 *  @param verbose A value indicating whether to print out verbose information. Input parameter.
106
 *  @param[in] verbose A value indicating whether to print out verbose information.
107
 *  @param socket_ids A field of stored socket identifiers. Input parameter.
107
 *  @param[in] socket_ids A field of stored socket identifiers.
108
 *  @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
108
 *  @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
109
 *  @returns EOK on success.
109
 *  @returns EOK on success.
110
 *  @returns Other error codes as defined for the closesocket() function.
110
 *  @returns Other error codes as defined for the closesocket() function.
111
 */
111
 */
112
int sockets_close( int verbose, int * socket_ids, int sockets );
112
int sockets_close( int verbose, int * socket_ids, int sockets );
113
 
113
 
114
/** Connects sockets.
114
/** Connects sockets.
115
 *  @param verbose A value indicating whether to print out verbose information. Input parameter.
115
 *  @param[in] verbose A value indicating whether to print out verbose information.
116
 *  @param socket_ids A field of stored socket identifiers. Input parameter.
116
 *  @param[in] socket_ids A field of stored socket identifiers.
117
 *  @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
117
 *  @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
118
 *  @param address The destination host address to connect to. Input parameter.
118
 *  @param[in] address The destination host address to connect to.
119
 *  @param addrlen The length of the destination address in bytes. Input parameter.
119
 *  @param[in] addrlen The length of the destination address in bytes.
120
 *  @returns EOK on success.
120
 *  @returns EOK on success.
121
 *  @returns Other error codes as defined for the connect() function.
121
 *  @returns Other error codes as defined for the connect() function.
122
 */
122
 */
123
int sockets_connect( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen );
123
int sockets_connect( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen );
124
 
124
 
125
/** Sends data via sockets.
125
/** Sends data via sockets.
126
 *  @param verbose A value indicating whether to print out verbose information. Input parameter.
126
 *  @param[in] verbose A value indicating whether to print out verbose information.
127
 *  @param socket_ids A field of stored socket identifiers. Input parameter.
127
 *  @param[in] socket_ids A field of stored socket identifiers.
128
 *  @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
128
 *  @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
129
 *  @param address The destination host address to send data to. Input parameter.
129
 *  @param[in] address The destination host address to send data to.
130
 *  @param addrlen The length of the destination address in bytes. Input parameter.
130
 *  @param[in] addrlen The length of the destination address in bytes.
131
 *  @param data The data to be sent. Input parameter.
131
 *  @param[in] data The data to be sent.
132
 *  @param size The data size in bytes. Input parameter
132
 *  @param[in] size The data size in bytes.
133
 *  @param messages The number of datagrams per socket to be sent. Input parameter.
133
 *  @param[in] messages The number of datagrams per socket to be sent.
134
 *  @returns EOK on success.
134
 *  @returns EOK on success.
135
 *  @returns Other error codes as defined for the sendto() function.
135
 *  @returns Other error codes as defined for the sendto() function.
136
 */
136
 */
137
int sockets_sendto( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen, char * data, int size, int messages );
137
int sockets_sendto( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen, char * data, int size, int messages );
138
 
138
 
139
/** Receives data via sockets.
139
/** Receives data via sockets.
140
 *  @param verbose A value indicating whether to print out verbose information. Input parameter.
140
 *  @param[in] verbose A value indicating whether to print out verbose information.
141
 *  @param socket_ids A field of stored socket identifiers. Input parameter.
141
 *  @param[in] socket_ids A field of stored socket identifiers.
142
 *  @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
142
 *  @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
143
 *  @param address The source host address of received datagrams. Input parameter.
143
 *  @param[in] address The source host address of received datagrams.
144
 *  @param addrlen The maximum length of the source address in bytes. The actual size of the source address is set instead. Input/output parameter.
144
 *  @param[in,out] addrlen The maximum length of the source address in bytes. The actual size of the source address is set instead.
145
 *  @param data The received data. Output parameter.
145
 *  @param[out] data The received data.
146
 *  @param size The maximum data size in bytes. Input parameter
146
 *  @param[in] size The maximum data size in bytes.
147
 *  @param messages The number of datagrams per socket to be received. Input parameter.
147
 *  @param[in] messages The number of datagrams per socket to be received.
148
 *  @returns EOK on success.
148
 *  @returns EOK on success.
149
 *  @returns Other error codes as defined for the recvfrom() function.
149
 *  @returns Other error codes as defined for the recvfrom() function.
150
 */
150
 */
151
int sockets_recvfrom( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t * addrlen, char * data, int size, int messages );
151
int sockets_recvfrom( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t * addrlen, char * data, int size, int messages );
152
 
152
 
153
/** Sends and receives data via sockets.
153
/** Sends and receives data via sockets.
154
 *  Each datagram is sent and a reply read consequently.
154
 *  Each datagram is sent and a reply read consequently.
155
 *  The next datagram is sent after the reply is received.
155
 *  The next datagram is sent after the reply is received.
156
 *  @param verbose A value indicating whether to print out verbose information. Input parameter.
156
 *  @param[in] verbose A value indicating whether to print out verbose information.
157
 *  @param socket_ids A field of stored socket identifiers. Input parameter.
157
 *  @param[in] socket_ids A field of stored socket identifiers.
158
 *  @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
158
 *  @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
159
 *  @param address The destination host address to send data to. The source host address of received datagrams is set instead. Input/output parameter.
159
 *  @param[in,out] address The destination host address to send data to. The source host address of received datagrams is set instead.
160
 *  @param addrlen The length of the destination address in bytes. Input parameter.
160
 *  @param[in] addrlen The length of the destination address in bytes.
161
 *  @param data The data to be sent. The received data are set instead. Input/output parameter.
161
 *  @param[in,out] data The data to be sent. The received data are set instead.
162
 *  @param size The data size in bytes. Input parameter
162
 *  @param[in] size The data size in bytes.
163
 *  @param messages The number of datagrams per socket to be received. Input parameter.
163
 *  @param[in] messages The number of datagrams per socket to be received.
164
 *  @returns EOK on success.
164
 *  @returns EOK on success.
165
 *  @returns Other error codes as defined for the recvfrom() function.
165
 *  @returns Other error codes as defined for the recvfrom() function.
166
 */
166
 */
167
int sockets_sendto_recvfrom( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t * addrlen, char * data, int size, int messages );
167
int sockets_sendto_recvfrom( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t * addrlen, char * data, int size, int messages );
168
 
168
 
169
/** Prints a mark.
169
/** Prints a mark.
170
 *  If the index is a multiple of ten, a different mark is printed.
170
 *  If the index is a multiple of ten, a different mark is printed.
171
 *  @param index The index of the mark to be printed. Input parameter.
171
 *  @param[in] index The index of the mark to be printed.
172
 */
172
 */
173
void    print_mark( int index );
173
void    print_mark( int index );
174
 
174
 
175
void print_help( void ){
175
void print_help( void ){
176
    printf(
176
    printf(