zserv.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* Zebra daemon server header.
  2. * Copyright (C) 1997, 98 Kunihiro Ishiguro
  3. *
  4. * This file is part of GNU Zebra.
  5. *
  6. * GNU Zebra is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2, or (at your option) any
  9. * later version.
  10. *
  11. * GNU Zebra is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  18. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. * 02111-1307, USA.
  20. */
  21. #ifndef _ZEBRA_ZSERV_H
  22. #define _ZEBRA_ZSERV_H
  23. #include "rib.h"
  24. #include "if.h"
  25. #include "workqueue.h"
  26. #include "vrf.h"
  27. /* Default port information. */
  28. #define ZEBRA_VTY_PORT 2601
  29. /* Default configuration filename. */
  30. #define DEFAULT_CONFIG_FILE "zebra.conf"
  31. /* Client structure. */
  32. struct zserv
  33. {
  34. /* Client file descriptor. */
  35. int sock;
  36. /* Input/output buffer to the client. */
  37. struct stream *ibuf;
  38. struct stream *obuf;
  39. /* Buffer of data waiting to be written to client. */
  40. struct buffer *wb;
  41. /* Threads for read/write. */
  42. struct thread *t_read;
  43. struct thread *t_write;
  44. /* Thread for delayed close. */
  45. struct thread *t_suicide;
  46. /* default routing table this client munges */
  47. int rtm_table;
  48. /* This client's redistribute flag. */
  49. vrf_bitmap_t redist[ZEBRA_ROUTE_MAX];
  50. /* Redistribute default route flag. */
  51. vrf_bitmap_t redist_default;
  52. /* Interface information. */
  53. vrf_bitmap_t ifinfo;
  54. /* Router-id information. */
  55. vrf_bitmap_t ridinfo;
  56. /* client's protocol */
  57. u_char proto;
  58. /* Statistics */
  59. u_int32_t redist_v4_add_cnt;
  60. u_int32_t redist_v4_del_cnt;
  61. u_int32_t redist_v6_add_cnt;
  62. u_int32_t redist_v6_del_cnt;
  63. u_int32_t v4_route_add_cnt;
  64. u_int32_t v4_route_upd8_cnt;
  65. u_int32_t v4_route_del_cnt;
  66. u_int32_t v6_route_add_cnt;
  67. u_int32_t v6_route_del_cnt;
  68. u_int32_t v6_route_upd8_cnt;
  69. u_int32_t connected_rt_add_cnt;
  70. u_int32_t connected_rt_del_cnt;
  71. u_int32_t ifup_cnt;
  72. u_int32_t ifdown_cnt;
  73. u_int32_t ifadd_cnt;
  74. u_int32_t ifdel_cnt;
  75. time_t connect_time;
  76. time_t last_read_time;
  77. time_t last_write_time;
  78. time_t nh_reg_time;
  79. time_t nh_dereg_time;
  80. time_t nh_last_upd_time;
  81. int last_read_cmd;
  82. int last_write_cmd;
  83. };
  84. /* Zebra instance */
  85. struct zebra_t
  86. {
  87. /* Thread master */
  88. struct thread_master *master;
  89. struct list *client_list;
  90. /* default table */
  91. int rtm_table_default;
  92. /* rib work queue */
  93. struct work_queue *ribq;
  94. struct meta_queue *mq;
  95. };
  96. /* Prototypes. */
  97. extern void zebra_init (void);
  98. extern void zebra_if_init (void);
  99. extern void zebra_zserv_socket_init (char *path);
  100. extern void hostinfo_get (void);
  101. extern void rib_init (void);
  102. extern void interface_list (struct zebra_vrf *);
  103. extern void route_read (struct zebra_vrf *);
  104. extern void kernel_init (struct zebra_vrf *);
  105. extern void kernel_terminate (struct zebra_vrf *);
  106. extern void zebra_route_map_init (void);
  107. extern void zebra_snmp_init (void);
  108. extern void zebra_vty_init (void);
  109. extern int zsend_interface_add (struct zserv *, struct interface *);
  110. extern int zsend_interface_delete (struct zserv *, struct interface *);
  111. extern int zsend_interface_address (int, struct zserv *, struct interface *,
  112. struct connected *);
  113. extern int zsend_interface_update (int, struct zserv *, struct interface *);
  114. extern int zsend_route_multipath (int, struct zserv *, struct prefix *,
  115. struct rib *);
  116. extern int zsend_router_id_update (struct zserv *, struct prefix *,
  117. vrf_id_t);
  118. extern int zsend_interface_link_params (struct zserv *, struct interface *);
  119. extern pid_t pid;
  120. extern void zserv_create_header(struct stream *s, uint16_t cmd, vrf_id_t);
  121. extern int zebra_server_send_message(struct zserv *client);
  122. #endif /* _ZEBRA_ZEBRA_H */