udhcpd: update --help to include -a MSEC

function                                             old     new   delta
packed_usage                                       33886   33891      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2021-09-02 13:59:39 +02:00
parent a51d953b95
commit d99dee944e

View File

@ -27,7 +27,7 @@
//kbuild:lib-$(CONFIG_FEATURE_UDHCP_RFC3397) += domain_codec.o //kbuild:lib-$(CONFIG_FEATURE_UDHCP_RFC3397) += domain_codec.o
//usage:#define udhcpd_trivial_usage //usage:#define udhcpd_trivial_usage
//usage: "[-fS] [-I ADDR]" IF_FEATURE_UDHCP_PORT(" [-P PORT]") " [CONFFILE]" //usage: "[-fS] [-I ADDR] [-a MSEC]" IF_FEATURE_UDHCP_PORT(" [-P PORT]") " [CONFFILE]"
//usage:#define udhcpd_full_usage "\n\n" //usage:#define udhcpd_full_usage "\n\n"
//usage: "DHCP server\n" //usage: "DHCP server\n"
//usage: "\n -f Run in foreground" //usage: "\n -f Run in foreground"
@ -877,6 +877,12 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
/* Setup the signal pipe on fds 3,4 - must be before openlog() */ /* Setup the signal pipe on fds 3,4 - must be before openlog() */
udhcp_sp_setup(); udhcp_sp_setup();
#define OPT_f (1 << 0)
#define OPT_S (1 << 1)
#define OPT_I (1 << 2)
#define OPT_v (1 << 3)
#define OPT_a (1 << 4)
#define OPT_P (1 << 5)
opt = getopt32(argv, "^" opt = getopt32(argv, "^"
"fSI:va:"IF_FEATURE_UDHCP_PORT("P:") "fSI:va:"IF_FEATURE_UDHCP_PORT("P:")
"\0" "\0"
@ -888,23 +894,23 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv)
IF_FEATURE_UDHCP_PORT(, &str_P) IF_FEATURE_UDHCP_PORT(, &str_P)
IF_UDHCP_VERBOSE(, &dhcp_verbose) IF_UDHCP_VERBOSE(, &dhcp_verbose)
); );
if (!(opt & 1)) { /* no -f */ if (!(opt & OPT_f)) { /* no -f */
bb_daemonize_or_rexec(0, argv); bb_daemonize_or_rexec(0, argv);
logmode = LOGMODE_NONE; logmode = LOGMODE_NONE;
} }
/* update argv after the possible vfork+exec in daemonize */ /* update argv after the possible vfork+exec in daemonize */
argv += optind; argv += optind;
if (opt & 2) { /* -S */ if (opt & OPT_S) {
openlog(applet_name, LOG_PID, LOG_DAEMON); openlog(applet_name, LOG_PID, LOG_DAEMON);
logmode |= LOGMODE_SYSLOG; logmode |= LOGMODE_SYSLOG;
} }
if (opt & 4) { /* -I */ if (opt & OPT_I) {
len_and_sockaddr *lsa = xhost_and_af2sockaddr(str_I, 0, AF_INET); len_and_sockaddr *lsa = xhost_and_af2sockaddr(str_I, 0, AF_INET);
server_data.server_nip = lsa->u.sin.sin_addr.s_addr; server_data.server_nip = lsa->u.sin.sin_addr.s_addr;
free(lsa); free(lsa);
} }
#if ENABLE_FEATURE_UDHCP_PORT #if ENABLE_FEATURE_UDHCP_PORT
if (opt & 32) { /* -P */ if (opt & OPT_P) {
SERVER_PORT = xatou16(str_P); SERVER_PORT = xatou16(str_P);
CLIENT_PORT = SERVER_PORT + 1; CLIENT_PORT = SERVER_PORT + 1;
} }