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, authentication style and so on.
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_t* na_server_open(const char* server, int major, int minor);
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.
|
Input |
Type |
Description |
|
server |
const char* |
The name or the IP address of the server in IPv4 or IPv6 format. |
|
major |
int |
The major version of the Data ONTAP API. |
|
minor |
int |
The minor version of the Data ONTAP API. |
The address of the server element
NULL on failure
void na_server_style(na_server_t* srv, na_style_t style);
Sets the authentication mechanism to be used for communicating with the given server.
|
Input |
Type |
Description |
|
srv |
na_server_t * |
The pointer to the server element. |
|
style |
na_style_t |
The communication style that is to be set. Following are the supported values: NA_STYLE_LOGIN_PASSWORD NA_STYLE_RPC NA_STYLE_HOSTSEQUIV If style=NA_STYLE_LOGIN_PASSWORD, you must furnish an administrator user name and password with na_server_adminuser(). If style=NA_STYLE_RPC, your code should run on a Windows system, so that a native Windows authentication based on remote procedure call is used. If style=NA_STYLE_HOSTSEQUIV, the server context authenticates against the /etc/hosts.equiv file on the NetApp storage system. You do not have to set the administrator user name and password in this case. |
None
int na_server_set_server_type(na_server_t *srv, na_server_type_t type)
Sets the type of system you are connecting to.
|
Input |
Type |
Description |
|
srv |
na_server_t* |
Pointer to the server element. |
|
type |
na_server_type_t |
The server type to be set. Following are the supported values:
The default server type is NA_SERVER_TYPE_FILER. |
1 (TRUE) on success
0 (FALSE) on failure
int na_server_adminuser(na_server_t* srv, const char* login, const char* pwd);
Sets the user name and password for a server context, where authentication style is NA_STYLE_LOGIN_PASSWORD.
The user that you specify should have administrative privilege on the storage system.
|
Input |
Type |
Description |
|
srv |
na_server_t* |
The pointer to the server element. |
|
login |
const char* |
The login name. |
|
pwd |
const char* |
The password. |
1 (TRUE) on success
0 (FALSE) on failure
int na_server_set_transport_type(na_server_t* srv, na_server_transport_t transport, const union zfd_setopt* transportarg);
Overrides the default transport type.
After setting the transport type, call the na_set_port() to set the port number used for that transport type.
|
Input |
Type |
Description |
|
srv |
na_server_t* |
The pointer to the server element. |
|
transport |
na_server_transport_t |
The transport type. Following are the supported transport types:
The default transport type is NA_SERVER_TRANSPORT_HTTP. For secure transport, use NA_SERVER_TRANSPORT_HTTPS as the transport type. |
|
transportarg |
const union zfd_setopt* |
The transport argument. You should set transportarg to zero for both the HTTP and HTTPS transport protocols. |
1 (TRUE) on success
0 (FALSE) on failure
int na_server_set_vfiler(na_server_t* srv, char * vfilerserver);
Sets the name of the vFiler unit on which the 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 storage system.
This API supports the vFiler tunneling feature.
|
Input |
Type |
Description |
|
srv |
na_server_t * |
The pointer to the server element. |
|
vfilerserver |
char * |
The name of the vFiler unit that is to be set. |
1 (TRUE) on success
0 (FALSE) on failure
int na_server_set_port(na_server_t* srv, int port);
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 Data ONTAP API communication:
HTTP=80
HTTPS=443
Set this port number to port, if Data ONTAP has the default port settings.
Depending on the transport type settings, use the above port numbers as input to this API if Data ONTAP has default port settings.
|
Input |
Type |
Description |
|
srv |
na_server_t * |
The pointer to the server element. |
|
port |
int |
The port number that is to be set. |
1 (TRUE) on success
0 (FALSE) on failure
int na_server_set_timeout(na_server_t* srv, int timeout);
Sets a connection timeout for the following actions:
Establishing a connection with the server.
Reading and writing data to and from the server socket used for API communication.
|
Input |
Type |
Description |
|
srv |
na_server_t * |
The pointer to the server element. |
|
timeout |
int |
The timeout value. This value is in seconds and should be zero or a positive number. If it is non-zero, the server uses non-blocking socket connection. If it is zero, the server uses blocking connection, which is the default behavior. |
1 (TRUE) on success
0 (FALSE) on failure
na_elem_t* na_server_invoke(na_server_t* srv, const char* api, ...);
Invokes any Data ONTAP API on the given server.
Input the name-value pairs and terminate the list with NULL. You can input only an even number of arguments to this function. The name-value pairs take only strings. All the elements are assembled and sent to the server.
|
Input |
Type |
Description |
|
srv |
na_server_t* |
The pointer to the server element. |
|
api |
const char * |
The name of the API that is to be invoked. |
|
... |
char * |
The input arguments as a name-value pair. |
The pointer to the input output element containing the server response
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 element, which has the embedded Data ONTAP API command and its input arguments.
After the API call ends, you must free the element elt by invoking na_elem_free().
While processing optional inputs from a dialog box, it is recommended that you construct an element chain instead of using na_server_invoke().
|
Input |
Type |
Description |
|
srv |
na_server_t* |
The pointer to the server element. |
|
elt |
na_elem_t* |
The pointer to the element chain. |
The pointer to the element containing the server's reply
int na_server_close(na_server_t* srv);
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.
|
Input |
Type |
Description |
|
srv |
na_server_t* |
The pointer to the server element. |
1 (TRUE) on success
0 (FALSE) on failure
void na_server_set_debugstyle(na_server_t * srv, na_debug_style_t style);
Sets the debug style for the given server context.
|
Input |
Type |
Description |
|
srv |
na_server_t* |
The pointer to the server element. |
|
style |
na_debug_style_t |
The debug style that is to be set. It sets the debug style to NA_PRINT_DONT_PARSE to print the raw XML output from the server with the API na_server_get_raw_xml_output. Following are the supported values for style: · NA_NO_DEBUG · NA_PRINT_DONT_PARSE · NA_DONT_PRINT_DONT_PARSE |
None
na_style_t na_server_get_style(na_server_t* srv);
Gets the authentication style used by the given server context.
|
Input |
Type |
Description |
|
srv |
na_server_t * |
The pointer to the server element. |
The server style.
Following are the possible return values:
NA_STYLE_LOGIN_PASSWORD
NA_STYLE_RPC
NA_STYLE_HOSTSEQUIV
na_server_transport_t na_server_get_transport_type(na_server_t* srv)
Gets the transport type used by the given server context.
|
Input |
Type |
Description |
|
srv |
na_server_t* |
The pointer to the server element. |
The current transport type used for the given server context.
Following are the possible return values:
NA_SERVER_TRANSPORT_HTTP
NA_SERVER_TRANSPORT_HTTPS
int na_server_get_port (na_server_t * srv);
Description
Gets the port number for the given server context used for invoking API commands.
|
Input |
Type |
Description |
|
srv |
na_server_t * |
The pointer to the server element. |
None
int na_server_get_timeout(na_server_t *srv);
Gets the connection timeout value of the given server context.
|
Input |
Type |
Description |
|
srv |
na_server_t * |
The pointer to the server element. |
The connection timeout value (in seconds)
char * na_server_get_raw_xml_output(na_server_t * srv);
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.
|
Input |
Type |
Description |
|
srv |
na_server_t * |
The pointer to the server element. |
The raw XML output