iPXE
Data Structures | Macros | Functions | Variables
slam.c File Reference

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...
 

Detailed Description

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.

Macro Definition Documentation

◆ SLAM_DEFAULT_PORT

#define SLAM_DEFAULT_PORT   10000

Default SLAM server port.

Definition at line 91 of file slam.c.

◆ SLAM_DEFAULT_MULTICAST_IP

#define SLAM_DEFAULT_MULTICAST_IP   ( ( 239 << 24 ) | ( 255 << 16 ) | ( 1 << 8 ) | ( 1 << 0 ) )

Default SLAM multicast IP address.

Definition at line 94 of file slam.c.

◆ SLAM_DEFAULT_MULTICAST_PORT

#define SLAM_DEFAULT_MULTICAST_PORT   10000

Default SLAM multicast port.

Definition at line 98 of file slam.c.

◆ SLAM_MAX_HEADER_LEN

#define SLAM_MAX_HEADER_LEN
Value:
( 7 /* transaction id */ + 7 /* total_bytes */ + \
7 /* block_size */ )

Maximum SLAM header length.

Definition at line 101 of file slam.c.

◆ SLAM_MAX_BLOCKS_PER_NACK

#define SLAM_MAX_BLOCKS_PER_NACK   4

Maximum number of blocks to request per NACK.

This is a policy decision equivalent to selecting a TCP window size.

Definition at line 109 of file slam.c.

◆ SLAM_MAX_NACK_LEN

#define SLAM_MAX_NACK_LEN   ( 7 /* block */ + 7 /* #blocks */ + 1 /* NUL */ )

Maximum SLAM NACK length.

We only ever send a NACK for a single range of up to SLAM_MAX_BLOCKS_PER_NACK blocks.

Definition at line 116 of file slam.c.

◆ SLAM_SLAVE_TIMEOUT

#define SLAM_SLAVE_TIMEOUT   ( 1 * TICKS_PER_SEC )

SLAM slave timeout.

Definition at line 119 of file slam.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FEATURE()

FEATURE ( FEATURE_PROTOCOL  ,
"SLAM"  ,
DHCP_EB_FEATURE_SLAM  ,
 
)

◆ slam_free()

static void slam_free ( struct refcnt refcnt)
static

Free a SLAM request.

Parameters
refcntReference counter

Definition at line 159 of file slam.c.

159  {
160  struct slam_request *slam =
161  container_of ( refcnt, struct slam_request, refcnt );
162 
163  bitmap_free ( &slam->bitmap );
164  free ( slam );
165 }
static void bitmap_free(struct bitmap *bitmap)
Free bitmap resources.
Definition: bitmap.h:57
A SLAM request.
Definition: slam.c:122
A reference counter.
Definition: refcnt.h:26
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
struct bitmap bitmap
Block bitmap.
Definition: slam.c:149

References slam_request::bitmap, bitmap_free(), container_of, and free.

Referenced by slam_open().

◆ slam_finished()

static void slam_finished ( struct slam_request slam,
int  rc 
)
static

Mark SLAM request as complete.

Parameters
slamSLAM request
rcReturn status code

Definition at line 173 of file slam.c.

