Macros | |
#define | UIP_IP_BUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN]) |
Functions | |
static void | init (void) |
PROCESS (udp_socket_process,"UDP socket process") | |
PROCESS_THREAD (udp_socket_process, ev, data) | |
int | udp_socket_bind (struct udp_socket *c, uint16_t local_port) |
Bind a UDP socket to a local port. More... | |
int | udp_socket_close (struct udp_socket *c) |
Close a UDP socket. More... | |
int | udp_socket_connect (struct udp_socket *c, uip_ipaddr_t *remote_addr, uint16_t remote_port) |
Bind a UDP socket to a remote address and port. More... | |
int | udp_socket_register (struct udp_socket *c, void *ptr, udp_socket_input_callback_t input_callback) |
Register a UDP socket. More... | |
int | udp_socket_send (struct udp_socket *c, const void *data, uint16_t datalen) |
Send data on a UDP socket. More... | |
int | udp_socket_sendto (struct udp_socket *c, const void *data, uint16_t datalen, const uip_ipaddr_t *to, uint16_t port) |
Send data on a UDP socket to a specific address and port. More... | |
Variables | |
static uint8_t | buf [UIP_BUFSIZE] |
#define UIP_IP_BUF ((struct uip_udpip_hdr *)&uip_buf[UIP_LLH_LEN]) |
Referenced by PROCESS_THREAD().
|
static |
References inited, NULL, and process_start().
PROCESS_THREAD | ( | udp_socket_process | , |
ev | , | ||
data | |||
) |
int udp_socket_bind | ( | struct udp_socket * | c, |
uint16_t | local_port | ||
) |
Bind a UDP socket to a local port.
c | A pointer to the struct udp_socket that should be bound to a local port |
local_port | The UDP port number, in host byte order, to bind the UDP socket to |
-1 | Binding the UDP socket to the local port failed |
1 | Binding the UDP socket to the local port succeeded This function binds the UDP socket to a local port so that it will begin to receive data that arrives on the specified port. A UDP socket will receive data addressed to the specified port number on any IP address of the host. A UDP socket that is bound to a local port will use this port number as a source port in outgoing UDP messages. |
References NULL, udp_bind, udp_socket::udp_conn, and UIP_HTONS.
Referenced by httpd_init().
int udp_socket_close | ( | struct udp_socket * | c | ) |
Close a UDP socket.
c | A pointer to the struct udp_socket to be closed |
-1 | If closing the UDP socket failed |
1 | If closing the UDP socket succeeded This function closes a UDP socket that has previously been registered with udp_socket_register(). All registered UDP sockets must be closed before exiting the process that registered them, or undefined behavior may occur. |
References NULL, udp_socket::udp_conn, and uip_udp_remove.
int udp_socket_connect | ( | struct udp_socket * | c, |
uip_ipaddr_t * | remote_addr, | ||
uint16_t | remote_port | ||
) |
Bind a UDP socket to a remote address and port.
c | A pointer to the struct udp_socket that should be connected |
remote_addr | The IP address of the remote host, or NULL if the UDP socket should only be connected to a specific port |
remote_port | The UDP port number, in host byte order, to which the UDP socket should be connected |
-1 | Connecting the UDP socket failed |
1 | Connecting the UDP socket succeeded This function connects the UDP socket to a specific remote port and optional remote IP address. When a UDP socket is connected to a remote port and address, it will only receive packets that are sent from the remote port and address. When sending data over a connected UDP socket, the data will be sent to the connected remote address. A UDP socket can be connected to a remote port, but not a remote IP address, by providing a NULL parameter as the remote_addr parameter. This lets the UDP socket receive data from any IP address on the specified port. |
References NULL, uip_udp_conn::ripaddr, uip_udp_conn::rport, udp_socket::udp_conn, UIP_HTONS, and uip_ipaddr_copy.
int udp_socket_register | ( | struct udp_socket * | c, |
void * | ptr, | ||
udp_socket_input_callback_t | receive_callback | ||
) |
Register a UDP socket.
c | A pointer to the struct udp_socket that should be registered |
ptr | An opaque pointer that will be passed to callbacks |
receive_callback | A function pointer to the callback function that will be called when data arrives |
-1 | The registration failed |
1 | The registration succeeded This function registers the UDP socket with the system. A UDP socket must be registered before any data can be sent or received over the socket. The caller must allocate memory for the struct udp_socket that is to be registered. A UDP socket can begin to receive data by calling udp_socket_bind(). |
References init, udp_socket::input_callback, input_callback, NULL, udp_socket::p, PROCESS_CONTEXT_BEGIN, PROCESS_CONTEXT_END, PROCESS_CURRENT, udp_socket::ptr, ptr, udp_socket::udp_conn, and udp_new().
Referenced by httpd_init().
int udp_socket_send | ( | struct udp_socket * | c, |
const void * | data, | ||
uint16_t | datalen | ||
) |
Send data on a UDP socket.
c | A pointer to the struct udp_socket on which the data should be sent |
data | A pointer to the data that should be sent |
datalen | The length of the data to be sent |
This function sends data over a UDP socket. The UDP socket must have been connected to a remote address and port with udp_socket_connect().
References NULL, udp_socket::udp_conn, and uip_udp_packet_send().
int udp_socket_sendto | ( | struct udp_socket * | c, |
const void * | data, | ||
uint16_t | datalen, | ||
const uip_ipaddr_t * | addr, | ||
uint16_t | port | ||
) |
Send data on a UDP socket to a specific address and port.
c | A pointer to the struct udp_socket on which the data should be sent |
data | A pointer to the data that should be sent |
datalen | The length of the data to be sent |
addr | The IP address to which the data should be sent |
port | The UDP port number, in host byte order, to which the data should be sent |
This function sends data over a UDP socket to a specific address and port. The UDP socket does not have to be connected to use this function.
References NULL, udp_socket::udp_conn, UIP_HTONS, and uip_udp_packet_sendto().
|
static |