2013-03-27 22:23:24 +01:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
/* nm-platform.c - Handle runtime kernel networking configuration
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2009 - 2010 Red Hat, Inc.
|
|
|
|
|
*/
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#ifndef __NETWORKMANAGER_PLATFORM_H__
|
|
|
|
|
#define __NETWORKMANAGER_PLATFORM_H__
|
2013-03-27 22:23:24 +01:00
|
|
|
|
|
|
|
|
#include <glib-object.h>
|
2014-02-12 05:16:54 -06:00
|
|
|
#include "nm-glib-compat.h"
|
2013-03-27 22:23:24 +01:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <linux/if.h>
|
2013-10-15 20:44:59 +02:00
|
|
|
#include <linux/if_addr.h>
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2014-07-05 16:23:30 -04:00
|
|
|
#include <nm-dbus-interface.h>
|
2014-07-17 17:06:44 -04:00
|
|
|
#include "nm-types.h"
|
2015-04-27 21:05:13 +02:00
|
|
|
#include "NetworkManagerUtils.h"
|
2014-02-04 14:27:03 +01:00
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
#define NM_TYPE_PLATFORM (nm_platform_get_type ())
|
|
|
|
|
#define NM_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform))
|
|
|
|
|
#define NM_PLATFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_PLATFORM, NMPlatformClass))
|
|
|
|
|
#define NM_IS_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_PLATFORM))
|
|
|
|
|
#define NM_IS_PLATFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_PLATFORM))
|
|
|
|
|
#define NM_PLATFORM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_PLATFORM, NMPlatformClass))
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
|
|
|
|
|
2015-05-12 07:34:56 +02:00
|
|
|
#define NM_PLATFORM_REGISTER_SINGLETON "register-singleton"
|
|
|
|
|
|
|
|
|
|
/******************************************************************/
|
|
|
|
|
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
typedef struct _NMPlatform NMPlatform;
|
|
|
|
|
|
2014-03-04 14:30:01 +01:00
|
|
|
/* workaround for older libnl version, that does not define these flags. */
|
|
|
|
|
#ifndef IFA_F_MANAGETEMPADDR
|
|
|
|
|
#define IFA_F_MANAGETEMPADDR 0x100
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef IFA_F_NOPREFIXROUTE
|
|
|
|
|
#define IFA_F_NOPREFIXROUTE 0x200
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-07-02 15:43:26 +02:00
|
|
|
typedef enum { /*< skip >*/
|
2015-06-15 15:50:59 +02:00
|
|
|
|
|
|
|
|
/* dummy value, to enforce that the enum type is signed and has a size
|
|
|
|
|
* to hold an integer. We want to encode errno from <errno.h> as negative
|
|
|
|
|
* values. */
|
|
|
|
|
_NM_PLATFORM_ERROR_MININT = G_MININT,
|
|
|
|
|
|
|
|
|
|
NM_PLATFORM_ERROR_SUCCESS = 0,
|
|
|
|
|
|
|
|
|
|
NM_PLATFORM_ERROR_BUG,
|
|
|
|
|
|
|
|
|
|
NM_PLATFORM_ERROR_UNSPECIFIED,
|
|
|
|
|
|
2013-04-29 13:57:58 +02:00
|
|
|
NM_PLATFORM_ERROR_NOT_FOUND,
|
|
|
|
|
NM_PLATFORM_ERROR_EXISTS,
|
2013-06-10 16:21:08 -03:00
|
|
|
NM_PLATFORM_ERROR_WRONG_TYPE,
|
2013-05-24 00:29:21 +02:00
|
|
|
NM_PLATFORM_ERROR_NOT_SLAVE,
|
2015-06-15 15:50:59 +02:00
|
|
|
NM_PLATFORM_ERROR_NO_FIRMWARE,
|
2013-04-29 13:57:58 +02:00
|
|
|
} NMPlatformError;
|
|
|
|
|
|
2015-07-02 16:57:28 +02:00
|
|
|
typedef enum {
|
2013-08-02 18:51:06 +02:00
|
|
|
NM_PLATFORM_REASON_NONE,
|
|
|
|
|
/* Event was requested by NetworkManager. */
|
|
|
|
|
NM_PLATFORM_REASON_INTERNAL,
|
|
|
|
|
/* Event came from the kernel. */
|
|
|
|
|
NM_PLATFORM_REASON_EXTERNAL,
|
|
|
|
|
/* Event is a result of cache checking and cleanups. */
|
2015-01-11 17:42:46 +01:00
|
|
|
NM_PLATFORM_REASON_CACHE_CHECK,
|
|
|
|
|
|
|
|
|
|
/* Internal reason to suppress announcing change events */
|
|
|
|
|
_NM_PLATFORM_REASON_CACHE_CHECK_INTERNAL,
|
2013-08-02 18:51:06 +02:00
|
|
|
} NMPlatformReason;
|
|
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
#define __NMPlatformObject_COMMON \
|
|
|
|
|
int ifindex; \
|
|
|
|
|
;
|
|
|
|
|
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformLink {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformObject_COMMON;
|
2013-03-27 22:23:24 +01:00
|
|
|
char name[IFNAMSIZ];
|
|
|
|
|
NMLinkType type;
|
2015-04-28 10:11:04 +02:00
|
|
|
|
2015-04-29 09:19:15 +02:00
|
|
|
/* rtnl_link_get_type(), IFLA_INFO_KIND. */
|
|
|
|
|
/* NMPlatform initializes this field with a static string. */
|
2015-04-28 10:11:04 +02:00
|
|
|
const char *kind;
|
|
|
|
|
|
2015-04-29 09:19:15 +02:00
|
|
|
/* NMPlatform initializes this field with a static string. */
|
2013-05-29 12:00:50 -03:00
|
|
|
const char *driver;
|
2015-04-29 09:19:15 +02:00
|
|
|
|
2015-04-13 16:29:37 -05:00
|
|
|
gboolean initialized;
|
2013-03-27 22:53:55 +01:00
|
|
|
int master;
|
2013-06-03 11:49:55 -03:00
|
|
|
int parent;
|
2015-04-25 16:42:26 +02:00
|
|
|
|
2015-04-27 18:45:23 +02:00
|
|
|
/* rtnl_link_get_arptype(), ifinfomsg.ifi_type. */
|
|
|
|
|
guint32 arptype;
|
|
|
|
|
|
2015-04-27 18:06:59 +02:00
|
|
|
/* rtnl_link_get_addr() */
|
|
|
|
|
struct {
|
|
|
|
|
guint8 data[20]; /* NM_UTILS_HWADDR_LEN_MAX */
|
|
|
|
|
guint8 len;
|
|
|
|
|
} addr;
|
|
|
|
|
|
2015-04-27 21:05:13 +02:00
|
|
|
/* rtnl_link_inet6_get_token() */
|
|
|
|
|
struct {
|
|
|
|
|
NMUtilsIPv6IfaceId iid;
|
|
|
|
|
guint8 is_valid;
|
|
|
|
|
} inet6_token;
|
|
|
|
|
|
2015-04-27 18:32:43 +02:00
|
|
|
/* The bitwise inverse of rtnl_link_inet6_get_addr_gen_mode(). It is inverse
|
|
|
|
|
* to have a default of 0 -- meaning: unspecified. That way, a struct
|
|
|
|
|
* initialized with memset(0) has and unset value.*/
|
|
|
|
|
guint8 inet6_addr_gen_mode_inv;
|
|
|
|
|
|
2015-04-25 16:42:26 +02:00
|
|
|
/* rtnl_link_vlan_get_id(), IFLA_VLAN_ID */
|
|
|
|
|
guint16 vlan_id;
|
|
|
|
|
|
2015-04-25 16:42:26 +02:00
|
|
|
/* IFF_* flags as u32. Note that ifi_flags in 'struct ifinfomsg' is declared as 'unsigned',
|
|
|
|
|
* but libnl stores the flag internally as u32. */
|
|
|
|
|
guint32 flags;
|
|
|
|
|
|
|
|
|
|
/* @connected is mostly identical to (@flags & IFF_UP). Except for bridge/bond masters,
|
|
|
|
|
* where we coerce the link as disconnect if it has no slaves. */
|
2013-03-27 22:23:24 +01:00
|
|
|
gboolean connected;
|
2015-04-25 16:42:26 +02:00
|
|
|
|
2013-04-15 21:48:12 +02:00
|
|
|
guint mtu;
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-07-02 16:57:28 +02:00
|
|
|
typedef enum {
|
2015-04-13 18:55:59 +02:00
|
|
|
NM_PLATFORM_SIGNAL_NONE,
|
2014-03-07 19:04:38 +01:00
|
|
|
NM_PLATFORM_SIGNAL_ADDED,
|
|
|
|
|
NM_PLATFORM_SIGNAL_CHANGED,
|
|
|
|
|
NM_PLATFORM_SIGNAL_REMOVED,
|
|
|
|
|
} NMPlatformSignalChangeType;
|
|
|
|
|
|
2013-06-29 11:30:11 +02:00
|
|
|
#define NM_PLATFORM_LIFETIME_PERMANENT G_MAXUINT32
|
|
|
|
|
|
2015-07-02 15:43:26 +02:00
|
|
|
typedef enum { /*< skip >*/
|
2015-06-22 17:28:37 +02:00
|
|
|
NM_PLATFORM_GET_ROUTE_FLAGS_NONE = 0,
|
|
|
|
|
|
|
|
|
|
/* Whether to include default-routes/non-default-routes. Omitting
|
|
|
|
|
* both WITH_DEFAULT and WITH_NON_DEFAULT, is equal to specifying
|
|
|
|
|
* both of them. */
|
|
|
|
|
NM_PLATFORM_GET_ROUTE_FLAGS_WITH_DEFAULT = (1LL << 0),
|
|
|
|
|
NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT = (1LL << 1),
|
2015-06-22 17:08:58 +02:00
|
|
|
|
|
|
|
|
NM_PLATFORM_GET_ROUTE_FLAGS_WITH_RTPROT_KERNEL = (1LL << 2),
|
2015-06-22 17:28:37 +02:00
|
|
|
} NMPlatformGetRouteFlags;
|
2014-10-14 19:02:50 +02:00
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
typedef struct {
|
|
|
|
|
__NMPlatformObject_COMMON;
|
|
|
|
|
} NMPlatformObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define __NMPlatformIPAddress_COMMON \
|
|
|
|
|
__NMPlatformObject_COMMON; \
|
2014-10-13 11:52:29 +02:00
|
|
|
NMIPConfigSource source; \
|
platform: fix preferred and valid lifetimes for addresses from netlink/kernel
The kernel tells the address lifetimes in the 'struct ifa_cacheinfo'
attribute. This contains two timestamps (cstamp and tstamp) and two
relative lifetimes (ifa_prefered and ifa_valid).
The timestamps are equal to clock_gettime(CLOCK_MONOTONIC) scale in
1/100th of a second (wrapping every 497 days).
The preferred/valid times are re-adjusted everytime when sending the
message and count down as the time goes by. In other words, they are
anchored relatively to the moment of when kernel creates the netlink
message.
As platform is caching the rtnl_addr object, the information of *when* the
lifetimes started counting is not available.
This patch fixes reading these values by hacking the libnl object
when it gets received, so that valid and preferred are instead absolute
expiration timestamps in scale nm_utils_get_monotonic_timestamp_s() --
which NM internally is used for address timestamps.
There are two minor downsides to this hack:
- the valid and preferred properties of a cached rtnl_addr object have
an unexpected meaning, i.e. they are absolute and in a different time
scale.
- later when converting rtnl_addr to NMPlatformIPAddress, the base
timestamp is set to "1", i.e. an NMPlatformIPAddress has no knowledge
of when the address was created or last modified. The timestamp
property of NMPlatformIPAddress is solely there to anchor the relative
timestamps lifetime and preferred. Do not use it for anything
else.
Another reason the timestamp property is meaningless is that
its scale nm_utils_get_monotonic_timestamp_s() starts counting at
process start. So addresses that existed before would have a negative
or zero timestamp, which we avoid. This in turn could be solved by either
allowing negative timestamps or by shifting
nm_utils_get_monotonic_timestamp_*(). Both is viable, but not
necessary (ATM), because the age of an address has no other apparent
use then to anchor the relative timestamps.
Another implication is, that we potentially could get rid of the
timestamp completely, and insteat make preferred and lifetime be
absolute expiries.
This will be fixed properly later, by not caching libnl objects but instead
native NMPlatform objects. For those we have full control over their properties.
https://bugzilla.gnome.org/show_bug.cgi?id=727382
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-02 13:35:21 +02:00
|
|
|
\
|
|
|
|
|
/* Timestamp in seconds in the reference system of nm_utils_get_monotonic_timestamp_*().
|
2014-06-09 10:03:01 +02:00
|
|
|
*
|
|
|
|
|
* The rules are:
|
|
|
|
|
* 1 @lifetime==0: @timestamp and @preferred is irrelevant (but mostly set to 0 too). Such addresses
|
|
|
|
|
* are permanent. This rule is so that unset addresses (calloc) are permanent by default.
|
|
|
|
|
* 2 @lifetime==@preferred==NM_PLATFORM_LIFETIME_PERMANENT: @timestamp is irrelevant (but mostly
|
|
|
|
|
* set to 0). Such addresses are permanent.
|
|
|
|
|
* 3 Non permanent addreses should (almost) always have @timestamp > 0. 0 is not a valid timestamp
|
|
|
|
|
* and never returned by nm_utils_get_monotonic_timestamp_s(). In this case @valid/@preferred
|
|
|
|
|
* is anchored at @timestamp.
|
|
|
|
|
* 4 Non permanent addresses with @timestamp == 0 are implicitely anchored at *now*, thus the time
|
|
|
|
|
* moves as time goes by. This is usually not useful, except e.g. nm_platform_ip[46]_address_add().
|
|
|
|
|
*
|
|
|
|
|
* Non permanent addresses from DHCP/RA might have the @timestamp set to the moment of when the
|
|
|
|
|
* lease was received. Addresses from kernel might have the @timestamp based on the last modification
|
|
|
|
|
* time of the addresses. But don't rely on this behaviour, the @timestamp is only defined for anchoring
|
|
|
|
|
* @lifetime and @preferred.
|
platform: fix preferred and valid lifetimes for addresses from netlink/kernel
The kernel tells the address lifetimes in the 'struct ifa_cacheinfo'
attribute. This contains two timestamps (cstamp and tstamp) and two
relative lifetimes (ifa_prefered and ifa_valid).
The timestamps are equal to clock_gettime(CLOCK_MONOTONIC) scale in
1/100th of a second (wrapping every 497 days).
The preferred/valid times are re-adjusted everytime when sending the
message and count down as the time goes by. In other words, they are
anchored relatively to the moment of when kernel creates the netlink
message.
As platform is caching the rtnl_addr object, the information of *when* the
lifetimes started counting is not available.
This patch fixes reading these values by hacking the libnl object
when it gets received, so that valid and preferred are instead absolute
expiration timestamps in scale nm_utils_get_monotonic_timestamp_s() --
which NM internally is used for address timestamps.
There are two minor downsides to this hack:
- the valid and preferred properties of a cached rtnl_addr object have
an unexpected meaning, i.e. they are absolute and in a different time
scale.
- later when converting rtnl_addr to NMPlatformIPAddress, the base
timestamp is set to "1", i.e. an NMPlatformIPAddress has no knowledge
of when the address was created or last modified. The timestamp
property of NMPlatformIPAddress is solely there to anchor the relative
timestamps lifetime and preferred. Do not use it for anything
else.
Another reason the timestamp property is meaningless is that
its scale nm_utils_get_monotonic_timestamp_s() starts counting at
process start. So addresses that existed before would have a negative
or zero timestamp, which we avoid. This in turn could be solved by either
allowing negative timestamps or by shifting
nm_utils_get_monotonic_timestamp_*(). Both is viable, but not
necessary (ATM), because the age of an address has no other apparent
use then to anchor the relative timestamps.
Another implication is, that we potentially could get rid of the
timestamp completely, and insteat make preferred and lifetime be
absolute expiries.
This will be fixed properly later, by not caching libnl objects but instead
native NMPlatform objects. For those we have full control over their properties.
https://bugzilla.gnome.org/show_bug.cgi?id=727382
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-02 13:35:21 +02:00
|
|
|
*/ \
|
|
|
|
|
guint32 timestamp; \
|
|
|
|
|
guint32 lifetime; /* seconds since timestamp */ \
|
|
|
|
|
guint32 preferred; /* seconds since timestamp */ \
|
2014-04-03 11:02:48 +02:00
|
|
|
int plen; \
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMPlatformIPAddress:
|
|
|
|
|
*
|
|
|
|
|
* Common parts of NMPlatformIP4Address and NMPlatformIP6Address.
|
|
|
|
|
**/
|
|
|
|
|
typedef struct {
|
|
|
|
|
__NMPlatformIPAddress_COMMON;
|
|
|
|
|
union {
|
|
|
|
|
guint8 address_ptr[1];
|
|
|
|
|
guint32 __dummy_for_32bit_alignment;
|
|
|
|
|
};
|
|
|
|
|
} NMPlatformIPAddress;
|
|
|
|
|
|
2013-12-10 19:04:22 +01:00
|
|
|
/**
|
|
|
|
|
* NMPlatformIP4Address:
|
|
|
|
|
* @timestamp: timestamp as returned by nm_utils_get_monotonic_timestamp_s()
|
|
|
|
|
**/
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformIP4Address {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformIPAddress_COMMON;
|
2013-03-27 22:23:24 +01:00
|
|
|
in_addr_t address;
|
2013-12-02 10:20:26 -05:00
|
|
|
in_addr_t peer_address; /* PTP peer address */
|
2014-02-19 16:10:59 -05:00
|
|
|
char label[IFNAMSIZ];
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2014-04-03 11:02:48 +02:00
|
|
|
G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPAddress, address_ptr) == G_STRUCT_OFFSET (NMPlatformIP4Address, address));
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2013-12-10 19:04:22 +01:00
|
|
|
/**
|
|
|
|
|
* NMPlatformIP6Address:
|
|
|
|
|
* @timestamp: timestamp as returned by nm_utils_get_monotonic_timestamp_s()
|
|
|
|
|
**/
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformIP6Address {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformIPAddress_COMMON;
|
2013-03-27 22:23:24 +01:00
|
|
|
struct in6_addr address;
|
2013-12-02 10:20:26 -05:00
|
|
|
struct in6_addr peer_address;
|
2013-10-15 20:44:59 +02:00
|
|
|
guint flags; /* ifa_flags from <linux/if_addr.h>, field type "unsigned int" is as used in rtnl_addr_get_flags. */
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2014-04-03 11:02:48 +02:00
|
|
|
G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPAddress, address_ptr) == G_STRUCT_OFFSET (NMPlatformIP6Address, address));
|
|
|
|
|
|
2014-11-10 14:23:44 +01:00
|
|
|
typedef union {
|
|
|
|
|
NMPlatformIPAddress ax;
|
|
|
|
|
NMPlatformIP4Address a4;
|
|
|
|
|
NMPlatformIP6Address a6;
|
|
|
|
|
} NMPlatformIPXAddress;
|
|
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
#undef __NMPlatformIPAddress_COMMON
|
|
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2014-11-26 20:47:44 +01:00
|
|
|
/* Default value for adding an IPv4 route. This is also what iproute2 does.
|
|
|
|
|
* Note that contrary to IPv6, you can add routes with metric 0 and it is even
|
|
|
|
|
* the default.
|
|
|
|
|
*/
|
|
|
|
|
#define NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP4 0
|
|
|
|
|
|
|
|
|
|
/* Default value for adding an IPv6 route. This is also what iproute2 does.
|
|
|
|
|
* Adding an IPv6 route with metric 0, kernel translates to IP6_RT_PRIO_USER (1024). */
|
|
|
|
|
#define NM_PLATFORM_ROUTE_METRIC_DEFAULT_IP6 1024
|
2014-01-06 15:15:55 -06:00
|
|
|
|
2014-11-11 14:55:07 +01:00
|
|
|
/* For IPv4, kernel adds a device route (subnet routes) with metric 0 when user
|
|
|
|
|
* configures addresses. */
|
|
|
|
|
#define NM_PLATFORM_ROUTE_METRIC_IP4_DEVICE_ROUTE 0
|
|
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
#define __NMPlatformIPRoute_COMMON \
|
|
|
|
|
__NMPlatformObject_COMMON; \
|
2014-10-13 11:52:29 +02:00
|
|
|
NMIPConfigSource source; \
|
2014-04-03 11:02:48 +02:00
|
|
|
int plen; \
|
2014-08-28 17:25:36 +02:00
|
|
|
guint32 metric; \
|
|
|
|
|
guint32 mss; \
|
2014-04-03 11:02:48 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
__NMPlatformIPRoute_COMMON;
|
|
|
|
|
union {
|
|
|
|
|
guint8 network_ptr[1];
|
|
|
|
|
guint32 __dummy_for_32bit_alignment;
|
|
|
|
|
};
|
|
|
|
|
} NMPlatformIPRoute;
|
|
|
|
|
|
2014-07-29 19:10:08 +02:00
|
|
|
#define NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route) \
|
|
|
|
|
( ((const NMPlatformIPRoute *) (route))->plen <= 0 )
|
|
|
|
|
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformIP4Route {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformIPRoute_COMMON;
|
2013-03-27 22:23:24 +01:00
|
|
|
in_addr_t network;
|
|
|
|
|
in_addr_t gateway;
|
2015-05-03 10:47:41 +02:00
|
|
|
|
|
|
|
|
/* The bitwise inverse of the route scope. It is inverted so that the
|
|
|
|
|
* default value (RT_SCOPE_NOWHERE) is nul. */
|
|
|
|
|
guint8 scope_inv;
|
2015-06-22 13:22:48 +02:00
|
|
|
|
|
|
|
|
/* RTA_PREFSRC/rtnl_route_get_pref_src(). A value of zero means that
|
|
|
|
|
* no pref-src is set. */
|
|
|
|
|
guint32 pref_src;
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2014-04-03 11:02:48 +02:00
|
|
|
G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPRoute, network_ptr) == G_STRUCT_OFFSET (NMPlatformIP4Route, network));
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2014-07-17 17:06:44 -04:00
|
|
|
struct _NMPlatformIP6Route {
|
2014-04-03 11:02:48 +02:00
|
|
|
__NMPlatformIPRoute_COMMON;
|
2013-03-27 22:23:24 +01:00
|
|
|
struct in6_addr network;
|
|
|
|
|
struct in6_addr gateway;
|
2014-07-17 17:06:44 -04:00
|
|
|
};
|
2014-04-03 11:02:48 +02:00
|
|
|
G_STATIC_ASSERT (G_STRUCT_OFFSET (NMPlatformIPRoute, network_ptr) == G_STRUCT_OFFSET (NMPlatformIP6Route, network));
|
|
|
|
|
|
2014-11-10 14:23:44 +01:00
|
|
|
typedef union {
|
|
|
|
|
NMPlatformIPRoute rx;
|
|
|
|
|
NMPlatformIP4Route r4;
|
|
|
|
|
NMPlatformIP6Route r6;
|
|
|
|
|
} NMPlatformIPXRoute;
|
|
|
|
|
|
2014-04-03 11:02:48 +02:00
|
|
|
#undef __NMPlatformIPRoute_COMMON
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef __NMPlatformObject_COMMON
|
|
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-03-25 11:28:19 +01:00
|
|
|
typedef struct {
|
|
|
|
|
gboolean is_ip4;
|
|
|
|
|
int addr_family;
|
|
|
|
|
gsize sizeof_route;
|
|
|
|
|
int (*route_cmp) (const NMPlatformIPXRoute *a, const NMPlatformIPXRoute *b);
|
|
|
|
|
const char *(*route_to_string) (const NMPlatformIPXRoute *route);
|
2015-06-22 17:28:37 +02:00
|
|
|
GArray *(*route_get_all) (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags);
|
2015-07-05 13:25:49 +02:00
|
|
|
gboolean (*route_add) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route, gint64 metric);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean (*route_delete) (NMPlatform *self, int ifindex, const NMPlatformIPXRoute *route);
|
|
|
|
|
gboolean (*route_delete_default) (NMPlatform *self, int ifindex, guint32 metric);
|
2015-03-25 11:28:19 +01:00
|
|
|
guint32 (*metric_normalize) (guint32 metric);
|
|
|
|
|
} NMPlatformVTableRoute;
|
|
|
|
|
|
|
|
|
|
extern const NMPlatformVTableRoute nm_platform_vtable_route_v4;
|
|
|
|
|
extern const NMPlatformVTableRoute nm_platform_vtable_route_v6;
|
|
|
|
|
|
2015-04-27 15:41:33 +02:00
|
|
|
extern char _nm_platform_to_string_buffer[256];
|
2015-03-25 11:28:19 +01:00
|
|
|
|
2013-05-03 13:55:51 -04:00
|
|
|
typedef struct {
|
|
|
|
|
int peer;
|
|
|
|
|
} NMPlatformVethProperties;
|
|
|
|
|
|
2013-04-25 15:46:39 -04:00
|
|
|
typedef struct {
|
|
|
|
|
gint64 owner;
|
|
|
|
|
gint64 group;
|
|
|
|
|
const char *mode;
|
|
|
|
|
gboolean no_pi;
|
|
|
|
|
gboolean vnet_hdr;
|
|
|
|
|
gboolean multi_queue;
|
|
|
|
|
} NMPlatformTunProperties;
|
|
|
|
|
|
2013-05-06 09:16:17 -04:00
|
|
|
typedef struct {
|
|
|
|
|
int parent_ifindex;
|
|
|
|
|
const char *mode;
|
|
|
|
|
gboolean no_promisc;
|
|
|
|
|
} NMPlatformMacvlanProperties;
|
|
|
|
|
|
2013-06-04 10:31:22 -03:00
|
|
|
typedef struct {
|
|
|
|
|
int parent_ifindex;
|
|
|
|
|
guint32 id;
|
|
|
|
|
in_addr_t group;
|
|
|
|
|
in_addr_t local;
|
|
|
|
|
struct in6_addr group6;
|
|
|
|
|
struct in6_addr local6;
|
|
|
|
|
guint8 tos;
|
|
|
|
|
guint8 ttl;
|
|
|
|
|
gboolean learning;
|
|
|
|
|
guint32 ageing;
|
|
|
|
|
guint32 limit;
|
|
|
|
|
guint16 dst_port;
|
|
|
|
|
guint16 src_port_min;
|
|
|
|
|
guint16 src_port_max;
|
|
|
|
|
gboolean proxy;
|
|
|
|
|
gboolean rsc;
|
|
|
|
|
gboolean l2miss;
|
|
|
|
|
gboolean l3miss;
|
|
|
|
|
} NMPlatformVxlanProperties;
|
|
|
|
|
|
2013-05-21 12:49:24 -03:00
|
|
|
typedef struct {
|
|
|
|
|
int parent_ifindex;
|
|
|
|
|
guint16 input_flags;
|
|
|
|
|
guint16 output_flags;
|
|
|
|
|
guint32 input_key;
|
|
|
|
|
guint32 output_key;
|
|
|
|
|
in_addr_t local;
|
|
|
|
|
in_addr_t remote;
|
|
|
|
|
guint8 ttl;
|
|
|
|
|
guint8 tos;
|
|
|
|
|
gboolean path_mtu_discovery;
|
|
|
|
|
} NMPlatformGreProperties;
|
|
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
/******************************************************************/
|
|
|
|
|
|
|
|
|
|
/* NMPlatform abstract class and its implementations provide a layer between
|
|
|
|
|
* networkmanager's device management classes and the operating system kernel.
|
|
|
|
|
*
|
|
|
|
|
* How it works, is best seen in tests/nm-platform-test.c source file.
|
|
|
|
|
*
|
|
|
|
|
* NMPlatform provides interface to configure kernel interfaces and receive
|
|
|
|
|
* notifications about both internal and external configuration changes. It
|
|
|
|
|
* respects the following rules:
|
|
|
|
|
*
|
|
|
|
|
* 1) Every change made through NMPlatform is readily available and the respective
|
|
|
|
|
* signals are called synchronously.
|
|
|
|
|
*
|
|
|
|
|
* 2) State of an object retrieved from NMPlatform (through functions or events)
|
|
|
|
|
* is at least as recent than the state retrieved before.
|
|
|
|
|
*
|
|
|
|
|
* Any failure of the above rules should be fixed in NMPlatform implementations
|
|
|
|
|
* and tested in nm-platform-test. Synchronization hacks should never be put
|
|
|
|
|
* to any other code. That's why NMPlatform was created and that's why the
|
|
|
|
|
* testing code was written for it.
|
|
|
|
|
*
|
|
|
|
|
* In future, parts of linux platform implementation may be moved to the libnl
|
|
|
|
|
* library.
|
|
|
|
|
*
|
|
|
|
|
* If you have any problems related to NMPlatform on your system, you should
|
|
|
|
|
* always first run tests/nm-linux-platform-test as root and with all
|
|
|
|
|
* network configuration daemons stopped. Look at the code first.
|
|
|
|
|
*/
|
|
|
|
|
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
struct _NMPlatform {
|
2013-03-27 22:23:24 +01:00
|
|
|
GObject parent;
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
};
|
2013-03-27 22:23:24 +01:00
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
GObjectClass parent;
|
|
|
|
|
|
2013-04-03 16:10:38 +02:00
|
|
|
gboolean (*sysctl_set) (NMPlatform *, const char *path, const char *value);
|
2014-02-25 13:23:07 -05:00
|
|
|
char * (*sysctl_get) (NMPlatform *, const char *path);
|
2013-04-03 16:10:38 +02:00
|
|
|
|
2015-06-20 12:05:01 +02:00
|
|
|
const NMPlatformLink *(*link_get) (NMPlatform *platform, int ifindex);
|
|
|
|
|
const NMPlatformLink *(*link_get_by_ifname) (NMPlatform *platform, const char *ifname);
|
|
|
|
|
const NMPlatformLink *(*link_get_by_address) (NMPlatform *platform, gconstpointer address, size_t length);
|
|
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
GArray *(*link_get_all) (NMPlatform *);
|
2014-09-18 12:53:19 -05:00
|
|
|
gboolean (*link_add) (NMPlatform *,
|
|
|
|
|
const char *name,
|
|
|
|
|
NMLinkType type,
|
|
|
|
|
const void *address,
|
|
|
|
|
size_t address_len,
|
|
|
|
|
NMPlatformLink *out_link);
|
2013-03-27 22:23:24 +01:00
|
|
|
gboolean (*link_delete) (NMPlatform *, int ifindex);
|
2013-04-26 11:43:08 -04:00
|
|
|
const char *(*link_get_type_name) (NMPlatform *, int ifindex);
|
2015-06-24 14:21:27 +02:00
|
|
|
gboolean (*link_get_unmanaged) (NMPlatform *, int ifindex, gboolean *unmanaged);
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2014-02-11 13:58:00 +01:00
|
|
|
gboolean (*link_refresh) (NMPlatform *, int ifindex);
|
2015-06-19 15:38:41 +02:00
|
|
|
void (*process_events) (NMPlatform *self);
|
2014-02-11 13:58:00 +01:00
|
|
|
|
2015-06-15 17:41:27 +02:00
|
|
|
gboolean (*link_set_up) (NMPlatform *, int ifindex, gboolean *out_no_firmware);
|
2013-03-27 22:23:24 +01:00
|
|
|
gboolean (*link_set_down) (NMPlatform *, int ifindex);
|
|
|
|
|
gboolean (*link_set_arp) (NMPlatform *, int ifindex);
|
|
|
|
|
gboolean (*link_set_noarp) (NMPlatform *, int ifindex);
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-06-15 14:41:35 +02:00
|
|
|
const char *(*link_get_udi) (NMPlatform *self, int ifindex);
|
2015-06-15 15:19:28 +02:00
|
|
|
GObject *(*link_get_udev_device) (NMPlatform *self, int ifindex);
|
2014-09-27 09:03:56 +02:00
|
|
|
|
2014-07-24 15:57:08 -05:00
|
|
|
gboolean (*link_set_user_ipv6ll_enabled) (NMPlatform *, int ifindex, gboolean enabled);
|
|
|
|
|
|
2014-10-03 17:37:26 -05:00
|
|
|
gboolean (*link_get_permanent_address) (NMPlatform *,
|
|
|
|
|
int ifindex,
|
|
|
|
|
guint8 *buf,
|
|
|
|
|
size_t *length);
|
2013-03-27 22:53:55 +01:00
|
|
|
gboolean (*link_set_address) (NMPlatform *, int ifindex, gconstpointer address, size_t length);
|
2013-04-15 21:48:12 +02:00
|
|
|
gboolean (*link_set_mtu) (NMPlatform *, int ifindex, guint32 mtu);
|
2013-03-27 22:53:55 +01:00
|
|
|
|
2015-03-24 12:35:36 -05:00
|
|
|
char * (*link_get_physical_port_id) (NMPlatform *, int ifindex);
|
|
|
|
|
guint (*link_get_dev_id) (NMPlatform *, int ifindex);
|
2014-02-05 11:56:44 +01:00
|
|
|
gboolean (*link_get_wake_on_lan) (NMPlatform *, int ifindex);
|
2014-10-03 13:41:49 -05:00
|
|
|
gboolean (*link_get_driver_info) (NMPlatform *,
|
|
|
|
|
int ifindex,
|
|
|
|
|
char **out_driver_name,
|
|
|
|
|
char **out_driver_version,
|
|
|
|
|
char **out_fw_version);
|
2013-10-11 14:59:26 -04:00
|
|
|
|
2013-03-27 22:53:55 +01:00
|
|
|
gboolean (*link_supports_carrier_detect) (NMPlatform *, int ifindex);
|
|
|
|
|
gboolean (*link_supports_vlans) (NMPlatform *, int ifindex);
|
|
|
|
|
|
2013-03-27 22:53:55 +01:00
|
|
|
gboolean (*link_enslave) (NMPlatform *, int master, int slave);
|
|
|
|
|
gboolean (*link_release) (NMPlatform *, int master, int slave);
|
2013-04-04 17:07:47 +02:00
|
|
|
gboolean (*master_set_option) (NMPlatform *, int ifindex, const char *option, const char *value);
|
|
|
|
|
char * (*master_get_option) (NMPlatform *, int ifindex, const char *option);
|
|
|
|
|
gboolean (*slave_set_option) (NMPlatform *, int ifindex, const char *option, const char *value);
|
|
|
|
|
char * (*slave_get_option) (NMPlatform *, int ifindex, const char *option);
|
2013-03-27 22:53:55 +01:00
|
|
|
|
2014-09-18 12:53:19 -05:00
|
|
|
gboolean (*vlan_add) (NMPlatform *, const char *name, int parent, int vlanid, guint32 vlanflags, NMPlatformLink *out_link);
|
2013-03-27 22:53:55 +01:00
|
|
|
gboolean (*vlan_get_info) (NMPlatform *, int ifindex, int *parent, int *vlan_id);
|
|
|
|
|
gboolean (*vlan_set_ingress_map) (NMPlatform *, int ifindex, int from, int to);
|
|
|
|
|
gboolean (*vlan_set_egress_map) (NMPlatform *, int ifindex, int from, int to);
|
|
|
|
|
|
2014-09-18 12:53:19 -05:00
|
|
|
gboolean (*infiniband_partition_add) (NMPlatform *, int parent, int p_key, NMPlatformLink *out_link);
|
2014-10-06 09:37:34 -05:00
|
|
|
gboolean (*infiniband_get_info) (NMPlatform *,
|
|
|
|
|
int ifindex,
|
|
|
|
|
int *parent,
|
|
|
|
|
int *p_key,
|
|
|
|
|
const char **mode);
|
2013-06-10 16:21:08 -03:00
|
|
|
|
2013-05-03 13:55:51 -04:00
|
|
|
gboolean (*veth_get_properties) (NMPlatform *, int ifindex, NMPlatformVethProperties *properties);
|
2013-04-25 15:46:39 -04:00
|
|
|
gboolean (*tun_get_properties) (NMPlatform *, int ifindex, NMPlatformTunProperties *properties);
|
2013-05-06 09:16:17 -04:00
|
|
|
gboolean (*macvlan_get_properties) (NMPlatform *, int ifindex, NMPlatformMacvlanProperties *props);
|
2013-06-04 10:31:22 -03:00
|
|
|
gboolean (*vxlan_get_properties) (NMPlatform *, int ifindex, NMPlatformVxlanProperties *props);
|
2013-05-21 12:49:24 -03:00
|
|
|
gboolean (*gre_get_properties) (NMPlatform *, int ifindex, NMPlatformGreProperties *props);
|
2013-05-03 13:55:51 -04:00
|
|
|
|
2014-02-04 14:27:03 +01:00
|
|
|
gboolean (*wifi_get_capabilities) (NMPlatform *, int ifindex, NMDeviceWifiCapabilities *caps);
|
2014-07-07 12:04:14 -04:00
|
|
|
gboolean (*wifi_get_bssid) (NMPlatform *, int ifindex, guint8 *bssid);
|
2014-02-04 14:27:03 +01:00
|
|
|
GByteArray *(*wifi_get_ssid) (NMPlatform *, int ifindex);
|
|
|
|
|
guint32 (*wifi_get_frequency) (NMPlatform *, int ifindex);
|
|
|
|
|
int (*wifi_get_quality) (NMPlatform *, int ifindex);
|
|
|
|
|
guint32 (*wifi_get_rate) (NMPlatform *, int ifindex);
|
|
|
|
|
NM80211Mode (*wifi_get_mode) (NMPlatform *, int ifindex);
|
|
|
|
|
void (*wifi_set_mode) (NMPlatform *, int ifindex, NM80211Mode mode);
|
2014-10-23 14:19:59 -04:00
|
|
|
void (*wifi_set_powersave) (NMPlatform *, int ifindex, guint32 powersave);
|
2014-02-04 14:27:03 +01:00
|
|
|
guint32 (*wifi_find_frequency) (NMPlatform *, int ifindex, const guint32 *freqs);
|
|
|
|
|
void (*wifi_indicate_addressing_running) (NMPlatform *, int ifindex, gboolean running);
|
|
|
|
|
|
|
|
|
|
guint32 (*mesh_get_channel) (NMPlatform *, int ifindex);
|
|
|
|
|
gboolean (*mesh_set_channel) (NMPlatform *, int ifindex, guint32 channel);
|
2014-06-26 10:42:11 -04:00
|
|
|
gboolean (*mesh_set_ssid) (NMPlatform *, int ifindex, const guint8 *ssid, gsize len);
|
2014-02-04 14:27:03 +01:00
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
GArray * (*ip4_address_get_all) (NMPlatform *, int ifindex);
|
|
|
|
|
GArray * (*ip6_address_get_all) (NMPlatform *, int ifindex);
|
2013-12-02 10:20:26 -05:00
|
|
|
gboolean (*ip4_address_add) (NMPlatform *, int ifindex,
|
|
|
|
|
in_addr_t address, in_addr_t peer_address, int plen,
|
2014-02-19 16:10:59 -05:00
|
|
|
guint32 lifetime, guint32 preferred_lft,
|
|
|
|
|
const char *label);
|
2013-12-02 10:20:26 -05:00
|
|
|
gboolean (*ip6_address_add) (NMPlatform *, int ifindex,
|
|
|
|
|
struct in6_addr address, struct in6_addr peer_address, int plen,
|
2013-10-15 20:44:59 +02:00
|
|
|
guint32 lifetime, guint32 preferred_lft, guint flags);
|
2014-08-12 01:31:00 +02:00
|
|
|
gboolean (*ip4_address_delete) (NMPlatform *, int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
|
2013-03-27 22:23:24 +01:00
|
|
|
gboolean (*ip6_address_delete) (NMPlatform *, int ifindex, struct in6_addr address, int plen);
|
2015-07-14 12:37:58 +02:00
|
|
|
const NMPlatformIP4Address *(*ip4_address_get) (NMPlatform *, int ifindex, in_addr_t address, int plen);
|
|
|
|
|
const NMPlatformIP6Address *(*ip6_address_get) (NMPlatform *, int ifindex, struct in6_addr address, int plen);
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-06-22 17:28:37 +02:00
|
|
|
GArray * (*ip4_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags);
|
|
|
|
|
GArray * (*ip6_route_get_all) (NMPlatform *, int ifindex, NMPlatformGetRouteFlags flags);
|
2014-10-13 11:52:29 +02:00
|
|
|
gboolean (*ip4_route_add) (NMPlatform *, int ifindex, NMIPConfigSource source,
|
2014-05-15 15:19:59 -04:00
|
|
|
in_addr_t network, int plen, in_addr_t gateway,
|
2014-11-11 14:19:12 +01:00
|
|
|
guint32 pref_src, guint32 metric, guint32 mss);
|
2014-10-13 11:52:29 +02:00
|
|
|
gboolean (*ip6_route_add) (NMPlatform *, int ifindex, NMIPConfigSource source,
|
2014-05-15 15:19:59 -04:00
|
|
|
struct in6_addr network, int plen, struct in6_addr gateway,
|
2014-08-28 17:25:36 +02:00
|
|
|
guint32 metric, guint32 mss);
|
|
|
|
|
gboolean (*ip4_route_delete) (NMPlatform *, int ifindex, in_addr_t network, int plen, guint32 metric);
|
|
|
|
|
gboolean (*ip6_route_delete) (NMPlatform *, int ifindex, struct in6_addr network, int plen, guint32 metric);
|
2015-07-14 12:37:58 +02:00
|
|
|
const NMPlatformIP4Route *(*ip4_route_get) (NMPlatform *, int ifindex, in_addr_t network, int plen, guint32 metric);
|
|
|
|
|
const NMPlatformIP6Route *(*ip6_route_get) (NMPlatform *, int ifindex, struct in6_addr network, int plen, guint32 metric);
|
2014-01-07 17:21:12 +01:00
|
|
|
|
|
|
|
|
gboolean (*check_support_kernel_extended_ifa_flags) (NMPlatform *);
|
2014-07-24 15:57:08 -05:00
|
|
|
gboolean (*check_support_user_ipv6ll) (NMPlatform *);
|
2013-03-27 22:23:24 +01:00
|
|
|
} NMPlatformClass;
|
|
|
|
|
|
|
|
|
|
/* NMPlatform signals
|
|
|
|
|
*
|
|
|
|
|
* Each signal handler is called with a type-specific object that provides
|
|
|
|
|
* key attributes that constitute identity of the object. They may also
|
|
|
|
|
* provide additional attributes for convenience.
|
|
|
|
|
*
|
|
|
|
|
* The object only intended to be used by the signal handler to determine
|
|
|
|
|
* the current values. It is no longer valid after the signal handler exits
|
|
|
|
|
* but you are free to copy the provided information and use it for later
|
|
|
|
|
* reference.
|
|
|
|
|
*/
|
2014-03-07 19:04:38 +01:00
|
|
|
#define NM_PLATFORM_SIGNAL_LINK_CHANGED "link-changed"
|
|
|
|
|
#define NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED "ip4-address-changed"
|
|
|
|
|
#define NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED "ip6-address-changed"
|
|
|
|
|
#define NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED "ip4-route-changed"
|
|
|
|
|
#define NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED "ip6-route-changed"
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2015-04-24 12:28:07 +02:00
|
|
|
const char *nm_platform_signal_change_type_to_string (NMPlatformSignalChangeType change_type);
|
|
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
/******************************************************************/
|
|
|
|
|
|
|
|
|
|
GType nm_platform_get_type (void);
|
|
|
|
|
|
2015-04-18 13:37:36 +02:00
|
|
|
void nm_platform_setup (NMPlatform *instance);
|
2013-03-27 22:23:24 +01:00
|
|
|
NMPlatform *nm_platform_get (void);
|
2015-04-18 14:02:24 +02:00
|
|
|
NMPlatform *nm_platform_try_get (void);
|
2013-03-27 22:23:24 +01:00
|
|
|
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
#define NM_PLATFORM_GET (nm_platform_get ())
|
|
|
|
|
|
2013-03-27 22:23:24 +01:00
|
|
|
/******************************************************************/
|
|
|
|
|
|
2015-05-03 10:47:41 +02:00
|
|
|
/**
|
|
|
|
|
* nm_platform_route_scope_inv:
|
|
|
|
|
* @scope: the route scope, either its original value, or its inverse.
|
|
|
|
|
*
|
|
|
|
|
* This function is useful, because the constants such as RT_SCOPE_NOWHERE
|
|
|
|
|
* are 'int', so ~scope also gives an 'int'. This function gets the type
|
|
|
|
|
* casts to guint8 right.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the bitwise inverse of the route scope.
|
|
|
|
|
* */
|
2015-06-25 18:44:58 +02:00
|
|
|
#define nm_platform_route_scope_inv _nm_platform_uint8_inv
|
2015-05-03 10:47:41 +02:00
|
|
|
static inline guint8
|
2015-06-25 18:44:58 +02:00
|
|
|
_nm_platform_uint8_inv (guint8 scope)
|
2015-05-03 10:47:41 +02:00
|
|
|
{
|
|
|
|
|
return (guint8) ~scope;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-28 07:55:30 +02:00
|
|
|
const char *nm_link_type_to_string (NMLinkType link_type);
|
|
|
|
|
|
2015-06-15 15:50:59 +02:00
|
|
|
const char *nm_platform_error_to_string (NMPlatformError error);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
|
|
|
|
|
gboolean nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value);
|
|
|
|
|
char *nm_platform_sysctl_get (NMPlatform *self, const char *path);
|
|
|
|
|
gint32 nm_platform_sysctl_get_int32 (NMPlatform *self, const char *path, gint32 fallback);
|
|
|
|
|
gint64 nm_platform_sysctl_get_int_checked (NMPlatform *self, const char *path, guint base, gint64 min, gint64 max, gint64 fallback);
|
|
|
|
|
|
2015-04-08 15:54:30 +02:00
|
|
|
gboolean nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char *iface, int value);
|
|
|
|
|
|
2015-06-20 12:05:01 +02:00
|
|
|
const NMPlatformLink *nm_platform_link_get (NMPlatform *self, int ifindex);
|
|
|
|
|
const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const char *ifname);
|
|
|
|
|
const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length);
|
|
|
|
|
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
GArray *nm_platform_link_get_all (NMPlatform *self);
|
2015-06-15 16:19:19 +02:00
|
|
|
NMPlatformError nm_platform_dummy_add (NMPlatform *self, const char *name, NMPlatformLink *out_link);
|
|
|
|
|
NMPlatformError nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, NMPlatformLink *out_link);
|
|
|
|
|
NMPlatformError nm_platform_bond_add (NMPlatform *self, const char *name, NMPlatformLink *out_link);
|
|
|
|
|
NMPlatformError nm_platform_team_add (NMPlatform *self, const char *name, NMPlatformLink *out_link);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_link_delete (NMPlatform *self, int ifindex);
|
2015-06-20 12:05:01 +02:00
|
|
|
|
|
|
|
|
/* convienience methods to lookup the link and access fields of NMPlatformLink. */
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
int nm_platform_link_get_ifindex (NMPlatform *self, const char *name);
|
|
|
|
|
const char *nm_platform_link_get_name (NMPlatform *self, int ifindex);
|
|
|
|
|
NMLinkType nm_platform_link_get_type (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_is_software (NMPlatform *self, int ifindex);
|
2015-06-20 12:05:01 +02:00
|
|
|
gboolean nm_platform_link_is_up (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_is_connected (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_uses_arp (NMPlatform *self, int ifindex);
|
|
|
|
|
guint32 nm_platform_link_get_mtu (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_get_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId *iid);
|
|
|
|
|
gboolean nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex);
|
|
|
|
|
gconstpointer nm_platform_link_get_address (NMPlatform *self, int ifindex, size_t *length);
|
|
|
|
|
int nm_platform_link_get_master (NMPlatform *self, int slave);
|
|
|
|
|
|
2015-06-24 14:21:27 +02:00
|
|
|
gboolean nm_platform_link_get_unmanaged (NMPlatform *self, int ifindex, gboolean *unmanaged);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_link_supports_slaves (NMPlatform *self, int ifindex);
|
2015-06-20 12:05:01 +02:00
|
|
|
const char *nm_platform_link_get_type_name (NMPlatform *self, int ifindex);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
|
|
|
|
|
gboolean nm_platform_link_refresh (NMPlatform *self, int ifindex);
|
2015-06-19 15:38:41 +02:00
|
|
|
void nm_platform_process_events (NMPlatform *self);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
|
2015-06-15 17:41:27 +02:00
|
|
|
gboolean nm_platform_link_set_up (NMPlatform *self, int ifindex, gboolean *out_no_firmware);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_link_set_down (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_set_arp (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_set_noarp (NMPlatform *self, int ifindex);
|
|
|
|
|
|
2015-06-15 14:41:35 +02:00
|
|
|
const char *nm_platform_link_get_udi (NMPlatform *self, int ifindex);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
|
2015-06-15 15:19:28 +02:00
|
|
|
GObject *nm_platform_link_get_udev_device (NMPlatform *self, int ifindex);
|
|
|
|
|
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled);
|
|
|
|
|
|
2014-10-03 17:37:26 -05:00
|
|
|
gboolean nm_platform_link_get_permanent_address (NMPlatform *self, int ifindex, guint8 *buf, size_t *length);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_link_set_address (NMPlatform *self, int ifindex, const void *address, size_t length);
|
|
|
|
|
gboolean nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu);
|
|
|
|
|
|
|
|
|
|
char *nm_platform_link_get_physical_port_id (NMPlatform *self, int ifindex);
|
|
|
|
|
guint nm_platform_link_get_dev_id (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_get_wake_on_lan (NMPlatform *self, int ifindex);
|
2014-10-03 13:41:49 -05:00
|
|
|
gboolean nm_platform_link_get_driver_info (NMPlatform *self,
|
|
|
|
|
int ifindex,
|
|
|
|
|
char **out_driver_name,
|
|
|
|
|
char **out_driver_version,
|
|
|
|
|
char **out_fw_version);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
|
|
|
|
|
gboolean nm_platform_link_supports_carrier_detect (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_link_supports_vlans (NMPlatform *self, int ifindex);
|
|
|
|
|
|
|
|
|
|
gboolean nm_platform_link_enslave (NMPlatform *self, int master, int slave);
|
|
|
|
|
gboolean nm_platform_link_release (NMPlatform *self, int master, int slave);
|
|
|
|
|
gboolean nm_platform_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
|
|
|
|
|
char *nm_platform_master_get_option (NMPlatform *self, int ifindex, const char *option);
|
|
|
|
|
gboolean nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value);
|
|
|
|
|
char *nm_platform_slave_get_option (NMPlatform *self, int ifindex, const char *option);
|
|
|
|
|
|
2015-06-15 16:19:19 +02:00
|
|
|
NMPlatformError nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags, NMPlatformLink *out_link);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_vlan_get_info (NMPlatform *self, int ifindex, int *parent, int *vlanid);
|
|
|
|
|
gboolean nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to);
|
|
|
|
|
gboolean nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to);
|
|
|
|
|
|
2015-06-15 16:19:19 +02:00
|
|
|
NMPlatformError nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, NMPlatformLink *out_link);
|
2014-10-06 09:37:34 -05:00
|
|
|
gboolean nm_platform_infiniband_get_info (NMPlatform *self, int ifindex, int *parent, int *p_key, const char **mode);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
|
|
|
|
|
gboolean nm_platform_veth_get_properties (NMPlatform *self, int ifindex, NMPlatformVethProperties *properties);
|
|
|
|
|
gboolean nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties);
|
|
|
|
|
gboolean nm_platform_macvlan_get_properties (NMPlatform *self, int ifindex, NMPlatformMacvlanProperties *props);
|
|
|
|
|
gboolean nm_platform_vxlan_get_properties (NMPlatform *self, int ifindex, NMPlatformVxlanProperties *props);
|
|
|
|
|
gboolean nm_platform_gre_get_properties (NMPlatform *self, int ifindex, NMPlatformGreProperties *props);
|
|
|
|
|
|
|
|
|
|
gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps);
|
|
|
|
|
gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid);
|
|
|
|
|
guint32 nm_platform_wifi_get_frequency (NMPlatform *self, int ifindex);
|
|
|
|
|
int nm_platform_wifi_get_quality (NMPlatform *self, int ifindex);
|
|
|
|
|
guint32 nm_platform_wifi_get_rate (NMPlatform *self, int ifindex);
|
|
|
|
|
NM80211Mode nm_platform_wifi_get_mode (NMPlatform *self, int ifindex);
|
|
|
|
|
void nm_platform_wifi_set_mode (NMPlatform *self, int ifindex, NM80211Mode mode);
|
|
|
|
|
void nm_platform_wifi_set_powersave (NMPlatform *self, int ifindex, guint32 powersave);
|
|
|
|
|
guint32 nm_platform_wifi_find_frequency (NMPlatform *self, int ifindex, const guint32 *freqs);
|
|
|
|
|
void nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gboolean running);
|
|
|
|
|
|
|
|
|
|
guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel);
|
|
|
|
|
gboolean nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len);
|
|
|
|
|
|
2015-07-14 12:37:58 +02:00
|
|
|
const NMPlatformIP4Address *nm_platform_ip4_address_get (NMPlatform *self, int ifindex, in_addr_t address, int plen);
|
|
|
|
|
const NMPlatformIP6Address *nm_platform_ip6_address_get (NMPlatform *self, int ifindex, struct in6_addr address, int plen);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
GArray *nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex);
|
|
|
|
|
GArray *nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex);
|
|
|
|
|
gboolean nm_platform_ip4_address_add (NMPlatform *self, int ifindex,
|
2013-12-02 10:20:26 -05:00
|
|
|
in_addr_t address, in_addr_t peer_address, int plen,
|
2014-02-19 16:10:59 -05:00
|
|
|
guint32 lifetime, guint32 preferred_lft,
|
|
|
|
|
const char *label);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_ip6_address_add (NMPlatform *self, int ifindex,
|
2013-12-02 10:20:26 -05:00
|
|
|
struct in6_addr address, struct in6_addr peer_address, int plen,
|
2013-10-15 20:44:59 +02:00
|
|
|
guint32 lifetime, guint32 preferred_lft, guint flags);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address, int plen, in_addr_t peer_address);
|
|
|
|
|
gboolean nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr address, int plen);
|
route-manager: manage IPv4 device-routes with NMRouteManager
When adding an IPv4 address, kernel will also add a device-route.
We don't want that route because it has the wrong metric. Instead,
we add our own route (with a different metric) and remove the
kernel-added one.
This could be avoided if kernel would support an IPv4 address flag
IFA_F_NOPREFIXROUTE like it does for IPv6 (see related bug rh#1221311).
One important thing is, that we want don't want to manage the
device-route on assumed devices. Note that this is correct behavior
if "assumed" means "do-not-touch".
If "assumed" means "seamlessly-takeover", then this is wrong.
Imagine we get a new DHCP address. In this case, we would not manage
the device-route on the assumed device. This cannot be fixed without
splitting unmanaged/assumed with related bug bgo 746440.
This is no regression as we would also not manage device-routes
for assumed devices previously.
We also don't want to remove the device-route if the user added
it externally. Note that here we behave wrongly too, because we
don't record externally added kernel routes in update_ip_config().
This still needs fixing.
Let IPv4 device-routes also be managed by NMRouteManager. NMRouteManager
has a list of all routes and can properly add, remove, and restore
the device route as needed.
One problem is, that the device-route does not get added immediately
with the address. It only appears some time later. This is solved
by NMRouteManager watching platform and if a matchin device-route shows up
within a short time after configuring addresses, remove it.
If the route appears after the short timeout, assume they were added for
other reasons (e.g. by the user) and don't remove them.
https://bugzilla.gnome.org/show_bug.cgi?id=751264
https://bugzilla.redhat.com/show_bug.cgi?id=1211287
2015-06-22 18:21:53 +02:00
|
|
|
gboolean nm_platform_ip4_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, GPtrArray **out_added_addresses);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_ip6_address_sync (NMPlatform *self, int ifindex, const GArray *known_addresses, gboolean keep_link_local);
|
|
|
|
|
gboolean nm_platform_address_flush (NMPlatform *self, int ifindex);
|
|
|
|
|
|
2015-07-14 12:37:58 +02:00
|
|
|
const NMPlatformIP4Route *nm_platform_ip4_route_get (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric);
|
|
|
|
|
const NMPlatformIP6Route *nm_platform_ip6_route_get (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric);
|
2015-06-22 17:28:37 +02:00
|
|
|
GArray *nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags);
|
|
|
|
|
GArray *nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteFlags flags);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_ip4_route_add (NMPlatform *self, int ifindex, NMIPConfigSource source,
|
2014-05-15 15:19:59 -04:00
|
|
|
in_addr_t network, int plen, in_addr_t gateway,
|
2014-11-11 14:19:12 +01:00
|
|
|
guint32 pref_src, guint32 metric, guint32 mss);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_ip6_route_add (NMPlatform *self, int ifindex, NMIPConfigSource source,
|
2014-05-15 15:19:59 -04:00
|
|
|
struct in6_addr network, int plen, struct in6_addr gateway,
|
2014-08-28 17:25:36 +02:00
|
|
|
guint32 metric, guint32 mss);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_ip4_route_delete (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric);
|
|
|
|
|
gboolean nm_platform_ip6_route_delete (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric);
|
2013-03-27 22:23:24 +01:00
|
|
|
|
2014-02-17 14:08:32 +01:00
|
|
|
const char *nm_platform_link_to_string (const NMPlatformLink *link);
|
2013-08-29 20:07:34 +02:00
|
|
|
const char *nm_platform_ip4_address_to_string (const NMPlatformIP4Address *address);
|
|
|
|
|
const char *nm_platform_ip6_address_to_string (const NMPlatformIP6Address *address);
|
|
|
|
|
const char *nm_platform_ip4_route_to_string (const NMPlatformIP4Route *route);
|
|
|
|
|
const char *nm_platform_ip6_route_to_string (const NMPlatformIP6Route *route);
|
2013-08-26 22:10:11 +02:00
|
|
|
|
2014-04-05 18:35:20 +02:00
|
|
|
int nm_platform_link_cmp (const NMPlatformLink *a, const NMPlatformLink *b);
|
2013-09-06 09:58:55 +02:00
|
|
|
int nm_platform_ip4_address_cmp (const NMPlatformIP4Address *a, const NMPlatformIP4Address *b);
|
|
|
|
|
int nm_platform_ip6_address_cmp (const NMPlatformIP6Address *a, const NMPlatformIP6Address *b);
|
|
|
|
|
int nm_platform_ip4_route_cmp (const NMPlatformIP4Route *a, const NMPlatformIP4Route *b);
|
|
|
|
|
int nm_platform_ip6_route_cmp (const NMPlatformIP6Route *a, const NMPlatformIP6Route *b);
|
|
|
|
|
|
2014-01-03 16:07:36 +01:00
|
|
|
gboolean nm_platform_check_support_libnl_extended_ifa_flags (void);
|
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-18 12:36:09 +02:00
|
|
|
gboolean nm_platform_check_support_kernel_extended_ifa_flags (NMPlatform *self);
|
|
|
|
|
gboolean nm_platform_check_support_user_ipv6ll (NMPlatform *self);
|
2014-01-03 16:07:36 +01:00
|
|
|
|
2014-03-04 22:00:24 +01:00
|
|
|
void nm_platform_addr_flags2str (int flags, char *buf, size_t size);
|
|
|
|
|
|
2014-04-03 11:42:00 +02:00
|
|
|
int nm_platform_ip_address_cmp_expiry (const NMPlatformIPAddress *a, const NMPlatformIPAddress *b);
|
|
|
|
|
|
all: fix up multiple-include-guard defines
Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and
libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include
guard, which meant that nm-test-utils.h could not tell which of them
was being included (and so, eg, if you tried to include
nm-ip4-config.h in a libnm test, it would fail to compile because
nm-test-utils.h was referring to symbols in src/nm-ip4-config.h).
Fix this by changing the include guards in the non-API-stable parts of
the tree:
- libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H
- libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__
- src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__
And likewise for all other headers.
The two non-"nm"-prefixed headers, libnm/NetworkManager.h and
src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and
__NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely
consistent with the general scheme, do still mostly make sense in
isolation.
2014-08-13 14:10:11 -04:00
|
|
|
#endif /* __NETWORKMANAGER_PLATFORM_H__ */
|