iPXE
xfer.h
Go to the documentation of this file.
00001 #ifndef _IPXE_XFER_H
00002 #define _IPXE_XFER_H
00003 
00004 /** @file
00005  *
00006  * Data transfer interfaces
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stddef.h>
00013 #include <stdarg.h>
00014 #include <ipxe/interface.h>
00015 
00016 struct xfer_metadata;
00017 struct io_buffer;
00018 struct sockaddr;
00019 struct net_device;
00020 
00021 /** Data transfer metadata */
00022 struct xfer_metadata {
00023         /** Flags
00024          *
00025          * This is the bitwise OR of zero or more @c XFER_FL_XXX
00026          * constants.
00027          */
00028         unsigned int flags;
00029         /** Offset of data within stream
00030          *
00031          * This is an absolute offset if the @c XFER_FL_ABS_OFFSET
00032          * flag is set, otherwise a relative offset.  (A freshly
00033          * zeroed @c xfer_metadata structure therefore represents a
00034          * relative offset of zero, i.e. no offset from the current
00035          * position.)
00036          */
00037         off_t offset;
00038         /** Source socket address, or NULL */
00039         struct sockaddr *src;
00040         /** Destination socket address, or NULL */
00041         struct sockaddr *dest;
00042         /** Network device, or NULL */
00043         struct net_device *netdev;
00044 };
00045 
00046 /** Offset is absolute */
00047 #define XFER_FL_ABS_OFFSET 0x0001
00048 
00049 /** Sender is relinquishing use of half-duplex channel */
00050 #define XFER_FL_OVER 0x0002
00051 
00052 /** This is the final data transfer */
00053 #define XFER_FL_OUT 0x0004
00054 
00055 /** Data content represents a command or status message
00056  *
00057  * The flag @c XFER_FL_RESPONSE is used to distinguish between a
00058  * command message and a status message.
00059  */
00060 #define XFER_FL_CMD_STAT 0x0008
00061 
00062 /** Data content is a response */
00063 #define XFER_FL_RESPONSE 0x0010
00064 
00065 /* Data transfer interface operations */
00066 
00067 extern int xfer_vredirect ( struct interface *intf, int type,
00068                             va_list args );
00069 #define xfer_vredirect_TYPE( object_type ) \
00070         typeof ( int ( object_type, int type, va_list args ) )
00071 
00072 extern size_t xfer_window ( struct interface *intf );
00073 #define xfer_window_TYPE( object_type ) \
00074         typeof ( size_t ( object_type ) )
00075 
00076 extern void xfer_window_changed ( struct interface *intf );
00077 #define xfer_window_changed_TYPE( object_type ) \
00078         typeof ( void ( object_type ) )
00079 
00080 extern struct io_buffer * xfer_alloc_iob ( struct interface *intf,
00081                                            size_t len );
00082 #define xfer_alloc_iob_TYPE( object_type ) \
00083         typeof ( struct io_buffer * ( object_type, size_t len ) )
00084 
00085 extern int xfer_deliver ( struct interface *intf,
00086                           struct io_buffer *iobuf,
00087                           struct xfer_metadata *meta );
00088 #define xfer_deliver_TYPE( object_type )                        \
00089         typeof ( int ( object_type, struct io_buffer *iobuf,    \
00090                        struct xfer_metadata *meta ) )
00091 
00092 /* Data transfer interface helper functions */
00093 
00094 extern int xfer_redirect ( struct interface *xfer, int type, ... );
00095 extern int xfer_deliver_iob ( struct interface *intf,
00096                               struct io_buffer *iobuf );
00097 extern int xfer_deliver_raw_meta ( struct interface *intf, const void *data,
00098                                    size_t len, struct xfer_metadata *meta );
00099 extern int xfer_deliver_raw ( struct interface *intf,
00100                               const void *data, size_t len );
00101 extern int xfer_vprintf ( struct interface *intf,
00102                           const char *format, va_list args );
00103 extern int __attribute__ (( format ( printf, 2, 3 ) ))
00104 xfer_printf ( struct interface *intf, const char *format, ... );
00105 extern int xfer_seek ( struct interface *intf, off_t offset );
00106 extern int xfer_check_order ( struct xfer_metadata *meta, size_t *pos,
00107                               size_t len );
00108 
00109 #endif /* _IPXE_XFER_H */