blob: 6e7f745d2a3e2dbdde7a59c5e7022bb1f33aa06c [file] [log] [blame]
jardineb5d44e2003-12-23 08:09:43 +00001/*
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; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24#ifndef _ZEBRA_ISIS_LSP_H
25#define _ZEBRA_ISIS_LSP_H
26
jardineb5d44e2003-12-23 08:09:43 +000027/* Structure for isis_lsp, this structure will only support the fixed
28 * System ID (Currently 6) (atleast for now). In order to support more
29 * We will have to split the header into two parts, and for readability
30 * sake it should better be avoided */
31struct isis_lsp
32{
hassof390d2c2004-09-10 20:48:21 +000033 struct isis_fixed_hdr *isis_header; /* normally equals pdu */
34 struct isis_link_state_hdr *lsp_header; /* pdu + isis_header_len */
35 struct stream *pdu; /* full pdu lsp */
36 union
37 {
jardineb5d44e2003-12-23 08:09:43 +000038 struct list *frags;
39 struct isis_lsp *zero_lsp;
40 } lspu;
Josh Bailey3f045a02012-03-24 08:35:20 -070041 u_int32_t auth_tlv_offset; /* authentication TLV position in the pdu */
jardineb5d44e2003-12-23 08:09:43 +000042 u_int32_t SRMflags[ISIS_MAX_CIRCUITS];
43 u_int32_t SSNflags[ISIS_MAX_CIRCUITS];
hassof390d2c2004-09-10 20:48:21 +000044 int level; /* L1 or L2? */
hassof390d2c2004-09-10 20:48:21 +000045 int scheduled; /* scheduled for sending */
jardineb5d44e2003-12-23 08:09:43 +000046 time_t installed;
47 time_t last_generated;
jardineb5d44e2003-12-23 08:09:43 +000048 int own_lsp;
49#ifdef TOPOLOGY_GENERATE
50 int from_topology;
51 struct thread *t_lsp_top_ref;
52#endif
53 /* used for 60 second counting when rem_lifetime is zero */
hassof390d2c2004-09-10 20:48:21 +000054 int age_out;
hassof1082d12005-09-19 04:23:34 +000055 struct isis_area *area;
hassof390d2c2004-09-10 20:48:21 +000056 struct tlvs tlv_data; /* Simplifies TLV access */
jardineb5d44e2003-12-23 08:09:43 +000057};
58
59dict_t *lsp_db_init (void);
hassof390d2c2004-09-10 20:48:21 +000060void lsp_db_destroy (dict_t * lspdb);
jardineb5d44e2003-12-23 08:09:43 +000061int lsp_tick (struct thread *thread);
62
Josh Bailey3f045a02012-03-24 08:35:20 -070063int lsp_generate (struct isis_area *area, int level);
64int lsp_regenerate_schedule (struct isis_area *area, int level,
65 int all_pseudo);
66int lsp_generate_pseudo (struct isis_circuit *circuit, int level);
67int lsp_regenerate_schedule_pseudo (struct isis_circuit *circuit, int level);
jardineb5d44e2003-12-23 08:09:43 +000068
hassof390d2c2004-09-10 20:48:21 +000069struct isis_lsp *lsp_new (u_char * lsp_id, u_int16_t rem_lifetime,
70 u_int32_t seq_num, u_int8_t lsp_bits,
71 u_int16_t checksum, int level);
72struct isis_lsp *lsp_new_from_stream_ptr (struct stream *stream,
73 u_int16_t pdu_len,
74 struct isis_lsp *lsp0,
Josh Bailey3f045a02012-03-24 08:35:20 -070075 struct isis_area *area,
76 int level);
hassof390d2c2004-09-10 20:48:21 +000077void lsp_insert (struct isis_lsp *lsp, dict_t * lspdb);
78struct isis_lsp *lsp_search (u_char * id, dict_t * lspdb);
jardineb5d44e2003-12-23 08:09:43 +000079
Josh Bailey3f045a02012-03-24 08:35:20 -070080void lsp_build_list (u_char * start_id, u_char * stop_id, u_char num_lsps,
hassof390d2c2004-09-10 20:48:21 +000081 struct list *list, dict_t * lspdb);
82void lsp_build_list_nonzero_ht (u_char * start_id, u_char * stop_id,
83 struct list *list, dict_t * lspdb);
Josh Bailey3f045a02012-03-24 08:35:20 -070084void lsp_build_list_ssn (struct isis_circuit *circuit, u_char num_lsps,
85 struct list *list, dict_t * lspdb);
jardineb5d44e2003-12-23 08:09:43 +000086
hassof390d2c2004-09-10 20:48:21 +000087void lsp_search_and_destroy (u_char * id, dict_t * lspdb);
Josh Bailey3f045a02012-03-24 08:35:20 -070088void lsp_purge_pseudo (u_char * id, struct isis_circuit *circuit, int level);
hassof390d2c2004-09-10 20:48:21 +000089void lsp_purge_non_exist (struct isis_link_state_hdr *lsp_hdr,
90 struct isis_area *area);
jardineb5d44e2003-12-23 08:09:43 +000091
92#define LSP_EQUAL 1
93#define LSP_NEWER 2
94#define LSP_OLDER 3
95
hassoc83dcd32004-09-26 15:42:44 +000096#define LSP_PSEUDO_ID(I) ((I)[ISIS_SYS_ID_LEN])
97#define LSP_FRAGMENT(I) ((I)[ISIS_SYS_ID_LEN + 1])
jardineb5d44e2003-12-23 08:09:43 +000098#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
hassof390d2c2004-09-10 20:48:21 +0000102int lsp_id_cmp (u_char * id1, u_char * id2);
103int lsp_compare (char *areatag, struct isis_lsp *lsp, u_int32_t seq_num,
104 u_int16_t checksum, u_int16_t rem_lifetime);
Josh Bailey3f045a02012-03-24 08:35:20 -0700105void lsp_update (struct isis_lsp *lsp, struct stream *stream,
106 struct isis_area *area, int level);
jardineb5d44e2003-12-23 08:09:43 +0000107void lsp_inc_seqnum (struct isis_lsp *lsp, u_int32_t seq_num);
Josh Bailey3f045a02012-03-24 08:35:20 -0700108void lsp_print (struct isis_lsp *lsp, struct vty *vty, char dynhost);
109void lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost);
hassof390d2c2004-09-10 20:48:21 +0000110int lsp_print_all (struct vty *vty, dict_t * lspdb, char detail,
111 char dynhost);
hasso1cd80842004-10-07 20:07:40 +0000112const char *lsp_bits2string (u_char *);
jardineb5d44e2003-12-23 08:09:43 +0000113
Josh Bailey3f045a02012-03-24 08:35:20 -0700114/* sets SRMflags for all active circuits of an lsp */
115void lsp_set_all_srmflags (struct isis_lsp *lsp);
116
jardineb5d44e2003-12-23 08:09:43 +0000117#ifdef TOPOLOGY_GENERATE
118void generate_topology_lsps (struct isis_area *area);
119void remove_topology_lsps (struct isis_area *area);
120void build_topology_lsp_data (struct isis_lsp *lsp,
hassof390d2c2004-09-10 20:48:21 +0000121 struct isis_area *area, int lsp_top_num);
jardineb5d44e2003-12-23 08:09:43 +0000122#endif /* TOPOLOGY_GENERATE */
123
124#endif /* ISIS_LSP */