Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4755 → Rev 4756

/branches/network/uspace/srv/net/tl/tcp/tcp_module.h
42,7 → 42,7
#include <ipc/ipc.h>
 
/** Initializes the TCP module.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
49,10 → 49,10
int tcp_initialize( async_client_conn_t client_connection );
 
/** Processes the TCP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @see tcp_interface.h
/branches/network/uspace/srv/net/tl/tcp/tcp_header.h
40,13 → 40,13
 
#include <sys/types.h>
 
/** Returns the actual TCP header length.
* @param header The TCP packet header. Input parameter.
/** Returns the actual TCP header length in bytes.
* @param[in] header The TCP packet header.
*/
#define TCP_HEADER_LENGTH( header ) (( header )->header_length * 4u )
 
/** Returns the actual TCP header length.
* @param header The TCP packet header. Input parameter.
/** Returns the TCP header length.
* @param[in] length The TCP header length in bytes.
*/
#define TCP_COMPUTE_HEADER_LENGTH( length ) (( uint8_t ) (( length ) / 4u ))
 
/branches/network/uspace/srv/net/tl/tcp/tcp.c
33,7 → 33,6
/** @file
* TCP module implementation.
* @see tcp.h
* \todo
*/
 
#include <assert.h>
81,11 → 80,11
*/
#define NET_DEFAULT_TCP_WINDOW 10240
 
/** \todo
/** Initial timeout for new connections.
*/
#define NET_DEFAULT_TCP_INITIAL_TIMEOUT 3000000L
 
/** \todo
/** Default timeout for closing.
*/
#define NET_DEFAULT_TCP_TIME_WAIT_TIMEOUT 2000L
 
105,7 → 104,7
*/
#define TCP_FREE_PORTS_END 65535
 
/** \todo
/** Timeout for connection initialization, SYN sent.
*/
#define TCP_SYN_SENT_TIMEOUT 1000000L
 
117,7 → 116,11
*/
#define TCP_FAST_RETRANSMIT_COUNT 3
 
/** \todo
/** Returns a value indicating whether the value is in the interval respecting the possible overflow.
* The high end and/or the value may overflow, be lower than the low value.
* @param[in] lower The last value before the interval.
* @param[in] value The value to be checked.
* @param[in] high_equal The last value in the interval.
*/
#define IS_IN_INTERVAL_OVERFLOW( lower, value, higher_equal ) (((( lower ) < ( value )) && ((( value ) <= ( higher_equal )) || (( higher_equal ) < ( lower )))) || ((( value ) <= ( higher_equal )) && (( higher_equal ) < ( lower ))))
 
166,8 → 169,8
};
 
/** Releases the packet and returns the result.
* @param packet The packet queue to be released. Input parameter.
* @param result The result to be returned. Input parameter.
* @param[in] packet The packet queue to be released.
* @param[in] result The result to be returned.
* @return The result parameter.
*/
int tcp_release_and_return( packet_t packet, int result );
/branches/network/uspace/srv/net/tl/tcp/tcp_module.c
66,7 → 66,7
 
/** Starts the TCP module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on successful module termination.
* @returns Other error codes as defined for the tcp_initialize() function.
* @returns Other error codes as defined for the REGISTER_ME() macro function.
74,10 → 74,10
int module_start( async_client_conn_t client_connection );
 
/** Processes the TCP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the tcp_message() function.
*/
/branches/network/uspace/srv/net/tl/icmp/icmp_module.h
42,7 → 42,7
#include <ipc/ipc.h>
 
/** Initializes the ICMP module.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
49,10 → 49,10
int icmp_initialize( async_client_conn_t client_connection );
 
/** Processes the ICMP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @see icmp_interface.h
/branches/network/uspace/srv/net/tl/icmp/icmp_messages.h
79,42 → 79,42
/*@{*/
 
/** Returns the ICMP code message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define ICMP_GET_CODE( call ) ( icmp_code_t ) IPC_GET_ARG1( * call )
 
/** Returns the ICMP link MTU message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define ICMP_GET_MTU( call ) ( icmp_param_t ) IPC_GET_ARG3( * call )
 
/** Returns the pointer message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define ICMP_GET_POINTER( call ) ( icmp_param_t ) IPC_GET_ARG3( * call )
 
/** Returns the size message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define ICMP_GET_SIZE( call ) ( size_t ) IPC_GET_ARG1( call )
 
/** Returns the timeout message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define ICMP_GET_TIMEOUT( call ) (( suseconds_t ) IPC_GET_ARG2( call ))
 
/** Returns the time to live message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define ICMP_GET_TTL( call ) ( ip_ttl_t ) IPC_GET_ARG3( call )
 
/** Returns the type of service message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define ICMP_GET_TOS( call ) ( ip_tos_t ) IPC_GET_ARG4( call )
 
/** Returns the dont fragment message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define ICMP_GET_DONT_FRAGMENT( call ) ( int ) IPC_GET_ARG5( call )
 
/branches/network/uspace/srv/net/tl/icmp/icmp.c
96,8 → 96,8
#define ICMP_FREE_IDS_END MAX_UINT16
 
/** Computes the ICMP datagram checksum.
* @param header The ICMP datagram header. Input/output parameter.
* @param length The total datagram length. Input parameter.
* @param[in,out] header The ICMP datagram header.
* @param[in] length The total datagram length.
* @returns The computed checksum.
*/
#define ICMP_CHECKSUM( header, length ) htons( ip_checksum(( uint8_t * ) ( header ), ( length )))
107,8 → 107,8
#define ICMP_ECHO_TEXT "Hello from HelenOS."
 
/** Computes an ICMP reply data key.
* @param id The message identifier. Input parameter.
* @param sequence The message sequence number. Input parameter.
* @param[in] id The message identifier.
* @param[in] sequence The message sequence number.
* @returns The computed ICMP reply data key.
*/
#define ICMP_GET_REPLY_KEY( id, sequence ) ((( id ) << 16 ) | ( sequence & 0xFFFF ))
140,9 → 140,9
* Is used as an entry point from the underlying IP module.
* Releases the packet on error.
* @param device_id The device identifier. Ignored parameter.
* @param packet The received packet. Input/output parameter.
* @param[in,out] packet The received packet.
* @param receiver The target service. Ignored parameter.
* @param error The packet error reporting service. Prefixes the received packet. Input parameter.
* @param[in] error The packet error reporting service. Prefixes the received packet.
* @returns EOK on success.
* @returns Other error codes as defined for the icmp_process_packet() function.
*/
150,8 → 150,8
 
/** Processes the received ICMP packet.
* Notifies the destination socket application.
* @param packet The received packet. Input/output parameter.
* @param error The packet error reporting service. Prefixes the received packet. Input parameter.
* @param[in,out] packet The received packet.
* @param[in] error The packet error reporting service. Prefixes the received packet.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns EINVAL if the stored packet address is not the an_addr_t.
166,8 → 166,8
/** Processes the client messages.
* Remembers the assigned identifier and sequence numbers.
* Runs until the client module disconnects.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @returns EOK.
* @see icmp_interface.h
* @see icmp_api.h
175,7 → 175,7
int icmp_process_client_messages( ipc_callid_t callid, ipc_call_t call );
 
/** Processes the generic client messages.
* @param call The message parameters. Input parameter.
* @param[in] call The message parameters.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for the packet_translate() function.
188,8 → 188,8
int icmp_process_message( ipc_call_t * call );
 
/** Releases the packet and returns the result.
* @param packet The packet queue to be released. Input parameter.
* @param result The result to be returned. Input parameter.
* @param[in] packet The packet queue to be released.
* @param[in] result The result to be returned.
* @returns The result parameter.
*/
int icmp_release_and_return( packet_t packet, int result );
197,15 → 197,15
/** Requests an echo message.
* Sends a packet with specified parameters to the target host and waits for the reply upto the given timeout.
* Blocks the caller until the reply or the timeout occurres.
* @param id The message identifier. Input parameter.
* @param sequence The message sequence parameter. Input parameter.
* @param size The message data length in bytes. Input parameter.
* @param timeout The timeout in miliseconds. Input parameter.
* @param ttl The time to live. Input parameter.
* @param tos The type of service. Input parameter.
* @param dont_fragment The value indicating whether the datagram must not be fragmented. Is used as a MTU discovery. Input parameter.
* @param addr The target host address. Input parameter.
* @param addrlen The torget host address length. Input parameter.
* @param[in] id The message identifier.
* @param[in] sequence The message sequence parameter.
* @param[in] size The message data length in bytes.
* @param[in] timeout The timeout in miliseconds.
* @param[in] ttl The time to live.
* @param[in] tos The type of service.
* @param[in] dont_fragment The value indicating whether the datagram must not be fragmented. Is used as a MTU discovery.
* @param[in] addr The target host address.
* @param[in] addrlen The torget host address length.
* @returns ICMP_ECHO on success.
* @returns ETIMEOUT if the reply has not arrived before the timeout.
* @returns ICMP type of the received error notification.
218,7 → 218,7
/** Prepares the ICMP error packet.
* Truncates the original packet if longer than ICMP_KEEP_LENGTH bytes.
* Prefixes and returns the ICMP header.
* @param packet The original packet. Input/output parameter.
* @param[in,out] packet The original packet.
* @returns The prefixed ICMP header.
* @returns NULL on errors.
*/
228,14 → 228,14
* Sets the message type and code and computes the checksum.
* Error messages are sent only if allowed in the configuration.
* Releases the packet on errors.
* @param type The message type. Input parameter.
* @param code The message code. Input parameter.
* @param packet The message packet to be sent. Input parameter.
* @param header The ICMP header. Input parameter.
* @param error The error service to be announced. Should be SERVICE_ICMP or zero (0). Input parametr.
* @param ttl The time to live. Input parameter.
* @param tos The type of service. Input parameter.
* @param dont_fragment The value indicating whether the datagram must not be fragmented. Is used as a MTU discovery. Input parameter.
* @param[in] type The message type.
* @param[in] code The message code.
* @param[in] packet The message packet to be sent.
* @param[in] header The ICMP header.
* @param[in] error The error service to be announced. Should be SERVICE_ICMP or zero (0).
* @param[in] ttl The time to live.
* @param[in] tos The type of service.
* @param[in] dont_fragment The value indicating whether the datagram must not be fragmented. Is used as a MTU discovery.
* @returns EOK on success.
* @returns EPERM if the error message is not allowed.
*/
245,10 → 245,10
* If the reply data are still present, the reply timeouted and the parent fibril is awaken.
* The global lock is not released in this case to be reused by the parent fibril.
* Releases the packet.
* @param packet The received reply message. Input parameter.
* @param header The ICMP message header. Input parameter.
* @param type The received reply message type. Input parameter.
* @param code The received reply message code. Input parameter.
* @param[in] packet The received reply message.
* @param[in] header The ICMP message header.
* @param[in] type The received reply message type.
* @param[in] code The received reply message code.
* @returns EOK.
*/
int icmp_process_echo_reply( packet_t packet, icmp_header_ref header, icmp_type_t type, icmp_code_t code );
258,7 → 258,7
* If the reply data are still present, the reply timeouted and the parent fibril is awaken.
* The global lock is not released in this case to be reused by the parent fibril.
* Should run in a searate fibril.
* @param data The icmp_reply_timeout structure. Input parameter.
* @param[in] data The icmp_reply_timeout structure.
* @returns EOK on success.
* @returns EINVAL if the data parameter is NULL.
*/
266,7 → 266,7
 
/** Assigns a new identifier for the connection.
* Fills the echo data parameter with the assigned values.
* @param echo_data The echo data to be bound. Input/output parameter.
* @param[in,out] echo_data The echo data to be bound.
* @returns Index of the inserted echo data.
* @returns EBADMEM if the echo_data parameter is NULL.
* @returns ENOTCONN if no free identifier have been found.
/branches/network/uspace/srv/net/tl/icmp/icmp_module.c
64,7 → 64,7
 
/** Starts the ICMP module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on successful module termination.
* @returns Other error codes as defined for the arp_initialize() function.
* @returns Other error codes as defined for the REGISTER_ME() macro function.
72,10 → 72,10
int module_start( async_client_conn_t client_connection );
 
/** Processes the ICMP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the icmp_message() function.
*/
/branches/network/uspace/srv/net/tl/udp/udp_module.h
42,7 → 42,7
#include <ipc/ipc.h>
 
/** Initializes the UDP module.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
49,10 → 49,10
int udp_initialize( async_client_conn_t client_connection );
 
/** Processes the UDP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @see udp_interface.h
/branches/network/uspace/srv/net/tl/udp/udp.c
97,9 → 97,9
* Is used as an entry point from the underlying IP module.
* Locks the global lock and calls udp_process_packet() function.
* @param device_id The device identifier. Ignored parameter.
* @param packet The received packet queue. Input/output parameter.
* @param[in,out] packet The received packet queue.
* @param receiver The target service. Ignored parameter.
* @param error The packet error reporting service. Prefixes the received packet. Input parameter.
* @param[in] error The packet error reporting service. Prefixes the received packet.
* @returns EOK on success.
* @returns Other error codes as defined for the udp_process_packet() function.
*/
108,8 → 108,8
/** Processes the received UDP packet queue.
* Notifies the destination socket application.
* Releases the packet on error or sends an ICMP error notification..
* @param packet The received packet queue. Input/output parameter.
* @param error The packet error reporting service. Prefixes the received packet. Input parameter.
* @param[in,out] packet The received packet queue.
* @param[in] error The packet error reporting service. Prefixes the received packet.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns EINVAL if the stored packet address is not the an_addr_t.
122,8 → 122,8
int udp_process_packet( packet_t packet, services_t error );
 
/** Releases the packet and returns the result.
* @param packet The packet queue to be released. Input parameter.
* @param result The result to be returned. Input parameter.
* @param[in] packet The packet queue to be released.
* @param[in] result The result to be returned.
* @return The result parameter.
*/
int udp_release_and_return( packet_t packet, int result );
134,8 → 134,8
 
/** Processes the socket client messages.
* Runs until the client module disconnects.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @returns EOK on success.
* @see socket.h
*/
145,13 → 145,13
* Binds the socket to a free port if not already connected/bound.
* Handles the NET_SOCKET_SENDTO message.
* Supports AF_INET and AF_INET6 address families.
* @param local_sockets The application local sockets. Input/output parameter.
* @param socket_id Socket identifier. Input parameter.
* @param addr The destination address. Input parameter.
* @param addrlen The address length. Input parameter.
* @param fragments The number of data fragments. Input parameter.
* @param data_fragment_size The data fragment size in bytes. Input parameter.
* @param flags Various send flags. Input parameter.
* @param[in,out] local_sockets The application local sockets.
* @param[in] socket_id Socket identifier.
* @param[in] addr The destination address.
* @param[in] addrlen The address length.
* @param[in] fragments The number of data fragments.
* @param[in] data_fragment_size The data fragment size in bytes.
* @param[in] flags Various send flags.
* @returns EOK on success.
* @returns EAFNOTSUPPORT if the address family is not supported.
* @returns ENOTSOCK if the socket is not found.
167,10 → 167,10
/** Receives data to the socket.
* Handles the NET_SOCKET_RECVFROM message.
* Replies the source address as well.
* @param local_sockets The application local sockets. Input parameter.
* @param socket_id Socket identifier. Input parameter.
* @param flags Various receive flags. Input parameter.
* @param addrlen The source address length. Output parameter.
* @param[in] local_sockets The application local sockets.
* @param[in] socket_id Socket identifier.
* @param[in] flags Various receive flags.
* @param[out] addrlen The source address length.
* @returns The number of bytes received.
* @returns ENOTSOCK if the socket is not found.
* @returns NO_DATA if there are no received packets or data.
/branches/network/uspace/srv/net/tl/udp/udp_module.c
64,7 → 64,7
 
/** Starts the UDP module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on successful module termination.
* @returns Other error codes as defined for the udp_initialize() function.
* @returns Other error codes as defined for the REGISTER_ME() macro function.
72,10 → 72,10
int module_start( async_client_conn_t client_connection );
 
/** Processes the UDP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the udp_message() function.
*/
/branches/network/uspace/srv/net/tl/tl_common.h
78,9 → 78,9
 
/** Gets the address port.
* Supports AF_INET and AF_INET6 address families.
* @param addr The address to be updated. Input/output parameter.
* @param addrlen The address length. Input parameter.
* @param port The set port. Output parameter.
* @param[in,out] addr The address to be updated.
* @param[in] addrlen The address length.
* @param[out] port The set port.
* @returns EOK on success.
* @returns EINVAL if the address length does not match the address family.
* @returns EAFNOSUPPORT if the address family is not supported.
93,7 → 93,7
* @param[in] ip_phone The IP moduel phone for (semi)remote calls.
* @param[in] packet_dimensions The packet dimensions cache.
* @param[in] device_id The device identifier.
* @param[out] packet_dimention The IP packet dimensions.
* @param[out] packet_dimension The IP packet dimensions.
* @returns EOK on success.
* @returns EBADMEM if the packet_dimension parameter is NULL.
* @return ENOMEM if there is not enough memory left.
104,9 → 104,9
 
/** Sets the address port.
* Supports AF_INET and AF_INET6 address families.
* @param addr The address to be updated. Input/output parameter.
* @param addrlen The address length. Input parameter.
* @param port The port to be set. Input parameter.
* @param[in,out] addr The address to be updated.
* @param[in] addrlen The address length.
* @param[in] port The port to be set.
* @returns EOK on success.
* @returns EINVAL if the address length does not match the address family.
* @returns EAFNOSUPPORT if the address family is not supported.
116,10 → 116,10
/** Prepares the packet for ICMP error notification.
* Keeps the first packet and releases all the others.
* Releases all the packets on error.
* @param packet_phone The packet server module phone. Input parameter.
* @param icmp_phone The ICMP module phone. Input parameter.
* @param packet The packet to be send. Input parameter.
* @param error The packet error reporting service. Prefixes the received packet. Input parameter.
* @param[in] packet_phone The packet server module phone.
* @param[in] icmp_phone The ICMP module phone.
* @param[in] packet The packet to be send.
* @param[in] error The packet error reporting service. Prefixes the received packet.
* @returns EOK on success.
* @returns ENOENT if no packet may be sent.
*/
126,12 → 126,12
int tl_prepare_icmp_packet( int packet_phone, int icmp_phone, packet_t packet, services_t error );
 
/** Receives data from the socket into a packet.
* @param packet_phone The packet server module phone. Input parameter.
* @param packet The new created packet. Output parameter.
* @param prefix Reserved packet data prefix length. Input parameter.
* @param dimension The packet dimension. Input parameter.
* @param addr The destination address. Input parameter.
* @param addrlen The address length. Input parameter.
* @param[in] packet_phone The packet server module phone.
* @param[out] packet The new created packet.
* @param[in] prefix Reserved packet data prefix length.
* @param[in] dimension The packet dimension.
* @param[in] addr The destination address.
* @param[in] addrlen The address length.
* @returns Number of bytes received.
* @returns EINVAL if the client does not send data.
* @returns ENOMEM if there is not enough memory left.
/branches/network/uspace/srv/net/app/parse.h
38,8 → 38,8
#define __NET_APP_PARSE__
 
/** Prints the parameter unrecognized message and the application help.
* @param index The index of the parameter. Input parameter.
* @param parameter The parameter name. Input parameter.
* @param[in] index The index of the parameter.
* @param[in] parameter The parameter name.
*/
void print_unrecognized( int index, const char * parameter );
 
46,12 → 46,12
/** Parses the next parameter as an integral number.
* The actual parameter is pointed by the index.
* Parses the offseted actual parameter value if the offset is set or the next one if not.
* @param argc The total number of the parameters. Input parameter.
* @param argv The parameters. Input parameter.
* @param index The actual parameter index. The index is incremented by the number of processed parameters. Input/output parameter.
* @param value The parsed parameter value. Output parameter.
* @param name The parameter name to be printed on errors. Input parameter.
* @param offset The value offset in the actual parameter. If not set, the next parameter is parsed instead. Input parameter.
* @param[in] argc The total number of the parameters.
* @param[in] argv The parameters.
* @param[in,out] index The actual parameter index. The index is incremented by the number of processed parameters.
* @param[out] value The parsed parameter value.
* @param[in] name The parameter name to be printed on errors.
* @param[in] offset The value offset in the actual parameter. If not set, the next parameter is parsed instead.
* @returns EOK on success.
* @returns EINVAL if the parameter is missing.
* @returns EINVAL if the parameter is in wrong format.
62,12 → 62,12
* The actual parameter is pointed by the index.
* Uses the offseted actual parameter value if the offset is set or the next one if not.
* Increments the actual index by the number of processed parameters.
* @param argc The total number of the parameters. Input parameter.
* @param argv The parameters. Input parameter.
* @param index The actual parameter index. The index is incremented by the number of processed parameters. Input/output parameter.
* @param value The parsed parameter value. Output parameter.
* @param name The parameter name to be printed on errors. Input parameter.
* @param offset The value offset in the actual parameter. If not set, the next parameter is parsed instead. Input parameter.
* @param[in] argc The total number of the parameters.
* @param[in] argv The parameters.
* @param[in,out] index The actual parameter index. The index is incremented by the number of processed parameters.
* @param[out] value The parsed parameter value.
* @param[in] name The parameter name to be printed on errors.
* @param[in] offset The value offset in the actual parameter. If not set, the next parameter is parsed instead.
* @returns EOK on success.
* @returns EINVAL if the parameter is missing.
*/
78,13 → 78,13
* Uses the offseted actual parameter if the offset is set or the next one if not.
* Translates the parameter using the parse_value function.
* Increments the actual index by the number of processed parameters.
* @param argc The total number of the parameters. Input parameter.
* @param argv The parameters. Input parameter.
* @param index The actual parameter index. The index is incremented by the number of processed parameters. Input/output parameter.
* @param value The parsed parameter value. Output parameter.
* @param name The parameter name to be printed on errors. Input parameter.
* @param offset The value offset in the actual parameter. If not set, the next parameter is parsed instead. Input parameter.
* @param parse_value The translation function to parse the named value.
* @param[in] argc The total number of the parameters.
* @param[in] argv The parameters.
* @param[in,out] index The actual parameter index. The index is incremented by the number of processed parameters.
* @param[out] value The parsed parameter value.
* @param[in] name The parameter name to be printed on errors.
* @param[in] offset The value offset in the actual parameter. If not set, the next parameter is parsed instead.
* @param[in] parse_value The translation function to parse the named value.
* @returns EOK on success.
* @returns EINVAL if the parameter is missing.
* @returns ENOENT if the parameter name has not been found.
/branches/network/uspace/srv/net/app/nettest1/nettest1.c
60,8 → 60,8
 
/** Module entry point.
* Starts testing.
* @param argc The number of command line parameters. Input parameter.
* @param argv The command line parameters. Input parameter.
* @param[in] argc The number of command line parameters.
* @param[in] argv The command line parameters.
* @returns EOK on success.
*/
int main( int argc, char * argv[] );
71,7 → 71,7
void print_help( void );
 
/** Translates the character string to the protocol family number.
* @param name The protocol family name. Input parameter.
* @param[in] name The protocol family name.
* @returns The corresponding protocol family number.
* @returns EPFNOSUPPORTED if the protocol family is not supported.
*/
78,7 → 78,7
int parse_protocol_family( const char * name );
 
/** Translates the character string to the socket type number.
* @param name The socket type name. Input parameter.
* @param[in] name The socket type name.
* @returns The corresponding socket type number.
* @returns ESOCKNOSUPPORTED if the socket type is not supported.
*/
86,17 → 86,17
 
/** Refreshes the data.
* Fills the data block with the NETTEST1_TEXT pattern.
* @param data The data block. Output parameter.
* @param size The data block size in bytes. Input parameter
* @param[out] data The data block.
* @param[in] size The data block size in bytes.
*/
void refresh_data( char * data, size_t size );
 
/** Creates new sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field to store the socket identifiers. Output parameter.
* @param sockets The number of sockets to create. Should be at most the size of the field. Input parameter.
* @param family The socket address family. Input parameter.
* @param type The socket type. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[out] socket_ids A field to store the socket identifiers.
* @param[in] sockets The number of sockets to create. Should be at most the size of the field.
* @param[in] family The socket address family.
* @param[in] type The socket type.
* @returns EOK on success.
* @returns Other error codes as defined for the socket() function.
*/
103,9 → 103,9
int sockets_create( int verbose, int * socket_ids, int sockets, int family, sock_type_t type );
 
/** Closes sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @returns EOK on success.
* @returns Other error codes as defined for the closesocket() function.
*/
112,11 → 112,11
int sockets_close( int verbose, int * socket_ids, int sockets );
 
/** Connects sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param address The destination host address to connect to. Input parameter.
* @param addrlen The length of the destination address in bytes. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @param[in] address The destination host address to connect to.
* @param[in] addrlen The length of the destination address in bytes.
* @returns EOK on success.
* @returns Other error codes as defined for the connect() function.
*/
123,14 → 123,14
int sockets_connect( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen );
 
/** Sends data via sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param address The destination host address to send data to. Input parameter.
* @param addrlen The length of the destination address in bytes. Input parameter.
* @param data The data to be sent. Input parameter.
* @param size The data size in bytes. Input parameter
* @param messages The number of datagrams per socket to be sent. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @param[in] address The destination host address to send data to.
* @param[in] addrlen The length of the destination address in bytes.
* @param[in] data The data to be sent.
* @param[in] size The data size in bytes.
* @param[in] messages The number of datagrams per socket to be sent.
* @returns EOK on success.
* @returns Other error codes as defined for the sendto() function.
*/
137,14 → 137,14
int sockets_sendto( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen, char * data, int size, int messages );
 
/** Receives data via sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param address The source host address of received datagrams. Input parameter.
* @param addrlen The maximum length of the source address in bytes. The actual size of the source address is set instead. Input/output parameter.
* @param data The received data. Output parameter.
* @param size The maximum data size in bytes. Input parameter
* @param messages The number of datagrams per socket to be received. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @param[in] address The source host address of received datagrams.
* @param[in,out] addrlen The maximum length of the source address in bytes. The actual size of the source address is set instead.
* @param[out] data The received data.
* @param[in] size The maximum data size in bytes.
* @param[in] messages The number of datagrams per socket to be received.
* @returns EOK on success.
* @returns Other error codes as defined for the recvfrom() function.
*/
153,14 → 153,14
/** 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.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param address The destination host address to send data to. The source host address of received datagrams is set instead. Input/output parameter.
* @param addrlen The length of the destination address in bytes. Input parameter.
* @param data The data to be sent. The received data are set instead. Input/output parameter.
* @param size The data size in bytes. Input parameter
* @param messages The number of datagrams per socket to be received. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @param[in,out] address The destination host address to send data to. The source host address of received datagrams is set instead.
* @param[in] addrlen The length of the destination address in bytes.
* @param[in,out] data The data to be sent. The received data are set instead.
* @param[in] size The data size in bytes.
* @param[in] messages The number of datagrams per socket to be received.
* @returns EOK on success.
* @returns Other error codes as defined for the recvfrom() function.
*/
168,7 → 168,7
 
/** Prints a mark.
* If the index is a multiple of ten, a different mark is printed.
* @param index The index of the mark to be printed. Input parameter.
* @param[in] index The index of the mark to be printed.
*/
void print_mark( int index );
 
/branches/network/uspace/srv/net/app/nettest2/nettest2.c
60,8 → 60,8
 
/** Module entry point.
* Starts testing.
* @param argc The number of command line parameters. Input parameter.
* @param argv The command line parameters. Input parameter.
* @param[in] argc The number of command line parameters.
* @param[in] argv The command line parameters.
* @returns EOK on success.
*/
int main( int argc, char * argv[] );
71,7 → 71,7
void print_help( void );
 
/** Translates the character string to the protocol family number.
* @param name The protocol family name. Input parameter.
* @param[in] name The protocol family name.
* @returns The corresponding protocol family number.
* @returns EPFNOSUPPORTED if the protocol family is not supported.
*/
78,7 → 78,7
int parse_protocol_family( const char * name );
 
/** Translates the character string to the socket type number.
* @param name The socket type name. Input parameter.
* @param[in] name The socket type name.
* @returns The corresponding socket type number.
* @returns ESOCKNOSUPPORTED if the socket type is not supported.
*/
86,17 → 86,17
 
/** Refreshes the data.
* Fills the data block with the NETTEST1_TEXT pattern.
* @param data The data block. Output parameter.
* @param size The data block size in bytes. Input parameter
* @param[out] data The data block.
* @param[in] size The data block size in bytes.
*/
void refresh_data( char * data, size_t size );
 
