[contrib] Allow Network Protocol header to display in rom-o-matic
[gpxe.git] / src / include / gpxe / open.h
blobebf754da6b0b25c1b765eacbfceb827ead5cdbd8
1 #ifndef _GPXE_OPEN_H
2 #define _GPXE_OPEN_H
4 /** @file
6 * Data transfer interface opening
8 */
10 FILE_LICENCE ( GPL2_OR_LATER );
12 #include <stdarg.h>
13 #include <gpxe/tables.h>
14 #include <gpxe/socket.h>
16 struct xfer_interface;
17 struct uri;
19 /** Location types */
20 enum {
21 /** Location is a URI
23 * Parameter list for open() is:
25 * struct uri *uri;
27 LOCATION_URI = 1,
28 /** Location is a URI string
30 * Parameter list for open() is:
32 * const char *uri_string;
34 LOCATION_URI_STRING,
35 /** Location is a socket
37 * Parameter list for open() is:
39 * int semantics;
40 * struct sockaddr *peer;
41 * struct sockaddr *local;
43 LOCATION_SOCKET,
46 /** A URI opener */
47 struct uri_opener {
48 /** URI protocol name
50 * This is the "scheme" portion of the URI, e.g. "http" or
51 * "file".
53 const char *scheme;
54 /** Open URI
56 * @v xfer Data transfer interface
57 * @v uri URI
58 * @ret rc Return status code
60 int ( * open ) ( struct xfer_interface *xfer, struct uri *uri );
63 /** URI opener table */
64 #define URI_OPENERS __table ( struct uri_opener, "uri_openers" )
66 /** Register a URI opener */
67 #define __uri_opener __table_entry ( URI_OPENERS, 01 )
69 /** A socket opener */
70 struct socket_opener {
71 /** Communication semantics (e.g. SOCK_STREAM) */
72 int semantics;
73 /** Address family (e.g. AF_INET) */
74 int family;
75 /** Open socket
77 * @v xfer Data transfer interface
78 * @v peer Peer socket address
79 * @v local Local socket address, or NULL
80 * @ret rc Return status code
82 int ( * open ) ( struct xfer_interface *xfer, struct sockaddr *peer,
83 struct sockaddr *local );
86 /** Socket opener table */
87 #define SOCKET_OPENERS __table ( struct socket_opener, "socket_openers" )
89 /** Register a socket opener */
90 #define __socket_opener __table_entry ( SOCKET_OPENERS, 01 )
92 extern int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri );
93 extern int xfer_open_uri_string ( struct xfer_interface *xfer,
94 const char *uri_string );
95 extern int xfer_open_named_socket ( struct xfer_interface *xfer,
96 int semantics, struct sockaddr *peer,
97 const char *name, struct sockaddr *local );
98 extern int xfer_open_socket ( struct xfer_interface *xfer, int semantics,
99 struct sockaddr *peer, struct sockaddr *local );
100 extern int xfer_vopen ( struct xfer_interface *xfer, int type, va_list args );
101 extern int xfer_open ( struct xfer_interface *xfer, int type, ... );
102 extern int xfer_vreopen ( struct xfer_interface *xfer, int type,
103 va_list args );
105 #endif /* _GPXE_OPEN_H */