libnetconf  0.10.0-146_trunk
NETCONF Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Client

Client Workflow

Here is a description of using libnetconf functions in a NETCONF client:

  1. Set verbosity (optional).
    The verbosity of the libnetconf can be set by nc_verbosity(). By default, libnetconf is completely silent.
    There is a default message-printing function that writes messages on stderr. The application's specific message printing function can be set via nc_callback_print() function.
  2. Set SSH authentication methods priorities (optional).
    libnetconf supports several SSH authentication methods for connecting to a NETCONF server over SSH. However, the used method is selected from a list of supported authentication methods provided by the server. Client is allowed to specify the priority of each supported authentication method via nc_ssh_pref() function. The authentication method can also be disabled using a negative priority value.
    Default priorities are following:
    • Interactive (value 3)
    • Password (value 2)
    • Public keys (value 1)
  3. Set your own callback(s) for the SSH authentication methods (optional).
    User credentials are received via the callback functions specific for each authentication method. There are default callbacks, but application can set their own via:
  4. Connect to the NETCONF server(s).
    Simply call nc_session_connect() to connect to the specified host via SSH. Authentication method is selected according to the default values or the previous steps.
  5. Prepare NETCONF rpc message(s).
    Creating NETCONF rpc messages is covered by the functions described in the section NETCONF rpc. The application prepares NETCONF rpc messages according to the specified attributes. These messages can be then repeatedly used for communication over any of the created NETCONF sessions.
  6. Send the message to the selected NETCONF server.
    To send created NETCONF rpc message to the NETCONF server, use nc_session_send_rpc() function. nc_session_send_recv() function connects sending and receiving the reply (see the next step) into one blocking call.
  7. Get the server's rpc-reply message. When the NETCONF rpc is sent, use nc_session_recv_reply() to receive the reply. To learn when the reply is coming, a file descriptor of the communication channel can be checked by poll(), select(), ... This descriptor can be obtained via nc_session_get_eventfd() function.
  8. Close the NETCONF session.
    When the communication is done, the NETCONF session should be freed (session is also properly closed) via nc_session_free() function.
  9. Free all created objects.
    Do not forget to free created rpc messages (nc_rpc_free()), filters (nc_filter_free()) or received NETCONF rpc-replies (nc_reply_free()).