/** Creates new sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field to store the socket identifiers. Output parameter.
* @param sockets The number of sockets to create. Should be at most the size of the field. Input parameter.
* @param family The socket address family. Input parameter.
* @param type The socket type. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[out] socket_ids A field to store the socket identifiers.
* @param[in] sockets The number of sockets to create. Should be at most the size of the field.
* @param[in] family The socket address family.
* @param[in] type The socket type.
* @returns EOK on success.
* @returns Other error codes as defined for the socket() function.
*/
103,9 → 103,9
int sockets_create( int verbose, int * socket_ids, int sockets, int family, sock_type_t type );
 
/** Closes sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @returns EOK on success.
* @returns Other error codes as defined for the closesocket() function.
*/
112,11 → 112,11
int sockets_close( int verbose, int * socket_ids, int sockets );
 
/** Connects sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param address The destination host address to connect to. Input parameter.
* @param addrlen The length of the destination address in bytes. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @param[in] address The destination host address to connect to.
* @param[in] addrlen The length of the destination address in bytes.
* @returns EOK on success.
* @returns Other error codes as defined for the connect() function.
*/
123,14 → 123,14
int sockets_connect( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen );
 
/** Sends data via sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param address The destination host address to send data to. Input parameter.
* @param addrlen The length of the destination address in bytes. Input parameter.
* @param data The data to be sent. Input parameter.
* @param size The data size in bytes. Input parameter
* @param messages The number of datagrams per socket to be sent. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @param[in] address The destination host address to send data to.
* @param[in] addrlen The length of the destination address in bytes.
* @param[in] data The data to be sent.
* @param[in] size The data size in bytes.
* @param[in] messages The number of datagrams per socket to be sent.
* @returns EOK on success.
* @returns Other error codes as defined for the sendto() function.
*/
137,14 → 137,14
int sockets_sendto( int verbose, int * socket_ids, int sockets, struct sockaddr * address, socklen_t addrlen, char * data, int size, int messages );
 
/** Receives data via sockets.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param address The source host address of received datagrams. Input parameter.
* @param addrlen The maximum length of the source address in bytes. The actual size of the source address is set instead. Input/output parameter.
* @param data The received data. Output parameter.
* @param size The maximum data size in bytes. Input parameter
* @param messages The number of datagrams per socket to be received. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @param[in] address The source host address of received datagrams.
* @param[in,out] addrlen The maximum length of the source address in bytes. The actual size of the source address is set instead.
* @param[out] data The received data.
* @param[in] size The maximum data size in bytes.
* @param[in] messages The number of datagrams per socket to be received.
* @returns EOK on success.
* @returns Other error codes as defined for the recvfrom() function.
*/
153,14 → 153,14
/** 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.
* @param verbose A value indicating whether to print out verbose information. Input parameter.
* @param socket_ids A field of stored socket identifiers. Input parameter.
* @param sockets The number of sockets in the field. Should be at most the size of the field. Input parameter.
* @param address The destination host address to send data to. The source host address of received datagrams is set instead. Input/output parameter.
* @param addrlen The length of the destination address in bytes. Input parameter.
* @param data The data to be sent. The received data are set instead. Input/output parameter.
* @param size The data size in bytes. Input parameter
* @param messages The number of datagrams per socket to be received. Input parameter.
* @param[in] verbose A value indicating whether to print out verbose information.
* @param[in] socket_ids A field of stored socket identifiers.
* @param[in] sockets The number of sockets in the field. Should be at most the size of the field.
* @param[in,out] address The destination host address to send data to. The source host address of received datagrams is set instead.
* @param[in] addrlen The length of the destination address in bytes.
* @param[in,out] data The data to be sent. The received data are set instead.
* @param[in] size The data size in bytes.
* @param[in] messages The number of datagrams per socket to be received.
* @returns EOK on success.
* @returns Other error codes as defined for the recvfrom() function.
*/
168,7 → 168,7
 
/** Prints a mark.
* If the index is a multiple of ten, a different mark is printed.
* @param index The index of the mark to be printed. Input parameter.
* @param[in] index The index of the mark to be printed.
*/
void print_mark( int index );
 
/branches/network/uspace/srv/net/app/print_error.h
38,13 → 38,13
#define __NET_APP_PRINT__
 
/** Returns whether the error code may be an ICMP error code.
* @param error_code The error code. Input parameter.
* @param[in] error_code The error code.
* @returns A value indicating whether the error code may be an ICMP error code.
*/
#define IS_ICMP_ERROR( error_code ) (( error_code ) > 0 )
 
/** Returns whether the error code may be socket error code.
* @param error_code The error code. Input parameter.
* @param[in] error_code The error code.
* @returns A value indicating whether the error code may be a socket error code.
*/
#define IS_SOCKET_ERROR( error_code ) (( error_code ) < 0 )
51,26 → 51,26
 
/** Prints the error description.
* Supports ICMP and socket error codes.
* @param output The description output stream. May be NULL. Input parameter.
* @param error_code The error code. Input parameter.
* @param prefix The error description prefix. May be NULL. Input parameter.
* @param suffix The error description suffix. May be NULL. Input parameter.
* @param[in] output The description output stream. May be NULL.
* @param[in] error_code The error code.
* @param[in] prefix The error description prefix. May be NULL.
* @param[in] suffix The error description suffix. May be NULL.
*/
void print_error( FILE * output, int error_code, const char * prefix, const char * suffix );
 
/** Prints the specific ICMP error description.
* @param output The description output stream. May be NULL. Input parameter.
* @param error_code The ICMP error code. Input parameter.
* @param prefix The error description prefix. May be NULL. Input parameter.
* @param suffix The error description suffix. May be NULL. Input parameter.
* @param[in] output The description output stream. May be NULL.
* @param[in] error_code The ICMP error code.
* @param[in] prefix The error description prefix. May be NULL.
* @param[in] suffix The error description suffix. May be NULL.
*/
void icmp_print_error( FILE * output, int error_code, const char * prefix, const char * suffix );
 
/** Prints the specific socket error description.
* @param output The description output stream. May be NULL. Input parameter.
* @param error_code The socket error code. Input parameter.
* @param prefix The error description prefix. May be NULL. Input parameter.
* @param suffix The error description suffix. May be NULL. Input parameter.
* @param[in] output The description output stream. May be NULL.
* @param[in] error_code The socket error code.
* @param[in] prefix The error description prefix. May be NULL.
* @param[in] suffix The error description suffix. May be NULL.
*/
void socket_print_error( FILE * output, int error_code, const char * prefix, const char * suffix );
 
/branches/network/uspace/srv/net/app/ping/ping.c
58,8 → 58,8
 
/** Module entry point.
* Reads command line parameters and pings.
* @param argc The number of command line parameters. Input parameter.
* @param argv The command line parameters. Input parameter.
* @param[in] argc The number of command line parameters.
* @param[in] argv The command line parameters.
* @returns EOK on success.
*/
int main( int argc, char * argv[] );
69,7 → 69,7
void print_help( void );
 
/** Translates the character string to the address family number.
* @param name The address family name. Input parameter.
* @param[in] name The address family name.
* @returns The corresponding address family number.
* @returns EAFNOSUPPORTED if the address family is not supported.
*/
/branches/network/uspace/srv/net/app/echo/echo.c
56,8 → 56,8
 
/** Module entry point.
* Reads command line parameters and starts listenning.
* @param argc The number of command line parameters. Input parameter.
* @param argv The command line parameters. Input parameter.
* @param[in] argc The number of command line parameters.
* @param[in] argv The command line parameters.
* @returns EOK on success.
*/
int main( int argc, char * argv[] );
64,23 → 64,23
 
/** Prints the application help.
*/
void print_help( void );
void echo_print_help( void );
 
/** Translates the character string to the protocol family number.
* @param name The protocol family name. Input parameter.
* @param[in] name The protocol family name.
* @returns The corresponding protocol family number.
* @returns EPFNOSUPPORTED if the protocol family is not supported.
*/
int parse_protocol_family( const char * name );
int echo_parse_protocol_family( const char * name );
 
/** Translates the character string to the socket type number.
* @param name The socket type name. Input parameter.
* @param[in] name The socket type name.
* @returns The corresponding socket type number.
* @returns ESOCKNOSUPPORTED if the socket type is not supported.
*/
int parse_socket_type( const char * name );
int echo_parse_socket_type( const char * name );
 
void print_help( void ){
void echo_print_help( void ){
printf(
"Network Echo aplication\n" \
"Usage: echo [options]\n" \
114,7 → 114,7
);
}
 
int parse_protocol_family( const char * name ){
int echo_parse_protocol_family( const char * name ){
if( str_lcmp( name, "PF_INET", 7 ) == 0 ){
return PF_INET;
}else if( str_lcmp( name, "PF_INET6", 8 ) == 0 ){
123,7 → 123,7
return EPFNOSUPPORT;
}
 
int parse_socket_type( const char * name ){
int echo_parse_socket_type( const char * name ){
if( str_lcmp( name, "SOCK_DGRAM", 11 ) == 0 ){
return SOCK_DGRAM;
}else if( str_lcmp( name, "SOCK_STREAM", 12 ) == 0 ){
170,9 → 170,9
break;
case 'c': ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & count, "message count", 0 ));
break;
case 'f': ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & family, "protocol family", 0, parse_protocol_family ));
case 'f': ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & family, "protocol family", 0, echo_parse_protocol_family ));
break;
case 'h': print_help();
case 'h': echo_print_help();
return EOK;
break;
case 'p': ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & value, "port number", 0 ));
183,7 → 183,7
case 's': ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & value, "receive size", 0 ));
size = (value >= 0 ) ? ( size_t ) value : 0;
break;
case 't': ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & value, "socket type", 0, parse_socket_type ));
case 't': ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & value, "socket type", 0, echo_parse_socket_type ));
type = ( sock_type_t ) value;
break;
case 'v': verbose = 1;
193,9 → 193,9
}else if( str_lcmp( argv[ index ] + 2, "count=", 6 ) == 0 ){
ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & count, "message count", 8 ));
}else if( str_lcmp( argv[ index ] + 2, "family=", 7 ) == 0 ){
ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & family, "protocol family", 9, parse_protocol_family ));
ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & family, "protocol family", 9, echo_parse_protocol_family ));
}else if( str_lcmp( argv[ index ] + 2, "help", 5 ) == 0 ){
print_help();
echo_print_help();
return EOK;
}else if( str_lcmp( argv[ index ] + 2, "port=", 5 ) == 0 ){
ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & value, "port number", 7 ));
206,24 → 206,24
ERROR_PROPAGATE( parse_parameter_int( argc, argv, & index, & value, "receive size", 7 ));
size = (value >= 0 ) ? ( size_t ) value : 0;
}else if( str_lcmp( argv[ index ] + 2, "type=", 5 ) == 0 ){
ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & value, "socket type", 7, parse_socket_type ));
ERROR_PROPAGATE( parse_parameter_name_int( argc, argv, & index, & value, "socket type", 7, echo_parse_socket_type ));
type = ( sock_type_t ) value;
}else if( str_lcmp( argv[ index ] + 2, "verbose", 8 ) == 0 ){
verbose = 1;
}else{
print_unrecognized( index, argv[ index ] + 2 );
print_help();
echo_print_help();
return EINVAL;
}
break;
default:
print_unrecognized( index, argv[ index ] + 1 );
print_help();
echo_print_help();
return EINVAL;
}
}else{
print_unrecognized( index, argv[ index ] );
print_help();
echo_print_help();
return EINVAL;
}
}
/branches/network/uspace/srv/net/nil/eth/eth.c
121,7 → 121,7
#define ETH_DIX ( 1 << ETH_MODE_SHIFT )
 
/** Returns whether the DIX Ethernet mode flag is set.
* @param flags The ethernet flags. Input parameter.
* @param[in] flags The ethernet flags.
* @see ETH_DIX
*/
#define IS_DIX( flags ) ((( flags ) & ETH_MODE_MASK ) == ETH_DIX )
131,7 → 131,7
#define ETH_8023_2_LSAP ( 2 << ETH_MODE_SHIFT )
 
/** Returns whether the 802.3 + 802.2 + LSAP mode flag is set.
* @param flags The ethernet flags. Input parameter.
* @param[in] flags The ethernet flags.
* @see ETH_8023_2_LSAP
*/
#define IS_8023_2_LSAP( flags ) ((( flags ) & ETH_MODE_MASK ) == ETH_8023_2_LSAP )
141,7 → 141,7
#define ETH_8023_2_SNAP ( 3 << ETH_MODE_SHIFT )
 
/** Returns whether the 802.3 + 802.2 + LSAP + SNAP mode flag is set.
* @param flags The ethernet flags. Input parameter.
* @param[in] flags The ethernet flags.
* @see ETH_8023_2_SNAP
*/
#define IS_8023_2_SNAP( flags ) ((( flags ) & ETH_MODE_MASK ) == ETH_8023_2_SNAP )
176,16 → 176,16
/*@{*/
 
/** Processes IPC messages from the registered device driver modules in an infinite loop.
* @param iid The message identifier. Input parameter.
* @param icall The message parameters. Input/output parameter.
* @param[in] iid The message identifier.
* @param[in,out] icall The message parameters.
*/
void eth_receiver( ipc_callid_t iid, ipc_call_t * icall );
 
/** Registers new device or updates the MTU of an existing one.
* Determines the device local hardware address.
* @param device_id The new device identifier. Input parameter.
* @param service The device driver service. Input parameter.
* @param mtu The device maximum transmission unit. Input parameter.
* @param[in] device_id The new device identifier.
* @param[in] service The device driver service.
* @param[in] mtu The device maximum transmission unit.
* @returns EOK on success.
* @returns EEXIST if the device with the different service exists.
* @returns ENOMEM if there is not enough memory left.
197,8 → 197,8
 
/** Registers receiving module service.
* Passes received packets for this service.
* @param service The module service. Input parameter.
* @param phone The service phone. Input parameter.
* @param[in] service The module service.
* @param[in] phone The service phone.
* @returns EOK on success.
* @returns ENOENT if the service is not known.
* @returns ENOMEM if there is not enough memory left.
206,11 → 206,11
int eth_register_message( services_t service, int phone );
 
/** Returns the device packet dimensions for sending.
* @param device_id The device identifier. Input parameter.
* @param addr_len The minimum reserved address length. Output parameter.
* @param prefix The minimum reserved prefix size. Output parameter.
* @param content The maximum content size. Output parameter.
* @param suffix The minimum reserved suffix size. Output parameter.
* @param[in] device_id The device identifier.
* @param[out] addr_len The minimum reserved address length.
* @param[out] prefix The minimum reserved prefix size.
* @param[out] content The maximum content size.
* @param[out] suffix The minimum reserved suffix size.
* @returns EOK on success.
* @returns EBADMEM if either one of the parameters is NULL.
* @returns ENOENT if there is no such device.
218,9 → 218,9
int eth_packet_space_message( device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix );
 
/** Returns the device hardware address.
* @param device_id The device identifier. Input parameter.
* @param type Type of the desired address. Input parameter
* @param address The device hardware address. Output parameter.
* @param[in] device_id The device identifier.
* @param[in] type Type of the desired address.
* @param[out] address The device hardware address.
* @returns EOK on success.
* @returns EBADMEM if the address parameter is NULL.
* @returns ENOENT if there no such device.
229,9 → 229,9
 
/** Sends the packet queue.
* Sends only packet successfully processed by the eth_prepare_packet() function.
* @param device_id The device identifier. Input parameter.
* @param packet The packet queue. Input parameter.
* @param sender The sending module service. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] packet The packet queue.
* @param[in] sender The sending module service.
* @returns EOK on success.
* @returns ENOENT if there no such device.
* @returns EINVAL if the service parameter is not known.
241,8 → 241,8
/*@}*/
 
/** Processes the received packet and chooses the target registered module.
* @param flags The device flags. Input parameter.
* @param packet The packet. Input parameter.
* @param[in] flags The device flags.
* @param[in] packet The packet.
* @returns The target registered module.
* @returns NULL if the packet is not long enough.
* @returns NULL if the packet is too long.
253,11 → 253,11
eth_proto_ref eth_process_packet( int flags, packet_t packet );
 
/** Prepares the packet for sending.
* @param flags The device flags. Input parameter.
* @param packet The packet. Input parameter.
* @param src_addr The source hardware address. Input parameter.
* @param ethertype The ethernet protocol type. Input parameter.
* @param mtu The device maximum transmission unit. Input parameter.
* @param[in] flags The device flags.
* @param[in] packet The packet.
* @param[in] src_addr The source hardware address.
* @param[in] ethertype The ethernet protocol type.
* @param[in] mtu The device maximum transmission unit.
* @returns EOK on success.
* @returns EINVAL if the packet addresses length is not long enough.
* @returns EINVAL if the packet is bigger than the device MTU.
/branches/network/uspace/srv/net/nil/eth/eth_module.c
62,7 → 62,7
 
/** Starts the Ethernet module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns Other error codes as defined for the pm_init() function.
* @returns Other error codes as defined for the nil_initialize() function.
71,10 → 71,10
int module_start( async_client_conn_t client_connection );
 
/** Passes the parameters to the module specific nil_message() function.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
/branches/network/uspace/srv/net/nil/nil_module.h
42,7 → 42,7
 
/** Module initialization.
* Is called by the module_start() function.
* @param net_phone The networking moduel phone. Input parameter.
* @param[in] net_phone The networking moduel phone.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module initialize function.
*/
49,10 → 49,10
int nil_initialize( int net_phone );
 
/** Message processing function.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
/branches/network/uspace/srv/net/nil/nildummy/nildummy.c
73,16 → 73,16
/*@{*/
 
/** Processes IPC messages from the registered device driver modules in an infinite loop.
* @param iid The message identifier. Input parameter.
* @param icall The message parameters. Input/output parameter.
* @param[in] iid The message identifier.
* @param[in,out] icall The message parameters.
*/
void nildummy_receiver( ipc_callid_t iid, ipc_call_t * icall );
 
/** Registers new device or updates the MTU of an existing one.
* Determines the device local hardware address.
* @param device_id The new device identifier. Input parameter.
* @param service The device driver service. Input parameter.
* @param mtu The device maximum transmission unit. Input parameter.
* @param[in] device_id The new device identifier.
* @param[in] service The device driver service.
* @param[in] mtu The device maximum transmission unit.
* @returns EOK on success.
* @returns EEXIST if the device with the different service exists.
* @returns ENOMEM if there is not enough memory left.
92,11 → 92,11
int nildummy_device_message( device_id_t device_id, services_t service, size_t mtu );
 
/** Returns the device packet dimensions for sending.
* @param device_id The device identifier. Input parameter.
* @param addr_len The minimum reserved address length. Output parameter.
* @param prefix The minimum reserved prefix size. Output parameter.
* @param content The maximum content size. Output parameter.
* @param suffix The minimum reserved suffix size. Output parameter.
* @param[in] device_id The device identifier.
* @param[out] addr_len The minimum reserved address length.
* @param[out] prefix The minimum reserved prefix size.
* @param[out] content The maximum content size.
* @param[out] suffix The minimum reserved suffix size.
* @returns EOK on success.
* @returns EBADMEM if either one of the parameters is NULL.
* @returns ENOENT if there is no such device.
105,8 → 105,8
 
/** Registers receiving module service.
* Passes received packets for this service.
* @param service The module service. Input parameter.
* @param phone The service phone. Input parameter.
* @param[in] service The module service.
* @param[in] phone The service phone.
* @returns EOK on success.
* @returns ENOENT if the service is not known.
* @returns ENOMEM if there is not enough memory left.
114,9 → 114,9
int nildummy_register_message( services_t service, int phone );
 
/** Sends the packet queue.
* @param device_id The device identifier. Input parameter.
* @param packet The packet queue. Input parameter.
* @param sender The sending module service. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] packet The packet queue.
* @param[in] sender The sending module service.
* @returns EOK on success.
* @returns ENOENT if there no such device.
* @returns EINVAL if the service parameter is not known.
124,8 → 124,8
int nildummy_send_message( device_id_t device_id, packet_t packet, services_t sender );
 
/** Returns the device hardware address.
* @param device_id The device identifier. Input parameter.
* @param address The device hardware address. Output parameter.
* @param[in] device_id The device identifier.
* @param[out] address The device hardware address.
* @returns EOK on success.
* @returns EBADMEM if the address parameter is NULL.
* @returns ENOENT if there no such device.
/branches/network/uspace/srv/net/nil/nildummy/nildummy_module.c
62,7 → 62,7
 
/** Starts the dummy nil module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns Other error codes as defined for the pm_init() function.
* @returns Other error codes as defined for the nil_initialize() function.
71,10 → 71,10
int module_start( async_client_conn_t client_connection );
 
/** Passes the parameters to the module specific nil_message() function.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
/branches/network/uspace/srv/net/structures/measured_strings.c
48,8 → 48,8
#include "measured_strings.h"
 
/** Computes the lengths of the measured strings in the given array.
* @param strings The measured strings array to be processed. Input parameter.
* @param count The measured strings array size. Input parameter.
* @param[in] strings The measured strings array to be processed.
* @param[in] count The measured strings array size.
* @returns The computed sizes array.
* @returns NULL if there is not enough memory left.
*/
/branches/network/uspace/srv/net/structures/char_map.h
77,10 → 77,10
};
 
/** Adds the value with the key to the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @param[in,out] map The character string to integer map.
* @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
* @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
* @param[in] value The integral value to be stored for the key character string.
* @returns EOK on success.
* @returns EINVAL if the map is not valid.
* @returns EINVAL if the identifier parameter is NULL.
91,15 → 91,15
int char_map_add( char_map_ref map, const char * identifier, size_t length, const int value );
 
/** Clears and destroys the map.
* @param map The character string to integer map. Input/output parameter.
* @param[in,out] map The character string to integer map.
*/
void char_map_destroy( char_map_ref map );
 
/** Excludes the value assigned to the key from the map.
* The entry is cleared from the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param[in,out] map The character string to integer map.
* @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
* @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
* @returns The integral value assigned to the key character string.
* @returns CHAR_MAP_NULL if the key is not assigned a&nbsp;value.
*/
106,9 → 106,9
int char_map_exclude( char_map_ref map, const char * identifier, size_t length );
 
/** Returns the value assigned to the key from the map.
* @param map The character string to integer map. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param[in] map The character string to integer map.
* @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
* @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
* @returns The integral value assigned to the key character string.
* @returns CHAR_MAP_NULL if the key is not assigned a&nbsp;value.
*/
115,7 → 115,7
int char_map_find( const char_map_ref map, const char * identifier, size_t length );
 
/** Initializes the map.
* @param map The character string to integer map. Input/output parameter.
* @param[in,out] map The character string to integer map.
* @returns EOK on success.
* @returns EINVAL if the map parameter is NULL.
* @returns ENOMEM if there is not enough memory left.
123,10 → 123,10
int char_map_initialize( char_map_ref map );
 
/** Adds or updates the value with the key to the map.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @param[in,out] map The character string to integer map.
* @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
* @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
* @param[in] value The integral value to be stored for the key character string.
* @returns EOK on success.
* @returns EINVAL if the map is not valid.
* @returns EINVAL if the identifier parameter is NULL.
/branches/network/uspace/srv/net/structures/measured_strings.h
65,8 → 65,8
/** Creates a&nbsp;new measured string bundled with a&nbsp;copy of the given string itself as one memory block.
* If the measured string is being freed, whole memory block is freed.
* The measured string should be used only as a&nbsp;constant.
* @param string The initial character string to be stored. Input parameter.
* @param length The length of the given string without the terminating zero ('/0') character. If the length is zero (0), the actual length is computed. The given length is used and appended with the terminating zero ('\\0') character otherwise. Input parameter.
* @param[in] string The initial character string to be stored.
* @param[in] length The length of the given string without the terminating zero ('/0') character. If the length is zero (0), the actual length is computed. The given length is used and appended with the terminating zero ('\\0') character otherwise.
* @returns The new bundled character string with measured length.
* @returns NULL if there is not enough memory left.
*/
73,7 → 73,7
measured_string_ref measured_string_create_bulk( const char * string, size_t length );
 
/** Copies the given measured string with separated header and data parts.
* @param source The source measured string to be copied. Input parameter.
* @param[in] source The source measured string to be copied.
* @returns The copy of the given measured string.
* @returns NULL if the source parameter is NULL.
* @returns NULL if there is not enough memory left.
83,9 → 83,9
/** Receives a&nbsp;measured strings array from a&nbsp;calling module.
* Creates the array and the data memory blocks.
* This method should be used only while processing IPC messages as the array size has to be negotiated in advance.
* @param strings The received measured strings array. Output parameter.
* @param data The measured strings data. This memory block stores the actual character strings. Output parameter.
* @param count The size of the measured strings array. Input parameter.
* @param[out] strings The received measured strings array.
* @param[out] data The measured strings data. This memory block stores the actual character strings.
* @param[in] count The size of the measured strings array.
* @returns EOK on success.
* @returns EINVAL if the strings or data parameter is NULL.
* @returns EINVAL if the count parameter is zero (0).
98,8 → 98,8
 
/** Replies the given measured strings array to a&nbsp;calling module.
* This method should be used only while processing IPC messages as the array size has to be negotiated in advance.
* @param strings The measured strings array to be transferred. Input parameter.
* @param count The measured strings array size. Input parameter.
* @param[in] strings The measured strings array to be transferred.
* @param[in] count The measured strings array size.
* @returns EOK on success.
* @returns EINVAL if the strings parameter is NULL.
* @returns EINVAL if the count parameter is zero (0).
112,10 → 112,10
/** Receives a&nbsp;measured strings array from another module.
* Creates the array and the data memory blocks.
* This method should be used only following other IPC messages as the array size has to be negotiated in advance.
* @param phone The other module phone. Input parameter.
* @param strings The returned measured strings array. Output parameter.
* @param data The measured strings data. This memory block stores the actual character strings. Output parameter.
* @param count The size of the measured strings array. Input parameter.
* @param[in] phone The other module phone.
* @param[out] strings The returned measured strings array.
* @param[out] data The measured strings data. This memory block stores the actual character strings.
* @param[in] count The size of the measured strings array.
* @returns EOK on success.
* @returns EINVAL if the strings or data parameter is NULL.
* @returns EINVAL if the phone or count parameter is not positive (<=0).
127,9 → 127,9
 
/** Sends the given measured strings array to another module.
* This method should be used only following other IPC messages as the array size has to be negotiated in advance.
* @param phone The other module phone. Input parameter.
* @param strings The measured strings array to be transferred. Input parameter.
* @param count The measured strings array size. Input parameter.
* @param[in] phone The other module phone.
* @param[in] strings The measured strings array to be transferred.
* @param[in] count The measured strings array size.
* @returns EOK on success.
* @returns EINVAL if the strings parameter is NULL.
* @returns EINVAL if the phone or count parameter is not positive (<=0).
/branches/network/uspace/srv/net/structures/generic_field.h
47,8 → 47,8
#define GENERIC_FIELD_MAGIC_VALUE 0x55667788
 
/** Generic type field declaration.
* @param name Name of the field. Input parameter.
* @param type Inner object type. Input parameter
* @param[in] name Name of the field.
* @param[in] type Inner object type.
*/
#define GENERIC_FIELD_DECLARE( name, type ) \
\
73,8 → 73,8
 
/** Generic type field implementation.
* Should follow declaration with the same parameters.
* @param name Name of the field. Input parameter.
* @param type Inner object type. Input parameter
* @param[in] name Name of the field.
* @param[in] type Inner object type.
*/
#define GENERIC_FIELD_IMPLEMENT( name, type ) \
\
/branches/network/uspace/srv/net/structures/packet/packet_remote.c
51,10 → 51,10
 
/** Obtains the packet from the packet server as the shared memory block.
* Creates the local packet mapping as well.
* @param phone The packet server module phone. Input parameter.
* @param packet The packet reference pointer to store the received packet reference. Output parameter.
* @param packet_id The packet identifier. Input parameter.
* @param size The packet total size in bytes. Input parameter.
* @param[in] phone The packet server module phone.
* @param[out] packet The packet reference pointer to store the received packet reference.
* @param[in] packet_id The packet identifier.
* @param[in] size The packet total size in bytes.
* @returns EOK on success.
* @returns Other error codes as defined for the pm_add() function.
* @returns Other error codes as defined for the ipc_share_in_start() function.
/branches/network/uspace/srv/net/structures/packet/packet_server.h
45,10 → 45,10
#include <ipc/ipc.h>
 
/** Processes the packet server message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
* @returns ENOENT if there is no such packet as in the packet message parameter..
/branches/network/uspace/srv/net/structures/packet/packet_header.h
40,17 → 40,17
#include "packet.h"
 
/** Returns the actual packet data length.
* @param header The packet header. Input parameter.
* @param[in] header The packet header.
*/
#define PACKET_DATA_LENGTH( header ) (( header )->data_end - ( header )->data_start )
 
