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 struct udp_globals udp_globals_t |
typedef struct udp_header udp_header_t |
Type definition of the user datagram header.
Definition at line 49 of file udp_header.h.
int main | ( | int | argc, | |
char * | argv[] | |||
) |
void tl_connection | ( | void | ) |
int tl_initialize | ( | int | net_phone | ) |
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.
[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. |
ENOTSUP if the message is not known.
static int udp_process_client_messages | ( | ipc_callid_t | callid, | |
ipc_call_t | call | |||
) | [static] |
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.
[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. |
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.
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.
[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. |
Other error codes as defined for the udp_process_packet() function.
static void udp_receiver | ( | ipc_callid_t | iid, | |
ipc_call_t * | icall | |||
) | [static] |
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.
[in] | local_sockets | The application local sockets. |
[in] | socket_id | Socket identifier. |
[in] | flags | Various receive flags. |
[out] | addrlen | The source address length. |
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.
static int udp_release_and_return | ( | packet_t * | packet, | |
int | result | |||
) | [static] |
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.
[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. |
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.