diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/frrstr.c | 24 | ||||
| -rw-r--r-- | lib/frrstr.h | 8 | ||||
| -rw-r--r-- | lib/mgmt_be_client.c | 7 | ||||
| -rw-r--r-- | lib/mgmt_be_client.h | 44 | ||||
| -rw-r--r-- | lib/northbound.c | 68 | ||||
| -rw-r--r-- | lib/northbound.h | 1 | ||||
| -rw-r--r-- | lib/yang.c | 9 |
7 files changed, 34 insertions, 127 deletions
diff --git a/lib/frrstr.c b/lib/frrstr.c index e5440c5093..bb112afef7 100644 --- a/lib/frrstr.c +++ b/lib/frrstr.c @@ -3,6 +3,7 @@ * FRR string processing utilities. * Copyright (C) 2018 Cumulus Networks, Inc. * Quentin Young + * Copyright (c) 2023, LabN Consulting, L.L.C. */ #include "zebra.h" @@ -225,3 +226,26 @@ char *frrstr_hex(char *buff, size_t bufsiz, const uint8_t *str, size_t num) return buff; } + +const char *frrstr_skip_over_char(const char *s, int skipc) +{ + int c, quote = 0; + + while ((c = *s++)) { + if (c == '\\') { + if (!*s++) + return NULL; + continue; + } + if (quote) { + if (c == quote) + quote = 0; + continue; + } + if (c == skipc) + return s; + if (c == '"' || c == '\'') + quote = c; + } + return NULL; +} diff --git a/lib/frrstr.h b/lib/frrstr.h index 19ba09e213..9a4fe257a2 100644 --- a/lib/frrstr.h +++ b/lib/frrstr.h @@ -3,6 +3,7 @@ * FRR string processing utilities. * Copyright (C) 2018 Cumulus Networks, Inc. * Quentin Young + * Copyright (c) 2023, LabN Consulting, L.L.C. */ #ifndef _FRRSTR_H_ @@ -166,6 +167,13 @@ int all_digit(const char *str); */ char *frrstr_hex(char *buff, size_t bufsiz, const uint8_t *str, size_t num); + +/* + * Advance past a given char `skipc` in a string, while honoring quoting and + * backslash escapes (i.e., ignore `skipc` which occur in quoted sections). + */ +const char *frrstr_skip_over_char(const char *s, int skipc); + #ifdef __cplusplus } #endif diff --git a/lib/mgmt_be_client.c b/lib/mgmt_be_client.c index be10dcf6a1..762ace1361 100644 --- a/lib/mgmt_be_client.c +++ b/lib/mgmt_be_client.c @@ -118,13 +118,6 @@ struct mgmt_be_client { struct debug mgmt_dbg_be_client = {0, "Management backend client operations"}; -const char *mgmt_be_client_names[MGMTD_BE_CLIENT_ID_MAX + 1] = { -#ifdef HAVE_STATICD - [MGMTD_BE_CLIENT_ID_STATICD] = "staticd", -#endif - [MGMTD_BE_CLIENT_ID_MAX] = "Unknown/Invalid", -}; - static int mgmt_be_client_send_msg(struct mgmt_be_client *client_ctx, Mgmtd__BeMessage *be_msg) { diff --git a/lib/mgmt_be_client.h b/lib/mgmt_be_client.h index 4ad5ca5957..051c908a37 100644 --- a/lib/mgmt_be_client.h +++ b/lib/mgmt_be_client.h @@ -17,27 +17,6 @@ extern "C" { #include "mgmtd/mgmt_defines.h" /*************************************************************** - * Client IDs - ***************************************************************/ - -/* - * Add enum value for each supported component, wrap with - * #ifdef HAVE_COMPONENT - */ -enum mgmt_be_client_id { - MGMTD_BE_CLIENT_ID_MIN = 0, - MGMTD_BE_CLIENT_ID_INIT = -1, -#ifdef HAVE_STATICD - MGMTD_BE_CLIENT_ID_STATICD, -#endif - MGMTD_BE_CLIENT_ID_MAX -}; - -#define FOREACH_MGMTD_BE_CLIENT_ID(id) \ - for ((id) = MGMTD_BE_CLIENT_ID_MIN; \ - (id) < MGMTD_BE_CLIENT_ID_MAX; (id)++) - -/*************************************************************** * Constants ***************************************************************/ @@ -108,29 +87,6 @@ struct mgmt_be_client_cbs { * Global data exported ***************************************************************/ -extern const char *mgmt_be_client_names[MGMTD_BE_CLIENT_ID_MAX + 1]; - -static inline const char *mgmt_be_client_id2name(enum mgmt_be_client_id id) -{ - if (id > MGMTD_BE_CLIENT_ID_MAX) - id = MGMTD_BE_CLIENT_ID_MAX; - return mgmt_be_client_names[id]; -} - -static inline enum mgmt_be_client_id -mgmt_be_client_name2id(const char *name) -{ - enum mgmt_be_client_id id; - - FOREACH_MGMTD_BE_CLIENT_ID (id) { - if (!strncmp(mgmt_be_client_names[id], name, - MGMTD_CLIENT_NAME_MAX_LEN)) - return id; - } - - return MGMTD_BE_CLIENT_ID_MAX; -} - extern struct debug mgmt_dbg_be_client; /*************************************************************** diff --git a/lib/northbound.c b/lib/northbound.c index be49d92841..080f3d002e 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -305,8 +305,6 @@ struct nb_config *nb_config_new(struct lyd_node *dnode) config->dnode = yang_dnode_new(ly_native_ctx, true); config->version = 0; - RB_INIT(nb_config_cbs, &config->cfg_chgs); - return config; } @@ -314,7 +312,7 @@ void nb_config_free(struct nb_config *config) { if (config->dnode) yang_dnode_free(config->dnode); - nb_config_diff_del_changes(&config->cfg_chgs); + XFREE(MTYPE_NB_CONFIG, config); } @@ -326,8 +324,6 @@ struct nb_config *nb_config_dup(const struct nb_config *config) dup->dnode = yang_dnode_dup(config->dnode); dup->version = config->version; - RB_INIT(nb_config_cbs, &dup->cfg_chgs); - return dup; } @@ -753,65 +749,6 @@ int nb_candidate_edit(struct nb_config *candidate, return NB_OK; } -static void nb_update_candidate_changes(struct nb_config *candidate, - struct nb_cfg_change *change, - uint32_t *seq) -{ - enum nb_operation oper = change->operation; - char *xpath = change->xpath; - struct lyd_node *root = NULL; - struct lyd_node *dnode; - struct nb_config_cbs *cfg_chgs = &candidate->cfg_chgs; - int op; - - switch (oper) { - case NB_OP_CREATE: - case NB_OP_MODIFY: - root = yang_dnode_get(candidate->dnode, xpath); - break; - case NB_OP_DESTROY: - root = yang_dnode_get(running_config->dnode, xpath); - /* code */ - break; - case NB_OP_MOVE: - case NB_OP_PRE_VALIDATE: - case NB_OP_APPLY_FINISH: - case NB_OP_GET_ELEM: - case NB_OP_GET_NEXT: - case NB_OP_GET_KEYS: - case NB_OP_LOOKUP_ENTRY: - case NB_OP_RPC: - break; - default: - assert(!"non-enum value, invalid"); - } - - if (!root) - return; - - LYD_TREE_DFS_BEGIN (root, dnode) { - op = nb_lyd_diff_get_op(dnode); - switch (op) { - case 'c': /* create */ - nb_config_diff_created(dnode, seq, cfg_chgs); - LYD_TREE_DFS_continue = 1; - break; - case 'd': /* delete */ - nb_config_diff_deleted(dnode, seq, cfg_chgs); - LYD_TREE_DFS_continue = 1; - break; - case 'r': /* replace */ - nb_config_diff_add_change(cfg_chgs, NB_OP_MODIFY, seq, - dnode); - break; - case 'n': /* none */ - default: - break; - } - LYD_TREE_DFS_END(root, dnode); - } -} - static bool nb_is_operation_allowed(struct nb_node *nb_node, struct nb_cfg_change *change) { @@ -829,8 +766,6 @@ void nb_candidate_edit_config_changes( size_t num_cfg_changes, const char *xpath_base, const char *curr_xpath, int xpath_index, char *err_buf, int err_bufsize, bool *error) { - uint32_t seq = 0; - if (error) *error = false; @@ -900,7 +835,6 @@ void nb_candidate_edit_config_changes( *error = true; continue; } - nb_update_candidate_changes(candidate_config, change, &seq); } if (error && *error) { diff --git a/lib/northbound.h b/lib/northbound.h index 1723a87e4e..5cf6e85b4b 100644 --- a/lib/northbound.h +++ b/lib/northbound.h @@ -703,7 +703,6 @@ struct nb_transaction { struct nb_config { struct lyd_node *dnode; uint32_t version; - struct nb_config_cbs cfg_chgs; }; /* Callback function used by nb_oper_data_iterate(). */ diff --git a/lib/yang.c b/lib/yang.c index 4dd8654217..7046091baa 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -254,15 +254,8 @@ struct lysc_node *yang_find_snode(struct ly_ctx *ly_ctx, const char *xpath, uint32_t options) { struct lysc_node *snode; - struct ly_set *set; - LY_ERR err; - err = lys_find_xpath(ly_native_ctx, NULL, xpath, options, &set); - if (err || !set->count) - return NULL; - - snode = set->snodes[0]; - ly_set_free(set, NULL); + snode = (struct lysc_node *)lys_find_path(ly_ctx, NULL, xpath, 0); return snode; } |
