diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2021-01-11 18:07:03 +0100 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2021-01-11 18:15:57 +0100 |
| commit | 2567f558da3eb9911678227d4aeb15162e707d89 (patch) | |
| tree | 13c80b0e091c8ba585b14b966cda998f95f1936d /src/initrd/nm-initrd-generator.h | |
| parent | 02d99ffd62ede29cffcb45fcbe33d044b7406d3a (diff) | |
| parent | f54032b30e1ddd84f10a339e0caf493772e049a7 (diff) | |
Merge branch 'debian/master' into ubuntu/master
Diffstat (limited to 'src/initrd/nm-initrd-generator.h')
| -rw-r--r-- | src/initrd/nm-initrd-generator.h | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/initrd/nm-initrd-generator.h b/src/initrd/nm-initrd-generator.h index 8e17f045..69c24b1b 100644 --- a/src/initrd/nm-initrd-generator.h +++ b/src/initrd/nm-initrd-generator.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: LGPL-2.1+ +/* SPDX-License-Identifier: LGPL-2.1+ */ /* * Copyright (C) 2014, 2018 Red Hat, Inc. */ @@ -11,25 +11,33 @@ #define NMI_WAIT_DEVICE_TIMEOUT_MS 60000 -static inline gboolean -guess_ip_address_family (const char *str) +static inline int +get_ip_address_family(const char *str, gboolean with_prefix) { - if (str == NULL) - return AF_UNSPEC; - else if (strchr (str, '.')) - return AF_INET; - else if (strchr (str, ':')) - return AF_INET6; - else - return AF_UNSPEC; + int addr_family; + + if (!str) + return AF_UNSPEC; + + if (with_prefix) { + if (nm_utils_parse_inaddr_prefix_bin(AF_UNSPEC, str, &addr_family, NULL, NULL)) + return addr_family; + } else { + if (nm_utils_parse_inaddr_bin(AF_UNSPEC, str, &addr_family, NULL)) + return addr_family; + } + + return AF_UNSPEC; } -GHashTable *nmi_ibft_read (const char *sysfs_dir); +GHashTable *nmi_ibft_read(const char *sysfs_dir); -gboolean nmi_ibft_update_connection_from_nic (NMConnection *connection, GHashTable *nic, GError **error); +gboolean +nmi_ibft_update_connection_from_nic(NMConnection *connection, GHashTable *nic, GError **error); -NMConnection *nmi_dt_reader_parse (const char *sysfs_dir); +NMConnection *nmi_dt_reader_parse(const char *sysfs_dir); -GHashTable *nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv, char **hostname); +GHashTable * +nmi_cmdline_reader_parse(const char *sysfs_dir, const char *const *argv, char **hostname); -#endif /* __NM_INITRD_GENERATOR_H__ */ +#endif /* __NM_INITRD_GENERATOR_H__ */ |