iPXE
|
UDP protocol. More...
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <byteswap.h>
#include <errno.h>
#include <ipxe/tcpip.h>
#include <ipxe/iobuf.h>
#include <ipxe/xfer.h>
#include <ipxe/open.h>
#include <ipxe/uri.h>
#include <ipxe/netdevice.h>
#include <ipxe/udp.h>
Go to the source code of this file.
Data Structures | |
struct | udp_connection |
A UDP connection. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static | LIST_HEAD (udp_conns) |
List of registered UDP connections. More... | |
static int | udp_port_available (int port) |
Check if local UDP port is available. More... | |
static int | udp_open_common (struct interface *xfer, struct sockaddr *peer, struct sockaddr *local, int promisc) |
Open a UDP connection. More... | |
int | udp_open (struct interface *xfer, struct sockaddr *peer, struct sockaddr *local) |
Open a UDP connection. More... | |
int | udp_open_promisc (struct interface *xfer) |
Open a promiscuous UDP connection. More... | |
static void | udp_close (struct udp_connection *udp, int rc) |
Close a UDP connection. More... | |
static int | udp_tx (struct udp_connection *udp, struct io_buffer *iobuf, struct sockaddr_tcpip *src, struct sockaddr_tcpip *dest, struct net_device *netdev) |
Transmit data via a UDP connection to a specified address. More... | |
static struct udp_connection * | udp_demux (struct sockaddr_tcpip *local) |
Identify UDP connection by local address. More... | |
static int | udp_rx (struct io_buffer *iobuf, struct net_device *netdev __unused, struct sockaddr_tcpip *st_src, struct sockaddr_tcpip *st_dest, uint16_t pshdr_csum) |
Process a received packet. More... | |
static struct io_buffer * | udp_xfer_alloc_iob (struct udp_connection *udp, size_t len) |
Allocate I/O buffer for UDP. More... | |
static int | udp_xfer_deliver (struct udp_connection *udp, struct io_buffer *iobuf, struct xfer_metadata *meta) |
Deliver datagram as I/O buffer. More... | |
static int | udp_open_uri (struct interface *xfer, struct uri *uri) |
Open UDP URI. More... | |
Variables | |
static struct interface_descriptor | udp_xfer_desc |
UDP data transfer interface descriptor. More... | |
struct tcpip_protocol udp_protocol | __tcpip_protocol |
ICMPv4 TCP/IP protocol. More... | |
static struct interface_operation | udp_xfer_operations [] |
UDP data transfer interface operations. More... | |
struct socket_opener udp_socket_opener | __socket_opener |
UDP socket opener. More... | |
int | udp_sock_dgram = UDP_SOCK_DGRAM |
Linkage hack. More... | |
struct uri_opener udp_uri_opener | __uri_opener |
UDP URI opener. More... | |
UDP protocol.
Definition in file udp.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
List of registered UDP connections.
|
static |
Check if local UDP port is available.
port | Local port number |
port | Local port number, or negative error |
Definition at line 56 of file udp.c.
References EADDRINUSE, htons, udp_connection::list, list_for_each_entry, udp_connection::local, port, and sockaddr_tcpip::st_port.
Referenced by udp_open_common().
|
static |
Open a UDP connection.
xfer | Data transfer interface |
peer | Peer socket address, or NULL |
local | Local socket address, or NULL |
promisc | Socket is promiscuous |
rc | Return status code |
Definition at line 75 of file udp.c.
References DBGC, ENOMEM, htons, intf_init(), intf_plug_plug(), udp_connection::list, list_add, udp_connection::local, memcpy(), ntohs, NULL, peer, udp_connection::peer, port, rc, ref_init, ref_put, udp_connection::refcnt, sockaddr_tcpip::st_port, strerror(), tcpip_bind(), udp_port_available(), udp_xfer_desc, udp_connection::xfer, and zalloc().
Referenced by udp_open(), and udp_open_promisc().
Open a UDP connection.
xfer | Data transfer interface |
peer | Peer socket address |
local | Local socket address, or NULL |
rc | Return status code |
Definition at line 130 of file udp.c.
References udp_connection::local, peer, udp_open_common(), and udp_connection::xfer.
int udp_open_promisc | ( | struct interface * | xfer | ) |
Open a promiscuous UDP connection.
xfer | Data transfer interface |
rc | Return status code |
Promiscuous UDP connections are required in order to support the PXE API.
Definition at line 144 of file udp.c.
References NULL, udp_open_common(), and udp_connection::xfer.
Referenced by efi_pxe_udp_open(), and pxenv_udp_open().
|
static |
Close a UDP connection.
udp | UDP connection |
rc | Reason for close |
Definition at line 154 of file udp.c.
References DBGC, intf_shutdown(), udp_connection::list, list_del, rc, ref_put, udp_connection::refcnt, and udp_connection::xfer.
|
static |
Transmit data via a UDP connection to a specified address.
udp | UDP connection |
iobuf | I/O buffer |
src | Source address, or NULL to use default |
dest | Destination address, or NULL to use default |
netdev | Network device, or NULL to use default |
rc | Return status code |
Definition at line 176 of file udp.c.
References udp_header::chksum, DBGC, DBGC2, udp_header::dest, dest, free_iob(), htons, iob_ensure_headroom(), iob_len(), iob_push, len, udp_header::len, udp_connection::local, MAX_LL_NET_HEADER_LEN, netdev, ntohs, udp_connection::peer, rc, udp_header::src, src, strerror(), tcpip_chksum(), and tcpip_tx().
Referenced by udp_xfer_deliver().
|
static |
Identify UDP connection by local address.
local | Local address |
udp | UDP connection, or NULL |
Definition at line 227 of file udp.c.
References udp_connection::list, list_for_each_entry, udp_connection::local, memcmp(), NULL, sockaddr_tcpip::pad, sockaddr_tcpip::st_family, and sockaddr_tcpip::st_port.
Referenced by udp_rx().
|
static |
Process a received packet.
iobuf | I/O buffer |
netdev | Network device |
st_src | Partially-filled source address |
st_dest | Partially-filled destination address |
pshdr_csum | Pseudo-header checksum |
rc | Return status code |
Definition at line 256 of file udp.c.
References udp_header::chksum, io_buffer::data, DBG, DBGC2, udp_header::dest, done, EINVAL, ENOTCONN, free_iob(), iob_disown, iob_len(), iob_pull, iob_unput, udp_header::len, memset(), meta(), ntohs, rc, udp_header::src, sockaddr_tcpip::st_port, tcpip_continue_chksum(), udp_demux(), udp_connection::xfer, and xfer_deliver().
|
static |
Allocate I/O buffer for UDP.
udp | UDP connection |
len | Payload size |
iobuf | I/O buffer, or NULL |
Definition at line 349 of file udp.c.
References alloc_iob(), DBGC, iob_reserve, len, MAX_LL_NET_HEADER_LEN, and NULL.
|
static |
Open UDP URI.
xfer | Data transfer interface |
uri | URI |
rc | Return status code |
Definition at line 415 of file udp.c.
References EINVAL, uri::host, htons, memset(), NULL, peer, SOCK_DGRAM, uri_port(), and xfer_open_named_socket().
|
static |
UDP data transfer interface descriptor.
Definition at line 47 of file udp.c.
Referenced by udp_open_common().
struct tcpip_protocol udp_protocol __tcpip_protocol |
ICMPv4 TCP/IP protocol.
ICMPv4 TCP/IP protocol.
|
static |
UDP data transfer interface operations.
struct socket_opener udp_socket_opener __socket_opener |
UDP socket opener.
struct uri_opener udp_uri_opener __uri_opener |
UDP URI opener.