]> git.proxmox.com Git - mirror_frr.git/blob - isisd/isis_lsp.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / isisd / isis_lsp.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * IS-IS Rout(e)ing protocol - isis_lsp.h
4 * LSP processing
5 *
6 * Copyright (C) 2001,2002 Sampo Saaristo
7 * Tampere University of Technology
8 * Institute of Communications Engineering
9 */
10
11 #ifndef _ZEBRA_ISIS_LSP_H
12 #define _ZEBRA_ISIS_LSP_H
13
14 #include "lib/typesafe.h"
15 #include "isisd/isis_pdu.h"
16
17 PREDECL_RBTREE_UNIQ(lspdb);
18
19 struct isis;
20 /* Structure for isis_lsp, this structure will only support the fixed
21 * System ID (Currently 6) (atleast for now). In order to support more
22 * We will have to split the header into two parts, and for readability
23 * sake it should better be avoided */
24 struct isis_lsp {
25 struct lspdb_item dbe;
26
27 struct isis_lsp_hdr hdr;
28 struct stream *pdu; /* full pdu lsp */
29 union {
30 struct list *frags;
31 struct isis_lsp *zero_lsp;
32 } lspu;
33 uint32_t SSNflags[ISIS_MAX_CIRCUITS];
34 int level; /* L1 or L2? */
35 int scheduled; /* scheduled for sending */
36 time_t installed;
37 time_t last_generated;
38 int own_lsp;
39 /* used for 60 second counting when rem_lifetime is zero */
40 int age_out;
41 struct isis_area *area;
42 struct isis_tlvs *tlvs;
43
44 time_t flooding_time;
45 struct list *flooding_neighbors[TX_LSP_CIRCUIT_SCOPED + 1];
46 char *flooding_interface;
47 bool flooding_circuit_scoped;
48 };
49
50 extern int lspdb_compare(const struct isis_lsp *a, const struct isis_lsp *b);
51 DECLARE_RBTREE_UNIQ(lspdb, struct isis_lsp, dbe, lspdb_compare);
52
53 void lsp_db_init(struct lspdb_head *head);
54 void lsp_db_fini(struct lspdb_head *head);
55 void lsp_tick(struct thread *thread);
56 void set_overload_on_start_timer(struct thread *thread);
57
58 int lsp_generate(struct isis_area *area, int level);
59 #define lsp_regenerate_schedule(area, level, all_pseudo) \
60 _lsp_regenerate_schedule((area), (level), (all_pseudo), true, \
61 __func__, __FILE__, __LINE__)
62 int _lsp_regenerate_schedule(struct isis_area *area, int level,
63 int all_pseudo, bool postpone,
64 const char *func, const char *file, int line);
65 int lsp_generate_pseudo(struct isis_circuit *circuit, int level);
66 int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level);
67
68 bool isis_level2_adj_up(struct isis_area *area);
69
70 struct isis_lsp *lsp_new(struct isis_area *area, uint8_t *lsp_id,
71 uint16_t rem_lifetime, uint32_t seq_num,
72 uint8_t lsp_bits, uint16_t checksum,
73 struct isis_lsp *lsp0, int level);
74 struct isis_lsp *lsp_new_from_recv(struct isis_lsp_hdr *hdr,
75 struct isis_tlvs *tlvs,
76 struct stream *stream, struct isis_lsp *lsp0,
77 struct isis_area *area, int level);
78 void lsp_insert(struct lspdb_head *head, struct isis_lsp *lsp);
79 struct isis_lsp *lsp_search(struct lspdb_head *head, const uint8_t *id);
80
81 void lsp_build_list(struct lspdb_head *head, const uint8_t *start_id,
82 const uint8_t *stop_id, uint8_t num_lsps,
83 struct list *list);
84 void lsp_build_list_nonzero_ht(struct lspdb_head *head,
85 const uint8_t *start_id,
86 const uint8_t *stop_id, struct list *list);
87 void lsp_search_and_destroy(struct lspdb_head *head, const uint8_t *id);
88 void lsp_purge_pseudo(uint8_t *id, struct isis_circuit *circuit, int level);
89 void lsp_purge_non_exist(int level, struct isis_lsp_hdr *hdr,
90 struct isis_area *area);
91
92 #define LSP_EQUAL 1
93 #define LSP_NEWER 2
94 #define LSP_OLDER 3
95
96 #define LSP_PSEUDO_ID(I) ((I)[ISIS_SYS_ID_LEN])
97 #define LSP_FRAGMENT(I) ((I)[ISIS_SYS_ID_LEN + 1])
98 #define OWNLSPID(I) \
99 memcpy((I), isis->sysid, ISIS_SYS_ID_LEN); \
100 (I)[ISIS_SYS_ID_LEN] = 0; \
101 (I)[ISIS_SYS_ID_LEN + 1] = 0
102 int lsp_id_cmp(uint8_t *id1, uint8_t *id2);
103 int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno,
104 uint16_t checksum, uint16_t rem_lifetime);
105 void lsp_update(struct isis_lsp *lsp, struct isis_lsp_hdr *hdr,
106 struct isis_tlvs *tlvs, struct stream *stream,
107 struct isis_area *area, int level, bool confusion);
108 void lsp_inc_seqno(struct isis_lsp *lsp, uint32_t seqno);
109 void lspid_print(uint8_t *lsp_id, char *dest, size_t dest_len, char dynhost,
110 char frag, struct isis *isis);
111 void lsp_print_common(struct isis_lsp *lsp, struct vty *vty,
112 struct json_object *json, char dynhost,
113 struct isis *isis);
114 void lsp_print_vty(struct isis_lsp *lsp, struct vty *vty, char dynhost,
115 struct isis *isis);
116 void lsp_print_json(struct isis_lsp *lsp, struct json_object *json,
117 char dynhost, struct isis *isis);
118 void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty,
119 struct json_object *json, char dynhost,
120 struct isis *isis);
121 int lsp_print_all(struct vty *vty, struct json_object *json,
122 struct lspdb_head *head, char detail, char dynhost,
123 struct isis *isis);
124 /* sets SRMflags for all active circuits of an lsp */
125 void lsp_set_all_srmflags(struct isis_lsp *lsp, bool set);
126
127 #define LSP_ITER_CONTINUE 0
128 #define LSP_ITER_STOP -1
129
130 /* Callback used by isis_lsp_iterate_ip_reach() function. */
131 struct isis_subtlvs;
132 typedef int (*lsp_ip_reach_iter_cb)(const struct prefix *prefix,
133 uint32_t metric, bool external,
134 struct isis_subtlvs *subtlvs, void *arg);
135
136 /* Callback used by isis_lsp_iterate_is_reach() function. */
137 typedef int (*lsp_is_reach_iter_cb)(const uint8_t *id, uint32_t metric,
138 bool oldmetric,
139 struct isis_ext_subtlvs *subtlvs,
140 void *arg);
141
142 int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid,
143 lsp_ip_reach_iter_cb cb, void *arg);
144 int isis_lsp_iterate_is_reach(struct isis_lsp *lsp, uint16_t mtid,
145 lsp_is_reach_iter_cb cb, void *arg);
146
147 #define lsp_flood(lsp, circuit) \
148 _lsp_flood((lsp), (circuit), __func__, __FILE__, __LINE__)
149 void _lsp_flood(struct isis_lsp *lsp, struct isis_circuit *circuit,
150 const char *func, const char *file, int line);
151 void lsp_init(void);
152
153 #endif /* ISIS_LSP */