summaryrefslogtreecommitdiff
path: root/src/nm-initrd-generator/nm-initrd-generator.h
blob: 4f33ac653b915ea280df682aa125f27d8d914dc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2014, 2018 Red Hat, Inc.
 */

#ifndef __NM_INITRD_GENERATOR_H__
#define __NM_INITRD_GENERATOR_H__

#include "nm-connection.h"
#include "nm-utils.h"

#define NMI_WAIT_DEVICE_TIMEOUT_MSEC 60000
#define NMI_IP_REQUIRED_TIMEOUT_MSEC 20000

static inline int
get_ip_address_family(const char *str, gboolean with_prefix)
{
    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);

gboolean
nmi_ibft_update_connection_from_nic(NMConnection *connection, GHashTable *nic, GError **error);

NMConnection *nmi_dt_reader_parse(const char *sysfs_dir);

GHashTable *nmi_cmdline_reader_parse(const char        *etc_connections_dir,
                                     const char        *sysfs_dir,
                                     const char *const *argv,
                                     char             **hostname,
                                     gint64            *carrier_timeout_sec);

#endif /* __NM_INITRD_GENERATOR_H__ */