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 FILE_SECBOOT ( PERMITTED );
12 
13 #include <stdarg.h>
14 #include <ipxe/tables.h>
15 #include <ipxe/socket.h>
16 
17 struct uri;
18 struct interface;
19 
20 /** Location types */
21 enum {
22  /** Location is a URI
23  *
24  * Parameter list for open() is:
25  *
26  * struct uri *uri;
27  */
29  /** Location is a URI string
30  *
31  * Parameter list for open() is:
32  *
33  * const char *uri_string;
34  */
36  /** Location is a socket
37  *
38  * Parameter list for open() is:
39  *
40  * int semantics;
41  * struct sockaddr *peer;
42  * struct sockaddr *local;
43  */
45 };
46 
47 /** A URI opener */
48 struct uri_opener {
49  /** URI protocol name
50  *
51  * This is the "scheme" portion of the URI, e.g. "http" or
52  * "file".
53  */
54  const char *scheme;
55  /** Open URI
56  *
57  * @v intf Object interface
58  * @v uri URI
59  * @ret rc Return status code
60  */
61  int ( * open ) ( struct interface *intf, struct uri *uri );
62 };
63 
64 /** URI opener table */
65 #define URI_OPENERS __table ( struct uri_opener, "uri_openers" )
66 
67 /** Register a URI opener */
68 #define __uri_opener __table_entry ( URI_OPENERS, 01 )
69 
70 /** A socket opener */
71 struct socket_opener {
72  /** Communication semantics (e.g. SOCK_STREAM) */
73  int semantics;
74  /** Open socket
75  *
76  * @v intf Object interface
77  * @v peer Peer socket address
78  * @v local Local socket address, or NULL
79  * @ret rc Return status code
80  */
81  int ( * open ) ( struct interface *intf, struct sockaddr *peer,
82  struct sockaddr *local );
83 };
84 
85 /** Socket opener table */
86 #define SOCKET_OPENERS __table ( struct socket_opener, "socket_openers" )
87 
88 /** Register a socket opener */
89 #define __socket_opener __table_entry ( SOCKET_OPENERS, 01 )
90 
91 extern struct uri_opener * xfer_uri_opener ( const char *scheme );
92 extern int xfer_open_uri ( struct interface *intf, struct uri *uri );
93 extern int xfer_open_uri_string ( struct interface *intf,
94  const char *uri_string );
95 extern int xfer_open_named_socket ( struct interface *intf, int semantics,
96  struct sockaddr *peer, const char *name,
97  struct sockaddr *local );
98 extern int xfer_open_socket ( struct interface *intf, int semantics,
99  struct sockaddr *peer, struct sockaddr *local );
100 extern int xfer_vopen ( struct interface *intf, int type, va_list args );
101 extern int xfer_open ( struct interface *intf, int type, ... );
102 extern int xfer_vreopen ( struct interface *intf, int type,
103  va_list args );
104 
105 #endif /* _IPXE_OPEN_H */
const char * name
Definition: ath9k_hw.c:1986
struct uri_opener * xfer_uri_opener(const char *scheme)
Find opener for URI scheme.
Definition: open.c:48
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint32_t type
Operating system type.
Definition: ena.h:12
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:73
int xfer_open_uri_string(struct interface *intf, const char *uri_string)
Open URI string.
Definition: open.c:116
struct interface * intf
Original interface.
Definition: interface.h:159
Location is a socket.
Definition: open.h:44
int(* open)(struct interface *intf, struct uri *uri)
Open URI.
Definition: open.h:61
Location is a URI string.
Definition: open.h:35
An object interface.
Definition: interface.h:125
Location is a URI.
Definition: open.h:28
const char * scheme
URI protocol name.
Definition: open.h:54
Generalized socket address structure.
Definition: socket.h:97
int xfer_open_socket(struct interface *intf, int semantics, struct sockaddr *peer, struct sockaddr *local)
Open socket.
Definition: open.c:143
int(* open)(struct interface *intf, struct sockaddr *peer, struct sockaddr *local)
Open socket.
Definition: open.h:81
__builtin_va_list va_list
Definition: stdarg.h:7
int xfer_open_uri(struct interface *intf, struct uri *uri)
Open URI.
Definition: open.c:68
Linker tables.
A Uniform Resource Identifier.
Definition: uri.h:65
int xfer_open(struct interface *intf, int type,...)
Open location.
Definition: open.c:203
struct mschapv2_challenge peer
Peer challenge.
Definition: mschapv2.h:12
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:403
Socket addresses.
A URI opener.
Definition: open.h:48
FILE_SECBOOT(PERMITTED)
A socket opener.
Definition: open.h:71