iPXE
|
Scalable Local Area Multicast protocol. More...
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <assert.h>
#include <byteswap.h>
#include <ipxe/features.h>
#include <ipxe/iobuf.h>
#include <ipxe/bitmap.h>
#include <ipxe/xfer.h>
#include <ipxe/open.h>
#include <ipxe/uri.h>
#include <ipxe/tcpip.h>
#include <ipxe/timer.h>
#include <ipxe/retry.h>
Go to the source code of this file.
Data Structures | |
struct | slam_request |
A SLAM request. More... | |
Macros | |
#define | SLAM_DEFAULT_PORT 10000 |
Default SLAM server port. More... | |
#define | SLAM_DEFAULT_MULTICAST_IP ( ( 239 << 24 ) | ( 255 << 16 ) | ( 1 << 8 ) | ( 1 << 0 ) ) |
Default SLAM multicast IP address. More... | |
#define | SLAM_DEFAULT_MULTICAST_PORT 10000 |
Default SLAM multicast port. More... | |
#define | SLAM_MAX_HEADER_LEN |
Maximum SLAM header length. More... | |
#define | SLAM_MAX_BLOCKS_PER_NACK 4 |
Maximum number of blocks to request per NACK. More... | |
#define | SLAM_MAX_NACK_LEN ( 7 /* block */ + 7 /* #blocks */ + 1 /* NUL */ ) |
Maximum SLAM NACK length. More... | |
#define | SLAM_SLAVE_TIMEOUT ( 1 * TICKS_PER_SEC ) |
SLAM slave timeout. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
FEATURE (FEATURE_PROTOCOL, "SLAM", DHCP_EB_FEATURE_SLAM, 1) | |
static void | slam_free (struct refcnt *refcnt) |
Free a SLAM request. More... | |
static void | slam_finished (struct slam_request *slam, int rc) |
Mark SLAM request as complete. More... | |
static int | slam_put_value (struct slam_request *slam, struct io_buffer *iobuf, unsigned long value) |
Add a variable-length value to a SLAM packet. More... | |
static int | slam_tx_nack (struct slam_request *slam) |
Send SLAM NACK packet. More... | |
static void | slam_master_timer_expired (struct retry_timer *timer, int fail) |
Handle SLAM master client retry timer expiry. More... | |
static void | slam_slave_timer_expired (struct retry_timer *timer, int fail) |
Handle SLAM slave client retry timer expiry. More... | |
static int | slam_pull_value (struct slam_request *slam, struct io_buffer *iobuf, unsigned long *value) |
Read and strip a variable-length value from a SLAM packet. More... | |
static int | slam_pull_header (struct slam_request *slam, struct io_buffer *iobuf) |
Read and strip SLAM header. More... | |
static int | slam_mc_socket_deliver (struct slam_request *slam, struct io_buffer *iobuf, struct xfer_metadata *rx_meta __unused) |
Receive SLAM data packet. More... | |
static int | slam_socket_deliver (struct slam_request *slam, struct io_buffer *iobuf, struct xfer_metadata *rx_meta __unused) |
Receive SLAM non-data packet. More... | |
static int | slam_parse_multicast_address (struct slam_request *slam, const char *path, struct sockaddr_tcpip *address) |
Parse SLAM URI multicast address. More... | |
static int | slam_open (struct interface *xfer, struct uri *uri) |
Initiate a SLAM request. More... | |
Variables | |
static struct interface_operation | slam_socket_operations [] |
SLAM unicast socket interface operations. More... | |
static struct interface_descriptor | slam_socket_desc |
SLAM unicast socket interface descriptor. More... | |
static struct interface_operation | slam_mc_socket_operations [] |
SLAM multicast socket interface operations. More... | |
static struct interface_descriptor | slam_mc_socket_desc |
SLAM multicast socket interface descriptor. More... | |
static struct interface_operation | slam_xfer_operations [] |
SLAM data transfer interface operations. More... | |
static struct interface_descriptor | slam_xfer_desc |
SLAM data transfer interface descriptor. More... | |
struct uri_opener slam_uri_opener | __uri_opener |
SLAM URI opener. More... | |
Scalable Local Area Multicast protocol.
The SLAM protocol is supported only by Etherboot; it was designed and implemented by Eric Biederman. A server implementation is available in contrib/mini-slamd. There does not appear to be any documentation beyond a few sparse comments in Etherboot's proto_slam.c.
SLAM packets use three types of data field:
Nul : A single NUL (0) byte, used as a list terminator
Raw : A block of raw data
Int : A variable-length integer, in big-endian order. The length of the integer is encoded in the most significant three bits.
Packets received by the client have the following layout:
Int : Transaction identifier. This is an opaque value.
Int : Total number of bytes in the transfer.
Int : Block size, in bytes.
Int : Packet sequence number within the transfer (if this packet contains data).
Raw : Packet data (if this packet contains data).
Packets transmitted by the client consist of a run-length-encoded representation of the received-blocks bitmap, looking something like:
Int : Number of consecutive successfully-received packets Int : Number of consecutive missing packets Int : Number of consecutive successfully-received packets Int : Number of consecutive missing packets .... Nul
Definition in file slam.c.
#define SLAM_DEFAULT_MULTICAST_IP ( ( 239 << 24 ) | ( 255 << 16 ) | ( 1 << 8 ) | ( 1 << 0 ) ) |
#define SLAM_DEFAULT_MULTICAST_PORT 10000 |
#define SLAM_MAX_HEADER_LEN |
#define SLAM_MAX_BLOCKS_PER_NACK 4 |
#define SLAM_SLAVE_TIMEOUT ( 1 * TICKS_PER_SEC ) |
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
FEATURE | ( | FEATURE_PROTOCOL | , |
"SLAM" | , | ||
DHCP_EB_FEATURE_SLAM | , | ||
1 | |||
) |
|
static |
Free a SLAM request.
refcnt | Reference counter |
Definition at line 159 of file slam.c.
References slam_request::bitmap, bitmap_free(), container_of, and free.
Referenced by slam_open().
|
static |
Mark SLAM request as complete.
slam | SLAM request |
rc | Return status code |
Definition at line 173 of file slam.c.
References DBGC, intf_shutdown(), slam_request::master_timer, slam_request::mc_socket, slam_request::nack_sent, rc, slam_request::slave_timer, slam_request::socket, stop_timer(), strerror(), slam_request::xfer, and xfer_deliver_raw().
Referenced by slam_mc_socket_deliver(), slam_open(), slam_pull_header(), and slam_slave_timer_expired().
|
static |
Add a variable-length value to a SLAM packet.
slam | SLAM request |
iobuf | I/O buffer |
value | Value to add |
rc | Return status code |
Adds a variable-length value to the end of an I/O buffer. Will always leave at least one byte of tailroom in the I/O buffer (to allow space for the terminating NUL).
Definition at line 215 of file slam.c.
References assert(), data, DBGC2, ENOBUFS, flsl, iob_put, iob_tailroom(), len, and value.
Referenced by slam_tx_nack().
|
static |
Send SLAM NACK packet.
slam | SLAM request |
rc | Return status code |
Definition at line 254 of file slam.c.
References slam_request::bitmap, bitmap_first_gap(), bitmap_test(), DBGC, DBGCP, ENOMEM, free_iob(), iob_disown, iob_put, slam_request::nack_sent, slam_request::num_blocks, rc, SLAM_MAX_BLOCKS_PER_NACK, SLAM_MAX_NACK_LEN, slam_put_value(), slam_request::socket, xfer_alloc_iob(), and xfer_deliver_iob().
Referenced by slam_master_timer_expired(), slam_slave_timer_expired(), and slam_socket_deliver().
|
static |
Handle SLAM master client retry timer expiry.
timer | Master retry timer |
fail | Failure indicator |
Definition at line 319 of file slam.c.
References container_of, DBGC, slam_request::master_timer, slam_tx_nack(), and start_timer().
Referenced by slam_open().
|
static |
Handle SLAM slave client retry timer expiry.
timer | Master retry timer |
fail | Failure indicator |
Definition at line 343 of file slam.c.
References container_of, DBGC, ETIMEDOUT, slam_finished(), slam_tx_nack(), slam_request::slave_timer, and start_timer().
Referenced by slam_open().
|
static |
Read and strip a variable-length value from a SLAM packet.
slam | SLAM request |
iobuf | I/O buffer |
value | Value to fill in, or NULL to ignore value |
rc | Return status code |
Reads a variable-length value from the start of the I/O buffer.
Definition at line 376 of file slam.c.
References data, io_buffer::data, DBGC, EINVAL, iob_len(), iob_pull, len, and value.
Referenced by slam_mc_socket_deliver(), and slam_pull_header().
|
static |
Read and strip SLAM header.
slam | SLAM request |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 425 of file slam.c.
References assert(), slam_request::bitmap, bitmap_free(), bitmap_resize(), block_size, slam_request::block_size, io_buffer::data, DBGC, EINVAL, slam_request::header, header, slam_request::header_len, iob_len(), iob_pull, memcmp(), memcpy(), memset(), NULL, slam_request::num_blocks, rc, slam_finished(), slam_pull_value(), strerror(), slam_request::total_bytes, slam_request::xfer, and xfer_seek().
Referenced by slam_mc_socket_deliver(), and slam_socket_deliver().
|
static |
Receive SLAM data packet.
slam | SLAM request |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 498 of file slam.c.
References slam_request::bitmap, bitmap_full(), bitmap_set(), bitmap_test(), block_size, slam_request::block_size, DBGC, EINVAL, free_iob(), iob_len(), len, slam_request::master_timer, memset(), meta(), slam_request::num_blocks, rc, slam_finished(), slam_pull_header(), slam_pull_value(), SLAM_SLAVE_TIMEOUT, slam_request::slave_timer, start_timer_fixed(), stop_timer(), slam_request::xfer, xfer_deliver(), and XFER_FL_ABS_OFFSET.
|
static |
Receive SLAM non-data packet.
slam | SLAM request |
iobuf | I/O buffer |
rc | Return status code |
Definition at line 578 of file slam.c.
References io_buffer::data, DBGC, DBGC_HD, EINVAL, free_iob(), iob_len(), slam_request::master_timer, rc, slam_pull_header(), slam_tx_nack(), start_timer(), and stop_timer().
|
static |
Parse SLAM URI multicast address.
slam | SLAM request |
path | Path portion of x-slam:// URI |
address | Socket address to fill in |
rc | Return status code |
Definition at line 656 of file slam.c.
References address, assert(), DBGC, EINVAL, end, ENOMEM, free, htons, rc, sock_aton(), strchr(), strdup(), and strtoul().
Referenced by slam_open().
Initiate a SLAM request.
xfer | Data transfer interface |
uri | Uniform Resource Identifier |
rc | Return status code |
Definition at line 710 of file slam.c.
References AF_INET, slam_request::bitmap, bitmap_resize(), DBGC, EINVAL, ENOMEM, slam_request::header_len, uri::host, htonl, htons, intf_init(), intf_plug_plug(), slam_request::master_timer, slam_request::mc_socket, memcpy(), memset(), NULL, slam_request::num_blocks, uri::path, rc, ref_init, ref_put, slam_request::refcnt, sockaddr_in::sin_family, SLAM_DEFAULT_MULTICAST_IP, SLAM_DEFAULT_MULTICAST_PORT, SLAM_DEFAULT_PORT, slam_finished(), slam_free(), slam_master_timer_expired(), slam_mc_socket_desc, slam_parse_multicast_address(), SLAM_SLAVE_TIMEOUT, slam_slave_timer_expired(), slam_socket_desc, slam_xfer_desc, slam_request::slave_timer, SOCK_DGRAM, slam_request::socket, sockaddr_tcpip::st_port, start_timer_fixed(), strerror(), uri_port(), slam_request::xfer, xfer_open_named_socket(), xfer_open_socket(), and zalloc().
|
static |
SLAM unicast socket interface operations.
|
static |
SLAM unicast socket interface descriptor.
Definition at line 620 of file slam.c.
Referenced by slam_open().
|
static |
SLAM multicast socket interface operations.
|
static |
SLAM multicast socket interface descriptor.
Definition at line 630 of file slam.c.
Referenced by slam_open().
|
static |
SLAM data transfer interface operations.
|
static |
SLAM data transfer interface descriptor.
Definition at line 645 of file slam.c.
Referenced by slam_open().
struct uri_opener slam_uri_opener __uri_opener |
SLAM URI opener.