User Datagram Protocol (UDP) Service
[Transport layer]


Files

file  udp.c
 UDP module implementation.
file  udp.h
 UDP module.
file  udp_header.h
 UDP header definition.

Data Structures

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

Defines

#define MAX_UDP_FRAGMENT_SIZE   65535
 Maximum UDP fragment size.
#define NAME   "udp"
 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.
#define UDP_FREE_PORTS_START   1025
 Free ports pool start.
#define UDP_HEADER_SIZE   sizeof(udp_header_t)
 UDP header size in bytes.

Typedefs

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

Functions

int main (int argc, char *argv[])
 Main entry point.
void tl_connection (void)
 Per-connection module initialization.
int tl_initialize (int net_phone)
 Module initialization.
int tl_message (ipc_callid_t callid, ipc_call_t *call, ipc_call_t *answer, size_t *answer_count)
 Process the transport layer module message.
static int udp_process_client_messages (ipc_callid_t callid, ipc_call_t call)
 Processes the socket client messages.
static int udp_process_packet (device_id_t device_id, packet_t *packet, services_t error)
 Processes the received UDP packet queue.
static int udp_received_msg (device_id_t device_id, packet_t *packet, services_t receiver, services_t error)
 Processes the received UDP packet queue.
static void udp_receiver (ipc_callid_t iid, ipc_call_t *icall)
 Process IPC messages from the IP module.
static int udp_recvfrom_message (socket_cores_t *local_sockets, int socket_id, int flags, size_t *addrlen)
 Receives data to the socket.
static int udp_release_and_return (packet_t *packet, int result)
 Releases the packet and returns the result.
static int udp_sendto_message (socket_cores_t *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.

Variables

udp_globals_t udp_globals
 UDP global data.

Typedef Documentation

typedef struct udp_globals udp_globals_t

Type definition of the UDP global data.

See also:
udp_globals

Definition at line 47 of file udp.h.

typedef struct udp_header udp_header_t

Type definition of the user datagram header.

See also:
udp_header

Definition at line 49 of file udp_header.h.


Function Documentation

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

Main entry point.

Parameters:
[in] argc Nmber of arguments in argv vector (ignored).
[in] argv Cmdline argument vector (ignored).
Returns:
Error code.
Driver debug level is set here.

Definition at line 924 of file udp.c.

void tl_connection ( void   ) 

Per-connection module initialization.

Initialize client-specific global variables.

Definition at line 894 of file udp.c.

int tl_initialize ( int  net_phone  ) 

Module initialization.

Parameters:
[in] net_phone Network module phone.
Returns:
EOK on success.

ENOMEM if there is not enough memory left.

Definition at line 373 of file udp.c.

int tl_message ( ipc_callid_t  callid,
ipc_call_t call,
ipc_call_t answer,
size_t answer_count 
)

Process the transport layer module 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()

Definition at line 911 of file udp.c.

static int udp_process_client_messages ( ipc_callid_t  callid,
ipc_call_t  call 
) [static]

Processes the socket client messages.

Runs until the client module disconnects.

Parameters:
[in] callid The message identifier.
[in] call The message parameters.
Returns:
EOK on success.
See also:
socket.h

Definition at line 747 of file udp.c.

static int udp_process_packet ( device_id_t  device_id,
packet_t packet,
services_t  error 
) [static]

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.

Definition at line 126 of file udp.c.

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

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.

Definition at line 322 of file udp.c.

static void udp_receiver ( ipc_callid_t  iid,
ipc_call_t icall 
) [static]

Process IPC messages from the IP module.

Parameters:
[in] iid Message identifier.
[in,out] icall Message parameters.

Definition at line 341 of file udp.c.

static int udp_recvfrom_message ( socket_cores_t *  local_sockets,
int  socket_id,
int  flags,
size_t addrlen 
) [static]

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.

Definition at line 654 of file udp.c.

static int udp_release_and_return ( packet_t packet,
int  result 
) [static]

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.

Definition at line 99 of file udp.c.

static int udp_sendto_message ( socket_cores_t *  local_sockets,
int  socket_id,
const struct sockaddr addr,
socklen_t  addrlen,
int  fragments,
size_t data_fragment_size,
int  flags 
) [static]

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.

Definition at line 484 of file udp.c.


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