User Datagram Protocol (UDP) Service
[Transport layer]

Collaboration diagram for User Datagram Protocol (UDP) Service:

Data Structures

struct  udp_globals
 UDP global data. More...
struct  udp_header
 User datagram header. More...

Files

file  udp.c
 

UDP module implementation.


file  udp.h
 

UDP module.


file  udp_header.h
 

UDP header definition.


file  udp_module.c
 

UDP standalone module implementation.


file  udp_module.h
 

UDP module functions.


Defines

#define NET_DEFAULT_UDP_CHECKSUM_COMPUTING   true
 Default UDP checksum computing.
#define NET_DEFAULT_UDP_AUTOBINDING   true
 Default UDP autobind when sending via unbound sockets.
#define MAX_UDP_FRAGMENT_SIZE   65535
 Maximum UDP fragment size.
#define UDP_FREE_PORTS_START   1025
 Free ports pool start.
#define UDP_FREE_PORTS_END   65535
 Free ports pool end.
#define UDP_HEADER_SIZE   sizeof(udp_header_t)
 UDP header size in bytes.
#define NAME   "UDP protocol"
 UDP module name.

Typedefs

typedef struct udp_globals udp_globals_t
 Type definition of the UDP global data.
typedef struct udp_header udp_header_t
 Type definition of the user datagram header.
typedef udp_header_tudp_header_ref
 Type definition of the user datagram header pointer.

Functions

int udp_received_msg (device_id_t device_id, packet_t packet, services_t receiver, services_t error)
 Processes the received UDP packet queue.
int udp_process_packet (device_id_t device_id, packet_t packet, services_t error)
 Processes the received UDP packet queue.
int udp_release_and_return (packet_t packet, int result)
 Releases the packet and returns the result.
int udp_initialize (async_client_conn_t client_connection)
 Initializes the UDP module.
int udp_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, int *answer_count)
 Processes the UDP message.
void module_print_name (void)
 Prints the module name.
int module_start (async_client_conn_t client_connection)
 Starts the UDP module.
int module_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, int *answer_count)
 Processes the UDP message.

Variables

udp_globals_t udp_globals
 UDP global data.
udp_globals_t udp_globals
 UDP module global data.

Socket messages processing functions



int udp_process_client_messages (ipc_callid_t callid, ipc_call_t call)
 Processes the socket client messages.
int udp_sendto_message (socket_cores_ref local_sockets, int socket_id, const struct sockaddr *addr, socklen_t addrlen, int fragments, size_t *data_fragment_size, int flags)
 Sends data from the socket to the remote address.
int udp_recvfrom_message (socket_cores_ref local_sockets, int socket_id, int flags, size_t *addrlen)
 Receives data to the socket.

Define Documentation

#define MAX_UDP_FRAGMENT_SIZE   65535

Maximum UDP fragment size.

#define NAME   "UDP protocol"

UDP module name.

#define NET_DEFAULT_UDP_AUTOBINDING   true

Default UDP autobind when sending via unbound sockets.

#define NET_DEFAULT_UDP_CHECKSUM_COMPUTING   true

Default UDP checksum computing.

#define UDP_FREE_PORTS_END   65535

Free ports pool end.

Referenced by udp_process_client_messages(), and udp_sendto_message().

#define UDP_FREE_PORTS_START   1025

Free ports pool start.

Referenced by udp_process_client_messages(), and udp_sendto_message().

#define UDP_HEADER_SIZE   sizeof(udp_header_t)

Typedef Documentation

typedef struct udp_globals udp_globals_t

Type definition of the UDP global data.

See also:
udp_globals

Type definition of the user datagram header pointer.

See also:
udp_header
typedef struct udp_header udp_header_t

Type definition of the user datagram header.

See also:
udp_header

Function Documentation

int module_message ( ipc_callid_t  callid,
ipc_call_t *  call,
ipc_call_t *  answer,
int *  answer_count 
)

Processes the UDP message.

Parameters:
[in] callid The message identifier.
[in] call The message parameters.
[out] answer The message answer parameters.
[out] answer_count The last parameter for the actual answer in the answer parameter.
Returns:
EOK on success.
Other error codes as defined for the udp_message() function.

