]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_flags.c
isisd: update struct isis_spftree with algorithm id
[mirror_frr.git] / isisd / isis_flags.c
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
eb5d44eb 2/*
3 * IS-IS Rout(e)ing protocol - isis_flags.c
4 * Routines for manipulation of SSN and SRM flags
5 *
6 * Copyright (C) 2001,2002 Sampo Saaristo
d62a17ae 7 * Tampere University of Technology
eb5d44eb 8 * Institute of Communications Engineering
eb5d44eb 9 */
10
eb5d44eb 11#include <zebra.h>
12#include "log.h"
13#include "linklist.h"
14
15#include "isisd/isis_constants.h"
16#include "isisd/isis_common.h"
17#include "isisd/isis_flags.h"
18
d62a17ae 19void flags_initialize(struct flags *flags)
c7350c48 20{
d62a17ae 21 flags->maxindex = 0;
22 flags->free_idcs = NULL;
c7350c48
PJ
23}
24
d62a17ae 25long int flags_get_index(struct flags *flags)
eb5d44eb 26{
d62a17ae 27 struct listnode *node;
28 long int index;
eb5d44eb 29
d62a17ae 30 if (flags->free_idcs == NULL || flags->free_idcs->count == 0) {
31 index = flags->maxindex++;
32 } else {
33 node = listhead(flags->free_idcs);
34 index = (long int)listgetdata(node);
35 listnode_delete(flags->free_idcs, (void *)index);
36 index--;
37 }
f390d2c7 38
d62a17ae 39 return index;
eb5d44eb 40}
41
d62a17ae 42void flags_free_index(struct flags *flags, long int index)
eb5d44eb 43{
d62a17ae 44 if (index + 1 == flags->maxindex) {
45 flags->maxindex--;
46 return;
47 }
c7350c48 48
d62a17ae 49 if (flags->free_idcs == NULL) {
50 flags->free_idcs = list_new();
51 }
f390d2c7 52
d62a17ae 53 listnode_add(flags->free_idcs, (void *)(index + 1));
f390d2c7 54
d62a17ae 55 return;
eb5d44eb 56}
57
d7c0a89a 58int flags_any_set(uint32_t *flags)
eb5d44eb 59{
d7c0a89a 60 uint32_t zero[ISIS_MAX_CIRCUITS];
d62a17ae 61 memset(zero, 0x00, ISIS_MAX_CIRCUITS * 4);
eb5d44eb 62
d62a17ae 63 return bcmp(flags, zero, ISIS_MAX_CIRCUITS * 4);
eb5d44eb 64}