Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 1 | /** |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 2 | * @file netconf.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief libnetconf2's general public functions and structures definitions. |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 5 | * |
Michal Vasko | 95ea9ff | 2021-11-09 12:29:14 +0100 | [diff] [blame] | 6 | * @copyright |
Michal Vasko | c446a38 | 2021-06-18 08:54:05 +0200 | [diff] [blame] | 7 | * Copyright (c) 2015 - 2021 CESNET, z.s.p.o. |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 8 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 9 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 10 | * You may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
Michal Vasko | afd416b | 2016-02-25 14:51:46 +0100 | [diff] [blame] | 12 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 13 | * https://opensource.org/licenses/BSD-3-Clause |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #ifndef NC_NETCONF_H_ |
| 17 | #define NC_NETCONF_H_ |
| 18 | |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 23 | /** |
| 24 | * @addtogroup misc |
| 25 | * @{ |
| 26 | */ |
| 27 | |
| 28 | /** @brief Base NETCONF namespace */ |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 29 | #define NC_NS_BASE "urn:ietf:params:xml:ns:netconf:base:1.0" |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 30 | /** @brief Notifications namespace */ |
Radek Krejci | 206fcd6 | 2015-10-07 15:42:48 +0200 | [diff] [blame] | 31 | #define NC_NS_NOTIF "urn:ietf:params:xml:ns:netconf:notification:1.0" |
| 32 | |
Radek Krejci | ac6d347 | 2015-10-22 15:47:18 +0200 | [diff] [blame] | 33 | /** @brief Default NETCONF over SSH port */ |
Michal Vasko | 38a7c6c | 2015-12-04 12:29:20 +0100 | [diff] [blame] | 34 | #define NC_PORT_SSH 830 |
| 35 | /** @brief Default NETCONF over SSH Call Home port */ |
Michal Vasko | 3b09029 | 2017-02-03 11:43:47 +0100 | [diff] [blame] | 36 | #define NC_PORT_CH_SSH 4334 |
Michal Vasko | 38a7c6c | 2015-12-04 12:29:20 +0100 | [diff] [blame] | 37 | |
Radek Krejci | ac6d347 | 2015-10-22 15:47:18 +0200 | [diff] [blame] | 38 | /** @brief Default NETCONF over TLS port */ |
Michal Vasko | 38a7c6c | 2015-12-04 12:29:20 +0100 | [diff] [blame] | 39 | #define NC_PORT_TLS 6513 |
| 40 | /** @brief Default NETCONF over TLS Call Home port */ |
Michal Vasko | 3b09029 | 2017-02-03 11:43:47 +0100 | [diff] [blame] | 41 | #define NC_PORT_CH_TLS 4335 |
Radek Krejci | ac6d347 | 2015-10-22 15:47:18 +0200 | [diff] [blame] | 42 | |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 43 | /** |
Michal Vasko | 3a889fd | 2016-09-30 12:16:37 +0200 | [diff] [blame] | 44 | * @brief Set RPC callback to a schema node. |
| 45 | * |
Michal Vasko | 49eb3f4 | 2021-05-19 10:20:57 +0200 | [diff] [blame] | 46 | * @param[in] node const struct lysc_node *node |
Michal Vasko | 3a889fd | 2016-09-30 12:16:37 +0200 | [diff] [blame] | 47 | * @param[in] cb nc_rpc_clb cb |
| 48 | */ |
Michal Vasko | 49eb3f4 | 2021-05-19 10:20:57 +0200 | [diff] [blame] | 49 | #define nc_set_rpc_callback(node, cb) (node->priv = cb) |
Michal Vasko | 3a889fd | 2016-09-30 12:16:37 +0200 | [diff] [blame] | 50 | |
| 51 | /** |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 52 | * @brief Enumeration of reasons of the NETCONF session termination as defined in RFC 6470. |
| 53 | */ |
| 54 | typedef enum NC_SESSION_TERM_REASON { |
Radek Krejci | 465308c | 2017-05-22 14:49:10 +0200 | [diff] [blame] | 55 | NC_SESSION_TERM_ERR = -1, /**< error return code for function getting the session termination reason */ |
Michal Vasko | 428087d | 2016-01-14 16:04:28 +0100 | [diff] [blame] | 56 | NC_SESSION_TERM_NONE = 0, /**< session still running */ |
| 57 | NC_SESSION_TERM_CLOSED, /**< closed by client in a normal fashion */ |
| 58 | NC_SESSION_TERM_KILLED, /**< session was terminated by \<kill-session\> operation */ |
| 59 | NC_SESSION_TERM_DROPPED, /**< transport layer connection was unexpectedly closed */ |
| 60 | NC_SESSION_TERM_TIMEOUT, /**< terminated because of inactivity */ |
| 61 | NC_SESSION_TERM_BADHELLO, /**< \<hello\> message was invalid */ |
| 62 | NC_SESSION_TERM_OTHER /**< terminated for some other reason */ |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 63 | } NC_SESSION_TERM_REASON; |
| 64 | |
| 65 | /** |
Radek Krejci | 4339024 | 2015-10-08 15:34:04 +0200 | [diff] [blame] | 66 | * @brief Enumeration of NETCONF message types. |
| 67 | */ |
| 68 | typedef enum NC_MSG_TYPE { |
Michal Vasko | 71ba2da | 2016-05-04 10:53:16 +0200 | [diff] [blame] | 69 | NC_MSG_ERROR, /**< error return value */ |
| 70 | NC_MSG_WOULDBLOCK, /**< timeout return value */ |
| 71 | NC_MSG_NONE, /**< no message at input or message was processed internally */ |
| 72 | NC_MSG_HELLO, /**< \<hello\> message */ |
Michal Vasko | 71090fc | 2016-05-24 16:37:28 +0200 | [diff] [blame] | 73 | NC_MSG_BAD_HELLO, /**< \<hello\> message parsing failed */ |
Michal Vasko | 71ba2da | 2016-05-04 10:53:16 +0200 | [diff] [blame] | 74 | NC_MSG_RPC, /**< \<rpc\> message */ |
| 75 | NC_MSG_REPLY, /**< \<rpc-reply\> message */ |
| 76 | NC_MSG_REPLY_ERR_MSGID, /**< \<rpc-reply\> message with missing or wrong message-id attribute value */ |
| 77 | NC_MSG_NOTIF /**< \<notification\> message */ |
Radek Krejci | 4339024 | 2015-10-08 15:34:04 +0200 | [diff] [blame] | 78 | } NC_MSG_TYPE; |
| 79 | |
| 80 | /** |
Michal Vasko | 8fe604c | 2020-02-10 15:25:04 +0100 | [diff] [blame] | 81 | * @brief Messages of NETCONF message type enum. |
| 82 | */ |
| 83 | extern const char *nc_msgtype2str[]; |
| 84 | |
| 85 | /** |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 86 | * @brief Enumeration of the supported types of datastores defined by NETCONF |
| 87 | */ |
| 88 | typedef enum NC_DATASTORE_TYPE { |
Michal Vasko | 7f1c78b | 2016-01-19 09:52:14 +0100 | [diff] [blame] | 89 | NC_DATASTORE_ERROR = 0, /**< error state of functions returning the datastore type */ |
| 90 | NC_DATASTORE_CONFIG, /**< value describing that the datastore is set as config */ |
| 91 | NC_DATASTORE_URL, /**< value describing that the datastore data should be given from the URL */ |
| 92 | NC_DATASTORE_RUNNING, /**< base NETCONF's datastore containing the current device configuration */ |
| 93 | NC_DATASTORE_STARTUP, /**< separated startup datastore as defined in Distinct Startup Capability */ |
| 94 | NC_DATASTORE_CANDIDATE /**< separated working datastore as defined in Candidate Configuration Capability */ |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 95 | } NC_DATASTORE; |
| 96 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 97 | /** |
| 98 | * @brief Enumeration of NETCONF with-defaults capability modes. |
| 99 | */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 100 | typedef enum NC_WITHDEFAULTS_MODE { |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 101 | NC_WD_UNKNOWN = 0, /**< invalid mode */ |
Radek Krejci | 36dfdb3 | 2016-09-01 16:56:35 +0200 | [diff] [blame] | 102 | NC_WD_ALL, /**< report-all mode */ |
| 103 | NC_WD_ALL_TAG, /**< report-all-tagged mode */ |
| 104 | NC_WD_TRIM, /**< trim mode */ |
| 105 | NC_WD_EXPLICIT /**< explicit mode */ |
Michal Vasko | 7bcb48e | 2016-01-15 10:28:54 +0100 | [diff] [blame] | 106 | } NC_WD_MODE; |
| 107 | |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 108 | /** |
| 109 | * @brief Enumeration of NETCONF (both server and client) rpc-reply types. |
| 110 | */ |
Michal Vasko | 495c946 | 2016-01-15 11:27:43 +0100 | [diff] [blame] | 111 | typedef enum NC_REPLY { |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 112 | NC_RPL_OK, /**< OK rpc-reply */ |
| 113 | NC_RPL_DATA, /**< DATA rpc-reply */ |
| 114 | NC_RPL_ERROR, /**< ERROR rpc-reply */ |
| 115 | NC_RPL_NOTIF /**< notification (client-only) */ |
Michal Vasko | 495c946 | 2016-01-15 11:27:43 +0100 | [diff] [blame] | 116 | } NC_RPL; |
| 117 | |
Radek Krejci | 695d4fa | 2015-10-22 13:23:54 +0200 | [diff] [blame] | 118 | /** |
Michal Vasko | 1a38c86 | 2016-01-15 15:50:07 +0100 | [diff] [blame] | 119 | * @brief Enumeration of function parameter treatments. |
| 120 | */ |
| 121 | typedef enum NC_PARAMTYPE { |
| 122 | NC_PARAMTYPE_CONST, /**< use the parameter directly, do not free */ |
| 123 | NC_PARAMTYPE_FREE, /**< use the parameter directly, free afterwards */ |
| 124 | NC_PARAMTYPE_DUP_AND_FREE /**< make a copy of the argument, free afterwards */ |
| 125 | } NC_PARAMTYPE; |
| 126 | |
Michal Vasko | 49eb3f4 | 2021-05-19 10:20:57 +0200 | [diff] [blame] | 127 | /** @} Miscellaneous */ |
Radek Krejci | 6799a05 | 2017-05-19 14:23:23 +0200 | [diff] [blame] | 128 | |
Radek Krejci | d0d1952 | 2015-09-02 13:49:25 +0200 | [diff] [blame] | 129 | #ifdef __cplusplus |
| 130 | } |
| 131 | #endif |
| 132 | |
| 133 | #endif /* NC_NETCONF_H_ */ |