]> git.proxmox.com Git - mirror_frr.git/blame - isisd/isis_lsp.h
zebra: Fix label manager memory leak (#5680)
[mirror_frr.git] / isisd / isis_lsp.h
CommitLineData
eb5d44eb 1/*
d62a17ae 2 * IS-IS Rout(e)ing protocol - isis_lsp.h
eb5d44eb 3 * LSP processing
4 *
5 * Copyright (C) 2001,2002 Sampo Saaristo
d62a17ae 6 * Tampere University of Technology
eb5d44eb 7 * Institute of Communications Engineering
8 *
d62a17ae 9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public Licenseas published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
eb5d44eb 12 * any later version.
13 *
d62a17ae 14 * This program is distributed in the hope that it will be useful,but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eb5d44eb 17 * more details.
896014f4
DL
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; see the file COPYING; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
eb5d44eb 22 */
23
24#ifndef _ZEBRA_ISIS_LSP_H
25#define _ZEBRA_ISIS_LSP_H
26
4bef0ec4 27#include "lib/typesafe.h"
af8ac8f9
CF
28#include "isisd/isis_pdu.h"
29
4bef0ec4
DL
30PREDECL_RBTREE_UNIQ(lspdb)
31
eb5d44eb 32/* Structure for isis_lsp, this structure will only support the fixed
33 * System ID (Currently 6) (atleast for now). In order to support more
34 * We will have to split the header into two parts, and for readability
35 * sake it should better be avoided */
d62a17ae 36struct isis_lsp {
4bef0ec4
DL
37 struct lspdb_item dbe;
38
af8ac8f9
CF
39 struct isis_lsp_hdr hdr;
40 struct stream *pdu; /* full pdu lsp */
d62a17ae 41 union {
42 struct list *frags;
43 struct isis_lsp *zero_lsp;
44 } lspu;
d7c0a89a 45 uint32_t SSNflags[ISIS_MAX_CIRCUITS];
d62a17ae 46 int level; /* L1 or L2? */
47 int scheduled; /* scheduled for sending */
48 time_t installed;
49 time_t last_generated;
50 int own_lsp;
51 /* used for 60 second counting when rem_lifetime is zero */
52 int age_out;
53 struct isis_area *area;
af8ac8f9 54 struct isis_tlvs *tlvs;
1eb7c3a1 55
a6b60da9 56 time_t flooding_time;
1eb7c3a1
CF
57 struct list *flooding_neighbors[TX_LSP_CIRCUIT_SCOPED + 1];
58 char *flooding_interface;
a6b60da9 59 bool flooding_circuit_scoped;
eb5d44eb 60};
61
4bef0ec4
DL
62extern int lspdb_compare(const struct isis_lsp *a, const struct isis_lsp *b);
63DECLARE_RBTREE_UNIQ(lspdb, struct isis_lsp, dbe, lspdb_compare)
64
65void lsp_db_init(struct lspdb_head *head);
66void lsp_db_fini(struct lspdb_head *head);
d62a17ae 67int lsp_tick(struct thread *thread);
eb5d44eb 68
d62a17ae 69int lsp_generate(struct isis_area *area, int level);
691f3e76 70#define lsp_regenerate_schedule(area, level, all_pseudo) \
f93025e1 71 _lsp_regenerate_schedule((area), (level), (all_pseudo), true, \
691f3e76
CF
72 __func__, __FILE__, __LINE__)
73int _lsp_regenerate_schedule(struct isis_area *area, int level,
f93025e1
CF
74 int all_pseudo, bool postpone,
75 const char *func, const char *file, int line);
d62a17ae 76int lsp_generate_pseudo(struct isis_circuit *circuit, int level);
77int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level);
eb5d44eb 78
af8ac8f9
CF
79struct isis_lsp *lsp_new(struct isis_area *area, uint8_t *lsp_id,
80 uint16_t rem_lifetime, uint32_t seq_num,
8f5dbe18
CF
81 uint8_t lsp_bits, uint16_t checksum,
82 struct isis_lsp *lsp0, int level);
af8ac8f9
CF
83struct isis_lsp *lsp_new_from_recv(struct isis_lsp_hdr *hdr,
84 struct isis_tlvs *tlvs,
85 struct stream *stream, struct isis_lsp *lsp0,
86 struct isis_area *area, int level);
4bef0ec4
DL
87void lsp_insert(struct lspdb_head *head, struct isis_lsp *lsp);
88struct isis_lsp *lsp_search(struct lspdb_head *head, const uint8_t *id);
eb5d44eb 89
4bef0ec4
DL
90void lsp_build_list(struct lspdb_head *head, const uint8_t *start_id,
91 const uint8_t *stop_id, uint8_t num_lsps,
92 struct list *list);
93void lsp_build_list_nonzero_ht(struct lspdb_head *head,
94 const uint8_t *start_id,
95 const uint8_t *stop_id, struct list *list);
96void lsp_search_and_destroy(struct lspdb_head *head, const uint8_t *id);
d7c0a89a 97void lsp_purge_pseudo(uint8_t *id, struct isis_circuit *circuit, int level);
af8ac8f9 98void lsp_purge_non_exist(int level, struct isis_lsp_hdr *hdr,
d62a17ae 99 struct isis_area *area);
eb5d44eb 100
101#define LSP_EQUAL 1
102#define LSP_NEWER 2
103#define LSP_OLDER 3
104
c83dcd3f 105#define LSP_PSEUDO_ID(I) ((I)[ISIS_SYS_ID_LEN])
106#define LSP_FRAGMENT(I) ((I)[ISIS_SYS_ID_LEN + 1])
d62a17ae 107#define OWNLSPID(I) \
108 memcpy((I), isis->sysid, ISIS_SYS_ID_LEN); \
109 (I)[ISIS_SYS_ID_LEN] = 0; \
110 (I)[ISIS_SYS_ID_LEN + 1] = 0
d7c0a89a 111int lsp_id_cmp(uint8_t *id1, uint8_t *id2);
af8ac8f9
CF
112int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno,
113 uint16_t checksum, uint16_t rem_lifetime);
114void lsp_update(struct isis_lsp *lsp, struct isis_lsp_hdr *hdr,
115 struct isis_tlvs *tlvs, struct stream *stream,
164066e4 116 struct isis_area *area, int level, bool confusion);
af8ac8f9 117void lsp_inc_seqno(struct isis_lsp *lsp, uint32_t seqno);
0d6fb551 118void lspid_print(uint8_t *lsp_id, char *dest, char dynhost, char frag);
d62a17ae 119void lsp_print(struct isis_lsp *lsp, struct vty *vty, char dynhost);
120void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost);
4bef0ec4
DL
121int lsp_print_all(struct vty *vty, struct lspdb_head *head, char detail,
122 char dynhost);
3f045a08 123/* sets SRMflags for all active circuits of an lsp */
9b39405f 124void lsp_set_all_srmflags(struct isis_lsp *lsp, bool set);
ddb33326
CF
125
126#define lsp_flood(lsp, circuit) \
127 _lsp_flood((lsp), (circuit), __func__, __FILE__, __LINE__)
128void _lsp_flood(struct isis_lsp *lsp, struct isis_circuit *circuit,
129 const char *func, const char *file, int line);
a5b5e946 130void lsp_init(void);
3f045a08 131
eb5d44eb 132#endif /* ISIS_LSP */