static void proto_init_instance(struct proto *p) { /* Here we cannot use p->cf->name since it won't survive reconfiguration */ p->pool = rp_new(proto_pool, p->proto->name); p->attn = ev_new(p->pool); p->attn->data = p; if (! p->proto->multitable) rt_lock_table(p->table); }
int main(int ac, char **av) { int ret; struct ospfd *ospfd; int ev_flags = 0; ospfd = alloc_ospfd(); ret = parse_cli_options(ospfd, ac, av); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Can't parse command line"); msg(ospfd, GENTLE, PROGRAMNAME " - " VERSIONSTRING); /* seed pseudo number randon generator */ init_pnrg(ospfd); /* initialize event subsystem. In this case this belongs * to open a epoll filedescriptor */ ospfd->ev = ev_new(); if (!ospfd->ev) err_msg_die(EXIT_FAILURE, "Can't initialize event subsystem"); ret = parse_rc_file(ospfd); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Can't parse configuration file"); ret = init_network(ospfd); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Can't initialize network subsystem"); /* and branch into the main loop * This loop will never return (with the exception of SIGINT or failure * condition) */ ret = ev_loop(ospfd->ev, ev_flags); if (ret != SUCCESS) err_msg_die(EXIT_FAILURE, "Main loop returned unexpected - exiting now"); fini_network(ospfd); free_options(ospfd); ev_free(ospfd->ev); free_ospfd(ospfd); return EXIT_SUCCESS; }
struct cli * cli_new(void *priv) { struct pool *p = rp_new(cli_pool, "CLI"); struct cli *c = mb_alloc(p, sizeof(struct cli)); bzero(c, sizeof(struct cli)); c->pool = p; c->priv = priv; c->event = ev_new(p); c->event->hook = cli_event; c->event->data = c; c->cont = cli_hello; c->parser_pool = lp_new(c->pool, 4096); c->rx_buf = mb_alloc(c->pool, CLI_RX_BUF_SIZE); ev_schedule(c->event); return c; }
static void bgp_setup_conn(struct bgp_proto *p, struct bgp_conn *conn) { timer *t; conn->sk = NULL; conn->bgp = p; conn->packets_to_send = 0; t = conn->connect_retry_timer = tm_new(p->p.pool); t->hook = bgp_connect_timeout; t->data = conn; t = conn->hold_timer = tm_new(p->p.pool); t->hook = bgp_hold_timeout; t->data = conn; t = conn->keepalive_timer = tm_new(p->p.pool); t->hook = bgp_keepalive_timeout; t->data = conn; conn->tx_ev = ev_new(p->p.pool); conn->tx_ev->hook = bgp_kick_tx; conn->tx_ev->data = conn; }