| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "networkd-forward.h" |
| 5 |
|
| 6 |
/* The following values are different from the ones defined in linux/rfkill.h. */ |
| 7 |
typedef enum RFKillState { |
| 8 |
RFKILL_UNKNOWN, |
| 9 |
RFKILL_UNBLOCKED, |
| 10 |
RFKILL_SOFT, |
| 11 |
RFKILL_HARD, |
| 12 |
_RFKILL_STATE_MAX, |
| 13 |
_RFKILL_STATE_INVALID = -EINVAL, |
| 14 |
} RFKillState; |
| 15 |
|
| 16 |
typedef struct Wiphy { |
| 17 |
Manager *manager; |
| 18 |
|
| 19 |
uint32_t index; |
| 20 |
char *name; |
| 21 |
|
| 22 |
sd_device *dev; |
| 23 |
sd_device *rfkill; |
| 24 |
RFKillState rfkill_state; |
| 25 |
} Wiphy; |
| 26 |
|
| 27 |
int wiphy_get_by_index(Manager *manager, uint32_t index, Wiphy **ret); |
| 28 |
int wiphy_get_by_name(Manager *manager, const char *name, Wiphy **ret); |
| 29 |
|
| 30 |
int link_rfkilled(Link *link); |
| 31 |
|
| 32 |
int manager_genl_process_nl80211_wiphy(sd_netlink *genl, sd_netlink_message *message, Manager *manager); |
| 33 |
int manager_udev_process_wiphy(Manager *m, sd_device *device, sd_device_action_t action); |
| 34 |
int manager_udev_process_rfkill(Manager *m, sd_device *device, sd_device_action_t action); |
| 35 |
|
| 36 |
#define log_wiphy_full_errno_zerook(w, level, error, ...) \ |
| 37 |
({ \ |
| 38 |
const Wiphy *_w = (w); \ |
| 39 |
log_interface_full_errno_zerook(_w ? _w->name : NULL, level, error, __VA_ARGS__); \ |
| 40 |
}) |
| 41 |
|
| 42 |
#define log_wiphy_full_errno(w, level, error, ...) \ |
| 43 |
({ \ |
| 44 |
int _error = (error); \ |
| 45 |
ASSERT_NON_ZERO(_error); \ |
| 46 |
log_wiphy_full_errno_zerook(w, level, _error, __VA_ARGS__); \ |
| 47 |
}) |
| 48 |
|
| 49 |
#define log_wiphy_full(w, level, ...) (void) log_wiphy_full_errno_zerook(w, level, 0, __VA_ARGS__) |
| 50 |
|
| 51 |
#define log_wiphy_debug(w, ...) log_wiphy_full(w, LOG_DEBUG, __VA_ARGS__) |
| 52 |
#define log_wiphy_info(w, ...) log_wiphy_full(w, LOG_INFO, __VA_ARGS__) |
| 53 |
#define log_wiphy_notice(w, ...) log_wiphy_full(w, LOG_NOTICE, __VA_ARGS__) |
| 54 |
#define log_wiphy_warning(w, ...) log_wiphy_full(w, LOG_WARNING, __VA_ARGS__) |
| 55 |
#define log_wiphy_error(w, ...) log_wiphy_full(w, LOG_ERR, __VA_ARGS__) |
| 56 |
|
| 57 |
#define log_wiphy_debug_errno(w, error, ...) log_wiphy_full_errno(w, LOG_DEBUG, error, __VA_ARGS__) |
| 58 |
#define log_wiphy_info_errno(w, error, ...) log_wiphy_full_errno(w, LOG_INFO, error, __VA_ARGS__) |
| 59 |
#define log_wiphy_notice_errno(w, error, ...) log_wiphy_full_errno(w, LOG_NOTICE, error, __VA_ARGS__) |
| 60 |
#define log_wiphy_warning_errno(w, error, ...) log_wiphy_full_errno(w, LOG_WARNING, error, __VA_ARGS__) |
| 61 |
#define log_wiphy_error_errno(w, error, ...) log_wiphy_full_errno(w, LOG_ERR, error, __VA_ARGS__) |