summaryrefslogtreecommitdiff
path: root/src/network/wait-online/wait-online.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/wait-online/wait-online.c')
-rw-r--r--src/network/wait-online/wait-online.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/network/wait-online/wait-online.c b/src/network/wait-online/wait-online.c
index ca0116e7f3..c65b885d2c 100644
--- a/src/network/wait-online/wait-online.c
+++ b/src/network/wait-online/wait-online.c
@@ -19,6 +19,7 @@ static usec_t arg_timeout = 120 * USEC_PER_SEC;
static Hashmap *arg_interfaces = NULL;
static char **arg_ignore = NULL;
static LinkOperationalStateRange arg_required_operstate = { _LINK_OPERSTATE_INVALID, _LINK_OPERSTATE_INVALID };
+static AddressFamily arg_required_family = ADDRESS_FAMILY_NO;
static bool arg_any = false;
STATIC_DESTRUCTOR_REGISTER(arg_interfaces, hashmap_free_free_freep);
@@ -42,6 +43,8 @@ static int help(void) {
" --ignore=INTERFACE Don't take these interfaces into account\n"
" -o --operational-state=MIN_OPERSTATE[:MAX_OPERSTATE]\n"
" Required operational state\n"
+ " -4 --ipv4 Requires at least one IPv4 address\n"
+ " -6 --ipv6 Requires at least one IPv6 address\n"
" --any Wait until at least one of the interfaces is online\n"
" --timeout=SECS Maximum time to wait for network connectivity\n"
"\nSee the %s for details.\n",
@@ -53,7 +56,7 @@ static int help(void) {
static int parse_interface_with_operstate_range(const char *str) {
_cleanup_free_ char *ifname = NULL;
- _cleanup_free_ LinkOperationalStateRange *range;
+ _cleanup_free_ LinkOperationalStateRange *range = NULL;
const char *p;
int r;
@@ -111,6 +114,8 @@ static int parse_argv(int argc, char *argv[]) {
{ "interface", required_argument, NULL, 'i' },
{ "ignore", required_argument, NULL, ARG_IGNORE },
{ "operational-state", required_argument, NULL, 'o' },
+ { "ipv4", no_argument, NULL, '4' },
+ { "ipv6", no_argument, NULL, '6' },
{ "any", no_argument, NULL, ARG_ANY },
{ "timeout", required_argument, NULL, ARG_TIMEOUT },
{}
@@ -121,7 +126,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "hi:qo:", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "hi:qo:46", options, NULL)) >= 0)
switch (c) {
@@ -159,6 +164,15 @@ static int parse_argv(int argc, char *argv[]) {
break;
}
+
+ case '4':
+ arg_required_family |= ADDRESS_FAMILY_IPV4;
+ break;
+
+ case '6':
+ arg_required_family |= ADDRESS_FAMILY_IPV6;
+ break;
+
case ARG_ANY:
arg_any = true;
break;
@@ -197,7 +211,7 @@ static int run(int argc, char *argv[]) {
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
- r = manager_new(&m, arg_interfaces, arg_ignore, arg_required_operstate, arg_any, arg_timeout);
+ r = manager_new(&m, arg_interfaces, arg_ignore, arg_required_operstate, arg_required_family, arg_any, arg_timeout);
if (r < 0)
return log_error_errno(r, "Could not create manager: %m");