Ejemplo n.º 1
0
/**
 * Open location
 *
 * @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 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 ( intf, uri_string );
    }
    case LOCATION_URI: {
        struct uri *uri = va_arg ( args, struct 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 ( intf, semantics, peer, local );
    }
    default:
        DBGC ( INTF_COL ( intf ), "INTF " INTF_FMT " attempted to "
               "open unsupported location type %d\n",
               INTF_DBG ( intf ), type );
        return -ENOTSUP;
    }
}
Ejemplo n.º 2
0
Archivo: open.c Proyecto: 42wim/ipxe
/**
 * Open URI string
 *
 * @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 interface *intf,
			   const char *uri_string ) {
	struct uri *uri;
	int rc;

	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 ( intf, uri );

	uri_put ( uri );
	return rc;
}