NetworkManager/src/core/ppp/nm-ppp-mgr.h
Thomas Haller 615221a99c format: reformat source tree with clang-format 13.0
We use clang-format for automatic formatting of our source files.
Since clang-format is actively maintained software, the actual
formatting depends on the used version of clang-format. That is
unfortunate and painful, but really unavoidable unless clang-format
would be strictly bug-compatible.

So the version that we must use is from the current Fedora release, which
is also tested by our gitlab-ci. Previously, we were using Fedora 34 with
clang-tools-extra-12.0.1-1.fc34.x86_64.

As Fedora 35 comes along, we need to update our formatting as Fedora 35
comes with version "13.0.0~rc1-1.fc35".
An alternative would be to freeze on version 12, but that has different
problems (like, it's cumbersome to rebuild clang 12 on Fedora 35 and it
would be cumbersome for our developers which are on Fedora 35 to use a
clang that they cannot easily install).

The (differently painful) solution is to reformat from time to time, as we
switch to a new Fedora (and thus clang) version.
Usually we would expect that such a reformatting brings minor changes.
But this time, the changes are huge. That is mentioned in the release
notes [1] as

  Makes PointerAligment: Right working with AlignConsecutiveDeclarations. (Fixes https://llvm.org/PR27353)

[1] https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
2021-11-29 09:31:09 +00:00

131 lines
4.2 KiB
C

/* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef __NM_PPP_MGR_H__
#define __NM_PPP_MGR_H__
#include "nm-l3cfg.h"
typedef struct _NMPppMgr NMPppMgr;
typedef enum _nm_packed {
/* NMPppMgr is starting. It will call nm_ppp_manager_start() on an idle
* handler. */
NM_PPP_MGR_STATE_STARTING,
/* NMPppMgr called nm_ppp_manager_start() and is now waiting to get
* an ifindex. At this time, we theoretically might already get IP configuration
* but that is cached and meaningless until we have the ifindex. */
NM_PPP_MGR_STATE_WAITING_FOR_IFINDEX,
/* NMPppMgr received an ifindex from NMPPPManager. But no IP configuration
* is yet received. */
NM_PPP_MGR_STATE_HAVE_IFINDEX,
/* NMPppMgr received an ifindex and IP configuration from NMPPPManager.
* Whether we have IPv4 and/or IPv6 is unspecified.
*
* If we have only either IPv4 or IPv6, then it's also unclear unknown
* whether the other address family will still arrive or not. */
NM_PPP_MGR_STATE_HAVE_IP_CONFIG,
/* Meta enum value which is the first failed state. All states larger than
* this are final (dead) states. */
_NM_PPP_MGR_STATE_FAILED_START,
/* NMPPPManager failed to start. This is a final (dead) state. */
NM_PPP_MGR_STATE_FAILED_TO_START = _NM_PPP_MGR_STATE_FAILED_START,
/* NMPppMgr started, but it failed to get the ifindex (possibly after timeout).
* This is a final (dead) state. */
NM_PPP_MGR_STATE_FAILED_TO_IFINDEX,
/* An unspecified failed state. This is a final (dead) state. */
NM_PPP_MGR_STATE_FAILED,
} NMPppMgrState;
const char *nm_ppp_mgr_state_to_string(NMPppMgrState state);
typedef enum {
NM_PPP_MGR_CALLBACK_TYPE_STATE_CHANGED,
NM_PPP_MGR_CALLBACK_TYPE_STATS_CHANGED,
} NMPppMgrCallbackType;
const char *nm_ppp_mgr_callback_type_to_string(NMPppMgrCallbackType callback_type);
typedef struct {
guint32 in_bytes;
guint32 out_bytes;
} NMPppMgrStatsData;
typedef struct {
const NML3ConfigData *l3cd;
const NMUtilsIPv6IfaceId *ipv6_iid;
NMOptionBool ip_enabled;
bool ip_received;
} NMPppMgrIPData;
typedef struct {
NMPppMgrCallbackType callback_type;
union {
struct {
const char *reason_msg;
union {
struct {
const NMPppMgrIPData *ip_data_6;
const NMPppMgrIPData *ip_data_4;
};
const NMPppMgrIPData *ip_data_x[2];
};
const NMPppMgrStatsData *stats_data;
int ifindex;
NMDeviceStateReason reason;
NMPppMgrState old_state;
NMPppMgrState state;
union {
struct {
bool ip_changed_6;
bool ip_changed_4;
};
bool ip_changed_x[2];
};
} data;
};
} NMPppMgrCallbackData;
typedef void (*NMPppMgrCallback)(NMPppMgr *self,
const NMPppMgrCallbackData *callback_data,
gpointer user_data);
typedef struct {
NMNetns *netns;
const char *parent_iface;
NMPppMgrCallback callback;
gpointer user_data;
NMActRequest *act_req;
const char *ppp_username;
guint32 timeout_secs;
guint baud_override;
} NMPppMgrConfig;
gboolean _nm_assert_is_ppp_mgr(const NMPppMgr *self);
#define NM_IS_PPP_MGR(self) \
({ \
const NMPppMgr *_self = (self); \
\
nm_assert(_nm_assert_is_ppp_mgr(_self)); \
!!_self; \
})
NMPppMgr *nm_ppp_mgr_start(const NMPppMgrConfig *config, GError **error);
NMPppMgrState nm_ppp_mgr_get_state(const NMPppMgr *self);
int nm_ppp_mgr_get_ifindex(const NMPppMgr *self);
const NMPppMgrIPData *nm_ppp_mgr_get_ip_data(const NMPppMgr *self, int addr_family);
const NMPppMgrStatsData *nm_ppp_mgr_get_stats(const NMPppMgr *self);
void nm_ppp_mgr_destroy(NMPppMgr *self);
#endif /* __NM_PPP_MGR_H__ */