iPXE
|
PXE UDP API. More...
#include <string.h>
#include <byteswap.h>
#include <ipxe/iobuf.h>
#include <ipxe/xfer.h>
#include <ipxe/udp.h>
#include <ipxe/uaccess.h>
#include <ipxe/process.h>
#include <ipxe/netdevice.h>
#include <ipxe/malloc.h>
#include <realmode.h>
#include <pxe.h>
Go to the source code of this file.
Data Structures | |
struct | pxe_udp_pseudo_header |
A PXE UDP pseudo-header. More... | |
struct | pxe_udp_connection |
A PXE UDP connection. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static int | pxe_udp_deliver (struct pxe_udp_connection *pxe_udp, struct io_buffer *iobuf, struct xfer_metadata *meta) |
Receive PXE UDP data. More... | |
static PXENV_EXIT_t | pxenv_udp_open (struct s_PXENV_UDP_OPEN *pxenv_udp_open) |
UDP OPEN. More... | |
static PXENV_EXIT_t | pxenv_udp_close (struct s_PXENV_UDP_CLOSE *pxenv_udp_close) |
UDP CLOSE. More... | |
static PXENV_EXIT_t | pxenv_udp_write (struct s_PXENV_UDP_WRITE *pxenv_udp_write) |
UDP WRITE. More... | |
static PXENV_EXIT_t | pxenv_udp_read (struct s_PXENV_UDP_READ *pxenv_udp_read) |
UDP READ. More... | |
static unsigned int | pxe_udp_discard (void) |
Discard some cached PXE UDP data. More... | |
struct cache_discarder pxe_udp_discarder | __cache_discarder (CACHE_NORMAL) |
PXE UDP cache discarder. More... | |
Variables | |
static struct interface_operation | pxe_udp_xfer_operations [] |
PXE UDP data transfer interface operations. More... | |
static struct interface_descriptor | pxe_udp_xfer_desc |
PXE UDP data transfer interface descriptor. More... | |
static struct pxe_udp_connection | pxe_udp |
The PXE UDP connection. More... | |
struct pxe_api_call pxe_udp_api [] | __pxe_api_call |
PXE UDP API. More... | |
PXE UDP API.
Definition in file pxe_udp.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Receive PXE UDP data.
pxe_udp | PXE UDP connection |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Receives a packet as part of the current pxenv_udp_read() operation.
Definition at line 77 of file pxe_udp.c.
References AF_INET, assert(), pxe_udp_pseudo_header::d_port, DBG, pxe_udp_pseudo_header::dest_ip, ENOMEM, free_iob(), iob_ensure_headroom(), iob_push, pxe_udp_connection::list, io_buffer::list, list_add_tail, meta(), pxe_udp, rc, in_addr::s_addr, pxe_udp_pseudo_header::s_port, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, and pxe_udp_pseudo_header::src_ip.
|
static |
UDP OPEN.
pxenv_udp_open | Pointer to a struct s_PXENV_UDP_OPEN |
s_PXENV_UDP_OPEN::src_ip | IP address of this station, or 0.0.0.0 |
PXENV_EXIT_SUCCESS | Always |
s_PXENV_UDP_OPEN::Status | PXE status code |
PXENV_STATUS_UDP_OPEN | UDP connection already open |
PXENV_STATUS_OUT_OF_RESOURCES | Could not open connection |
Prepares the PXE stack for communication using pxenv_udp_write() and pxenv_udp_read().
The IP address supplied in s_PXENV_UDP_OPEN::src_ip will be recorded and used as the local station's IP address for all further communication, including communication by means other than pxenv_udp_write() and pxenv_udp_read(). (If s_PXENV_UDP_OPEN::src_ip is 0.0.0.0, the local station's IP address will remain unchanged.)
You can only have one open UDP connection at a time. This is not a meaningful restriction, since pxenv_udp_write() and pxenv_udp_read() allow you to specify arbitrary local and remote ports and an arbitrary remote address for each packet. According to the PXE specifiation, you cannot have a UDP connection open at the same time as a TFTP connection; this restriction does not apply to Etherboot.
On x86, you must set the s_PXE::StatusCallout field to a nonzero value before calling this function in protected mode. You cannot call this function with a 32-bit stack segment. (See the relevant implementation note for more details.)
Definition at line 176 of file pxe_udp.c.
References DBG, inet_ntoa(), intf_restart(), pxe_udp_connection::local, net_device::name, netdev_is_open(), netdev_open(), pxe_netdev, pxe_udp, PXENV_EXIT_FAILURE, PXENV_EXIT_SUCCESS, PXENV_STATUS, PXENV_STATUS_SUCCESS, rc, in_addr::s_addr, sockaddr_in::sin_addr, strerror(), udp_open_promisc(), and pxe_udp_connection::xfer.
|
static |
UDP CLOSE.
pxenv_udp_close | Pointer to a struct s_PXENV_UDP_CLOSE |
PXENV_EXIT_SUCCESS | Always |
s_PXENV_UDP_CLOSE::Status | PXE status code |
None | - |
Closes a UDP connection opened with pxenv_udp_open().
You can only have one open UDP connection at a time. You cannot have a UDP connection open at the same time as a TFTP connection. You cannot use pxenv_udp_close() to close a TFTP connection; use pxenv_tftp_close() instead.
On x86, you must set the s_PXE::StatusCallout field to a nonzero value before calling this function in protected mode. You cannot call this function with a 32-bit stack segment. (See the relevant implementation note for more details.)
Definition at line 229 of file pxe_udp.c.
References DBG, free_iob(), intf_restart(), pxe_udp_connection::list, io_buffer::list, list_del, list_for_each_entry_safe, pxe_udp, PXENV_EXIT_SUCCESS, PXENV_STATUS_SUCCESS, tmp, and pxe_udp_connection::xfer.
|
static |
UDP WRITE.
pxenv_udp_write | Pointer to a struct s_PXENV_UDP_WRITE |
s_PXENV_UDP_WRITE::ip | Destination IP address |
s_PXENV_UDP_WRITE::gw | Relay agent IP address, or 0.0.0.0 |
s_PXENV_UDP_WRITE::src_port | Source UDP port, or 0 |
s_PXENV_UDP_WRITE::dst_port | Destination UDP port |
s_PXENV_UDP_WRITE::buffer_size | Length of the UDP payload |
s_PXENV_UDP_WRITE::buffer | Address of the UDP payload |
PXENV_EXIT_SUCCESS | Packet was transmitted successfully |
PXENV_EXIT_FAILURE | Packet could not be transmitted |
s_PXENV_UDP_WRITE::Status | PXE status code |
PXENV_STATUS_UDP_CLOSED | UDP connection is not open |
PXENV_STATUS_UNDI_TRANSMIT_ERROR | Could not transmit packet |
Transmits a single UDP packet. A valid IP and UDP header will be prepended to the payload in s_PXENV_UDP_WRITE::buffer; the buffer should not contain precomputed IP and UDP headers, nor should it contain space allocated for these headers. The first byte of the buffer will be transmitted as the first byte following the UDP header.
If s_PXENV_UDP_WRITE::gw is 0.0.0.0, normal IP routing will take place. See the relevant implementation note for more details.
If s_PXENV_UDP_WRITE::src_port is 0, port 2069 will be used.
You must have opened a UDP connection with pxenv_udp_open() before calling pxenv_udp_write().
On x86, you must set the s_PXE::StatusCallout field to a nonzero value before calling this function in protected mode. You cannot call this function with a 32-bit stack segment. (See the relevant implementation note for more details.)
Definition at line 290 of file pxe_udp.c.
References AF_INET, buffer, copy_from_user(), DBG, dest, htons, inet_ntoa(), iob_put, len, pxe_udp_connection::local, memset(), meta(), ntohs, pxe_netdev, pxe_udp, PXENV_EXIT_FAILURE, PXENV_EXIT_SUCCESS, PXENV_STATUS, PXENV_STATUS_OUT_OF_RESOURCES, PXENV_STATUS_SUCCESS, rc, real_to_user(), sockaddr_in::sin_port, strerror(), pxe_udp_connection::xfer, xfer_alloc_iob(), and xfer_deliver().
|
static |
UDP READ.
pxenv_udp_read | Pointer to a struct s_PXENV_UDP_READ |
s_PXENV_UDP_READ::dest_ip | Destination IP address, or 0.0.0.0 |
s_PXENV_UDP_READ::d_port | Destination UDP port, or 0 |
s_PXENV_UDP_READ::buffer_size | Size of the UDP payload buffer |
s_PXENV_UDP_READ::buffer | Address of the UDP payload buffer |
PXENV_EXIT_SUCCESS | A packet has been received |
PXENV_EXIT_FAILURE | No packet has been received |
s_PXENV_UDP_READ::Status | PXE status code |
s_PXENV_UDP_READ::src_ip | Source IP address |
s_PXENV_UDP_READ::dest_ip | Destination IP address |
s_PXENV_UDP_READ::s_port | Source UDP port |
s_PXENV_UDP_READ::d_port | Destination UDP port |
s_PXENV_UDP_READ::buffer_size | Length of UDP payload |
PXENV_STATUS_UDP_CLOSED | UDP connection is not open |
PXENV_STATUS_FAILURE | No packet was ready to read |
Receive a single UDP packet. This is a non-blocking call; if no packet is ready to read, the call will return instantly with s_PXENV_UDP_READ::Status==PXENV_STATUS_FAILURE.
If s_PXENV_UDP_READ::dest_ip is 0.0.0.0, UDP packets addressed to any IP address will be accepted and may be returned to the caller.
If s_PXENV_UDP_READ::d_port is 0, UDP packets addressed to any UDP port will be accepted and may be returned to the caller.
You must have opened a UDP connection with pxenv_udp_open() before calling pxenv_udp_read().
On x86, you must set the s_PXE::StatusCallout field to a nonzero value before calling this function in protected mode. You cannot call this function with a 32-bit stack segment. (See the relevant implementation note for more details.)
Definition at line 396 of file pxe_udp.c.
References assert(), buffer, copy_to_user(), pxe_udp_pseudo_header::d_port, d_port, io_buffer::data, DBG, DBG2, pxe_udp_pseudo_header::dest_ip, dest_ip, free_iob(), htons, inet_ntoa(), iob_len(), iob_pull, len, pxe_udp_connection::list, io_buffer::list, list_del, list_empty, list_first_entry, ntohs, pxe_udp, PXENV_EXIT_FAILURE, PXENV_EXIT_SUCCESS, PXENV_STATUS_FAILURE, PXENV_STATUS_SUCCESS, real_to_user(), in_addr::s_addr, pxe_udp_pseudo_header::s_port, pxe_udp_pseudo_header::src_ip, and step().
|
static |
Discard some cached PXE UDP data.
discarded | Number of cached items discarded |
Definition at line 492 of file pxe_udp.c.
References free_iob(), pxe_udp_connection::list, io_buffer::list, list_del, list_first_entry, and pxe_udp.
struct cache_discarder pxe_udp_discarder __cache_discarder | ( | CACHE_NORMAL | ) |
PXE UDP cache discarder.
|
static |
PXE UDP data transfer interface operations.
|
static |
PXE UDP data transfer interface descriptor.
|
static |
The PXE UDP connection.
Definition at line 126 of file pxe_udp.c.
Referenced by pxe_udp_deliver(), pxe_udp_discard(), pxenv_udp_close(), pxenv_udp_open(), pxenv_udp_read(), and pxenv_udp_write().
struct pxe_api_call pxe_udp_api [] __pxe_api_call |
PXE UDP API.