]>
Commit | Line | Data |
---|---|---|
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 | ||
960b9a53 | 30 | PREDECL_RBTREE_UNIQ(lspdb); |
4bef0ec4 | 31 | |
eab88f36 | 32 | struct isis; |
eb5d44eb | 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 */ | |
d62a17ae | 37 | struct isis_lsp { |
4bef0ec4 DL |
38 | struct lspdb_item dbe; |
39 | ||
af8ac8f9 CF |
40 | struct isis_lsp_hdr hdr; |
41 | struct stream *pdu; /* full pdu lsp */ | |
d62a17ae | 42 | union { |
43 | struct list *frags; | |
44 | struct isis_lsp *zero_lsp; | |
45 | } lspu; | |
d7c0a89a | 46 | uint32_t SSNflags[ISIS_MAX_CIRCUITS]; |
d62a17ae | 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; | |
af8ac8f9 | 55 | struct isis_tlvs *tlvs; |
1eb7c3a1 | 56 | |
a6b60da9 | 57 | time_t flooding_time; |
1eb7c3a1 CF |
58 | struct list *flooding_neighbors[TX_LSP_CIRCUIT_SCOPED + 1]; |
59 | char *flooding_interface; | |
a6b60da9 | 60 | bool flooding_circuit_scoped; |
eb5d44eb | 61 | }; |
62 | ||
4bef0ec4 | 63 | extern int lspdb_compare(const struct isis_lsp *a, const struct isis_lsp *b); |
960b9a53 | 64 | DECLARE_RBTREE_UNIQ(lspdb, struct isis_lsp, dbe, lspdb_compare); |
4bef0ec4 DL |
65 | |
66 | void lsp_db_init(struct lspdb_head *head); | |
67 | void lsp_db_fini(struct lspdb_head *head); | |
d62a17ae | 68 | int lsp_tick(struct thread *thread); |
eb5d44eb | 69 | |
d62a17ae | 70 | int lsp_generate(struct isis_area *area, int level); |
691f3e76 | 71 | #define lsp_regenerate_schedule(area, level, all_pseudo) \ |
f93025e1 | 72 | _lsp_regenerate_schedule((area), (level), (all_pseudo), true, \ |
691f3e76 CF |
73 | __func__, __FILE__, __LINE__) |
74 | int _lsp_regenerate_schedule(struct isis_area *area, int level, | |
f93025e1 CF |
75 | int all_pseudo, bool postpone, |
76 | const char *func, const char *file, int line); | |
d62a17ae | 77 | int lsp_generate_pseudo(struct isis_circuit *circuit, int level); |
78 | int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level); | |
eb5d44eb | 79 | |
a4777e46 IR |
80 | bool isis_level2_adj_up(struct isis_area *area); |
81 | ||
af8ac8f9 CF |
82 | struct isis_lsp *lsp_new(struct isis_area *area, uint8_t *lsp_id, |
83 | uint16_t rem_lifetime, uint32_t seq_num, | |
8f5dbe18 CF |
84 | uint8_t lsp_bits, uint16_t checksum, |
85 | struct isis_lsp *lsp0, int level); | |
af8ac8f9 CF |
86 | struct isis_lsp *lsp_new_from_recv(struct isis_lsp_hdr *hdr, |
87 | struct isis_tlvs *tlvs, | |
88 | struct stream *stream, struct isis_lsp *lsp0, | |
89 | struct isis_area *area, int level); | |
4bef0ec4 DL |
90 | void lsp_insert(struct lspdb_head *head, struct isis_lsp *lsp); |
91 | struct isis_lsp *lsp_search(struct lspdb_head *head, const uint8_t *id); | |
eb5d44eb | 92 | |
4bef0ec4 DL |
93 | void lsp_build_list(struct lspdb_head *head, const uint8_t *start_id, |
94 | const uint8_t *stop_id, uint8_t num_lsps, | |
95 | struct list *list); | |
96 | void lsp_build_list_nonzero_ht(struct lspdb_head *head, | |
97 | const uint8_t *start_id, | |
98 | const uint8_t *stop_id, struct list *list); | |
99 | void lsp_search_and_destroy(struct lspdb_head *head, const uint8_t *id); | |
d7c0a89a | 100 | void lsp_purge_pseudo(uint8_t *id, struct isis_circuit *circuit, int level); |
af8ac8f9 | 101 | void lsp_purge_non_exist(int level, struct isis_lsp_hdr *hdr, |
d62a17ae | 102 | struct isis_area *area); |
eb5d44eb | 103 | |
104 | #define LSP_EQUAL 1 | |
105 | #define LSP_NEWER 2 | |
106 | #define LSP_OLDER 3 | |
107 | ||
c83dcd3f | 108 | #define LSP_PSEUDO_ID(I) ((I)[ISIS_SYS_ID_LEN]) |
109 | #define LSP_FRAGMENT(I) ((I)[ISIS_SYS_ID_LEN + 1]) | |
d62a17ae | 110 | #define OWNLSPID(I) \ |
111 | memcpy((I), isis->sysid, ISIS_SYS_ID_LEN); \ | |
112 | (I)[ISIS_SYS_ID_LEN] = 0; \ | |
113 | (I)[ISIS_SYS_ID_LEN + 1] = 0 | |
d7c0a89a | 114 | int lsp_id_cmp(uint8_t *id1, uint8_t *id2); |
af8ac8f9 CF |
115 | int lsp_compare(char *areatag, struct isis_lsp *lsp, uint32_t seqno, |
116 | uint16_t checksum, uint16_t rem_lifetime); | |
117 | void lsp_update(struct isis_lsp *lsp, struct isis_lsp_hdr *hdr, | |
118 | struct isis_tlvs *tlvs, struct stream *stream, | |
164066e4 | 119 | struct isis_area *area, int level, bool confusion); |
af8ac8f9 | 120 | void lsp_inc_seqno(struct isis_lsp *lsp, uint32_t seqno); |
7533cad7 QY |
121 | void lspid_print(uint8_t *lsp_id, char *dest, size_t dest_len, char dynhost, |
122 | char frag, struct isis *isis); | |
eab88f36 K |
123 | void lsp_print(struct isis_lsp *lsp, struct vty *vty, char dynhost, |
124 | struct isis *isis); | |
125 | void lsp_print_detail(struct isis_lsp *lsp, struct vty *vty, char dynhost, | |
126 | struct isis *isis); | |
4bef0ec4 | 127 | int lsp_print_all(struct vty *vty, struct lspdb_head *head, char detail, |
eab88f36 | 128 | char dynhost, struct isis *isis); |
3f045a08 | 129 | /* sets SRMflags for all active circuits of an lsp */ |
9b39405f | 130 | void lsp_set_all_srmflags(struct isis_lsp *lsp, bool set); |
ddb33326 | 131 | |
98a49636 RW |
132 | #define LSP_ITER_CONTINUE 0 |
133 | #define LSP_ITER_STOP -1 | |
134 | ||
135 | /* Callback used by isis_lsp_iterate_ip_reach() function. */ | |
136 | struct isis_subtlvs; | |
137 | typedef int (*lsp_ip_reach_iter_cb)(const struct prefix *prefix, | |
138 | uint32_t metric, bool external, | |
139 | struct isis_subtlvs *subtlvs, void *arg); | |
140 | ||
141 | /* Callback used by isis_lsp_iterate_is_reach() function. */ | |
142 | typedef int (*lsp_is_reach_iter_cb)(const uint8_t *id, uint32_t metric, | |
143 | bool oldmetric, | |
144 | struct isis_ext_subtlvs *subtlvs, | |
145 | void *arg); | |
146 | ||
147 | int isis_lsp_iterate_ip_reach(struct isis_lsp *lsp, int family, uint16_t mtid, | |
148 | lsp_ip_reach_iter_cb cb, void *arg); | |
149 | int isis_lsp_iterate_is_reach(struct isis_lsp *lsp, uint16_t mtid, | |
150 | lsp_is_reach_iter_cb cb, void *arg); | |
151 | ||
ddb33326 CF |
152 | #define lsp_flood(lsp, circuit) \ |
153 | _lsp_flood((lsp), (circuit), __func__, __FILE__, __LINE__) | |
154 | void _lsp_flood(struct isis_lsp *lsp, struct isis_circuit *circuit, | |
155 | const char *func, const char *file, int line); | |
a5b5e946 | 156 | void lsp_init(void); |
3f045a08 | 157 | |
eb5d44eb | 158 | #endif /* ISIS_LSP */ |