iPXE
Functions | Variables
xfer.c File Reference

Data transfer interfaces. More...

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/iobuf.h>
#include <ipxe/xfer.h>
#include <ipxe/open.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
int xfer_vredirect (struct interface *intf, int type, va_list args)
 Send redirection event. More...
 
size_t xfer_window (struct interface *intf)
 Check flow control window. More...
 
void xfer_window_changed (struct interface *intf)
 Report change of flow control window. More...
 
struct io_bufferxfer_alloc_iob (struct interface *intf, size_t len)
 Allocate I/O buffer. More...
 
int xfer_deliver (struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
 Deliver datagram. More...
 
int xfer_redirect (struct interface *intf, int type,...)
 Send redirection event. More...
 
int xfer_deliver_iob (struct interface *intf, struct io_buffer *iobuf)
 Deliver datagram as I/O buffer without metadata. More...
 
int xfer_deliver_raw_meta (struct interface *intf, const void *data, size_t len, struct xfer_metadata *meta)
 Deliver datagram as raw data. More...
 
int xfer_deliver_raw (struct interface *intf, const void *data, size_t len)
 Deliver datagram as raw data without metadata. More...
 
int xfer_vprintf (struct interface *intf, const char *format, va_list args)
 Deliver formatted string. More...
 
int xfer_printf (struct interface *intf, const char *format,...)
 Deliver formatted string. More...
 
int xfer_seek (struct interface *intf, off_t offset)
 Seek to position. More...
 
int xfer_check_order (struct xfer_metadata *meta, size_t *pos, size_t len)
 Check that data is delivered strictly in order. More...
 

Variables

static struct xfer_metadata dummy_metadata
 Dummy transfer metadata. More...
 

Detailed Description

Data transfer interfaces.

Definition in file xfer.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ xfer_vredirect()

int xfer_vredirect ( struct interface intf,
int  type,
va_list  args 
)

Send redirection event.

Parameters
intfData transfer interface
typeNew location type
argsRemaining arguments depend upon location type
Return values
rcReturn status code

Definition at line 62 of file xfer.c.

62  {
64  struct interface *dest;
65  xfer_vredirect_TYPE ( void * ) *op =
67  void *object = intf_object ( dest );
68  int rc;
69 
70  DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " redirect\n",
71  INTF_INTF_DBG ( intf, dest ) );
72 
73  if ( op ) {
74  rc = op ( object, type, args );
75  } else {
76  /* Default is to reopen the interface as instructed,
77  * then send xfer_window_changed() messages to both
78  * new child and parent interfaces. Since our
79  * original child interface is likely to be closed and
80  * unplugged as a result of the call to
81  * xfer_vreopen(), we create a temporary interface in
82  * order to be able to send xfer_window_changed() to
83  * the parent.
84  *
85  * If redirection fails, then send intf_close() to the
86  * parent interface.
87  */
88  intf_plug ( &tmp, dest );
89  rc = xfer_vreopen ( dest, type, args );
90  if ( rc == 0 ) {
93  } else {
94  intf_close ( &tmp, rc );
95  }
96  intf_unplug ( &tmp );
97  }
98 
99  if ( rc != 0 ) {
100  DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " redirect "
101  "failed: %s\n", INTF_INTF_DBG ( intf, dest ),
102  strerror ( rc ) );
103  }
104 
105  intf_put ( dest );
106  return rc;
107 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition: xfer.c:145
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:244
#define INTF_INTF_FMT
printf() format string for INTF_INTF_DBG()
Definition: interface.h:240
struct interface_descriptor null_intf_desc
Null interface descriptor.
Definition: interface.c:61
#define INTF_INTF_DBG(intf, dest)
printf() arguments for representing an object interface pair
Definition: interface.h:249
#define INTF_INIT(descriptor)
Initialise a static object interface.
Definition: interface.h:187
uint8_t type
Type.
Definition: ena.h:16
#define INTF_COL(intf)
Find debugging colourisation for an object interface.
Definition: interface.h:226
#define DBGC(...)
Definition: compiler.h:505
int xfer_vredirect(struct interface *intf, int type, va_list args)
Send redirection event.
Definition: xfer.c:62
#define xfer_vredirect_TYPE(object_type)
Definition: xfer.h:69
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:154
An object interface.
Definition: interface.h:109
static void * dest
Definition: strings.h:176
void intf_unplug(struct interface *intf)
Unplug an object interface.
Definition: interface.c:112
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint8_t * tmp
Definition: entropy.h:156
int xfer_vreopen(struct interface *intf, int type, va_list args)
Reopen location.
Definition: open.c:223
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:144
#define intf_get_dest_op_no_passthru(intf, type, dest)
Get object interface destination and operation method (without pass-through)
Definition: interface.h:202
void intf_plug(struct interface *intf, struct interface *dest)
Plug an object interface into a new destination object interface.
Definition: interface.c:83

