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
parent
64dcf257e3
commit
08a6a14e6c
10
clock.h
10
clock.h
|
@ -22,21 +22,13 @@
|
|||
|
||||
#include "dm.h"
|
||||
#include "ds.h"
|
||||
#include "config.h"
|
||||
#include "servo.h"
|
||||
#include "tmv.h"
|
||||
#include "transport.h"
|
||||
|
||||
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. */
|
||||
struct clock;
|
||||
|
||||
|
|
15
config.h
15
config.h
|
@ -21,8 +21,23 @@
|
|||
#define HAVE_CONFIG_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 {
|
||||
/* configured interfaces */
|
||||
struct interface iface[MAX_PORTS];
|
||||
int nports;
|
||||
|
||||
struct defaultDS *dds;
|
||||
struct port_defaults *pod;
|
||||
int *assume_two_step;
|
||||
|
|
19
ptp4l.c
19
ptp4l.c
|
@ -73,8 +73,9 @@ static void usage(char *progname)
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *config = NULL, *req_phc = NULL, *progname;
|
||||
int c, nports = 0, slaveonly = 0;
|
||||
struct interface iface[MAX_PORTS];
|
||||
int c, slaveonly = 0;
|
||||
struct interface *iface = cfg_settings.iface;
|
||||
int *nports = &cfg_settings.nports;
|
||||
enum delay_mechanism dm = DM_E2E;
|
||||
enum transport_type transport = TRANS_UDP_IPV4;
|
||||
enum timestamp_type timestamping = TS_HARDWARE;
|
||||
|
@ -117,11 +118,11 @@ int main(int argc, char *argv[])
|
|||
config = optarg;
|
||||
break;
|
||||
case 'i':
|
||||
if (nports < MAX_PORTS) {
|
||||
iface[nports].name = optarg;
|
||||
iface[nports].dm = dm;
|
||||
iface[nports].transport = transport;
|
||||
nports++;
|
||||
if (*nports < MAX_PORTS) {
|
||||
iface[*nports].name = optarg;
|
||||
iface[*nports].dm = dm;
|
||||
iface[*nports].transport = transport;
|
||||
(*nports)++;
|
||||
} else {
|
||||
fprintf(stderr, "too many interfaces\n");
|
||||
return -1;
|
||||
|
@ -154,7 +155,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (!nports) {
|
||||
if (!*nports) {
|
||||
fprintf(stderr, "no interface specified\n");
|
||||
usage(progname);
|
||||
return -1;
|
||||
|
@ -219,7 +220,7 @@ int main(int argc, char *argv[])
|
|||
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) {
|
||||
fprintf(stderr, "failed to create a clock\n");
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue