Skip to content

Commit

Permalink
mgmtd: simplify xpath registries
Browse files Browse the repository at this point in the history
- move from client id indexed array of uints for register info
  per client to a u64 bitmask.

Signed-off-by: Christian Hopps <[email protected]>
  • Loading branch information
choppsv1 committed Oct 31, 2023
1 parent e1b2381 commit 65cbbd3
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 299 deletions.
24 changes: 24 additions & 0 deletions lib/frrstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
8 changes: 8 additions & 0 deletions lib/frrstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down Expand Up @@ -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.
*/
const char *frrstr_skip_over_char(const char *s, int skipc);

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions lib/mgmt_be_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ enum mgmt_be_client_id {
for ((id) = MGMTD_BE_CLIENT_ID_MIN; \
(id) < MGMTD_BE_CLIENT_ID_MAX; (id)++)

#define IS_IDBIT_UNSET(v, id) (!((v) & (1ull << (id))))
#define IS_IDBIT_SET(v, id) (!IS_IDBIT_UNSET(v, id))

/***************************************************************
* Constants
***************************************************************/
Expand Down
Loading

0 comments on commit 65cbbd3

Please sign in to comment.