References DBGC, dest, intf_close(), INTF_COL, intf_get_dest_op_no_passthru, INTF_INIT, INTF_INTF_DBG, INTF_INTF_FMT, intf_object(), intf_plug(), intf_put(), intf_unplug(), null_intf_desc, op, rc, strerror(), tmp, type, xfer_vredirect(), xfer_vredirect_TYPE, xfer_vreopen(), and xfer_window_changed().

Referenced by xfer_redirect(), and xfer_vredirect().

◆ xfer_window()

size_t xfer_window ( struct interface intf)

Check flow control window.

Parameters
intfData transfer interface
Return values
lenLength of window

Definition at line 115 of file xfer.c.

115  {
116  struct interface *dest;
117  xfer_window_TYPE ( void * ) *op =
118  intf_get_dest_op ( intf, xfer_window, &dest );
119  void *object = intf_object ( dest );
120  size_t len;
121 
122  if ( op ) {
123  len = op ( object );
124  } else {
125  /* Default is to provide an unlimited window */
126  len = ~( ( size_t ) 0 );
127  }
128 
129  intf_put ( dest );
130  return len;
131 }
__SIZE_TYPE__ size_t
Definition: stdint.h:6
size_t xfer_window(struct interface *intf)
Check flow control window.
Definition: xfer.c:115
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:154
An object interface.
Definition: interface.h:109
static void * dest
Definition: strings.h:176
#define xfer_window_TYPE(object_type)
Definition: xfer.h:73
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint32_t len
Length.
Definition: ena.h:14
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:144
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:214

References dest, intf_get_dest_op, intf_object(), intf_put(), len, op, xfer_window(), and xfer_window_TYPE.

Referenced by efi_local_step(), fc_port_window_changed(), fcpcmd_send_wrdata(), http_step(), hw_step(), iscsi_tx_step(), nfs_mount_step(), nfs_pm_step(), nfs_step(), pinger_window_changed(), pxenv_tftp_open(), sanpath_step(), scsidev_step(), scsidev_window(), syslogs_window_changed(), tcp_xmit_sack(), tftp_send_packet(), tftp_send_rrq(), tls_cipherstream_window(), tls_plainstream_window(), tls_tx_step(), xcm_step(), and xfer_window().

◆ xfer_window_changed()

void xfer_window_changed ( struct interface intf)

Report change of flow control window.

Parameters
intfData transfer interface

Note that this method is used to indicate only unsolicited changes in the flow control window. In particular, this method must not be called as part of the response to xfer_deliver(), since that could easily lead to an infinite loop. Callers of xfer_deliver() should assume that the flow control window will have changed without generating an xfer_window_changed() message.

Definition at line 145 of file xfer.c.

145  {
146 
147  intf_poke ( intf, xfer_window_changed );
148 }
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition: xfer.c:145
void intf_poke(struct interface *intf, void(type)(struct interface *intf))
Poke an object interface.
Definition: interface.c:397

References intf_poke(), and xfer_window_changed().

Referenced by aoedev_config_done(), fcoe_expired(), fcoe_reset(), fcpdev_examine(), http_step(), ib_cmrc_changed(), iscsi_rx_login_response(), scsidev_ready(), srp_login_rsp(), tcp_rx(), tls_new_finished(), tls_tx_step(), xfer_vredirect(), and xfer_window_changed().

