open-close.c 1.7 KB
Newer Older
1 2 3
/*
 * Alessandro Rubini for CERN, 2011 -- public domain
 */
4
#include <pptp/pptp.h>
5 6 7 8 9 10 11 12 13 14

/*
 * This file deals with opening and closing an instance. The channel
 * must already have been created. In practices, this initializes the
 * state machine to the first state.
 *
 * A protocol extension can override none or both of these functions.
 */

struct pp_runtime_opts default_rt_opts = {
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
	.max_rst = FALSE,
	.max_dly = FALSE,
	.slave_only = FALSE,
	.no_adjust = TRUE,
	.display_stats = FALSE,
	.csv_stats = FALSE,
	.ethernet_mode = FALSE,
	.e2e_mode = FALSE,
	.ofst_first_updated = FALSE,
	.no_rst_clk = PP_DEFAULT_NO_RESET_CLOCK,
	.use_syslog = FALSE,
	.ap = PP_DEFAULT_AP,
	.ai = PP_DEFAULT_AI,
	.s = PP_DEFAULT_DELAY_S,
	.max_foreign_records = PP_DEFAULT_MAX_FOREIGN_RECORDS,
	.cur_utc_ofst = PP_DEFAULT_UTC_OFFSET,
	.announce_intvl = PP_DEFAULT_ANNOUNCE_INTERVAL,
	.sync_intvl = PP_DEFAULT_SYNC_INTERVAL,
	.prio1 = PP_DEFAULT_PRIORITY1,
	.prio2 = PP_DEFAULT_PRIORITY2,
	.domain_number = PP_DEFAULT_DOMAIN_NUMBER,
	.unicast_addr = 0,
	.iface_name = 0,
	.ttl = 1,
	.arch_opts = 0,
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
};


struct pp_runtime_opts *pp_get_default_rt_opts()
{
	return &default_rt_opts;
}

int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv)
{
	/* TODO: Check how to parse cmdline. We can not rely on getopt()
	 * function. Which are the really useful parameters?
	 * Every parameter should be contained in ppi->rt_opts and set here
	 */
	return 0;
}

int pp_open_instance(struct pp_instance *ppi, struct pp_runtime_opts *rt_opts)
{
59
	if (rt_opts)
60
		ppi->rt_opts = rt_opts;
61
	else
62
		ppi->rt_opts = &default_rt_opts;
63

64 65 66 67 68 69 70 71 72 73
	ppi->state = PPS_INITIALIZING;

	return 0;
}

int pp_close_instance(struct pp_instance *ppi)
{
	/* Nothing to do by now */
	return 0;
}