Skip to content

Commit

Permalink
Issue #95: Finalize changes to command line options
Browse files Browse the repository at this point in the history
o Change case for program identidy: -I NAME --> -i NAME
o Drop -N and keep long option --disable-vifs
o Drop -P and keep long option --pidfile=FILE

Update man page accordingly.  Also, fix triple dash to --syslog and
add missing line break in phyint description.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
  • Loading branch information
troglobit committed Jan 1, 2019
1 parent 8f4dcbc commit 627e11a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
19 changes: 11 additions & 8 deletions pimd.8
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
.Nd PIM-SM/SSM v2 dynamic multicast routing daemon
.Sh SYNOPSIS
.Nm pimd
.Op Fl hNnrsv
.Op Fl hnrsv
.Op Fl f Ar FILE
.Op Fl d Ar [SYS[,SYS,...]
.Op Fl I Ar NAME
.Op Fl P Ar FILE
.Op Fl -no-fallback
.Op Fl d Ar SYS[,SYS,...]
.Op Fl i Ar NAME
.Op Fl -pidfile Ar FILE
.Op Fl -disable-vifs
.Op Fl l Ar LEVEL
.Op Fl t Ar ID
.Sh DESCRIPTION
Expand Down Expand Up @@ -142,7 +144,7 @@ Run in the foreground, do not detach from calling terminal and do not
fork to background. Useful not only when debugging (above) but also
when running under a process monitor like daemontools, runit, finit, or
systemd.
.It Fl I, Fl -ident=NAME
.It Fl i, Fl -ident=NAME
Specify program identity (name) to be used for configuration file, PID
file and syslog messages. Useful with multiple instances of
.Nm ,
Expand All @@ -155,15 +157,15 @@ or
.Pa /run/pimd.pid
and
.Pa /etc/pimd.conf .
.It Fl N, -disable-vifs
.It Fl -disable-vifs
This prevents
.Nm
from running on all interfaces by default. When this command line
option is given, use
.Cm phyint IFNAME enable
to selectively activate PIM services on an interface. This command line
option is also available as a setting in the configuration file.
.It Fl P, -pidfile=FILE
.It Fl -pidfile=FILE
Set PID file name and location, defaults to
.Pa /run/pimd/pimd.pid ,
derived from
Expand Down Expand Up @@ -197,7 +199,7 @@ interfaces listed in
.Pa /etc/pimd.conf .
Useful at startup when not all interfaces may be up or have an IP
address assigned yet.
.It Fl s, --syslog
.It Fl s, -syslog
Use syslog, default unless running in foreground,
.Fl n .
.It Fl t, -table-id=ID
Expand Down Expand Up @@ -263,6 +265,7 @@ interface configuration setting below.
.Cm <address | ifname>
.Bl -item -offset indent
.Op Cm disable | enable
.br
.Op Cm igmpv2 | igmpv3
.br
.Op Cm dr-priority Ar <1-4294967294>
Expand Down
30 changes: 15 additions & 15 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,25 @@ static int usage(int code)
else
snprintf(pidfn, sizeof(pidfn), "%s", pid_file);

printf("Usage: %s [-DhlNnv] [-f FILE] [-d [SYS][,SYS...]] [-s LEVEL]\n\n", prognm);
printf("Usage: %s [-hNnsv] [-f FILE] [-i NAME] [-d [SYS][,SYS...]] [-l LEVEL]\n\n", prognm);
printf(" -f, --config=FILE Configuration file, default uses ident NAME: %s\n", config_file);
printf(" --no-fallback When started without a config file, skip RP/BSR fallbacks\n");
printf(" -n, --foreground Run in foreground, do not detach from calling terminal\n");
printf(" -d SYS[,SYS,SYS..] Enable debug for SYS, see below for valid systems\n");
printf(" -d, --debug=SYS Enable debug for subystem(s) SYS, separate more with comma\n");
printf(" -l, --loglevel=LVL Set log level: none, err, info, notice (default), debug\n");
printf(" -I, --ident=NAME Identity for config + PID file, and syslog, default: %s\n", ident);
printf(" -N, --disable-vifs Disable all virtual interfaces (phyint) by default\n");
printf(" -P, --pidfile=FILE File to store process ID for signaling %s\n"
printf(" -i, --ident=NAME Identity for config + PID file, and syslog, default: %s\n", ident);
printf(" --pidfile=FILE File to store process ID for signaling %s\n"
" Default uses ident NAME: %s\n", prognm, pidfn);
printf(" -r Retry (forever) if not all phyint interfaces are available\n"
" yet when starting up, e.g. wait for DHCP lease\n");
printf(" -r Retry (forever) if not all configured phyint interfaces are\n"
" available when starting up, e.g. wait for DHCP lease\n");
printf(" --disable-vifs Disable all virtual interfaces (phyint) by default\n");
printf(" -s, --syslog Use syslog, default unless running in foreground, -n\n");
printf(" -t, --table-id=ID Set multicast routing table ID. Allowed table ID#:\n"
" 0 .. 999999999. Default: 0 (use default table)\n");
printf(" -h, --help Show this help text\n");
printf(" -v, --version Show %s version\n", prognm);
printf("\n");

/* From pimd v2.3.0 we show *all* the debug levels again */
printf("Available subsystems for debug:\n");
for (i = 0, d = debugnames; i < ARRAY_LEN(debugnames); i++, d++) {
if (strlen(line) + strlen(d->name) + 3 >= sizeof(line)) {
Expand Down Expand Up @@ -310,13 +309,14 @@ int main(int argc, char *argv[])
struct sigaction sa;
struct option long_options[] = {
{ "config", 1, 0, 'f' },
{ "debug", 1, 0, 'd' },
{ "no-fallback", 0, 0, 500 },
{ "disable-vifs", 0, 0, 'N' },
{ "disable-vifs", 0, 0, 501 },
{ "foreground", 0, 0, 'n' },
{ "help", 0, 0, 'h' },
{ "ident", 1, 0, 'I' },
{ "ident", 1, 0, 'i' },
{ "loglevel", 1, 0, 'l' },
{ "pidfile", 1, 0, 'P' },
{ "pidfile", 1, 0, 502 },
{ "syslog", 0, 0, 's' },
{ "table-id", 1, 0, 't' },
{ "version", 0, 0, 'v' },
Expand All @@ -326,7 +326,7 @@ int main(int argc, char *argv[])
snprintf(versionstring, sizeof (versionstring), "pimd version %s", PACKAGE_VERSION);

prognm = ident = progname(argv[0]);
while ((ch = getopt_long(argc, argv, "d:f:hI:l:nNP:rst:v", long_options, NULL)) != EOF) {
while ((ch = getopt_long(argc, argv, "d:f:hi:l:nrst:v", long_options, NULL)) != EOF) {
const char *errstr;

switch (ch) {
Expand Down Expand Up @@ -369,7 +369,7 @@ int main(int argc, char *argv[])
case 'h':
return usage(0);

case 'I': /* --ident=NAME */
case 'i': /* --ident=NAME */
ident = optarg;
break;

Expand All @@ -384,11 +384,11 @@ int main(int argc, char *argv[])
foreground = 1;
break;

case 'N':
case 501: /* --disable-vifs */
do_vifs = 0;
break;

case 'P': /* --pidfile=NAME */
case 502: /* --pidfile=NAME */
pid_file = strdup(optarg);
break;

Expand Down

0 comments on commit 627e11a

Please sign in to comment.