Skip to content

Commit 2076041

Browse files
committed
err netconf REFACTOR missing attribute function
1 parent 71dc3b5 commit 2076041

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/err_netconf.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ np_err_missing_element(sr_session_ctx_t *ev_sess, const char *elem_name)
122122
sr_session_set_netconf_error(ev_sess, "protocol", "missing-element", NULL, NULL, msg, 1, "bad-element", elem_name);
123123
}
124124

125+
void
126+
np_err_missing_attribute(sr_session_ctx_t *ev_sess, const char *message, const char *elem_name)
127+
{
128+
sr_session_set_netconf_error(ev_sess, "protocol", "missing-attribute", NULL, NULL, message, 1, "bad-element", elem_name);
129+
}
130+
125131
void
126132
np_err_bad_element(sr_session_ctx_t *ev_sess, const char *elem_name, const char *description)
127133
{

src/err_netconf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ void np_err_lock_denied(sr_session_ctx_t *ev_sess, const char *err_msg, uint32_t
3131

3232
void np_err_missing_element(sr_session_ctx_t *ev_sess, const char *elem_name);
3333

34+
void np_err_missing_attribute(sr_session_ctx_t *ev_sess, const char *message, const char *elem_name);
35+
3436
void np_err_bad_element(sr_session_ctx_t *ev_sess, const char *elem_name, const char *description);
3537

3638
void np_err_invalid_value(sr_session_ctx_t *ev_sess, const char *description, const char *bad_elem_name);

src/netconf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ np2srv_rpc_get_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), const char
155155
if (meta && !strcmp(lyd_get_meta_value(meta), "xpath")) {
156156
meta = lyd_find_meta(node->meta, NULL, "ietf-netconf:select");
157157
if (!meta) {
158-
ERR("RPC with an XPath filter without the \"select\" attribute.");
158+
np_err_missing_attribute(session, "Missing \"select\" attribute", "filter");
159159
rc = SR_ERR_INVAL_ARG;
160160
goto cleanup;
161161
}
@@ -933,7 +933,7 @@ np2srv_rpc_subscribe_cb(sr_session_ctx_t *session, uint32_t UNUSED(sub_id), cons
933933
if (meta && !strcmp(lyd_get_meta_value(meta), "xpath")) {
934934
meta = lyd_find_meta(node->meta, NULL, "ietf-netconf:select");
935935
if (!meta) {
936-
ERR("RPC with an XPath filter without the \"select\" attribute.");
936+
np_err_missing_attribute(session, "Missing \"select\" attribute", "filter");
937937
rc = SR_ERR_INVAL_ARG;
938938
goto cleanup;
939939
}

0 commit comments

Comments
 (0)