mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 18:10:29 +01:00
core: add nm_ip6_config_dump function
Also improve nm_ip4_config_dump to print all properties and make use of nm_platform_*_to_string. Also, ensure that never_default is set to gboolean 1 or 0. Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
parent
5a4e40bacf
commit
47a0cf2a6c
3 changed files with 68 additions and 20 deletions
|
|
@ -770,22 +770,20 @@ void
|
|||
nm_ip4_config_dump (const NMIP4Config *config, const char *detail)
|
||||
{
|
||||
guint32 i, tmp;
|
||||
const char *str;
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
char buf2[INET_ADDRSTRLEN];
|
||||
|
||||
g_return_if_fail (config != NULL);
|
||||
|
||||
g_message ("--------- NMIP4Config %p (%s)", config, detail);
|
||||
|
||||
/* addresses */
|
||||
for (i = 0; i < nm_ip4_config_get_num_addresses (config); i++) {
|
||||
const NMPlatformIP4Address *addr = nm_ip4_config_get_address (config, i);
|
||||
str = nm_ip4_config_get_dbus_path (config);
|
||||
if (str)
|
||||
g_message (" path: %s", str);
|
||||
|
||||
if (inet_ntop (AF_INET, (void *) &addr->address, buf, sizeof (buf))) {
|
||||
g_message (" a: %s/%u timestamp:%u lifetime:%u preferred:%u",
|
||||
buf, addr->plen, addr->timestamp, addr->lifetime, addr->preferred);
|
||||
}
|
||||
}
|
||||
/* addresses */
|
||||
for (i = 0; i < nm_ip4_config_get_num_addresses (config); i++)
|
||||
g_message (" a: %s", nm_platform_ip4_address_to_string (nm_ip4_config_get_address (config, i)));
|
||||
|
||||
/* ptp address */
|
||||
tmp = nm_ip4_config_get_ptp_address (config);
|
||||
|
|
@ -805,15 +803,8 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail)
|
|||
}
|
||||
|
||||
/* routes */
|
||||
for (i = 0; i < nm_ip4_config_get_num_routes (config); i++) {
|
||||
const NMPlatformIP4Route *route = nm_ip4_config_get_route (config, i);
|
||||
|
||||
if (inet_ntop (AF_INET, &route->network, buf, sizeof (buf)) &&
|
||||
inet_ntop (AF_INET, &route->gateway, buf2, sizeof (buf2))) {
|
||||
g_message (" rt: %s/%u via %s metric:%u",
|
||||
buf, route->plen, buf2, route->metric);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < nm_ip4_config_get_num_routes (config); i++)
|
||||
g_message (" rt: %s", nm_platform_ip4_route_to_string (nm_ip4_config_get_route (config, i)));
|
||||
|
||||
/* domains */
|
||||
for (i = 0; i < nm_ip4_config_get_num_domains (config); i++)
|
||||
|
|
@ -824,6 +815,7 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail)
|
|||
g_message (" search: %s", nm_ip4_config_get_search (config, i));
|
||||
|
||||
g_message (" mss: %u", nm_ip4_config_get_mss (config));
|
||||
g_message (" mtu: %u", nm_ip4_config_get_mtu (config));
|
||||
|
||||
/* NIS */
|
||||
for (i = 0; i < nm_ip4_config_get_num_nis_servers (config); i++) {
|
||||
|
|
@ -842,6 +834,8 @@ nm_ip4_config_dump (const NMIP4Config *config, const char *detail)
|
|||
if (inet_ntop (AF_INET, (void *) &wins, buf, sizeof (buf)))
|
||||
g_message (" wins: %s", buf);
|
||||
}
|
||||
|
||||
g_message (" n-dflt: %d", nm_ip4_config_get_never_default (config));
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -867,7 +861,7 @@ nm_ip4_config_set_never_default (NMIP4Config *config, gboolean never_default)
|
|||
{
|
||||
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
priv->never_default = never_default;
|
||||
priv->never_default = !!never_default;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
|
|
@ -693,6 +693,59 @@ nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relev
|
|||
return has_relevant_changes || has_minor_changes;
|
||||
}
|
||||
|
||||
void
|
||||
nm_ip6_config_dump (const NMIP6Config *config, const char *detail)
|
||||
{
|
||||
const struct in6_addr *tmp;
|
||||
guint32 i;
|
||||
const char *str;
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
|
||||
g_return_if_fail (config != NULL);
|
||||
|
||||
g_message ("--------- NMIP6Config %p (%s)", config, detail);
|
||||
|
||||
str = nm_ip6_config_get_dbus_path (config);
|
||||
if (str)
|
||||
g_message (" path: %s", str);
|
||||
|
||||
/* addresses */
|
||||
for (i = 0; i < nm_ip6_config_get_num_addresses (config); i++)
|
||||
g_message (" a: %s", nm_platform_ip6_address_to_string (nm_ip6_config_get_address (config, i)));
|
||||
|
||||
/* ptp address */
|
||||
tmp = nm_ip6_config_get_ptp_address (config);
|
||||
if (tmp && inet_ntop (AF_INET6, tmp, buf, sizeof (buf)))
|
||||
g_message (" ptp: %s", buf);
|
||||
|
||||
/* default gateway */
|
||||
tmp = nm_ip6_config_get_gateway (config);
|
||||
if (tmp && inet_ntop (AF_INET6, tmp, buf, sizeof (buf)))
|
||||
g_message (" gw: %s", buf);
|
||||
|
||||
/* nameservers */
|
||||
for (i = 0; i < nm_ip6_config_get_num_nameservers (config); i++) {
|
||||
tmp = nm_ip6_config_get_nameserver (config, i);
|
||||
if (inet_ntop (AF_INET6, tmp, buf, sizeof (buf)))
|
||||
g_message (" ns: %s", buf);
|
||||
}
|
||||
|
||||
/* routes */
|
||||
for (i = 0; i < nm_ip6_config_get_num_routes (config); i++)
|
||||
g_message (" rt: %s", nm_platform_ip6_route_to_string (nm_ip6_config_get_route (config, i)));
|
||||
|
||||
/* domains */
|
||||
for (i = 0; i < nm_ip6_config_get_num_domains (config); i++)
|
||||
g_message (" domain: %s", nm_ip6_config_get_domain (config, i));
|
||||
|
||||
/* dns searches */
|
||||
for (i = 0; i < nm_ip6_config_get_num_searches (config); i++)
|
||||
g_message (" search: %s", nm_ip6_config_get_search (config, i));
|
||||
|
||||
g_message (" mss: %u", nm_ip6_config_get_mss (config));
|
||||
g_message (" n-dflt: %d", nm_ip6_config_get_never_default (config));
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
void
|
||||
|
|
@ -700,7 +753,7 @@ nm_ip6_config_set_never_default (NMIP6Config *config, gboolean never_default)
|
|||
{
|
||||
NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
priv->never_default = never_default;
|
||||
priv->never_default = !!never_default;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ void nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src);
|
|||
void nm_ip6_config_subtract (NMIP6Config *dst, const NMIP6Config *src);
|
||||
gboolean nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relevant_changes);
|
||||
int nm_ip6_config_destination_is_direct (const NMIP6Config *config, const struct in6_addr *dest, int plen);
|
||||
void nm_ip6_config_dump (const NMIP6Config *config, const char *detail);
|
||||
|
||||
/* Gateways */
|
||||
void nm_ip6_config_set_never_default (NMIP6Config *config, gboolean never_default);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue