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