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  /** Open socket
74  *
75  * @v intf Object interface
76  * @v peer Peer socket address
77  * @v local Local socket address, or NULL
78  * @ret rc Return status code
79  */
80  int ( * open ) ( struct interface *intf, struct sockaddr *peer,
81  struct sockaddr *local );
82 };
83 
84 /** Socket opener table */
85 #define SOCKET_OPENERS __table ( struct socket_opener, "socket_openers" )
86 
87 /** Register a socket opener */
88 #define __socket_opener __table_entry ( SOCKET_OPENERS, 01 )
89 
90 extern struct uri_opener * xfer_uri_opener ( const char *scheme );
91 extern int xfer_open_uri ( struct interface *intf, struct uri *uri );
92 extern int xfer_open_uri_string ( struct interface *intf,
93  const char *uri_string );
94 extern int xfer_open_named_socket ( struct interface *intf, int semantics,
95  struct sockaddr *peer, const char *name,
96  struct sockaddr *local );
97 extern int xfer_open_socket ( struct interface *intf, int semantics,
98  struct sockaddr *peer, struct sockaddr *local );
99 extern int xfer_vopen ( struct interface *intf, int type, va_list args );
100 extern int xfer_open ( struct interface *intf, int type, ... );
101 extern int xfer_vreopen ( struct interface *intf, int type,
102  va_list args );
103 
104 #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:47
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
uint32_t type
Operating system type.
Definition: ena.h:12
Location is a socket.
Definition: open.h:43
int xfer_vopen(struct interface *intf, int type, va_list args)
Open location.
Definition: open.c:170
int xfer_vreopen(struct interface *intf, int type, va_list args)
Reopen location.
Definition: open.c:224
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:115
struct interface * intf
Original interface.
Definition: interface.h:158
int(* open)(struct interface *intf, struct uri *uri)
Open URI.
Definition: open.h:60
An object interface.
Definition: interface.h:124
const char * scheme
URI protocol name.
Definition: open.h:53
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:142
Location is a URI string.
Definition: open.h:34
int(* open)(struct interface *intf, struct sockaddr *peer, struct sockaddr *local)
Open socket.
Definition: open.h:80
__builtin_va_list va_list
Definition: stdarg.h:6
int xfer_open_uri(struct interface *intf, struct uri *uri)
Open URI.
Definition: open.c:67
Location is a URI.
Definition: open.h:27
Linker tables.
A Uniform Resource Identifier.
Definition: uri.h:64
int xfer_open(struct interface *intf, int type,...)
Open location.
Definition: open.c:202
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:402
Socket addresses.
A URI opener.
Definition: open.h:47
A socket opener.
Definition: open.h:70