/** Returns the maximum packet address length.
* @param header The packet header. Input parameter.
* @param[in] header The packet header.
*/
#define PACKET_MAX_ADDRESS_LENGTH( header ) (( header )->dest_addr - ( header )->src_addr )
 
/** Returns the minimum packet suffix.
* @param header The packet header. Input parameter.
* @param[in] header The packet header.
*/
#define PACKET_MIN_SUFFIX( header ) (( header )->length - ( header )->data_start - ( header )->max_content )
 
109,7 → 109,7
};
 
/** Returns whether the packet is valid.
* @param packet The packet to be checked. Input parameter.
* @param[in] packet The packet to be checked.
* @returns true if the packet is not NULL and the magic value is correct.
* @returns false otherwise.
*/
/branches/network/uspace/srv/net/structures/packet/packet.c
56,12 → 56,12
#define PACKET_MAP_SIZE 100
 
/** Returns the packet map page index.
* @param packet_id The packet identifier.
* @param[in] packet_id The packet identifier.
*/
#define PACKET_MAP_PAGE( packet_id ) ((( packet_id ) - 1 ) / PACKET_MAP_SIZE )
 
/** Returns the packet index in the corresponding packet map page.
* @param packet_id The packet identifier.
* @param[in] packet_id The packet identifier.
*/
#define PACKET_MAP_INDEX( packet_id ) ((( packet_id ) - 1 ) % PACKET_MAP_SIZE )
 
79,7 → 79,7
GENERIC_FIELD_DECLARE( gpm, packet_map_t );
 
/** Releases the packet.
* @param packet The packet to be released. Input parameter.
* @param[in] packet The packet to be released.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
*/
/branches/network/uspace/srv/net/structures/packet/packet_client.h
52,8 → 52,8
 
/** Allocates the specified type right before the actual packet content and returns its pointer.
* The wrapper of the packet_prepend() function.
* @param packet The packet to be used. Input parameter.
* @param type The type to be allocated at the beginning of the packet content. Input parameter.
* @param[in] packet The packet to be used.
* @param[in] type The type to be allocated at the beginning of the packet content.
* @returns The typed pointer to the allocated memory.
* @returns NULL if the packet is not valid.
* @returns NULL if there is not enough memory left.
62,8 → 62,8
 
/** Allocates the specified type right after the actual packet content and returns its pointer.
* The wrapper of the packet_append() function.
* @param packet The packet to be used. Input parameter.
* @param type The type to be allocated at the end of the packet content. Input parameter.
* @param[in] packet The packet to be used.
* @param[in] type The type to be allocated at the end of the packet content.
* @returns The typed pointer to the allocated memory.
* @returns NULL if the packet is not valid.
* @returns NULL if there is not enough memory left.
72,9 → 72,9
 
/** Trims the actual packet content by the specified prefix and suffix types.
* The wrapper of the packet_trim() function.
* @param packet The packet to be trimmed. Input parameter.
* @param prefix The type of the prefix to be removed from the beginning of the packet content. Input parameter.
* @param suffix The type of the suffix to be removed from the end of the packet content. Input parameter.
* @param[in] packet The packet to be trimmed.
* @param[in] prefix The type of the prefix to be removed from the beginning of the packet content.
* @param[in] suffix The type of the suffix to be removed from the end of the packet content.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns ENOMEM if there is not enough memory left.
82,8 → 82,8
#define PACKET_TRIM( packet, prefix, suffix ) packet_trim(( packet ), sizeof( prefix ), sizeof( suffix ))
 
/** Allocates the specified space right before the actual packet content and returns its pointer.
* @param packet The packet to be used. Input parameter.
* @param length The space length to be allocated at the beginning of the packet content. Input parameter.
* @param[in] packet The packet to be used.
* @param[in] length The space length to be allocated at the beginning of the packet content.
* @returns The pointer to the allocated memory.
* @returns NULL if there is not enough memory left.
*/
90,8 → 90,8
void * packet_prefix( packet_t packet, size_t length );
 
/** Allocates the specified space right after the actual packet content and returns its pointer.
* @param packet The packet to be used. Input parameter.
* @param length The space length to be allocated at the end of the packet content. Input parameter.
* @param[in] packet The packet to be used.
* @param[in] length The space length to be allocated at the end of the packet content.
* @returns The pointer to the allocated memory.
* @returns NULL if there is not enough memory left.
*/
98,9 → 98,9
void * packet_suffix( packet_t packet, size_t length );
 
/** Trims the actual packet content by the specified prefix and suffix lengths.
* @param packet The packet to be trimmed. Input parameter.
* @param prefix The prefix length to be removed from the beginning of the packet content. Input parameter.
* @param suffix The suffix length to be removed from the end of the packet content. Input parameter.
* @param[in] packet The packet to be trimmed.
* @param[in] prefix The prefix length to be removed from the beginning of the packet content.
* @param[in] suffix The suffix length to be removed from the end of the packet content.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns ENOMEM if there is not enough memory left.
109,9 → 109,9
 
/** Copies the specified data to the beginning of the actual packet content.
* Pushes the content end if needed.
* @param packet The packet to be filled. Input parameter.
* @param data The data to be copied. Input parameter.
* @param length The length of the copied data. Input parameter.
* @param[in] packet The packet to be filled.
* @param[in] data The data to be copied.
* @param[in] length The length of the copied data.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns ENOMEM if there is not enough memory left.
119,7 → 119,7
int packet_copy_data( packet_t packet, const void * data, size_t length );
 
/** Returns the packet identifier.
* @param packet The packet. Input parameter.
* @param[in] packet The packet.
* @returns The packet identifier.
* @returns Zero (0) if the packet is not valid.
*/
126,7 → 126,7
packet_id_t packet_get_id( const packet_t packet );
 
/** Returns the packet content length.
* @param packet The packet. Input parameter.
* @param[in] packet The packet.
* @returns The packet content length in bytes.
* @returns Zero (0) if the packet is not valid.
*/
133,7 → 133,7
size_t packet_get_data_length( const packet_t packet );
 
/** Returns the pointer to the beginning of the packet content.
* @param packet The packet. Input parameter.
* @param[in] packet The packet.
* @returns The pointer to the beginning of the packet content.
* @returns NULL if the packet is not valid.
*/
140,9 → 140,9
void * packet_get_data( const packet_t packet );
 
/** Returns the stored packet addresses and their length.
* @param packet The packet. Input parameter.
* @param src The source address. May be NULL if not desired. Output parameter.
* @param dest The destination address. May be NULL if not desired. Output parameter.
* @param[in] packet The packet.
* @param[out] src The source address. May be NULL if not desired.
* @param[out] dest The destination address. May be NULL if not desired.
* @returns The stored addresses length.
* @returns Zero (0) if the addresses are not present.
* @returns EINVAL if the packet is not valid.
150,10 → 150,10
int packet_get_addr( const packet_t packet, uint8_t ** src, uint8_t ** dest );
 
/** Sets the packet addresses.
* @param packet The packet. Input parameter.
* @param src The new source address. May be NULL. Input parameter.
* @param dest The new destination address. May be NULL. Input parameter.
* @param addr_len The addresses length.
* @param[in] packet The packet.
* @param[in] src The new source address. May be NULL.
* @param[in] dest The new destination address. May be NULL.
* @param[in] addr_len The addresses length.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns ENOMEM if there is not enough memory left.
163,9 → 163,9
/** Translates the packet identifier to the packet reference.
* Tries to find mapping first.
* Contacts the packet server to share the packet if the mapping is not present.
* @param phone The packet server module phone. Input parameter.
* @param packet The packet reference. Output parameter.
* @param packet_id The packet identifier. Input parameter.
* @param[in] phone The packet server module phone.
* @param[out] packet The packet reference.
* @param[in] packet_id The packet identifier.
* @returns EOK on success.
* @returns EINVAL if the packet parameter is NULL.
* @returns Other error codes as defined for the NET_PACKET_GET_SIZE message.
175,11 → 175,11
 
/** Obtains the packet of the given dimensions.
* Contacts the packet server to return the appropriate packet.
* @param phone The packet server module phone. Input parameter.
* @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
* @param max_prefix The maximal prefix length in bytes. Input parameter.
* @param max_content The maximal content length in bytes. Input parameter.
* @param max_suffix The maximal suffix length in bytes. Input parameter.
* @param[in] phone The packet server module phone.
* @param[in] addr_len The source and destination addresses maximal length in bytes.
* @param[in] max_prefix The maximal prefix length in bytes.
* @param[in] max_content The maximal content length in bytes.
* @param[in] max_suffix The maximal suffix length in bytes.
* @returns The packet reference.
* @returns NULL on error.
*/
187,8 → 187,8
 
/** Obtains the packet of the given content size.
* Contacts the packet server to return the appropriate packet.
* @param phone The packet server module phone. Input parameter.
* @param content The maximal content length in bytes. Input parameter.
* @param[in] phone The packet server module phone.
* @param[in] content The maximal content length in bytes.
* @returns The packet reference.
* @returns NULL on error.
*/
198,12 → 198,18
* All packets in the queue are marked as free for use.
* The packet queue may be one packet only.
* The module should not use the packets after this point until they are received or obtained again.
* @param phone The packet server module phone. Input parameter.
* @param packet_id The packet identifier. Input parameter.
* @param[in] phone The packet server module phone.
* @param[in] packet_id The packet identifier.
*/
void pq_release( int phone, packet_id_t packet_id );
 
/** \todo
/** Returns the packet copy.
* Copies the addresses, data, order and metric values.
* Does not copy the queue placement.
* @param[in] phone The packet server module phone.
* @param[in] packet The original packet.
* @returns The packet copy.
* @returns NULL on error.
*/
packet_t packet_get_copy( int phone, packet_t packet );
 
/branches/network/uspace/srv/net/structures/packet/packet.h
57,7 → 57,7
/*@{*/
 
/** Finds the packet mapping.
* @param packet_id The packet identifier to be found. Input parameter.
* @param[in] packet_id The packet identifier to be found.
* @returns The found packet reference.
* @returns NULL if the mapping does not exist.
*/
64,7 → 64,7
packet_t pm_find( packet_id_t packet_id );
 
/** Adds the packet mapping.
* @param packet The packet to be remembered. Input parameter.
* @param[in] packet The packet to be remembered.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns EINVAL if the packet map is not initialized.
85,10 → 85,10
/** Add packet to the sorted queue.
* The queue is sorted in the ascending order.
* The packet is inserted right before the packets of the same order value.
* @param first The first packet of the queue. May be NULL. Input parameter.
* @param packet The packet to be added. Input parameter.
* @param order The packet order value. Input parameter.
* @param metric The metric value of the packet. Input parameter.
* @param[in] first The first packet of the queue. May be NULL.
* @param[in] packet The packet to be added.
* @param[in] order The packet order value.
* @param[in] metric The metric value of the packet.
* @returns The first packet of the queue. The original first packet may be shifted by the new packet.
* @returns NULL if the packet is not valid.
*/
95,8 → 95,8
packet_t pq_add( packet_t first, packet_t packet, size_t order, size_t metric );
 
/** Finds the packet with the given order.
* @param first The first packet of the queue. Input parameter.
* @param order The packet order value. Input parameter.
* @param[in] first The first packet of the queue.
* @param[in] order The packet order value.
* @returns The packet with the given order.
* @returns NULL if the first packet is not valid.
* @returns NULL if the packet is not found.
104,8 → 104,8
packet_t pq_find( packet_t first, size_t order );
 
/** Inserts packet after the given one.
* @param packet The packet in the queue. Input parameter.
* @param new_packet The new packet to be inserted. Input parameter.
* @param[in] packet The packet in the queue.
* @param[in] new_packet The new packet to be inserted.
* @returns EOK on success.
* @returns EINVAL if etiher of the packets is invalid.
*/
112,7 → 112,7
int pq_insert_after( packet_t packet, packet_t new_packet );
 
/** Detach the packet from the queue.
* @param packet The packet to be detached. Input parameter.
* @param[in] packet The packet to be detached.
* @returns The next packet in the queue. If the packet is the first one of the queue, this becomes the new first one.
* @returns NULL if there is no packet left.
* @returns NULL if the packet is not valid.
120,9 → 120,9
packet_t pq_detach( packet_t packet );
 
/** Sets the packet order and metric attributes.
* @param packet The packet to be set. Input parameter.
* @param order The packet order value. Input parameter.
* @param metric The metric value of the packet. Input parameter.
* @param[in] packet The packet to be set.
* @param[in] order The packet order value.
* @param[in] metric The metric value of the packet.
* @returns EOK on success.
* @returns EINVAL if the packet is invalid..
*/
129,9 → 129,9
int pq_set_order( packet_t packet, size_t order, size_t metric );
 
/** Sets the packet order and metric attributes.
* @param packet The packet to be set. Input parameter.
* @param order The packet order value. Output parameter.
* @param metric The metric value of the packet. Ouput parameter.
* @param[in] packet The packet to be set.
* @param[out] order The packet order value.
* @param[out] metric The metric value of the packet.
* @returns EOK on success.
* @returns EINVAL if the packet is invalid..
*/
139,13 → 139,13
 
/** Releases the whole queue.
* Detaches all packets of the queue and calls the packet_release() for each of them.
* @param first The first packet of the queue. Input parameter.
* @param packet_release The releasing function called for each of the packets after its detachment. Input parameter.
* @param[in] first The first packet of the queue.
* @param[in] packet_release The releasing function called for each of the packets after its detachment.
*/
void pq_destroy( packet_t first, void ( * packet_release )( packet_t packet ));
 
/** Returns the next packet in the queue.
* @param packet The packet queue member. Input parameter.
* @param[in] packet The packet queue member.
* @returns The next packet in the queue.
* @returns NULL if there is no next packet.
* @returns NULL if the packet is not valid.
153,7 → 153,7
packet_t pq_next( packet_t packet );
 
/** Returns the previous packet in the queue.
* @param packet The packet queue member. Input parameter.
* @param[in] packet The packet queue member.
* @returns The previous packet in the queue.
* @returns NULL if there is no previous packet.
* @returns NULL if the packet is not valid.
/branches/network/uspace/srv/net/structures/packet/packet_server.c
105,10 → 105,10
* Tries to reuse free packets first.
* Creates a&nbsp;new packet aligned to the memory page size if none available.
* Locks the global data during its processing.
* @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
* @param max_prefix The maximal prefix length in bytes. Input parameter.
* @param max_content The maximal content length in bytes. Input parameter.
* @param max_suffix The maximal suffix length in bytes. Input parameter.
* @param[in] addr_len The source and destination addresses maximal length in bytes.
* @param[in] max_prefix The maximal prefix length in bytes.
* @param[in] max_content The maximal content length in bytes.
* @param[in] max_suffix The maximal suffix length in bytes.
* @returns The packet of dimensions at least as given.
* @returns NULL if there is not enough memory left.
*/
115,7 → 115,7
packet_t packet_get( size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
 
/** Releases the packet queue.
* @param packet_id The first packet identifier. Input parameter.
* @param[in] packet_id The first packet identifier.
* @returns EOK on success.
* @returns ENOENT if there is no such packet.
*/
123,17 → 123,17
 
/** Releases the packet and returns it to the appropriate free packet queue.
* Should be used only when the global data are locked.
* @param packet The packet to be released. Input parameter.
* @param[in] packet The packet to be released.
*/
void packet_release( packet_t packet );
 
/** Creates a&nbsp;new packet of dimensions at least as given.
* Should be used only when the global data are locked.
* @param length The total length of the packet, including the header, the addresses and the data of the packet. Input parameter.
* @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
* @param max_prefix The maximal prefix length in bytes. Input parameter.
* @param max_content The maximal content length in bytes. Input parameter.
* @param max_suffix The maximal suffix length in bytes. Input parameter.
* @param[in] length The total length of the packet, including the header, the addresses and the data of the packet.
* @param[in] addr_len The source and destination addresses maximal length in bytes.
* @param[in] max_prefix The maximal prefix length in bytes.
* @param[in] max_content The maximal content length in bytes.
* @param[in] max_suffix The maximal suffix length in bytes.
* @returns The packet of dimensions at least as given.
* @returns NULL if there is not enough memory left.
*/
140,16 → 140,16
packet_t packet_create( size_t length, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
 
/** Clears and initializes the packet according to the given dimensions.
* @param packet The packet to be initialized. Input parameter.
* @param addr_len The source and destination addresses maximal length in bytes. Input parameter.
* @param max_prefix The maximal prefix length in bytes. Input parameter.
* @param max_content The maximal content length in bytes. Input parameter.
* @param max_suffix The maximal suffix length in bytes. Input parameter.
* @param[in] packet The packet to be initialized.
* @param[in] addr_len The source and destination addresses maximal length in bytes.
* @param[in] max_prefix The maximal prefix length in bytes.
* @param[in] max_content The maximal content length in bytes.
* @param[in] max_suffix The maximal suffix length in bytes.
*/
void packet_init( packet_t packet, size_t addr_len, size_t max_prefix, size_t max_content, size_t max_suffix );
 
/** Shares the packet memory block.
* @param packet The packet to be shared.
* @param[in] packet The packet to be shared.
* @returns EOK on success.
* @returns EINVAL if the packet is not valid.
* @returns EINVAL if the calling module does not accept the memory.
/branches/network/uspace/srv/net/structures/dynamic_fifo.c
46,13 → 46,13
 
/** Returns the next queue index.
* The queue field is circular.
* @param fifo The dynamic queue. Input parameter.
* @param index The actual index to be shifted. Input parameter.
* @param[in] fifo The dynamic queue.
* @param[in] index The actual index to be shifted.
*/
#define NEXT_INDEX( fifo, index ) ((( index ) + 1 ) % (( fifo )->size + 1 ))
 
/** Checks if the queue is valid.
* @param fifo The dynamic queue. Input parameter.
* @param[in] fifo The dynamic queue.
* @returns TRUE if the queue is valid.
* @returns FALSE otherwise.
*/
/branches/network/uspace/srv/net/structures/module_map.h
88,13 → 88,13
};
 
/** Adds module to the module map.
* @param module The module structure added. Output parameter.
* @param modules The module map. Input parameter.
* @param name The module name. Input parameter.
* @param filename The full path filename. Input parameter.
* @param service The module service. Input parameter.
* @param task_id The module current task identifier. Zero (0) means not running. Input parameter.
* @param connect_module The module connecting function. Input parameter.
* @param[out] module The module structure added.
* @param[in] modules The module map.
* @param[in] name The module name.
* @param[in] filename The full path filename.
* @param[in] service The module service.
* @param[in] task_id The module current task identifier. Zero (0) means not running.
* @param[in] connect_module The module connecting function.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
103,8 → 103,8
/** Searches and returns the specified module.
* If the module is not running, the module filaname is spawned.
* If the module is not connected, the connect_function is called.
* @param modules The module map. Input parameter.
* @param name The module name. Input parameter.
* @param[in] modules The module map.
* @param[in] name The module name.
* @returns The running module found. It does not have to be connected.
* @returns NULL if there is no such module.
*/
111,7 → 111,7
module_ref get_running_module( modules_ref modules, char * name );
 
/** Starts the given module.
* @param fname The module full or relative path filename. Input parameter.
* @param[in] fname The module full or relative path filename.
* @returns The new module task identifier on success.
* @returns 0 if there is no such module.
*/
/branches/network/uspace/srv/net/structures/char_map.c
48,10 → 48,10
 
/** Adds the value with the key to the map.
* Creates new nodes to map the key.
* @param map The character string to integer map. Input/output parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param value The integral value to be stored for the key character string. Input parameter.
* @param[in,out] map The character string to integer map.
* @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
* @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
* @param[in] value The integral value to be stored for the key character string.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
* @returns EEXIST if the key character string is already used.
59,9 → 59,9
int char_map_add_item( char_map_ref map, const char * identifier, size_t length, const int value );
 
/** Returns the node assigned to the key from the map.
* @param map The character string to integer map. Input parameter.
* @param identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found. Input parameter.
* @param length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found. Input parameter.
* @param[in] map The character string to integer map.
* @param[in] identifier The key zero ('\\0') terminated character string. The key character string is processed until the first terminating zero ('\\0') character after the given length is found.
* @param[in] length The key character string length. The parameter may be zero (0) which means that the string is processed until the terminating zero ('\\0') character is found.
* @returns The node holding the integral value assigned to the key character string.
* @returns NULL if the key is not assigned a&nbsp;node.
*/
68,7 → 68,7
char_map_ref char_map_find_node( const char_map_ref map, const char * identifier, const size_t length );
 
/** Returns the value assigned to the map.
* @param map The character string to integer map. Input parameter.
* @param[in] map The character string to integer map.
* @returns The integral value assigned to the map.
* @returns CHAR_MAP_NULL if the map is not assigned a&nbsp;value.
*/
75,7 → 75,7
int char_map_get_value( const char_map_ref map );
 
/** Checks if the map is valid.
* @param map The character string to integer map. Input parameter.
* @param[in] map The character string to integer map.
* @returns TRUE if the map is valid.
* @returns FALSE otherwise.
*/
/branches/network/uspace/srv/net/structures/generic_char_map.h
50,8 → 50,8
#define GENERIC_CHAR_MAP_MAGIC_VALUE 0x12345622
 
/** Character string to generic type map declaration.
* @param name Name of the map. Input parameter.
* @param type Inner object type. Input parameter
* @param[in] name Name of the map.
* @param[in] type Inner object type.
*/
#define GENERIC_CHAR_MAP_DECLARE( name, type ) \
\
76,8 → 76,8
 
/** Character string to generic type map implementation.
* Should follow declaration with the same parameters.
* @param name Name of the map. Input parameter.
* @param type Inner object type. Input parameter
* @param[in] name Name of the map.
* @param[in] type Inner object type.
*/
#define GENERIC_CHAR_MAP_IMPLEMENT( name, type ) \
\
/branches/network/uspace/srv/net/structures/dynamic_fifo.h
71,8 → 71,8
};
 
/** Initializes the dynamic queue.
* @param fifo The dynamic queue. Input/output parameter.
* @param size The initial queue size. Input parameter.
* @param[in,out] fifo The dynamic queue.
* @param[in] size The initial queue size.
* @returns EOK on success.
* @returns EINVAL if the queue is not valid.
* @returns EBADMEM if the fifo parameter is NULL.
81,9 → 81,9
int dyn_fifo_initialize( dyn_fifo_ref fifo, int size );
 
/** Appends a new item to the queue end.
* @param fifo The dynamic queue. Input/output parameter.
* @param value The new item value. Should be positive. Input parameter.
* @param max_size The maximum queue size. The queue is not resized beyound this limit. May be zero or negative (<=0) to indicate no limit. Input parameter.
* @param[in,out] fifo The dynamic queue.
* @param[in] value The new item value. Should be positive.
* @param[in] max_size The maximum queue size. The queue is not resized beyound this limit. May be zero or negative (<=0) to indicate no limit.
* @returns EOK on success.
* @returns EINVAL if the queue is not valid.
* @returns ENOMEM if there is not enough memory left.
91,7 → 91,7
int dyn_fifo_push( dyn_fifo_ref fifo, int value, int max_size );
 
/** Returns and excludes the first item in the queue.
* @param fifo The dynamic queue. Input/output parameter.
* @param[in,out] fifo The dynamic queue.
* @returns Value of the first item in the queue.
* @returns EINVAL if the queue is not valid.
* @returns ENOENT if the queue is empty.
99,7 → 99,7
int dyn_fifo_pop( dyn_fifo_ref fifo );
 
/** Returns and keeps the first item in the queue.
* @param fifo The dynamic queue. Input/output parameter.
* @param[in,out] fifo The dynamic queue.
* @returns Value of the first item in the queue.
* @returns EINVAL if the queue is not valid.
* @returns ENOENT if the queue is empty.
107,7 → 107,7
int dyn_fifo_value( dyn_fifo_ref fifo );
 
/** Clears and destroys the queue.
* @param fifo The dynamic queue. Input/output parameter.
* @param[in,out] fifo The dynamic queue.
* @returns EOK on success.
* @returns EINVAL if the queue is not valid.
*/
/branches/network/uspace/srv/net/structures/int_map.h
51,8 → 51,8
#define INT_MAP_ITEM_MAGIC_VALUE 0x55667788
 
/** Integer to generic type map declaration.
* @param name Name of the map. Input parameter.
* @param type Inner object type. Input parameter
* @param[in] name Name of the map.
* @param[in] type Inner object type.
*/
#define INT_MAP_DECLARE( name, type ) \
\
89,8 → 89,8
 
/** Integer to generic type map implementation.
* Should follow declaration with the same parameters.
* @param name Name of the map. Input parameter.
* @param type Inner object type. Input parameter
* @param[in] name Name of the map.
* @param[in] type Inner object type.
*/
#define INT_MAP_IMPLEMENT( name, type ) \
\
/branches/network/uspace/srv/net/checksum.c
38,8 → 38,12
 
#include "include/checksum.h"
 
/** Big-endian encoding CRC divider.
*/
#define CRC_DIVIDER_BE 0x04C11DB7
 
/** Little-endian encoding CRC divider.
*/
#define CRC_DIVIDER_LE 0xEDB88320
 
/** IP checksum value for computed zero checksum.
/branches/network/uspace/srv/net/include/netdb.h
90,19 → 90,18
/*@}*/
 
/** Returns host entry by the host address.
* \todo address type?
* @param address The host address. Input parameter.
* @param len The address length. Input parameter.
* @param type The address type. Input parameter.
* @param[in] address The host address.
* @param[in] len The address length.
* @param[in] type The address type.
* @returns Host entry information.
*/
struct hostent * gethostbyaddr( const void * address, int len, int type );
//struct hostent * gethostbyaddr( const void * address, int len, int type );
 
/** Returns host entry by the host name.
* @param name The host name. Input parameter.
* @param[in] name The host name.
* @returns Host entry information.
*/
struct hostent * gethostbyname( const char * name );
//struct hostent * gethostbyname( const char * name );
 
#endif
 
/branches/network/uspace/srv/net/include/protocol_map.h
44,8 → 44,8
#include "hardware.h"
 
/** Maps the internetwork layer service to the network interface layer type.
* @param nil Network interface layer service. Input parameter.
* @param il Internetwork layer service. Input parameter.
* @param[in] nil Network interface layer service.
* @param[in] il Internetwork layer service.
* @returns Network interface layer type of the internetworking layer service.
* @returns 0 if mapping is not found.
*/
67,8 → 67,8
}
 
/** Maps the network interface layer type to the internetwork layer service.
* @param nil Network interface layer service. Input parameter.
* @param protocol Network interface layer type. Input parameter.
* @param[in] nil Network interface layer service.
* @param[in] protocol Network interface layer type.
* @returns Internetwork layer service of the network interface layer type.
* @returns 0 if mapping is not found.
*/
90,7 → 90,7
}
 
/** Maps the link service access point identifier to the Ethernet protocol identifier.
* @param lsap Link service access point identifier. Input parameter.
* @param[in] lsap Link service access point identifier.
* @returns Ethernet protocol identifier of the link service access point identifier.
* @returns ETH_LSAP_NULL if mapping is not found.
*/
106,7 → 106,7
}
 
/** Maps the Ethernet protocol identifier to the link service access point identifier.
* @param ethertype Ethernet protocol identifier. Input parameter.
* @param[in] ethertype Ethernet protocol identifier.
* @returns Link service access point identifier.
* @returns 0 if mapping is not found.
*/
122,7 → 122,7
}
 
/** Maps the network interface layer services to the hardware types.
* @param nil The network interface service. Input parameter.
* @param[in] nil The network interface service.
* @returns The hardware type of the network interface service.
* @returns 0 if mapping is not found.
*/
/branches/network/uspace/srv/net/include/tl_interface.h
56,11 → 56,11
/*@{*/
 
