iPXE
xfer.h
Go to the documentation of this file.
1 #ifndef _IPXE_XFER_H
2 #define _IPXE_XFER_H
3 
4 /** @file
5  *
6  * Data transfer interfaces
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stddef.h>
13 #include <stdarg.h>
14 #include <ipxe/interface.h>
15 
16 struct xfer_metadata;
17 struct io_buffer;
18 struct sockaddr;
19 struct net_device;
20 
21 /** Data transfer metadata */
22 struct xfer_metadata {
23  /** Flags
24  *
25  * This is the bitwise OR of zero or more @c XFER_FL_XXX
26  * constants.
27  */
28  unsigned int flags;
29  /** Offset of data within stream
30  *
31  * This is an absolute offset if the @c XFER_FL_ABS_OFFSET
32  * flag is set, otherwise a relative offset. (A freshly
33  * zeroed @c xfer_metadata structure therefore represents a
34  * relative offset of zero, i.e. no offset from the current
35  * position.)
36  */
38  /** Source socket address, or NULL */
39  struct sockaddr *src;
40  /** Destination socket address, or NULL */
41  struct sockaddr *dest;
42  /** Network device, or NULL */
43  struct net_device *netdev;
44 };
45 
46 /** Offset is absolute */
47 #define XFER_FL_ABS_OFFSET 0x0001
48 
49 /** Sender is relinquishing use of half-duplex channel */
50 #define XFER_FL_OVER 0x0002
51 
52 /** This is the final data transfer */
53 #define XFER_FL_OUT 0x0004
54 
55 /** Data content represents a command or status message
56  *
57  * The flag @c XFER_FL_RESPONSE is used to distinguish between a
58  * command message and a status message.
59  */
60 #define XFER_FL_CMD_STAT 0x0008
61 
62 /** Data content is a response */
63 #define XFER_FL_RESPONSE 0x0010
64 
65 /* Data transfer interface operations */
66 
67 extern int xfer_vredirect ( struct interface *intf, int type,
68  va_list args );
69 #define xfer_vredirect_TYPE( object_type ) \
70  typeof ( int ( object_type, int type, va_list args ) )
71 
72 extern size_t xfer_window ( struct interface *intf );
73 #define xfer_window_TYPE( object_type ) \
74  typeof ( size_t ( object_type ) )
75 
76 extern void xfer_window_changed ( struct interface *intf );
77 #define xfer_window_changed_TYPE( object_type ) \
78  typeof ( void ( object_type ) )
79 
80 extern struct io_buffer * xfer_alloc_iob ( struct interface *intf,
81  size_t len );
82 #define xfer_alloc_iob_TYPE( object_type ) \
83  typeof ( struct io_buffer * ( object_type, size_t len ) )
84 
85 extern int xfer_deliver ( struct interface *intf,
86  struct io_buffer *iobuf,
87  struct xfer_metadata *meta );
88 #define xfer_deliver_TYPE( object_type ) \
89  typeof ( int ( object_type, struct io_buffer *iobuf, \
90  struct xfer_metadata *meta ) )
91 
92 /* Data transfer interface helper functions */
93 
94 extern int xfer_redirect ( struct interface *xfer, int type, ... );
95 extern int xfer_deliver_iob ( struct interface *intf,
96  struct io_buffer *iobuf );
97 extern int xfer_deliver_raw_meta ( struct interface *intf, const void *data,
98  size_t len, struct xfer_metadata *meta );
99 extern int xfer_deliver_raw ( struct interface *intf,
100  const void *data, size_t len );
101 extern int xfer_vprintf ( struct interface *intf,
102  const char *format, va_list args );
103 extern int __attribute__ (( format ( printf, 2, 3 ) ))
104 xfer_printf ( struct interface *intf, const char *format, ... );
105 extern int xfer_seek ( struct interface *intf, off_t offset );
106 extern int xfer_check_order ( struct xfer_metadata *meta, size_t *pos,
107  size_t len );
108 
109 #endif /* _IPXE_XFER_H */
int const char int xfer_seek(struct interface *intf, off_t offset)
Seek to position.
Definition: xfer.c:350
Data transfer metadata.
Definition: xfer.h:22
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition: xfer.c:287
uint8_t type
Type.
Definition: ena.h:16
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:193
int xfer_vprintf(struct interface *intf, const char *format, va_list args)
Deliver formatted string.
Definition: xfer.c:299
struct net_device * netdev
Network device, or NULL.
Definition: xfer.h:43
An object interface.
Definition: interface.h:109
Object interfaces.
static userptr_t size_t offset
Offset of the first segment within the content.
Definition: deflate.h:259
int xfer_deliver_iob(struct interface *intf, struct io_buffer *iobuf)
Deliver datagram as I/O buffer without metadata.
Definition: xfer.c:254
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
int meta(WINDOW *, bool)
Generalized socket address structure.
Definition: socket.h:96
int __attribute__((format(printf, 2, 3))) xfer_printf(struct interface *intf
off_t offset
Offset of data within stream.
Definition: xfer.h:37
A network device.
Definition: netdevice.h:348
int xfer_vredirect(struct interface *intf, int type, va_list args)
Send redirection event.
Definition: xfer.c:62
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition: xfer.c:145
unsigned int flags
Flags.
Definition: xfer.h:28
struct sockaddr * src
Source socket address, or NULL.
Definition: xfer.h:39
int xfer_printf(struct interface *intf, const char *format,...)
Deliver formatted string.
Definition: xfer.c:333
size_t xfer_window(struct interface *intf)
Check flow control window.
Definition: xfer.c:115
signed long off_t
Definition: stdint.h:8
uint32_t len
Length.
Definition: ena.h:14
__builtin_va_list va_list
Definition: stdarg.h:6
struct sockaddr * dest
Destination socket address, or NULL.
Definition: xfer.h:41
int xfer_redirect(struct interface *xfer, int type,...)
Send redirection event.
Definition: xfer.c:237
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
int const char * format
Definition: xfer.h:104
A persistent I/O buffer.
Definition: iobuf.h:32
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
Definition: xfer.c:157
int xfer_check_order(struct xfer_metadata *meta, size_t *pos, size_t len)
Check that data is delivered strictly in order.
Definition: xfer.c:376