Blame config.h

Packit 9c3e7e
/**
Packit 9c3e7e
 * @file config.h
Packit 9c3e7e
 * @brief Configuration file code
Packit 9c3e7e
 * @note Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com>
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is free software; you can redistribute it and/or modify
Packit 9c3e7e
 * it under the terms of the GNU General Public License as published by
Packit 9c3e7e
 * the Free Software Foundation; either version 2 of the License, or
Packit 9c3e7e
 * (at your option) any later version.
Packit 9c3e7e
 *
Packit 9c3e7e
 * This program is distributed in the hope that it will be useful,
Packit 9c3e7e
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 9c3e7e
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 9c3e7e
 * GNU General Public License for more details.
Packit 9c3e7e
 *
Packit 9c3e7e
 * You should have received a copy of the GNU General Public License along
Packit 9c3e7e
 * with this program; if not, write to the Free Software Foundation, Inc.,
Packit 9c3e7e
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Packit 9c3e7e
 */
Packit 9c3e7e
#ifndef HAVE_CONFIG_H
Packit 9c3e7e
#define HAVE_CONFIG_H
Packit 9c3e7e
Packit 9c3e7e
#include <getopt.h>
Packit 9c3e7e
#include <sys/queue.h>
Packit 9c3e7e
Packit 9c3e7e
#include "ds.h"
Packit 9c3e7e
#include "dm.h"
Packit 9c3e7e
#include "filter.h"
Packit 9c3e7e
#include "mtab.h"
Packit 9c3e7e
#include "transport.h"
Packit 9c3e7e
#include "servo.h"
Packit 9c3e7e
#include "sk.h"
Packit 9c3e7e
Packit 9c3e7e
#define MAX_IFNAME_SIZE 108 /* = UNIX_PATH_MAX */
Packit 9c3e7e
Packit 9c3e7e
#if (IF_NAMESIZE > MAX_IFNAME_SIZE)
Packit 9c3e7e
#error if_namesize larger than expected.
Packit 9c3e7e
#endif
Packit 9c3e7e
Packit 9c3e7e
/** Defines a network interface, with PTP options. */
Packit 9c3e7e
struct interface {
Packit 9c3e7e
	STAILQ_ENTRY(interface) list;
Packit 9c3e7e
	char name[MAX_IFNAME_SIZE + 1];
Packit 9c3e7e
	char ts_label[MAX_IFNAME_SIZE + 1];
Packit 9c3e7e
	struct sk_ts_info ts_info;
Packit 9c3e7e
};
Packit 9c3e7e
Packit 9c3e7e
struct config {
Packit 9c3e7e
	/* configured interfaces */
Packit 9c3e7e
	STAILQ_HEAD(interfaces_head, interface) interfaces;
Packit 9c3e7e
	int n_interfaces;
Packit 9c3e7e
Packit 9c3e7e
	/* for parsing command line options */
Packit 9c3e7e
	struct option *opts;
Packit 9c3e7e
Packit 9c3e7e
	/* hash of all non-legacy items */
Packit 9c3e7e
	struct hash *htab;
Packit 9c3e7e
Packit 9c3e7e
	/* unicast master tables */
Packit 9c3e7e
	STAILQ_HEAD(ucmtab_head, unicast_master_table) unicast_master_tables;
Packit 9c3e7e
};
Packit 9c3e7e
Packit 9c3e7e
int config_read(char *name, struct config *cfg);
Packit 9c3e7e
struct interface *config_create_interface(char *name, struct config *cfg);
Packit 9c3e7e
void config_destroy(struct config *cfg);
Packit 9c3e7e
Packit 9c3e7e
/* New, hash table based methods: */
Packit 9c3e7e
Packit 9c3e7e
struct config *config_create(void);
Packit 9c3e7e
Packit 9c3e7e
double config_get_double(struct config *cfg, const char *section,
Packit 9c3e7e
			 const char *option);
Packit 9c3e7e
Packit 9c3e7e
int config_get_int(struct config *cfg, const char *section,
Packit 9c3e7e
		   const char *option);
Packit 9c3e7e
Packit 9c3e7e
char *config_get_string(struct config *cfg, const char *section,
Packit 9c3e7e
			const char *option);
Packit 9c3e7e
Packit 9c3e7e
int config_harmonize_onestep(struct config *cfg);
Packit 9c3e7e
Packit 9c3e7e
static inline struct option *config_long_options(struct config *cfg)
Packit 9c3e7e
{
Packit 9c3e7e
	return cfg->opts;
Packit 9c3e7e
}
Packit 9c3e7e
Packit 9c3e7e
int config_parse_option(struct config *cfg, const char *opt, const char *val);
Packit 9c3e7e
Packit 9c3e7e
int config_set_double(struct config *cfg, const char *option, double val);
Packit 9c3e7e
Packit 9c3e7e
int config_set_section_int(struct config *cfg, const char *section,
Packit 9c3e7e
			   const char *option, int val);
Packit 9c3e7e
Packit 9c3e7e
static inline int config_set_int(struct config *cfg,
Packit 9c3e7e
				 const char *option, int val)
Packit 9c3e7e
{
Packit 9c3e7e
	return config_set_section_int(cfg, NULL, option, val);
Packit 9c3e7e
}
Packit 9c3e7e
Packit 9c3e7e
int config_set_string(struct config *cfg, const char *option,
Packit 9c3e7e
		      const char *val);
Packit 9c3e7e
Packit 9c3e7e
#endif