babeld_quagga_init();
/* init zebra client's structure and it's commands */
/* this replace kernel_setup && kernel_setup_socket */
- babelz_zebra_init ();
+ babelz_zebra_init(master);
/* Get zebra configuration file. */
zlog_set_level (NULL, ZLOG_DEST_STDOUT, ZLOG_DISABLED);
#include "xroute.h"
#include "util.h"
-void babelz_zebra_init(void);
-
-
/* we must use a pointer because of zclient.c's functions (new, free). */
struct zclient *zclient;
static int zebra_config_write (struct vty *vty);
#endif /* NO_DEBUG */
}
-void babelz_zebra_init(void)
+void babelz_zebra_init (struct thread_master *master)
{
- zclient = zclient_new();
+ zclient = zclient_new(master);
zclient_init(zclient, ZEBRA_ROUTE_BABEL, 0);
zclient->interface_add = babel_interface_add;
extern struct zclient *zclient;
-void babelz_zebra_init(void);
+void babelz_zebra_init(struct thread_master *);
void babel_zebra_close_connexion(void);
extern int debug_babel_config_write (struct vty *);
}
void
-bgp_zebra_init (void)
+bgp_zebra_init (struct thread_master *master)
{
/* Set default values. */
- zclient = zclient_new ();
+ zclient = zclient_new (master);
zclient_init (zclient, ZEBRA_ROUTE_BGP, 0);
zclient->router_id_update = bgp_router_id_update;
zclient->interface_add = bgp_interface_add;
extern struct stream *bgp_nexthop_buf;
extern struct stream *bgp_ifindices_buf;
-extern void bgp_zebra_init (void);
+extern void bgp_zebra_init(struct thread_master *master);
extern int bgp_if_update_all (void);
extern int bgp_config_write_maxpaths (struct vty *, struct bgp *, afi_t,
safi_t, int *);
bgp_scan_init ();
/* Init zebra. */
- bgp_zebra_init ();
+ bgp_zebra_init(master);
/* BGP VTY commands installation. */
bgp_vty_init ();
/* create the global 'isis' instance */
isis_new (1);
- isis_zebra_init ();
+ isis_zebra_init(master);
/* parse config file */
/* this is needed three times! because we have interfaces before the areas */
#endif /* 0 */
void
-isis_zebra_init ()
+isis_zebra_init (struct thread_master *master)
{
- zclient = zclient_new ();
+ zclient = zclient_new(master);
zclient_init (zclient, ZEBRA_ROUTE_ISIS, 0);
zclient->router_id_update = isis_router_id_update_zebra;
zclient->interface_add = isis_zebra_if_add;
extern struct zclient *zclient;
-void isis_zebra_init (void);
+void isis_zebra_init(struct thread_master *);
void isis_zebra_route_update (struct prefix *prefix,
struct isis_route_info *route_info);
int isis_distribute_list_update (int routetype);
/* Prototype for event manager. */
static void zclient_event (enum event, struct zclient *);
-extern struct thread_master *master;
-
char *zclient_serv_path = NULL;
/* This file local debug flag. */
/* Allocate zclient structure. */
struct zclient *
-zclient_new ()
+zclient_new (struct thread_master *master)
{
struct zclient *zclient;
zclient = XCALLOC (MTYPE_ZCLIENT, sizeof (struct zclient));
zclient->ibuf = stream_new (ZEBRA_MAX_PACKET_SIZ);
zclient->obuf = stream_new (ZEBRA_MAX_PACKET_SIZ);
zclient->wb = buffer_new(0);
+ zclient->master = master;
return zclient;
}
return zclient_failed(zclient);
break;
case BUFFER_PENDING:
- zclient->t_write = thread_add_write(master, zclient_flush_data,
+ zclient->t_write = thread_add_write(zclient->master, zclient_flush_data,
zclient, zclient->sock);
break;
case BUFFER_EMPTY:
THREAD_OFF(zclient->t_write);
break;
case BUFFER_PENDING:
- THREAD_WRITE_ON(master, zclient->t_write,
+ THREAD_WRITE_ON(zclient->master, zclient->t_write,
zclient_flush_data, zclient, zclient->sock);
break;
}
case ZCLIENT_SCHEDULE:
if (! zclient->t_connect)
zclient->t_connect =
- thread_add_event (master, zclient_connect, zclient, 0);
+ thread_add_event (zclient->master, zclient_connect, zclient, 0);
break;
case ZCLIENT_CONNECT:
if (zclient->fail >= 10)
zclient->fail < 3 ? 10 : 60);
if (! zclient->t_connect)
zclient->t_connect =
- thread_add_timer (master, zclient_connect, zclient,
+ thread_add_timer (zclient->master, zclient_connect, zclient,
zclient->fail < 3 ? 10 : 60);
break;
case ZCLIENT_READ:
zclient->t_read =
- thread_add_read (master, zclient_read, zclient, zclient->sock);
+ thread_add_read (zclient->master, zclient_read, zclient, zclient->sock);
break;
}
}
/* Structure for the zebra client. */
struct zclient
{
+ /* The thread master we schedule ourselves on */
+ struct thread_master *master;
+
/* Socket to zebra daemon. */
int sock;
};
/* Prototypes of zebra client service functions. */
-extern struct zclient *zclient_new (void);
+extern struct zclient *zclient_new (struct thread_master *);
extern void zclient_init (struct zclient *, int, u_short);
extern int zclient_start (struct zclient *);
extern void zclient_stop (struct zclient *);
}
void
-ospf6_zebra_init (void)
+ospf6_zebra_init (struct thread_master *master)
{
/* Allocate zebra structure. */
- zclient = zclient_new ();
+ zclient = zclient_new(master);
zclient_init (zclient, ZEBRA_ROUTE_OSPF6, 0);
zclient->router_id_update = ospf6_router_id_update_zebra;
zclient->interface_add = ospf6_zebra_if_add;
extern void ospf6_zebra_redistribute (int);
extern void ospf6_zebra_no_redistribute (int);
#define ospf6_zebra_is_redistribute(type) (zclient->redist[AFI_IP6][type].enabled)
-extern void ospf6_zebra_init (void);
+extern void ospf6_zebra_init (struct thread_master *);
extern void ospf6_zebra_add_discard (struct ospf6_route *request);
extern void ospf6_zebra_delete_discard (struct ospf6_route *request);
ospf6_area_init ();
ospf6_interface_init ();
ospf6_neighbor_init ();
- ospf6_zebra_init ();
+ ospf6_zebra_init(master);
ospf6_lsa_init ();
ospf6_spf_init ();
/* OSPFd inits. */
ospf_if_init ();
- ospf_zebra_init (instance);
+ ospf_zebra_init(master, instance);
/* OSPF vty inits. */
ospf_vty_init ();
}
void
-ospf_zebra_init (u_short instance)
+ospf_zebra_init (struct thread_master *master, u_short instance)
{
/* Allocate zebra structure. */
- zclient = zclient_new ();
+ zclient = zclient_new(master);
zclient_init (zclient, ZEBRA_ROUTE_OSPF, instance);
zclient->router_id_update = ospf_router_id_update_zebra;
zclient->interface_add = ospf_interface_add;
const char *, const char *);
extern int ospf_distance_unset (struct vty *, struct ospf *, const char *,
const char *, const char *);
-extern void ospf_zebra_init (u_short);
+extern void ospf_zebra_init(struct thread_master *, u_short);
#endif /* _ZEBRA_OSPF_ZEBRA_H */
/* RIP related initialization. */
rip_init ();
rip_if_init ();
- rip_zclient_init ();
+ rip_zclient_init(master);
rip_peer_init ();
/* Get configuration file. */
};
void
-rip_zclient_init ()
+rip_zclient_init (struct thread_master *master)
{
/* Set default value to the zebra client structure. */
- zclient = zclient_new ();
+ zclient = zclient_new(master);
zclient_init (zclient, ZEBRA_ROUTE_RIP, 0);
zclient->interface_add = rip_interface_add;
zclient->interface_delete = rip_interface_delete;
extern void rip_route_map_init (void);
extern void rip_route_map_reset (void);
extern void rip_snmp_init (void);
-extern void rip_zclient_init (void);
+extern void rip_zclient_init(struct thread_master *);
extern void rip_zclient_start (void);
extern void rip_zclient_reset (void);
extern void rip_offset_init (void);
/* RIPngd inits. */
ripng_init ();
- zebra_init ();
+ zebra_init(master);
ripng_peer_init ();
/* Get configuration file. */
/* Initialize zebra structure and it's commands. */
void
-zebra_init ()
+zebra_init (struct thread_master *master)
{
/* Allocate zebra structure. */
- zclient = zclient_new ();
+ zclient = zclient_new(master);
zclient_init (zclient, ZEBRA_ROUTE_RIPNG, 0);
zclient->interface_up = ripng_interface_up;
extern void ripng_route_map_reset (void);
extern void ripng_terminate (void);
/* zclient_init() is done by ripng_zebra.c:zebra_init() */
-extern void zebra_init (void);
+extern void zebra_init(struct thread_master *);
extern void ripng_zclient_start (void);
extern void ripng_zclient_reset (void);
extern void ripng_offset_init (void);
global_test_init (void)
{
master = thread_master_create ();
- zclient = zclient_new ();
+ zclient = zclient_new(master);
bgp_master_init ();
bgp_option_set (BGP_OPT_NO_LISTEN);
int
main (int argc, char **argv)
{
+ struct thread_master *master;
FILE *fp;
if (argc == 1)
usage_exit ();
+ master = thread_master_create();
/* Establish connection to zebra. */
- zclient = zclient_new ();
+ zclient = zclient_new(master);
zclient->enable = 1;
#ifdef HAVE_TCP_ZEBRA
zclient->sock = zclient_socket ();