diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-10-14 12:17:47 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-10-14 13:20:34 +0200 |
commit | 54a19002df18d2f19fc455c9b1ef9f88b96b7bd1 (patch) | |
tree | 20bba67589f85a708f626273979dae26a8530774 /conf.c | |
parent | 1cbd2c8c6b3a564aba84abcd20f05c5c646d2fb4 (diff) | |
download | passt-54a19002df18d2f19fc455c9b1ef9f88b96b7bd1.tar passt-54a19002df18d2f19fc455c9b1ef9f88b96b7bd1.tar.gz passt-54a19002df18d2f19fc455c9b1ef9f88b96b7bd1.tar.bz2 passt-54a19002df18d2f19fc455c9b1ef9f88b96b7bd1.tar.lz passt-54a19002df18d2f19fc455c9b1ef9f88b96b7bd1.tar.xz passt-54a19002df18d2f19fc455c9b1ef9f88b96b7bd1.tar.zst passt-54a19002df18d2f19fc455c9b1ef9f88b96b7bd1.zip |
conf: Add -P, --pid, to specify a file where own PID is written to
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -565,6 +565,7 @@ static void usage(const char *name) else info(" /tmp/passt_ISO8601-TIMESTAMP_INSTANCE-NUMBER.pcap"); + info( " -P, --pid FILE Write own PID to the given file"); info( " -m, --mtu MTU Assign MTU via DHCP/NDP"); info( " a zero value disables assignment"); info( " default: 65520: maximum 802.3 MTU minus 802.3 header"); @@ -764,6 +765,7 @@ void conf(struct ctx *c, int argc, char **argv) {"socket", required_argument, NULL, 's' }, {"ns-ifname", required_argument, NULL, 'I' }, {"pcap", optional_argument, NULL, 'p' }, + {"pid", required_argument, NULL, 'P' }, {"mtu", required_argument, NULL, 'm' }, {"address", required_argument, NULL, 'a' }, {"netmask", required_argument, NULL, 'n' }, @@ -807,9 +809,9 @@ void conf(struct ctx *c, int argc, char **argv) const char *optstring; if (c->mode == MODE_PASST) - optstring = "dqfehs:p::m:a:n:M:g:i:D::S::46t:u:"; + optstring = "dqfehs:p::P:m:a:n:M:g:i:D::S::46t:u:"; else - optstring = "dqfehI:p::m:a:n:M:g:i:D::S::46t:u:T:U:"; + optstring = "dqfehI:p::P:m:a:n:M:g:i:D::S::46t:u:T:U:"; name = getopt_long(argc, argv, optstring, options, NULL); @@ -949,6 +951,19 @@ void conf(struct ctx *c, int argc, char **argv) usage(argv[0]); } break; + case 'P': + if (*c->pid_file) { + err("Multiple --pid options given"); + usage(argv[0]); + } + + ret = snprintf(c->pid_file, sizeof(c->pid_file), "%s", + optarg); + if (ret <= 0 || ret >= (int)sizeof(c->pid_file)) { + err("Invalid PID file: %s", optarg); + usage(argv[0]); + } + break; case 'm': if (c->mtu) { err("Multiple --mtu options given"); |