mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-19 20:18:14 +02:00
Currently "src/" mostly contains the source code of the daemon. I say mostly, because that is not true, there are also the device, settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp helper, and probably more. Also we have source code under libnm-core/, libnm/, clients/, and shared/ directories. That is all confusing. We should have one "src" directory, that contains subdirectories. Those subdirectories should contain individual parts (libraries or applications), that possibly have dependencies on other subdirectories. There should be a flat hierarchy of directories under src/, which contains individual modules. As the name "src/" is already taken, that prevents any sensible restructuring of the code. As a first step, move "src/" to "src/core/". This gives space to reorganize the code better by moving individual components into "src/". For inspiration, look at systemd's "src/" directory. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
87 lines
5 KiB
C
87 lines
5 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2016 Red Hat, Inc.
|
|
*/
|
|
|
|
#ifndef __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__
|
|
#define __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__
|
|
|
|
#include "nm-dhcp-client.h"
|
|
|
|
static inline NMLogDomain
|
|
_nm_dhcp_client_get_domain(NMDhcpClient *self)
|
|
{
|
|
if (self) {
|
|
switch (nm_dhcp_client_get_addr_family(self)) {
|
|
case AF_INET:
|
|
return LOGD_DHCP4;
|
|
case AF_INET6:
|
|
return LOGD_DHCP6;
|
|
default:
|
|
nm_assert_not_reached();
|
|
break;
|
|
}
|
|
}
|
|
return LOGD_DHCP;
|
|
}
|
|
|
|
#define _NMLOG_PREFIX_NAME "dhcp"
|
|
#define _NMLOG_DOMAIN LOGD_DHCP
|
|
#define _NMLOG(level, ...) \
|
|
G_STMT_START \
|
|
{ \
|
|
const NMLogLevel _level = (level); \
|
|
\
|
|
/* we check first for LOGD_DHCP instead of the correct domain.
|
|
* In the worst case, we guess wrong and enter the block.
|
|
*
|
|
* Same for the _NMLOG_ENABLED() macro. Probably it would be more
|
|
* expensive to determine the correct value then what we could
|
|
* safe. */ \
|
|
if (nm_logging_enabled(_level, _NMLOG_DOMAIN)) { \
|
|
NMDhcpClient * _self = (NMDhcpClient *) (self); \
|
|
const char * __ifname = _self ? nm_dhcp_client_get_iface(_self) : NULL; \
|
|
const NMLogDomain _domain = _nm_dhcp_client_get_domain(_self); \
|
|
\
|
|
nm_log(_level, \
|
|
_domain, \
|
|
__ifname, \
|
|
NULL, \
|
|
"%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
|
_NMLOG_PREFIX_NAME, \
|
|
(_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \
|
|
NM_PRINT_FMT_QUOTED(__ifname, " (", __ifname, ")", "") \
|
|
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
|
} \
|
|
} \
|
|
G_STMT_END
|
|
|
|
#define _NMLOG2(level, domain, ifname, ...) \
|
|
G_STMT_START \
|
|
{ \
|
|
const NMLogLevel _level = (level); \
|
|
const NMLogDomain _domain = (domain); \
|
|
\
|
|
/* we check first for LOGD_DHCP instead of the correct domain.
|
|
* In the worst case, we guess wrong and enter the block.
|
|
*
|
|
* Same for the _NMLOG_ENABLED() macro. Probably it would be more
|
|
* expensive to determine the correct value then what we could
|
|
* safe. */ \
|
|
if (nm_logging_enabled(_level, _domain)) { \
|
|
const char *__ifname = (ifname); \
|
|
\
|
|
nm_log(_level, \
|
|
_domain, \
|
|
__ifname, \
|
|
NULL, \
|
|
"%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
|
|
_NMLOG_PREFIX_NAME, \
|
|
(_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \
|
|
NM_PRINT_FMT_QUOTED(__ifname, " (", __ifname, ")", "") \
|
|
_NM_UTILS_MACRO_REST(__VA_ARGS__)); \
|
|
} \
|
|
} \
|
|
G_STMT_END
|
|
|
|
#endif /* __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ */
|