/** Notifies the remote transport layer modules about the received packet/s.
* @param tl_phone The transport layer module phone used for remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param packet The received packet or the received packet queue. The packet queue is used to carry a~fragmented datagram. The first packet contains the headers, the others contain only data. Input parameter.
* @param target The target transport layer module service to be delivered to. Input parameter.
* @param error The packet error reporting service. Prefixes the received packet. Input parameter.
* @param[in] tl_phone The transport layer module phone used for remote calls.
* @param[in] device_id The device identifier.
* @param[in] packet The received packet or the received packet queue. The packet queue is used to carry a~fragmented datagram. The first packet contains the headers, the others contain only data.
* @param[in] target The target transport layer module service to be delivered to.
* @param[in] error The packet error reporting service. Prefixes the received packet.
* @returns EOK on success.
*/
inline static int tl_received_msg( int tl_phone, device_id_t device_id, packet_t packet, services_t target, services_t error ){
/branches/network/uspace/srv/net/include/byteorder.h
46,25 → 46,25
// Already in the network byte order.
 
/** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ).
* @param number The number in the host byte order to be converted.
* @param[in] number The number in the host byte order to be converted.
* @returns The number in the network byte order.
*/
#define htons( number ) ( number )
 
/** Converts the given long number ( 32 bit ) from the host byte order to the network byte order ( big endian ).
* @param number The number in the host byte order to be converted.
* @param[in] number The number in the host byte order to be converted.
* @returns The number in the network byte order.
*/
#define htonl( number ) ( number )
 
/** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order.
* @param number The number in the network byte order to be converted.
* @param[in] number The number in the network byte order to be converted.
* @returns The number in the host byte order.
*/
#define ntohs( number ) ( number )
 
/** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order.
* @param number The number in the network byte order to be converted.
* @param[in] number The number in the network byte order to be converted.
* @returns The number in the host byte order.
*/
#define ntohl( number ) ( number )
74,25 → 74,25
// Has to be swapped.
 
/** Converts the given short number ( 16 bit ) from the host byte order to the network byte order ( big endian ).
* @param number The number in the host byte order to be converted.
* @param[in] number The number in the host byte order to be converted.
* @returns The number in the network byte order.
*/
#define htons( number ) uint16_t_byteorder_swap(( uint16_t )( number ))
 
/** Converts the given long number ( 32 bit ) from the host byte order to the network byte order ( big endian ).
* @param number The number in the host byte order to be converted.
* @param[in] number The number in the host byte order to be converted.
* @returns The number in the network byte order.
*/
#define htonl( number ) uint32_t_byteorder_swap( number )
 
/** Converts the given short number ( 16 bit ) from the network byte order ( big endian ) to the host byte order.
* @param number The number in the network byte order to be converted.
* @param[in] number The number in the network byte order to be converted.
* @returns The number in the host byte order.
*/
#define ntohs( number ) uint16_t_byteorder_swap(( uint16_t )( number ))
 
/** Converts the given long number ( 32 bit ) from the network byte order ( big endian ) to the host byte order.
* @param number The number in the network byte order to be converted.
* @param[in] number The number in the network byte order to be converted.
* @returns The number in the host byte order.
*/
#define ntohl( number ) uint32_t_byteorder_swap( number )
/branches/network/uspace/srv/net/include/inet.h
52,10 → 52,10
typedef struct addrinfo addrinfo_t;
 
/** Prints the address into the character buffer.
* @param family The address family. Input parameter.
* @param data The address data. Input parameter.
* @param address The character buffer to be filled. Output parameter.
* @param length The buffer length. Input parameter.
* @param[in] family The address family.
* @param[in] data The address data.
* @param[out] address The character buffer to be filled.
* @param[in] length The buffer length.
* @returns EOK on success.
* @returns EINVAL if the data or address parameter is NULL.
* @returns ENOMEM if the character buffer is not long enough.
65,9 → 65,9
 
/** Parses the character string into the address.
* If the string is shorter than the full address, zero bytes are added.
* @param family The address family. Input parameter.
* @param address The character buffer to be parsed. Input parameter.
* @param data The address data to be filled. Output parameter.
* @param[in] family The address family.
* @param[in] address The character buffer to be parsed.
* @param[out] data The address data to be filled.
* @returns EOK on success.
* @returns EINVAL if the data parameter is NULL.
* @returns ENOENT if the address parameter is NULL.
87,25 → 87,25
uint8_t sa_data[ 14 ];
};
 
/** Address information.
* \todo
*/
struct addrinfo{
int ai_flags; // AI_PASSIVE, AI_CANONNAME, etc.
uint16_t ai_family; // AF_INET, AF_INET6, AF_UNSPEC
int ai_socktype; // SOCK_STREAM, SOCK_DGRAM
int ai_protocol; // use 0 for "any"
size_t ai_addrlen; // size of ai_addr in bytes
struct sockaddr * ai_addr; // struct sockaddr_in or _in6
char * ai_canonname; // full canonical hostname
struct addrinfo * ai_next; // linked list, next node
};
// TODO define address information
// /** Address information.
// * \todo
// */
//struct addrinfo{
// int ai_flags; // AI_PASSIVE, AI_CANONNAME, etc.
// uint16_t ai_family; // AF_INET, AF_INET6, AF_UNSPEC
// int ai_socktype; // SOCK_STREAM, SOCK_DGRAM
// int ai_protocol; // use 0 for "any"
// size_t ai_addrlen; // size of ai_addr in bytes
// struct sockaddr * ai_addr; // struct sockaddr_in or _in6
// char * ai_canonname; // full canonical hostname
// struct addrinfo * ai_next; // linked list, next node
//};
 
/*int getaddrinfo(const char *node, // e.g. "www.example.com" or IP
const char *service, // e.g. "http" or port number
const struct addrinfo *hints,
struct addrinfo **res);
 
getnameinfo
*/
 
/branches/network/uspace/srv/net/include/nil_interface.h
61,12 → 61,12
/*@{*/
 
/** Returns the device local hardware address.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param address The device local hardware address. Output parameter.
* @param data The address data. Output parameter.
* @param[in] nil_phone The network interface layer phone.
* @param[in] device_id The device identifier.
* @param[out] address The device local hardware address.
* @param[out] data The address data.
* @returns EOK on success.
* @returns EBADMEM if the address parameter is NULL.
* @returns EBADMEM if the address parameter and/or the data parameter is NULL.
* @returns ENOENT if there no such device.
* @returns Other error codes as defined for the generic_get_addr_req() function.
*/
74,10 → 74,10
generic_get_addr_req( nil_phone, NET_NIL_ADDR, device_id, address, data )
 
/** Returns the device broadcast hardware address.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param address The device broadcast hardware address. Output parameter.
* @param data The address data. Output parameter.
* @param[in] nil_phone The network interface layer phone.
* @param[in] device_id The device identifier.
* @param[out] address The device broadcast hardware address.
* @param[out] data The address data.
* @returns EOK on success.
* @returns EBADMEM if the address parameter is NULL.
* @returns ENOENT if there no such device.
87,10 → 87,10
generic_get_addr_req( nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data )
 
/** Sends the packet queue.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param packet The packet queue. Input parameter.
* @param sender The sending module service. Input parameter.
* @param[in] nil_phone The network interface layer phone.
* @param[in] device_id The device identifier.
* @param[in] packet The packet queue.
* @param[in] sender The sending module service.
* @returns EOK on success.
* @returns Other error codes as defined for the generic_send_msg() function.
*/
98,12 → 98,12
generic_send_msg( nil_phone, NET_NIL_SEND, device_id, packet_get_id( packet ), sender, 0 )
 
/** Returns the device packet dimensions for sending.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param addr_len The minimum reserved address length. Output parameter.
* @param prefix The minimum reserved prefix size. Output parameter.
* @param content The maximum content size. Output parameter.
* @param suffix The minimum reserved suffix size. Output parameter.
* @param[in] nil_phone The network interface layer phone.
* @param[in] device_id The device identifier.
* @param[out] addr_len The minimum reserved address length.
* @param[out] prefix The minimum reserved prefix size.
* @param[out] content The maximum content size.
* @param[out] suffix The minimum reserved suffix size.
* @returns EOK on success.
* @returns EBADMEM if either one of the parameters is NULL.
* @returns ENOENT if there is no such device.
113,10 → 113,10
generic_packet_size_req( nil_phone, NET_NIL_PACKET_SPACE, device_id, addr_len, prefix, content, suffix )
 
/** Registers new device or updates the MTU of an existing one.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The new device identifier. Input parameter.
* @param mtu The device maximum transmission unit. Input parameter.
* @param netif_service The device driver service. Input parameter.
* @param[in] nil_phone The network interface layer phone.
* @param[in] device_id The new device identifier.
* @param[in] mtu The device maximum transmission unit.
* @param[in] netif_service The device driver service.
* @returns EOK on success.
* @returns EEXIST if the device with the different service exists.
* @returns ENOMEM if there is not enough memory left.
126,9 → 126,9
generic_device_req( nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service )
 
/** Notifies the network interface layer about the device state change.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param state The new device state. Input parameter.
* @param[in] nil_phone The network interface layer phone.
* @param[in] device_id The device identifier.
* @param[in] state The new device state.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module device state function.
*/
136,9 → 136,9
 
/** Passes the packet queue to the network interface layer.
* Processes and redistributes the received packet queue to the registered upper layers.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The source device identifier. Input parameter.
* @param packet The received packet or the received packet queue. Input parameter.
* @param[in] nil_phone The network interface layer phone.
* @param[in] device_id The source device identifier.
* @param[in] packet The received packet or the received packet queue.
* @param target The target service. Ignored parameter.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module received function.
146,10 → 146,10
int nil_received_msg( int nil_phone, device_id_t device_id, packet_t packet, services_t target );
 
/** Creates bidirectional connection with the network interface layer module and registers the message receiver.
* @param service The network interface layer module service. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param me The requesting module service. Input parameter.
* @param receiver The message receiver. Input parameter.
* @param[in] service The network interface layer module service.
* @param[in] device_id The device identifier.
* @param[in] me The requesting module service.
* @param[in] receiver The message receiver.
* @returns The phone of the needed service.
* @returns EOK on success.
* @returns Other error codes as defined for the bind_service() function.
/branches/network/uspace/srv/net/include/arp_interface.h
52,11 → 52,11
/** Registers the new device and the requesting protocol service.
* Connects to the network interface layer service.
* Determines the device broadcast address, its address lengths and packet size.
* @param arp_phone The ARP module phone used for (semi)remote calls. Input parameter.
* @param device_id The new device identifier. Input parameter.
* @param protocol The requesting protocol service. Input parameter.
* @param netif The underlying device network interface layer service. Input parameter.
* @param address The local requesting protocol address of the device. Input parameter.
* @param[in] arp_phone The ARP module phone used for (semi)remote calls.
* @param[in] device_id The new device identifier.
* @param[in] protocol The requesting protocol service.
* @param[in] netif The underlying device network interface layer service.
* @param[in] address The local requesting protocol address of the device.
* @returns EOK on success.
* @returns EEXIST if the device is already used.
* @returns ENOMEM if there is not enough memory left.
71,15 → 71,14
/** Translates the given protocol address to the network interface address.
* Broadcasts the ARP request if the mapping is not found.
* Allocates and returns the needed memory block as the data parameter.
* @param arp_phone The ARP module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param protocol The requesting protocol service. Input parameter.
* @param address The local requesting protocol address. Input parameter.
* @param translation The translation of the local protocol address. Output parameter.
* @param data The allocated raw translation data container. Output parameter.
* @param[in] arp_phone The ARP module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[in] protocol The requesting protocol service.
* @param[in] address The local requesting protocol address.
* @param[out] translation The translation of the local protocol address.
* @param[out] data The allocated raw translation data container.
* @returns EOK on success.
* @returns EINVAL if the configuration parameter is NULL.
* @returns EINVAL if the count parameter is zero (0).
* @returns EINVAL if the address parameter is NULL.
* @returns EBADMEM if the translation or the data parameters are NULL.
* @returns ENOENT if the mapping is not found.
*/
86,8 → 85,8
int arp_translate_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data );
 
/** Clears the device cache.
* @param arp_phone The ARP module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param[in] arp_phone The ARP module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @returns EOK on success.
* @returns ENOENT if the device is not found.
*/
94,10 → 93,10
int arp_clear_device_req( int arp_phone, device_id_t device_id );
 
/** Clears the given protocol address from the cache.
* @param arp_phone The ARP module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param protocol The requesting protocol service. Input parameter.
* @param address The protocol address to be cleared. Input parameter.
* @param[in] arp_phone The ARP module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[in] protocol The requesting protocol service.
* @param[in] address The protocol address to be cleared.
* @returns EOK on success.
* @returns ENOENT if the mapping is not found.
*/
104,7 → 103,7
int arp_clear_address_req( int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address );
 
/** Cleans the cache.
* @param arp_phone The ARP module phone used for (semi)remote calls. Input parameter.
* @param[in] arp_phone The ARP module phone used for (semi)remote calls.
* @returns EOK on success.
*/
int arp_clean_cache_req( int arp_phone );
/branches/network/uspace/srv/net/include/checksum.h
42,9 → 42,9
#include <sys/types.h>
 
/** Computes CRC32 value.
* @param seed Initial value. Often used as 0 or ~0. Input parameter.
* @param data Pointer to the beginning of data to process. Input parameter.
* @param length Length of the data in bits. Input parameter.
* @param[in] seed Initial value. Often used as 0 or ~0.
* @param[in] data Pointer to the beginning of data to process.
* @param[in] length Length of the data in bits.
* @returns The computed CRC32 of the length bits of the data.
*/
#ifdef ARCH_IS_BIG_ENDIAN
54,17 → 54,17
#endif
 
/** Computes CRC32 value in the little-endian environment.
* @param seed Initial value. Often used as 0 or ~0. Input parameter.
* @param data Pointer to the beginning of data to process. Input parameter.
* @param length Length of the data in bits. Input parameter.
* @param[in] seed Initial value. Often used as 0 or ~0.
* @param[in] data Pointer to the beginning of data to process.
* @param[in] length Length of the data in bits.
* @returns The computed CRC32 of the length bits of the data.
*/
uint32_t compute_crc32_le( uint32_t seed, uint8_t * data, size_t length );
 
/** Computes CRC32 value in the big-endian environment.
* @param seed Initial value. Often used as 0 or ~0. Input parameter.
* @param data Pointer to the beginning of data to process. Input parameter.
* @param length Length of the data in bits. Input parameter.
* @param[in] seed Initial value. Often used as 0 or ~0.
* @param[in] data Pointer to the beginning of data to process.
* @param[in] length Length of the data in bits.
* @returns The computed CRC32 of the length bits of the data.
*/
uint32_t compute_crc32_be( uint32_t seed, uint8_t * data, size_t length );
71,21 → 71,21
 
/** Computes sum of the 2 byte fields.
* Padds one zero (0) byte if odd.
* @param seed Initial value. Often used as 0 or ~0. Input parameter.
* @param data Pointer to the beginning of data to process. Input parameter.
* @param length Length of the data in bytes. Input parameter.
* @param[in] seed Initial value. Often used as 0 or ~0.
* @param[in] data Pointer to the beginning of data to process.
* @param[in] length Length of the data in bytes.
* @returns The computed checksum of the length bytes of the data.
*/
uint32_t compute_checksum( uint32_t seed, uint8_t * data, size_t length );
 
/** Compacts the computed checksum to the 16 bit number adding the carries.
* @param sum Computed checksum. Input parameter.
* @param[in] sum Computed checksum.
* @returns Compacted computed checksum to the 16 bits.
*/
uint16_t compact_checksum( uint32_t sum );
 
/** Returns or flips the checksum if zero.
* @param checksum The computed checksum. Input parameter.
* @param[in] checksum The computed checksum.
* @returns The internet protocol header checksum.
* @returns 0xFFFF if the computed checksum is zero.
*/
95,8 → 95,8
* To compute the checksum of a new packet, the checksum header field must be zero.
* To check the checksum of a received packet, the checksum may be left set.
* The zero (0) value will be returned in this case if valid.
* @param data The header data. Input parameter.
* @param length The header length in bytes. Input parameter.
* @param[in] data The header data.
* @param[in] length The header length in bytes.
* @returns The internet protocol header checksum.
* @returns 0xFFFF if the computed checksum is zero.
*/
/branches/network/uspace/srv/net/include/ip_client.h
31,7 → 31,7
*/
 
/** @file
* \todo
* IP client interface.
*/
 
#ifndef __NET_IP_CLIENT_H__
45,22 → 45,67
#include "ip_interface.h"
#include "socket_codes.h"
 
/** Prepares the packet to be transfered via IP.
* The IP header is prefixed.
* @param[in,out] packet The packet to be prepared.
* @param[in] protocol The transport protocol.
* @param[in] ttl The time to live counter. The IPDEFTTL is set if zero (0).
* @param[in] tos The type of service.
* @param[in] dont_fragment The value indicating whether fragmentation is disabled.
* @param[in] ipopt_length The prefixed IP options length in bytes.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left in the packet.
*/
int ip_client_prepare_packet( packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length );
 
/** Processes the received IP packet.
* Fills set header fields.
* Returns the prefixed IP header length.
* @param[in] packet The received packet.
* @param[out] protocol The transport protocol. May be NULL if not desired.
* @param[out] ttl The time to live counter. May be NULL if not desired.
* @param[out] tos The type of service. May be NULL if not desired.
* @param[out] dont_fragment The value indicating whether the fragmentation is disabled. May be NULL if not desired.
* @param[out] ipopt_length The IP options length in bytes. May be NULL if not desired.
* @returns The prefixed IP header length in bytes on success.
* @returns ENOMEM if the packet is too short to contain the IP header.
*/
int ip_client_process_packet( packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length );
 
/** Returns the IP header length.
* @param packet The packet. Input parameter.
* @param[in] packet The packet.
* @returns The IP header length in bytes.
* @returns Zero (0) if there is no IP header.
*/
size_t ip_client_header_length( packet_t packet );
 
/** \todo
/** Updates the IPv4 pseudo header data length field.
* @param[in,out] header The IPv4 pseudo header to be updated.
* @param[in] headerlen The length of the IP pseudo header in bytes.
* @param[in] data_length The data length to be set.
* @returns EOK on success.
* @returns EBADMEM if the header parameter is NULL.
* @returns EINVAL if the headerlen parameter is not IPv4 pseudo header length.
*/
int ip_client_set_pseudo_header_data_length( ip_pseudo_header_ref header, size_t headerlen, size_t data_length );
 
/** \todo
/** Constructs the IPv4 pseudo header.
* @param[in] protocol The transport protocol.
* @param[in] src The source address.
* @param[in] srclen The source address length.
* @param[in] dest The destination address.
* @param[in] destlen The destination address length.
* @param[in] data_length The data length to be set.
* @param[out] header The constructed IPv4 pseudo header.
* @param[out] headerlen The length of the IP pseudo header in bytes.
* @returns EOK on success.
* @returns EBADMEM if the header and/or the headerlen parameter is NULL.
* @returns EINVAL if the source address and/or the destination address parameter is NULL.
* @returns EINVAL if the source address length is less than struct sockaddr length.
* @returns EINVAL if the source address length differs from the destination address length.
* @returns EINVAL if the source address family differs from the destination family.
* @returns EAFNOSUPPORT if the address family is not supported.
* @returns ENOMEM if there is not enough memory left.
*/
int ip_client_get_pseudo_header( ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, ip_pseudo_header_ref * header, size_t * headerlen );
 
/branches/network/uspace/srv/net/include/net_interface.h
55,11 → 55,11
* Returns the global configuration if the device specific is not found.
* The configuration names are read and the appropriate settings are set instead.
* Call net_free_settings() function to release the returned configuration.
* @param net_phone The networking module phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param configuration The requested device configuration. The names are read and the appropriate settings are set instead. Input/output parameter.
* @param count The configuration entries count. Input parameter.
* @param data The configuration and settings data. Input/output parameter.
* @param[in] net_phone The networking module phone.
* @param[in] device_id The device identifier.
* @param[in,out] configuration The requested device configuration. The names are read and the appropriate settings are set instead.
* @param[in] count The configuration entries count.
* @param[in,out] data The configuration and settings data.
* @returns EOK on success.
* @returns EINVAL if the configuration is NULL.
* @returns EINVAL if the count is zero (0).
70,10 → 70,10
/** Returns the global configuration.
* The configuration names are read and the appropriate settings are set instead.
* Call net_free_settings() function to release the returned configuration.
* @param net_phone The networking module phone. Input parameter.
* @param configuration The requested configuration. The names are read and the appropriate settings are set instead. Input/output parameter.
* @param count The configuration entries count. Input parameter.
* @param data The configuration and settings data. Input/output parameter.
* @param[in] net_phone The networking module phone.
* @param[in,out] configuration The requested configuration. The names are read and the appropriate settings are set instead.
* @param[in] count The configuration entries count.
* @param[in,out] data The configuration and settings data.
* @returns EOK on success.
* @returns EINVAL if the configuration is NULL.
* @returns EINVAL if the count is zero (0).
82,8 → 82,8
int net_get_conf_req( int net_phone, measured_string_ref * configuration, size_t count, char ** data );
 
/** Frees the received settings.
* @param settings The received settings. Input parameter.
* @param data The received settings data. Input parameter.
* @param[in] settings The received settings.
* @param[in] data The received settings data.
* @see net_get_device_conf_req()
* @see net_get_conf_req()
*/
/branches/network/uspace/srv/net/include/icmp_interface.h
62,10 → 62,10
/** Sends the Destination Unreachable error notification packet.
* Beginning of the packet is sent as the notification packet data.
* The source and the destination addresses should be set in the original packet.
* @param icmp_phone The ICMP module phone used for (semi)remote calls. Input parameter.
* @param code The error specific code. Input parameter.
* @param mtu The error MTU value. Input parameter.
* @param packet The original packet.
* @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
* @param[in] code The error specific code.
* @param[in] mtu The error MTU value.
* @param[in] packet The original packet.
* @returns EOK on success.
* @returns EPERM if the ICMP error notifications are disabled.
* @returns ENOMEM if there is not enough memory left.
75,8 → 75,8
/** Sends the Source Quench error notification packet.
* Beginning of the packet is sent as the notification packet data.
* The source and the destination addresses should be set in the original packet.
* @param icmp_phone The ICMP module phone used for (semi)remote calls. Input parameter.
* @param packet The original packet.
* @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
* @param[in] packet The original packet.
* @returns EOK on success.
* @returns EPERM if the ICMP error notifications are disabled.
* @returns ENOMEM if there is not enough memory left.
86,9 → 86,9
/** Sends the Time Exceeded error notification packet.
* Beginning of the packet is sent as the notification packet data.
* The source and the destination addresses should be set in the original packet.
* @param icmp_phone The ICMP module phone used for (semi)remote calls. Input parameter.
* @param code The error specific code. Input parameter.
* @param packet The original packet.
* @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
* @param[in] code The error specific code.
* @param[in] packet The original packet.
* @returns EOK on success.
* @returns EPERM if the ICMP error notifications are disabled.
* @returns ENOMEM if there is not enough memory left.
98,10 → 98,10
/** Sends the Parameter Problem error notification packet.
* Beginning of the packet is sent as the notification packet data.
* The source and the destination addresses should be set in the original packet.
* @param icmp_phone The ICMP module phone used for (semi)remote calls. Input parameter.
* @param code The error specific code. Input parameter.
* @param pointer The problematic parameter offset. Input parameter.
* @param packet The original packet.
* @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
* @param[in] code The error specific code.
* @param[in] pointer The problematic parameter offset.
* @param[in] packet The original packet.
* @returns EOK on success.
* @returns EPERM if the ICMP error notifications are disabled.
* @returns ENOMEM if there is not enough memory left.
/branches/network/uspace/srv/net/include/icmp_api.h
63,14 → 63,14
/** Requests an echo message.
* Sends a packet with specified parameters to the target host and waits for the reply upto the given timeout.
* Blocks the caller until the reply or the timeout occurres.
* @param icmp_phone The ICMP module phone used for (semi)remote calls. Input parameter.
* @param size The message data length in bytes. Input parameter.
* @param timeout The timeout in miliseconds. Input parameter.
* @param ttl The time to live. Input parameter.
* @param tos The type of service. Input parameter.
* @param dont_fragment The value indicating whether the datagram must not be fragmented. Is used as a MTU discovery. Input parameter.
* @param addr The target host address. Input parameter.
* @param addrlen The torget host address length. Input parameter.
* @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
* @param[in] size The message data length in bytes.
* @param[in] timeout The timeout in miliseconds.
* @param[in] ttl The time to live.
* @param[in] tos The type of service.
* @param[in] dont_fragment The value indicating whether the datagram must not be fragmented. Is used as a MTU discovery.
* @param[in] addr The target host address.
* @param[in] addrlen The torget host address length.
* @returns ICMP_ECHO on success.
* @returns ETIMEOUT if the reply has not arrived before the timeout.
* @returns ICMP type of the received error notification.
/branches/network/uspace/srv/net/include/il_interface.h
57,10 → 57,10
/*@{*/
 
/** Notifies the internetwork layer modules about the device state change.
* @param il_phone The internetwork layer module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param state The new device state. Input parameter.
* @param target The target internetwork module service to be delivered to. Input parameter.
* @param[in] il_phone The internetwork layer module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[in] state The new device state.
* @param[in] target The target internetwork module service to be delivered to.
* @returns EOK on success.
*/
static inline int il_device_state_msg( int il_phone, device_id_t device_id, device_state_t state, services_t target ){
68,10 → 68,10
}
 
/** Notifies the internetwork layer modules about the received packet/s.
* @param il_phone The internetwork layer module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param packet The received packet or the received packet queue. Input parameter.
* @param target The target internetwork module service to be delivered to. Input parameter.
* @param[in] il_phone The internetwork layer module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[in] packet The received packet or the received packet queue.
* @param[in] target The target internetwork module service to be delivered to.
* @returns EOK on success.
*/
inline static int il_received_msg( int il_phone, device_id_t device_id, packet_t packet, services_t target ){
79,10 → 79,10
}
 
