]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
eb5d44eb | 2 | /* |
d62a17ae | 3 | * IS-IS Rout(e)ing protocol - isis_lsp.h |
eb5d44eb | 4 | * LSP processing |
5 | * | |
6 | * Copyright (C) 2001,2002 Sampo Saaristo | |
d62a17ae | 7 | * Tampere University of Technology |
eb5d44eb | 8 | * Institute of Communications Engineering |
eb5d44eb | 9 | */ |
10 | ||
11 | #ifndef _ZEBRA_ISIS_LSP_H | |
12 | #define _ZEBRA_ISIS_LSP_H | |
13 | ||
4bef0ec4 | 14 | #include "lib/typesafe.h" |
af8ac8f9 CF |
15 | #include "isisd/isis_pdu.h" |
16 | ||
960b9a53 | 17 | PREDECL_RBTREE_UNIQ(lspdb); |
4bef0ec4 | 18 | |
eab88f36 | 19 | struct isis; |
eb5d44eb | 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 */ | |
d62a17ae | 24 | struct isis_lsp { |
4bef0ec4 DL |
25 | struct lspdb_item dbe; |
26 | ||
af8ac8f9 CF |
27 | struct isis_lsp_hdr hdr; |
28 | struct stream *pdu; /* full pdu lsp */ | |
d62a17ae | 29 | union { |
30 | struct list *frags; | |
31 | struct isis_lsp *zero_lsp; | |
32 | } lspu; | |
d7c0a89a | 33 | uint32_t SSNflags[ISIS_MAX_CIRCUITS]; |
d62a17ae | 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; | |
af8ac8f9 | 42 | struct isis_tlvs *tlvs; |
1eb7c3a1 | 43 | |
a6b60da9 | 44 | time_t flooding_time; |
1eb7c3a1 CF |
45 | struct list *flooding_neighbors[TX_LSP_CIRCUIT_SCOPED + 1]; |
46 | char *flooding_interface; | |
a6b60da9 | 47 | bool flooding_circuit_scoped; |
eb5d44eb | 48 | }; |
49 | ||
4bef0ec4 | 50 | extern int lspdb_compare(const struct isis_lsp *a, const struct isis_lsp *b); |
960b9a53 | 51 | DECLARE_RBTREE_UNIQ(lspdb, struct isis_lsp, dbe, lspdb_compare); |
4bef0ec4 DL |
52 | |
53 | void lsp_db_init(struct lspdb_head *head); | |
54 | void lsp_db_fini(struct lspdb_head *head); | |
cc9f21da | 55 | void lsp_tick(struct thread *thread); |
49b27ea2 | 56 | void set_overload_on_start_timer(struct thread *thread); |
eb5d44eb | 57 | |
d62a17ae | 58 | int lsp_generate(struct isis_area *area, int level); |
691f3e76 | 59 | #define lsp_regenerate_schedule(area, level, all_pseudo) \ |
f93025e1 | 60 | _lsp_regenerate_schedule((area), (level), (all_pseudo), true, \ |
691f3e76 CF |
61 | __func__, __FILE__, __LINE__) |
62 | int _lsp_regenerate_schedule(struct isis_area *area, int level, | |
f93025e1 CF |
63 | int all_pseudo, bool postpone, |
64 | const char *func, const char *file, int line); | |
d62a17ae | 65 | int lsp_generate_pseudo(struct isis_circuit *circuit, int level); |
66 | int lsp_regenerate_schedule_pseudo(struct isis_circuit *circuit, int level); | |
eb5d44eb | 67 | |
a4777e46 IR |
68 | bool isis_level2_adj_up(struct isis_area *area); |
69 | ||
af8ac8f9 CF |
70 | struct isis_lsp *lsp_new(struct isis_area *area, uint8_t *lsp_id, |
71 | uint16_t rem_lifetime, uint32_t seq_num, | |
8f5dbe18 CF |
72 | uint8_t lsp_bits, uint16_t checksum, |
73 | struct isis_lsp *lsp0, int level); | |
af8ac8f9 CF |
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); | |
4bef0ec4 DL |
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); | |
eb5d44eb | 80 | |
4bef0ec4 DL |
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); | |
d7c0a89a | 88 | void lsp_purge_pseudo(uint8_t *id, struct isis_circuit *circuit, int level); |
af8ac8f9 | 89 | void lsp_purge_non_exist(int level, struct isis_lsp_hdr *hdr, |
d62a17ae | 90 | struct isis_area *area); |
eb5d44eb | 91 | |
92 | #define LSP_EQUAL 1 | |
93 | #define LSP_NEWER 2 | |
94 | #define LSP_OLDER 3 | |
95 | ||
c83dcd3f | 96 | #define LSP_PSEUDO_ID(I) ((I)[ISIS_SYS_ID_LEN]) |
97 | #define LSP_FRAGMENT(I) ((I)[ISIS_SYS_ID_LEN + 1]) | |
d62a17ae | 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 | |
d7c0a89a | 102 | int lsp_id_cmp(uint8_t *id1, uint8_t *id2); |
af8ac8f9 CF |
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, | |
164066e4 | 107 | struct isis_area *area, int level, bool confusion); |
af8ac8f9 | 108 | void lsp_inc_seqno(struct isis_lsp *lsp, uint32_t seqno); |
7533cad7 QY |
109 | void lspid_print(uint8_t *lsp_id, char *dest, size_t dest_len, char dynhost, |
110 | char frag, struct isis *isis); | |
a2cac12a JG |
111 | void lsp_print_common(struct isis_lsp *lsp, struct vty *vty, |
112 | struct json_object *json, char dynhost, | |
eab88f36 | 113 | struct isis *isis); |
a2cac12a JG |
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); | |
3f045a08 | 124 | /* sets SRMflags for all active circuits of an lsp */ |
9b39405f | 125 | void lsp_set_all_srmflags(struct isis_lsp *lsp, bool set); |
ddb33326 | 126 | |
98a49636 RW |
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 | ||
ddb33326 CF |
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); | |
a5b5e946 | 151 | void lsp_init(void); |
3f045a08 | 152 | |
eb5d44eb | 153 | #endif /* ISIS_LSP */ |