◆ xfer_alloc_iob()

struct io_buffer* xfer_alloc_iob ( struct interface intf,
size_t  len 
)

Allocate I/O buffer.

Parameters
intfData transfer interface
lenI/O buffer payload length
Return values
iobufI/O buffer

Definition at line 157 of file xfer.c.

157  {
158  struct interface *dest;
159  xfer_alloc_iob_TYPE ( void * ) *op =
161  void *object = intf_object ( dest );
162  struct io_buffer *iobuf;
163 
164  DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " alloc_iob %zd\n",
165  INTF_INTF_DBG ( intf, dest ), len );
166 
167  if ( op ) {
168  iobuf = op ( object, len );
169  } else {
170  /* Default is to allocate an I/O buffer with no
171  * reserved space.
172  */
173  iobuf = alloc_iob ( len );
174  }
175 
176  if ( ! iobuf ) {
177  DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " alloc_iob "
178  "failed\n", INTF_INTF_DBG ( intf, dest ) );
179  }
180 
181  intf_put ( dest );
182  return iobuf;
183 }
#define INTF_INTF_FMT
printf() format string for INTF_INTF_DBG()
Definition: interface.h:240
#define INTF_INTF_DBG(intf, dest)
printf() arguments for representing an object interface pair
Definition: interface.h:249
#define INTF_COL(intf)
Find debugging colourisation for an object interface.
Definition: interface.h:226
#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:157
struct io_buffer * alloc_iob(size_t len)
Allocate I/O buffer.
Definition: iobuf.c:128
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:154
An object interface.
Definition: interface.h:109
static void * dest
Definition: strings.h:176
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint32_t len
Length.
Definition: ena.h:14
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:144
#define xfer_alloc_iob_TYPE(object_type)
Definition: xfer.h:82
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:214
A persistent I/O buffer.
Definition: iobuf.h:32

References alloc_iob(), DBGC, dest, INTF_COL, intf_get_dest_op, INTF_INTF_DBG, INTF_INTF_FMT, intf_object(), intf_put(), len, op, xfer_alloc_iob(), and xfer_alloc_iob_TYPE.

Referenced by dhcp_tx(), dhcpv6_tx(), efi_local_step(), efi_pxe_udp_write(), fc_xchg_alloc_iob(), fcpcmd_send_cmnd(), fcpcmd_send_wrdata(), iscsi_tx_data_out(), iscsi_tx_login_request(), pinger_expired(), pxenv_udp_write(), slam_tx_nack(), srp_cmd(), srp_login(), tftp_send_ack(), tftp_send_error(), tftp_send_rrq(), tls_send_plaintext(), xfer_alloc_iob(), xfer_deliver_raw_meta(), and xfer_seek().

◆ xfer_deliver()

int xfer_deliver ( struct interface intf,
struct io_buffer iobuf,
struct xfer_metadata meta 
)

Deliver datagram.

Parameters
intfData transfer interface
iobufDatagram I/O buffer
metaData transfer metadata
Return values
rcReturn status code

Definition at line 193 of file xfer.c.

195  {
196  struct interface *dest;
197  xfer_deliver_TYPE ( void * ) *op =
198  intf_get_dest_op ( intf, xfer_deliver, &dest );
199  void *object = intf_object ( dest );
200  int rc;
201 
202  DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT " deliver %zd\n",
203  INTF_INTF_DBG ( intf, dest ), iob_len ( iobuf ) );
204 
205  if ( op ) {
206  rc = op ( object, iobuf, meta );
207  } else {
208  /* Default is to discard the I/O buffer */
209  free_iob ( iobuf );
210  rc = -EPIPE;
211  }
212 
213  if ( rc != 0 ) {
214  DBGC ( INTF_COL ( intf ), "INTF " INTF_INTF_FMT
215  " deliver failed: %s\n",
216  INTF_INTF_DBG ( intf, dest ), strerror ( rc ) );
217  }
218 
219  intf_put ( dest );
220  return rc;
221 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define INTF_INTF_FMT
printf() format string for INTF_INTF_DBG()
Definition: interface.h:240
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:145
#define INTF_INTF_DBG(intf, dest)
printf() arguments for representing an object interface pair
Definition: interface.h:249
#define EPIPE
Broken pipe.
Definition: errno.h:619
#define INTF_COL(intf)
Find debugging colourisation for an object interface.
Definition: interface.h:226
#define DBGC(...)
Definition: compiler.h:505
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:154
#define xfer_deliver_TYPE(object_type)
Definition: xfer.h:88
An object interface.
Definition: interface.h:109
static void * dest
Definition: strings.h:176
int meta(WINDOW *, bool)
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:151
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:193
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:144
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:214

