.\" Automatically generated by Podwrapper::Man 1.6.1 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "nbd_connect_uri 3" .TH nbd_connect_uri 3 "2021-02-09" "libnbd-1.6.1" "LIBNBD" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" nbd_connect_uri \- connect to NBD URI .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& #include \& \& int nbd_connect_uri (struct nbd_handle *h, const char *uri); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Connect (synchronously) to an \s-1NBD\s0 server and export by specifying the \s-1NBD URI.\s0 This call parses the \s-1URI\s0 and calls \&\fBnbd_set_export_name\fR\|(3) and \fBnbd_set_tls\fR\|(3) and other calls as needed, followed by \fBnbd_connect_tcp\fR\|(3) or \&\fBnbd_connect_unix\fR\|(3). However, it is possible to override the export name portion of a \s-1URI\s0 by using \fBnbd_set_opt_mode\fR\|(3) to enable option mode, then using \fBnbd_set_export_name\fR\|(3) and \&\fBnbd_opt_go\fR\|(3) as part of subsequent negotiation. .PP This call returns when the connection has been made. .SS "Example URIs supported" .IX Subsection "Example URIs supported" .ie n .IP """nbd://example.com""" 4 .el .IP "\f(CWnbd://example.com\fR" 4 .IX Item "nbd://example.com" Connect over \s-1TCP,\s0 unencrypted, to \f(CW\*(C`example.com\*(C'\fR port 10809. .ie n .IP """nbds://example.com""" 4 .el .IP "\f(CWnbds://example.com\fR" 4 .IX Item "nbds://example.com" Connect over \s-1TCP\s0 with \s-1TLS,\s0 to \f(CW\*(C`example.com\*(C'\fR port 10809. If the server does not support \s-1TLS\s0 then this will fail. .ie n .IP """nbd+unix:///foo?socket=/tmp/nbd.sock""" 4 .el .IP "\f(CWnbd+unix:///foo?socket=/tmp/nbd.sock\fR" 4 .IX Item "nbd+unix:///foo?socket=/tmp/nbd.sock" Connect over the Unix domain socket \fI/tmp/nbd.sock\fR to an \s-1NBD\s0 server running locally. The export name is set to \f(CW\*(C`foo\*(C'\fR (note without any leading \f(CW\*(C`/\*(C'\fR character). .ie n .IP """nbd+vsock:///""" 4 .el .IP "\f(CWnbd+vsock:///\fR" 4 .IX Item "nbd+vsock:///" In this scenario libnbd is running in a virtual machine. Connect over \f(CW\*(C`AF_VSOCK\*(C'\fR to an \s-1NBD\s0 server running on the hypervisor. .SS "Supported \s-1URI\s0 formats" .IX Subsection "Supported URI formats" The following schemes are supported in the current version of libnbd: .ie n .IP """nbd:""" 4 .el .IP "\f(CWnbd:\fR" 4 .IX Item "nbd:" Connect over \s-1TCP\s0 without using \s-1TLS.\s0 .ie n .IP """nbds:""" 4 .el .IP "\f(CWnbds:\fR" 4 .IX Item "nbds:" Connect over \s-1TCP.\s0 \s-1TLS\s0 is required and the connection will fail if the server does not support \s-1TLS.\s0 .ie n .IP """nbd+unix:""" 4 .el .IP "\f(CWnbd+unix:\fR" 4 .IX Item "nbd+unix:" .PD 0 .ie n .IP """nbds+unix:""" 4 .el .IP "\f(CWnbds+unix:\fR" 4 .IX Item "nbds+unix:" .PD Connect over a Unix domain socket, without or with \s-1TLS\s0 respectively. The \f(CW\*(C`socket\*(C'\fR parameter is required. .ie n .IP """nbd+vsock:""" 4 .el .IP "\f(CWnbd+vsock:\fR" 4 .IX Item "nbd+vsock:" .PD 0 .ie n .IP """nbds+vsock:""" 4 .el .IP "\f(CWnbds+vsock:\fR" 4 .IX Item "nbds+vsock:" .PD Connect over the \f(CW\*(C`AF_VSOCK\*(C'\fR transport, without or with \&\s-1TLS\s0 respectively. .PP The authority part of the \s-1URI\s0 (\f(CW\*(C`[username@][servername][:port]\*(C'\fR) is parsed depending on the transport. For \s-1TCP\s0 it specifies the server to connect to and optional port number. For \f(CW\*(C`+unix\*(C'\fR it should not be present. For \f(CW\*(C`+vsock\*(C'\fR the server name is the numeric \s-1CID\s0 (eg. \f(CW2\fR to connect to the host), and the optional port number may be present. If the \f(CW\*(C`username\*(C'\fR is present it is used for \s-1TLS\s0 authentication. .PP For all transports, an export name may be present, parsed in accordance with the \s-1NBD URI\s0 specification. .PP Finally the query part of the \s-1URI\s0 can contain: .IP "\fBsocket=\fR\fI\s-1SOCKET\s0\fR" 4 .IX Item "socket=SOCKET" Specifies the Unix domain socket to connect on. Must be present for the \f(CW\*(C`+unix\*(C'\fR transport and must not be present for the other transports. .IP "\fBtls\-psk\-file=\fR\fI\s-1PSKFILE\s0\fR" 4 .IX Item "tls-psk-file=PSKFILE" Set the \s-1PSK\s0 file. See \fBnbd_set_tls_psk_file\fR\|(3). Note this is not allowed by default \- see next section. .SS "Disable \s-1URI\s0 features" .IX Subsection "Disable URI features" For security reasons you might want to disable certain \s-1URI\s0 features. Pre-filtering URIs is error-prone and should not be attempted. Instead use the libnbd APIs below to control what can appear in URIs. Note you must call these functions on the same handle before calling \fBnbd_connect_uri\fR\|(3) or \&\fBnbd_aio_connect_uri\fR\|(3). .ie n .IP "\s-1TCP,\s0 Unix domain socket or ""AF_VSOCK"" transports" 4 .el .IP "\s-1TCP,\s0 Unix domain socket or \f(CWAF_VSOCK\fR transports" 4 .IX Item "TCP, Unix domain socket or AF_VSOCK transports" Default: all allowed .Sp To select which transports are allowed call \&\fBnbd_set_uri_allow_transports\fR\|(3). .IP "\s-1TLS\s0" 4 .IX Item "TLS" Default: both non-TLS and \s-1TLS\s0 connections allowed .Sp To force \s-1TLS\s0 off or on in URIs call \&\fBnbd_set_uri_allow_tls\fR\|(3). .IP "Connect to Unix domain socket in the local filesystem" 4 .IX Item "Connect to Unix domain socket in the local filesystem" Default: allowed .Sp To prevent this you must disable the \f(CW\*(C`+unix\*(C'\fR transport using \fBnbd_set_uri_allow_transports\fR\|(3). .IP "Read from local files" 4 .IX Item "Read from local files" Default: denied .Sp To allow URIs to contain references to local files (eg. for parameters like \f(CW\*(C`tls\-psk\-file\*(C'\fR) call \&\fBnbd_set_uri_allow_local_file\fR\|(3). .SS "Optional features" .IX Subsection "Optional features" This call will fail if libnbd was not compiled with libxml2; you can test whether this is the case with \fBnbd_supports_uri\fR\|(3). .PP Support for URIs that require \s-1TLS\s0 will fail if libnbd was not compiled with gnutls; you can test whether this is the case with \fBnbd_supports_tls\fR\|(3). .SH "RETURN VALUE" .IX Header "RETURN VALUE" If the call is successful the function returns \f(CW0\fR. .SH "ERRORS" .IX Header "ERRORS" On error \f(CW\*(C`\-1\*(C'\fR is returned. .PP Refer to \*(L"\s-1ERROR HANDLING\*(R"\s0 in \fBlibnbd\fR\|(3) for how to get further details of the error. .SH "HANDLE STATE" .IX Header "HANDLE STATE" The handle must be newly created, otherwise this call will return an error. .SH "VERSION" .IX Header "VERSION" This function first appeared in libnbd 1.0. .PP If you need to test if this function is available at compile time check if the following macro is defined: .PP .Vb 1 \& #define LIBNBD_HAVE_NBD_CONNECT_URI 1 .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBnbd_aio_connect_uri\fR\|(3), \&\fBnbd_connect_tcp\fR\|(3), \&\fBnbd_connect_unix\fR\|(3), \&\fBnbd_connect_uri\fR\|(3), \&\fBnbd_create\fR\|(3), \&\fBnbd_opt_go\fR\|(3), \&\fBnbd_set_export_name\fR\|(3), \&\fBnbd_set_opt_mode\fR\|(3), \&\fBnbd_set_tls\fR\|(3), \&\fBnbd_set_tls_psk_file\fR\|(3), \&\fBnbd_set_uri_allow_local_file\fR\|(3), \&\fBnbd_set_uri_allow_tls\fR\|(3), \&\fBnbd_set_uri_allow_transports\fR\|(3), \&\fBnbd_supports_tls\fR\|(3), \&\fBnbd_supports_uri\fR\|(3), \&\fBlibnbd\fR\|(3), https://github.com/NetworkBlockDevice/nbd/blob/master/doc/uri.md. .SH "AUTHORS" .IX Header "AUTHORS" Eric Blake .PP Richard W.M. Jones .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2019\-2020 Red Hat Inc. .SH "LICENSE" .IX Header "LICENSE" This library is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. .PP This library is distributed in the hope that it will be useful, but \s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE.\s0 See the \s-1GNU\s0 Lesser General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, \s-1MA 02110\-1301 USA\s0