paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
| 22 | #ifndef _ZEBRA_ZSERV_H |
| 23 | #define _ZEBRA_ZSERV_H |
| 24 | |
paul | 5b73a67 | 2004-07-23 15:26:14 +0000 | [diff] [blame] | 25 | #include "rib.h" |
paul | ec1a428 | 2005-11-24 15:15:17 +0000 | [diff] [blame] | 26 | #include "if.h" |
paul | 4d38fdb | 2005-04-28 17:35:14 +0000 | [diff] [blame] | 27 | #include "workqueue.h" |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 28 | #include "vrf.h" |
paul | 5b73a67 | 2004-07-23 15:26:14 +0000 | [diff] [blame] | 29 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 30 | /* Default port information. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 31 | #define ZEBRA_VTY_PORT 2601 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 32 | |
| 33 | /* Default configuration filename. */ |
| 34 | #define DEFAULT_CONFIG_FILE "zebra.conf" |
| 35 | |
| 36 | /* Client structure. */ |
| 37 | struct zserv |
| 38 | { |
| 39 | /* Client file descriptor. */ |
| 40 | int sock; |
| 41 | |
| 42 | /* Input/output buffer to the client. */ |
| 43 | struct stream *ibuf; |
| 44 | struct stream *obuf; |
| 45 | |
ajs | 719e974 | 2005-02-28 20:52:15 +0000 | [diff] [blame] | 46 | /* Buffer of data waiting to be written to client. */ |
| 47 | struct buffer *wb; |
| 48 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 49 | /* Threads for read/write. */ |
| 50 | struct thread *t_read; |
| 51 | struct thread *t_write; |
| 52 | |
ajs | 719e974 | 2005-02-28 20:52:15 +0000 | [diff] [blame] | 53 | /* Thread for delayed close. */ |
| 54 | struct thread *t_suicide; |
| 55 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 56 | /* default routing table this client munges */ |
| 57 | int rtm_table; |
| 58 | |
| 59 | /* This client's redistribute flag. */ |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 60 | vrf_bitmap_t redist[ZEBRA_ROUTE_MAX]; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | |
| 62 | /* Redistribute default route flag. */ |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 63 | vrf_bitmap_t redist_default; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 64 | |
| 65 | /* Interface information. */ |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 66 | vrf_bitmap_t ifinfo; |
hasso | 18a6dce | 2004-10-03 18:18:34 +0000 | [diff] [blame] | 67 | |
| 68 | /* Router-id information. */ |
Feng Lu | c99f348 | 2014-10-16 09:52:36 +0800 | [diff] [blame] | 69 | vrf_bitmap_t ridinfo; |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 70 | |
| 71 | /* client's protocol */ |
| 72 | u_char proto; |
Dinesh Dutt | 9ae8552 | 2015-05-19 17:47:22 -0700 | [diff] [blame^] | 73 | |
| 74 | /* Statistics */ |
| 75 | u_int32_t redist_v4_add_cnt; |
| 76 | u_int32_t redist_v4_del_cnt; |
| 77 | u_int32_t redist_v6_add_cnt; |
| 78 | u_int32_t redist_v6_del_cnt; |
| 79 | u_int32_t v4_route_add_cnt; |
| 80 | u_int32_t v4_route_upd8_cnt; |
| 81 | u_int32_t v4_route_del_cnt; |
| 82 | u_int32_t v6_route_add_cnt; |
| 83 | u_int32_t v6_route_del_cnt; |
| 84 | u_int32_t v6_route_upd8_cnt; |
| 85 | u_int32_t connected_rt_add_cnt; |
| 86 | u_int32_t connected_rt_del_cnt; |
| 87 | u_int32_t ifup_cnt; |
| 88 | u_int32_t ifdown_cnt; |
| 89 | u_int32_t ifadd_cnt; |
| 90 | u_int32_t ifdel_cnt; |
| 91 | |
| 92 | time_t connect_time; |
| 93 | time_t last_read_time; |
| 94 | time_t last_write_time; |
| 95 | time_t nh_reg_time; |
| 96 | time_t nh_dereg_time; |
| 97 | time_t nh_last_upd_time; |
| 98 | |
| 99 | int last_read_cmd; |
| 100 | int last_write_cmd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 101 | }; |
| 102 | |
paul | b21b19c | 2003-06-15 01:28:29 +0000 | [diff] [blame] | 103 | /* Zebra instance */ |
| 104 | struct zebra_t |
| 105 | { |
| 106 | /* Thread master */ |
| 107 | struct thread_master *master; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 108 | struct list *client_list; |
paul | b21b19c | 2003-06-15 01:28:29 +0000 | [diff] [blame] | 109 | |
| 110 | /* default table */ |
| 111 | int rtm_table_default; |
paul | 4d38fdb | 2005-04-28 17:35:14 +0000 | [diff] [blame] | 112 | |
| 113 | /* rib work queue */ |
| 114 | struct work_queue *ribq; |
Denis Ovsienko | e96f920 | 2008-06-02 12:03:22 +0000 | [diff] [blame] | 115 | struct meta_queue *mq; |
paul | b21b19c | 2003-06-15 01:28:29 +0000 | [diff] [blame] | 116 | }; |
| 117 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 118 | /* Prototypes. */ |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 119 | extern void zebra_init (void); |
| 120 | extern void zebra_if_init (void); |
Vyacheslav Trushkin | b511468 | 2011-11-25 18:51:48 +0400 | [diff] [blame] | 121 | extern void zebra_zserv_socket_init (char *path); |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 122 | extern void hostinfo_get (void); |
| 123 | extern void rib_init (void); |
Feng Lu | 758fb8f | 2014-07-03 18:23:09 +0800 | [diff] [blame] | 124 | extern void interface_list (struct zebra_vrf *); |
| 125 | extern void route_read (struct zebra_vrf *); |
| 126 | extern void kernel_init (struct zebra_vrf *); |
| 127 | extern void kernel_terminate (struct zebra_vrf *); |
Paul Jakma | 7514fb7 | 2007-05-02 16:05:35 +0000 | [diff] [blame] | 128 | extern void zebra_route_map_init (void); |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 129 | extern void zebra_snmp_init (void); |
| 130 | extern void zebra_vty_init (void); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 131 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 132 | extern int zsend_interface_add (struct zserv *, struct interface *); |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 133 | extern int zsend_interface_delete (struct zserv *, struct interface *); |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 134 | extern int zsend_interface_address (int, struct zserv *, struct interface *, |
| 135 | struct connected *); |
| 136 | extern int zsend_interface_update (int, struct zserv *, struct interface *); |
| 137 | extern int zsend_route_multipath (int, struct zserv *, struct prefix *, |
| 138 | struct rib *); |
Feng Lu | ac19a44 | 2015-05-22 11:40:07 +0200 | [diff] [blame] | 139 | extern int zsend_router_id_update (struct zserv *, struct prefix *, |
| 140 | vrf_id_t); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 141 | |
Olivier Dugeon | 15773a8 | 2016-04-19 18:29:55 +0200 | [diff] [blame] | 142 | extern int zsend_interface_link_params (struct zserv *, struct interface *); |
| 143 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 144 | extern pid_t pid; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 145 | |
Pradosh Mohapatra | 60cc959 | 2015-11-09 20:21:41 -0500 | [diff] [blame] | 146 | extern void zserv_create_header(struct stream *s, uint16_t cmd, vrf_id_t); |
| 147 | extern int zebra_server_send_message(struct zserv *client); |
| 148 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 149 | #endif /* _ZEBRA_ZEBRA_H */ |