References udp_message().

Here is the call graph for this function:

void module_print_name ( void   ) 

Prints the module name.

See also:
NAME

References NAME.

int module_start ( async_client_conn_t  client_connection  ) 

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.

Parameters:
[in] client_connection The client connection processing function. The module skeleton propagates its own one.
Returns:
EOK on successful module termination.
Other error codes as defined for the udp_initialize() function.
Other error codes as defined for the REGISTER_ME() macro function.

References ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, ERROR_PROPAGATE, net_connect_module(), udp_globals::net_phone, pm_destroy(), pm_init(), REGISTER_ME, and udp_initialize().

Here is the call graph for this function:

int udp_initialize ( async_client_conn_t  client_connection  ) 

Initializes the UDP module.

Parameters:
[in] client_connection The client connection processing function. The module skeleton propagates its own one.
Returns:
EOK on success.
ENOMEM if there is not enough memory left.

Referenced by module_start().

Here is the caller graph for this function:

int udp_message ( ipc_callid_t  callid,
ipc_call_t *  call,
ipc_call_t *  answer,
int *  answer_count 
)

Processes the UDP message.

Parameters:
[in] callid The message identifier.
[in] call The message parameters.
[out] answer The message answer parameters.
[out] answer_count The last parameter for the actual answer in the answer parameter.
Returns:
EOK on success.
ENOTSUP if the message is not known.
See also:
udp_interface.h
IS_NET_UDP_MESSAGE()

Referenced by module_message().

Here is the caller graph for this function:

int udp_process_client_messages ( ipc_callid_t  callid,
ipc_call_t  call 
)
int udp_process_packet ( device_id_t  device_id,
packet_t  packet,
services_t  error 
)

Processes the received UDP packet queue.

Notifies the destination socket application. Releases the packet on error or sends an ICMP error notification..

Parameters:
[in] device_id The receiving device identifier.
[in,out] packet The received packet queue.
[in] error The packet error reporting service. Prefixes the received packet.
Returns:
EOK on success.
EINVAL if the packet is not valid.
EINVAL if the stored packet address is not the an_addr_t.
EINVAL if the packet does not contain any data.
NO_DATA if the packet content is shorter than the user datagram header.
ENOMEM if there is not enough memory left.
EADDRNOTAVAIL if the destination socket does not exist.
Other error codes as defined for the ip_client_process_packet() function.

References udp_header::checksum, compact_checksum(), compute_checksum(), packet_dimension::content, udp_header::destination_port, udp_globals::dimensions, dyn_fifo_push(), ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, flip_checksum(), free, icmp_client_process_packet(), icmp_destination_unreachable_msg(), ICMP_PARAM_POINTER, icmp_parameter_problem_msg(), udp_globals::icmp_phone, ICMP_PORT_UNREACH, IP_CHECKSUM_ZERO, ip_client_get_pseudo_header(), ip_client_process_packet(), udp_globals::ip_phone, IPPROTO_UDP, udp_globals::lock, udp_globals::net_phone, NET_SOCKET_RECEIVED, NO_DATA, ntohs, packet_get_addr(), packet_get_data(), packet_get_data_length(), packet_get_id(), packet_trim(), socket_core::phone, pq_detach(), pq_next(), pq_release(), socket_core::received, socket_core::socket_id, SOCKET_MAP_KEY_LISTENING, SOCKET_MAX_RECEIVED_SIZE, socket_port_find(), udp_globals::sockets, tl_get_ip_packet_dimension(), tl_prepare_icmp_packet(), udp_header::total_length, UDP_HEADER_SIZE, and udp_release_and_return().

Referenced by udp_received_msg().

Here is the call graph for this function:

Here is the caller graph for this function:

int udp_received_msg ( device_id_t  device_id,
packet_t  packet,
services_t  receiver,
services_t  error 
)

Processes the received UDP packet queue.

Is used as an entry point from the underlying IP module. Locks the global lock and calls udp_process_packet() function.

Parameters:
[in] device_id The receiving device identifier.
[in,out] packet The received packet queue.
receiver The target service. Ignored parameter.
[in] error The packet error reporting service. Prefixes the received packet.
Returns:
EOK on success.
Other error codes as defined for the udp_process_packet() function.

