Example #1
0
void
switch_status_start(struct secchan *secchan, const struct settings *s,
                    struct switch_status **ssp)
{
    struct switch_status *ss = xcalloc(1, sizeof *ss);
    ss->s = s;
    ss->booted = time_now();
    switch_status_register_category(ss, "config",
                                    config_status_cb, (void *) s);
    switch_status_register_category(ss, "switch", switch_status_cb, ss);
    *ssp = ss;
    add_hook(secchan, &switch_status_hook_class, ss);
}
void
failover_start(struct secchan *secchan, const struct settings *settings,
	       struct switch_status *switch_status, struct rconn *remote_rconn)
{
	struct failover_context *context = NULL;
	int i;
	static struct hook_class failover_hook_class = {
		NULL,		/* local_packet_cb */
		NULL,		/* remote_packet_cb */
		failover_periodic_cb,	/* periodic_cb */
		NULL,		/* wait_cb */
		NULL,		/* closing_cb */
	};

	context = xmalloc(sizeof(*context));
	context->settings = settings;
	context->secchan = secchan;
	context->remote_rconn = remote_rconn;
	context->index = 0;
	for (i = 0; i < MAX_CONTROLLERS; ++i) {
		context->peers[i] = NULL;
		if (settings->controller_names[i] == NULL)
			continue;
		context->peers[i] = xmalloc(sizeof(struct failover_peer));
		context->peers[i]->epoch = time_now();
	}

	switch_status_register_category(switch_status, "failover",
					failover_status_cb, context);
	add_hook(secchan, &failover_hook_class, context);
}
Example #3
0
struct discovery *
discovery_init(const struct settings *s, struct port_watcher *pw,
               struct switch_status *ss)
{
    struct discovery *d;

    d = xmalloc(sizeof *d);
    d->s = s;
    d->dhcp = NULL;
    d->n_changes = 0;

    switch_status_register_category(ss, "discovery", discovery_status_cb, d);
    port_watcher_register_local_port_callback(pw, discovery_local_port_cb, d);

    return d;
}
Example #4
0
void
fail_open_start(struct secchan *secchan, const struct settings *s,
                struct switch_status *ss,
                struct rconn *local_rconn, struct rconn *remote_rconn)
{
    struct fail_open_data *fail_open = xmalloc(sizeof *fail_open);
    fail_open->s = s;
    fail_open->local_rconn = local_rconn;
    fail_open->remote_rconn = remote_rconn;
    fail_open->lswitch = NULL;
    fail_open->boot_deadline = time_now() + s->probe_interval * 3;
    if (s->enable_stp) {
        fail_open->boot_deadline += STP_EXTRA_BOOT_TIME;
    }
    switch_status_register_category(ss, "fail-open",
                                    fail_open_status_cb, fail_open);
    add_hook(secchan, &fail_open_hook_class, fail_open);
}
Example #5
0
void
rate_limit_start(struct secchan *secchan, const struct settings *s,
                 struct switch_status *ss, struct rconn *remote)
{
    struct rate_limiter *rl;
    size_t i;

    rl = xcalloc(1, sizeof *rl);
    rl->s = s;
    rl->remote_rconn = remote;
    for (i = 0; i < ARRAY_SIZE(rl->queues); i++) {
        queue_init(&rl->queues[i]);
    }
    rl->last_fill = time_msec();
    rl->tokens = s->rate_limit * 100;
    switch_status_register_category(ss, "rate-limit",
                                    rate_limit_status_cb, rl);
    add_hook(secchan, &rate_limit_hook_class, rl);
}