]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_flags.c
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / isisd / isis_flags.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
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
7 * Tampere University of Technology
8 * Institute of Communications Engineering
9 */
10
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
19 void flags_initialize(struct flags *flags)
20 {
21 flags->maxindex = 0;
22 flags->free_idcs = NULL;
23 }
24
25 long int flags_get_index(struct flags *flags)
26 {
27 struct listnode *node;
28 long int index;
29
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 }
38
39 return index;
40 }
41
42 void flags_free_index(struct flags *flags, long int index)
43 {
44 if (index + 1 == flags->maxindex) {
45 flags->maxindex--;
46 return;
47 }
48
49 if (flags->free_idcs == NULL) {
50 flags->free_idcs = list_new();
51 }
52
53 listnode_add(flags->free_idcs, (void *)(index + 1));
54
55 return;
56 }
57
58 int flags_any_set(uint32_t *flags)
59 {
60 uint32_t zero[ISIS_MAX_CIRCUITS];
61 memset(zero, 0x00, ISIS_MAX_CIRCUITS * 4);
62
63 return bcmp(flags, zero, ISIS_MAX_CIRCUITS * 4);
64 }