ptp4l: pull iface into the configure settings

this patch modifies the ptp4l.c and config settings so that the iface list is
inside the cfg_settings structure

-v2
* Moved "struct interface" into config.h

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
master
Jacob Keller 2012-08-20 10:56:24 -07:00 committed by Richard Cochran
parent 64dcf257e3
commit 08a6a14e6c
3 changed files with 26 additions and 18 deletions

10
clock.h
View File

@ -22,21 +22,13 @@
#include "dm.h" #include "dm.h"
#include "ds.h" #include "ds.h"
#include "config.h"
#include "servo.h" #include "servo.h"
#include "tmv.h" #include "tmv.h"
#include "transport.h" #include "transport.h"
struct ptp_message; /*forward declaration*/ struct ptp_message; /*forward declaration*/
#define MAX_PORTS 8
/** Defines a network interface, with PTP options. */
struct interface {
char *name;
enum delay_mechanism dm;
enum transport_type transport;
};
/** Opaque type. */ /** Opaque type. */
struct clock; struct clock;

View File

@ -21,8 +21,23 @@
#define HAVE_CONFIG_H #define HAVE_CONFIG_H
#include "ds.h" #include "ds.h"
#include "dm.h"
#include "transport.h"
#define MAX_PORTS 8
/** Defines a network interface, with PTP options. */
struct interface {
char *name;
enum delay_mechanism dm;
enum transport_type transport;
};
struct config { struct config {
/* configured interfaces */
struct interface iface[MAX_PORTS];
int nports;
struct defaultDS *dds; struct defaultDS *dds;
struct port_defaults *pod; struct port_defaults *pod;
int *assume_two_step; int *assume_two_step;

19
ptp4l.c
View File

@ -73,8 +73,9 @@ static void usage(char *progname)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *config = NULL, *req_phc = NULL, *progname; char *config = NULL, *req_phc = NULL, *progname;
int c, nports = 0, slaveonly = 0; int c, slaveonly = 0;
struct interface iface[MAX_PORTS]; struct interface *iface = cfg_settings.iface;
int *nports = &cfg_settings.nports;
enum delay_mechanism dm = DM_E2E; enum delay_mechanism dm = DM_E2E;
enum transport_type transport = TRANS_UDP_IPV4; enum transport_type transport = TRANS_UDP_IPV4;
enum timestamp_type timestamping = TS_HARDWARE; enum timestamp_type timestamping = TS_HARDWARE;
@ -117,11 +118,11 @@ int main(int argc, char *argv[])
config = optarg; config = optarg;
break; break;
case 'i': case 'i':
if (nports < MAX_PORTS) { if (*nports < MAX_PORTS) {
iface[nports].name = optarg; iface[*nports].name = optarg;
iface[nports].dm = dm; iface[*nports].dm = dm;
iface[nports].transport = transport; iface[*nports].transport = transport;
nports++; (*nports)++;
} else { } else {
fprintf(stderr, "too many interfaces\n"); fprintf(stderr, "too many interfaces\n");
return -1; return -1;
@ -154,7 +155,7 @@ int main(int argc, char *argv[])
} }
} }
if (!nports) { if (!*nports) {
fprintf(stderr, "no interface specified\n"); fprintf(stderr, "no interface specified\n");
usage(progname); usage(progname);
return -1; return -1;
@ -219,7 +220,7 @@ int main(int argc, char *argv[])
ds.clockQuality.clockClass = 255; ds.clockQuality.clockClass = 255;
} }
clock = clock_create(phc_index, iface, nports, timestamping, &ds, &pod); clock = clock_create(phc_index, iface, *nports, timestamping, &ds, &pod);
if (!clock) { if (!clock) {
fprintf(stderr, "failed to create a clock\n"); fprintf(stderr, "failed to create a clock\n");
return -1; return -1;