173  {
174  static const uint8_t slam_disconnect[] = { 0 };
175 
176  DBGC ( slam, "SLAM %p finished with status code %d (%s)\n",
177  slam, rc, strerror ( rc ) );
178 
179  /* Send a disconnect message if we ever sent anything to the
180  * server.
181  */
182  if ( slam->nack_sent ) {
183  xfer_deliver_raw ( &slam->socket, slam_disconnect,
184  sizeof ( slam_disconnect ) );
185  }
186 
187  /* Stop the retry timers */
188  stop_timer ( &slam->master_timer );
189  stop_timer ( &slam->slave_timer );
190 
191  /* Close all data transfer interfaces */
192  intf_shutdown ( &slam->socket, rc );
193  intf_shutdown ( &slam->mc_socket, rc );
194  intf_shutdown ( &slam->xfer, rc );
195 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:278
#define DBGC(...)
Definition: compiler.h:505
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition: xfer.c:288
int nack_sent
NACK sent flag.
Definition: slam.c:151
struct retry_timer master_timer
Master client retry timer.
Definition: slam.c:134
struct interface socket
Unicast socket.
Definition: slam.c:129
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
unsigned char uint8_t
Definition: stdint.h:10
struct interface mc_socket
Multicast socket.
Definition: slam.c:131
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
struct interface xfer
Data transfer interface.
Definition: slam.c:127
struct retry_timer slave_timer
Slave client retry timer.
Definition: slam.c:136

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().

◆ slam_put_value()

static int slam_put_value ( struct slam_request slam,
struct io_buffer iobuf,
unsigned long  value 
)
static

Add a variable-length value to a SLAM packet.

Parameters
slamSLAM request
iobufI/O buffer
valueValue to add
Return values
rcReturn 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.

216  {
217  uint8_t *data;
218  size_t len;
219  unsigned int i;
220 
221  /* Calculate variable length required to store value. Always
222  * leave at least one byte in the I/O buffer.
223  */
224  len = ( ( flsl ( value ) + 10 ) / 8 );
225  if ( len >= iob_tailroom ( iobuf ) ) {
226  DBGC2 ( slam, "SLAM %p cannot add %zd-byte value\n",
227  slam, len );
228  return -ENOBUFS;
229  }
230  /* There is no valid way within the protocol that we can end
231  * up trying to push a full-sized long (i.e. without space for
232  * the length encoding).
233  */
234  assert ( len <= sizeof ( value ) );
235 
236  /* Add value */
237  data = iob_put ( iobuf, len );
238  for ( i = len ; i-- ; ) {
239  data[i] = value;
240  value >>= 8;
241  }
242  *data |= ( len << 5 );
243  assert ( value == 0 );
244 
245  return 0;
246 }
#define iob_put(iobuf, len)
Definition: iobuf.h:120
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
Definition: iobuf.h:175
unsigned char uint8_t
Definition: stdint.h:10
uint32_t len
Length.
Definition: ena.h:14
#define ENOBUFS
No buffer space available.
Definition: errno.h:498
#define DBGC2(...)
Definition: compiler.h:522
uint8_t data[48]
Additional event data.
Definition: ena.h:22
#define flsl(x)
Find last (i.e.
Definition: strings.h:157

References assert(), data, DBGC2, ENOBUFS, flsl, iob_put, iob_tailroom(), len, and value.

Referenced by slam_tx_nack().

◆ slam_tx_nack()

static int slam_tx_nack ( struct slam_request slam)
static

Send SLAM NACK packet.

Parameters
slamSLAM request
Return values
rcReturn status code

Definition at line 254 of file slam.c.

254  {
255  struct io_buffer *iobuf;
256  unsigned long first_block;
257  unsigned long num_blocks;
258  uint8_t *nul;
259  int rc;
260 
261  /* Mark NACK as sent, so that we know we have to disconnect later */
262  slam->nack_sent = 1;
263 
264  /* Allocate I/O buffer */
265  iobuf = xfer_alloc_iob ( &slam->socket, SLAM_MAX_NACK_LEN );
266  if ( ! iobuf ) {
267  DBGC ( slam, "SLAM %p could not allocate I/O buffer\n",
268  slam );
269  rc = -ENOMEM;
270  goto err_alloc;
271  }
272 
273  /* Construct NACK. We always request only a single packet;
274  * this allows us to force multicast-TFTP-style flow control
275  * on the SLAM server, which will otherwise just blast the
276  * data out as fast as it can. On a gigabit network, without
277  * RX checksumming, this would inevitably cause packet drops.
278  */
279  first_block = bitmap_first_gap ( &slam->bitmap );
280  for ( num_blocks = 1 ; ; num_blocks++ ) {
281  if ( num_blocks >= SLAM_MAX_BLOCKS_PER_NACK )
282  break;
283  if ( ( first_block + num_blocks ) >= slam->num_blocks )
284  break;
285  if ( bitmap_test ( &slam->bitmap,
286  ( first_block + num_blocks ) ) )
287  break;
288  }
289  if ( first_block ) {
290  DBGCP ( slam, "SLAM %p transmitting NACK for blocks "
291  "%ld-%ld\n", slam, first_block,
292  ( first_block + num_blocks - 1 ) );
293  } else {
294  DBGC ( slam, "SLAM %p transmitting initial NACK for blocks "
295  "0-%ld\n", slam, ( num_blocks - 1 ) );
296  }
297  if ( ( rc = slam_put_value ( slam, iobuf, first_block ) ) != 0 )
298  goto err_put_value;
299  if ( ( rc = slam_put_value ( slam, iobuf, num_blocks ) ) != 0 )
300  goto err_put_value;
301  nul = iob_put ( iobuf, 1 );
302  *nul = 0;
303 
304  /* Transmit packet */
305  return xfer_deliver_iob ( &slam->socket, iob_disown ( iobuf ) );
306 
307  err_put_value:
308  free_iob ( iobuf );
309  err_alloc:
310  return rc;
311 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define iob_put(iobuf, len)
Definition: iobuf.h:120
int xfer_deliver_iob(struct interface *intf, struct io_buffer *iobuf)
Deliver datagram as I/O buffer without metadata.
Definition: xfer.c:255
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#define DBGC(...)
Definition: compiler.h:505
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
Definition: xfer.c:158
int nack_sent
NACK sent flag.
Definition: slam.c:151
int bitmap_test(struct bitmap *bitmap, unsigned int bit)
Test bit in bitmap.
Definition: bitmap.c:78
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define iob_disown(iobuf)
Disown an I/O buffer.
Definition: iobuf.h:212
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.
Definition: slam.c:215
unsigned long num_blocks
Number of blocks in transfer.
Definition: slam.c:147
struct interface socket
Unicast socket.
Definition: slam.c:129
unsigned char uint8_t
Definition: stdint.h:10
#define SLAM_MAX_BLOCKS_PER_NACK
Maximum number of blocks to request per NACK.
Definition: slam.c:109
#define SLAM_MAX_NACK_LEN
Maximum SLAM NACK length.
Definition: slam.c:116
static unsigned int bitmap_first_gap(struct bitmap *bitmap)
Get first gap within bitmap.
Definition: bitmap.h:69
#define DBGCP(...)
Definition: compiler.h:539
struct bitmap bitmap
Block bitmap.
Definition: slam.c:149
A persistent I/O buffer.
Definition: iobuf.h:33

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().

◆ slam_master_timer_expired()

static void slam_master_timer_expired ( struct retry_timer timer,
int  fail 
)
static

Handle SLAM master client retry timer expiry.

Parameters
timerMaster retry timer
failFailure indicator

Definition at line 319 of file slam.c.

320  {
321  struct slam_request *slam =
323 
324  if ( fail ) {
325  /* Allow timer to stop running. We will terminate the
326  * connection only if the slave timer times out.
327  */
328  DBGC ( slam, "SLAM %p giving up acting as master client\n",
329  slam );
330  } else {
331  /* Retransmit NACK */
332  start_timer ( timer );
333  slam_tx_nack ( slam );
334  }
335 }
#define DBGC(...)
Definition: compiler.h:505
A SLAM request.
Definition: slam.c:122
A timer.
Definition: timer.h:28
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct retry_timer master_timer
Master client retry timer.
Definition: slam.c:134
void start_timer(struct retry_timer *timer)
Start timer.
Definition: retry.c:93
static int slam_tx_nack(struct slam_request *slam)
Send SLAM NACK packet.
Definition: slam.c:254

References container_of, DBGC, slam_request::master_timer, slam_tx_nack(), and start_timer().

Referenced by slam_open().

◆ slam_slave_timer_expired()

static void slam_slave_timer_expired ( struct retry_timer timer,
int  fail 
)
static

Handle SLAM slave client retry timer expiry.

Parameters
timerMaster retry timer
failFailure indicator

Definition at line 343 of file slam.c.

344  {
345  struct slam_request *slam =
347 
348  if ( fail ) {
349  /* Terminate connection */
350  slam_finished ( slam, -ETIMEDOUT );
351  } else {
352  /* Try sending a NACK */
353  DBGC ( slam, "SLAM %p trying to become master client\n",
354  slam );
355  start_timer ( timer );
356  slam_tx_nack ( slam );
357  }
358 }
#define DBGC(...)
Definition: compiler.h:505
A SLAM request.
Definition: slam.c:122
A timer.
Definition: timer.h:28
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
void start_timer(struct retry_timer *timer)
Start timer.
Definition: retry.c:93
static void slam_finished(struct slam_request *slam, int rc)
Mark SLAM request as complete.
Definition: slam.c:173
struct retry_timer slave_timer
Slave client retry timer.
Definition: slam.c:136
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:669
static int slam_tx_nack(struct slam_request *slam)
Send SLAM NACK packet.
Definition: slam.c:254

References container_of, DBGC, ETIMEDOUT, slam_finished(), slam_tx_nack(), slam_request::slave_timer, and start_timer().

Referenced by slam_open().

◆ slam_pull_value()

static int slam_pull_value ( struct slam_request slam,
struct io_buffer iobuf,
unsigned long *  value 
)
static

Read and strip a variable-length value from a SLAM packet.

Parameters
slamSLAM request
iobufI/O buffer
valueValue to fill in, or NULL to ignore value
Return values
rcReturn status code

Reads a variable-length value from the start of the I/O buffer.

Definition at line 376 of file slam.c.

378  {
379  uint8_t *data;
380  size_t len;
381 
382  /* Sanity check */
383  if ( iob_len ( iobuf ) == 0 ) {
384  DBGC ( slam, "SLAM %p empty value\n", slam );
385  return -EINVAL;
386  }
387 
388  /* Read and verify length of value */
389  data = iobuf->data;
390  len = ( *data >> 5 );
391  if ( ( len == 0 ) ||
392  ( value && ( len > sizeof ( *value ) ) ) ) {
393  DBGC ( slam, "SLAM %p invalid value length %zd bytes\n",
394  slam, len );
395  return -EINVAL;
396  }
397  if ( len > iob_len ( iobuf ) ) {
398  DBGC ( slam, "SLAM %p value extends beyond I/O buffer\n",
399  slam );
400  return -EINVAL;
401  }
402 
403  /* Strip value */
404  iob_pull ( iobuf, len );
405 
406  /* Read value, if applicable */
407  if ( value ) {
408  *value = ( *data & 0x1f );
409  while ( --len ) {
410  *value <<= 8;
411  *value |= *(++data);
412  }
413  }
414 
415  return 0;
416 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:102
#define EINVAL
Invalid argument.
Definition: errno.h:428
#define DBGC(...)
Definition: compiler.h:505
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
unsigned char uint8_t
Definition: stdint.h:10
uint32_t len
Length.
Definition: ena.h:14
void * data
Start of data.
Definition: iobuf.h:48
uint8_t data[48]
Additional event data.
Definition: ena.h:22

References data, io_buffer::data, DBGC, EINVAL, iob_len(), iob_pull, len, and value.

Referenced by slam_mc_socket_deliver(), and slam_pull_header().

◆ slam_pull_header()

static int slam_pull_header ( struct slam_request slam,
struct io_buffer iobuf 
)
static

Read and strip SLAM header.

Parameters
slamSLAM request
iobufI/O buffer
Return values
rcReturn status code

Definition at line 425 of file slam.c.

426  {
427  void *header = iobuf->data;
428  unsigned long total_bytes;
429  unsigned long block_size;
430  int rc;
431 
432  /* If header matches cached header, just pull it and return */
433  if ( ( slam->header_len <= iob_len ( iobuf ) ) &&
434  ( memcmp ( slam->header, iobuf->data, slam->header_len ) == 0 )){
435  iob_pull ( iobuf, slam->header_len );
436  return 0;
437  }
438 
439  DBGC ( slam, "SLAM %p detected changed header; resetting\n", slam );
440 
441  /* Read and strip transaction ID, total number of bytes, and
442  * block size.
443  */
444  if ( ( rc = slam_pull_value ( slam, iobuf, NULL ) ) != 0 )
445  return rc;
446  if ( ( rc = slam_pull_value ( slam, iobuf, &total_bytes ) ) != 0 )
447  return rc;
448  if ( ( rc = slam_pull_value ( slam, iobuf, &block_size ) ) != 0 )
449  return rc;
450 
451  /* Sanity check */
452  if ( block_size == 0 ) {
453  DBGC ( slam, "SLAM %p ignoring zero block size\n", slam );
454  return -EINVAL;
455  }
456 
457  /* Update the cached header */
458  slam->header_len = ( iobuf->data - header );
459  assert ( slam->header_len <= sizeof ( slam->header ) );
460  memcpy ( slam->header, header, slam->header_len );
461 
462  /* Calculate number of blocks */
463  slam->total_bytes = total_bytes;
464  slam->block_size = block_size;
465  slam->num_blocks = ( ( total_bytes + block_size - 1 ) / block_size );
466  DBGC ( slam, "SLAM %p has total bytes %ld, block size %ld, num "
467  "blocks %ld\n", slam, slam->total_bytes, slam->block_size,
468  slam->num_blocks );
469 
470  /* Discard and reset the bitmap */
471  bitmap_free ( &slam->bitmap );
472  memset ( &slam->bitmap, 0, sizeof ( slam->bitmap ) );
473 
474  /* Allocate a new bitmap */
475  if ( ( rc = bitmap_resize ( &slam->bitmap,
476  slam->num_blocks ) ) != 0 ) {
477  /* Failure to allocate a bitmap is fatal */
478  DBGC ( slam, "SLAM %p could not allocate bitmap for %ld "
479  "blocks: %s\n", slam, slam->num_blocks,
480  strerror ( rc ) );
481  slam_finished ( slam, rc );
482  return rc;
483  }
484 
485  /* Notify recipient of file size */
486  xfer_seek ( &slam->xfer, slam->total_bytes );
487 
488  return 0;
489 }
#define iob_pull(iobuf, len)
Definition: iobuf.h:102
#define EINVAL
Invalid argument.
Definition: errno.h:428
size_t header_len
Size of cached header.
Definition: slam.c:141
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
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.
Definition: slam.c:376
static void bitmap_free(struct bitmap *bitmap)
Free bitmap resources.
Definition: bitmap.h:57
uint8_t header[SLAM_MAX_HEADER_LEN]
Cached header.
Definition: slam.c:139
#define DBGC(...)
Definition: compiler.h:505
void * memcpy(void *dest, const void *src, size_t len) __nonnull
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
unsigned long block_size
Transfer block size.
Definition: slam.c:145
int bitmap_resize(struct bitmap *bitmap, unsigned int new_length)
Resize bitmap.
Definition: bitmap.c:42
int xfer_seek(struct interface *intf, off_t offset)
Seek to position.
Definition: xfer.c:351
unsigned long num_blocks
Number of blocks in transfer.
Definition: slam.c:147
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
static void slam_finished(struct slam_request *slam, int rc)
Mark SLAM request as complete.
Definition: slam.c:173
struct interface xfer
Data transfer interface.
Definition: slam.c:127
void * data
Start of data.
Definition: iobuf.h:48
struct ena_aq_header header
Header.
Definition: ena.h:12
device nvs block_size
Definition: threewire.h:58
struct bitmap bitmap
Block bitmap.
Definition: slam.c:149
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
unsigned long total_bytes
Total number of bytes in transfer.
Definition: slam.c:143
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void * memset(void *dest, int character, size_t len) __nonnull

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().

◆ slam_mc_socket_deliver()

static int slam_mc_socket_deliver ( struct slam_request slam,
struct io_buffer iobuf,
struct xfer_metadata *rx_meta  __unused 
)
static

Receive SLAM data packet.

Parameters
slamSLAM request
iobufI/O buffer
Return values
rcReturn status code

Definition at line 498 of file slam.c.

500  {
501  struct xfer_metadata meta;
502  unsigned long packet;
503  size_t len;
504  int rc;
505 
506  /* Stop the master client timer. Restart the slave client timer. */
507  stop_timer ( &slam->master_timer );
508  stop_timer ( &slam->slave_timer );
510 
511  /* Read and strip packet header */
512  if ( ( rc = slam_pull_header ( slam, iobuf ) ) != 0 )
513  goto err_discard;
514 
515  /* Read and strip packet number */
516  if ( ( rc = slam_pull_value ( slam, iobuf, &packet ) ) != 0 )
517  goto err_discard;
518 
519  /* Sanity check packet number */
520  if ( packet >= slam->num_blocks ) {
521  DBGC ( slam, "SLAM %p received out-of-range packet %ld "
522  "(num_blocks=%ld)\n", slam, packet, slam->num_blocks );
523  rc = -EINVAL;
524  goto err_discard;
525  }
526 
527  /* Sanity check length */
528  len = iob_len ( iobuf );
529  if ( len > slam->block_size ) {
530  DBGC ( slam, "SLAM %p received oversize packet of %zd bytes "
531  "(block_size=%ld)\n", slam, len, slam->block_size );
532  rc = -EINVAL;
533  goto err_discard;
534  }
535  if ( ( packet != ( slam->num_blocks - 1 ) ) &&
536  ( len < slam->block_size ) ) {
537  DBGC ( slam, "SLAM %p received short packet of %zd bytes "
538  "(block_size=%ld)\n", slam, len, slam->block_size );
539  rc = -EINVAL;
540  goto err_discard;
541  }
542 
543  /* If we have already seen this packet, discard it */
544  if ( bitmap_test ( &slam->bitmap, packet ) ) {
545  goto discard;
546  }
547 
548  /* Pass to recipient */
549  memset ( &meta, 0, sizeof ( meta ) );
550  meta.flags = XFER_FL_ABS_OFFSET;
551  meta.offset = ( packet * slam->block_size );
552  if ( ( rc = xfer_deliver ( &slam->xfer, iobuf, &meta ) ) != 0 )
553  goto err;
554 
555  /* Mark block as received */
556  bitmap_set ( &slam->bitmap, packet );
557 
558  /* If we have received all blocks, terminate */
559  if ( bitmap_full ( &slam->bitmap ) )
560  slam_finished ( slam, 0 );
561 
562  return 0;
563 
564  err_discard:
565  discard:
566  free_iob ( iobuf );
567  err:
568  return rc;
569 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Data transfer metadata.
Definition: xfer.h:22
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.
Definition: slam.c:376
#define XFER_FL_ABS_OFFSET
Offset is absolute.
Definition: xfer.h:47
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#define DBGC(...)
Definition: compiler.h:505
int bitmap_test(struct bitmap *bitmap, unsigned int bit)
Test bit in bitmap.
Definition: bitmap.c:78
unsigned long block_size
Transfer block size.
Definition: slam.c:145
static int slam_pull_header(struct slam_request *slam, struct io_buffer *iobuf)
Read and strip SLAM header.
Definition: slam.c:425
struct retry_timer master_timer
Master client retry timer.
Definition: slam.c:134
unsigned long num_blocks
Number of blocks in transfer.
Definition: slam.c:147
int meta(WINDOW *, bool)
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:194
void bitmap_set(struct bitmap *bitmap, unsigned int bit)
Set bit in bitmap.
Definition: bitmap.c:93
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
static void slam_finished(struct slam_request *slam, int rc)
Mark SLAM request as complete.
Definition: slam.c:173
struct interface xfer
Data transfer interface.
Definition: slam.c:127
uint32_t len
Length.
Definition: ena.h:14
#define SLAM_SLAVE_TIMEOUT
SLAM slave timeout.
Definition: slam.c:119
device nvs block_size
Definition: threewire.h:58
struct bitmap bitmap
Block bitmap.
Definition: slam.c:149
static int bitmap_full(struct bitmap *bitmap)
Check to see if bitmap is full.
Definition: bitmap.h:81
struct retry_timer slave_timer
Slave client retry timer.
Definition: slam.c:136
void * memset(void *dest, int character, size_t len) __nonnull

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.

◆ slam_socket_deliver()

static int slam_socket_deliver ( struct slam_request slam,
struct io_buffer iobuf,
struct xfer_metadata *rx_meta  __unused 
)
static

Receive SLAM non-data packet.

Parameters
slamSLAM request
iobufI/O buffer
Return values
rcReturn status code

Definition at line 578 of file slam.c.

580  {
581  int rc;
582 
583  /* Restart the master client timer */
584  stop_timer ( &slam->master_timer );
585  start_timer ( &slam->master_timer );
586 
587  /* Read and strip packet header */
588  if ( ( rc = slam_pull_header ( slam, iobuf ) ) != 0 )
589  goto discard;
590 
591  /* Sanity check */
592  if ( iob_len ( iobuf ) != 0 ) {
593  DBGC ( slam, "SLAM %p received trailing garbage:\n", slam );
594  DBGC_HD ( slam, iobuf->data, iob_len ( iobuf ) );
595  rc = -EINVAL;
596  goto discard;
597  }
598 
599  /* Discard packet */
600  free_iob ( iobuf );
601 
602  /* Send NACK in reply */
603  slam_tx_nack ( slam );
604 
605  return 0;
606 
607  discard:
608  free_iob ( iobuf );
609  return rc;
610 
611 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
#define DBGC(...)
Definition: compiler.h:505
static int slam_pull_header(struct slam_request *slam, struct io_buffer *iobuf)
Read and strip SLAM header.
Definition: slam.c:425
struct retry_timer master_timer
Master client retry timer.
Definition: slam.c:134
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
#define DBGC_HD(...)
Definition: compiler.h:507
void start_timer(struct retry_timer *timer)
Start timer.
Definition: retry.c:93
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
void * data
Start of data.
Definition: iobuf.h:48
static int slam_tx_nack(struct slam_request *slam)
Send SLAM NACK packet.
Definition: slam.c:254

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().

◆ slam_parse_multicast_address()

static int slam_parse_multicast_address ( struct slam_request slam,
const char *  path,
struct sockaddr_tcpip address 
)
static

Parse SLAM URI multicast address.

Parameters
slamSLAM request
pathPath portion of x-slam:// URI
addressSocket address to fill in
Return values
rcReturn status code

Definition at line 656 of file slam.c.

658  {
659  char *path_dup;
660  char *sep;
661  char *end;
662  int rc;
663 
664  /* Create temporary copy of path, minus the leading '/' */
665  assert ( *path == '/' );
666  path_dup = strdup ( path + 1 );
667  if ( ! path_dup ) {
668  rc = -ENOMEM;
669  goto err_strdup;
670  }
671 
672  /* Parse port, if present */
673  sep = strchr ( path_dup, ':' );
674  if ( sep ) {
675  *(sep++) = '\0';
676  address->st_port = htons ( strtoul ( sep, &end, 0 ) );
677  if ( *end != '\0' ) {
678  DBGC ( slam, "SLAM %p invalid multicast port "
679  "\"%s\"\n", slam, sep );
680  rc = -EINVAL;
681  goto err_port;
682  }
683  }
684 
685  /* Parse address */
686  if ( sock_aton ( path_dup, ( ( struct sockaddr * ) address ) ) == 0 ) {
687  DBGC ( slam, "SLAM %p invalid multicast address \"%s\"\n",
688  slam, path_dup );
689  rc = -EINVAL;
690  goto err_addr;
691  }
692 
693  /* Success */
694  rc = 0;
695 
696  err_addr:
697  err_port:
698  free ( path_dup );
699  err_strdup:
700  return rc;
701 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
Definition: string.c:471
uint64_t address
Base address.
Definition: ena.h:24
#define DBGC(...)
Definition: compiler.h:505
int sock_aton(const char *string, struct sockaddr *sa)
Parse socket address.
Definition: socket.c:59
#define ENOMEM
Not enough space.
Definition: errno.h:534
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
Generalized socket address structure.
Definition: socket.h:96
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
char * strchr(const char *src, int character)
Find character within a string.
Definition: string.c:271
char * strdup(const char *src)
Duplicate string.
Definition: string.c:380
uint32_t end
Ending offset.
Definition: netvsc.h:18
#define htons(value)
Definition: byteswap.h:135

References address, assert(), DBGC, EINVAL, end, ENOMEM, free, htons, rc, sock_aton(), strchr(), strdup(), and strtoul().

Referenced by slam_open().

◆ slam_open()

static int slam_open ( struct interface xfer,
struct uri uri 
)
static

Initiate a SLAM request.

Parameters
xferData transfer interface
uriUniform Resource Identifier
Return values
rcReturn status code

Definition at line 710 of file slam.c.

710  {
711  static const struct sockaddr_in default_multicast = {
712  .sin_family = AF_INET,
713  .sin_port = htons ( SLAM_DEFAULT_MULTICAST_PORT ),
714  .sin_addr = { htonl ( SLAM_DEFAULT_MULTICAST_IP ) },
715  };
716  struct slam_request *slam;
717  struct sockaddr_tcpip server;
718  struct sockaddr_tcpip multicast;
719  int rc;
720 
721  /* Sanity checks */
722  if ( ! uri->host )
723  return -EINVAL;
724 
725  /* Allocate and populate structure */
726  slam = zalloc ( sizeof ( *slam ) );
727  if ( ! slam )
728  return -ENOMEM;
729  ref_init ( &slam->refcnt, slam_free );
730  intf_init ( &slam->xfer, &slam_xfer_desc, &slam->refcnt );
731  intf_init ( &slam->socket, &slam_socket_desc, &slam->refcnt );
732  intf_init ( &slam->mc_socket, &slam_mc_socket_desc, &slam->refcnt );
733  timer_init ( &slam->master_timer, slam_master_timer_expired,
734  &slam->refcnt );
735  timer_init ( &slam->slave_timer, slam_slave_timer_expired,
736  &slam->refcnt );
737  /* Fake an invalid cached header of { 0x00, ... } */
738  slam->header_len = 1;
739  /* Fake parameters for initial NACK */
740  slam->num_blocks = 1;
741  if ( ( rc = bitmap_resize ( &slam->bitmap, 1 ) ) != 0 ) {
742  DBGC ( slam, "SLAM %p could not allocate initial bitmap: "
743  "%s\n", slam, strerror ( rc ) );
744  goto err;
745  }
746 
747  /* Open unicast socket */
748  memset ( &server, 0, sizeof ( server ) );
749  server.st_port = htons ( uri_port ( uri, SLAM_DEFAULT_PORT ) );
750  if ( ( rc = xfer_open_named_socket ( &slam->socket, SOCK_DGRAM,
751  ( struct sockaddr * ) &server,
752  uri->host, NULL ) ) != 0 ) {
753  DBGC ( slam, "SLAM %p could not open unicast socket: %s\n",
754  slam, strerror ( rc ) );
755  goto err;
756  }
757 
758  /* Open multicast socket */
759  memcpy ( &multicast, &default_multicast, sizeof ( multicast ) );
760  if ( uri->path &&
761  ( ( rc = slam_parse_multicast_address ( slam, uri->path,
762  &multicast ) ) != 0 ) ) {
763  goto err;
764  }
765  if ( ( rc = xfer_open_socket ( &slam->mc_socket, SOCK_DGRAM,
766  ( struct sockaddr * ) &multicast,
767  ( struct sockaddr * ) &multicast ) ) != 0 ) {
768  DBGC ( slam, "SLAM %p could not open multicast socket: %s\n",
769  slam, strerror ( rc ) );
770  goto err;
771  }
772 
773  /* Start slave retry timer */
775 
776  /* Attach to parent interface, mortalise self, and return */
777  intf_plug_plug ( &slam->xfer, xfer );
778  ref_put ( &slam->refcnt );
779  return 0;
780 
781  err:
782  slam_finished ( slam, rc );
783  ref_put ( &slam->refcnt );
784  return rc;
785 }
#define EINVAL
Invalid argument.
Definition: errno.h:428
size_t header_len
Size of cached header.
Definition: slam.c:141
TCP/IP socket address.
Definition: tcpip.h:75
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
struct refcnt refcnt
Reference counter.
Definition: slam.c:124
static struct interface_descriptor slam_xfer_desc
SLAM data transfer interface descriptor.
Definition: slam.c:645
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
int xfer_open_socket(struct interface *intf, int semantics, struct sockaddr *peer, struct sockaddr *local)
Open socket.
Definition: open.c:142
#define SOCK_DGRAM
Definition: socket.h:29
#define DBGC(...)
Definition: compiler.h:505
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:107
IPv4 socket address.
Definition: in.h:82
sa_family_t sin_family
Socket address family (part of struct sockaddr)
Definition: in.h:87
#define htonl(value)
Definition: byteswap.h:133
A SLAM request.
Definition: slam.c:122
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define SLAM_DEFAULT_PORT
Default SLAM server port.
Definition: slam.c:91
const char * path
Path (after URI decoding)
Definition: uri.h:80
int bitmap_resize(struct bitmap *bitmap, unsigned int new_length)
Resize bitmap.
Definition: bitmap.c:42
static struct interface_descriptor slam_socket_desc
SLAM unicast socket interface descriptor.
Definition: slam.c:620
struct retry_timer master_timer
Master client retry timer.
Definition: slam.c:134
unsigned long num_blocks
Number of blocks in transfer.
Definition: slam.c:147
static struct interface_descriptor slam_mc_socket_desc
SLAM multicast socket interface descriptor.
Definition: slam.c:630
Generalized socket address structure.
Definition: socket.h:96
#define SLAM_DEFAULT_MULTICAST_PORT
Default SLAM multicast port.
Definition: slam.c:98
struct interface socket
Unicast socket.
Definition: slam.c:129
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
struct interface mc_socket
Multicast socket.
Definition: slam.c:131
#define SLAM_DEFAULT_MULTICAST_IP
Default SLAM multicast IP address.
Definition: slam.c:94
static void slam_master_timer_expired(struct retry_timer *timer, int fail)
Handle SLAM master client retry timer expiry.
Definition: slam.c:319
const char * host
Host name.
Definition: uri.h:76
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64
static void slam_slave_timer_expired(struct retry_timer *timer, int fail)
Handle SLAM slave client retry timer expiry.
Definition: slam.c:343
static void slam_finished(struct slam_request *slam, int rc)
Mark SLAM request as complete.
Definition: slam.c:173
struct interface xfer
Data transfer interface.
Definition: slam.c:127
#define SLAM_SLAVE_TIMEOUT
SLAM slave timeout.
Definition: slam.c:119
unsigned int uri_port(const struct uri *uri, unsigned int default_port)
Get port from URI.
Definition: uri.c:455
A Uniform Resource Identifier.
Definition: uri.h:64
static int slam_parse_multicast_address(struct slam_request *slam, const char *path, struct sockaddr_tcpip *address)
Parse SLAM URI multicast address.
Definition: slam.c:656
struct bitmap bitmap
Block bitmap.
Definition: slam.c:149
static void slam_free(struct refcnt *refcnt)
Free a SLAM request.
Definition: slam.c:159
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203
struct retry_timer slave_timer
Slave client retry timer.
Definition: slam.c:136
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define htons(value)
Definition: byteswap.h:135
#define AF_INET
IPv4 Internet addresses.
Definition: socket.h:63
int xfer_open_named_socket(struct interface *xfer, int semantics, struct sockaddr *peer, const char *name, struct sockaddr *local)
Open named socket.
Definition: resolv.c:402
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106
void * memset(void *dest, int character, size_t len) __nonnull

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().

Variable Documentation

◆ slam_socket_operations

struct interface_operation slam_socket_operations[]
static
Initial value:
= {
}
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
static int slam_socket_deliver(struct slam_request *slam, struct io_buffer *iobuf, struct xfer_metadata *rx_meta __unused)
Receive SLAM non-data packet.
Definition: slam.c:578
A SLAM request.
Definition: slam.c:122
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:194
static void slam_finished(struct slam_request *slam, int rc)
Mark SLAM request as complete.
Definition: slam.c:173

SLAM unicast socket interface operations.

Definition at line 614 of file slam.c.

◆ slam_socket_desc

struct interface_descriptor slam_socket_desc
static
Initial value:
=
static struct interface_operation slam_socket_operations[]
SLAM unicast socket interface operations.
Definition: slam.c:614
A SLAM request.
Definition: slam.c:122
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80

SLAM unicast socket interface descriptor.

Definition at line 620 of file slam.c.

Referenced by slam_open().

◆ slam_mc_socket_operations

struct interface_operation slam_mc_socket_operations[]
static
Initial value:
= {
}
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
A SLAM request.
Definition: slam.c:122
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:194
static void slam_finished(struct slam_request *slam, int rc)
Mark SLAM request as complete.
Definition: slam.c:173
static int slam_mc_socket_deliver(struct slam_request *slam, struct io_buffer *iobuf, struct xfer_metadata *rx_meta __unused)
Receive SLAM data packet.
Definition: slam.c:498

SLAM multicast socket interface operations.

Definition at line 624 of file slam.c.

◆ slam_mc_socket_desc

struct interface_descriptor slam_mc_socket_desc
static
Initial value:
=
A SLAM request.
Definition: slam.c:122
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80
static struct interface_operation slam_mc_socket_operations[]
SLAM multicast socket interface operations.
Definition: slam.c:624

SLAM multicast socket interface descriptor.

Definition at line 630 of file slam.c.

Referenced by slam_open().

◆ slam_xfer_operations

struct interface_operation slam_xfer_operations[]
static
Initial value:
= {
}
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
A SLAM request.
Definition: slam.c:122
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
static void slam_finished(struct slam_request *slam, int rc)
Mark SLAM request as complete.
Definition: slam.c:173

SLAM data transfer interface operations.

Definition at line 640 of file slam.c.

◆ slam_xfer_desc

struct interface_descriptor slam_xfer_desc
static
Initial value:
=
A SLAM request.
Definition: slam.c:122
static struct interface_operation slam_xfer_operations[]
SLAM data transfer interface operations.
Definition: slam.c:640
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80

SLAM data transfer interface descriptor.

Definition at line 645 of file slam.c.

Referenced by slam_open().

◆ __uri_opener

struct uri_opener slam_uri_opener __uri_opener
Initial value:
= {
.scheme = "x-slam",
.open = slam_open,
}
static int slam_open(struct interface *xfer, struct uri *uri)
Initiate a SLAM request.
Definition: slam.c:710

SLAM URI opener.

Definition at line 788 of file slam.c.