iPXE
open.h
Go to the documentation of this file.
1 #ifndef _IPXE_OPEN_H
2 #define _IPXE_OPEN_H
3 
4 /** @file
5  *
6  * Data transfer interface opening
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdarg.h>
13 #include <ipxe/tables.h>
14 #include <ipxe/socket.h>
15 
16 struct uri;
17 struct interface;
18 
19 /** Location types */
20 enum {
21  /** Location is a URI
22  *
23  * Parameter list for open() is:
24  *
25  * struct uri *uri;
26  */
28  /** Location is a URI string
29  *
30  * Parameter list for open() is:
31  *
32  * const char *uri_string;
33  */
35  /** Location is a socket
36  *
37  * Parameter list for open() is:
38  *
39  * int semantics;
40  * struct sockaddr *peer;
41  * struct sockaddr *local;
42  */
44 };
45 
46 /** A URI opener */
47 struct uri_opener {
48  /** URI protocol name
49  *
50  * This is the "scheme" portion of the URI, e.g. "http" or
51  * "file".
52  */
53  const char *scheme;
54  /** Open URI
55  *
56  * @v intf Object interface
57  * @v uri URI
58  * @ret rc Return status code
59  */
60  int ( * open ) ( struct interface *intf, struct uri *uri );
61 };
62 
63 /** URI opener table */
64 #define URI_OPENERS __table ( struct uri_opener, "uri_openers" )
65 
66 /** Register a URI opener */
67 #define __uri_opener __table_entry ( URI_OPENERS, 01 )
68 
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
76  *
77  * @v intf Object interface
78  * @v peer Peer socket address
79  * @v local Local socket address, or NULL
80  * @ret rc Return status code
81  */
82  int ( * open ) ( struct interface *intf, struct sockaddr *peer,
83  struct sockaddr *local );
84 };
85 
86 /** Socket opener table */
87 #define SOCKET_OPENERS __table ( struct socket_opener, "socket_openers" )
88 
89 /** Register a socket opener */
90 #define __socket_opener __table_entry ( SOCKET_OPENERS, 01 )
91 
92 extern struct uri_opener * xfer_uri_opener ( const char *scheme );
93 extern int xfer_open_uri ( struct interface *intf, struct uri *uri );
94 extern int xfer_open_uri_string ( struct interface *intf,
95  const char *uri_string );
96 extern int xfer_open_named_socket ( struct interface *intf, int semantics,
97  struct sockaddr *peer, const char *name,
98  struct sockaddr *local );
99 extern int xfer_open_socket ( struct interface *intf, int semantics,
100  struct sockaddr *peer, struct sockaddr *local );
101 extern int xfer_vopen ( struct interface *intf, int type, va_list args );
102 extern int xfer_open ( struct interface *intf, int type, ... );
103 extern int xfer_vreopen ( struct interface *intf, int type,
104  va_list args );
105 
106 #endif /* _IPXE_OPEN_H */
const char * name
Definition: ath9k_hw.c:1984
struct uri_opener * xfer_uri_opener(const char *scheme)
Find opener for URI scheme.
Definition: open.c:46
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint8_t type
Type.
Definition: ena.h:16
int xfer_vopen(struct interface *intf, int type, va_list args)
Open location.
Definition: open.c:171
int xfer_vreopen(struct interface *intf, int type, va_list args)
Reopen location.
Definition: open.c:225
int semantics
Communication semantics (e.g.
Definition: open.h:72
int xfer_open_uri_string(struct interface *intf, const char *uri_string)
Open URI string.
Definition: open.c:114
int(* open)(struct interface *intf, struct uri *uri)
Open URI.
Definition: open.h:60
An object interface.
Definition: interface.h:109
const char * scheme
URI protocol name.
Definition: open.h:53
int family
Address family (e.g.
Definition: open.h:74
Generalized socket address structure.
Definition: socket.h:96
int xfer_open_socket(struct interface *intf, int semantics, struct sockaddr *peer, struct sockaddr *local)
Open socket.
Definition: open.c:141
int(* open)(struct interface *intf, struct sockaddr *peer, struct sockaddr *local)
Open socket.
Definition: open.h:82
__builtin_va_list va_list
Definition: stdarg.h:6
int xfer_open_uri(struct interface *intf, struct uri *uri)
Open URI.
Definition: open.c:66
Location is a socket.
Definition: open.h:43
Linker tables.
Location is a URI string.
Definition: open.h:34
A Uniform Resource Identifier.
Definition: uri.h:50
int xfer_open(struct interface *intf, int type,...)
Open location.
Definition: open.c:203
int xfer_open_named_socket(struct interface *intf, int semantics, struct sockaddr *peer, const char *name, struct sockaddr *local)
Open named socket.
Definition: resolv.c:402
Socket addresses.
A URI opener.
Definition: open.h:47
Location is a URI.
Definition: open.h:27
A socket opener.
Definition: open.h:70