iPXE
open.h
Go to the documentation of this file.
00001 #ifndef _IPXE_OPEN_H
00002 #define _IPXE_OPEN_H
00003 
00004 /** @file
00005  *
00006  * Data transfer interface opening
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <stdarg.h>
00013 #include <ipxe/tables.h>
00014 #include <ipxe/socket.h>
00015 
00016 struct uri;
00017 struct interface;
00018 
00019 /** Location types */
00020 enum {
00021         /** Location is a URI
00022          *
00023          * Parameter list for open() is:
00024          *
00025          * struct uri *uri;
00026          */
00027         LOCATION_URI = 1,
00028         /** Location is a URI string
00029          *
00030          * Parameter list for open() is:
00031          *
00032          * const char *uri_string;
00033          */
00034         LOCATION_URI_STRING,
00035         /** Location is a socket
00036          *
00037          * Parameter list for open() is:
00038          *
00039          * int semantics;
00040          * struct sockaddr *peer;
00041          * struct sockaddr *local;
00042          */
00043         LOCATION_SOCKET,
00044 };
00045 
00046 /** A URI opener */
00047 struct uri_opener {
00048         /** URI protocol name
00049          *
00050          * This is the "scheme" portion of the URI, e.g. "http" or
00051          * "file".
00052          */
00053         const char *scheme;
00054         /** Open URI
00055          *
00056          * @v intf              Object interface
00057          * @v uri               URI
00058          * @ret rc              Return status code
00059          */
00060         int ( * open ) ( struct interface *intf, struct uri *uri );
00061 };
00062 
00063 /** URI opener table */
00064 #define URI_OPENERS __table ( struct uri_opener, "uri_openers" )
00065 
00066 /** Register a URI opener */
00067 #define __uri_opener __table_entry ( URI_OPENERS, 01 )
00068 
00069 /** A socket opener */
00070 struct socket_opener {
00071         /** Communication semantics (e.g. SOCK_STREAM) */
00072         int semantics;
00073         /** Address family (e.g. AF_INET) */
00074         int family;
00075         /** Open socket
00076          *
00077          * @v intf              Object interface
00078          * @v peer              Peer socket address
00079          * @v local             Local socket address, or NULL
00080          * @ret rc              Return status code
00081          */
00082         int ( * open ) ( struct interface *intf, struct sockaddr *peer,
00083                          struct sockaddr *local );
00084 };
00085 
00086 /** Socket opener table */
00087 #define SOCKET_OPENERS __table ( struct socket_opener, "socket_openers" )
00088 
00089 /** Register a socket opener */
00090 #define __socket_opener __table_entry ( SOCKET_OPENERS, 01 )
00091 
00092 extern struct uri_opener * xfer_uri_opener ( const char *scheme );
00093 extern int xfer_open_uri ( struct interface *intf, struct uri *uri );
00094 extern int xfer_open_uri_string ( struct interface *intf,
00095                                   const char *uri_string );
00096 extern int xfer_open_named_socket ( struct interface *intf, int semantics,
00097                                     struct sockaddr *peer, const char *name,
00098                                     struct sockaddr *local );
00099 extern int xfer_open_socket ( struct interface *intf, int semantics,
00100                               struct sockaddr *peer, struct sockaddr *local );
00101 extern int xfer_vopen ( struct interface *intf, int type, va_list args );
00102 extern int xfer_open ( struct interface *intf, int type, ... );
00103 extern int xfer_vreopen ( struct interface *intf, int type,
00104                           va_list args );
00105 
00106 #endif /* _IPXE_OPEN_H */