Skip to content

Commit

Permalink
lib: Add function to copy an SRv6 locator
Browse files Browse the repository at this point in the history
Add a new function to copy an SRv6 locator.

Signed-off-by: Carmine Scarpitta <[email protected]>
  • Loading branch information
cscarpitta committed May 8, 2024
1 parent abce616 commit a1d9830
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,21 @@ struct srv6_locator_chunk *srv6_locator_chunk_alloc(void)
return chunk;
}

void srv6_locator_copy(struct srv6_locator *copy,
const struct srv6_locator *locator)
{
strlcpy(copy->name, locator->name, sizeof(locator->name));
copy->prefix = locator->prefix;
copy->block_bits_length = locator->block_bits_length;
copy->node_bits_length = locator->node_bits_length;
copy->function_bits_length = locator->function_bits_length;
copy->argument_bits_length = locator->argument_bits_length;
copy->algonum = locator->algonum;
copy->current = locator->current;
copy->status_up = locator->status_up;
copy->flags = locator->flags;
}

void srv6_locator_free(struct srv6_locator *locator)
{
if (locator) {
Expand Down
2 changes: 2 additions & 0 deletions lib/srv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ extern struct srv6_locator_chunk *srv6_locator_chunk_alloc(void);
extern void srv6_locator_free(struct srv6_locator *locator);
extern void srv6_locator_chunk_list_free(void *data);
extern void srv6_locator_chunk_free(struct srv6_locator_chunk **chunk);
extern void srv6_locator_copy(struct srv6_locator *copy,
const struct srv6_locator *locator);
json_object *srv6_locator_chunk_json(const struct srv6_locator_chunk *chunk);
json_object *srv6_locator_json(const struct srv6_locator *loc);
json_object *srv6_locator_detailed_json(const struct srv6_locator *loc);
Expand Down

0 comments on commit a1d9830

Please sign in to comment.