config: Add a hash table into the data structure.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-08 19:17:29 +02:00
parent 8601aa31a3
commit 8f5344eed9
2 changed files with 15 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#include <string.h> #include <string.h>
#include "config.h" #include "config.h"
#include "ether.h" #include "ether.h"
#include "hash.h"
#include "print.h" #include "print.h"
#include "util.h" #include "util.h"
@ -803,6 +804,15 @@ void config_init_interface(struct interface *iface, struct config *cfg)
iface->boundary_clock_jbod = cfg->dds.boundary_clock_jbod; iface->boundary_clock_jbod = cfg->dds.boundary_clock_jbod;
} }
int config_init(struct config *cfg)
{
cfg->htab = hash_create();
if (!cfg->htab) {
return -1;
}
return 0;
}
void config_destroy(struct config *cfg) void config_destroy(struct config *cfg)
{ {
struct interface *iface; struct interface *iface;
@ -811,4 +821,5 @@ void config_destroy(struct config *cfg)
STAILQ_REMOVE_HEAD(&cfg->interfaces, list); STAILQ_REMOVE_HEAD(&cfg->interfaces, list);
free(iface); free(iface);
} }
hash_destroy(cfg->htab, free);
} }

View File

@ -60,6 +60,10 @@ struct config {
/* configured interfaces */ /* configured interfaces */
STAILQ_HEAD(interfaces_head, interface) interfaces; STAILQ_HEAD(interfaces_head, interface) interfaces;
/* hash of all non-legacy items */
struct hash *htab;
/* the rest are legacy fields */
enum timestamp_type timestamping; enum timestamp_type timestamping;
enum transport_type transport; enum transport_type transport;
enum delay_mechanism dm; enum delay_mechanism dm;