Blame config.h

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