#include "strv.h"
#include "utf8.h"
-struct link_config_ctx {
+struct LinkConfigContext {
LIST_HEAD(link_config, links);
-
int ethtool_fd;
-
bool enable_name_policy;
-
sd_netlink *rtnl;
-
usec_t network_dirs_ts_usec;
};
DEFINE_TRIVIAL_CLEANUP_FUNC(link_config*, link_config_free);
-static void link_configs_free(link_config_ctx *ctx) {
+static void link_configs_free(LinkConfigContext *ctx) {
link_config *link, *link_next;
if (!ctx)
link_config_free(link);
}
-link_config_ctx* link_config_ctx_free(link_config_ctx *ctx) {
+LinkConfigContext *link_config_ctx_free(LinkConfigContext *ctx) {
if (!ctx)
return NULL;
return mfree(ctx);
}
-int link_config_ctx_new(link_config_ctx **ret) {
- _cleanup_(link_config_ctx_freep) link_config_ctx *ctx = NULL;
+int link_config_ctx_new(LinkConfigContext **ret) {
+ _cleanup_(link_config_ctx_freep) LinkConfigContext *ctx = NULL;
if (!ret)
return -EINVAL;
- ctx = new0(link_config_ctx, 1);
+ ctx = new(LinkConfigContext, 1);
if (!ctx)
return -ENOMEM;
- LIST_HEAD_INIT(ctx->links);
-
- ctx->ethtool_fd = -1;
-
- ctx->enable_name_policy = true;
+ *ctx = (LinkConfigContext) {
+ .ethtool_fd = -1,
+ .enable_name_policy = true,
+ };
*ret = TAKE_PTR(ctx);
return 0;
}
-int link_load_one(link_config_ctx *ctx, const char *filename) {
+int link_load_one(LinkConfigContext *ctx, const char *filename) {
_cleanup_(link_config_freep) link_config *link = NULL;
_cleanup_free_ char *name = NULL;
const char *dropin_dirname;
return 0;
}
-int link_config_load(link_config_ctx *ctx) {
+int link_config_load(LinkConfigContext *ctx) {
_cleanup_strv_free_ char **files = NULL;
char **f;
int r;
return 0;
}
-bool link_config_should_reload(link_config_ctx *ctx) {
+bool link_config_should_reload(LinkConfigContext *ctx) {
return paths_check_timestamp(NETWORK_DIRS, &ctx->network_dirs_ts_usec, false);
}
-int link_config_get(link_config_ctx *ctx, sd_device *device, link_config **ret) {
+int link_config_get(LinkConfigContext *ctx, sd_device *device, link_config **ret) {
unsigned name_assign_type = NET_NAME_UNKNOWN;
struct ether_addr permanent_mac = {};
unsigned short iftype = 0;
return 0;
}
-static int link_config_generate_new_name(const link_config_ctx *ctx, const link_config *config, sd_device *device, const char **ret_name) {
+static int link_config_generate_new_name(const LinkConfigContext *ctx, const link_config *config, sd_device *device, const char **ret_name) {
unsigned name_type = NET_NAME_UNKNOWN;
int r;
return 0;
}
-int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device *device, const char **ret_name) {
+int link_config_apply(LinkConfigContext *ctx, const link_config *config, sd_device *device, const char **ret_name) {
const char *new_name;
sd_device_action_t a;
int r;
return 0;
}
-int link_get_driver(link_config_ctx *ctx, sd_device *device, char **ret) {
+int link_get_driver(LinkConfigContext *ctx, sd_device *device, char **ret) {
const char *name;
char *driver = NULL;
int r;
#include "list.h"
#include "net-condition.h"
-typedef struct link_config_ctx link_config_ctx;
+typedef struct LinkConfigContext LinkConfigContext;
typedef struct link_config link_config;
typedef enum MACAddressPolicy {
LIST_FIELDS(link_config, links);
};
-int link_config_ctx_new(link_config_ctx **ret);
-link_config_ctx* link_config_ctx_free(link_config_ctx *ctx);
-DEFINE_TRIVIAL_CLEANUP_FUNC(link_config_ctx*, link_config_ctx_free);
+int link_config_ctx_new(LinkConfigContext **ret);
+LinkConfigContext* link_config_ctx_free(LinkConfigContext *ctx);
+DEFINE_TRIVIAL_CLEANUP_FUNC(LinkConfigContext*, link_config_ctx_free);
-int link_load_one(link_config_ctx *ctx, const char *filename);
-int link_config_load(link_config_ctx *ctx);
-bool link_config_should_reload(link_config_ctx *ctx);
+int link_load_one(LinkConfigContext *ctx, const char *filename);
+int link_config_load(LinkConfigContext *ctx);
+bool link_config_should_reload(LinkConfigContext *ctx);
-int link_config_get(link_config_ctx *ctx, sd_device *device, link_config **ret);
-int link_config_apply(link_config_ctx *ctx, const link_config *config, sd_device *device, const char **ret_name);
-int link_get_driver(link_config_ctx *ctx, sd_device *device, char **ret);
+int link_config_get(LinkConfigContext *ctx, sd_device *device, link_config **ret);
+int link_config_apply(LinkConfigContext *ctx, const link_config *config, sd_device *device, const char **ret_name);
+int link_get_driver(LinkConfigContext *ctx, sd_device *device, char **ret);
const char *name_policy_to_string(NamePolicy p) _const_;
NamePolicy name_policy_from_string(const char *p) _pure_;