Skip to main content

lyd_parse_op

Function lyd_parse_op 

Source
pub unsafe extern "C" fn lyd_parse_op(
    ctx: *const ly_ctx,
    parent: *mut lyd_node,
    in_: *mut ly_in,
    format: Type,
    data_type: Type,
    parse_options: u32,
    tree: *mut *mut lyd_node,
    op: *mut *mut lyd_node,
) -> Type
Expand description

@brief Parse YANG data into an operation data tree. Specific parsing flags ::LYD_PARSE_ONLY, ::LYD_PARSE_STRICT and no validation flags are used.

At least one of @p parent, @p tree, or @p op must always be set.

Specific @p data_type values have different parameter meaning as follows:

  • ::LYD_TYPE_RPC_NETCONF:

    • @p parent - must be NULL, the whole RPC is expected;
    • @p format - must be ::LYD_XML, NETCONF supports only this format;
    • @p tree - must be provided, all the NETCONF-specific XML envelopes will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
    • @p op - must be provided, the RPC/action data tree itself will be returned here, pointing to the operation;
  • ::LYD_TYPE_NOTIF_NETCONF:

    • @p parent - must be NULL, the whole notification is expected;
    • @p format - must be ::LYD_XML, NETCONF supports only this format;
    • @p tree - must be provided, all the NETCONF-specific XML envelopes will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
    • @p op - must be provided, the notification data tree itself will be returned here, pointing to the operation;
  • ::LYD_TYPE_REPLY_NETCONF:

    • @p parent - must be set, pointing to the invoked RPC operation (RPC or action) node;
    • @p format - must be ::LYD_XML, NETCONF supports only this format;
    • @p tree - must be provided, all the NETCONF-specific XML envelopes will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
    • @p op - must be NULL, the reply is appended to the RPC; Note that there are 3 kinds of NETCONF replies - ok, error, and data. Only data reply appends any nodes to the RPC.
  • ::LYD_TYPE_RPC_RESTCONF:

    • @p parent - must be set, pointing to the invoked RPC operation (RPC or action) node;
    • @p format - can be both ::LYD_JSON and ::LYD_XML;
    • @p tree - must be provided, all the RESTCONF-specific JSON objects will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
    • @p op - must be NULL, @p parent points to the operation;
  • ::LYD_TYPE_NOTIF_RESTCONF:

    • @p parent - must be NULL, the whole notification is expected;
    • @p format - must be ::LYD_JSON, XML-formatted notifications are parsed using ::LYD_TYPE_NOTIF_NETCONF;
    • @p tree - must be provided, all the RESTCONF-specific JSON objects will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
    • @p op - must be provided, the notification data tree itself will be returned here, pointing to the operation;
  • ::LYD_TYPE_REPLY_RESTCONF:

    • @p parent - must be set, pointing to the invoked RPC operation (RPC or action) node;
    • @p format - can be both ::LYD_JSON and ::LYD_XML;
    • @p tree - must be provided, all the RESTCONF-specific JSON objects will be returned here as a separate opaque data tree, even if the function fails, this may be returned;
    • @p op - must be NULL, @p parent points to the operation; Note that error reply should be parsed as ‘yang-data’ extension data.
  • ::LYD_TYPE_RPC_YANG:

  • ::LYD_TYPE_NOTIF_YANG:

  • ::LYD_TYPE_REPLY_YANG:

    • all the parameters have their default meaning.
  • :: LYD_TYPE_DATA_YANG:

    • not accepted by the function.

@param[in] ctx libyang context. @param[in] parent Optional parent to connect the parsed nodes to. @param[in] in Input handle to read the input from. @param[in] format Expected format of the data in @p in. @param[in] data_type Expected operation to parse (@ref datatype). @param[in] parse_options Options for parser are set based on @p data_type but either of ::LYD_PARSE_STRICT and ::LYD_PARSE_OPAQ can be added, see @ref dataparseroptions. @param[out] tree Optional full parsed data tree. If @p parent is set, set to NULL. @param[out] op Optional pointer to the operation (action/RPC/notification) node. @return LY_ERR value. @return LY_ENOT if @p data_type is a NETCONF message and the root XML element is not the expected one.