Session Management APIs for C and C++
The Session Management APIs are used to open or close the server connection, and to set and retrieve the server session parameters, such as transport type and authentication style. This page contains information about the Session Management APIs for C and C++, including the description and syntax, and the input, input types, input description, and input return values.
na_server_open
Prototype
na_server_t* na_server_open(const char* server, int major, int minor);
Description
Sets the server context and assigns default values to the session parameters.
Following are the default values:
username= ""
password = ""
style = NA_STYLE_LOGIN_PASSWORD
port = 80
transport = NA_SERVER_TRANSPORT_HTTP
servertype = NA_SERVER_TYPE_FILER
You can overwrite the default values by using the na_server* Core APIs.
Return value
•
•
na_server_style
Prototype
void na_server_style(na_server_t* srv, na_style_t style);
Description
Sets the authentication mechanism to be used for communicating with the given server.
If style= NA_STYLE_LOGIN_PASSWORD, you must provide an administrator user name and password with na_server_adminuser().
If style= NA_STYLE_RPC, your code should run on the Windows system so that a native Windows authentication based on remote procedure call is used. This is applicable for ONTAP APIs only.
If style= NA_STYLE_HOSTSEQUIV, the server context authenticates the against the /etc/hosts.equiv file on the NetApp storage system. In such a case, you do not have to set the administrator user name and password. This is applicable for ONTAP APIs.
If style =NA_STYLE_CERTIFICATE, you can use certificates to authenticate clients who attempt to connect to a server, without using login credentials. This style automatically sets HTTPS as the transport mechanism. You can use this authentication mechanism for clustered Data ONTAP 8.2 and OnCommand Unified Manager 5.0.2, 5.1, and 5.2.
and na_server_set_hostname_verification().
Return value
None
na_server_adminuser
Prototype
int na_server_adminuser(na_server_t* srv, const char* login, const char* pwd);
Description
Sets the user name and password for a server context, where authentication style is NA_STYLE_LOGIN_PASSWORD.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_set_server_type
Prototype
int na_server_set_server_type(na_server_t *srv, na_server_type_t type);
Description
Sets the type of system you are connecting to.
NA_SERVER_TYPE_FILER — to connect to a NetApp storage system.
NA_SERVER_TYPE_DFM — to connect to a OnCommand Unified Manager server 5.2 or earlier.
NA_SERVER_TYPE_OCUM — to connect to a OnCommand Unified Manager server 6.0 or later.
The default server type is NA_SERVER_TYPE_FILER.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_set_transport_type
Prototype
int na_server_set_transport_type(na_server_t* srv, na_server_transport_t transport, const union zfd_setopt* transportarg);
Description
•
•
Following are the supported transport types for NA_SERVER_TYPE_FILER and NA_SERVER_TYPE_DFM:
The default transport type is NA_SERVER_TRANSPORT_HTTP. For secure transport, use NA_SERVER_TRANSPORT_HTTPS as the transport type.
For NA_SERVER_TYPE_OCUM, only NA_SERVER_TRANSPORT_ HTTPS is supported and is set by default.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_set_sslv3
Prototype
int na_server_set_sslv3(na_server_t *srv, int enable);
Description
Enables or disables SSLv3 protocol for use over HTTPS transport. SSLlv3 is disabled by default.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_is_sslv3_enabled
Prototype
int na_server_is_sslv3_enabled(na_server_t *srv);
Description
Determines whether SSLv3 is enabled.
Return value
•
1 (TRUE) if SSLv3 is enabled
•
0 (FALSE) if SSLV3 is disabled
na_server_set_vfiler
Prototype
int na_server_set_vfiler(na_server_t* srv, const char * vfilerserver);
Description
Sets the name of the vFiler unit on which the ONTAP API commands need to be invoked for the given server context.
After the command is set, all the API commands are executed on the vFiler unit through the actual server.
The API supports the vFiler tunneling feature.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_set_port
Prototype
int na_server_set_port(na_server_t* srv, int port);
Description
Sets the port on which the API commands need to be invoked for the given server context.
Following is the default port on the storage system for ONTAP API communication:
HTTP=80
HTTPS=443
Following is the default port on the server for OnCommand Unified Manager Core Package 5.2 or earlier for API communication:
HTTP=8080
HTTPS=8488
Following is the only supported and default port on the server for OnCommand Unified Manager 6.0 or later for API communication:
HTTPS=443
You must invoke this API to set the port, if ONTAP or OnCommand Unified Manager does not have the default port settings.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_set_timeout
Prototype
int na_server_set_timeout(na_server_t* srv, int timeout);
Description
Sets a connection timeout for the following actions:
•
•
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_set_vserver
Prototype
int na_server_set_vserver(na_server_t* srv, const char* vsrv);
Description
Sets the name of the Storage Virtual Machine (SVM, formerly known as Vserver) to which a Cluster API need to be tunneled from a Cluster Management Interface.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_invoke
Prototype
na_elem_t* na_server_invoke(na_server_t* srv, const char* api, ...);
Description
Invokes any API on the given server.
Enter the name-value pairs and terminate the list with NULL. You can enter only an even number of arguments to this function. The name-value pairs take only strings. All these contexts are then assembled and sent to the server.
Return value
The pointer to the input output context that contains the server response
na_server_invoke_elem
Prototype
na_elem_t* na_server_invoke_elem(na_server_t* srv, na_elem_t* elt);
Description
Sends the API request in the form of input output context, in which the API command and its input arguments are embedded.
After the API call ends, you must free the context elt by invoking na_elem_free().
While processing optional inputs from a dialog box, it is recommended that you construct a context chain instead of using na_server_invoke().
Return value
The pointer to the context that contains the server's reply
na_server_close
Prototype
int na_server_close(na_server_t* srv);
Description
Clears the server context opened by na_server_open(). This is done by freeing all the allocated resources for that server context.
You can have multiple server contexts opened at the same time and each opened server context has to be closed individually.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_set_debugstyle
Prototype
void na_server_set_debugstyle(na_server_t * srv, na_debug_style_t style);
Description
Sets the debug style for the given server context.
The default value is NA_PRINT_DONT_PARSE, which prints the raw XML output derived from the server by using na_server_get_raw_xml_output.
Return value
None
na_server_set_client_cert_and_key
Prototype
int na_server_set_client_cert_and_key (na_server_t* srv, const char* cert, const char* key, const char* passwd);
Description
Sets the client's certificate for authentication by the server in a Secure Sockets Layer (SSL) session.
If key = NULL, then the certificate file is used as the key file.
The password to access the private key file passwd = NULL if the private key file is not password-protected.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_set_server_cert_verification
Prototype
int na_server_is_server_cert_verification_enabled (na_server_t* srv);
Description
Determines whether server certificate verification is enabled.
Return value
•
1 (TRUE) if server certificate verification enabled
•
0 (FALSE) if server certificate verification disabled
na_server_set_ca_certs
Prototype
int na_server_set_ca_certs (na_server_t* srv, const char* CAfile);
Description
Sets the location of trusted certificates that is used for server certificate verification during an SSL session.
The APIs na_server_set_ca_certs() and na_server_set_client_cert_and_key() can be used to build a client certificate chain that is sent to the server during an SSL session.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_set_hostname_verification
Prototype
int na_server_set_hostname_verification (na_server_t *srv, int enable);
Description
Enables or disables hostname verification during server certificate verification.
You must use the na_server_open() API to specify the hostname it is connecting to.
Hostname verification ensures that the hostname to which the client connects, matches that with the hostname in the certificate (CN name) that the server sends during an SSL session.
Hostname verification is enabled by default during server certificate verification.
Set enable = 1 to enable hostname certificate verification, and set 0 to disable.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_is_hostname_verification_enabled
Prototype
int na_server_is_hostname_verification_enabled (na_server_t* srv);
Description
Determines whether hostname verification is enabled.
Return value
•
1 (TRUE) if hostname verification is enabled
•
0 (FALSE) if hostname verification is disabled
na_server_set_application_name
Prototype
int na_server_set_application_name(const char* app_name);
Description
Sets the name of the client application that initiates an operation using ONTAP APIs, and requires a response from the ONTAP server.
The name of the client application helps you track the actions performed by the application on the server. This information is logged in the server audit log file.
Return value
•
1 (TRUE) on success
•
0 (FALSE) on failure
na_server_get_application_name
Prototype
const char* na_server_get_application_name()
Description
Gets the name of the client application.
Return value
•
Name of the client application if set using na_server_set_application_name()
•
na_server_get_style
Prototype
na_style_t na_server_get_style(na_server_t* srv);
Description
Gets the authentication style used by the given server context.
Return value
The server style.
Following are the possible return values:
•
•
•
•
na_server_get_transport_type
Prototype
na_server_transport_t na_server_get_transport_type(na_server_t* srv)
Description
Gets the transport type used by the given server context.
Return value
The current transport type used for the given server context.
Following are the possible return values:
•
•
na_server_get_port
Prototype
int na_server_get_port (na_server_t * srv);
Description
Gets the port number for the given server context used for invoking API commands.
Return value
The port number
na_server_get_timeout
Prototype
const char* na_server_get_timeout(na_server_t *srv);
Description
Gets the connection timeout value of the given server context.
Return value
The connection timeout value (in seconds)
na_server_get_vserver
Prototype
const char* na_server_get_vserver();
Description
Gets the name of the Storage Virtual Machine (SVM, formerly known as Vserver) to which a Cluster API need to be tunneled from a Cluster Management Interface.
Return value
Name of the SVM
na_server_get_raw_xml_output
Prototype
char * na_server_get_raw_xml_output(na_server_t * srv);
Description
Gets the output of the API invoked in raw XML format.
The debug style of the server should be set to NA_PRINT_DONT_PARSE before using this API.
Return value
The raw XML output
Parent topic: C and C++ Core APIs

Was this topic helpful? Send comments to NetApp.