/** Notifies the internetwork layer modules about the mtu change.
* @param il_phone The internetwork layer module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param mtu The new mtu value. Input parameter.
* @param target The target internetwork module service to be delivered to. Input parameter.
* @param[in] il_phone The internetwork layer module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[in] mtu The new mtu value.
* @param[in] target The target internetwork module service to be delivered to.
* @returns EOK on success.
*/
inline static int il_mtu_changed_msg( int il_phone, device_id_t device_id, size_t mtu, services_t target ){
/branches/network/uspace/srv/net/include/ip_codes.h
31,7 → 31,7
*/
 
/** @file
* \todo
* IP codes and definitions.
*/
 
#ifndef __NET_IP_CODES_H__
39,98 → 39,335
 
#include <sys/types.h>
 
/** IP time to live counter type definition.
*/
typedef uint8_t ip_ttl_t;
 
/** IP type of service type definition.
*/
typedef uint8_t ip_tos_t;
 
/** IP transport protocol type definition.
*/
typedef uint8_t ip_protocol_t;
 
/** Default IPVERSION.
*/
#define IPVERSION 4
 
/** Maximum time to live counter.
*/
#define MAXTTL 255
 
/** Default time to live counter.
*/
#define IPDEFTTL 64
 
/** @name IP type of service definitions
*/
/*@{*/
 
/** IP TOS mask.
*/
#define IPTOS_TOS_MASK 0x1E
 
/** Precedence shift.
*/
#define IPTOS_PRECEDENCE_SHIFT 5
 
/** Delay shift.
*/
#define IPTOS_DELAY_SHIFT 4
 
/** Throughput shift.
*/
#define IPTOS_THROUGHPUT_SHIFT 3
 
/** Reliability shift.
*/
#define IPTOS_RELIABILITY_SHIFT 2
 
/** Cost shift.
*/
#define IPTOS_COST_SHIFT 1
 
/** Normal delay.
*/
#define IPTOS_NORMALDELAY ( 0x0 << IPTOS_DELAY_SHIFT )
 
/** Low delay.
*/
#define IPTOS_LOWDELAY ( 0x1 << IPTOS_DELAY_SHIFT )
 
/** Normal throughput.
*/
#define IPTOS_NORMALTHROUGHPUT ( 0x0 << IPTOS_THROUGHPUT_SHIFT )
 
/** Throughput.
*/
#define IPTOS_THROUGHPUT ( 0x1 << IPTOS_THROUGHPUT_SHIFT )
 
/** Normal reliability.
*/
#define IPTOS_NORMALRELIABILITY ( 0x0 << IPTOS_RELIABILITY_SHIFT )
 
/** Reliability.
*/
#define IPTOS_RELIABILITY ( 0x1 << IPTOS_RELIABILITY_SHIFT )
 
/** Normal cost.
*/
#define IPTOS_NORMALCOST ( 0x0 << IPTOS_COST_SHIFT )
 
/** Minimum cost.
*/
#define IPTOS_MICNCOST ( 0x1 << IPTOS_COST_SHIFT )
 
/*@}*/
 
/** @name IP TOS precedence definitions
*/
/*@{*/
 
 
/** Precedence mask.
*/
#define IPTOS_PREC_MASK 0xE0
 
/** Routine precedence.
*/
#define IPTOS_PREC_ROUTINE ( 0x0 << IPTOS_PRECEDENCE_SHIFT )
 
/** Priority precedence.
*/
#define IPTOS_PREC_PRIORITY ( 0x1 << IPTOS_PRECEDENCE_SHIFT )
 
/** Immediate precedence.
*/
#define IPTOS_PREC_IMMEDIATE ( 0x2 << IPTOS_PRECEDENCE_SHIFT )
 
/** Flash precedence.
*/
#define IPTOS_PREC_FLASH ( 0x3 << IPTOS_PRECEDENCE_SHIFT )
 
/** Flash override precedence.
*/
#define IPTOS_PREC_FLASHOVERRIDE ( 0x4 << IPTOS_PRECEDENCE_SHIFT )
 
/** Critical precedence.
*/
#define IPTOS_PREC_CRITIC_ECP ( 0x5 << IPTOS_PRECEDENCE_SHIFT )
 
/** Inter-network control precedence.
*/
#define IPTOS_PREC_INTERNETCONTROL ( 0x6 << IPTOS_PRECEDENCE_SHIFT )
 
/** Network control precedence.
*/
#define IPTOS_PREC_NETCONTROL ( 0x7 << IPTOS_PRECEDENCE_SHIFT )
 
/*@}*/
 
/** @name IP options definitions
*/
/*@{*/
 
/** Copy shift.
*/
#define IPOPT_COPY_SHIFT 7
 
/** Class shift.
*/
#define IPOPT_CLASS_SHIFT 5
 
/** Number shift.
*/
#define IPOPT_NUMBER_SHIFT 0
 
/** Class mask.
*/
#define IPOPT_CLASS_MASK 0x60
 
/** Number mask.
*/
#define IPOPT_NUMBER_MASK 0x1F
 
/** Copy flag.
*/
#define IPOPT_COPY ( 1 << IPOPT_COPY_SHIFT )
 
/** Returns IP option type.
* @param[in] copy The value indication whether the IP option should be copied.
* @param[in] class The IP option class.
* @param[in] number The IP option number.
*/
#define IPOPT_TYPE( copy, class, number ) ((( copy ) & IPOPT_COPY ) | (( class ) & IPOPT_CLASS_MASK ) | (( number << IPOPT_NUMBER_SHIFT ) & IPOPT_NUMBER_MASK ))
 
/** Returns a value indicating whether the IP option should be copied.
* @param[in] o The IP option.
*/
#define IPOPT_COPIED( o ) (( o ) & IPOPT_COPY )
 
/** Returns an IP option class.
* @param[in] o The IP option.
*/
#define IPOPT_CLASS( o ) (( o ) & IPOPT_CLASS_MASK )
 
/** Returns an IP option number.
* @param[in] o The IP option.
*/
#define IPOPT_NUMBER( o ) (( o ) & IPOPT_NUMBER_MASK )
 
/*@}*/
 
/** @name IP option class definitions
*/
/*@{*/
 
/** Control class.
*/
#define IPOPT_CONTROL ( 0 << IPOPT_CLASS_SHIFT )
 
/** Reserved class 1.
*/
#define IPOPT_RESERVED1 ( 1 << IPOPT_CLASS_SHIFT )
 
/** Measurement class.
*/
#define IPOPT_MEASUREMENT ( 2 << IPOPT_CLASS_SHIFT )
 
/** Reserved class 2.
*/
#define IPOPT_RESERVED2 ( 3 << IPOPT_CLASS_SHIFT )
 
//#define IPOPT_END_OF_LIST 0x0
/*@}*/
 
/** @name IP option type definitions
*/
/*@{*/
 
/** End of list.
*/
//#define IPOPT_END_OF_LIST 0x0
#define IPOPT_END IPOPT_TYPE( 0, IPOPT_CONTROL, 0 )
 
/** No operation.
*/
//#define IPOPT_NO_OPERATION 0x1
#define IPOPT_NOOP IPOPT_TYPE( 0, IPOPT_CONTROL, 1 )
 
/** Security.
*/
//#define IPOPT_SECURITY 0x82
#define IPOPT_SEC IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 2 )
#define IPOPT_SEC_LENGTH 11
#define IPOPT_SEC_UNCLASIFIED 0x0
#define IPOPT_SEC_CONFIDENTIAL 0xF035
#define IPOPT_SEC_EFTO 0x789A
#define IPOPT_SEC_MMMM 0xBC4D
#define IPOPT_SEC_PROG 0x5E26
#define IPOPT_SEC_RESTRICTED 0xAF13
#define IPOPT_SEC_SECRET 0xD788
#define IPOPT_SEC_TOP_SECRET 0x6BC5
 
/** Loose source.
*/
//#define IPOPT_LOOSE_SOURCE 0x83
#define IPOPT_LSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 3 )
 
/** Strict route.
*/
//#define IPOPT_STRICT_SOURCE 0x89
#define IPOPT_SSRR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 9 )
 
/** Record route.
*/
//#define IPOPT_RECORD_ROUTE 0x07
#define IPOPT_RR IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 7 )
 
/** Stream identifier.
*/
//#define IPOPT_STREAM_IDENTIFIER 0x88
#define IPOPT_SID IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 8 )
 
/** Stream identifier length.
*/
#define IPOPT_SID_LENGTH 4
 
/** Internet timestamp.
*/
//#define IPOPT_INTERNET_TIMESTAMP 0x44
#define IPOPT_TIMESTAMP IPOPT_TYPE( IPOPT_COPY, IPOPT_MEASUREMENT, 4 )
 
/** Commercial IP security option.
*/
#define IPOPT_CIPSO IPOPT_TYPE( IPOPT_COPY, IPOPT_CONTROL, 5 )
 
/** No operation variant.
*/
#define IPOPT_NOP IPOPT_NOOP
 
/** End of list variant.
*/
#define IPOPT_EOL IPOPT_END
 
/** Timestamp variant.
*/
#define IPOPT_TS IPOPT_TIMESTAMP
 
#define IPOPT_TS_TSONLY 0 /* timestamps only */
#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
#define IPOPT_TS_PRESPEC 3 /* specified modules only */
/*@}*/
 
/** @name IP security option definitions
*/
/*@{*/
 
/** Security length.
*/
#define IPOPT_SEC_LENGTH 11
 
/** Unclasified.
*/
#define IPOPT_SEC_UNCLASIFIED 0x0
 
/** Confidential.
*/
#define IPOPT_SEC_CONFIDENTIAL 0xF035
 
/** EFTO.
*/
#define IPOPT_SEC_EFTO 0x789A
 
/** MMMM.
*/
#define IPOPT_SEC_MMMM 0xBC4D
 
/** PROG.
*/
#define IPOPT_SEC_PROG 0x5E26
 
/** Restricted.
*/
#define IPOPT_SEC_RESTRICTED 0xAF13
 
/** Secret.
*/
#define IPOPT_SEC_SECRET 0xD788
 
/** Top secret.
*/
#define IPOPT_SEC_TOP_SECRET 0x6BC5
 
/*@}*/
 
/** @name IP timestamp option definitions
*/
/*@{*/
 
/** Tiemstamp only.
*/
#define IPOPT_TS_TSONLY 0
 
/** Timestamps and addresses.
*/
#define IPOPT_TS_TSANDADDR 1
 
/** Specified modules only.
*/
#define IPOPT_TS_PRESPEC 3
 
/*@}*/
 
#endif
 
/** @}
/branches/network/uspace/srv/net/include/netif_interface.h
55,10 → 55,10
/*@{*/
 
/** Returns the device local hardware address.
* @param netif_phone The network interface phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param address The device local hardware address. Output parameter.
* @param data The address data. Output parameter.
* @param[in] netif_phone The network interface phone.
* @param[in] device_id The device identifier.
* @param[out] address The device local hardware address.
* @param[out] data The address data.
* @returns EOK on success.
* @returns EBADMEM if the address parameter is NULL.
* @returns ENOENT if there no such device.
67,10 → 67,10
int netif_get_addr_req( int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data );
 
/** Probes the existence of the device.
* @param netif_phone The network interface phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param irq The device interrupt number. Input parameter.
* @param io The device input/output address. Input parameter.
* @param[in] netif_phone The network interface phone.
* @param[in] device_id The device identifier.
* @param[in] irq The device interrupt number.
* @param[in] io The device input/output address.
* @returns EOK on success.
* @returns Other errro codes as defined for the netif_probe_message().
*/
77,10 → 77,10
int netif_probe_req( int netif_phone, device_id_t device_id, int irq, int io );
 
/** Sends the packet queue.
* @param netif_phone The network interface phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param packet The packet queue. Input parameter.
* @param sender The sending module service. Input parameter.
* @param[in] netif_phone The network interface phone.
* @param[in] device_id The device identifier.
* @param[in] packet The packet queue.
* @param[in] sender The sending module service.
* @returns EOK on success.
* @returns Other error codes as defined for the generic_send_msg() function.
*/
87,8 → 87,8
int netif_send_msg( int netif_phone, device_id_t device_id, packet_t packet, services_t sender );
 
/** Starts the device.
* @param netif_phone The network interface phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param[in] netif_phone The network interface phone.
* @param[in] device_id The device identifier.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the netif_start_message() function.
96,8 → 96,8
int netif_start_req( int netif_phone, device_id_t device_id );
 
/** Stops the device.
* @param netif_phone The network interface phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param[in] netif_phone The network interface phone.
* @param[in] device_id The device identifier.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the netif_stop_message() function.
105,18 → 105,18
int netif_stop_req( int netif_phone, device_id_t device_id );
 
/** Returns the device usage statistics.
* @param netif_phone The network interface phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param stats The device usage statistics. Output parameter.
* @param[in] netif_phone The network interface phone.
* @param[in] device_id The device identifier.
* @param[out] stats The device usage statistics.
* @returns EOK on success.
*/
int netif_stats_req( int netif_phone, device_id_t device_id, device_stats_ref stats );
 
/** Creates bidirectional connection with the network interface module and registers the message receiver.
* @param service The network interface module service. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param me The requesting module service. Input parameter.
* @param receiver The message receiver. Input parameter.
* @param[in] service The network interface module service.
* @param[in] device_id The device identifier.
* @param[in] me The requesting module service.
* @param[in] receiver The message receiver.
* @returns The phone of the needed service.
* @returns EOK on success.
* @returns Other error codes as defined for the bind_service() function.
/branches/network/uspace/srv/net/include/icmp_client.h
41,11 → 41,11
#include "../structures/packet/packet.h"
 
/** Processes the received packet prefixed with an ICMP header.
* @param packet The received packet. Input parameter.
* @param type The ICMP header type. Output parameter.
* @param code The ICMP header code. Output parameter.
* @param pointer The ICMP header pointer. Output parameter.
* @param mtu The ICMP header MTU. Output parameter.
* @param[in] packet The received packet.
* @param[out] type The ICMP header type.
* @param[out] code The ICMP header code.
* @param[out] pointer The ICMP header pointer.
* @param[out] mtu The ICMP header MTU.
* @returns The ICMP header length.
* @returns Zero (0) if the packet contains no data.
*/
52,7 → 52,7
int icmp_client_process_packet( packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu );
 
/** Returns the ICMP header length.
* @param packet The packet. Input parameter.
* @param[in] packet The packet.
* @returns The ICMP header length in bytes.
*/
size_t icmp_client_header_length( packet_t packet );
/branches/network/uspace/srv/net/include/ip_interface.h
63,20 → 63,20
 
/** The transport layer notification function type definition.
* Notifies the transport layer modules about the received packet/s.
* @param device_id The device identifier. Input parameter.
* @param packet The received packet or the received packet queue. Input parameter.
* @param receiver The receiving module service. Input parameter.
* @param error The packet error reporting service. Prefixes the received packet. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] packet The received packet or the received packet queue.
* @param[in] receiver The receiving module service.
* @param[in] error The packet error reporting service. Prefixes the received packet.
* @returns EOK on success.
*/
typedef int ( * tl_received_msg_t )( device_id_t device_id, packet_t packet, services_t receiver, services_t error );
 
/** Creates bidirectional connection with the ip module service and registers the message receiver.
* @param service The IP module service. Input parameter.
* @param protocol The transport layer protocol. Input parameter.
* @param me The requesting module service. Input parameter.
* @param receiver The message receiver. Used for remote connection. Input parameter.
* @param tl_received_msg The message processing function. Used if bundled together. Input parameter.
* @param[in] service The IP module service.
* @param[in] protocol The transport layer protocol.
* @param[in] me The requesting module service.
* @param[in] receiver The message receiver. Used for remote connection.
* @param[in] tl_received_msg The message processing function. Used if bundled together.
* @returns The phone of the needed service.
* @returns EOK on success.
* @returns Other error codes as defined for the bind_service() function.
86,9 → 86,9
/** Registers the new device.
* Registers itself as the ip packet receiver.
* If the device uses ARP registers also the new ARP device.
* @param ip_phone The IP module phone used for (semi)remote calls. Input parameter.
* @param device_id The new device identifier. Input parameter.
* @param netif The underlying device network interface layer service. Input parameter.
* @param[in] ip_phone The IP module phone used for (semi)remote calls.
* @param[in] device_id The new device identifier.
* @param[in] netif The underlying device network interface layer service.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
* @returns EINVAL if the device configuration is invalid.
101,11 → 101,11
 
/** Sends the packet queue.
* The packets may get fragmented if needed.
* @param ip_phone The IP module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param packet The packet fragments as a~packet queue. All the packets have to have the same destination address. Input parameter.
* @param sender The sending module service. Input parameter.
* @param error The packet error reporting service. Prefixes the received packet. Input parameter.
* @param[in] ip_phone The IP module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[in] packet The packet fragments as a~packet queue. All the packets have to have the same destination address.
* @param[in] sender The sending module service.
* @param[in] error The packet error reporting service. Prefixes the received packet.
* @returns EOK on success.
* @returns Other error codes as defined for the generic_send_msg() function.
*/
120,29 → 120,29
 
/** Adds a route to the device routing table.
* The target network is routed using this device.
* @param ip_phone The IP module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param address The target network address. Input parameter.
* @param netmask The target network mask. Input parameter.
* @param gateway The target network gateway. Not used if zero. Input parameter.
* @param[in] ip_phone The IP module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[in] address The target network address.
* @param[in] netmask The target network mask.
* @param[in] gateway The target network gateway. Not used if zero.
*/
int ip_add_route_req( int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway );
 
/** Sets the default gateway.
* This gateway is used if no other route is found.
* @param ip_phone The IP module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param gateway The default gateway. Input parameter.
* @param[in] ip_phone The IP module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[in] gateway The default gateway.
*/
int ip_set_gateway_req( int ip_phone, device_id_t device_id, in_addr_t gateway );
 
/** Returns the device packet dimensions for sending.
* @param ip_phone The IP module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param addr_len The minimum reserved address length. Output parameter.
* @param prefix The minimum reserved prefix size. Output parameter.
* @param content The maximum content size. Output parameter.
* @param suffix The minimum reserved suffix size. Output parameter.
* @param[in] ip_phone The IP module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[out] addr_len The minimum reserved address length.
* @param[out] prefix The minimum reserved prefix size.
* @param[out] content The maximum content size.
* @param[out] suffix The minimum reserved suffix size.
* @returns EOK on success.
* @returns EBADMEM if either one of the parameters is NULL.
* @returns ENOENT if there is no such device.
151,16 → 151,23
int ip_packet_size_req( int ip_phone, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix );
 
/** Notifies the IP module about the received error notification packet.
* @param ip_phone The IP module phone used for (semi)remote calls. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param packet The received packet or the received packet queue. Input parameter.
* @param target The target internetwork module service to be delivered to. Input parameter.
* @param error The packet error reporting service. Prefixes the received packet. Input parameter.
* @param[in] ip_phone The IP module phone used for (semi)remote calls.
* @param[in] device_id The device identifier.
* @param[in] packet The received packet or the received packet queue.
* @param[in] target The target internetwork module service to be delivered to.
* @param[in] error The packet error reporting service. Prefixes the received packet.
* @returns EOK on success.
*/
int ip_received_error_msg( int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error );
 
/** \todo
/** Returns the device identifier and the IP pseudo header based on the destination address.
* @param[in] ip_phone The IP module phone used for (semi)remote calls.
* @param[in] protocol The transport protocol.
* @param[in] destination The destination address.
* @param[in] addrlen The destination address length.
* @param[out] device_id The device identifier.
* @param[out] header The constructed IP pseudo header.
* @param[out] headerlen The IP pseudo header length.
*/
int ip_get_route_req( int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, ip_pseudo_header_ref * header, size_t * headerlen );
 
/branches/network/uspace/srv/net/include/socket.h
52,9 → 52,9
/*@{*/
 
/** Creates a new socket.
* @param domain The socket protocol family. Input parameter.
* @param type Socket type. Input parameter.
* @param protocol Socket protocol. Input parameter.
* @param[in] domain The socket protocol family.
* @param[in] type Socket type.
* @param[in] protocol Socket protocol.
* @returns The socket identifier on success.
* @returns EPFNOTSUPPORT if the protocol family is not supported.
* @returns ESOCKNOTSUPPORT if the socket type is not supported.
65,9 → 65,9
int socket( int domain, int type, int protocol );
 
/** Binds the socket to a port address.
* @param socket_id Socket identifier. Input parameter.
* @param my_addr The port address. Input parameter.
* @param addrlen The address length. Input parameter.
* @param[in] socket_id Socket identifier.
* @param[in] my_addr The port address.
* @param[in] addrlen The address length.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the my_addr parameter is NULL.
77,8 → 77,8
int bind( int socket_id, const struct sockaddr * my_addr, socklen_t addrlen );
 
/** Sets the number of connections waiting to be accepted.
* @param socket_id Socket identifier. Input parameter.
* @param backlog The maximum number of waiting sockets to be accepted. Input parameter.
* @param[in] socket_id Socket identifier.
* @param[in] backlog The maximum number of waiting sockets to be accepted.
* @returns EOK on success.
* @returns EINVAL if the backlog parameter is not positive (<=0).
* @returns ENOTSOCK if the socket is not found.
88,9 → 88,9
 
/** Accepts waiting socket.
* Blocks until such a socket exists.
* @param socket_id Socket identifier. Input parameter.
* @param cliaddr The remote client address. Output parameter.
* @param addrlen The address length. Input parameter.
* @param[in] socket_id Socket identifier.
* @param[out] cliaddr The remote client address.
* @param[in] addrlen The address length.
* @returns EOK on success.
* @returns EBADMEM if the cliaddr or addrlen parameter is NULL.
* @returns EINVAL if the backlog parameter is not positive (<=0).
100,9 → 100,9
int accept( int socket_id, struct sockaddr * cliaddr, socklen_t * addrlen );
 
/** Connects socket to the remote server.
* @param socket_id Socket identifier. Input parameter.
* @param serv_addr The remote server address. Input parameter.
* @param addrlen The address length. Input parameter.
* @param[in] socket_id Socket identifier.
* @param[in] serv_addr The remote server address.
* @param[in] addrlen The address length.
* @returns EOK on success.
* @returns EBADMEM if the serv_addr parameter is NULL.
* @returns NO_DATA if the addlen parameter is zero (0).
112,7 → 112,7
int connect( int socket_id, const struct sockaddr * serv_addr, socklen_t addrlen );
 
/** Closes the socket.
* @param socket_id Socket identifier. Input parameter.
* @param[in] socket_id Socket identifier.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EINPROGRESS if there is another blocking function in progress.
121,10 → 121,10
int closesocket( int socket_id );
 
/** Sends data via the socket.
* @param socket_id Socket identifier. Input parameter.
* @param data The data to be sent. Input parameter.
* @param datalength The data length. Input parameter.
* @param flags Various send flags. Input parameter.
* @param[in] socket_id Socket identifier.
* @param[in] data The data to be sent.
* @param[in] datalength The data length.
* @param[in] flags Various send flags.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the data parameter is NULL.
135,12 → 135,12
 
/** Sends data via the socket to the remote address.
* Binds the socket to a free port if not already connected/bound.
* @param socket_id Socket identifier. Input parameter.
* @param data The data to be sent. Input parameter.
* @param datalength The data length. Input parameter.
* @param flags Various send flags. Input parameter.
* @param toaddr The destination address. Input parameter.
* @param addrlen The address length. Input parameter.
* @param[in] socket_id Socket identifier.
* @param[in] data The data to be sent.
* @param[in] datalength The data length.
* @param[in] flags Various send flags.
* @param[in] toaddr The destination address.
* @param[in] addrlen The address length.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the data or toaddr parameter is NULL.
150,10 → 150,10
int sendto( int socket_id, const void * data, size_t datalength, int flags, const struct sockaddr * toaddr, socklen_t addrlen );
 
/** Receives data via the socket.
* @param socket_id Socket identifier. Input parameter.
* @param data The data buffer to be filled. Output parameter.
* @param datalength The data length. Input parameter.
* @param flags Various receive flags. Input parameter.
* @param[in] socket_id Socket identifier.
* @param[out] data The data buffer to be filled.
* @param[in] datalength The data length.
* @param[in] flags Various receive flags.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the data parameter is NULL.
163,12 → 163,12
int recv( int socket_id, void * data, size_t datalength, int flags );
 
/** Receives data via the socket.
* @param socket_id Socket identifier. Input parameter.
* @param data The data buffer to be filled. Output parameter.
* @param datalength The data length. Input parameter.
* @param flags Various receive flags. Input parameter.
* @param fromaddr The source address. Output parameter.
* @param addrlen The address length. The maximum address length is read. The actual address length is set. Input/output parameter.
* @param[in] socket_id Socket identifier.
* @param[out] data The data buffer to be filled.
* @param[in] datalength The data length.
* @param[in] flags Various receive flags.
* @param[out] fromaddr The source address.
* @param[in,out] addrlen The address length. The maximum address length is read. The actual address length is set.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the data or fromaddr parameter is NULL.
178,11 → 178,11
int recvfrom( int socket_id, void * data, size_t datalength, int flags, struct sockaddr * fromaddr, socklen_t * addrlen );
 
/** Gets socket option.
* @param socket_id Socket identifier. Input parameter.
* @param level The socket options level. Input parameter.
* @param optname The socket option to be get. Input parameter.
* @param value The value buffer to be filled. Output parameter.
* @param optlen The value buffer length. The maximum length is read. The actual length is set. Input/output parameter.
* @param[in] socket_id Socket identifier.
* @param[in] level The socket options level.
* @param[in] optname The socket option to be get.
* @param[out] value The value buffer to be filled.
* @param[in,out] optlen The value buffer length. The maximum length is read. The actual length is set.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the value or optlen parameter is NULL.
192,11 → 192,11
int getsockopt( int socket_id, int level, int optname, void * value, size_t * optlen );
 
/** Sets socket option.
* @param socket_id Socket identifier. Input parameter.
* @param level The socket options level. Input parameter.
* @param optname The socket option to be set. Input parameter.
* @param value The value to be set. Input parameter.
* @param optlen The value length. Input parameter.
* @param[in] socket_id Socket identifier.
* @param[in] level The socket options level.
* @param[in] optname The socket option to be set.
* @param[in] value The value to be set.
* @param[in] optlen The value length.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the value parameter is NULL.
/branches/network/uspace/srv/net/net/net.c
76,7 → 76,7
 
/** Starts the networking module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on successful module termination.
* @returns Other error codes as defined for the net_initialize() function.
* @returns Other error codes as defined for the REGISTER_ME() macro function.
94,7 → 94,7
/** Starts the network interface according to its configuration.
* Registers the network interface with the subsystem modules.
* Starts the needed subsystem modules.
* @param netif The network interface specific data.
* @param[in] netif The network interface specific data.
* @returns EOK on success.
* @returns EINVAL if there are some settings missing.
* @returns ENOENT if the internet protocol module is not known.
122,16 → 122,16
 
/** Returns the configured values.
* The network interface configuration is searched first.
* @param netif_conf The network interface configuration setting. Input parameter.
* @param configuration The found configured values. Output parameter.
* @param count The desired settings count. Input parameter.
* @param data The found configuration settings data. Output parameter.
* @param[in] netif_conf The network interface configuration setting.
* @param[out] configuration The found configured values.
* @param[in] count The desired settings count.
* @param[out] data The found configuration settings data.
* @returns EOK.
*/
int net_get_conf( measured_strings_ref netif_conf, measured_string_ref configuration, size_t count, char ** data );
 
/** Initializes the networking module.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
138,8 → 138,8
int net_initialize( async_client_conn_t client_connection );
 
/** Reads the network interface specific configuration.
* @param name The network interface name. Input parameter.
* @param netif The network interface structure. Input/output parameter.
* @param[in] name The network interface name.
* @param[in,out] netif The network interface structure.
* @returns EOK on success.
* @returns Other error codes as defined for the add_configuration() function.
*/
/branches/network/uspace/srv/net/net/net.h
195,9 → 195,9
};
 
/** Adds the configured setting to the configuration map.
* @param configuration The configuration map. Input parameter.
* @param name The setting name. Input parameter.
* @param value The setting value. Input parameter.
* @param[in] configuration The configuration map.
* @param[in] name The setting name.
* @param[in] value The setting value.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
204,10 → 204,10
int add_configuration( measured_strings_ref configuration, const char * name, const char * value );
 
/** Processes the networking message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @see net_interface.h
216,7 → 216,7
int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
/** Initializes the networking module for the chosen subsystem build type.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
224,10 → 224,10
 
/** Processes the module message.
* Distributes the message to the right bundled module.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each bundled module message function.
235,8 → 235,8
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
/** Reads the network interface specific configuration for the chosen subsystem build type.
* @param name The network interface name. Input parameter.
* @param netif The network interface structure. Input/output parameter.
* @param[in] name The network interface name.
* @param[in,out] netif The network interface structure.
* @returns EOK on success.
* @returns Other error codes as defined for the add_configuration() function.
*/
/branches/network/uspace/srv/net/net/start/netstart.c
54,8 → 54,8
#define NAME "Networking startup"
 
/** Module entry point.
* @param argc The number of command line parameters. Input parameter.
* @param argv The command line parameters. Input parameter.
* @param[in] argc The number of command line parameters.
* @param[in] argv The command line parameters.
* @returns EOK on success.
* @returns EINVAL if the net module cannot be started.
* @returns Other error codes as defined for the self_test() function.
64,7 → 64,7
int main( int argc, char * argv[] );
 
/** Starts the module.
* @param fname The module absolute name. Input parameter.
* @param[in] fname The module absolute name.
* @returns The started module task identifier.
* @returns Other error codes as defined for the task_spawn() function.
*/
/branches/network/uspace/srv/net/socket/socket_core.c
31,7 → 31,7
*/
 
/** @file
* \todo
* Socket common core implementation.
*/
 
#include "../err.h"
51,22 → 51,46
 
#include "socket_core.h"
 
/** \todo
/** Bound port sockets.
*/
struct socket_port{
/** The bound sockets map.
*/
socket_port_map_t map;
/** The bound sockets count.
*/
int count;
};
 
/** \todo
/** Binds the socket to the port.
* The SOCKET_MAP_KEY_LISTENING key identifier is used.
* @param[in] global_sockets The global sockets to be updated.
* @param[in] socket The socket to be added.
* @param[in] port The port number to be bound to.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
* @returns Other error codes as defined for the socket_ports_add() function.
*/
int socket_bind_insert( socket_ports_ref global_sockets, socket_core_ref socket, int port );
 
/** \todo
/** Destroys the socket.
* If the socket is bound, the port is released.
* Releases all buffered packets, calls the release function and removes the socket from the local sockets.
* @param[in] packet_phone The packet server phone to release buffered packets.
* @param[in] socket The socket to be destroyed.
* @param[in,out] local_sockets The local sockets to be updated.
* @param[in,out] global_sockets The global sockets to be updated.
* @param[in] socket_release The client release callback function.
*/
void socket_destroy_core( int packet_phone, socket_core_ref socket, socket_cores_ref local_sockets, socket_ports_ref global_sockets, void ( * socket_release )( socket_core_ref socket ));
 
/** \todo
/** Adds the socket to a socket port.
* @param[in,out] socket_port The socket port structure.
* @param[in] socket The socket to be added.
* @param[in] key The socket key identifier.
* @param[in] key_length The socket key length.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
int socket_port_add_core( socket_port_ref socket_port, socket_core_ref socket, const char * key, size_t key_length );
 
267,9 → 291,7
size_t * lengths;
size_t index;
 
if( ! length ){
return EINVAL;
}
if( ! length ) return EBADMEM;
next_packet = pq_next( packet );
if( ! next_packet ){
// write all if only one fragment
/branches/network/uspace/srv/net/socket/socket_messages.h
33,7 → 33,6
/** @file
* Socket messages.
* @see socket.h
* \todo
*/
 
 
46,21 → 45,65
 
