isis_lsp.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. #ifndef _ZEBRA_ISIS_LSP_H
  23. #define _ZEBRA_ISIS_LSP_H
  24. /* Structure for isis_lsp, this structure will only support the fixed
  25. * System ID (Currently 6) (atleast for now). In order to support more
  26. * We will have to split the header into two parts, and for readability
  27. * sake it should better be avoided */
  28. struct isis_lsp
  29. {
  30. struct isis_fixed_hdr *isis_header; /* normally equals pdu */
  31. struct isis_link_state_hdr *lsp_header; /* pdu + isis_header_len */
  32. struct stream *pdu; /* full pdu lsp */
  33. union
  34. {
  35. struct list *frags;
  36. struct isis_lsp *zero_lsp;
  37. } lspu;
  38. u_int32_t auth_tlv_offset; /* authentication TLV position in the pdu */
  39. u_int32_t SRMflags[ISIS_MAX_CIRCUITS];
  40. u_int32_t SSNflags[ISIS_MAX_CIRCUITS];
  41. int level; /* L1 or L2? */
  42. int scheduled; /* scheduled for sending */
  43. time_t installed;
  44. time_t last_generated;
  45. int own_lsp;
  46. #ifdef TOPOLOGY_GENERATE
  47. int from_topology;
  48. struct thread *t_lsp_top_ref;
  49. #endif
  50. /* used for 60 second counting when rem_lifetime is zero */
  51. int age_out;
  52. struct isis_area *area;
  53. struct tlvs tlv_data; /* Simplifies TLV access */
  54. };
  55. dict_t *lsp_db_init (void);
  56. void lsp_db_destroy (dict_t * lspdb);
  57. int lsp_tick (struct thread *thread);
  58. int lsp_generate (struct isis_area *area, int level);
  59. int lsp_regenerate_schedule (struct isis_area *area, int level,
  60. int all_pseudo);
  61. int lsp_generate_pseudo (struct isis_circuit *circuit, int level);
  62. int lsp_regenerate_schedule_pseudo (struct isis_circuit *circuit, int level);
  63. struct isis_lsp *lsp_new (struct isis_area *area, u_char * lsp_id,
  64. u_int16_t rem_lifetime,
  65. u_int32_t seq_num, u_int8_t lsp_bits,
  66. u_int16_t checksum, int level);
  67. struct isis_lsp *lsp_new_from_stream_ptr (struct stream *stream,
  68. u_int16_t pdu_len,
  69. struct isis_lsp *lsp0,
  70. struct isis_area *area,
  71. int level);
  72. void lsp_insert (struct isis_lsp *lsp, dict_t * lspdb);
  73. struct isis_lsp *lsp_search (u_char * id, dict_t * lspdb);
  74. void lsp_build_list (u_char * start_id, u_char * stop_id, u_char num_lsps,
  75. struct list *list, dict_t * lspdb);
  76. void lsp_build_list_nonzero_ht (u_char * start_id, u_char * stop_id,
  77. struct list *list, dict_t * lspdb);
  78. void lsp_build_list_ssn (struct isis_circuit *circuit, u_char num_lsps,
  79. struct list *list, dict_t * lspdb);
  80. void lsp_search_and_destroy (u_char * id, dict_t * lspdb);
  81. void lsp_purge_pseudo (u_char * id, struct isis_circuit *circuit, int level);
  82. void lsp_purge_non_exist (int level,
  83. struct isis_link_state_hdr *lsp_hdr,
  84. struct isis_area *area);
  85. #define LSP_EQUAL 1
  86. #define LSP_NEWER 2
  87. #define LSP_OLDER 3
  88. #define LSP_PSEUDO_ID(I) ((I)[ISIS_SYS_ID_LEN])
  89. #define LSP_FRAGMENT(I) ((I)[ISIS_SYS_ID_LEN + 1])
  90. #define OWNLSPID(I) \
  91. memcpy ((I), isis->sysid, ISIS_SYS_ID_LEN);\
  92. (I)[ISIS_SYS_ID_LEN] = 0;\
  93. (I)[ISIS_SYS_ID_LEN + 1] = 0
  94. int lsp_id_cmp (u_char * id1, u_char * id2);
  95. int lsp_compare (char *areatag, struct isis_lsp *lsp, u_int32_t seq_num,
  96. u_int16_t checksum, u_int16_t rem_lifetime);
  97. void lsp_update (struct isis_lsp *lsp, struct stream *stream,
  98. struct isis_area *area, int level);
  99. void lsp_inc_seqnum (struct isis_lsp *lsp, u_int32_t seq_num);
  100. void lsp_print (struct isis_lsp *lsp, struct vty *vty, char dynhost);
  101. void lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost);
  102. int lsp_print_all (struct vty *vty, dict_t * lspdb, char detail,
  103. char dynhost);
  104. const char *lsp_bits2string (u_char *);
  105. /* sets SRMflags for all active circuits of an lsp */
  106. void lsp_set_all_srmflags (struct isis_lsp *lsp);
  107. #ifdef TOPOLOGY_GENERATE
  108. void generate_topology_lsps (struct isis_area *area);
  109. void remove_topology_lsps (struct isis_area *area);
  110. void build_topology_lsp_data (struct isis_lsp *lsp,
  111. struct isis_area *area, int lsp_top_num);
  112. #endif /* TOPOLOGY_GENERATE */
  113. #endif /* ISIS_LSP */