1// Copyright (C) 2017 The Qt Company Ltd.
2// Copyright (C) 2017 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QNETWORKINTERFACE_UNIX_P_H
6#define QNETWORKINTERFACE_UNIX_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "qnetworkinterface_p.h"
20#include "private/qnet_unix_p.h"
21
22#ifndef QT_NO_NETWORKINTERFACE
23
24#define IP_MULTICAST // make AIX happy and define IFF_MULTICAST
25
26#include <sys/types.h>
27#include <sys/socket.h>
28#ifdef Q_OS_SOLARIS
29# include <sys/sockio.h>
30#endif
31#ifdef Q_OS_HAIKU
32# include <sys/sockio.h>
33# define IFF_RUNNING 0x0001
34#endif
35#if QT_CONFIG(linux_netlink)
36// Same as net/if.h but contains other things we need in
37// qnetworkinterface_linux.cpp.
38# include <linux/if.h>
39#else
40# include <net/if.h>
41#endif
42
43QT_BEGIN_NAMESPACE
44
45static QNetworkInterface::InterfaceFlags convertFlags(uint rawFlags)
46{
47 QNetworkInterface::InterfaceFlags flags;
48 flags |= (rawFlags & IFF_UP) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0);
49 flags |= (rawFlags & IFF_RUNNING) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0);
50 flags |= (rawFlags & IFF_BROADCAST) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0);
51 flags |= (rawFlags & IFF_LOOPBACK) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0);
52#ifdef IFF_POINTOPOINT //cygwin doesn't define IFF_POINTOPOINT
53 flags |= (rawFlags & IFF_POINTOPOINT) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0);
54#endif
55
56#ifdef IFF_MULTICAST
57 flags |= (rawFlags & IFF_MULTICAST) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0);
58#endif
59 return flags;
60}
61
62QT_END_NAMESPACE
63
64#endif // QT_NO_NETWORKINTERFACE
65
66#endif // QNETWORKINTERFACE_UNIX_P_H
67

source code of qtbase/src/network/kernel/qnetworkinterface_unix_p.h