References udp_globals::lock, and udp_process_packet().

Here is the call graph for this function:

int udp_recvfrom_message ( socket_cores_ref  local_sockets,
int  socket_id,
int  flags,
size_t *  addrlen 
)

Receives data to the socket.

Handles the NET_SOCKET_RECVFROM message. Replies the source address as well.

Parameters:
[in] local_sockets The application local sockets.
[in] socket_id Socket identifier.
[in] flags Various receive flags.
[out] addrlen The source address length.
Returns:
The number of bytes received.
ENOTSOCK if the socket is not found.
NO_DATA if there are no received packets or data.
ENOMEM if there is not enough memory left.
EINVAL if the received address is not an IP address.
Other error codes as defined for the packet_translate() function.
Other error codes as defined for the data_reply() function.

References data_reply(), dyn_fifo_pop(), dyn_fifo_value(), ENOTSOCK, ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, ERROR_PROPAGATE, udp_globals::net_phone, NO_DATA, ntohs, packet_get_addr(), packet_get_data(), packet_get_id(), packet_translate(), packet_trim(), pq_release(), socket_core::received, socket_reply_packets(), udp_header::source_port, tl_set_address_port(), and UDP_HEADER_SIZE.

Referenced by udp_process_client_messages().

Here is the call graph for this function:

Here is the caller graph for this function:

int udp_release_and_return ( packet_t  packet,
int  result 
)

Releases the packet and returns the result.

Parameters:
[in] packet The packet queue to be released.
[in] result The result to be returned.
Returns:
The result parameter.

References udp_globals::net_phone, packet_get_id(), and pq_release().

Referenced by udp_process_packet(), and udp_sendto_message().

Here is the call graph for this function:

Here is the caller graph for this function:

int udp_sendto_message ( socket_cores_ref  local_sockets,
int  socket_id,
const struct sockaddr addr,
socklen_t  addrlen,
int  fragments,
size_t *  data_fragment_size,
int  flags 
)

Sends data from the socket to the remote address.

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.

Parameters:
[in,out] local_sockets The application local sockets.
[in] socket_id Socket identifier.
[in] addr The destination address.
[in] addrlen The address length.
[in] fragments The number of data fragments.
[out] data_fragment_size The data fragment size in bytes.
[in] flags Various send flags.
Returns:
EOK on success.
EAFNOTSUPPORT if the address family is not supported.
ENOTSOCK if the socket is not found.
EINVAL if the address is invalid.
ENOTCONN if the sending socket is not and cannot be bound.
ENOMEM if there is not enough memory left.
Other error codes as defined for the socket_read_packet_data() function.
Other error codes as defined for the ip_client_prepare_packet() function.
Other error codes as defined for the ip_send_msg() function.

References udp_globals::autobinding, udp_header::checksum, udp_globals::checksum_computing, compact_checksum(), compute_checksum(), udp_header::destination_port, DEVICE_INVALID_ID, ENOTSOCK, ERROR_CODE, ERROR_DECLARE, ERROR_OCCURRED, ERROR_PROPAGATE, flip_checksum(), free, htons, ip_client_prepare_packet(), ip_client_set_pseudo_header_data_length(), ip_get_route_req(), ip_packet_size_req(), udp_globals::ip_phone, ip_send_msg(), IPPROTO_UDP, udp_globals::last_used_port, udp_globals::lock, udp_globals::net_phone, udp_globals::packet_dimension, packet_get_data(), packet_get_data_length(), PACKET_PREFIX, socket_core::port, pq_add(), socket_bind_free_port(), udp_globals::sockets, udp_header::source_port, tl_get_address_port(), tl_socket_read_packet_data(), udp_header::total_length, UDP_FREE_PORTS_END, UDP_FREE_PORTS_START, UDP_HEADER_SIZE, and udp_release_and_return().

Referenced by udp_process_client_messages().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

UDP module global data.

UDP global data.

UDP module global data.


Generated on Thu Mar 11 20:47:16 2010 for Networking and TCP/IP stack for HelenOS system by  doxygen 1.6.1