1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/**
* @file ptpd.c
* @date Wed Jun 23 10:13:38 2010
*
* @brief The main() function for the PTP daemon
*
* This file contains very little code, as should be obvious,
* and only serves to tie together the rest of the daemon.
* All of the default options are set here, but command line
* arguments are processed in the ptpdStartup() routine called
* below.
*/
#include "ptpd.h"
RunTimeOpts rtOpts; /* statically allocated run-time
* configuration data */
int
main(int argc, char **argv)
{
PtpClock *ptpClock;
Integer16 ret;
/* initialize run-time options to reasonable values */
rtOpts.syncInterval = DEFAULT_SYNC_INTERVAL;
memcpy(rtOpts.subdomainName, DEFAULT_PTP_DOMAIN_NAME, PTP_SUBDOMAIN_NAME_LENGTH);
memcpy(rtOpts.clockIdentifier, IDENTIFIER_DFLT, PTP_CODE_STRING_LENGTH);
rtOpts.clockVariance = DEFAULT_CLOCK_VARIANCE;
rtOpts.clockStratum = DEFAULT_CLOCK_STRATUM;
rtOpts.unicastAddress[0] = 0;
rtOpts.inboundLatency.nanoseconds = DEFAULT_INBOUND_LATENCY;
rtOpts.outboundLatency.nanoseconds = DEFAULT_OUTBOUND_LATENCY;
rtOpts.noResetClock = DEFAULT_NO_RESET_CLOCK;
rtOpts.s = DEFAULT_DELAY_S;
rtOpts.ap = DEFAULT_AP;
rtOpts.ai = DEFAULT_AI;
rtOpts.max_foreign_records = DEFAULT_MAX_FOREIGN_RECORDS;
rtOpts.currentUtcOffset = DEFAULT_UTC_OFFSET;
rtOpts.logFd = -1;
rtOpts.recordFP = NULL;
rtOpts.useSysLog = FALSE;
rtOpts.ttl = 1;
if (!(ptpClock = ptpdStartup(argc, argv, &ret, &rtOpts)))
return ret;
if (rtOpts.probe) {
probe(&rtOpts, ptpClock);
} else {
/* do the protocol engine */
protocol(&rtOpts, ptpClock);
}
ptpdShutdown();
NOTIFY("self shutdown, probably due to an error\n");
return 1;
}
|