|
From: <wow...@us...> - 2015-10-22 04:31:13
|
Revision: 599
http://sourceforge.net/p/ptpd/code/599
Author: wowczarek
Date: 2015-10-22 04:31:10 +0000 (Thu, 22 Oct 2015)
Log Message:
-----------
- added templates.conf missing from svn
- all config-related operations:
parse, help, print default, check restart,
now merged into parseConfig (opCode)
- removed more macros, help related
and restart check related
- added array size parameter
to configMapString for safe strncpy
(macros had access to array so could
run sizeof, now functions only have
a pointer)
- expanded ptpengine:interface man page
Modified Paths:
--------------
trunk/src/dep/daemonconfig.c
trunk/src/dep/daemonconfig.h
trunk/src/dep/startup.c
trunk/src/ptpd2.conf.5.in
Added Paths:
-----------
trunk/src/templates.conf
Modified: trunk/src/dep/daemonconfig.c
===================================================================
--- trunk/src/dep/daemonconfig.c 2015-10-21 01:28:49 UTC (rev 598)
+++ trunk/src/dep/daemonconfig.c 2015-10-22 04:31:10 UTC (rev 599)
@@ -48,81 +48,59 @@
* within parseConfig - they assume the existence of the "dictionary*" dict variable.
*/
-/* Basic helper macros */
+static void printComment(const char* helptext);
-#define STRING_EMPTY(string)\
- (!strcmp(string,""))
+static int configSettingChanged(dictionary *oldConfig, dictionary *newConfig, const char *key);
-#define CONFIG_ISSET(key) \
- (strcmp(iniparser_getstring(dict, key, ""),"") != 0)
+static void warnRestart(const char *key, int flags);
-#define CONFIG_ISPRESENT(key) \
- (iniparser_find_entry(dict, key) != 0)
+static int configMapBoolean(int opCode, void *opArg, dictionary* dict,
+ dictionary *target, const char * key, int restartFlags, Boolean *var, Boolean def, const char* helptext);
-#define CONFIG_ISTRUE(key) \
- (iniparser_getboolean(dict,key,FALSE)==TRUE)
+static int configMapString(int opCode, void *opArg, dictionary *dict,
+ dictionary *target, const char *key, int restartFlags, char *var, int size, char *def, const char* helptext);
-#define DICT_ISTRUE(dict,key) \
- (iniparser_getboolean(dict,key,FALSE)==TRUE)
+static int checkRangeInt(dictionary *dict, const char *key, int rangeFlags, int minBound, int maxBound);
+static int configMapInt(int opCode, void *opArg, dictionary *dict,
+ dictionary *target, const char *key, int restartFlags, int intType, void *var, int def,
+ const char *helptext, int rangeFlags, int minBound, int maxBound);
-/*
- * Macros controlling the behaviour of parseConfig - using "hidden" keys.
- * Thanks to this, a single line in parseConfig can map settings and print help.
- * the SET_QUIET / END_QUIET macros suppress info and error output of parseConfig
- */
+static int checkRangeDouble(dictionary *dict, const char *key, int rangeFlags, double minBound, double maxBound);
-#define SET_QUIET() \
- dictionary_set(dict,"%quiet%:%quiet%","Y");
+static int configMapDouble(int opCode, void *opArg, dictionary *dict,
+ dictionary *target, const char *key, int restartFlags, double *var, double def,
+ const char *helptext, int rangeFlags, double minBound, double maxBound);
-#define END_QUIET() \
- dictionary_unset(dict,"%quiet%:%quiet%");
+static int configMapSelectValue(int opCode, void *opArg, dictionary *dict,
+ dictionary *target, const char* key, int restartFlags, uint8_t *var, int def, const char *helptext, ...);
-#define IS_QUIET()\
- ( CONFIG_ISTRUE("%quiet%:%quiet%") )
+static void parseUserVariables(dictionary *dict, dictionary *target);
-#define SET_SHOWDEFAULT() \
- SET_QUIET();\
- dictionary_set(dict,"%showdefault%:%showdefault%","Y");
+static void findUnknownSettings(int opCode, dictionary* source, dictionary* dict);
-#define END_SHOWDEFAULT() \
- END_QUIET();\
- dictionary_unset(dict,"%showdefault%:%showdefault%");
-#define IS_SHOWDEFAULT()\
- ( CONFIG_ISTRUE("%showdefault%:%showdefault%") )
+/* Basic helper macros */
-#define HELP_START() \
- SET_QUIET();\
- dictionary_set(dict,"%helponly%:%helponly%","T");
+#define STRING_EMPTY(string)\
+ (!strcmp(string,""))
-#define HELP_ITEM(key) \
- SET_QUIET();\
- dictionary_set(dict,"%helponly%:%helpitem%",key);
+#define CONFIG_ISSET(key) \
+ (strcmp(iniparser_getstring(dict, key, ""),"") != 0)
-#define HELP_ITEM_COMPLETE() \
- dictionary_set(dict,"%helponly%:%helpitem%","%complete%");
+#define CONFIG_ISPRESENT(key) \
+ (iniparser_find_entry(dict, key) != 0)
-#define HELP_ITEM_FOUND() \
- (strcmp(iniparser_getstring(dict, "%helponly%:%helpitem%" , ""),"%complete%") == 0)
+#define CONFIG_ISTRUE(key) \
+ (iniparser_getboolean(dict,key,FALSE)==TRUE)
-#define HELP_END() \
- dictionary_unset(dict,"%helponly%:%helponly%");\
- dictionary_unset(dict,"%helponly%:%helpitem%");\
- END_QUIET();
+#define DICT_ISTRUE(dict,key) \
+ (iniparser_getboolean(dict,key,FALSE)==TRUE)
-#define IS_HELP(key, helptext)\
- ( ( (strcmp(iniparser_getstring(dict, "%helponly%:%helpitem%", ""),key) == 0) ||\
- CONFIG_ISTRUE("%helponly%:%helponly%")) && (strcmp(helptext, "") != 0) )
-
-#define HELP_ON()\
- ( CONFIG_ISTRUE("%helponly%:%helponly%") || \
- CONFIG_ISSET("%helponly%:%helpitem%") )
-
/* Macros handling required settings, triggers, conflicts and dependencies */
#define CONFIG_KEY_REQUIRED(key) \
- if( !IS_QUIET() && !HELP_ON() && !CONFIG_ISSET(key) )\
+ if( !(opCode & CFGOP_PARSE_QUIET) && !(opCode & CFGOP_HELP_FULL) && !(opCode & CFGOP_HELP_SINGLE) && !CONFIG_ISSET(key) )\
{ \
ERROR("Configuration error: option \"%s\" is required\n", key); \
parseResult = FALSE;\
@@ -132,7 +110,7 @@
if( CONFIG_ISSET(key1) && \
!CONFIG_ISSET(key2)) \
{ \
- if(!IS_QUIET())\
+ if(!(opCode & CFGOP_PARSE_QUIET))\
ERROR("Configuration error: option \"%s\" requires option \"%s\"\n", key1, key2); \
parseResult = FALSE;\
}
@@ -141,7 +119,7 @@
if( CONFIG_ISSET(key1) && \
CONFIG_ISSET(key2)) \
{ \
- if(!IS_QUIET())\
+ if(!(opCode & CFGOP_PARSE_QUIET))\
ERROR("Configuration error: option \"%s\" cannot be used with option \"%s\"\n", key1, key2); \
parseResult = FALSE;\
}
@@ -150,7 +128,7 @@
if ( (condition) && \
!CONFIG_ISSET(dep) ) \
{ \
- if(!IS_QUIET())\
+ if(!(opCode & CFGOP_PARSE_QUIET))\
WARNING("Warning: %s\n", messageText); \
}
@@ -158,7 +136,7 @@
if ( (condition) && \
CONFIG_ISSET(dep) ) \
{ \
- if(!IS_QUIET())\
+ if(!(opCode & CFGOP_PARSE_QUIET))\
WARNING("Warning: %s\n", messageText); \
}
@@ -166,7 +144,7 @@
if ( (condition) && \
!CONFIG_ISSET(dep) ) \
{ \
- if(!IS_QUIET())\
+ if(!(opCode & CFGOP_PARSE_QUIET))\
ERROR("Configuration error: option \"%s=%s\" requires option \"%s\"\n", key, stringval, dep); \
parseResult = FALSE;\
}
@@ -175,7 +153,7 @@
if ( (condition) && \
CONFIG_ISSET(dep) ) \
{ \
- if(!IS_QUIET())\
+ if(!(opCode & CFGOP_PARSE_QUIET))\
ERROR("Configuration error: option \"%s=%s\" cannot be used with option \"%s\"\n", key, stringval, dep); \
parseResult = FALSE;\
}
@@ -184,7 +162,7 @@
if ( (condition) && \
CONFIG_ISSET(key) ) \
{ \
- if(!IS_QUIET())\
+ if(!(opCode & CFGOP_PARSE_QUIET))\
ERROR("Configuration error: option \"%s=%s\" cannot be used: \n%s", key, stringval, message); \
parseResult = FALSE;\
}
@@ -210,7 +188,7 @@
if ( (condition) && \
CONFIG_ISSET(key) ) \
{ \
- if(!IS_QUIET())\
+ if(!(opCode & CFGOP_PARSE_QUIET))\
ERROR("%s\n", warningtext); \
parseResult = FALSE;\
}
@@ -218,7 +196,7 @@
#define CONFIG_CONDITIONAL_ASSERTION(condition,warningtext) \
if ( (condition) ) \
{ \
- if(!IS_QUIET())\
+ if(!(opCode & CFGOP_PARSE_QUIET))\
ERROR("%s\n", warningtext); \
parseResult = FALSE;\
}
@@ -231,22 +209,6 @@
#define WARN_DEPRECATED(old,new,long,key)\
WARN_DEPRECATED_COMMENT( old,new,long,key,"")
-#define SETTING_CHANGED(key) \
- (strcmp(\
- dictionary_get(newConfig, key,""),\
- dictionary_get(oldConfig, key,"")\
- ) != 0 )
-/* Macro flagging component restart if the given option has changed */
-#define COMPONENT_RESTART_REQUIRED(key,flag)\
- if(SETTING_CHANGED(key)) {\
- if(flag == PTPD_RESTART_DAEMON) {\
- DBG("Setting %s changed, restart of ptpd process required\n",key,flag);\
- NOTIFY("Change of %s setting requires "PTPD_PROGNAME" restart\n",key);\
- } else\
- DBG("Setting %s changed, restart of subystem %d required\n",key,flag);\
- restartFlags |= flag;\
- }
-
#define CONFIG_KEY_ALIAS(src,dest) \
{ \
if(!STRING_EMPTY(dictionary_get(dict,src,""))) {\
@@ -256,8 +218,10 @@
}
/* Output a potentially multi-line string, prefixed with ;s */
-static void printComment(const char* helptext)
+static void
+printComment(const char* helptext)
{
+
int i, len;
len = strlen(helptext);
@@ -281,33 +245,75 @@
}
static int
-configMapBoolean(dictionary* dict, dictionary *target, const char * key, Boolean *var, Boolean def, const char* helptext)
+configSettingChanged(dictionary *oldConfig, dictionary *newConfig, const char *key)
{
- if(IS_HELP(key, helptext)) {
+
+ return(strcmp(
+ dictionary_get(newConfig, key,""),
+ dictionary_get(oldConfig, key,"")
+ ) != 0 );
+
+}
+
+/* warn about restart required if needed */
+static void
+warnRestart(const char *key, int flags)
+{
+ if(flags & PTPD_RESTART_DAEMON) {
+ NOTIFY("Change of %s setting requires "PTPD_PROGNAME" restart\n",key);
+ } else {
+ DBG("Setting %s changed, restart of subystem %d required\n",key,flag);
+ }
+}
+
+static int
+configMapBoolean(int opCode, void *opArg, dictionary* dict, dictionary *target,
+ const char * key, int restartFlags, Boolean *var, Boolean def, const char* helptext)
+{
+
+ if(opCode & CFGOP_RESTART_FLAGS) {
+ if(CONFIG_ISSET(key)) {
+ *(int*)opArg |= restartFlags;
+ if(opCode & CFGOP_RESTART_FLAGS && !(opCode & CFGOP_PARSE_QUIET)) {
+ warnRestart(key, restartFlags);
+ }
+ }
+ return 1;
+ } else if(opCode & CFGOP_HELP_FULL || opCode & CFGOP_HELP_SINGLE) {
+
+ char *helpKey = (char*)opArg;
+
+ if(opCode & CFGOP_HELP_SINGLE && strcmp(key, helpKey)) {
+ return 1;
+ }
+
+ helpKey[0] = '\0';
+
printf("setting: %s (--%s)\n", key, key);
printf(" type: BOOLEAN (value must start with t/T/y/Y/1/f/F/n/N/0)\n");
printf(" usage: %s\n", helptext);
printf("default: %s\n", def ? "Y" : "N");
printf("\n");
- HELP_ITEM_COMPLETE();
return 1;
} else {
if (!CONFIG_ISPRESENT(key)) {
*var = def;
dictionary_set(target,key,(*var)?"Y":"N");
- if(!STRING_EMPTY(helptext) && IS_SHOWDEFAULT()) {
+ if(!strcmp(helptext, "") && opCode & CFGOP_PRINT_DEFAULT) {
printComment(helptext);
printf("%s = %s\n", key,(*var)?"Y":"N");
}
return 1;
} else if(!CONFIG_ISSET(key) || iniparser_getboolean(dict,key,-1) == -1) {
- ERROR("Configuration error: option \"%s='%s'\" has unknown boolean value: must start with 0/1/t/T/f/F/y/Y/n/N\n",key,iniparser_getstring(dict,key,""));
+ if(!(opCode & CFGOP_PARSE_QUIET)) {
+ ERROR("Configuration error: option \"%s='%s'\" has unknown boolean value: must start with 0/1/t/T/f/F/y/Y/n/N\n",key,iniparser_getstring(dict,key,""));
+ }
dictionary_set(target,key,""); /* suppress the "unknown entry" warning for malformed boolean values */ \
return 0;
} else {
*var=iniparser_getboolean(dict,key,def);
dictionary_set(target,key,(*var)?"Y":"N");
- if(!STRING_EMPTY(helptext) && IS_SHOWDEFAULT()) {
+ if(strcmp(helptext, "") && opCode & CFGOP_PRINT_DEFAULT) {
printComment(helptext);\
printf("%s = %s\n", key,(*var)?"Y":"N");
}
@@ -317,23 +323,42 @@
}
static int
-configMapString(dictionary *dict, dictionary *target, const char *key, char *var, char *def, const char* helptext)
+configMapString(int opCode, void *opArg, dictionary *dict, dictionary *target,
+ const char *key, int restartFlags, char *var, int size, char *def, const char* helptext)
{
+ if(opCode & CFGOP_RESTART_FLAGS) {
+ if(CONFIG_ISSET(key)) {
+ *(int*)opArg |= restartFlags;
+ if(opCode & CFGOP_RESTART_FLAGS && !(opCode & CFGOP_PARSE_QUIET)) {
+ warnRestart(key, restartFlags);
+ }
+ }
+ return 1;
+ } else if(opCode & CFGOP_HELP_FULL || opCode & CFGOP_HELP_SINGLE) {
+ char *helpKey = (char*)opArg;
- if(IS_HELP(key, helptext)) {
+ if(opCode & CFGOP_HELP_SINGLE && strcmp(key, helpKey)) {
+ return 1;
+ }
+
+ helpKey[0] = '\0';
+
printf("setting: %s (--%s)\n", key, key);
printf(" type: STRING\n");
printf(" usage: %s\n", helptext);
printf("default: %s\n", (strcmp(def, "") == 0) ? "[none]" : def);
printf("\n");\
- HELP_ITEM_COMPLETE();
return 1;
} else {
char *tmpstring = iniparser_getstring(dict,key,def);
- if (strncmp(var, tmpstring, MAX_LINE_SIZE)) strncpy(var, tmpstring, sizeof(var) / sizeof(char));
+ /* do not overwrite the same pointer with the same pointer */
+ if (var!=tmpstring) {
+ strncpy(var, tmpstring, size);
+ var[size-1] = '\0';
+ }
dictionary_set(target, key, tmpstring);
- if(!STRING_EMPTY(helptext) && IS_SHOWDEFAULT()) {
+ if(strcmp(helptext,"") && opCode & CFGOP_PRINT_DEFAULT) {
printComment(helptext);
printf("%s = %s\n", key,tmpstring);
}
@@ -341,7 +366,8 @@
}
}
-static int checkRangeInt(dictionary *dict, const char *key, int rangeFlags, int minBound, int maxBound)
+static int
+checkRangeInt(dictionary *dict, const char *key, int rangeFlags, int minBound, int maxBound)
{
int tmpdouble = iniparser_getint(dict,key,minBound);
@@ -363,19 +389,35 @@
return 0;
}
- if(!ret && !IS_QUIET()) {
- ERROR("Configuration error: option \"%s=%d\" not within allowed range: %d..%d\n", key, tmpdouble, minBound, maxBound);
- }
-
return ret;
}
-static int configMapInt(dictionary *dict, dictionary *target, const char *key, int intType,
- void *var, int def, const char *helptext, int rangeFlags,
- int minBound, int maxBound)
+static int
+configMapInt(int opCode, void *opArg, dictionary *dict, dictionary *target, const char *key, int restartFlags, int intType,
+ void *var, int def, const char *helptext, int rangeFlags,
+ int minBound, int maxBound)
{
- if(IS_HELP(key, helptext)) {
+ int ret = 0;
+
+ if(opCode & CFGOP_RESTART_FLAGS) {
+ if(CONFIG_ISSET(key)) {
+ *(int*)opArg |= restartFlags;
+ if(opCode & CFGOP_RESTART_FLAGS && !(opCode & CFGOP_PARSE_QUIET)) {
+ warnRestart(key, restartFlags);
+ }
+ }
+ return 1;
+ } else if(opCode & CFGOP_HELP_FULL || opCode & CFGOP_HELP_SINGLE) {
+
+ char *helpKey = (char*)opArg;
+
+ if(opCode & CFGOP_HELP_SINGLE && strcmp(key, helpKey)) {
+ return 1;
+ }
+
+ helpKey[0] = '\0';
+
switch(rangeFlags) {
case RANGECHECK_NONE:
printf("setting: %s (--%s)\n", key, key);
@@ -383,7 +425,6 @@
printf(" usage: %s\n", helptext);
printf("default: %d\n", def);
printf("\n");
- HELP_ITEM_COMPLETE();
return 1;
case RANGECHECK_RANGE:
printf("setting: %s (--%s)\n", key, key);
@@ -396,7 +437,6 @@
printf(" usage: %s\n", helptext);
printf("default: %d\n", def);
printf("\n");
- HELP_ITEM_COMPLETE();
return 1;
case RANGECHECK_MIN:
printf("setting: %s (--%s)\n", key, key);
@@ -404,7 +444,6 @@
printf(" usage: %s\n", helptext);
printf("default: %d\n", def);
printf("\n");
- HELP_ITEM_COMPLETE();
return 1;
case RANGECHECK_MAX:
printf("setting: %s (--%s)\n", key, key);
@@ -412,7 +451,6 @@
printf(" usage: %s\n", helptext);
printf("default: %d\n", def);
printf("\n");
- HELP_ITEM_COMPLETE();
return 1;
default:
return 0;
@@ -447,19 +485,37 @@
break;
}
-
memset(buf, 0, 50);
snprintf(buf, 50, "%d", userVar);
dictionary_set(target,key,buf);
- if(!STRING_EMPTY(helptext) && IS_SHOWDEFAULT()) {
+ if(strcmp(helptext, "") && opCode & CFGOP_PRINT_DEFAULT) {
printComment(helptext);
printf("%s = %s\n", key,buf);
}
- return checkRangeInt(dict, key, rangeFlags, minBound, maxBound);
+ ret = checkRangeInt(dict, key, rangeFlags, minBound, maxBound);
+
+ if(!ret && !(opCode & CFGOP_PARSE_QUIET)) {
+ switch(rangeFlags) {
+ case RANGECHECK_RANGE:
+ ERROR("Configuration error: option \"%s=%s\" not within allowed range: %d..%d\n", key, buf, minBound, maxBound);
+ break;
+ case RANGECHECK_MIN:
+ ERROR("Configuration error: option \"%s=%s\" below allowed minimum: %d\n", key, buf, minBound);
+ break;
+ case RANGECHECK_MAX:
+ ERROR("Configuration error: option \"%s=%s\" above allowed maximum: %d\n", key, buf, maxBound);
+ break;
+ default:
+ return ret;
+ }
+ }
+
+ return ret;
}
}
-static int checkRangeDouble(dictionary *dict, const char *key, int rangeFlags, double minBound, double maxBound)
+static int
+checkRangeDouble(dictionary *dict, const char *key, int rangeFlags, double minBound, double maxBound)
{
double tmpdouble = iniparser_getdouble(dict,key,minBound);
@@ -481,18 +537,34 @@
return 0;
}
- if(!ret && !IS_QUIET()) {
- ERROR("Configuration error: option \"%s=%f\" not within allowed range: %f..%f\n", key, tmpdouble, minBound, maxBound);
- }
-
return ret;
}
-static int configMapDouble(dictionary *dict, dictionary *target, const char *key,
+static int
+configMapDouble(int opCode, void *opArg, dictionary *dict, dictionary *target, const char *key, int restartFlags,
double *var, double def, const char *helptext, int rangeFlags,
double minBound, double maxBound)
{
- if(IS_HELP(key, helptext)) {
+
+ int ret = 0;
+ if(opCode & CFGOP_RESTART_FLAGS) {
+ if(CONFIG_ISSET(key)) {
+ *(int*)opArg |= restartFlags;
+ if(opCode & CFGOP_RESTART_FLAGS && !(opCode & CFGOP_PARSE_QUIET)) {
+ warnRestart(key, restartFlags);
+ }
+ }
+ return 1;
+ } else if(opCode & CFGOP_HELP_FULL || opCode & CFGOP_HELP_SINGLE) {
+
+ char *helpKey = (char*)opArg;
+
+ if(opCode & CFGOP_HELP_SINGLE && strcmp(key, helpKey)) {
+ return 1;
+ }
+
+ helpKey[0] = '\0';
+
switch(rangeFlags) {
case RANGECHECK_NONE:
printf("setting: %s (--%s)\n", key, key);
@@ -500,7 +572,6 @@
printf(" usage: %s\n", helptext);
printf("default: %f\n", def);
printf("\n");
- HELP_ITEM_COMPLETE();
return 1;
case RANGECHECK_RANGE:
printf("setting: %s (--%s)\n", key, key);
@@ -513,7 +584,6 @@
printf(" usage: %s\n", helptext);
printf("default: %f\n", def);
printf("\n");
- HELP_ITEM_COMPLETE();
return 1;
case RANGECHECK_MIN:
printf("setting: %s (--%s)\n", key, key);
@@ -521,7 +591,6 @@
printf(" usage: %s\n", helptext);
printf("default: %f\n", def);
printf("\n");
- HELP_ITEM_COMPLETE();
return 1;
case RANGECHECK_MAX:
printf("setting: %s (--%s)\n", key, key);
@@ -529,7 +598,6 @@
printf(" usage: %s\n", helptext);
printf("default: %f\n", def);
printf("\n");
- HELP_ITEM_COMPLETE();
return 1;
default:
return 0;
@@ -540,16 +608,36 @@
memset(buf, 0, 50);
snprintf(buf, 50, "%f", *var);
dictionary_set(target,key,buf);
- if(!STRING_EMPTY(helptext) && IS_SHOWDEFAULT()) {
+ if(strcmp(helptext, "") && opCode & CFGOP_PRINT_DEFAULT) {
printComment(helptext);
printf("%s = %s\n", key,buf);
}
- return checkRangeDouble(dict, key, rangeFlags, minBound, maxBound);
+
+ ret = checkRangeDouble(dict, key, rangeFlags, minBound, maxBound);
+
+ if(!ret && !(opCode & CFGOP_PARSE_QUIET)) {
+ switch(rangeFlags) {
+ case RANGECHECK_RANGE:
+ ERROR("Configuration error: option \"%s=%f\" not within allowed range: %f..%f\n", key, *var, minBound, maxBound);
+ break;
+ case RANGECHECK_MIN:
+ ERROR("Configuration error: option \"%s=%f\" below allowed minimum: %f\n", key, *var, minBound);
+ break;
+ case RANGECHECK_MAX:
+ ERROR("Configuration error: option \"%s=%f\" above allowed maximum: %f\n", key, *var, maxBound);
+ break;
+ default:
+ return ret;
+ }
+ }
+
+ return ret;
}
}
static int
-configMapSelectValue(dictionary *dict, dictionary *target, const char* key, uint8_t *var, int def, const char *helptext, ...)
+configMapSelectValue(int opCode, void *opArg, dictionary *dict, dictionary *target,
+const char* key, int restartFlags, uint8_t *var, int def, const char *helptext, ...)
{
int ret;
@@ -597,25 +685,42 @@
}
va_end(ap);
+ if(opCode & CFGOP_RESTART_FLAGS) {
+ if(CONFIG_ISSET(key)) {
+ *(int*)opArg |= restartFlags;
+ if(opCode & CFGOP_RESTART_FLAGS && !(opCode & CFGOP_PARSE_QUIET)) {
+ warnRestart(key, restartFlags);
+ }
+ }
+ return 1;
+ } else if(opCode & CFGOP_HELP_FULL || opCode & CFGOP_HELP_SINGLE) {
- if(IS_HELP(key, helptext)) {
+ char *helpKey = (char*)opArg;
+
+ if(opCode & CFGOP_HELP_SINGLE && strcmp(key, helpKey)) {
+ return 1;
+ }
+
+ helpKey[0] = '\0';
+
printf("setting: %s (--%s)\n", key, key);
printf(" type: SELECT\n");
printf(" usage: %s\n", helptext);
printf("options: %s\n", sbuf);
printf("default: %s\n", defValue);
printf("\n");
- HELP_ITEM_COMPLETE();
ret = 1;
goto result;
} else {
dictionary_set(target, key, keyValue);
if(selectedValue < 0) {
- ERROR("Configuration error: option \"%s\" has unknown value: %s - allowed values: %s\n", key, keyValue, sbuf);
+ if(!(opCode & CFGOP_PARSE_QUIET)) {
+ ERROR("Configuration error: option \"%s\" has unknown value: %s - allowed values: %s\n", key, keyValue, sbuf);
+ }
ret = 0;
} else {
*var = (uint8_t)selectedValue;
- if(!STRING_EMPTY(helptext) && IS_SHOWDEFAULT()) {
+ if(strcmp(helptext, "") && opCode & CFGOP_PRINT_DEFAULT) {
printComment(helptext);
printf("; Options: %s\n", sbuf);
printf("%s = %s\n", key,keyValue);
@@ -654,7 +759,7 @@
search++;
replace = dictionary_get(dict, key, "");
snprintf(varname, sizeof(varname), "@%s@", search);
- DBG("replacing %s with %s in config\n", varname, replace);
+ DBGV("replacing %s with %s in config\n", varname, replace);
dictionary_replace(dict, varname, replace);
dictionary_set(target, key, replace);
}
@@ -669,7 +774,7 @@
* that are not present in the template - display only.
*/
static void
-findUnknownSettings(dictionary* source, dictionary* dict)
+findUnknownSettings(int opCode, dictionary* source, dictionary* dict)
{
int i = 0;
@@ -680,7 +785,7 @@
/* skip if the key is null or is a section */
if(source->key[i] == NULL || strstr(source->key[i],":") == NULL)
continue;
- if ( !iniparser_find_entry(dict, source->key[i]) && !IS_QUIET() )
+ if ( !iniparser_find_entry(dict, source->key[i]) && !(opCode & CFGOP_PARSE_QUIET) )
WARNING("Unknown configuration entry: %s - setting will be ignored\n", source->key[i]);
}
}
@@ -695,7 +800,7 @@
* ensure correct config reload behaviour.
*/
dictionary*
-parseConfig ( dictionary* dict, RunTimeOpts *rtOpts )
+parseConfig ( int opCode, void *opArg, dictionary* dict, RunTimeOpts *rtOpts )
{
/*-
@@ -705,6 +810,7 @@
*/
+
/*-
* WARNING: for ease of use, a limited number of keys is set
* via getopt in loadCommanLineOptions(). When renaming settings, make sure
@@ -729,7 +835,7 @@
PtpEnginePreset ptpPreset;
- if(!IS_QUIET()) {
+ if(!(opCode & CFGOP_PARSE_QUIET)) {
INFO("Checking configuration\n");
}
@@ -758,17 +864,20 @@
CONFIG_KEY_REQUIRED("ptpengine:interface");
- parseResult &= configMapString(dict, target, "ptpengine:interface",rtOpts->primaryIfaceName,rtOpts->primaryIfaceName,
+ parseResult &= configMapString(opCode, opArg, dict, target, "ptpengine:interface",
+ PTPD_RESTART_NETWORK, rtOpts->primaryIfaceName, sizeof(rtOpts->primaryIfaceName), rtOpts->primaryIfaceName,
"Network interface to use - eth0, igb0 etc. (required).");
- parseResult &= configMapString(dict, target, "ptpengine:backup_interface",rtOpts->backupIfaceName,rtOpts->backupIfaceName,
+ parseResult &= configMapString(opCode, opArg, dict, target, "ptpengine:backup_interface",
+ PTPD_RESTART_NETWORK, rtOpts->backupIfaceName, sizeof(rtOpts->backupIfaceName), rtOpts->backupIfaceName,
"Backup network interface to use - eth0, igb0 etc. When no GM available, \n"
" slave will keep alternating between primary and secondary until a GM is found.\n");
- CONFIG_KEY_TRIGGER("ptpengine:backup_interface",rtOpts->backupIfaceEnabled,TRUE,FALSE);
+ CONFIG_KEY_TRIGGER("ptpengine:backup_interface", rtOpts->backupIfaceEnabled,TRUE,FALSE);
/* Preset option names have to be mapped to defined presets - no free strings here */
- parseResult &= configMapSelectValue(dict, target, "ptpengine:preset", &rtOpts->selectedPreset,rtOpts->selectedPreset,
+ parseResult &= configMapSelectValue(opCode, opArg, dict, target, "ptpengine:preset",
+ PTPD_RESTART_PROTOCOL, &rtOpts->selectedPreset, rtOpts->selectedPreset,
"PTP engine preset:\n"
" none = Defaults, no clock class restrictions\n"
" masteronly = Master, passive when not best master (clock class 0..127)\n"
@@ -777,11 +886,11 @@
" (clock class 128..254)\n"
" slaveonly = Slave only (clock class 255 only)\n",
#ifndef PTPD_SLAVE_ONLY
- (getPtpPreset(PTP_PRESET_NONE,rtOpts)).presetName, PTP_PRESET_NONE,
- (getPtpPreset(PTP_PRESET_MASTERONLY,rtOpts)).presetName, PTP_PRESET_MASTERONLY,
- (getPtpPreset(PTP_PRESET_MASTERSLAVE,rtOpts)).presetName, PTP_PRESET_MASTERSLAVE,
+ (getPtpPreset(PTP_PRESET_NONE, rtOpts)).presetName, PTP_PRESET_NONE,
+ (getPtpPreset(PTP_PRESET_MASTERONLY, rtOpts)).presetName, PTP_PRESET_MASTERONLY,
+ (getPtpPreset(PTP_PRESET_MASTERSLAVE, rtOpts)).presetName, PTP_PRESET_MASTERSLAVE,
#endif /* PTPD_SLAVE_ONLY */
- (getPtpPreset(PTP_PRESET_SLAVEONLY,rtOpts)).presetName, PTP_PRESET_SLAVEONLY, NULL
+ (getPtpPreset(PTP_PRESET_SLAVEONLY, rtOpts)).presetName, PTP_PRESET_SLAVEONLY, NULL
);
CONFIG_KEY_CONDITIONAL_CONFLICT("ptpengine:preset",
@@ -792,7 +901,8 @@
ptpPreset = getPtpPreset(rtOpts->selectedPreset, rtOpts);
- parseResult &= configMapSelectValue(dict, target, "ptpengine:transport", &rtOpts->transport,rtOpts->transport,
+ parseResult &= configMapSelectValue(opCode, opArg, dict, target, "ptpengine:transport",
+ PTPD_RESTART_NETWORK, &rtOpts->transport, rtOpts->transport,
"Transport type for PTP packets. Ethernet transport requires libpcap support.",
"ipv4", UDP_IPV4,
#if 0
@@ -801,16 +911,17 @@
"ethernet", IEEE_802_3, NULL
);
- parseResult &= configMapBoolean(dict, target,"ptpengine:dot2as", &rtOpts->dot2AS,rtOpts->dot2AS,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:dot2as", PTPD_UPDATE_DATASETS, &rtOpts->dot2AS, rtOpts->dot2AS,
"Enable TransportSpecific field compatibility with 802.1AS / AVB (requires Ethernet transport)");
CONFIG_KEY_CONDITIONAL_WARNING_ISSET((rtOpts->transport != IEEE_802_3) && rtOpts->dot2AS,
"ptpengine:dot2as",
"802.1AS compatibility can only be used with the Ethernet transport\n");
- CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->transport != IEEE_802_3,rtOpts->dot2AS,FALSE,rtOpts->dot2AS);
+ CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->transport != IEEE_802_3, rtOpts->dot2AS,FALSE, rtOpts->dot2AS);
- parseResult &= configMapSelectValue(dict, target, "ptpengine:ip_mode", &rtOpts->ipMode, rtOpts->ipMode,
+ parseResult &= configMapSelectValue(opCode, opArg, dict, target, "ptpengine:ip_mode",
+ PTPD_RESTART_NETWORK, &rtOpts->ipMode, rtOpts->ipMode,
"IP transmission mode (requires IP transport) - hybrid mode uses\n"
" multicast for sync and announce, and unicast for delay request and\n"
" response; unicast mode uses unicast for all transmission.\n"
@@ -821,15 +932,18 @@
"hybrid", IPMODE_HYBRID, NULL
);
- parseResult &= configMapBoolean(dict, target,"ptpengine:unicast_negotiation", &rtOpts->unicastNegotiation,rtOpts->unicastNegotiation,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:unicast_negotiation",
+ PTPD_RESTART_PROTOCOL, &rtOpts->unicastNegotiation, rtOpts->unicastNegotiation,
"Enable unicast negotiation support using signaling messages\n");
- parseResult &= configMapBoolean(dict, target,"ptpengine:unicast_any_master", &rtOpts->unicastAcceptAny,rtOpts->unicastAcceptAny,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:unicast_any_master",
+ PTPD_RESTART_NONE, &rtOpts->unicastAcceptAny, rtOpts->unicastAcceptAny,
"When using unicast negotiation (slave), accept PTP messages from any master.\n"
" By default, only messages from acceptable masters (ptpengine:unicast_destinations)\n"
" are accepted, and only if transmission was granted by the master\n");
- parseResult &= configMapInt(dict, target, "ptpengine:unicast_port_mask", INTTYPE_U16, &rtOpts->unicastPortMask,rtOpts->unicastPortMask,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:unicast_port_mask",
+ PTPD_RESTART_PROTOCOL, INTTYPE_U16, &rtOpts->unicastPortMask, rtOpts->unicastPortMask,
"PTP port number wildcard mask applied onto port identities when running\n"
" unicast negotiation: allows multiple port identities to be accepted as one.\n"
" This option can be used as a workaround where a node sends signaling messages and\n"
@@ -844,15 +958,17 @@
"Unicast negotiation can only be used with unicast transmission\n");
/* disable unicast negotiation unless running unicast */
- CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->transport == IEEE_802_3,rtOpts->unicastNegotiation,FALSE,rtOpts->unicastNegotiation);
- CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->ipMode != IPMODE_UNICAST,rtOpts->unicastNegotiation,FALSE,rtOpts->unicastNegotiation);
+ CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->transport == IEEE_802_3, rtOpts->unicastNegotiation,FALSE, rtOpts->unicastNegotiation);
+ CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->ipMode != IPMODE_UNICAST, rtOpts->unicastNegotiation,FALSE, rtOpts->unicastNegotiation);
- parseResult &= configMapBoolean(dict, target,"ptpengine:disable_bmca", &rtOpts->disableBMCA,rtOpts->disableBMCA,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:disable_bmca",
+ PTPD_RESTART_PROTOCOL, &rtOpts->disableBMCA, rtOpts->disableBMCA,
"Disable Best Master Clock Algorithm for unicast masters:\n"
" Only effective for masteronly preset - all Announce messages\n"
" will be ignored and clock will transition directly into MASTER state.\n");
- parseResult &= configMapBoolean(dict, target,"ptpengine:unicast_negotiation_listening", &rtOpts->unicastNegotiationListening,rtOpts->unicastNegotiationListening,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:unicast_negotiation_listening",
+ PTPD_RESTART_NONE, &rtOpts->unicastNegotiationListening, rtOpts->unicastNegotiationListening,
"When unicast negotiation enabled on a master clock, \n"
" reply to transmission requests also in LISTENING state.");
@@ -861,7 +977,8 @@
INFO("Libpcap support is currently marked broken/experimental on Solaris platforms.\n"
"To test it, please build with --enable-experimental-options\n");
- parseResult &= configMapBoolean(dict, target,"ptpengine:use_libpcap", &rtOpts->pcap,FALSE,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:use_libpcap",
+ PTPD_RESTART_NETWORK, &rtOpts->pcap,FALSE,
"Use libpcap for sending and receiving traffic (automatically enabled\n"
" in Ethernet mode).");
@@ -872,19 +989,21 @@
"Libpcap support is currently marked broken/experimental on Solaris platforms.\n"
"To test it and use the Ethernet transport, please build with --enable-experimental-options\n");
#elif defined(PTPD_PCAP)
- parseResult &= configMapBoolean(dict, target,"ptpengine:use_libpcap", &rtOpts->pcap,rtOpts->pcap,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:use_libpcap",
+ PTPD_RESTART_NETWORK, &rtOpts->pcap, rtOpts->pcap,
"Use libpcap for sending and receiving traffic (automatically enabled\n"
" in Ethernet mode).");
/* in ethernet mode, activate pcap and overwrite previous setting */
- CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->transport==IEEE_802_3,rtOpts->pcap,TRUE,rtOpts->pcap);
+ CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->transport==IEEE_802_3, rtOpts->pcap,TRUE, rtOpts->pcap);
#else
if(CONFIG_ISTRUE("ptpengine:use_libpcap"))
INFO("Libpcap support disabled or not available. Please install libpcap,\n"
"build without --disable-pcap, or try building with ---with-pcap-config\n"
" to use ptpengine:use_libpcap.\n");
- parseResult &= configMapBoolean(dict, target,"ptpengine:use_libpcap", &rtOpts->pcap,FALSE,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:use_libpcap",
+ PTPD_RESTART_NETWORK, &rtOpts->pcap,FALSE,
"Use libpcap for sending and receiving traffic (automatically enabled\n"
" in Ethernet mode).");
@@ -898,12 +1017,14 @@
#endif /* PTPD_PCAP */
- parseResult &= configMapBoolean(dict, target,"ptpengine:disable_udp_checksums", &rtOpts->disableUdpChecksums,rtOpts->disableUdpChecksums,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:disable_udp_checksums",
+ PTPD_RESTART_NETWORK, &rtOpts->disableUdpChecksums, rtOpts->disableUdpChecksums,
"Disable UDP checksum validation on UDP sockets (Linux only).\n"
" Workaround for situations where a node (like Transparent Clock).\n"
" does not rewrite checksums\n");
- parseResult &= configMapSelectValue(dict, target, "ptpengine:delay_mechanism", &rtOpts->delayMechanism,rtOpts->delayMechanism,
+ parseResult &= configMapSelectValue(opCode, opArg, dict, target, "ptpengine:delay_mechanism",
+ PTPD_RESTART_PROTOCOL, &rtOpts->delayMechanism, rtOpts->delayMechanism,
"Delay detection mode used - use DELAY_DISABLED for syntonisation only\n"
" (no full synchronisation).",
"E2E", E2E,
@@ -911,62 +1032,72 @@
"DELAY_DISABLED", DELAY_DISABLED, NULL
);
- parseResult &= configMapInt(dict, target, "ptpengine:domain", INTTYPE_U8, &rtOpts->domainNumber,rtOpts->domainNumber,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:domain",
+ PTPD_RESTART_PROTOCOL, INTTYPE_U8, &rtOpts->domainNumber, rtOpts->domainNumber,
"PTP domain number.", RANGECHECK_RANGE, 0,127);
- parseResult &= configMapInt(dict, target, "ptpengine:port_number", INTTYPE_U16, &rtOpts->portNumber,rtOpts->portNumber,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:port_number", PTPD_UPDATE_DATASETS, INTTYPE_U16, &rtOpts->portNumber, rtOpts->portNumber,
"PTP port number (part of PTP Port Identity - not UDP port).\n"
" For ordinary clocks (single port), the default should be used, \n"
" but when running multiple instances to simulate a boundary clock, \n"
" The port number can be changed.",RANGECHECK_RANGE,1,65534);
- parseResult &= configMapBoolean(dict, target,"ptpengine:any_domain", &rtOpts->anyDomain, rtOpts->anyDomain,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:any_domain",
+ PTPD_RESTART_PROTOCOL, &rtOpts->anyDomain, rtOpts->anyDomain,
"Usability extension: if enabled, a slave-only clock will accept\n"
" masters from any domain, while preferring the configured domain,\n"
" and preferring lower domain number.\n"
" NOTE: this behaviour is not part of the standard.");
- parseResult &= configMapBoolean(dict, target,"ptpengine:slave_only", &rtOpts->slaveOnly, ptpPreset.slaveOnly,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:slave_only",
+ PTPD_RESTART_NONE, &rtOpts->slaveOnly, ptpPreset.slaveOnly,
"Slave only mode (sets clock class to 255, overriding value from preset).");
- parseResult &= configMapInt(dict, target, "ptpengine:inbound_latency", INTTYPE_I32, &rtOpts->inboundLatency.nanoseconds,rtOpts->inboundLatency.nanoseconds,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:inbound_latency",
+ PTPD_RESTART_NONE, INTTYPE_I32, &rtOpts->inboundLatency.nanoseconds, rtOpts->inboundLatency.nanoseconds,
"Specify latency correction (nanoseconds) for incoming packets.", RANGECHECK_NONE, 0,0);
- parseResult &= configMapInt(dict, target, "ptpengine:outbound_latency",INTTYPE_I32, &rtOpts->outboundLatency.nanoseconds,rtOpts->outboundLatency.nanoseconds,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:outbound_latency",
+ PTPD_RESTART_NONE, INTTYPE_I32, &rtOpts->outboundLatency.nanoseconds, rtOpts->outboundLatency.nanoseconds,
"Specify latency correction (nanoseconds) for outgoing packets.", RANGECHECK_NONE,0,0);
- parseResult &= configMapInt(dict, target, "ptpengine:offset_shift", INTTYPE_I32, &rtOpts->ofmShift.nanoseconds,rtOpts->ofmShift.nanoseconds,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:offset_shift",
+ PTPD_RESTART_NONE, INTTYPE_I32, &rtOpts->ofmShift.nanoseconds, rtOpts->ofmShift.nanoseconds,
"Apply an arbitrary shift (nanoseconds) to offset from master when\n"
" in slave state. Value can be positive or negative - useful for\n"
" correcting for antenna latencies, delay assymetry\n"
" and IP stack latencies. This will not be visible in the offset \n"
" from master value - only in the resulting clock correction.", RANGECHECK_NONE, 0,0);
- parseResult &= configMapBoolean(dict, target,"ptpengine:always_respect_utc_offset", &rtOpts->alwaysRespectUtcOffset, rtOpts->alwaysRespectUtcOffset,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:always_respect_utc_offset",
+ PTPD_RESTART_NONE, &rtOpts->alwaysRespectUtcOffset, rtOpts->alwaysRespectUtcOffset,
"Compatibility option: In slave state, always respect UTC offset\n"
" announced by best master, even if the the\n"
" currrentUtcOffsetValid flag is announced FALSE.\n"
" NOTE: this behaviour is not part of the standard.");
- parseResult &= configMapBoolean(dict, target,"ptpengine:prefer_utc_offset_valid", &rtOpts->preferUtcValid, rtOpts->preferUtcValid,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:prefer_utc_offset_valid",
+ PTPD_RESTART_NONE, &rtOpts->preferUtcValid, rtOpts->preferUtcValid,
"Compatibility extension to BMC algorithm: when enabled,\n"
" BMC for both master and save clocks will prefer masters\n"
" nannouncing currrentUtcOffsetValid as TRUE.\n"
" NOTE: this behaviour is not part of the standard.");
- parseResult &= configMapBoolean(dict, target,"ptpengine:require_utc_offset_valid", &rtOpts->requireUtcValid, rtOpts->requireUtcValid,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:require_utc_offset_valid",
+ PTPD_RESTART_NONE, &rtOpts->requireUtcValid, rtOpts->requireUtcValid,
"Compatibility option: when enabled, ptpd2 will ignore\n"
" Announce messages from masters announcing currentUtcOffsetValid\n"
" as FALSE.\n"
" NOTE: this behaviour is not part of the standard.");
/* from 30 seconds to 7 days */
- parseResult &= configMapInt(dict, target, "ptpengine:unicast_grant_duration", INTTYPE_U32, &rtOpts->unicastGrantDuration, rtOpts->unicastGrantDuration,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:unicast_grant_duration",
+ PTPD_RESTART_PROTOCOL, INTTYPE_U32, &rtOpts->unicastGrantDuration, rtOpts->unicastGrantDuration,
"Time (seconds) unicast messages are requested for by slaves\n"
" when using unicast negotiation, and maximum time unicast message\n"
" transmission is granted to slaves by masters\n", RANGECHECK_RANGE, 30, 604800);
- parseResult &= configMapInt(dict, target, "ptpengine:log_announce_interval", INTTYPE_I8, &rtOpts->logAnnounceInterval,rtOpts->logAnnounceInterval,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:log_announce_interval", PTPD_UPDATE_DATASETS, INTTYPE_I8, &rtOpts->logAnnounceInterval, rtOpts->logAnnounceInterval,
"PTP announce message interval in master state. When using unicast negotiation, for\n"
" slaves this is the minimum interval requested, and for masters\n"
" this is the only interval granted.\n"
@@ -976,7 +1107,7 @@
" "LOG2_HELP,RANGECHECK_RANGE,-4,7);
#endif
- parseResult &= configMapInt(dict, target, "ptpengine:log_announce_interval_max",INTTYPE_I8,&rtOpts->logMaxAnnounceInterval,rtOpts->logMaxAnnounceInterval,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:log_announce_interval_max", PTPD_UPDATE_DATASETS, INTTYPE_I8, &rtOpts->logMaxAnnounceInterval, rtOpts->logMaxAnnounceInterval,
"Maximum Announce message interval requested by slaves "
"when using unicast negotiation,\n"
#ifdef PTPD_EXPERIMENTAL
@@ -988,10 +1119,11 @@
CONFIG_CONDITIONAL_ASSERTION(rtOpts->logAnnounceInterval >= rtOpts->logMaxAnnounceInterval,
"ptpengine:log_announce_interval value must be lower than ptpengine:log_announce_interval_max\n");
- parseResult &= configMapInt(dict, target, "ptpengine:announce_receipt_timeout",INTTYPE_I8, &rtOpts->announceReceiptTimeout,rtOpts->announceReceiptTimeout,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:announce_receipt_timeout", PTPD_UPDATE_DATASETS, INTTYPE_I8, &rtOpts->announceReceiptTimeout, rtOpts->announceReceiptTimeout,
"PTP announce receipt timeout announced in master state.",RANGECHECK_RANGE,2,255);
- parseResult &= configMapInt(dict, target, "ptpengine:announce_receipt_grace_period",INTTYPE_INT,&rtOpts->announceTimeoutGracePeriod,rtOpts->announceTimeoutGracePeriod,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:announce_receipt_grace_period",
+ PTPD_RESTART_NONE, INTTYPE_INT, &rtOpts->announceTimeoutGracePeriod, rtOpts->announceTimeoutGracePeriod,
"PTP announce receipt timeout grace period in slave state:\n"
" when announce receipt timeout occurs, disqualify current best GM,\n"
" then wait n times announce receipt timeout before resetting.\n"
@@ -999,7 +1131,7 @@
" to react. When set to 0, this option is not used.", RANGECHECK_RANGE,
0,20);
- parseResult &= configMapInt(dict, target, "ptpengine:log_sync_interval",INTTYPE_I8,&rtOpts->logSyncInterval,rtOpts->logSyncInterval,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:log_sync_interval", PTPD_UPDATE_DATASETS, INTTYPE_I8, &rtOpts->logSyncInterval, rtOpts->logSyncInterval,
"PTP sync message interval in master state. When using unicast negotiation, for\n"
" slaves this is the minimum interval requested, and for masters\n"
" this is the only interval granted.\n"
@@ -1009,7 +1141,7 @@
" "LOG2_HELP,RANGECHECK_RANGE,-7,7);
#endif
- parseResult &= configMapInt(dict, target, "ptpengine:log_sync_interval_max",INTTYPE_I8,&rtOpts->logMaxSyncInterval,rtOpts->logMaxSyncInterval,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:log_sync_interval_max", PTPD_UPDATE_DATASETS, INTTYPE_I8, &rtOpts->logMaxSyncInterval, rtOpts->logMaxSyncInterval,
"Maximum Sync message interval requested by slaves "
"when using unicast negotiation,\n"
#ifdef PTPD_EXPERIMENTAL
@@ -1021,17 +1153,18 @@
CONFIG_CONDITIONAL_ASSERTION(rtOpts->logSyncInterval >= rtOpts->logMaxSyncInterval,
"ptpengine:log_sync_interval value must be lower than ptpengine:log_sync_interval_max\n");
- parseResult &= configMapBoolean(dict, target,"ptpengine:log_delayreq_override", &rtOpts->ignore_delayreq_interval_master,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:log_delayreq_override", PTPD_UPDATE_DATASETS, &rtOpts->ignore_delayreq_interval_master,
rtOpts->ignore_delayreq_interval_master,
"Override the Delay Request interval announced by best master.");
- parseResult &= configMapBoolean(dict, target,"ptpengine:log_delayreq_auto", &rtOpts->autoDelayReqInterval,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:log_delayreq_auto", PTPD_UPDATE_DATASETS, &rtOpts->autoDelayReqInterval,
rtOpts->autoDelayReqInterval,
"Automatically override the Delay Request interval\n"
" if the announced value is 127 (0X7F), such as in\n"
" unicast messages (unless using unicast negotiation)");
- parseResult &= configMapInt(dict, target, "ptpengine:log_delayreq_interval_initial",INTTYPE_I8,&rtOpts->initial_delayreq,rtOpts->initial_delayreq,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:log_delayreq_interval_initial",
+ PTPD_RESTART_NONE, INTTYPE_I8, &rtOpts->initial_delayreq, rtOpts->initial_delayreq,
"Delay request interval used before receiving first delay response\n"
#ifdef PTPD_EXPERIMENTAL
" "LOG2_HELP,RANGECHECK_RANGE,-30,30);
@@ -1040,7 +1173,7 @@
#endif
/* take the delayreq_interval from config, otherwise use the initial setting as default */
- parseResult &= configMapInt(dict, target, "ptpengine:log_delayreq_interval",INTTYPE_I8,&rtOpts->logMinDelayReqInterval,rtOpts->initial_delayreq,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:log_delayreq_interval", PTPD_UPDATE_DATASETS, INTTYPE_I8, &rtOpts->logMinDelayReqInterval, rtOpts->initial_delayreq,
"Minimum delay request interval announced when in master state,\n"
" in slave state overrides the master interval,\n"
" required in hybrid mode. When using unicast negotiation, for\n"
@@ -1052,7 +1185,7 @@
" "LOG2_HELP,RANGECHECK_RANGE,-7,7);
#endif
- parseResult &= configMapInt(dict, target, "ptpengine:log_delayreq_interval_max",INTTYPE_I8,&rtOpts->logMaxDelayReqInterval,rtOpts->logMaxDelayReqInterval,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:log_delayreq_interval_max", PTPD_UPDATE_DATASETS, INTTYPE_I8, &rtOpts->logMaxDelayReqInterval, rtOpts->logMaxDelayReqInterval,
"Maximum Delay Response interval requested by slaves "
"when using unicast negotiation,\n"
#ifdef PTPD_EXPERIMENTAL
@@ -1064,7 +1197,8 @@
CONFIG_CONDITIONAL_ASSERTION(rtOpts->logMinDelayReqInterval >= rtOpts->logMaxDelayReqInterval,
"ptpengine:log_delayreq_interval value must be lower than ptpengine:log_delayreq_interval_max\n");
- parseResult &= configMapInt(dict, target, "ptpengine:log_peer_delayreq_interval",INTTYPE_I8,&rtOpts->logMinPdelayReqInterval,rtOpts->logMinPdelayReqInterval,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:log_peer_delayreq_interval",
+ PTPD_RESTART_NONE, INTTYPE_I8, &rtOpts->logMinPdelayReqInterval, rtOpts->logMinPdelayReqInterval,
"Minimum peer delay request message interval in peer to peer delay mode.\n"
" When using unicast negotiation, this is the minimum interval requested, \n"
" and the only interval granted.\n"
@@ -1074,7 +1208,8 @@
" "LOG2_HELP,RANGECHECK_RANGE,-7,7);
#endif
- parseResult &= configMapInt(dict, target, "ptpengine:log_peer_delayreq_interval_max",INTTYPE_I8,&rtOpts->logMaxPdelayReqInterval,rtOpts->logMaxPdelayReqInterval,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:log_peer_delayreq_interval_max",
+ PTPD_RESTART_NONE, INTTYPE_I8, &rtOpts->logMaxPdelayReqInterval, rtOpts->logMaxPdelayReqInterval,
"Maximum Peer Delay Response interval requested by slaves "
"when using unicast negotiation,\n"
#ifdef PTPD_EXPERIMENTAL
@@ -1086,13 +1221,14 @@
CONFIG_CONDITIONAL_ASSERTION(rtOpts->logMinPdelayReqInterval >= rtOpts->logMaxPdelayReqInterval,
"ptpengine:log_peer_delayreq_interval value must be lower than ptpengine:log_peer_delayreq_interval_max\n");
- parseResult &= configMapInt(dict, target, "ptpengine:foreignrecord_capacity",INTTYPE_I16,&rtOpts->max_foreign_records,rtOpts->max_foreign_records,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:foreignrecord_capacity",
+ PTPD_RESTART_DAEMON, INTTYPE_I16, &rtOpts->max_foreign_records, rtOpts->max_foreign_records,
"Foreign master record size (Maximum number of foreign masters).",RANGECHECK_RANGE,5,10);
- parseResult &= configMapInt(dict, target, "ptpengine:ptp_allan_variance",INTTYPE_U16,&rtOpts->clockQuality.offsetScaledLogVariance,rtOpts->clockQuality.offsetScaledLogVariance,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:ptp_allan_variance", PTPD_UPDATE_DATASETS, INTTYPE_U16, &rtOpts->clockQuality.offsetScaledLogVariance, rtOpts->clockQuality.offsetScaledLogVariance,
"Specify Allan variance announced in master state.",RANGECHECK_RANGE,0,65535);
- parseResult &= configMapSelectValue(dict, target, "ptpengine:ptp_clock_accuracy", &rtOpts->clockQuality.clockAccuracy,rtOpts->clockQuality.clockAccuracy,
+ parseResult &= configMapSelectValue(opCode, opArg, dict, target, "ptpengine:ptp_clock_accuracy", PTPD_UPDATE_DATASETS, &rtOpts->clockQuality.clockAccuracy, rtOpts->clockQuality.clockAccuracy,
"Clock accuracy range announced in master state.",
"ACC_25NS", 0x20,
"ACC_100NS", 0x21,
@@ -1115,22 +1251,22 @@
"ACC_UNKNOWN", 0xFE, NULL
);
- parseResult &= configMapInt(dict, target, "ptpengine:utc_offset",INTTYPE_I16,&rtOpts->timeProperties.currentUtcOffset,rtOpts->timeProperties.currentUtcOffset,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:utc_offset", PTPD_UPDATE_DATASETS, INTTYPE_I16, &rtOpts->timeProperties.currentUtcOffset, rtOpts->timeProperties.currentUtcOffset,
"Underlying time source UTC offset announced in master state.", RANGECHECK_NONE,0,0);
- parseResult &= configMapBoolean(dict, target,"ptpengine:utc_offset_valid", &rtOpts->timeProperties.currentUtcOffsetValid,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:utc_offset_valid", PTPD_UPDATE_DATASETS, &rtOpts->timeProperties.currentUtcOffsetValid,
rtOpts->timeProperties.currentUtcOffsetValid,
"Underlying time source UTC offset validity announced in master state.");
- parseResult &= configMapBoolean(dict, target,"ptpengine:time_traceable", &rtOpts->timeProperties.timeTraceable,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:time_traceable", PTPD_UPDATE_DATASETS, &rtOpts->timeProperties.timeTraceable,
rtOpts->timeProperties.timeTraceable,
"Underlying time source time traceability announced in master state.");
- parseResult &= configMapBoolean(dict, target,"ptpengine:frequency_traceable", &rtOpts->timeProperties.frequencyTraceable,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:frequency_traceable", PTPD_UPDATE_DATASETS, &rtOpts->timeProperties.frequencyTraceable,
rtOpts->timeProperties.frequencyTraceable,
"Underlying time source frequency traceability announced in master state.");
- parseResult &= configMapSelectValue(dict, target, "ptpengine:ptp_timescale", (uint8_t*)&rtOpts->timeProperties.ptpTimescale,rtOpts->timeProperties.ptpTimescale,
+ parseResult &= configMapSelectValue(opCode, opArg, dict, target, "ptpengine:ptp_timescale", PTPD_UPDATE_DATASETS, (uint8_t*)&rtOpts->timeProperties.ptpTimescale, rtOpts->timeProperties.ptpTimescale,
"Time scale announced in master state (with ARB, UTC properties\n"
" are ignored by slaves). When clock class is set to 13 (application\n"
" specific), this value is ignored and ARB is used.",
@@ -1138,7 +1274,7 @@
"ARB", FALSE, NULL
);
- parseResult &= configMapSelectValue(dict, target, "ptpengine:ptp_timesource", &rtOpts->timeProperties.timeSource,rtOpts->timeProperties.timeSource,
+ parseResult &= configMapSelectValue(opCode, opArg, dict, target, "ptpengine:ptp_timesource", PTPD_UPDATE_DATASETS, &rtOpts->timeProperties.timeSource, rtOpts->timeProperties.timeSource,
"Time source announced in master state.",
"ATOMIC_CLOCK", ATOMIC_CLOCK,
"GPS", GPS,
@@ -1150,7 +1286,7 @@
"INTERNAL_OSCILLATOR", INTERNAL_OSCILLATOR, NULL
);
- parseResult &= configMapInt(dict, target, "ptpengine:clock_class",INTTYPE_U8,&rtOpts->clockQuality.clockClass,ptpPreset.clockClass.defaultValue,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:clock_class", PTPD_UPDATE_DATASETS, INTTYPE_U8, &rtOpts->clockQuality.clockClass,ptpPreset.clockClass.defaultValue,
"Clock class - announced in master state. Always 255 for slave-only.\n"
" Minimum, maximum and default values are controlled by presets.\n"
" If set to 13 (application specific time source), announced \n"
@@ -1162,34 +1298,35 @@
/* ClockClass = 13 triggers ARB */
CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->clockQuality.clockClass==DEFAULT_CLOCK_CLASS__APPLICATION_SPECIFIC_TIME_SOURCE,
- rtOpts->timeProperties.ptpTimescale,FALSE,rtOpts->timeProperties.ptpTimescale);
+ rtOpts->timeProperties.ptpTimescale,FALSE, rtOpts->timeProperties.ptpTimescale);
/* ClockClass = 14 triggers ARB */
CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->clockQuality.clockClass==14,
- rtOpts->timeProperties.ptpTimescale,FALSE,rtOpts->timeProperties.ptpTimescale);
+ rtOpts->timeProperties.ptpTimescale,FALSE, rtOpts->timeProperties.ptpTimescale);
/* ClockClass = 6 triggers PTP*/
CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->clockQuality.clockClass==6,
- rtOpts->timeProperties.ptpTimescale,TRUE,rtOpts->timeProperties.ptpTimescale);
+ rtOpts->timeProperties.ptpTimescale,TRUE, rtOpts->timeProperties.ptpTimescale);
/* ClockClass = 7 triggers PTP*/
CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->clockQuality.clockClass==7,
- rtOpts->timeProperties.ptpTimescale,TRUE,rtOpts->timeProperties.ptpTimescale);
+ rtOpts->timeProperties.ptpTimescale,TRUE, rtOpts->timeProperties.ptpTimescale);
/* ClockClass = 255 triggers slaveOnly */
- CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->clockQuality.clockClass==SLAVE_ONLY_CLOCK_CLASS,rtOpts->slaveOnly,TRUE,FALSE);
+ CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->clockQuality.clockClass==SLAVE_ONLY_CLOCK_CLASS, rtOpts->slaveOnly,TRUE,FALSE);
/* ...and vice versa */
- CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->slaveOnly==TRUE,rtOpts->clockQuality.clockClass,SLAVE_ONLY_CLOCK_CLASS,rtOpts->clockQuality.clockClass);
+ CONFIG_KEY_CONDITIONAL_TRIGGER(rtOpts->slaveOnly==TRUE, rtOpts->clockQuality.clockClass,SLAVE_ONLY_CLOCK_CLASS, rtOpts->clockQuality.clockClass);
- parseResult &= configMapInt(dict, target, "ptpengine:priority1",INTTYPE_U8,&rtOpts->priority1,rtOpts->priority1,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:priority1", PTPD_UPDATE_DATASETS, INTTYPE_U8, &rtOpts->priority1, rtOpts->priority1,
"Priority 1 announced in master state,used for Best Master\n"
" Clock selection.",RANGECHECK_RANGE,0,248);
- parseResult &= configMapInt(dict, target, "ptpengine:priority2",INTTYPE_U8,&rtOpts->priority2,rtOpts->priority2,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:priority2", PTPD_UPDATE_DATASETS, INTTYPE_U8, &rtOpts->priority2, rtOpts->priority2,
"Priority 2 announced in master state, used for Best Master\n"
" Clock selection.",RANGECHECK_RANGE,0,248);
- parseResult &= configMapInt(dict, target, "ptpengine:max_listen",INTTYPE_INT,&rtOpts->maxListen,rtOpts->maxListen,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:max_listen",
+ PTPD_RESTART_NONE, INTTYPE_INT, &rtOpts->maxListen, rtOpts->maxListen,
"Number of consecutive resets to LISTENING before full network reset\n",RANGECHECK_MIN,1,0);
/*
@@ -1210,6 +1347,8 @@
"It is recommended to set the delay request interval (ptpengine:log_delayreq_interval) in unicast mode"
);
+
+
CONFIG_KEY_ALIAS("ptpengine:unicast_address","ptpengine:unicast_destinations");
/* unicast signaling slave -> must specify unicast destination(s) */
@@ -1228,22 +1367,25 @@
"unicast",
"ptpengine:unicast_destinations");
- CONFIG_KEY_TRIGGER("ptpengine:unicast_destinations",rtOpts->unicastDestinationsSet,TRUE,rtOpts->unicastDestinationsSet);
+ CONFIG_KEY_TRIGGER("ptpengine:unicast_destinations", rtOpts->unicastDestinationsSet,TRUE, rtOpts->unicastDestinationsSet);
- parseResult &= configMapString(dict, target, "ptpengine:unicast_destinations",rtOpts->unicastDestinations,rtOpts->unicastDestinations,
+ parseResult &= configMapString(opCode, opArg, dict, target, "ptpengine:unicast_destinations",
+ PTPD_RESTART_NETWORK, rtOpts->unicastDestinations, sizeof(rtOpts->unicastDestinations), rtOpts->unicastDestinations,
"Specify unicast slave addresses for unicast master operation, or unicast\n"
" master addresses for slave operation. Format is similar to an ACL: comma,\n"
" tab or space-separated IPv4 unicast addresses, one or more. For a slave,\n"
" when unicast negotiation is used, setting this is mandatory.");
- parseResult &= configMapString(dict, target, "ptpengine:unicast_domains",rtOpts->unicastDomains,rtOpts->unicastDomains,
+ parseResult &= configMapString(opCode, opArg, dict, target, "ptpengine:unicast_domains",
+ PTPD_RESTART_NETWORK, rtOpts->unicastDomains, sizeof(rtOpts->unicastDomains), rtOpts->unicastDomains,
"Specify PTP domain number for each configured unicast destination (ptpengine:unicast_destinations).\n"
" This is only used by slave-only clocks using unicast destinations to allow for each master\n"
" to be in a separate domain, such as with Telecom Profile. The number of entries should match the number\n"
" of unicast destinations, otherwise unconfigured domains or domains set to 0 are set to domain configured in\n"
" ptpengine:domain. The format is a comma, tab or space-separated list of 8-bit unsigned integers (0 .. 255)");
- parseResult &= configMapString(dict, target, "ptpengine:unicast_local_preference",rtOpts->unicastLocalPreference,rtOpts->unicastLocalPreference,
+ parseResult &= configMapString(opCode, opArg, dict, target, "ptpengine:unicast_local_preference",
+ PTPD_RESTART_NETWORK, rtOpts->unicastLocalPreference, sizeof(rtOpts->unicastLocalPreference), rtOpts->unicastLocalPreference,
"Specify a local preference for each configured unicast destination (ptpengine:unicast_destinations).\n"
" This is only used by slave-only clocks using unicast destinations to allow for each master's\n"
" BMC selection to be influenced by the slave, such as with Telecom Profile. The number of entries should match the number\n"
@@ -1257,41 +1399,50 @@
"P2P",
"ptpengine:unicast_peer_destination");
- CONFIG_KEY_TRIGGER("ptpengine:unicast_peer_destination",rtOpts->unicastPeerDestinationSet,TRUE,rtOpts->unicastPeerDestinationSet);
+ CONFIG_KEY_TRIGGER("ptpengine:unicast_peer_destination", rtOpts->unicastPeerDestinationSet,TRUE, rtOpts->unicastPeerDestinationSet);
- parseResult &= configMapString(dict, target, "ptpengine:unicast_peer_destination",rtOpts->unicastPeerDestination,rtOpts->unicastPeerDestination,
+ parseResult &= configMapString(opCode, opArg, dict, target, "ptpengine:unicast_peer_destination",
+ PTPD_RESTART_NETWORK, rtOpts->unicastPeerDestination, sizeof(rtOpts->unicastPeerDestination), rtOpts->unicastPeerDestination,
"Specify peer unicast adress for P2P unicast. Mandatory when\n"
" running unicast mode and P2P delay mode.");
- parseResult &= configMapBoolean(dict, target,"ptpengine:management_enable", &rtOpts->managementEnabled,rtOpts->managementEnabled,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:management_enable",
+ PTPD_RESTART_NONE, &rtOpts->managementEnabled, rtOpts->managementEnabled,
"Enable handling of PTP management messages.");
- parseResult &= configMapBoolean(dict, target,"ptpengine:management_set_enable", &rtOpts->managementSetEnable,rtOpts->managementSetEnable,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:management_set_enable",
+ PTPD_RESTART_NONE, &rtOpts->managementSetEnable, rtOpts->managementSetEnable,
"Accept SET and COMMAND management messages.");
- parseResult &= configMapBoolean(dict, target,"ptpengine:igmp_refresh", &rtOpts->do_IGMP_refresh,rtOpts->do_IGMP_refresh,
+ parseResult &= configMapBoolean(opCode, opArg, dict, target, "ptpengine:igmp_refresh",
+ PTPD_RESTART_NONE, &rtOpts->do_IGMP_refresh, rtOpts->do_IGMP_refresh,
"Send explicit IGMP joins between engine resets and periodically\n"
" in master state.");
- parseResult &= configMapInt(dict, target, "ptpengine:master_igmp_refresh_interval",INTTYPE_I8,&rtOpts->masterRefreshInterval,rtOpts->masterRefreshInterval,
+ parseResult &= configMapInt(opCode, opArg, dict, target, "ptpengine:master_igmp_refresh_interval",
+ PTPD_RESTART_PROTOCOL, INTTYPE_I8, &rtOpts->masterRefreshInterval, rtOpts->masterRefreshInterval,
"Periodic IGMP join interval (seconds) in master state when running\n"
" IPv4 multicast: when set below 10 or when ptpengine:igmp_refresh\n"
" is disabled, th...
[truncated message content] |