References DBGC, dest, EPIPE, free_iob(), INTF_COL, intf_get_dest_op, INTF_INTF_DBG, INTF_INTF_FMT, intf_object(), intf_put(), iob_len(), meta(), op, rc, strerror(), xfer_deliver(), and xfer_deliver_TYPE.

Referenced by dhcp_tx(), efi_pxe_udp_write(), fc_xchg_rx(), fcpcmd_send_cmnd(), fcpcmd_send_wrdata(), http_conn_socket_deliver(), http_content_deliver(), peerblk_deliver(), peermux_block_deliver(), ping_rx(), pinger_expired(), pxenv_udp_write(), slam_mc_socket_deliver(), tftp_rx_data(), tftp_send_ack(), tftp_send_error(), udp_rx(), xfer_buffer(), xfer_deliver(), xfer_deliver_iob(), xfer_deliver_raw_meta(), and xfer_seek().

◆ xfer_redirect()

int xfer_redirect ( struct interface intf,
int  type,
  ... 
)

Send redirection event.

Parameters
intfData transfer interface
typeNew location type
...Remaining arguments depend upon location type
Return values
rcReturn status code

Definition at line 237 of file xfer.c.

237  {
238  va_list args;
239  int rc;
240 
241  va_start ( args, type );
242  rc = xfer_vredirect ( intf, type, args );
243  va_end ( args );
244  return rc;
245 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define va_end(ap)
Definition: stdarg.h:9
uint8_t type
Type.
Definition: ena.h:16
int xfer_vredirect(struct interface *intf, int type, va_list args)
Send redirection event.
Definition: xfer.c:62
__builtin_va_list va_list
Definition: stdarg.h:6
#define va_start(ap, last)
Definition: stdarg.h:7

References rc, type, va_end, va_start, and xfer_vredirect().

Referenced by http_redirect(), and named_resolv_done().

◆ xfer_deliver_iob()

int xfer_deliver_iob ( struct interface intf,
struct io_buffer iobuf 
)

Deliver datagram as I/O buffer without metadata.

Parameters
intfData transfer interface
iobufDatagram I/O buffer
Return values
rcReturn status code

Definition at line 254 of file xfer.c.

254  {
255  return xfer_deliver ( intf, iobuf, &dummy_metadata );
256 }
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:193
static struct xfer_metadata dummy_metadata
Dummy transfer metadata.
Definition: xfer.c:46

References dummy_metadata, and xfer_deliver().

Referenced by dhcpv6_tx(), efi_local_step(), fc_xchg_tx(), fcoe_rx(), http_rx_chunk_data(), http_rx_transfer_identity(), http_tx_request(), ib_cmrc_complete_recv(), iscsi_tx_data_out(), iscsi_tx_login_request(), nfs_deliver(), oncrpc_call(), slam_tx_nack(), srp_cmd(), srp_login(), tcp_rx_data(), tftp_send_rrq(), tls_new_record(), and tls_send_plaintext().

◆ xfer_deliver_raw_meta()

int xfer_deliver_raw_meta ( struct interface intf,
const void *  data,
size_t  len,
struct xfer_metadata meta 
)

Deliver datagram as raw data.

Parameters
intfData transfer interface
dataData
lenLength of data
metaData transfer metadata
Return values
rcReturn status code

Definition at line 267 of file xfer.c.

268  {
269  struct io_buffer *iobuf;
270 
271  iobuf = xfer_alloc_iob ( intf, len );
272  if ( ! iobuf )
273  return -ENOMEM;
274 
275  memcpy ( iob_put ( iobuf, len ), data, len );
276  return xfer_deliver ( intf, iobuf, meta );
277 }
#define iob_put(iobuf, len)
Definition: iobuf.h:116
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
Definition: xfer.c:157
#define ENOMEM
Not enough space.
Definition: errno.h:534
void * memcpy(void *dest, const void *src, size_t len) __nonnull
int meta(WINDOW *, bool)
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:193
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
A persistent I/O buffer.
Definition: iobuf.h:32

References data, ENOMEM, iob_put, len, memcpy(), meta(), xfer_alloc_iob(), and xfer_deliver().

Referenced by dns_send_packet(), fc_els_tx(), fc_ns_query_step(), peerdisc_socket_tx(), and xfer_deliver_raw().

◆ xfer_deliver_raw()

int xfer_deliver_raw ( struct interface intf,
const void *  data,
size_t  len 
)

Deliver datagram as raw data without metadata.

Parameters
intfData transfer interface
dataData
lenLength of data
Return values
rcReturn status code

Definition at line 287 of file xfer.c.

287  {
288  return xfer_deliver_raw_meta ( intf, data, len, &dummy_metadata );
289 }
int xfer_deliver_raw_meta(struct interface *intf, const void *data, size_t len, struct xfer_metadata *meta)
Deliver datagram as raw data.
Definition: xfer.c:267
uint32_t len
Length.
Definition: ena.h:14
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
static struct xfer_metadata dummy_metadata
Dummy transfer metadata.
Definition: xfer.c:46

References data, dummy_metadata, len, and xfer_deliver_raw_meta().

Referenced by fcoe_fip_rx_els_response(), hw_step(), ib_cmrc_changed(), iscsi_tx_bhs(), ntp_request(), slam_finished(), xcm_step(), xfer_vprintf(), xsmp_tx_session(), and xsmp_tx_xve().

◆ xfer_vprintf()

int xfer_vprintf ( struct interface intf,
const char *  format,
va_list  args 
)

Deliver formatted string.

Parameters
intfData transfer interface
formatFormat string
argsArguments corresponding to the format string
Return values
rcReturn status code

Definition at line 299 of file xfer.c.

300  {
301  va_list args_tmp;
302  char *buf;
303  int len;
304  int rc;
305 
306  /* Create temporary string */
307  va_copy ( args_tmp, args );
308  len = vasprintf ( &buf, format, args );
309  va_end ( args_tmp );
310  if ( len < 0 ) {
311  rc = len;
312  goto err_asprintf;
313  }
314 
315  /* Transmit string */
316  if ( ( rc = xfer_deliver_raw ( intf, buf, len ) ) != 0 )
317  goto err_deliver;
318 
319  err_deliver:
320  free ( buf );
321  err_asprintf:
322  return rc;
323 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define va_end(ap)
Definition: stdarg.h:9
#define va_copy(dest, src)
Definition: stdarg.h:10
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition: xfer.c:287
int vasprintf(char **strp, const char *fmt, va_list args)
Write a formatted string to newly allocated memory.
Definition: asprintf.c:17
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
uint32_t len
Length.
Definition: ena.h:14
__builtin_va_list va_list
Definition: stdarg.h:6
int const char * format
Definition: xfer.h:104

References format, free, len, rc, va_copy, va_end, vasprintf(), and xfer_deliver_raw().

Referenced by xfer_printf().

◆ xfer_printf()

int xfer_printf ( struct interface intf,
const char *  format,
  ... 
)

Deliver formatted string.

Parameters
intfData transfer interface
formatFormat string
...Arguments corresponding to the format string
Return values
rcReturn status code

Definition at line 333 of file xfer.c.

333  {
334  va_list args;
335  int rc;
336 
337  va_start ( args, format );
338  rc = xfer_vprintf ( intf, format, args );
339  va_end ( args );
340  return rc;
341 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define va_end(ap)
Definition: stdarg.h:9
int xfer_vprintf(struct interface *intf, const char *format, va_list args)
Deliver formatted string.
Definition: xfer.c:299
__builtin_va_list va_list
Definition: stdarg.h:6
#define va_start(ap, last)
Definition: stdarg.h:7
int const char * format
Definition: xfer.h:104

References format, rc, va_end, va_start, and xfer_vprintf().

Referenced by ftp_next_state(), and syslog_send().

◆ xfer_seek()

int xfer_seek ( struct interface intf,
off_t  offset 
)

Seek to position.

Parameters
intfData transfer interface
offsetOffset to new position
Return values
rcReturn status code

Definition at line 350 of file xfer.c.

350  {
351  struct io_buffer *iobuf;
352  struct xfer_metadata meta = {
353  .flags = XFER_FL_ABS_OFFSET,
354  .offset = offset,
355  };
356 
357  DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " seek to %ld\n",
358  INTF_DBG ( intf ), offset );
359 
360  /* Allocate and send a zero-length data buffer */
361  iobuf = xfer_alloc_iob ( intf, 0 );
362  if ( ! iobuf )
363  return -ENOMEM;
364 
365  return xfer_deliver ( intf, iobuf, &meta );
366 }
Data transfer metadata.
Definition: xfer.h:22
#define INTF_DBG(intf)
printf() arguments for representing an object interface
Definition: interface.h:237
#define XFER_FL_ABS_OFFSET
Offset is absolute.
Definition: xfer.h:47
#define INTF_COL(intf)
Find debugging colourisation for an object interface.
Definition: interface.h:226
#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:157
#define ENOMEM
Not enough space.
Definition: errno.h:534
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
int meta(WINDOW *, bool)
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:193
#define INTF_FMT
printf() format string for INTF_DBG()
Definition: interface.h:229
A persistent I/O buffer.
Definition: iobuf.h:32

References DBGC, ENOMEM, INTF_COL, INTF_DBG, INTF_FMT, meta(), offset, xfer_alloc_iob(), xfer_deliver(), and XFER_FL_ABS_OFFSET.

Referenced by efi_local_step(), ftp_reply(), http_rx_chunk_len(), http_rx_headers(), nfs_deliver(), peermux_info_close(), slam_pull_header(), and tftp_presize().

◆ xfer_check_order()

int xfer_check_order ( struct xfer_metadata meta,
size_t pos,
size_t  len 
)

Check that data is delivered strictly in order.

Parameters
metaData transfer metadata
posCurrent position
lenLength of data
Return values
rcReturn status code

Definition at line 376 of file xfer.c.

376  {
377  size_t new_pos;
378 
379  /* Allow out-of-order zero-length packets (as used by xfer_seek()) */
380  if ( len == 0 )
381  return 0;
382 
383  /* Calculate position of this delivery */
384  new_pos = *pos;
385  if ( meta->flags & XFER_FL_ABS_OFFSET )
386  new_pos = 0;
387  new_pos += meta->offset;
388 
389  /* Fail if delivery position is not equal to current position */
390  if ( new_pos != *pos )
391  return -EPROTO;
392 
393  /* Update current position */
394  *pos += len;
395 
396  return 0;
397 }
#define XFER_FL_ABS_OFFSET
Offset is absolute.
Definition: xfer.h:47
#define EPROTO
Protocol error.
Definition: errno.h:624
int meta(WINDOW *, bool)
uint32_t len
Length.
Definition: ena.h:14

References EPROTO, len, meta(), and XFER_FL_ABS_OFFSET.

Referenced by peerblk_raw_rx().

Variable Documentation

◆ dummy_metadata

struct xfer_metadata dummy_metadata
static

Dummy transfer metadata.

This gets passed to xfer_interface::deliver() and equivalents when no metadata is available.

Definition at line 46 of file xfer.c.

Referenced by xfer_deliver_iob(), and xfer_deliver_raw().