#include "../include/socket_codes.h"
 
/** Socket client messages.
*/
typedef enum{
/** Creates a new socket.
* @see socket()
*/
NET_SOCKET = NET_SOCKET_FIRST,
/** Binds the socket.
* @see bind()
*/
NET_SOCKET_BIND,
/** Creates a new socket.
* @see socket()
*/
NET_SOCKET_LISTEN,
/** Accepts an incomming connection.
* @see accept()
*/
NET_SOCKET_ACCEPT,
/** Connects the socket.
* @see connect()
*/
NET_SOCKET_CONNECT,
/** Closes the socket.
* @see closesocket()
*/
NET_SOCKET_CLOSE,
/** Sends data via the stream socket.
* @see send()
*/
NET_SOCKET_SEND,
/** Sends data via the datagram socket.
* @see sendto()
*/
NET_SOCKET_SENDTO,
/** Receives data from the stream socket.
* @see socket()
*/
NET_SOCKET_RECV,
/** Receives data from the datagram socket.
* @see socket()
*/
NET_SOCKET_RECVFROM,
/** Gets the socket option.
* @see getsockopt()
*/
NET_SOCKET_GETSOCKOPT,
/** Sets the socket option.
* @see setsockopt()
*/
NET_SOCKET_SETSOCKOPT,
/** New socket for acceptence notification message.
*/
NET_SOCKET_ACCEPTED,
/** New data received notification message.
*/
NET_SOCKET_RECEIVED,
/** New socket data fragment size notification message.
*/
NET_SOCKET_DATA_FRAGMENT_SIZE
} socket_messages;
 
68,27 → 111,86
*/
/*@{*/
 
#define SOCKET_SET_SOCKET_ID( call ) ( int * ) & IPC_GET_ARG1( call )
#define SOCKET_GET_SOCKET_ID( call ) ( int ) IPC_GET_ARG1( call )
#define SOCKET_SET_READ_DATA_LENGTH( call ) ( int * ) & IPC_GET_ARG1( call )
#define SOCKET_GET_READ_DATA_LENGTH( call ) ( int ) IPC_GET_ARG1( call )
/** Sets the socket identifier in the message answer.
* @param[out] answer The message answer structure.
*/
#define SOCKET_SET_SOCKET_ID( answer ) ( int * ) & IPC_GET_ARG1( answer )
 
#define SOCKET_GET_BACKLOG( call ) ( int ) IPC_GET_ARG2( call )
#define SOCKET_GET_OPT_LEVEL( call ) ( int ) IPC_GET_ARG2( call )
#define SOCKET_SET_ADDRESS_LENGTH( call ) ( socklen_t * ) & IPC_GET_ARG2( call )
#define SOCKET_GET_ADDRESS_LENGTH( call ) ( socklen_t ) IPC_GET_ARG2( call )
/** Returns the socket identifier message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_SOCKET_ID( call ) ( int ) IPC_GET_ARG1( call )
 
/** Sets the read data length in the message answer.
* @param[out] answer The message answer structure.
*/
#define SOCKET_SET_READ_DATA_LENGTH( answer ) ( int * ) & IPC_GET_ARG1( answer )
 
/** Returns the read data length message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_READ_DATA_LENGTH( call ) ( int ) IPC_GET_ARG1( call )
 
/** Returns the backlog message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_BACKLOG( call ) ( int ) IPC_GET_ARG2( call )
 
/** Returns the option level message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_OPT_LEVEL( call ) ( int ) IPC_GET_ARG2( call )
 
/** Sets the address length in the message answer.
* @param[out] answer The message answer structure.
*/
#define SOCKET_SET_ADDRESS_LENGTH( answer ) ( socklen_t * ) & IPC_GET_ARG2( answer )
 
/** Returns the address length message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_ADDRESS_LENGTH( call ) ( socklen_t ) IPC_GET_ARG2( call )
 
/** Returns the data fragment size message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_DATA_FRAGMENT_SIZE( call ) ( size_t ) IPC_GET_ARG2( call )
#define SOCKET_SET_DATA_FRAGMENT_SIZE( call ) ( size_t * ) & IPC_GET_ARG2( call )
 
#define SOCKET_SET_HEADER_SIZE( call ) ( int * ) & IPC_GET_ARG3( call )
#define SOCKET_GET_HEADER_SIZE( call ) ( int ) IPC_GET_ARG3( call )
/** Sets the data fragment size in the message answer.
* @param[out] answer The message answer structure.
*/
#define SOCKET_SET_DATA_FRAGMENT_SIZE( answer ) ( size_t * ) & IPC_GET_ARG2( answer )
 
#define SOCKET_GET_FLAGS( call ) ( int ) IPC_GET_ARG4( call )
#define SOCKET_GET_OPT_NAME( call ) ( int ) IPC_GET_ARG4( call )
/** Sets the header size in the message answer.
* @param[out] answer The message answer structure.
*/
#define SOCKET_SET_HEADER_SIZE( answer ) ( int * ) & IPC_GET_ARG3( answer )
 
#define SOCKET_GET_DATA_FRAGMENTS( call ) ( int ) IPC_GET_ARG5( call )
#define SOCKET_GET_NEW_SOCKET_ID( call ) ( int ) IPC_GET_ARG5( call )
/** Returns the header size message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_HEADER_SIZE( call ) ( int ) IPC_GET_ARG3( call )
 
/** Returns the flags message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_FLAGS( call ) ( int ) IPC_GET_ARG4( call )
 
/** Returns the option name message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_OPT_NAME( call ) ( int ) IPC_GET_ARG4( call )
 
/** Returns the data fragments message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_DATA_FRAGMENTS( call ) ( int ) IPC_GET_ARG5( call )
 
/** Returns the new socket identifier message parameter.
* @param[in] call The message call structure.
*/
#define SOCKET_GET_NEW_SOCKET_ID( call ) ( int ) IPC_GET_ARG5( call )
 
/*@}*/
 
#endif
/branches/network/uspace/srv/net/socket/socket_core.h
31,7 → 31,7
*/
 
/** @file
* \todo
* Socket common core.
*/
 
#ifndef __NET_SOCKET_CORE_H__
47,48 → 47,194
#include "../structures/int_map.h"
#include "../structures/packet/packet.h"
 
/** Initial size of the received packet queue.
*/
#define SOCKET_INITIAL_RECEIVED_SIZE 4
 
/** Maximum size of the received packet queue.
*/
#define SOCKET_MAX_RECEIVED_SIZE 0
 
/** Initial size of the sockets for acceptance queue.
*/
#define SOCKET_INITIAL_ACCEPTED_SIZE 1
 
/** Maximum size of the sockets for acceptance queue.
*/
#define SOCKET_MAX_ACCEPTEDED_SIZE 0
 
/** \todo
/** Listening sockets' port map key.
*/
#define SOCKET_MAP_KEY_LISTENING "L"
 
/** Type definition of the socket core.
* @see socket_core
*/
typedef struct socket_core socket_core_t;
typedef socket_core_t * socket_core_ref;
 
/** Type definition of the socket core pointer.
* @see socket_core
*/
typedef socket_core_t * socket_core_ref;
 
/** Type definition of the socket port.
* @see socket_port
*/
typedef struct socket_port socket_port_t;
typedef socket_port_t * socket_port_ref;
 
/** Type definition of the socket port pointer.
* @see socket_port
*/
typedef socket_port_t * socket_port_ref;
 
/** Socket core.
*/
struct socket_core{
/** Socket identifier.
*/
int socket_id;
/** Client application phone.
*/
int phone;
/** Bound port.
*/
int port;
/** Received packets queue.
*/
dyn_fifo_t received;
/** Sockets for acceptance queue.
*/
dyn_fifo_t accepted;
/** Protocol specific data.
*/
void * specific_data;
/** Socket ports map key.
*/
const char * key;
/** Length of the Socket ports map key.
*/
size_t key_length;
};
 
/** Sockets map.
* The key is the socket identifier.
*/
INT_MAP_DECLARE( socket_cores, socket_core_t );
 
/** Bount port sockets map.
* The listening socket has the SOCKET_MAP_KEY_LISTENING key identifier whereas the other use the remote addresses.
*/
GENERIC_CHAR_MAP_DECLARE( socket_port_map, socket_core_ref );
 
/** Ports map.
* The key is the port number.
*/
INT_MAP_DECLARE( socket_ports, socket_port_t );
 
/** Destroys local sockets.
* Releases all buffered packets and calls the release function for each of the sockets.
* @param[in] packet_phone The packet server phone to release buffered packets.
* @param[in] local_sockets The local sockets to be destroyed.
* @param[in,out] global_sockets The global sockets to be updated.
* @param[in] socket_release The client release callback function.
*/
void socket_cores_release( int packet_phone, socket_cores_ref local_sockets, socket_ports_ref global_sockets, void ( * socket_release )( socket_core_ref socket ));
 
/** Binds the socket to the port.
* The address port is used if set, a free port is used if not.
* @param[in] local_sockets The local sockets to be searched.
* @param[in,out] global_sockets The global sockets to be updated.
* @param[in] socket_id The new socket identifier.
* @param[in] addr The address to be bound to.
* @param[in] addrlen The address length.
* @param[in] free_ports_start The minimum free port.
* @param[in] free_ports_end The maximum free port.
* @param[in] last_used_port The last used free port.
* @returns EOK on success.
* @returns ENOTSOCK if the socket was not found.
* @returns EAFNOSUPPORT if the address family is not supported.
* @returns EADDRINUSE if the port is already in use.
* @returns Other error codes as defined for the socket_bind_free_port() function.
* @returns Other error codes as defined for the socket_bind_insert() function.
*/
int socket_bind( socket_cores_ref local_sockets, socket_ports_ref global_sockets, int socket_id, void * addr, size_t addrlen, int free_ports_start, int free_ports_end, int last_used_port );
 
/** Binds the socket to a free port.
* The first free port is used.
* @param[in,out] global_sockets The global sockets to be updated.
* @param[in,out] socket The socket to be bound.
* @param[in] free_ports_start The minimum free port.
* @param[in] free_ports_end The maximum free port.
* @param[in] last_used_port The last used free port.
* @returns EOK on success.
* @returns ENOTCONN if no free port was found.
* @returns Other error codes as defined for the socket_bind_insert() function.
*/
int socket_bind_free_port( socket_ports_ref global_sockets, socket_core_ref socket, int free_ports_start, int free_ports_end, int last_used_port );
 
/** Creates a new socket.
* @param[in,out] local_sockets The local sockets to be updated.
* @param[in] app_phone The application phone.
* @param[in] specific_data The socket specific data.
* @param[out] socket_id The new socket identifier.
* @returns EOK on success.
* @returns EBADMEM if the socket_id parameter is NULL.
* @returns ENOMEM if there is not enough memory left.
*/
int socket_create( socket_cores_ref local_sockets, int app_phone, void * specific_data, int * socket_id );
 
/** Destroys the socket.
* If the socket is bound, the port is released.
* Releases all buffered packets, calls the release function and removes the socket from the local sockets.
* @param[in] packet_phone The packet server phone to release buffered packets.
* @param[in] socket_id The socket identifier.
* @param[in,out] local_sockets The local sockets to be updated.
* @param[in,out] global_sockets The global sockets to be updated.
* @param[in] socket_release The client release callback function.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
*/
int socket_destroy( int packet_phone, int socket_id, socket_cores_ref local_sockets, socket_ports_ref global_sockets, void ( * socket_release )( socket_core_ref socket ));
 
/** Replies the packet or the packet queue data to the application via the socket.
* Uses the current message processing fibril.
* @param[in] packet The packet to be transfered.
* @param[out] length The total data length.
* @returns EOK on success.
* @returns EBADMEM if the length parameter is NULL.
* @returns ENOMEM if there is not enough memory left.
* @returns Other error codes as defined for the data_reply() function.
*/
int socket_reply_packets( packet_t packet, size_t * length );
 
/** Finds the bound port socket.
* @param[in] global_sockets The global sockets to be searched.
* @param[in] port The port number.
* @param[in] key The socket key identifier.
* @param[in] key_length The socket key length.
* @returns The found socket.
* @returns NULL if no socket was found.
*/
socket_core_ref socket_port_find( socket_ports_ref global_sockets, int port, const char * key, size_t key_length );
 
/** Releases the socket port.
* If the socket is bound the port entry is released.
* If there are no more port entries the port is release.
* @param[in] global_sockets The global sockets to be updated.
* @param[in] socket The socket to be unbound.
*/
void socket_port_release( socket_ports_ref global_sockets, socket_core_ref socket );
 
/** Adds the socket to an already bound port.
* @param[in] global_sockets The global sockets to be updated.
* @param[in] port The port number to be bound to.
* @param[in] socket The socket to be added.
* @param[in] key The socket key identifier.
* @param[in] key_length The socket key length.
* @returns EOK on success.
* @returns ENOENT if the port is not already used.
* @returns Other error codes as defined for the socket_port_add_core() function.
*/
int socket_port_add( socket_ports_ref global_sockets, int port, socket_core_ref socket, const char * key, size_t key_length );
 
#endif
/branches/network/uspace/srv/net/socket/socket_client.c
194,17 → 194,17
static sockets_ref socket_get_sockets( void );
 
/** Default thread for new connections.
* @param iid The initial message identifier. Input parameter.
* @param icall The initial message call structure. Input parameter.
* @param[in] iid The initial message identifier.
* @param[in] icall The initial message call structure.
*/
void socket_connection( ipc_callid_t iid, ipc_call_t * icall );
 
/** Sends message to the socket parent module with specified data.
* @param socket_id Socket identifier. Input parameter.
* @param message The action message. Input parameter.
* @param arg2 The second message parameter. Input parameter.
* @param data The data to be sent. Input parameter.
* @param datalength The data length. Input parameter.
* @param[in] socket_id Socket identifier.
* @param[in] message The action message.
* @param[in] arg2 The second message parameter.
* @param[in] data The data to be sent.
* @param[in] datalength The data length.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the data parameter is NULL.
214,26 → 214,26
int socket_send_data( int socket_id, ipcarg_t message, ipcarg_t arg2, const void * data, size_t datalength );
 
/** Initializes a new socket specific data.
* @param socket The socket to be initialized. Input/output parameter.
* @param socket_id The new socket identifier. Input parameter.
* @param phone The parent module phone. Input parameter.
* @param service The parent module service. Input parameter.
* @param[in,out] socket The socket to be initialized.
* @param[in] socket_id The new socket identifier.
* @param[in] phone The parent module phone.
* @param[in] service The parent module service.
*/
void socket_initialize( socket_ref socket, int socket_id, int phone, services_t service );
 
/** Clears and destroys the socket.
* @param socket The socket to be destroyed. Input parameter.
* @param[in] socket The socket to be destroyed.
*/
void socket_destroy( socket_ref socket );
 
/** Receives data via the socket.
* @param message The action message. Input parameter.
* @param socket_id Socket identifier. Input parameter.
* @param data The data buffer to be filled. Output parameter.
* @param datalength The data length. Input parameter.
* @param flags Various receive flags. Input parameter.
* @param fromaddr The source address. May be NULL for connected sockets. Output parameter.
* @param addrlen The address length. The maximum address length is read. The actual address length is set. Used only if fromaddr is not NULL. Input/output parameter.
* @param[in] message The action message.
* @param[in] socket_id Socket identifier.
* @param[out] data The data buffer to be filled.
* @param[in] datalength The data length.
* @param[in] flags Various receive flags.
* @param[out] fromaddr The source address. May be NULL for connected sockets.
* @param[in,out] addrlen The address length. The maximum address length is read. The actual address length is set. Used only if fromaddr is not NULL.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the data parameter is NULL.
244,13 → 244,13
 
/** Sends data via the socket to the remote address.
* Binds the socket to a free port if not already connected/bound.
* @param message The action message. Input parameter.
* @param socket_id Socket identifier. Input parameter.
* @param data The data to be sent. Input parameter.
* @param datalength The data length. Input parameter.
* @param flags Various send flags. Input parameter.
* @param toaddr The destination address. May be NULL for connected sockets. Input parameter.
* @param addrlen The address length. Used only if toaddr is not NULL. Input parameter.
* @param[in] message The action message.
* @param[in] socket_id Socket identifier.
* @param[in] data The data to be sent.
* @param[in] datalength The data length.
* @param[in] flags Various send flags.
* @param[in] toaddr The destination address. May be NULL for connected sockets.
* @param[in] addrlen The address length. Used only if toaddr is not NULL.
* @returns EOK on success.
* @returns ENOTSOCK if the socket is not found.
* @returns EBADMEM if the data or toaddr parameter is NULL.
/branches/network/uspace/srv/net/messages.h
31,7 → 31,7
*/
 
/** @file
* \todo
* Networking common message definitions.
*/
 
#ifndef __NET_MESSAGES_H__
47,107 → 47,349
#include "structures/measured_strings.h"
#include "structures/packet/packet.h"
 
/** @name Networking message counts
*/
/*@{*/
 
/** The number of network interface driver messages.
*/
#define NET_NETIF_COUNT 6
 
/** The number of general networking messages.
*/
#define NET_NET_COUNT 3
 
/** The number of network interface layer messages.
*/
#define NET_NIL_COUNT 7
 
/** The number of Ethernet messages.
*/
#define NET_ETH_COUNT 0
 
/** The number of inter-network messages.
*/
#define NET_IL_COUNT 6
 
/** The number of IP messages.
*/
#define NET_IP_COUNT 4
 
/** The number of ARP messages.
*/
#define NET_ARP_COUNT 5
 
/** The number of ICMP messages.
*/
#define NET_ICMP_COUNT 6
 
/** The number of transport layer messages.
*/
#define NET_TL_COUNT 1
 
/** The number of UDP messages.
*/
#define NET_UDP_COUNT 0
 
/** The number of TCP messages.
*/
#define NET_TCP_COUNT 0
 
/** The number of packet management system messages.
*/
#define NET_PACKET_COUNT 5
 
/** The number of socket messages.
*/
#define NET_SOCKET_COUNT 14
 
/*@}*/
 
/** @name Networking message intervals
*/
/*@{*/
 
/** The first networking message.
*/
#define NET_FIRST 2000
 
/** The first network interface layer message.
*/
#define NET_NETIF_FIRST NET_FIRST
 
/** The last network interface layer message.
*/
#define NET_NETIF_LAST ( NET_NETIF_FIRST + NET_NETIF_COUNT )
 
/** The first general networking message.
*/
#define NET_NET_FIRST ( NET_NETIF_LAST + 0 )
 
/** The last general networking message.
*/
#define NET_NET_LAST ( NET_NET_FIRST + NET_NET_COUNT )
 
/** The first network interface layer message.
*/
#define NET_NIL_FIRST ( NET_NET_LAST + 0 )
 
/** The last network interface layer message.
*/
#define NET_NIL_LAST ( NET_NIL_FIRST + NET_NIL_COUNT )
 
/** The first Ethernet message.
*/
#define NET_ETH_FIRST ( NET_NIL_LAST + 0 )
 
/** The last Ethernet message.
*/
#define NET_ETH_LAST ( NET_ETH_FIRST + NET_ETH_COUNT )
 
/** The first inter-network message.
*/
#define NET_IL_FIRST ( NET_ETH_LAST + 0 )
 
/** The last inter-network message.
*/
#define NET_IL_LAST ( NET_IL_FIRST + NET_IL_COUNT )
 
/** The first IP message.
*/
#define NET_IP_FIRST ( NET_IL_LAST + 0 )
 
/** The last IP message.
*/
#define NET_IP_LAST ( NET_IP_FIRST + NET_IP_COUNT )
 
/** The first ARP message.
*/
#define NET_ARP_FIRST ( NET_IP_LAST + 0 )
 
/** The last ARP message.
*/
#define NET_ARP_LAST ( NET_ARP_FIRST + NET_ARP_COUNT )
 
/** The first ICMP message.
*/
#define NET_ICMP_FIRST ( NET_ARP_LAST + 0 )
 
/** The last ICMP message.
*/
#define NET_ICMP_LAST ( NET_ICMP_FIRST + NET_ICMP_COUNT )
 
/** The first ICMP message.
*/
#define NET_TL_FIRST ( NET_ICMP_LAST + 0 )
 
/** The last ICMP message.
*/
#define NET_TL_LAST ( NET_TL_FIRST + NET_TL_COUNT )
 
/** The first UDP message.
*/
#define NET_UDP_FIRST ( NET_TL_LAST + 0 )
 
/** The last UDP message.
*/
#define NET_UDP_LAST ( NET_UDP_FIRST + NET_UDP_COUNT )
 
/** The first TCP message.
*/
#define NET_TCP_FIRST ( NET_UDP_LAST + 0 )
 
/** The last TCP message.
*/
#define NET_TCP_LAST ( NET_TCP_FIRST + NET_TCP_COUNT )
 
/** The first socket message.
*/
#define NET_SOCKET_FIRST ( NET_TCP_LAST + 0 )
 
/** The last socket message.
*/
#define NET_SOCKET_LAST ( NET_SOCKET_FIRST + NET_SOCKET_COUNT )
 
/** The first packet management system message.
*/
#define NET_PACKET_FIRST ( NET_SOCKET_LAST + 0 )
 
/** The last packet management system message.
*/
#define NET_PACKET_LAST ( NET_PACKET_FIRST + NET_PACKET_COUNT )
 
/** The last networking message.
*/
#define NET_LAST NET_PACKET_LAST
 
/** The number of networking messages.
*/
#define NET_COUNT ( NET_LAST - NET_FIRST )
 
/** Returns a value indicating whether the value is in the interval.
* @param[in] item The value to be checked.
* @param[in] first_inclusive The first value in the interval inclusive.
* @param[in] last_exclusive The first value after the interval.
*/
#define IS_IN_INTERVAL( item, first_inclusive, last_exclusive ) ((( item ) >= ( first_inclusive )) && (( item ) < ( last_exclusive )))
 
/** Returns a value indicating whether the IPC call is a generic networking message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_FIRST, NET_LAST )
 
/** Returns a value indicating whether the IPC call is a generic networking message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_NET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NET_FIRST, NET_NET_LAST )
 
/** Returns a value indicating whether the IPC call is a network interface layer message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_NIL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_NIL_FIRST, NET_NIL_LAST )
 
/** Returns a value indicating whether the IPC call is an Ethernet message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_ETH_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ETH_FIRST, NET_ETH_LAST )
 
/** Returns a value indicating whether the IPC call is an inter-network layer message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_IL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IL_FIRST, NET_IL_LAST )
 
/** Returns a value indicating whether the IPC call is an IP message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_IP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_IP_FIRST, NET_IP_LAST )
 
/** Returns a value indicating whether the IPC call is an ARP message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_ARP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ARP_FIRST, NET_ARP_LAST )
 
/** Returns a value indicating whether the IPC call is an ICMP message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_ICMP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_ICMP_FIRST, NET_ICMP_LAST )
 
/** Returns a value indicating whether the IPC call is a transport layer message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_TL_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TL_FIRST, NET_TL_LAST )
 
/** Returns a value indicating whether the IPC call is a UDP message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_UDP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_UDP_FIRST, NET_UDP_LAST )
 
/** Returns a value indicating whether the IPC call is a TCP message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_TCP_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_TCP_FIRST, NET_TCP_LAST )
 
/** Returns a value indicating whether the IPC call is a socket message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_SOCKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_SOCKET_FIRST, NET_SOCKET_LAST )
 
/** Returns a value indicating whether the IPC call is a packet manaagement system message.
* @param[in] call The IPC call to be checked.
*/
#define IS_NET_PACKET_MESSAGE( call ) IS_IN_INTERVAL( IPC_GET_METHOD( * call ), NET_PACKET_FIRST, NET_PACKET_LAST )
 
/*@}*/
 
/** @name Networking specific message parameters definitions
*/
/*@{*/
 
/** Returns the device identifier message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_DEVICE( call ) ( device_id_t ) IPC_GET_ARG1( * call )
 
/** Returns the packet identifier message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_PACKET( call ) ( packet_id_t ) IPC_GET_ARG2( * call )
 
/** Returns the count message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_COUNT( call ) ( size_t ) IPC_GET_ARG2( * call )
 
/** Returns the device state message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_STATE( call ) ( device_state_t ) IPC_GET_ARG2( * call )
 
/** Returns the maximum transmission unit message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_MTU( call ) ( size_t ) IPC_GET_ARG2( * call )
 
/** Returns the device driver service message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG3( * call )
 
/** Returns the target service message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_TARGET( call ) ( services_t ) IPC_GET_ARG3( * call )
 
/** Returns the sender service message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_SENDER( call ) ( services_t ) IPC_GET_ARG3( * call )
 
/** Returns the error service message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_ERROR( call ) ( services_t ) IPC_GET_ARG4( * call )
 
/** Returns the phone message parameter.
* @param[in] call The message call structure.
*/
#define IPC_GET_PHONE( call ) ( int ) IPC_GET_ARG5( * call )
 
/** Sets the device identifier in the message answer.
* @param[out] answer The message answer structure.
*/
#define IPC_SET_DEVICE( answer ) (( device_id_t * ) & IPC_GET_ARG1( * answer ))
 
/** Sets the minimum address length in the message answer.
* @param[out] answer The message answer structure.
*/
#define IPC_SET_ADDR( answer ) (( size_t * ) & IPC_GET_ARG1( * answer ))
 
/** Sets the minimum prefix size in the message answer.
* @param[out] answer The message answer structure.
*/
#define IPC_SET_PREFIX( answer ) (( size_t * ) & IPC_GET_ARG2( * answer ))
 
/** Sets the maximum content size in the message answer.
* @param[out] answer The message answer structure.
*/
#define IPC_SET_CONTENT( answer ) (( size_t * ) & IPC_GET_ARG3( * answer ))
 
/** Sets the minimum suffix size in the message answer.
* @param[out] answer The message answer structure.
*/
#define IPC_SET_SUFFIX( answer ) (( size_t * ) & IPC_GET_ARG4( * answer ))
 
/*@}*/
 
/** Returns the address.
* @param[in] phone The service module phone.
* @param[in] message The service specific message.
* @param[in] device_id The device identifier.
* @param[out] address The desired address.
* @param[out] data The address data container.
* @returns EOK on success.
* @returns EBADMEM if the address parameter and/or the data parameter is NULL.
* @returns Other error codes as defined for the specific service message.
*/
static inline int generic_get_addr_req( int phone, int message, device_id_t device_id, measured_string_ref * address, char ** data ){
aid_t message_id;
ipcarg_t result;
164,6 → 406,22
return ( int ) result;
}
 
/** Translates the given strings.
* Allocates and returns the needed memory block as the data parameter.
* @param[in] phone The service module phone.
* @param[in] message The service specific message.
* @param[in] device_id The device identifier.
* @param[in] service The module service.
* @param[in] configuration The key strings.
* @param[in] count The number of configuration keys.
* @param[out] translation The translated values.
* @param[out] data The translation data container.
* @returns EOK on success.
* @returns EINVAL if the configuration parameter is NULL.
* @returns EINVAL if the count parameter is zero (0).
* @returns EBADMEM if the translation or the data parameters are NULL.
* @returns Other error codes as defined for the specific service message.
*/
static inline int generic_translate_req( int phone, int message, device_id_t device_id, services_t service, measured_string_ref configuration, size_t count, measured_string_ref * translation, char ** data ){
aid_t message_id;
ipcarg_t result;
182,6 → 440,15
return ( int ) result;
}
 
/** Sends the packet queue.
* @param[in] phone The service module phone.
* @param[in] message The service specific message.
* @param[in] device_id The device identifier.
* @param[in] packet_id The packet or the packet queue identifier.
* @param[in] sender The sending module service.
* @param[in] error The error module service.
* @returns EOK on success.
*/
static inline int generic_send_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t sender, services_t error ){
if( error ){
async_msg_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) sender, ( ipcarg_t ) error );
191,15 → 458,43
return EOK;
}
 
/** Returns the device packet dimensions for sending.
* @param[in] phone The service module phone.
* @param[in] message The service specific message.
* @param[in] device_id The device identifier.
* @param[out] addr_len The minimum reserved address length.
* @param[out] prefix The minimum reserved prefix size.
* @param[out] content The maximum content size.
* @param[out] suffix The minimum reserved suffix size.
* @returns EOK on success.
* @returns Other error codes as defined for the specific service message.
*/
static inline int generic_packet_size_req( int phone, int message, device_id_t device_id, size_t * addr_len, size_t * prefix, size_t * content, size_t * suffix ){
return ( int ) async_req_1_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t * ) addr_len, ( ipcarg_t * ) prefix, ( ipcarg_t * ) content, ( ipcarg_t * ) suffix );
}
 
