summaryrefslogtreecommitdiffstats
path: root/src/core/open.c
diff options
context:
space:
mode:
authorMichael Brown2010-06-16 02:31:29 +0200
committerMichael Brown2010-06-22 16:50:31 +0200
commit4327d5d39f101f1df0ace6c03f3b3ada5f6a6213 (patch)
treeccf92bdfd23046b6c7f64f87b57350f02f63ad6f /src/core/open.c
parent[interface] Convert all name-resolution interfaces to generic interfaces (diff)
downloadipxe-4327d5d39f101f1df0ace6c03f3b3ada5f6a6213.tar.gz
ipxe-4327d5d39f101f1df0ace6c03f3b3ada5f6a6213.tar.xz
ipxe-4327d5d39f101f1df0ace6c03f3b3ada5f6a6213.zip
[interface] Convert all data-xfer interfaces to generic interfaces
Remove data-xfer as an interface type, and replace data-xfer interfaces with generic interfaces supporting the data-xfer methods. Filter interfaces (as used by the TLS layer) are handled using the generic pass-through interface capability. A side-effect of this is that deliver_raw() no longer exists as a data-xfer method. (In practice this doesn't lose any efficiency, since there are no instances within the current codebase where xfer_deliver_raw() is used to pass data to an interface supporting the deliver_raw() method.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/open.c')
-rw-r--r--src/core/open.c69
1 files changed, 37 insertions, 32 deletions
diff --git a/src/core/open.c b/src/core/open.c
index 58edef56..f8ee9f3a 100644
--- a/src/core/open.c
+++ b/src/core/open.c
@@ -35,14 +35,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
/**
* Open URI
*
- * @v xfer Data transfer interface
+ * @v intf Data transfer interface
* @v uri URI
* @ret rc Return status code
*
* The URI will be regarded as being relative to the current working
* URI (see churi()).
*/
-int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
+int xfer_open_uri ( struct interface *intf, struct uri *uri ) {
struct uri_opener *opener;
struct uri *resolved_uri;
int rc = -ENOTSUP;
@@ -55,14 +55,16 @@ int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
/* Find opener which supports this URI scheme */
for_each_table_entry ( opener, URI_OPENERS ) {
if ( strcmp ( resolved_uri->scheme, opener->scheme ) == 0 ) {
- DBGC ( xfer, "XFER %p opening %s URI\n",
- xfer, opener->scheme );
- rc = opener->open ( xfer, resolved_uri );
+ DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT
+ " opening %s URI\n", INTF_DBG ( intf ),
+ resolved_uri->scheme );
+ rc = opener->open ( intf, resolved_uri );
goto done;
}
}
- DBGC ( xfer, "XFER %p attempted to open unsupported URI scheme "
- "\"%s\"\n", xfer, resolved_uri->scheme );
+ DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " attempted to open "
+ "unsupported URI scheme \"%s\"\n",
+ INTF_DBG ( intf ), resolved_uri->scheme );
done:
uri_put ( resolved_uri );
@@ -72,25 +74,26 @@ int xfer_open_uri ( struct xfer_interface *xfer, struct uri *uri ) {
/**
* Open URI string
*
- * @v xfer Data transfer interface
+ * @v intf Data transfer interface
* @v uri_string URI string (e.g. "http://ipxe.org/kernel")
* @ret rc Return status code
*
* The URI will be regarded as being relative to the current working
* URI (see churi()).
*/
-int xfer_open_uri_string ( struct xfer_interface *xfer,
+int xfer_open_uri_string ( struct interface *intf,
const char *uri_string ) {
struct uri *uri;
int rc;
- DBGC ( xfer, "XFER %p opening URI %s\n", xfer, uri_string );
+ DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " opening URI %s\n",
+ INTF_DBG ( intf ), uri_string );
uri = parse_uri ( uri_string );
if ( ! uri )
return -ENOMEM;
- rc = xfer_open_uri ( xfer, uri );
+ rc = xfer_open_uri ( intf, uri );
uri_put ( uri );
return rc;
@@ -99,29 +102,30 @@ int xfer_open_uri_string ( struct xfer_interface *xfer,
/**
* Open socket
*
- * @v xfer Data transfer interface
+ * @v intf Data transfer interface
* @v semantics Communication semantics (e.g. SOCK_STREAM)
* @v peer Peer socket address
* @v local Local socket address, or NULL
* @ret rc Return status code
*/
-int xfer_open_socket ( struct xfer_interface *xfer, int semantics,
+int xfer_open_socket ( struct interface *intf, int semantics,
struct sockaddr *peer, struct sockaddr *local ) {
struct socket_opener *opener;
- DBGC ( xfer, "XFER %p opening (%s,%s) socket\n", xfer,
- socket_semantics_name ( semantics ),
+ DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " opening (%s,%s) socket\n",
+ INTF_DBG ( intf ), socket_semantics_name ( semantics ),
socket_family_name ( peer->sa_family ) );
for_each_table_entry ( opener, SOCKET_OPENERS ) {
if ( ( opener->semantics == semantics ) &&
( opener->family == peer->sa_family ) ) {
- return opener->open ( xfer, peer, local );
+ return opener->open ( intf, peer, local );
}
}
- DBGC ( xfer, "XFER %p attempted to open unsupported socket type "
- "(%s,%s)\n", xfer, socket_semantics_name ( semantics ),
+ DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " attempted to open "
+ "unsupported socket type (%s,%s)\n",
+ INTF_DBG ( intf ), socket_semantics_name ( semantics ),
socket_family_name ( peer->sa_family ) );
return -ENOTSUP;
}
@@ -129,30 +133,31 @@ int xfer_open_socket ( struct xfer_interface *xfer, int semantics,
/**
* Open location
*
- * @v xfer Data transfer interface
+ * @v intf Data transfer interface
* @v type Location type
* @v args Remaining arguments depend upon location type
* @ret rc Return status code
*/
-int xfer_vopen ( struct xfer_interface *xfer, int type, va_list args ) {
+int xfer_vopen ( struct interface *intf, int type, va_list args ) {
switch ( type ) {
case LOCATION_URI_STRING: {
const char *uri_string = va_arg ( args, const char * );
- return xfer_open_uri_string ( xfer, uri_string ); }
+ return xfer_open_uri_string ( intf, uri_string ); }
case LOCATION_URI: {
struct uri *uri = va_arg ( args, struct uri * );
- return xfer_open_uri ( xfer, uri ); }
+ return xfer_open_uri ( intf, uri ); }
case LOCATION_SOCKET: {
int semantics = va_arg ( args, int );
struct sockaddr *peer = va_arg ( args, struct sockaddr * );
struct sockaddr *local = va_arg ( args, struct sockaddr * );
- return xfer_open_socket ( xfer, semantics, peer, local ); }
+ return xfer_open_socket ( intf, semantics, peer, local ); }
default:
- DBGC ( xfer, "XFER %p attempted to open unsupported location "
- "type %d\n", xfer, type );
+ DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " attempted to "
+ "open unsupported location type %d\n",
+ INTF_DBG ( intf ), type );
return -ENOTSUP;
}
}
@@ -160,17 +165,17 @@ int xfer_vopen ( struct xfer_interface *xfer, int type, va_list args ) {
/**
* Open location
*
- * @v xfer Data transfer interface
+ * @v intf Data transfer interface
* @v type Location type
* @v ... Remaining arguments depend upon location type
* @ret rc Return status code
*/
-int xfer_open ( struct xfer_interface *xfer, int type, ... ) {
+int xfer_open ( struct interface *intf, int type, ... ) {
va_list args;
int rc;
va_start ( args, type );
- rc = xfer_vopen ( xfer, type, args );
+ rc = xfer_vopen ( intf, type, args );
va_end ( args );
return rc;
}
@@ -178,7 +183,7 @@ int xfer_open ( struct xfer_interface *xfer, int type, ... ) {
/**
* Reopen location
*
- * @v xfer Data transfer interface
+ * @v intf Data transfer interface
* @v type Location type
* @v args Remaining arguments depend upon location type
* @ret rc Return status code
@@ -187,11 +192,11 @@ int xfer_open ( struct xfer_interface *xfer, int type, ... ) {
* using xfer_vopen(). It is intended to be used as a .vredirect
* method handler.
*/
-int xfer_vreopen ( struct xfer_interface *xfer, int type, va_list args ) {
+int xfer_vreopen ( struct interface *intf, int type, va_list args ) {
/* Close existing connection */
- xfer_close ( xfer, 0 );
+ intf_restart ( intf, 0 );
/* Open new location */
- return xfer_vopen ( xfer, type, args );
+ return xfer_vopen ( intf, type, args );
}