/** Notifies the module about the device state change.
* @param[in] phone The service module phone.
* @param[in] message The service specific message.
* @param[in] device_id The device identifier.
* @param[in] state The new device state.
* @param[in] target The target module service.
* @returns EOK on success.
*/
static inline int generic_device_state_msg( int phone, int message, device_id_t device_id, int state, services_t target ){
async_msg_3( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) state, target );
return EOK;
}
 
/** Passes the packet queue to the module.
* @param[in] phone The service module phone.
* @param[in] message The service specific message.
* @param[in] device_id The device identifier.
* @param[in] packet_id The received packet or the received packet queue identifier.
* @param[in] target The target module service.
* @param[in] error The error module service.
* @returns EOK on success.
*/
static inline int generic_received_msg( int phone, int message, device_id_t device_id, packet_id_t packet_id, services_t target, services_t error ){
if( error ){
async_msg_4( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) packet_id, ( ipcarg_t ) target, ( ipcarg_t ) error );
209,6 → 504,15
return EOK;
}
 
/** Notifies a module about the device.
* @param[in] phone The service module phone.
* @param[in] message The service specific message.
* @param[in] device_id The device identifier.
* @param[in] arg2 The second argument of the message.
* @param[in] service The device module service.
* @returns EOK on success.
* @returns Other error codes as defined for the specific service message.
*/
static inline int generic_device_req( int phone, int message, device_id_t device_id, int arg2, services_t service ){
return ( int ) async_req_3_0( phone, ( ipcarg_t ) message, ( ipcarg_t ) device_id, ( ipcarg_t ) arg2, ( ipcarg_t ) service );
}
/branches/network/uspace/srv/net/modules.h
43,36 → 43,36
#include <ipc/services.h>
 
/** Converts the data length between different types.
* @param type_from The source type. Input parameter.
* @param type_to The destination type. Input parameter.
* @param count The number units of the source type size. Input parameter.
* @param[in] type_from The source type.
* @param[in] type_to The destination type.
* @param[in] count The number units of the source type size.
*/
#define CONVERT_SIZE( type_from, type_to, count ) (( sizeof( type_from ) / sizeof( type_to )) * ( count ))
 
/** Registers the module service at the name server.
* @param me The module service. Input parameter.
* @param phonehash The created phone hash. Output parameter.
* @param[in] me The module service.
* @param[out] phonehash The created phone hash.
*/
#define REGISTER_ME( me, phonehash ) ipc_connect_to_me( PHONE_NS, ( me ), 0, 0, ( phonehash ))
 
/** Connect to the needed module function type definition.
* @param need The needed module service. Input parameter.
* @param[in] need The needed module service.
* @returns The phone of the needed service.
*/
typedef int connect_module_t( services_t need );
 
/** Connects to the needed module.
* @param need The needed module service. Input parameter.
* @param[in] need The needed module service.
* @returns The phone of the needed service.
*/
int connect_to_service( services_t need );
 
/** Creates bidirectional connection with the needed module service and registers the message receiver.
* @param need The needed module service. Input parameter.
* @param arg1 The first parameter. Input parameter.
* @param arg2 The second parameter. Input parameter.
* @param arg3 The third parameter. Input parameter.
* @param client_receiver The message receiver. Input parameter.
* @param[in] need The needed module service.
* @param[in] arg1 The first parameter.
* @param[in] arg2 The second parameter.
* @param[in] arg3 The third parameter.
* @param[in] client_receiver The message receiver.
* @returns The phone of the needed service.
* @returns Other error codes as defined for the ipc_connect_to_me() function.
*/
79,24 → 79,24
int bind_service( services_t need, ipcarg_t arg1, ipcarg_t arg2, ipcarg_t arg3, async_client_conn_t client_receiver );
 
/** Answers the call.
* @param callid The call identifier. Input parameter.
* @param result The message processing result. Input parameter.
* @param answer The message processing answer. Input parameter.
* @param answer_count The number of answer parameters. Input parameter.
* @param[in] callid The call identifier.
* @param[in] result The message processing result.
* @param[in] answer The message processing answer.
* @param[in] answer_count The number of answer parameters.
*/
void answer_call( ipc_callid_t callid, int result, ipc_call_t * answer, int answer_count );
 
/** Refreshes answer structure and parameters count.
* Erases all attributes.
* @param answer The message processing answer structure. Input/output parameter.
* @param answer_count The number of answer parameters. Input/output parameter.
* @param[in,out] answer The message processing answer structure.
* @param[in,out] answer_count The number of answer parameters.
*/
void refresh_answer( ipc_call_t * answer, int * answer_count );
 
/** Receives data from the other party.
* The received data buffer is allocated and returned.
* @param data The data buffer to be filled. Output parameter.
* @param length The buffer length. Output parameter.
* @param[out] data The data buffer to be filled.
* @param[out] length The buffer length.
* @returns EOK on success.
* @returns EBADMEM if the data or the length parameter is NULL.
* @returns EINVAL if the client does not send data.
106,8 → 106,8
int data_receive( void ** data, size_t * length );
 
/** Replies the data to the other party.
* @param data The data buffer to be sent. Input parameter.
* @param data_length The buffer length. Input parameter.
* @param[in] data The data buffer to be sent.
* @param[in] data_length The buffer length.
* @returns EOK on success.
* @returns EINVAL if the client does not expect the data.
* @returns EOVERFLOW if the client does not expect all the data. Only partial data are transfered.
/branches/network/uspace/srv/net/il/il_messages.h
75,12 → 75,12
/*@{*/
 
/** Returns the protocol number message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define IL_GET_PROTO( call ) ( int ) IPC_GET_ARG1( * call )
 
/** Returns the registering service message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define IL_GET_SERVICE( call ) ( services_t ) IPC_GET_ARG2( * call )
 
/branches/network/uspace/srv/net/il/arp/arp_messages.h
72,7 → 72,7
/*@{*/
 
/** Returns the protocol service message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define ARP_GET_NETIF( call ) ( services_t ) IPC_GET_ARG2( * call )
 
/branches/network/uspace/srv/net/il/arp/arp.c
74,9 → 74,9
 
/** Creates new protocol specific data.
* Allocates and returns the needed memory block as the proto parameter.
* @param proto The allocated protocol specific data. Output parameter.
* @param service The protocol module service. Input parameter.
* @param address The actual protocol device address. Input parameter.
* @param[out] proto The allocated protocol specific data.
* @param[in] service The protocol module service.
* @param[in] address The actual protocol device address.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
83,9 → 83,9
int arp_proto_create( arp_proto_ref * proto, services_t service, measured_string_ref address );
 
/** Clears the device specific data.
* @param device The device specific data.
* @param[in] device The device specific data.
*/
void clear_device( arp_device_ref device );
void arp_clear_device( arp_device_ref device );
 
/** @name Message processing functions
*/
93,10 → 93,10
 
/** Registers the device.
* Creates new device entry in the cache or updates the protocol address if the device with the device identifier and the driver service exists.
* @param device_id The device identifier. Input parameter.
* @param service The device driver service. Input parameter.
* @param protocol The protocol service. Input parameter.
* @param address The actual device protocol address.
* @param[in] device_id The device identifier.
* @param[in] service The device driver service.
* @param[in] protocol The protocol service.
* @param[in] address The actual device protocol address.
* @returns EOK on success.
* @returns EEXIST if another device with the same device identifier and different driver service exists.
* @returns ENOMEM if there is not enough memory left.
106,9 → 106,9
 
/** Returns the hardware address for the given protocol address.
* Sends the ARP request packet if the hardware address is not found in the cache.
* @param device_id The device identifier. Input parameter.
* @param protocol The protocol service. Input parameter.
* @param target The target protocol address. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] protocol The protocol service.
* @param[in] target The target protocol address.
* @returns The hardware address of the target.
* @returns NULL if the target parameter is NULL.
* @returns NULL if the device is not found.
120,8 → 120,8
/** Processes the received ARP packet.
* Updates the source hardware address if the source entry exists or the packet is targeted to my protocol address.
* Responses to the ARP request if the packet is the ARP request and is targeted to my address.
* @param device_id The source device identifier. Input parameter.
* @param packet The received packet. Input/output parameter.
* @param[in] device_id The source device identifier.
* @param[in,out] packet The received packet.
* @returns EOK on success and the packet is no longer needed.
* @returns 1 on success and the packet has been reused.
* @returns EINVAL if the packet is too small to carry an ARP packet.
133,8 → 133,8
int arp_receive_message( device_id_t device_id, packet_t packet );
 
/** Updates the device content length according to the new MTU value.
* @param device_id The device identifier. Input parameter.
* @param mtu The new mtu value. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] mtu The new mtu value.
* @returns ENOENT if device is not found.
* @returns EOK on success.
*/
161,7 → 161,7
fibril_rwlock_write_unlock( & arp_globals.lock );
return ENOENT;
}
clear_device( device );
arp_clear_device( device );
printf( "Device %d cleared\n", device_id );
fibril_rwlock_write_unlock( & arp_globals.lock );
return EOK;
195,7 → 195,7
for( count = arp_cache_count( & arp_globals.cache ) - 1; count >= 0; -- count ){
device = arp_cache_get_index( & arp_globals.cache, count );
if( device ){
clear_device( device );
arp_clear_device( device );
if( device->addr_data ) free( device->addr_data );
if( device->broadcast_data ) free( device->broadcast_data );
}
481,7 → 481,7
return EOK;
}
 
void clear_device( arp_device_ref device ){
void arp_clear_device( arp_device_ref device ){
int count;
arp_proto_ref proto;
 
/branches/network/uspace/srv/net/il/arp/arp_module.c
64,7 → 64,7
 
/** Starts the ARP module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on successful module termination.
* @returns Other error codes as defined for the arp_initialize() function.
* @returns Other error codes as defined for the REGISTER_ME() macro function.
72,10 → 72,10
int module_start( async_client_conn_t client_connection );
 
/** Processes the ARP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the arp_message() function.
*/
/branches/network/uspace/srv/net/il/arp/arp_module.h
41,7 → 41,7
#include <ipc/ipc.h>
 
/** Initializes the ARP module.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
48,10 → 48,10
int arp_initialize( async_client_conn_t client_connection );
 
/** Processes the ARP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @see arp_interface.h
/branches/network/uspace/srv/net/il/ip/ip_module.h
41,7 → 41,7
#include <ipc/ipc.h>
 
/** Initializes the IP module.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns ENOMEM if there is not enough memory left.
*/
48,10 → 48,10
int ip_initialize( async_client_conn_t client_connection );
 
/** Processes the IP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @see ip_interface.h
/branches/network/uspace/srv/net/il/ip/ip_messages.h
69,31 → 69,30
/*@{*/
 
/** Returns the gateway message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define IP_GET_GATEWAY( call ) ({ in_addr_t addr; addr.s_addr = IPC_GET_ARG2( * call ); addr; })
 
/** Returns the address message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define IP_GET_ADDRESS( call ) ({ in_addr_t addr; addr.s_addr = IPC_GET_ARG3( * call ); addr; })
 
/** Returns the network mask message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define IP_GET_NETMASK( call ) ({ in_addr_t addr; addr.s_addr = IPC_GET_ARG4( * call ); addr; })
 
/** Returns the protocol message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define IP_GET_PROTOCOL( call ) (( ip_protocol_t ) IPC_GET_ARG1( * call ))
 
/** Sets the header length in the message answer.
* @param answer The message answer structure. Output parameter.
* @param[out] answer The message answer structure.
*/
#define IP_SET_HEADERLEN( answer ) (( size_t * ) & IPC_GET_ARG2( * answer ))
 
 
/*@}*/
 
#endif
/branches/network/uspace/srv/net/il/ip/ip_header.h
41,43 → 41,43
#include <byteorder.h>
#include <sys/types.h>
 
/** Returns the actual IP header length.
* @param header The IP packet header. Input parameter.
/** Returns the actual IP header length in bytes.
* @param[in] header The IP packet header.
*/
#define IP_HEADER_LENGTH( header ) (( header )->header_length * 4u )
 
/** Returns the actual IP header length.
* @param header The IP packet header. Input parameter.
/** Returns the IP header length.
* @param[in] length The IP header length in bytes.
*/
#define IP_COMPUTE_HEADER_LENGTH( length ) (( uint8_t ) (( length ) / 4u ))
 
/** Returns the actual IP packet total length.
* @param header The IP packet header. Input parameter.
* @param[in] header The IP packet header.
*/
#define IP_TOTAL_LENGTH( header ) ntohs(( header )->total_length )
 
/** Returns the actual IP packet data length.
* @param header The IP packet header. Input parameter.
* @param[in] header The IP packet header.
*/
#define IP_HEADER_DATA_LENGTH( header ) ( IP_TOTAL_LENGTH( header ) - IP_HEADER_LENGTH( header ))
 
/** Returns the IP packet header checksum.
* @param header The IP packet header. Input parameter.
* @param[in] header The IP packet header.
*/
#define IP_HEADER_CHECKSUM( header ) ( htons( ip_checksum(( uint8_t * )( header ), IP_HEADER_LENGTH( header ))))
 
/** Returns the fragment offest.
* @param header The IP packet header. Input parameter.
* @param[in] header The IP packet header.
*/
#define IP_FRAGMENT_OFFSET( header ) (((( header )->fragment_offset_high << 8 ) + ( header )->fragment_offset_low ) * 8u )
 
/** Returns the fragment offest high bits.
* @param length The prefixed data total length. Input parameter.
* @param[in] length The prefixed data total length.
*/
#define IP_COMPUTE_FRAGMENT_OFFSET_HIGH( length ) (((( length ) / 8u ) & 0x1F00 ) >> 8 )
 
/** Returns the fragment offest low bits.
* @param length The prefixed data total length. Input parameter.
* @param[in] length The prefixed data total length.
*/
#define IP_COMPUTE_FRAGMENT_OFFSET_LOW( length ) ((( length ) / 8u ) & 0xFF )
 
/branches/network/uspace/srv/net/il/ip/ip.c
33,7 → 33,6
/** @file
* IP module implementation.
* @see arp.h
* \todo
*/
 
#include <async.h>
137,8 → 136,8
GENERIC_FIELD_IMPLEMENT( ip_routes, ip_route_t )
 
/** Updates the device content length according to the new MTU value.
* @param device_id The device identifier. Input parameter.
* @param mtu The new mtu value. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] mtu The new mtu value.
* @returns EOK on success.
* @returns ENOENT if device is not found.
*/
145,19 → 144,30
int ip_mtu_changed_message( device_id_t device_id, size_t mtu );
 
/** Updates the device state.
* @param device_id The device identifier. Input parameter.
* @param state The new state value. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] state The new state value.
* @returns EOK on success.
* @returns ENOENT if device is not found.
*/
int ip_device_state_message( device_id_t device_id, device_state_t state );
 
/** Registers the transport layer protocol.
* The traffic of this protocol will be supplied using either the receive function or IPC message.
* @param[in] protocol The transport layer module protocol.
* @param[in] service The transport layer module service.
* @param[in] phone The transport layer module phone.
* @param[in] tl_received_msg The receiving function.
* @returns EOK on success.
* @returns EINVAL if the protocol parameter and/or the service parameter is zero (0).
* @returns EINVAL if the phone parameter is not a positive number and the tl_receive_msg is NULL.
* @returns ENOMEM if there is not enough memory left.
*/
int ip_register( int protocol, services_t service, int phone, tl_received_msg_t tl_received_msg );
 
/** Initializes a new network interface specific data.
* Connects to the network interface layer module, reads the netif configuration, starts an ARP module if needed and sets the netif routing table.
* The device identifier and the nil service has to be set.
* @param ip_netif Network interface specific data. Input/output parameter.
* @param[in,out] ip_netif Network interface specific data.
* @returns EOK on success.
* @returns ENOTSUP if DHCP is configured.
* @returns ENOTSUP if IPv6 is configured.
171,22 → 181,126
*/
int ip_netif_initialize( ip_netif_ref ip_netif );
 
/** Sends the packet or the packet queue via the specified route.
* The ICMP_HOST_UNREACH error notification may be sent if route hardware destination address is found.
* @param[in,out] packet The packet to be sent.
* @param[in] netif The target network interface.
* @param[in] route The target route.
* @param[in] src The source address.
* @param[in] dest The destination address.
* @param[in] error The error module service.
* @returns EOK on success.
* @returns Other error codes as defined for the arp_translate_req() function.
* @returns Other error codes as defined for the ip_prepare_packet() function.
*/
int ip_send_route( packet_t packet, ip_netif_ref netif, ip_route_ref route, in_addr_t * src, in_addr_t dest, services_t error );
 
/** Prepares the outgoing packet or the packet queue.
* The packet queue is a fragmented packet
* Updates the first packet's IP header.
* Prefixes the additional packets with fragment headers.
* @param[in] source The source address.
* @param[in] dest The destination address.
* @param[in,out] packet The packet to be sent.
* @param[in] destination The destination hardware address.
* @returns EOK on success.
* @returns EINVAL if the packet is too small to contain the IP header.
* @returns EINVAL if the packet is too long than the IP allows.
* @returns ENOMEM if there is not enough memory left.
* @returns Other error codes as defined for the packet_set_addr() function.
*/
int ip_prepare_packet( in_addr_t * source, in_addr_t dest, packet_t packet, measured_string_ref destination );
 
/** Checks the packet queue lengths and fragments the packets if needed.
* The ICMP_FRAG_NEEDED error notification may be sent if the packet needs to be fragmented and the fragmentation is not allowed.
* @param[in,out] packet The packet or the packet queue to be checked.
* @param[in] prefix The minimum prefix size.
* @param[in] content The maximum content size.
* @param[in] suffix The minimum suffix size.
* @param[in] addr_len The minimum address length.
* @param[in] error The error module service.
* @returns The packet or the packet queue of the allowed length.
* @returns NULL if there are no packets left.
*/
packet_t ip_split_packet( packet_t packet, size_t prefix, size_t content, size_t suffix, socklen_t addr_len, services_t error );
 
/** Checks the packet length and fragments it if needed.
* The new fragments are queued before the original packet.
* @param[in,out] packet The packet to be checked.
* @param[in] length The maximum packet length.
* @param[in] prefix The minimum prefix size.
* @param[in] suffix The minimum suffix size.
* @param[in] addr_len The minimum address length.
* @returns EOK on success.
* @returns EINVAL if the packet_get_addr() function fails.
* @returns EINVAL if the packet does not contain the IP header.
* @returns EPERM if the packet needs to be fragmented and the fragmentation is not allowed.
* @returns ENOMEM if there is not enough memory left.
* @returns ENOMEM if there is no packet available.
* @returns ENOMEM if the packet is too small to contain the IP header.
* @returns Other error codes as defined for the packet_trim() function.
* @returns Other error codes as defined for the ip_create_middle_header() function.
* @returns Other error codes as defined for the ip_fragment_packet_data() function.
*/
int ip_fragment_packet( packet_t packet, size_t length, size_t prefix, size_t suffix, socklen_t addr_len );
 
/** Fragments the packet from the end.
* @param[in] packet The packet to be fragmented.
* @param[in,out] new_packet The new packet fragment.
* @param[in,out] header The original packet header.
* @param[in,out] new_header The new packet fragment header.
* @param[in] length The new fragment length.
* @param[in] src The source address.
* @param[in] dest The destiantion address.
* @param[in] addrlen The address length.
* @returns EOK on success.
* @returns ENOMEM if the target packet is too small.
* @returns Other error codes as defined for the packet_set_addr() function.
* @returns Other error codes as defined for the pq_insert_after() function.
*/
int ip_fragment_packet_data( packet_t packet, packet_t new_packet, ip_header_ref header, ip_header_ref new_header, size_t length, const struct sockaddr * src, const struct sockaddr * dest, socklen_t addrlen );
 
/** Prefixes a middle fragment header based on the last fragment header to the packet.
* @param[in] packet The packet to be prefixed.
* @param[in] last The last header to be copied.
* @returns The prefixed middle header.
* @returns NULL on error.
*/
ip_header_ref ip_create_middle_header( packet_t packet, ip_header_ref last );
 
/** Copies the fragment header.
* Copies only the header itself and relevant IP options.
* @param[out] last The created header.
* @param[in] first The original header to be copied.
*/
void ip_create_last_header( ip_header_ref last, ip_header_ref first );
 
/** Returns the network interface's IP address.
* @param[in] netif The network interface.
* @returns The IP address.
* @returns NULL if no IP address was found.
*/
in_addr_t * ip_netif_address( ip_netif_ref netif );
 
/** Searches all network interfaces if there is a suitable route.
* @param[in] destination The destination address.
* @returns The found route.
* @returns NULL if no route was found.
*/
ip_route_ref ip_find_route( in_addr_t destination );
 
/** Searches the network interfaces if there is a suitable route.
* @param[in] netif The network interface to be searched for routes. May be NULL.
* @param[in] destination The destination address.
* @returns The found route.
* @returns NULL if no route was found.
*/
ip_route_ref ip_netif_find_route( ip_netif_ref netif, in_addr_t destination );
 
/** Processes the received IP packet.
* @param device_id The source device identifier. Input parameter.
* @param packet The received packet. Input/output parameter.
/** Processes the received IP packet or the packet queue one by one.
* The packet is either passed to another module or released on error.
* @param[in] device_id The source device identifier.
* @param[in,out] packet The received packet.
* @returns EOK on success and the packet is no longer needed.
* @returns EINVAL if the packet is too small to carry the IP packet.
* @returns EINVAL if the received address lengths differs from the registered values.
196,14 → 310,84
*/
int ip_receive_message( device_id_t device_id, packet_t packet );
 
/** Processes the received packet.
* The packet is either passed to another module or released on error.
* The ICMP_PARAM_POINTER error notification may be sent if the checksum is invalid.
* The ICMP_EXC_TTL error notification may be sent if the TTL is less than two (2).
* The ICMP_HOST_UNREACH error notification may be sent if no route was found.
* The ICMP_HOST_UNREACH error notification may be sent if the packet is for another host and the routing is disabled.
* @param[in] device_id The source device identifier.
* @param[in] packet The received packet to be processed.
* @returns EOK on success.
* @returns EINVAL if the TTL is less than two (2).
* @returns EINVAL if the checksum is invalid.
* @returns EAFNOSUPPORT if the address family is not supported.
* @returns ENOENT if no route was found.
* @returns ENOENT if the packet is for another host and the routing is disabled.
*/
int ip_process_packet( device_id_t device_id, packet_t packet );
 
/** Returns the packet destination address from the IP header.
* @param[in] header The packet IP header to be read.
* @returns The packet destination address.
*/
in_addr_t ip_get_destination( ip_header_ref header );
 
/** Delivers the packet to the local host.
* The packet is either passed to another module or released on error.
* The ICMP_PROT_UNREACH error notification may be sent if the protocol is not found.
* @param[in] device_id The source device identifier.
* @param[in] packet The packet to be delivered.
* @param[in] header The first packet IP header. May be NULL.
* @param[in] error The packet error service.
* @returns EOK on success.
* @returns ENOTSUP if the packet is a fragment.
* @returns EAFNOSUPPORT if the address family is not supported.
* @returns ENOENT if the target protocol is not found.
* @returns Other error codes as defined for the packet_set_addr() function.
* @returns Other error codes as defined for the packet_trim() function.
* @returns Other error codes as defined for the protocol specific tl_received_msg function.
*/
int ip_deliver_local( device_id_t device_id, packet_t packet, ip_header_ref header, services_t error );
 
/** Prepares the ICMP notification packet.
* Releases additional packets and keeps only the first one.
* All packets is released on error.
* @param[in] error The packet error service.
* @param[in] packet The packet or the packet queue to be reported as faulty.
* @param[in] header The first packet IP header. May be NULL.
* @returns The found ICMP phone.
* @returns EINVAL if the error parameter is set.
* @returns EINVAL if the ICMP phone is not found.
* @returns EINVAL if the ip_prepare_icmp() fails.
*/
int ip_prepare_icmp_and_get_phone( services_t error, packet_t packet, ip_header_ref header );
 
/** Returns the ICMP phone.
* Searches the registered protocols.
* @returns The found ICMP phone.
* @returns ENOENT if the ICMP is not registered.
*/
int ip_get_icmp_phone( void );
 
/** Prepares the ICMP notification packet.
* Releases additional packets and keeps only the first one.
* @param[in] packet The packet or the packet queue to be reported as faulty.
* @param[in] header The first packet IP header. May be NULL.
* @returns EOK on success.
* @returns EINVAL if there are no data in the packet.
* @returns EINVAL if the packet is a fragment.
* @returns ENOMEM if the packet is too short to contain the IP header.
* @returns EAFNOSUPPORT if the address family is not supported.
* @returns Other error codes as defined for the packet_set_addr().
*/
int ip_prepare_icmp( packet_t packet, ip_header_ref header );
 
/** Releases the packet and returns the result.
* @param[in] packet The packet queue to be released.
* @param[in] result The result to be returned.
* @return The result parameter.
*/
int ip_release_and_return( packet_t packet, int result );
 
int ip_initialize( async_client_conn_t client_connection ){
1050,7 → 1234,7
dest = ( struct sockaddr * ) & dest_in;
break;
*/ default:
return EAFNOSUPPORT;
return ip_release_and_return( packet, EAFNOSUPPORT );
}
ERROR_PROPAGATE( packet_set_addr( packet, NULL, ( uint8_t * ) & addr, addrlen ));
route = ip_find_route( dest );
/branches/network/uspace/srv/net/il/ip/ip_module.c
64,7 → 64,7
 
/** Starts the IP module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on successful module termination.
* @returns Other error codes as defined for the ip_initialize() function.
* @returns Other error codes as defined for the REGISTER_ME() macro function.
72,10 → 72,10
int module_start( async_client_conn_t client_connection );
 
/** Processes the IP message.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the ip_message() function.
*/
/branches/network/uspace/srv/net/netif/netif_module.h
52,9 → 52,9
int netif_initialize( void );
 
/** Probes the existence of the device.
* @param device_id The device identifier. Input parameter.
* @param irq The device interrupt number. Input parameter.
* @param io The device input/output address. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] irq The device interrupt number.
* @param[in] io The device input/output address.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
62,9 → 62,9
int netif_probe_message( device_id_t device_id, int irq, int io );
 
/** Sends the packet queue.
* @param device_id The device identifier. Input parameter.
* @param packet The packet queue. Input parameter.
* @param sender The sending module service. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] packet The packet queue.
* @param[in] sender The sending module service.
* @returns EOK on success.
* @returns EFORWARD if the device is not active (in the NETIF_ACTIVE state).
* @returns Other error codes as defined for the find_device() function.
73,7 → 73,7
int netif_send_message( device_id_t device_id, packet_t packet, services_t sender );
 
/** Starts the device.
* @param device The device structure. Input parameter.
* @param[in] device The device structure.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
81,7 → 81,7
int netif_start_message( device_ref device );
 
/** Stops the device.
* @param device The device structure. Input parameter.
* @param[in] device The device structure.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
89,8 → 89,8
int netif_stop_message( device_ref device );
 
/** Returns the device local hardware address.
* @param device_id The device identifier. Input parameter.
* @param address The device local hardware address. Output parameter.
* @param[in] device_id The device identifier.
* @param[out] address The device local hardware address.
* @returns EOK on success.
* @returns EBADMEM if the address parameter is NULL.
* @returns ENOENT if there no such device.
101,10 → 101,10
 
/** Processes the netif driver specific message.
* This function is called for uncommon messages received by the netif skeleton.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for the specific module message implementation.
112,8 → 112,8
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
 
/** Returns the device usage statistics.
* @param device_id The device identifier. Input parameter.
* @param stats The device usage statistics. Output parameter.
* @param[in] device_id The device identifier.
* @param[out] stats The device usage statistics.
* @returns EOK on success.
* @returns Other error codes as defined for the find_device() function.
* @returns Other error codes as defined for the specific module message implementation.
/branches/network/uspace/srv/net/netif/netif_nil_bundle.c
52,10 → 52,10
extern netif_globals_t netif_globals;
 
/** Distributes the messages between the module parts.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
64,7 → 64,7
 
/** Starts the bundle network interface module.
* Initializes the client connection serving function, initializes both module parts, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module message function.
*/
/branches/network/uspace/srv/net/netif/netif_messages.h
76,12 → 76,12
/*@{*/
 
/** Returns the interrupt number message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define NETIF_GET_IRQ( call ) ( int ) IPC_GET_ARG2( * call )
 
/** Returns the input/output address message parameter.
* @param call The message call structure. Input parameter.
* @param[in] call The message call structure.
*/
#define NETIF_GET_IO( call ) ( int ) IPC_GET_ARG3( * call )
 
/branches/network/uspace/srv/net/netif/netif.c
70,8 → 70,8
/*@{*/
 
/** Registers the device notification receiver, the network interface layer module.
* @param device_id The device identifier. Input parameter.
* @param phone The network interface layer module phone. Input parameter.
* @param[in] device_id The device identifier.
* @param[in] phone The network interface layer module phone.
* @returns EOK on success.
* @returns ENOENT if there is no such device.
* @returns ELIMIT if there is another module registered.
/branches/network/uspace/srv/net/netif/dp8390/local.h
21,7 → 21,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes:
* 2009 Lukas Mejdrech ported to HelenOS
* 2009 ported to HelenOS, Lukas Mejdrech
*/
 
/** @addtogroup dp8390
28,6 → 28,10
* @{
*/
 
/** @file
* Network interface probe functions.
*/
 
#ifndef __NET_NETIF_DP8390_CONFIG_H__
#define __NET_NETIF_DP8390_CONFIG_H__
 
37,25 → 41,57
local.h
*/
 
/** WDETH switch.
*/
#define ENABLE_WDETH 0
 
/** NE2000 switch.
*/
#define ENABLE_NE2000 1
 
/** 3C503 switch.
*/
#define ENABLE_3C503 0
 
/** PCI support switch.
*/
#define ENABLE_PCI 0
 
struct dpeth;
 
/* 3c503.c */
_PROTOTYPE( int el2_probe, (struct dpeth* dep) );
/* * Probes a 3C503 network interface.
* @param[in] dep The network interface structure.
* @returns 1 if the NE2000 network interface is present.
* @returns 0 otherwise.
*/
//_PROTOTYPE( int el2_probe, (struct dpeth* dep) );
 
/* ne2000.c */
_PROTOTYPE( int ne_probe, (struct dpeth *dep) );
/** Probes a NE2000 or NE1000 network interface.
* @param[in] dep The network interface structure.
* @returns 1 if the NE2000 network interface is present.
* @returns 0 otherwise.
*/
int ne_probe( struct dpeth * dep );
//_PROTOTYPE( int ne_probe, (struct dpeth *dep) );
//_PROTOTYPE( void ne_init, (struct dpeth *dep) );
 
/* rtl8029.c */
_PROTOTYPE( int rtl_probe, (struct dpeth *dep) );
/* * Probes a RTL8029 network interface.
* @param[in] dep The network interface structure.
* @returns 1 if the NE2000 network interface is present.
* @returns 0 otherwise.
*/
//_PROTOTYPE( int rtl_probe, (struct dpeth *dep) );
 
/* wdeth.c */
_PROTOTYPE( int wdeth_probe, (struct dpeth* dep) );
/* * Probes a WDETH network interface.
* @param[in] dep The network interface structure.
* @returns 1 if the NE2000 network interface is present.
* @returns 0 otherwise.
*/
//_PROTOTYPE( int wdeth_probe, (struct dpeth* dep) );
 
#endif
 
/branches/network/uspace/srv/net/netif/dp8390/dp8390_port.h
31,7 → 31,7
*/
 
/** @file
* \todo
* DP8390 network interface types and structures ports.
*/
 
#ifndef __NET_NETIF_DP8390_PORT_H__
43,26 → 43,105
#include <libarch/ddi.h>
#include <sys/types.h>
 
/** Macro for difining functions.
* @param[in] function The function type and name definition.
* @param[in] params The function parameters definition.
*/
#define _PROTOTYPE( function, params ) function params
 
/** Success error code.
*/
#define OK EOK
 
/** Type definition of the unsigned byte.
*/
typedef uint8_t u8_t;
 
/** Type definition of the unsigned short.
*/
typedef uint16_t u16_t;
 
/** Compares two memory blocks.
* @param[in] first The first memory block.
* @param[in] second The second memory block.
* @param[in] size The blocks size in bytes.
* @returns 0 if equeal.
* @returns -1 if the first is greater than the second.
* @returns 1 if the second is greater than the first.
*/
#define memcmp( first, second, size ) bcmp(( char * ) ( first ), ( char * ) ( second ), ( size ))
 
/** Reads 1 byte.
* @param[in] port The address to be read.
* @returns The read value.
*/
#define inb( port ) pio_read_8(( ioport8_t * ) ( port ))
 
/** Reads 1 word (2 bytes).
* @param[in] port The address to be read.
* @returns The read value.
*/
#define inw( port ) pio_read_16(( ioport16_t * ) ( port ))
 
/** Writes 1 byte.
* @param[in] port The address to be written.
* @param[in] value The value to be written.
*/
#define outb( port, value ) pio_write_8(( ioport8_t * ) ( port ), ( value ))
 
/** Writes 1 word (2 bytes).
* @param[in] port The address to be written.
* @param[in] value The value to be written.
*/
#define outw( port, value ) pio_write_16(( ioport16_t * ) ( port ), ( value ))
 
/** Prints out the driver critical error.
* Does not call the system panic().
*/
#define panic( ... ) printf( "%s%s%d", __VA_ARGS__ )
 
/** Copies a memory block.
* @param proc The source process. Ignored parameter.
* @param src_s Ignored parameter.
* @param[in] src The source address.
* @param me The current proces. Ignored parameter.
* @param dst_s Ignored parameter.
* @param[in] dst The destination address.
* @param[in] bytes The block size in bytes.
* @returns EOK.
*/
#define sys_vircopy( proc, src_s, src, me, dst_s, dst, bytes ) ({ memcpy(( void * )( dst ), ( void * )( src ), ( bytes )); EOK; })
#define do_vir_insb( port, proc, src, bytes ) insb(( port ), ( void * )( src ), ( bytes ))
#define do_vir_insw( port, proc, src, bytes ) insw(( port ), ( void * )( src ), ( bytes ))
 
/** Reads a memory block byte by byte.
* @param[in] port The address to be written.
* @param proc The source process. Ignored parameter.
* @param[in] dst The destination address.
* @param[in] bytes The block size in bytes.
*/
#define do_vir_insb( port, proc, dst, bytes ) insb(( port ), ( void * )( dst ), ( bytes ))
 
/** Reads a memory block word by word (2 bytes).
* @param[in] port The address to be written.
* @param proc The source process. Ignored parameter.
* @param[in] dst The destination address.
* @param[in] bytes The block size in bytes.
*/
#define do_vir_insw( port, proc, dst, bytes ) insw(( port ), ( void * )( dst ), ( bytes ))
 
/** Writes a memory block byte by byte.
* @param[in] port The address to be written.
* @param proc The source process. Ignored parameter.
* @param[in] src The source address.
* @param[in] bytes The block size in bytes.
*/
#define do_vir_outsb( port, proc, src, bytes ) outsb(( port ), ( void * )( src ), ( bytes ))
 
/** Writes a memory block word by word (2 bytes).
* @param[in] port The address to be written.
* @param proc The source process. Ignored parameter.
* @param[in] src The source address.
* @param[in] bytes The block size in bytes.
*/
#define do_vir_outsw( port, proc, src, bytes ) outsw(( port ), ( void * )( src ), ( bytes ))
 
/* com.h */
73,54 → 152,120
# define DL_BROAD_REQ 0x8
 
/* const.h */
/** True value.
*/
#define TRUE 1 /* used for turning integers into Booleans */
 
/** False value.
*/
#define FALSE 0 /* used for turning integers into Booleans */
 
/** No number value.
*/
#define NO_NUM 0x8000 /* used as numerical argument to panic() */
 
/* devio.h */
//typedef u16_t port_t;
/** Type definition of a port.
*/
typedef int port_t;
 
/* dl_eth.h */
/** Ethernet statistics.
*/
typedef struct eth_stat
{
unsigned long ets_recvErr, /* # receive errors */
ets_sendErr, /* # send error */
ets_OVW, /* # buffer overwrite warnings */
ets_CRCerr, /* # crc errors of read */
ets_frameAll, /* # frames not alligned (# bits % 8 != 0) */
ets_missedP, /* # packets missed due to slow processing */
ets_packetR, /* # packets received */
ets_packetT, /* # packets transmitted */
ets_transDef, /* # transmission defered (Tx was busy) */
ets_collision, /* # collissions */
ets_transAb, /* # Tx aborted due to excess collisions */
ets_carrSense, /* # carrier sense lost */
ets_fifoUnder, /* # FIFO underruns (processor too busy) */
ets_fifoOver, /* # FIFO overruns (processor too busy) */
ets_CDheartbeat, /* # times unable to transmit collision sig*/
ets_OWC; /* # times out of window collision */
/** Number of receive errors.
*/
unsigned long ets_recvErr;
/** Number of send error.
*/
unsigned long ets_sendErr;
/** Number of buffer overwrite warnings.
*/
unsigned long ets_OVW;
/** Number of crc errors of read.
*/
unsigned long ets_CRCerr;
/** Number of frames not alligned (number of bits % 8 != 0).
*/
unsigned long ets_frameAll;
/** Number of packets missed due to slow processing.
*/
unsigned long ets_missedP;
/** Number of packets received.
*/
unsigned long ets_packetR;
/** Number of packets transmitted.
*/
unsigned long ets_packetT;
/** Number of transmission defered (Tx was busy).
*/
unsigned long ets_transDef;
/** Number of collissions.
*/
unsigned long ets_collision;
/** Number of Tx aborted due to excess collisions.
*/
unsigned long ets_transAb;
/** Number of carrier sense lost.
*/
unsigned long ets_carrSense;
/** Number of FIFO underruns (processor too busy).
*/
unsigned long ets_fifoUnder;
/** Number of FIFO overruns (processor too busy).
*/
unsigned long ets_fifoOver;
/** Number of times unable to transmit collision sig.
*/
unsigned long ets_CDheartbeat;
/** Number of times out of window collision.
*/
unsigned long ets_OWC;
} eth_stat_t;
 
/* errno.h */
/** Generic error.
*/
#define EGENERIC EINVAL
 
/* ether.h */
/** Minimum Ethernet packet size in bytes.
*/
#define ETH_MIN_PACK_SIZE 60
 
/** Maximum Ethernet packet size in bytes.
*/
#define ETH_MAX_PACK_SIZE_TAGGED 1518
 
/** Ethernet address type definition.
*/
typedef struct ether_addr
{
/** Address data.
*/
u8_t ea_addr[6];
} ether_addr_t;
 
/* type.h */
typedef unsigned long phys_bytes; /* physical addr/length in bytes */
typedef unsigned int vir_bytes; /* virtual addresses and lengths in bytes */
/** Type definition of the physical addresses and lengths in bytes.
*/
typedef unsigned long phys_bytes;
 
/** Type definition of the virtual addresses and lengths in bytes.
*/
typedef unsigned int vir_bytes;
 
/** Type definition of the input/output vector.
*/
typedef struct {
vir_bytes iov_addr; /* address of an I/O buffer */
vir_bytes iov_size; /* sizeof an I/O buffer */
/** Address of an I/O buffer.
*/
vir_bytes iov_addr;
/** Sizeof an I/O buffer.
*/
vir_bytes iov_size;
} iovec_t;
 
#endif
/branches/network/uspace/srv/net/netif/dp8390/ne2000.c
21,7 → 21,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes:
* 2009 Lukas Mejdrech ported to HelenOS
* 2009 ported to HelenOS, Lukas Mejdrech
*/
 
/** @addtogroup ne2k
29,7 → 29,7
*/
 
/** @file
* \todo
* NE1000 and NE2000 network interface initialization and probe functions implementation.
*/
 
#include <stdio.h>
60,26 → 60,66
 
#if ENABLE_NE2000
 
/** Number of bytes to transfer.
*/
#define N 100
 
//#define MILLIS_TO_TICKS(m) (((m)*HZ/1000)+1)
 
/** Sleeps for the defined millicesonds.
* @param[in] millis The number of milliseconds to sleep.
*/
#define milli_delay( millis ) usleep(( millis ) * 1000 )
 
/** Type definition of the testing function.
*/
_PROTOTYPE( typedef int (*testf_t), (dpeth_t *dep, int pos, u8_t *pat) );
 
/** First data pattern.
*/
u8_t pat0[]= { 0x00, 0x00, 0x00, 0x00 };
 
/** Second data pattern.
*/
u8_t pat1[]= { 0xFF, 0xFF, 0xFF, 0xFF };
 
/** Third data pattern.
*/
u8_t pat2[]= { 0xA5, 0x5A, 0x69, 0x96 };
 
/** Fourth data pattern.
*/
u8_t pat3[]= { 0x96, 0x69, 0x5A, 0xA5 };
 
_PROTOTYPE( static int test_8, (dpeth_t *dep, int pos, u8_t *pat) );
_PROTOTYPE( static int test_16, (dpeth_t *dep, int pos, u8_t *pat) );
_PROTOTYPE( static void ne_stop, (dpeth_t *dep) );
/** Tests 8 bit NE2000 network interface.
* @param[in,out] dep The network interface structure.
* @param[in] pos The starting position.
* @param[in] pat The data pattern to be written.
* @returns True on success.
* @returns FALSE otherwise.
*/
static int test_8(dpeth_t *dep, int pos, u8_t *pat);
 
/** Tests 16 bit NE2000 network interface.
* @param[in,out] dep The network interface structure.
* @param[in] pos The starting position.
* @param[in] pat The data pattern to be written.
* @returns True on success.
* @returns FALSE otherwise.
*/
static int test_16(dpeth_t *dep, int pos, u8_t *pat);
 
/** Stops the NE2000 network interface.
* @param[in,out] dep The network interface structure.
*/
static void ne_stop(dpeth_t *dep);
//_PROTOTYPE( static void milli_delay, (unsigned long millis) );
 
#define milli_delay( millis ) usleep(( millis ) * 1000 )
/** Initializes the NE2000 network interface.
* @param[in,out] dep The network interface structure.
*/
void ne_init(struct dpeth *dep);
 
_PROTOTYPE( void ne_init, (struct dpeth *dep) );
 
/*===========================================================================*
* ne_probe *
*===========================================================================*/
/branches/network/uspace/srv/net/netif/dp8390/dp8390.c
21,7 → 21,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes:
* 2009 Lukas Mejdrech ported to HelenOS
* 2009 ported to HelenOS, Lukas Mejdrech
*/
 
/** @addtogroup dp8390
29,7 → 29,7
*/
 
/** @file
* \todo
* DP8390 network interface core implementation.
*/
 
#include <assert.h>
60,8 → 60,26
#include "local.h"
#include "dp8390.h"
 
/** Queues the outgoing packet.
* @param[in] dep The network interface structure.
* @param[in] packet The outgoing packet.
* @returns EOK on success.
* @returns EINVAL
*/
int queue_packet( dpeth_t * dep, packet_t packet );
 
/** Reads a memory block byte by byte.
* @param[in] port The source address.
* @param[out] buf The destination buffer.
* @param[in] size The memory block size in bytes.
*/
static void outsb( port_t port, void * buf, size_t size );
 
/** Reads a memory block word by word.
* @param[in] port The source address.
* @param[out] buf The destination buffer.
* @param[in] size The memory block size in bytes.
*/
static void outsw( port_t port, void * buf, size_t size );
 
//static u16_t eth_ign_proto;
/branches/network/uspace/srv/net/netif/dp8390/dp8390_drv.h
31,7 → 31,7
*/
 
/** @file
* \todo
* DP8390 network interface driver interface.
*/
 
#ifndef __NET_NETIF_DP8390_DRIVER_H__
39,11 → 39,43
 
#include "dp8390.h"
 
_PROTOTYPE( int do_init, (dpeth_t *dep, int mode) );
_PROTOTYPE( void do_stop, (dpeth_t *dep) );
_PROTOTYPE( void dp_check_ints, (dpeth_t *dep, int isr) );
/** Initializes and/or starts the network interface.
* @param[in,out] dep The network interface structure.
* @param[in] mode The state mode.
* @returns EOK on success.
* @returns EXDEV if the network interface is disabled.
*/
int do_init(dpeth_t *dep, int mode);
 
/** Stops the network interface.
* @param[in,out] dep The network interface structure.
*/
void do_stop(dpeth_t *dep);
 
/** Processes the interrupt.
* @param[in,out] dep The network interface structure.
* @param[in] isr The interrupt status register.
*/
void dp_check_ints(dpeth_t *dep, int isr);
 
/** Probes and initializes the network interface.
* @param[in,out] dep The network interface structure.
* @returns EOK on success.
* @returns EXDEV if the network interface was not recognized.
*/
int do_probe( dpeth_t * dep );
 
/** Sends a packet.
* @param[in,out] dep The network interface structure.
* @param[in] packet The packet t be sent.
* @param[in] from_int The value indicating whether the sending is initialized from the interrupt handler.
* @returns
*/
int do_pwrite( dpeth_t * dep, packet_t packet, int from_int );
 
/** Prints out network interface information.
* @param[in] dep The network interface structure.
*/
void dp8390_dump( dpeth_t * dep );
 
#endif
/branches/network/uspace/srv/net/netif/dp8390/ne2000.h
21,7 → 21,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes:
* 2009 Lukas Mejdrech ported to HelenOS
* 2009 ported to HelenOS, Lukas Mejdrech
*/
 
/*
35,7 → 35,7
*/
 
/** @file
* \todo
* NE1000 and NE2000 network interface definitions.
*/
 
#ifndef __NET_NETIF_NE2000_H__
45,18 → 45,60
 
#include "dp8390_port.h"
 
/** DP8390 register offset.
*/
#define NE_DP8390 0x00
 
/** Data register.
*/
#define NE_DATA 0x10
 
/** Reset register.
*/
#define NE_RESET 0x1F
 
/** NE1000 data start.
*/
#define NE1000_START 0x2000
 
/** NE1000 data size.
*/
#define NE1000_SIZE 0x2000
 
/** NE2000 data start.
*/
#define NE2000_START 0x4000
 
/** NE2000 data size.
*/
#define NE2000_SIZE 0x4000
 
/** Reads 1 byte register.
* @param[in] dep The network interface structure.
* @param[in] reg The register offset.
* @returns The read value.
*/
#define inb_ne(dep, reg) (inb(dep->de_base_port+reg))
 
/** Writes 1 byte register.
* @param[in] dep The network interface structure.
* @param[in] reg The register offset.
* @param[in] data The value to be written.
*/
#define outb_ne(dep, reg, data) (outb(dep->de_base_port+reg, data))
 
/** Reads 1 word (2 bytes) register.
* @param[in] dep The network interface structure.
* @param[in] reg The register offset.
* @returns The read value.
*/
#define inw_ne(dep, reg) (inw(dep->de_base_port+reg))
 
/** Writes 1 word (2 bytes) register.
* @param[in] dep The network interface structure.
* @param[in] reg The register offset.
* @param[in] data The value to be written.
*/
#define outw_ne(dep, reg, data) (outw(dep->de_base_port+reg, data))
 
#endif /* __NET_NETIF_NE2000_H__ */
/branches/network/uspace/srv/net/netif/dp8390/dp8390.h
21,7 → 21,7
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Changes:
* 2009 Lukas Mejdrech ported to HelenOS
* 2009 ported to HelenOS, Lukas Mejdrech
*/
 
/** @addtogroup dp8390
29,7 → 29,7
*/
 
/** @file
* \todo
* DP8390 network interface definitions.
*/
 
#ifndef __NET_NETIF_DP8390_H__
40,6 → 40,8
#include "dp8390_port.h"
#include "local.h"
 
/** Input/output size.
*/
#define DP8390_IO_SIZE 0x01f
 
/*
196,21 → 198,55
#define RSR_DIS 0x40 /* Receiver Disabled */
#define RSR_DFR 0x80 /* In later manuals: Deferring */
 
 
/** Type definition of the receive header.
*/
typedef struct dp_rcvhdr
{
u8_t dr_status; /* Copy of rsr */
u8_t dr_next; /* Pointer to next packet */
u8_t dr_rbcl; /* Receive Byte Count Low */
u8_t dr_rbch; /* Receive Byte Count High */
/** Copy of rsr.
*/
u8_t dr_status;
/** Pointer to next packet.
*/
u8_t dr_next;
/** Receive Byte Count Low.
*/
u8_t dr_rbcl;
/** Receive Byte Count High.
*/
u8_t dr_rbch;
} dp_rcvhdr_t;
 
/** Page size.
*/
#define DP_PAGESIZE 256
 
/* Some macros to simplify accessing the dp8390 */
/** Reads 1 byte from the zero page register.
* @param[in] dep The network interface structure.
* @param[in] reg The register offset.
* @returns The read value.
*/
#define inb_reg0(dep, reg) (inb(dep->de_dp8390_port+reg))
 
/** Writes 1 byte zero page register.
* @param[in] dep The network interface structure.
* @param[in] reg The register offset.
* @param[in] data The value to be written.
*/
#define outb_reg0(dep, reg, data) (outb(dep->de_dp8390_port+reg, data))
 
/** Reads 1 byte from the first page register.
* @param[in] dep The network interface structure.
* @param[in] reg The register offset.
* @returns The read value.
*/
#define inb_reg1(dep, reg) (inb(dep->de_dp8390_port+reg))
 
/** Writes 1 byte first page register.
* @param[in] dep The network interface structure.
* @param[in] reg The register offset.
* @param[in] data The value to be written.
*/
#define outb_reg1(dep, reg, data) (outb(dep->de_dp8390_port+reg, data))
 
/* Software interface to the dp8390 driver */
274,14 → 310,18
 
typedef struct dpeth
{
/* Packet send queue.
*/
/** Outgoing packets queue.
*/
packet_t packet_queue;
/** Outgoing packets count.
*/
int packet_count;
 
/* Packet receive queue.
*/
/** Received packets queue.
*/
packet_t received_queue;
/** Received packets count.
*/
int received_count;
 
/* The de_base_port field is the starting point of the probe.
/branches/network/uspace/srv/net/netif/dp8390/dp8390_module.c
31,7 → 31,7
*/
 
/** @file
* \todo
* DP8390 network interface implementation.
*/
 
#include <assert.h>
60,11 → 60,22
#include "dp8390_drv.h"
#include "dp8390_port.h"
 
/** DP8390 module name.
*/
#define NAME "dp8390 network interface"
 
/** Returns the device from the interrupt call.
* @param[in] call The interrupt call.
*/
#define IRQ_GET_DEVICE( call ) ( device_id_t ) IPC_GET_METHOD( * call )
 
/** Returns the interrupt status register from the interrupt call.
* @param[in] call The interrupt call.
*/
#define IPC_GET_ISR( call ) ( int ) IPC_GET_ARG2( * call )
 
/** DP8390 kernel interrupt command sequence.
*/
static irq_cmd_t dp8390_cmds[] = {
{ .cmd = CMD_PIO_READ_8,
.addr = NULL,
80,16 → 91,34
}
};
 
/** DP8390 kernel interrupt code.
*/
static irq_code_t dp8390_code = {
sizeof( dp8390_cmds ) / sizeof( irq_cmd_t ),
dp8390_cmds
};
 
/** Network interface module global data.
*/
netif_globals_t netif_globals;
 
/** Prints the module name.
* @see NAME
*/
void module_print_name( void );
 
/** Handles the interrupt messages.
* This is the interrupt handler callback function.
* @param[in] iid The interrupt message identifier.
* @param[in] call The interrupt message.
*/
void irq_handler( ipc_callid_t iid, ipc_call_t * call );
 
/** Changes the network interface state.
* @param[in,out] device The network interface.
* @param[in] state The new state.
* @returns The new state.
*/
int change_state( device_ref device, device_state_t state );
 
int netif_specific_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count ){
/branches/network/uspace/srv/net/netif/lo/lo.c
74,8 → 74,8
netif_globals_t netif_globals;
 
/** Changes the loopback state.
* @param device The device structure. Input parameter.
* @param state The new device state. Input parameter.
* @param[in] device The device structure.
* @param[in] state The new device state.
* @returns The new state if changed.
* @returns EOK otherwise.
*/
82,8 → 82,8
int change_state_message( device_ref device, device_state_t state );
 
/** Creates and returns the loopback network interface structure.
* @param device_id The new devce identifier. Input parameter.
* @param device The device structure. Output parameter.
* @param[in] device_id The new devce identifier.
* @param[out] device The device structure.
* @returns EOK on success.
* @returns EXDEV if one loopback network interface already exists.
* @returns ENOMEM if there is not enough memory left.
/branches/network/uspace/srv/net/netif/netif.h
102,8 → 102,8
};
 
/** Finds the device specific data.
* @param device_id The device identifier. Input parameter.
* @param device The device specific data. Output parameter.
* @param[in] device_id The device identifier.
* @param[out] device The device specific data.
* @returns EOK on success.
* @returns ENOENT if device is not found.
* @returns EPERM if the device is not initialized.
111,18 → 111,18
int find_device( device_id_t device_id, device_ref * device );
 
/** Clears the usage statistics.
* @param stats The usage statistics. Input parameter.
* @param[in] stats The usage statistics.
*/
void null_device_stats( device_stats_ref stats );
 
// prepared for future optimalizations
/** Releases the given packet.
* @param packet_id The packet identifier. Input parameter.
* @param[in] packet_id The packet identifier.
*/
void netif_pq_release( packet_id_t packet_id );
 
/** Allocates new packet to handle the given content size.
* @param content The minimum content size. Input parameter.
* @param[in] content The minimum content size.
* @returns The allocated packet.
* @returns NULL if there is an error.
*/
129,10 → 129,10
packet_t netif_packet_get_1( size_t content );
 
/** Processes the netif module messages.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
143,7 → 143,7
 
/** Initializes the netif module.
* The function has to be defined in each module.
* @param client_connection The client connection functio to be registered. Input parameter.
* @param[in] client_connection The client connection functio to be registered.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module message function.
*/
/branches/network/uspace/srv/net/netif/netif_standalone.c
41,10 → 41,10
#include "netif.h"
 
/** Delegates the messages to the netif_message() function.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
53,7 → 53,7
 
/** Starts the network interface module.
* Initializes the client connection serving function, initializes the module, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
* @param client_connection The client connection processing function. The module skeleton propagates its own one. Input parameter.
* @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module message function.
*/
/branches/network/uspace/srv/net/module.c
51,10 → 51,10
/** External message processing function.
* Should process the messages.
* The function has to be defined in each module.
* @param callid The message identifier. Input parameter.
* @param call The message parameters. Input parameter.
* @param answer The message answer parameters. Output parameter.
* @param answer_count The last parameter for the actual answer in the answer parameter. Output parameter.
* @param[in] callid The message identifier.
* @param[in] call The message parameters.
* @param[out] answer The message answer parameters.
* @param[out] answer_count The last parameter for the actual answer in the answer parameter.
* @returns EOK on success.
* @returns ENOTSUP if the message is not known.
* @returns Other error codes as defined for each specific module message function.
70,7 → 70,7
/** External module startup function.
* Should start and initialize the module and register the given client connection function.
* The function has to be defined in each module.
* @param client_connection The client connection function to be registered. Input parameter.
* @param[in] client_connection The client connection function to be registered.
*/
extern int module_start( async_client_conn_t client_connection );
 
77,8 → 77,8
/*@}*/
 
/** Default thread for new connections.
* @param iid The initial message identifier. Input parameter.
* @param icall The initial message call structure. Input parameter.
* @param[in] iid The initial message identifier.
* @param[in] icall The initial message call structure.
*/
void client_connection( ipc_callid_t iid, ipc_call_t * icall );
 
/branches/network/uspace/srv/net/self_test.c
52,9 → 52,9
#include "self_test.h"
 
/** Tests the function, compares the result and remembers if the result differs.
* @param name The test name. Input parameter.
* @param function_call The function to be called and checked. Input parameter.
* @param result The expected result. Input parameter.
* @param[in] name The test name.
* @param[in] function_call The function to be called and checked.
* @param[in] result The expected result.
*/
#define TEST( name, function_call, result ); { \
printf( "\n\t%s", ( name )); \
/branches/network/uspace/srv/net/err.h
55,7 → 55,7
#define ERROR_DECLARE int ERROR_CODE
 
/** Stores the value as an error code and checks if an error occurred.
* @param value The value to be checked. May be a function call. Input parameter.
* @param[in] value The value to be checked. May be a function call.
* @returns FALSE if the value indicates success (EOK).
* @returns TRUE otherwise.
*/
70,7 → 70,7
#endif
 
/** Checks if an error occurred and immediately exits the actual function returning the error code.
* @param value The value to be checked. May be a function call. Input parameter.
* @param[in] value The value to be checked. May be a function call.
*/
 
#define ERROR_PROPAGATE( value ) if( ERROR_OCCURRED( value )) return ERROR_CODE