all: rename nm_utils_strbuf_*() API to nm_strbuf_*()
The "utils" part does not seem useful in the name. Note that we also have NMStrBuf, which is named nm_str_buf_*(). There is an unfortunate similarity between the two, but it's still distinct enough (in particular, because one takes an NMStrBuf and the other not).
This commit is contained in:
@@ -382,64 +382,56 @@ _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len)
|
||||
buf[0] = '\0';
|
||||
|
||||
if (bzobj->d_has_adapter_iface) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append_str(&buf, &len, "Adapter1 {");
|
||||
nm_strbuf_append_str(&buf, &len, "Adapter1 {");
|
||||
if (bzobj->d_adapter.address) {
|
||||
nm_utils_strbuf_append(&buf, &len, " d.address: \"%s\"", bzobj->d_adapter.address);
|
||||
nm_strbuf_append(&buf, &len, " d.address: \"%s\"", bzobj->d_adapter.address);
|
||||
if (bzobj->d_adapter_powered)
|
||||
nm_utils_strbuf_append_str(&buf, &len, ",");
|
||||
nm_strbuf_append_str(&buf, &len, ",");
|
||||
}
|
||||
if (bzobj->d_adapter_powered)
|
||||
nm_utils_strbuf_append(&buf, &len, " d.powered: 1");
|
||||
nm_utils_strbuf_append_str(&buf, &len, " }");
|
||||
nm_strbuf_append(&buf, &len, " d.powered: 1");
|
||||
nm_strbuf_append_str(&buf, &len, " }");
|
||||
}
|
||||
|
||||
if (bzobj->d_has_device_iface) {
|
||||
const char *prefix1 = "";
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append_str(&buf, &len, "Device1 {");
|
||||
nm_strbuf_append_str(&buf, &len, "Device1 {");
|
||||
if (bzobj->d_device.address) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s d.address: \"%s\"",
|
||||
prefix1,
|
||||
bzobj->d_device.address);
|
||||
nm_strbuf_append(&buf, &len, "%s d.address: \"%s\"", prefix1, bzobj->d_device.address);
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device.name) {
|
||||
nm_utils_strbuf_append(&buf, &len, "%s d.name: \"%s\"", prefix1, bzobj->d_device.name);
|
||||
nm_strbuf_append(&buf, &len, "%s d.name: \"%s\"", prefix1, bzobj->d_device.name);
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device.adapter) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s d.adapter: \"%s\"",
|
||||
prefix1,
|
||||
bzobj->d_device.adapter);
|
||||
nm_strbuf_append(&buf, &len, "%s d.adapter: \"%s\"", prefix1, bzobj->d_device.adapter);
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device_capabilities != NM_BT_CAPABILITY_NONE) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s d.capabilities: \"%s\"",
|
||||
prefix1,
|
||||
nm_bluetooth_capability_to_string(bzobj->d_device_capabilities,
|
||||
sbuf_cap,
|
||||
sizeof(sbuf_cap)));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s d.capabilities: \"%s\"",
|
||||
prefix1,
|
||||
nm_bluetooth_capability_to_string(bzobj->d_device_capabilities,
|
||||
sbuf_cap,
|
||||
sizeof(sbuf_cap)));
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device_connected) {
|
||||
nm_utils_strbuf_append(&buf, &len, "%s d.connected: 1", prefix1);
|
||||
nm_strbuf_append(&buf, &len, "%s d.connected: 1", prefix1);
|
||||
prefix1 = ",";
|
||||
}
|
||||
if (bzobj->d_device_paired) {
|
||||
nm_utils_strbuf_append(&buf, &len, "%s d.paired: 1", prefix1);
|
||||
nm_strbuf_append(&buf, &len, "%s d.paired: 1", prefix1);
|
||||
prefix1 = ",";
|
||||
}
|
||||
nm_utils_strbuf_append_str(&buf, &len, " }");
|
||||
nm_strbuf_append_str(&buf, &len, " }");
|
||||
}
|
||||
|
||||
network_server_is_usable = _bzobjs_network_server_is_usable(bzobj, TRUE);
|
||||
@@ -450,43 +442,43 @@ _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len)
|
||||
|| !nm_streq0(bzobj->d_has_adapter_iface ? bzobj->d_adapter.address : NULL,
|
||||
bzobj->x_network_server.adapter_address)
|
||||
|| bzobj->x_network_server.device_br || bzobj->x_network_server.r_req_data) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
|
||||
nm_utils_strbuf_append(&buf, &len, "NetworkServer1 { ");
|
||||
nm_strbuf_append(&buf, &len, "NetworkServer1 { ");
|
||||
|
||||
if (!bzobj->d_has_network_server_iface)
|
||||
nm_utils_strbuf_append(&buf, &len, " has-d-iface: 0, ");
|
||||
nm_strbuf_append(&buf, &len, " has-d-iface: 0, ");
|
||||
|
||||
if (network_server_is_usable != (!c_list_is_empty(&bzobj->x_network_server.lst)))
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"usable: %d, used: %d",
|
||||
!!network_server_is_usable,
|
||||
!network_server_is_usable);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"usable: %d, used: %d",
|
||||
!!network_server_is_usable,
|
||||
!network_server_is_usable);
|
||||
else if (network_server_is_usable)
|
||||
nm_utils_strbuf_append(&buf, &len, "used: 1");
|
||||
nm_strbuf_append(&buf, &len, "used: 1");
|
||||
else
|
||||
nm_utils_strbuf_append(&buf, &len, "usable: 0");
|
||||
nm_strbuf_append(&buf, &len, "usable: 0");
|
||||
|
||||
if (!nm_streq0(bzobj->d_has_adapter_iface ? bzobj->d_adapter.address : NULL,
|
||||
bzobj->x_network_server.adapter_address)) {
|
||||
if (bzobj->x_network_server.adapter_address)
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
", adapter-address: \"%s\"",
|
||||
bzobj->x_network_server.adapter_address);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
", adapter-address: \"%s\"",
|
||||
bzobj->x_network_server.adapter_address);
|
||||
else
|
||||
nm_utils_strbuf_append(&buf, &len, ", adapter-address: <NULL>");
|
||||
nm_strbuf_append(&buf, &len, ", adapter-address: <NULL>");
|
||||
}
|
||||
|
||||
if (bzobj->x_network_server.device_br)
|
||||
nm_utils_strbuf_append(&buf, &len, ", bridge-device: 1");
|
||||
nm_strbuf_append(&buf, &len, ", bridge-device: 1");
|
||||
|
||||
if (bzobj->x_network_server.r_req_data)
|
||||
nm_utils_strbuf_append(&buf, &len, ", register-in-progress: 1");
|
||||
nm_strbuf_append(&buf, &len, ", register-in-progress: 1");
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &len, " }");
|
||||
nm_strbuf_append_str(&buf, &len, " }");
|
||||
}
|
||||
|
||||
device_is_usable = _bzobjs_device_is_usable(bzobj, NULL, &create_panu_connection);
|
||||
@@ -497,76 +489,72 @@ _bzobj_to_string(const BzDBusObj *bzobj, char *buf, gsize len)
|
||||
|| bzobj->x_device_connect_bt_type != NM_BT_CAPABILITY_NONE
|
||||
|| bzobj->x_device.connect_dun_context || bzobj->x_device.c_req_data
|
||||
|| bzobj->x_device_is_connected != bzobj->d_network_connected) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append_str(&buf, &len, "Network1 {");
|
||||
nm_strbuf_append_str(&buf, &len, "Network1 {");
|
||||
if (bzobj->d_network.interface)
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" d.interface: \"%s\", ",
|
||||
bzobj->d_network.interface);
|
||||
nm_strbuf_append(&buf, &len, " d.interface: \"%s\", ", bzobj->d_network.interface);
|
||||
if (bzobj->d_network_connected)
|
||||
nm_utils_strbuf_append(&buf, &len, " d.connected: %d, ", !!bzobj->d_network_connected);
|
||||
nm_strbuf_append(&buf, &len, " d.connected: %d, ", !!bzobj->d_network_connected);
|
||||
if (!bzobj->d_has_network_iface)
|
||||
nm_utils_strbuf_append(&buf, &len, " has-d-iface: 0, ");
|
||||
nm_strbuf_append(&buf, &len, " has-d-iface: 0, ");
|
||||
if (device_is_usable != bzobj->x_device_is_usable)
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" usable: %d, used: %d",
|
||||
!!device_is_usable,
|
||||
!device_is_usable);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" usable: %d, used: %d",
|
||||
!!device_is_usable,
|
||||
!device_is_usable);
|
||||
else if (device_is_usable)
|
||||
nm_utils_strbuf_append(&buf, &len, " used: 1");
|
||||
nm_strbuf_append(&buf, &len, " used: 1");
|
||||
else
|
||||
nm_utils_strbuf_append(&buf, &len, " usable: 0");
|
||||
nm_strbuf_append(&buf, &len, " usable: 0");
|
||||
|
||||
if (create_panu_connection)
|
||||
nm_utils_strbuf_append(&buf, &len, ", create-panu-connection: 1");
|
||||
nm_strbuf_append(&buf, &len, ", create-panu-connection: 1");
|
||||
|
||||
if (bzobj->x_device.panu_connection)
|
||||
nm_utils_strbuf_append(&buf, &len, ", has-panu-connection: 1");
|
||||
nm_strbuf_append(&buf, &len, ", has-panu-connection: 1");
|
||||
|
||||
if (bzobj->x_device.device_bt)
|
||||
nm_utils_strbuf_append(&buf, &len, ", has-device: 1");
|
||||
nm_strbuf_append(&buf, &len, ", has-device: 1");
|
||||
|
||||
if (bzobj->x_device_connect_bt_type != NM_BT_CAPABILITY_NONE
|
||||
|| bzobj->x_device.connect_dun_context) {
|
||||
nm_utils_strbuf_append(
|
||||
&buf,
|
||||
&len,
|
||||
", connect: %s%s",
|
||||
nm_bluetooth_capability_to_string(bzobj->x_device_connect_bt_type,
|
||||
sbuf_cap,
|
||||
sizeof(sbuf_cap)),
|
||||
bzobj->x_device.connect_dun_context ? ",with-dun-context" : "");
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
", connect: %s%s",
|
||||
nm_bluetooth_capability_to_string(bzobj->x_device_connect_bt_type,
|
||||
sbuf_cap,
|
||||
sizeof(sbuf_cap)),
|
||||
bzobj->x_device.connect_dun_context ? ",with-dun-context" : "");
|
||||
}
|
||||
|
||||
if (bzobj->x_device.c_req_data)
|
||||
nm_utils_strbuf_append(&buf, &len, ", connecting: 1");
|
||||
nm_strbuf_append(&buf, &len, ", connecting: 1");
|
||||
|
||||
if (bzobj->x_device_is_connected != bzobj->d_network_connected)
|
||||
nm_utils_strbuf_append(&buf, &len, ", connected: %d", !!bzobj->x_device_is_connected);
|
||||
nm_strbuf_append(&buf, &len, ", connected: %d", !!bzobj->x_device_is_connected);
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &len, " }");
|
||||
nm_strbuf_append_str(&buf, &len, " }");
|
||||
}
|
||||
|
||||
if (_bzobjs_is_dead(bzobj)) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append_str(&buf, &len, "dead: 1");
|
||||
nm_strbuf_append_str(&buf, &len, "dead: 1");
|
||||
}
|
||||
|
||||
if (!c_list_is_empty(&bzobj->process_change_lst)) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append(&buf, &len, "change-pending-on-idle: 1");
|
||||
nm_strbuf_append(&buf, &len, "change-pending-on-idle: 1");
|
||||
}
|
||||
|
||||
if (_bzobjs_adapter_is_usable_for_device(bzobj)
|
||||
!= bzobj->was_usable_adapter_for_device_before) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, prefix);
|
||||
nm_strbuf_append_str(&buf, &len, prefix);
|
||||
prefix = ", ";
|
||||
nm_utils_strbuf_append(&buf, &len, "change-usable-adapter-for-device: 1");
|
||||
nm_strbuf_append(&buf, &len, "change-usable-adapter-for-device: 1");
|
||||
}
|
||||
|
||||
return buf0;
|
||||
|
@@ -14738,15 +14738,15 @@ _unmanaged_flags2str(NMUnmanagedFlags flags, NMUnmanagedFlags mask, char *buf, g
|
||||
tmp = buf2;
|
||||
while (TRUE) {
|
||||
if (add_separator)
|
||||
nm_utils_strbuf_append_c(&b, &len, ',');
|
||||
nm_strbuf_append_c(&b, &len, ',');
|
||||
add_separator = TRUE;
|
||||
|
||||
tmp2 = strchr(tmp, ',');
|
||||
if (tmp2)
|
||||
tmp2[0] = '\0';
|
||||
|
||||
nm_utils_strbuf_append_c(&b, &len, '!');
|
||||
nm_utils_strbuf_append_str(&b, &len, tmp);
|
||||
nm_strbuf_append_c(&b, &len, '!');
|
||||
nm_strbuf_append_str(&b, &len, tmp);
|
||||
if (!tmp2)
|
||||
break;
|
||||
|
||||
|
@@ -4072,8 +4072,8 @@ nm_utils_get_reverse_dns_domains_ip_4(guint32 addr, guint8 plen, GPtrArray *doma
|
||||
len = len0;
|
||||
str = s = g_malloc(len);
|
||||
for (i = octets; i > 0; i--)
|
||||
nm_utils_strbuf_append(&s, &len, "%u.", p[i - 1] & 0xff);
|
||||
nm_utils_strbuf_append_str(&s, &len, "in-addr.arpa");
|
||||
nm_strbuf_append(&s, &len, "%u.", p[i - 1] & 0xff);
|
||||
nm_strbuf_append_str(&s, &len, "in-addr.arpa");
|
||||
|
||||
g_ptr_array_add(domains, str);
|
||||
|
||||
@@ -4124,8 +4124,8 @@ nm_utils_get_reverse_dns_domains_ip_6(const struct in6_addr *ip, guint8 plen, GP
|
||||
str = s = g_malloc(len);
|
||||
|
||||
for (j = nibbles - 1; j >= 0; j--)
|
||||
nm_utils_strbuf_append(&s, &len, "%x.", (addr.s6_addr[j / 2] >> N_SHIFT(j)) & 0xf);
|
||||
nm_utils_strbuf_append_str(&s, &len, "ip6.arpa");
|
||||
nm_strbuf_append(&s, &len, "%x.", (addr.s6_addr[j / 2] >> N_SHIFT(j)) & 0xf);
|
||||
nm_strbuf_append_str(&s, &len, "ip6.arpa");
|
||||
|
||||
g_ptr_array_add(domains, str);
|
||||
|
||||
|
@@ -439,27 +439,23 @@ nm_l3_config_data_log(const NML3ConfigData *self,
|
||||
const char *s_prefix = "ndisc: ";
|
||||
|
||||
if (self->ndisc_hop_limit_set) {
|
||||
nm_utils_strbuf_append(&p,
|
||||
&l,
|
||||
"%shop-limit=%d",
|
||||
s_prefix,
|
||||
self->ndisc_hop_limit_val);
|
||||
nm_strbuf_append(&p, &l, "%shop-limit=%d", s_prefix, self->ndisc_hop_limit_val);
|
||||
s_prefix = ", ";
|
||||
}
|
||||
if (self->ndisc_reachable_time_msec_set) {
|
||||
nm_utils_strbuf_append(&p,
|
||||
&l,
|
||||
"%sreachable-time-msec=%u",
|
||||
s_prefix,
|
||||
self->ndisc_reachable_time_msec_val);
|
||||
nm_strbuf_append(&p,
|
||||
&l,
|
||||
"%sreachable-time-msec=%u",
|
||||
s_prefix,
|
||||
self->ndisc_reachable_time_msec_val);
|
||||
s_prefix = ", ";
|
||||
}
|
||||
if (self->ndisc_retrans_timer_msec_set) {
|
||||
nm_utils_strbuf_append(&p,
|
||||
&l,
|
||||
"%sretrans-timer-msec=%u",
|
||||
s_prefix,
|
||||
self->ndisc_retrans_timer_msec_val);
|
||||
nm_strbuf_append(&p,
|
||||
&l,
|
||||
"%sretrans-timer-msec=%u",
|
||||
s_prefix,
|
||||
self->ndisc_retrans_timer_msec_val);
|
||||
s_prefix = ", ";
|
||||
}
|
||||
_L("%s", sbuf);
|
||||
|
@@ -358,31 +358,29 @@ _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data,
|
||||
nm_assert(sbuf_size > 0);
|
||||
|
||||
_l3_config_notify_type_to_string(notify_data->notify_type, s, l);
|
||||
nm_utils_strbuf_seek_end(&s, &l);
|
||||
nm_strbuf_seek_end(&s, &l);
|
||||
|
||||
switch (notify_data->notify_type) {
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_L3CD_CHANGED:
|
||||
nm_utils_strbuf_append(
|
||||
&s,
|
||||
&l,
|
||||
", l3cd-old=%s",
|
||||
NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_old, sbufobf));
|
||||
nm_utils_strbuf_append(
|
||||
&s,
|
||||
&l,
|
||||
", l3cd-new=%s",
|
||||
NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_new, sbufobf));
|
||||
nm_utils_strbuf_append(&s, &l, ", commited=%d", notify_data->l3cd_changed.commited);
|
||||
nm_strbuf_append(&s,
|
||||
&l,
|
||||
", l3cd-old=%s",
|
||||
NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_old, sbufobf));
|
||||
nm_strbuf_append(&s,
|
||||
&l,
|
||||
", l3cd-new=%s",
|
||||
NM_HASH_OBFUSCATE_PTR_STR(notify_data->l3cd_changed.l3cd_new, sbufobf));
|
||||
nm_strbuf_append(&s, &l, ", commited=%d", notify_data->l3cd_changed.commited);
|
||||
break;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT:
|
||||
nm_utils_strbuf_append(&s,
|
||||
&l,
|
||||
", addr=%s, state=%s",
|
||||
_nm_utils_inet4_ntop(notify_data->acd_event.info.addr, sbuf_addr),
|
||||
_l3_acd_addr_state_to_string(notify_data->acd_event.info.state));
|
||||
nm_strbuf_append(&s,
|
||||
&l,
|
||||
", addr=%s, state=%s",
|
||||
_nm_utils_inet4_ntop(notify_data->acd_event.info.addr, sbuf_addr),
|
||||
_l3_acd_addr_state_to_string(notify_data->acd_event.info.state));
|
||||
break;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE:
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&s,
|
||||
&l,
|
||||
", obj-type=%s, change=%s, obj=",
|
||||
@@ -391,15 +389,15 @@ _l3_config_notify_data_to_string(const NML3ConfigNotifyData *notify_data,
|
||||
nmp_object_to_string(notify_data->platform_change.obj, NMP_OBJECT_TO_STRING_PUBLIC, s, l);
|
||||
break;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE:
|
||||
nm_utils_strbuf_append(&s,
|
||||
&l,
|
||||
", obj-type-flags=0x%x",
|
||||
notify_data->platform_change_on_idle.obj_type_flags);
|
||||
nm_strbuf_append(&s,
|
||||
&l,
|
||||
", obj-type-flags=0x%x",
|
||||
notify_data->platform_change_on_idle.obj_type_flags);
|
||||
break;
|
||||
case NM_L3_CONFIG_NOTIFY_TYPE_IPV4LL_EVENT:
|
||||
nm_assert(NM_IS_L3_IPV4LL(notify_data->ipv4ll_event.ipv4ll));
|
||||
addr4 = nm_l3_ipv4ll_get_addr(notify_data->ipv4ll_event.ipv4ll);
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&s,
|
||||
&l,
|
||||
", ipv4ll=" NM_HASH_OBFUSCATE_PTR_FMT "%s%s, state=%s",
|
||||
|
@@ -1442,12 +1442,12 @@ write_vlan_setting(NMConnection *connection, shvarFile *ifcfg, gboolean *wired,
|
||||
svSetValueBoolean(ifcfg, "REORDER_HDR", NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS));
|
||||
svSetValueBoolean(ifcfg, "GVRP", NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_GVRP));
|
||||
|
||||
nm_utils_strbuf_init(s_buf, &s_buf_ptr, &s_buf_len);
|
||||
nm_strbuf_init_arr(s_buf, &s_buf_ptr, &s_buf_len);
|
||||
|
||||
if (NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_LOOSE_BINDING))
|
||||
nm_utils_strbuf_append_str(&s_buf_ptr, &s_buf_len, "LOOSE_BINDING");
|
||||
nm_strbuf_append_str(&s_buf_ptr, &s_buf_len, "LOOSE_BINDING");
|
||||
if (!NM_FLAGS_HAS(vlan_flags, NM_VLAN_FLAG_REORDER_HEADERS))
|
||||
nm_utils_strbuf_append(&s_buf_ptr, &s_buf_len, "%sNO_REORDER_HDR", s_buf[0] ? "," : "");
|
||||
nm_strbuf_append(&s_buf_ptr, &s_buf_len, "%sNO_REORDER_HDR", s_buf[0] ? "," : "");
|
||||
|
||||
svSetValueStr(ifcfg, "VLAN_FLAGS", s_buf);
|
||||
|
||||
|
@@ -101,27 +101,27 @@ _extra_flags_to_string(char * str,
|
||||
const char *str0 = str;
|
||||
|
||||
if (!is_nm_generated && !is_volatile && !is_external)
|
||||
nm_utils_strbuf_append_str(&str, &str_len, "");
|
||||
nm_strbuf_append_str(&str, &str_len, "");
|
||||
else {
|
||||
char ch = '(';
|
||||
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ' ');
|
||||
nm_strbuf_append_c(&str, &str_len, ' ');
|
||||
if (is_nm_generated) {
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_utils_strbuf_append_str(&str, &str_len, "nm-generated");
|
||||
nm_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_strbuf_append_str(&str, &str_len, "nm-generated");
|
||||
ch = ',';
|
||||
}
|
||||
if (is_volatile) {
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_utils_strbuf_append_str(&str, &str_len, "volatile");
|
||||
nm_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_strbuf_append_str(&str, &str_len, "volatile");
|
||||
ch = ',';
|
||||
}
|
||||
if (is_external) {
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_utils_strbuf_append_str(&str, &str_len, "external");
|
||||
nm_strbuf_append_c(&str, &str_len, ch);
|
||||
nm_strbuf_append_str(&str, &str_len, "external");
|
||||
ch = ',';
|
||||
}
|
||||
nm_utils_strbuf_append_c(&str, &str_len, ')');
|
||||
nm_strbuf_append_c(&str, &str_len, ')');
|
||||
}
|
||||
|
||||
return str0;
|
||||
|
@@ -1728,86 +1728,86 @@ test_nm_utils_strbuf_append(void)
|
||||
char buf[NM_STRLEN(BUF_ORIG) + 1];
|
||||
char str[NM_STRLEN(BUF_ORIG) + 1];
|
||||
|
||||
#define _strbuf_append(buf, len, format, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char ** _buf = (buf); \
|
||||
gsize * _len = (len); \
|
||||
const char * _str_iter; \
|
||||
gs_free char *_str = NULL; \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_utils_strbuf_append(_buf, _len, (format), __VA_ARGS__); \
|
||||
break; \
|
||||
case 1: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
nm_utils_strbuf_append_str(_buf, _len, _str); \
|
||||
break; \
|
||||
case 2: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
nm_utils_strbuf_append_bin(_buf, _len, _str, strlen(_str)); \
|
||||
break; \
|
||||
case 3: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
if (!_str[0]) \
|
||||
nm_utils_strbuf_append_str(_buf, _len, _str); \
|
||||
for (_str_iter = _str; _str_iter[0]; _str_iter++) \
|
||||
nm_utils_strbuf_append_c(_buf, _len, _str_iter[0]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
#define _strbuf_append(buf, len, format, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char ** _buf = (buf); \
|
||||
gsize * _len = (len); \
|
||||
const char * _str_iter; \
|
||||
gs_free char *_str = NULL; \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_strbuf_append(_buf, _len, (format), __VA_ARGS__); \
|
||||
break; \
|
||||
case 1: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
nm_strbuf_append_str(_buf, _len, _str); \
|
||||
break; \
|
||||
case 2: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
nm_strbuf_append_bin(_buf, _len, _str, strlen(_str)); \
|
||||
break; \
|
||||
case 3: \
|
||||
_str = g_strdup_printf((format), __VA_ARGS__); \
|
||||
if (!_str[0]) \
|
||||
nm_strbuf_append_str(_buf, _len, _str); \
|
||||
for (_str_iter = _str; _str_iter[0]; _str_iter++) \
|
||||
nm_strbuf_append_c(_buf, _len, _str_iter[0]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
#define _strbuf_append_str(buf, len, str) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char ** _buf = (buf); \
|
||||
gsize * _len = (len); \
|
||||
const char *_str = (str); \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_utils_strbuf_append(_buf, _len, "%s", _str ?: ""); \
|
||||
break; \
|
||||
case 1: \
|
||||
nm_utils_strbuf_append_str(_buf, _len, _str); \
|
||||
break; \
|
||||
case 2: \
|
||||
nm_utils_strbuf_append_bin(_buf, _len, _str, _str ? strlen(_str) : 0); \
|
||||
break; \
|
||||
case 3: \
|
||||
if (!_str || !_str[0]) \
|
||||
nm_utils_strbuf_append_str(_buf, _len, _str); \
|
||||
for (; _str && _str[0]; _str++) \
|
||||
nm_utils_strbuf_append_c(_buf, _len, _str[0]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
#define _strbuf_append_str(buf, len, str) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char ** _buf = (buf); \
|
||||
gsize * _len = (len); \
|
||||
const char *_str = (str); \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_strbuf_append(_buf, _len, "%s", _str ?: ""); \
|
||||
break; \
|
||||
case 1: \
|
||||
nm_strbuf_append_str(_buf, _len, _str); \
|
||||
break; \
|
||||
case 2: \
|
||||
nm_strbuf_append_bin(_buf, _len, _str, _str ? strlen(_str) : 0); \
|
||||
break; \
|
||||
case 3: \
|
||||
if (!_str || !_str[0]) \
|
||||
nm_strbuf_append_str(_buf, _len, _str); \
|
||||
for (; _str && _str[0]; _str++) \
|
||||
nm_strbuf_append_c(_buf, _len, _str[0]); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
#define _strbuf_append_c(buf, len, ch) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char **_buf = (buf); \
|
||||
gsize *_len = (len); \
|
||||
char _ch = (ch); \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_utils_strbuf_append(_buf, _len, "%c", _ch); \
|
||||
break; \
|
||||
case 1: \
|
||||
nm_utils_strbuf_append_str(_buf, _len, ((char[2]){_ch, 0})); \
|
||||
break; \
|
||||
case 2: \
|
||||
nm_utils_strbuf_append_bin(_buf, _len, &_ch, 1); \
|
||||
break; \
|
||||
case 3: \
|
||||
nm_utils_strbuf_append_c(_buf, _len, _ch); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
#define _strbuf_append_c(buf, len, ch) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
char **_buf = (buf); \
|
||||
gsize *_len = (len); \
|
||||
char _ch = (ch); \
|
||||
\
|
||||
switch (nmtst_get_rand_uint32() % 4) { \
|
||||
case 0: \
|
||||
nm_strbuf_append(_buf, _len, "%c", _ch); \
|
||||
break; \
|
||||
case 1: \
|
||||
nm_strbuf_append_str(_buf, _len, ((char[2]){_ch, 0})); \
|
||||
break; \
|
||||
case 2: \
|
||||
nm_strbuf_append_bin(_buf, _len, &_ch, 1); \
|
||||
break; \
|
||||
case 3: \
|
||||
nm_strbuf_append_c(_buf, _len, _ch); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
for (buf_len = 0; buf_len < 10; buf_len++) {
|
||||
@@ -1854,28 +1854,28 @@ test_nm_utils_strbuf_append(void)
|
||||
if (t_len > 0 && strlen(str) >= buf_len && (nmtst_get_rand_uint32() % 2)) {
|
||||
/* the string was truncated by g_snprintf(). That means, at the last position in the
|
||||
* buffer is now NUL.
|
||||
* Replace the NUL by the actual character, and check that nm_utils_strbuf_seek_end()
|
||||
* Replace the NUL by the actual character, and check that nm_strbuf_seek_end()
|
||||
* does the right thing: NUL terminate the buffer and seek past the end of the buffer. */
|
||||
g_assert_cmpmem(t_buf, t_len - 1, str, t_len - 1);
|
||||
g_assert(t_buf[t_len - 1] == '\0');
|
||||
g_assert(str[t_len - 1] != '\0');
|
||||
t_buf[t_len - 1] = str[t_len - 1];
|
||||
nm_utils_strbuf_seek_end(&t_buf, &t_len);
|
||||
nm_strbuf_seek_end(&t_buf, &t_len);
|
||||
g_assert(t_len == 0);
|
||||
g_assert(t_buf == &buf[buf_len]);
|
||||
g_assert(t_buf[-1] == '\0');
|
||||
} else {
|
||||
nm_utils_strbuf_seek_end(&t_buf, &t_len);
|
||||
nm_strbuf_seek_end(&t_buf, &t_len);
|
||||
if (buf_len > 0 && strlen(str) + 1 > buf_len) {
|
||||
/* the buffer was truncated by g_snprintf() above.
|
||||
*
|
||||
* But nm_utils_strbuf_seek_end() does not recognize that and returns
|
||||
* But nm_strbuf_seek_end() does not recognize that and returns
|
||||
* a remaining length of 1.
|
||||
*
|
||||
* Note that other nm_utils_strbuf_append*() functions recognize
|
||||
* Note that other nm_strbuf_append*() functions recognize
|
||||
* truncation, and properly set the remaining length to zero.
|
||||
* As the assertions below check for the behavior of nm_utils_strbuf_append*(),
|
||||
* we assert here that nm_utils_strbuf_seek_end() behaved as expected, and then
|
||||
* As the assertions below check for the behavior of nm_strbuf_append*(),
|
||||
* we assert here that nm_strbuf_seek_end() behaved as expected, and then
|
||||
* adjust t_buf/t_len according to the "is-truncated" case. */
|
||||
g_assert(t_len == 1);
|
||||
g_assert(t_buf == &buf[buf_len - 1]);
|
||||
@@ -2594,7 +2594,7 @@ main(int argc, char **argv)
|
||||
g_test_add_func("/general/test_logging_domains", test_logging_domains);
|
||||
g_test_add_func("/general/test_logging_error", test_logging_error);
|
||||
|
||||
g_test_add_func("/general/nm_utils_strbuf_append", test_nm_utils_strbuf_append);
|
||||
g_test_add_func("/general/nm_strbuf_append", test_nm_utils_strbuf_append);
|
||||
|
||||
g_test_add_func("/general/nm_utils_ip6_address_clear_host_address",
|
||||
test_nm_utils_ip6_address_clear_host_address);
|
||||
|
@@ -310,7 +310,7 @@ parse_old_openssl_key_file(const guint8 * data,
|
||||
"Malformed PEM file: both Proc-Type and DEK-Info tags are required.");
|
||||
return FALSE;
|
||||
}
|
||||
nm_utils_strbuf_append_str(&str_p, &str_len, p);
|
||||
nm_strbuf_append_str(&str_p, &str_len, p);
|
||||
nm_assert(str_len > 0);
|
||||
}
|
||||
}
|
||||
|
@@ -263,7 +263,7 @@ _nm_assert_on_main_thread(void)
|
||||
/*****************************************************************************/
|
||||
|
||||
void
|
||||
nm_utils_strbuf_append_c(char **buf, gsize *len, char c)
|
||||
nm_strbuf_append_c(char **buf, gsize *len, char c)
|
||||
{
|
||||
switch (*len) {
|
||||
case 0:
|
||||
@@ -283,7 +283,7 @@ nm_utils_strbuf_append_c(char **buf, gsize *len, char c)
|
||||
}
|
||||
|
||||
void
|
||||
nm_utils_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len)
|
||||
nm_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len)
|
||||
{
|
||||
switch (*len) {
|
||||
case 0:
|
||||
@@ -318,7 +318,7 @@ nm_utils_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_
|
||||
}
|
||||
|
||||
void
|
||||
nm_utils_strbuf_append_str(char **buf, gsize *len, const char *str)
|
||||
nm_strbuf_append_str(char **buf, gsize *len, const char *str)
|
||||
{
|
||||
gsize src_len;
|
||||
|
||||
@@ -352,7 +352,7 @@ nm_utils_strbuf_append_str(char **buf, gsize *len, const char *str)
|
||||
}
|
||||
|
||||
void
|
||||
nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...)
|
||||
nm_strbuf_append(char **buf, gsize *len, const char *format, ...)
|
||||
{
|
||||
char * p = *buf;
|
||||
va_list args;
|
||||
@@ -375,25 +375,25 @@ nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...)
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_strbuf_seek_end:
|
||||
* nm_strbuf_seek_end:
|
||||
* @buf: the input/output buffer
|
||||
* @len: the input/output length of the buffer.
|
||||
*
|
||||
* Commonly, one uses nm_utils_strbuf_append*(), to incrementally
|
||||
* Commonly, one uses nm_strbuf_append*(), to incrementally
|
||||
* append strings to the buffer. However, sometimes we need to use
|
||||
* existing API to write to the buffer.
|
||||
* After doing so, we want to adjust the buffer counter.
|
||||
* Essentially,
|
||||
*
|
||||
* g_snprintf (buf, len, ...);
|
||||
* nm_utils_strbuf_seek_end (&buf, &len);
|
||||
* nm_strbuf_seek_end (&buf, &len);
|
||||
*
|
||||
* is almost the same as
|
||||
*
|
||||
* nm_utils_strbuf_append (&buf, &len, ...);
|
||||
* nm_strbuf_append (&buf, &len, ...);
|
||||
*
|
||||
* The only difference is the behavior when the string got truncated:
|
||||
* nm_utils_strbuf_append() will recognize that and set the remaining
|
||||
* nm_strbuf_append() will recognize that and set the remaining
|
||||
* length to zero.
|
||||
*
|
||||
* In general, the behavior is:
|
||||
@@ -411,13 +411,13 @@ nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...)
|
||||
* the NUL byte. This would happen with
|
||||
*
|
||||
* strncpy (buf, long_str, len);
|
||||
* nm_utils_strbuf_seek_end (&buf, &len).
|
||||
* nm_strbuf_seek_end (&buf, &len).
|
||||
*
|
||||
* where strncpy() does truncate the string and not NUL terminate it.
|
||||
* nm_utils_strbuf_seek_end() would then NUL terminate it.
|
||||
* nm_strbuf_seek_end() would then NUL terminate it.
|
||||
*/
|
||||
void
|
||||
nm_utils_strbuf_seek_end(char **buf, gsize *len)
|
||||
nm_strbuf_seek_end(char **buf, gsize *len)
|
||||
{
|
||||
gsize l;
|
||||
char *end;
|
||||
@@ -714,7 +714,7 @@ nm_strquote(char *buf, gsize buf_len, const char *str)
|
||||
const char *const buf0 = buf;
|
||||
|
||||
if (!str) {
|
||||
nm_utils_strbuf_append_str(&buf, &buf_len, "(null)");
|
||||
nm_strbuf_append_str(&buf, &buf_len, "(null)");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ nm_strquote(char *buf, gsize buf_len, const char *str)
|
||||
*(buf++) = '"';
|
||||
buf_len--;
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &buf_len, str);
|
||||
nm_strbuf_append_str(&buf, &buf_len, str);
|
||||
|
||||
/* if the string was too long we indicate truncation with a
|
||||
* '^' instead of a closing quote. */
|
||||
@@ -817,7 +817,7 @@ nm_utils_flags2str(const NMUtilsFlags2StrDesc *descs,
|
||||
if (!flags) {
|
||||
for (i = 0; i < n_descs; i++) {
|
||||
if (!descs[i].flag) {
|
||||
nm_utils_strbuf_append_str(&p, &len, descs[i].name);
|
||||
nm_strbuf_append_str(&p, &len, descs[i].name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -829,14 +829,14 @@ nm_utils_flags2str(const NMUtilsFlags2StrDesc *descs,
|
||||
flags &= ~descs[i].flag;
|
||||
|
||||
if (buf[0] != '\0')
|
||||
nm_utils_strbuf_append_c(&p, &len, ',');
|
||||
nm_utils_strbuf_append_str(&p, &len, descs[i].name);
|
||||
nm_strbuf_append_c(&p, &len, ',');
|
||||
nm_strbuf_append_str(&p, &len, descs[i].name);
|
||||
}
|
||||
}
|
||||
if (flags) {
|
||||
if (buf[0] != '\0')
|
||||
nm_utils_strbuf_append_c(&p, &len, ',');
|
||||
nm_utils_strbuf_append(&p, &len, "0x%x", flags);
|
||||
nm_strbuf_append_c(&p, &len, ',');
|
||||
nm_strbuf_append(&p, &len, "0x%x", flags);
|
||||
}
|
||||
return buf;
|
||||
};
|
||||
|
@@ -565,25 +565,25 @@ extern const void *const _NM_PTRARRAY_EMPTY[1];
|
||||
#define NM_STRV_EMPTY_CC() NM_PTRARRAY_EMPTY(const char *)
|
||||
|
||||
static inline void
|
||||
_nm_utils_strbuf_init(char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len)
|
||||
nm_strbuf_init(char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len)
|
||||
{
|
||||
NM_SET_OUT(p_buf_len, len);
|
||||
NM_SET_OUT(p_buf_ptr, buf);
|
||||
buf[0] = '\0';
|
||||
}
|
||||
|
||||
#define nm_utils_strbuf_init(buf, p_buf_ptr, p_buf_len) \
|
||||
#define nm_strbuf_init_arr(buf, p_buf_ptr, p_buf_len) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
G_STATIC_ASSERT(G_N_ELEMENTS(buf) == sizeof(buf) && sizeof(buf) > sizeof(char *)); \
|
||||
_nm_utils_strbuf_init((buf), sizeof(buf), (p_buf_ptr), (p_buf_len)); \
|
||||
nm_strbuf_init((buf), sizeof(buf), (p_buf_ptr), (p_buf_len)); \
|
||||
} \
|
||||
G_STMT_END
|
||||
void nm_utils_strbuf_append(char **buf, gsize *len, const char *format, ...) _nm_printf(3, 4);
|
||||
void nm_utils_strbuf_append_c(char **buf, gsize *len, char c);
|
||||
void nm_utils_strbuf_append_str(char **buf, gsize *len, const char *str);
|
||||
void nm_utils_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len);
|
||||
void nm_utils_strbuf_seek_end(char **buf, gsize *len);
|
||||
void nm_strbuf_append(char **buf, gsize *len, const char *format, ...) _nm_printf(3, 4);
|
||||
void nm_strbuf_append_c(char **buf, gsize *len, char c);
|
||||
void nm_strbuf_append_str(char **buf, gsize *len, const char *str);
|
||||
void nm_strbuf_append_bin(char **buf, gsize *len, gconstpointer str, gsize str_len);
|
||||
void nm_strbuf_seek_end(char **buf, gsize *len);
|
||||
|
||||
const char *nm_strquote(char *buf, gsize buf_len, const char *str);
|
||||
|
||||
|
@@ -525,16 +525,16 @@ again:
|
||||
buf_p = _all_logging_domains_to_str;
|
||||
buf_l = sizeof(_all_logging_domains_to_str);
|
||||
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, LOGD_DEFAULT_STRING);
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, LOGD_DEFAULT_STRING);
|
||||
for (diter = &domain_desc[0]; diter->name; diter++) {
|
||||
nm_utils_strbuf_append_c(&buf_p, &buf_l, ',');
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, diter->name);
|
||||
nm_strbuf_append_c(&buf_p, &buf_l, ',');
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, diter->name);
|
||||
if (diter->num == LOGD_DHCP6)
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, "," LOGD_DHCP_STRING);
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, "," LOGD_DHCP_STRING);
|
||||
else if (diter->num == LOGD_IP6)
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, "," LOGD_IP_STRING);
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, "," LOGD_IP_STRING);
|
||||
}
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_l, LOGD_ALL_STRING);
|
||||
nm_strbuf_append_str(&buf_p, &buf_l, LOGD_ALL_STRING);
|
||||
|
||||
/* Did you modify the logging domains (or their names)? Adjust the size of
|
||||
* _all_logging_domains_to_str buffer above to have the exact size. */
|
||||
@@ -746,13 +746,13 @@ _nm_log_impl(const char *file,
|
||||
s_log_domains = s_log_domains_buf;
|
||||
l_log_domains = sizeof(s_log_domains_buf);
|
||||
|
||||
nm_utils_strbuf_append_str(&s_log_domains, &l_log_domains, "NM_LOG_DOMAINS=");
|
||||
nm_strbuf_append_str(&s_log_domains, &l_log_domains, "NM_LOG_DOMAINS=");
|
||||
for (diter = &domain_desc[0]; dom_all != 0 && diter->name; diter++) {
|
||||
if (!NM_FLAGS_ANY(dom_all, diter->num))
|
||||
continue;
|
||||
if (dom_all != domain)
|
||||
nm_utils_strbuf_append_c(&s_log_domains, &l_log_domains, ',');
|
||||
nm_utils_strbuf_append_str(&s_log_domains, &l_log_domains, diter->name);
|
||||
nm_strbuf_append_c(&s_log_domains, &l_log_domains, ',');
|
||||
nm_strbuf_append_str(&s_log_domains, &l_log_domains, diter->name);
|
||||
dom_all &= ~diter->num;
|
||||
}
|
||||
nm_assert(l_log_domains > 0);
|
||||
|
@@ -582,25 +582,25 @@ wait_for_nl_response_to_string(WaitForNlResponseResult seq_result,
|
||||
|
||||
switch (seq_result) {
|
||||
case WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN:
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, "unknown");
|
||||
nm_strbuf_append_str(&buf, &buf_size, "unknown");
|
||||
break;
|
||||
case WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_OK:
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, "success");
|
||||
nm_strbuf_append_str(&buf, &buf_size, "success");
|
||||
break;
|
||||
case WAIT_FOR_NL_RESPONSE_RESULT_RESPONSE_UNKNOWN:
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, "failure");
|
||||
nm_strbuf_append_str(&buf, &buf_size, "failure");
|
||||
break;
|
||||
default:
|
||||
if (seq_result < 0) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&buf_size,
|
||||
"failure %d (%s%s%s)",
|
||||
-((int) seq_result),
|
||||
nm_strerror_native(-((int) seq_result)),
|
||||
errmsg ? " - " : "",
|
||||
errmsg ?: "");
|
||||
nm_strbuf_append(&buf,
|
||||
&buf_size,
|
||||
"failure %d (%s%s%s)",
|
||||
-((int) seq_result),
|
||||
nm_strerror_native(-((int) seq_result)),
|
||||
errmsg ? " - " : "",
|
||||
errmsg ?: "");
|
||||
} else
|
||||
nm_utils_strbuf_append(&buf, &buf_size, "internal failure %d", (int) seq_result);
|
||||
nm_strbuf_append(&buf, &buf_size, "internal failure %d", (int) seq_result);
|
||||
break;
|
||||
}
|
||||
return buf0;
|
||||
@@ -5811,13 +5811,13 @@ delayed_action_to_string_full(DelayedActionType action_type,
|
||||
char * buf0 = buf;
|
||||
const DelayedActionWaitForNlResponseData *data;
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, delayed_action_to_string(action_type));
|
||||
nm_strbuf_append_str(&buf, &buf_size, delayed_action_to_string(action_type));
|
||||
switch (action_type) {
|
||||
case DELAYED_ACTION_TYPE_MASTER_CONNECTED:
|
||||
nm_utils_strbuf_append(&buf, &buf_size, " (master-ifindex %d)", GPOINTER_TO_INT(user_data));
|
||||
nm_strbuf_append(&buf, &buf_size, " (master-ifindex %d)", GPOINTER_TO_INT(user_data));
|
||||
break;
|
||||
case DELAYED_ACTION_TYPE_REFRESH_LINK:
|
||||
nm_utils_strbuf_append(&buf, &buf_size, " (ifindex %d)", GPOINTER_TO_INT(user_data));
|
||||
nm_strbuf_append(&buf, &buf_size, " (ifindex %d)", GPOINTER_TO_INT(user_data));
|
||||
break;
|
||||
case DELAYED_ACTION_TYPE_WAIT_FOR_NL_RESPONSE:
|
||||
data = user_data;
|
||||
@@ -5826,7 +5826,7 @@ delayed_action_to_string_full(DelayedActionType action_type,
|
||||
gint64 timeout = data->timeout_abs_ns - nm_utils_get_monotonic_timestamp_nsec();
|
||||
char b[255];
|
||||
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&buf,
|
||||
&buf_size,
|
||||
" (seq %u, timeout in %s%" G_GINT64_FORMAT ".%09" G_GINT64_FORMAT
|
||||
@@ -5841,7 +5841,7 @@ delayed_action_to_string_full(DelayedActionType action_type,
|
||||
? wait_for_nl_response_to_string(data->seq_result, NULL, b, sizeof(b))
|
||||
: "");
|
||||
} else
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, " (any)");
|
||||
nm_strbuf_append_str(&buf, &buf_size, " (any)");
|
||||
break;
|
||||
default:
|
||||
nm_assert(!user_data);
|
||||
|
@@ -162,28 +162,28 @@ nl_nlmsghdr_to_str(const struct nlmsghdr *hdr, char *buf, gsize len)
|
||||
}
|
||||
|
||||
if (s)
|
||||
nm_utils_strbuf_append_str(&buf, &len, s);
|
||||
nm_strbuf_append_str(&buf, &len, s);
|
||||
else
|
||||
nm_utils_strbuf_append(&buf, &len, "(%u)", (unsigned) hdr->nlmsg_type);
|
||||
nm_strbuf_append(&buf, &len, "(%u)", (unsigned) hdr->nlmsg_type);
|
||||
|
||||
flags = hdr->nlmsg_flags;
|
||||
|
||||
if (!flags) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, ", flags 0");
|
||||
nm_strbuf_append_str(&buf, &len, ", flags 0");
|
||||
goto flags_done;
|
||||
}
|
||||
|
||||
#define _F(f, n) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
if (NM_FLAGS_ALL(flags, f)) { \
|
||||
flags &= ~(f); \
|
||||
nm_utils_strbuf_append(&buf, &len, "%s%s", prefix, n); \
|
||||
if (!flags) \
|
||||
goto flags_done; \
|
||||
prefix = ","; \
|
||||
} \
|
||||
} \
|
||||
#define _F(f, n) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
if (NM_FLAGS_ALL(flags, f)) { \
|
||||
flags &= ~(f); \
|
||||
nm_strbuf_append(&buf, &len, "%s%s", prefix, n); \
|
||||
if (!flags) \
|
||||
goto flags_done; \
|
||||
prefix = ","; \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
prefix = ", flags ";
|
||||
@@ -225,11 +225,11 @@ nl_nlmsghdr_to_str(const struct nlmsghdr *hdr, char *buf, gsize len)
|
||||
|
||||
if (flags_before != flags)
|
||||
prefix = ";";
|
||||
nm_utils_strbuf_append(&buf, &len, "%s0x%04x", prefix, flags);
|
||||
nm_strbuf_append(&buf, &len, "%s0x%04x", prefix, flags);
|
||||
|
||||
flags_done:
|
||||
|
||||
nm_utils_strbuf_append(&buf, &len, ", seq %u", (unsigned) hdr->nlmsg_seq);
|
||||
nm_strbuf_append(&buf, &len, ", seq %u", (unsigned) hdr->nlmsg_seq);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
@@ -1229,25 +1229,25 @@ nm_platform_link_add(NMPlatform * self,
|
||||
|
||||
switch (type) {
|
||||
case NM_LINK_TYPE_BRIDGE:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_bridge_to_string((const NMPlatformLnkBridge *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_VLAN:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_vlan_to_string((const NMPlatformLnkVlan *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_VRF:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_vrf_to_string((const NMPlatformLnkVrf *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_VXLAN:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_vxlan_to_string((const NMPlatformLnkVxlan *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
@@ -1257,13 +1257,13 @@ nm_platform_link_add(NMPlatform * self,
|
||||
break;
|
||||
case NM_LINK_TYPE_GRE:
|
||||
case NM_LINK_TYPE_GRETAP:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_gre_to_string((const NMPlatformLnkGre *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_SIT:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_sit_to_string((const NMPlatformLnkSit *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
@@ -1271,26 +1271,26 @@ nm_platform_link_add(NMPlatform * self,
|
||||
case NM_LINK_TYPE_IP6TNL:
|
||||
case NM_LINK_TYPE_IP6GRE:
|
||||
case NM_LINK_TYPE_IP6GRETAP:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_ip6tnl_to_string((const NMPlatformLnkIp6Tnl *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_IPIP:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_ipip_to_string((const NMPlatformLnkIpIp *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_MACSEC:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_macsec_to_string((const NMPlatformLnkMacsec *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
break;
|
||||
case NM_LINK_TYPE_MACVLAN:
|
||||
case NM_LINK_TYPE_MACVTAP:
|
||||
nm_utils_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_strbuf_append_str(&buf_p, &buf_len, ", ");
|
||||
nm_platform_lnk_macvlan_to_string((const NMPlatformLnkMacvlan *) extra_data,
|
||||
buf_p,
|
||||
buf_len);
|
||||
@@ -2336,13 +2336,13 @@ nm_platform_link_wireguard_change(NMPlatform * self
|
||||
gsize len = sizeof(buf_peers);
|
||||
guint i;
|
||||
|
||||
nm_utils_strbuf_append_str(&b, &len, " { ");
|
||||
nm_strbuf_append_str(&b, &len, " { ");
|
||||
for (i = 0; i < peers_len; i++) {
|
||||
nm_utils_strbuf_append_str(&b, &len, " { ");
|
||||
nm_strbuf_append_str(&b, &len, " { ");
|
||||
nm_platform_wireguard_peer_to_string(&peers[i], b, len);
|
||||
nm_utils_strbuf_seek_end(&b, &len);
|
||||
nm_strbuf_seek_end(&b, &len);
|
||||
if (peer_flags) {
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&b,
|
||||
&len,
|
||||
" (%s)",
|
||||
@@ -2350,9 +2350,9 @@ nm_platform_link_wireguard_change(NMPlatform * self
|
||||
buf_change_flags,
|
||||
sizeof(buf_change_flags)));
|
||||
}
|
||||
nm_utils_strbuf_append_str(&b, &len, " } ");
|
||||
nm_strbuf_append_str(&b, &len, " } ");
|
||||
}
|
||||
nm_utils_strbuf_append_str(&b, &len, "}");
|
||||
nm_strbuf_append_str(&b, &len, "}");
|
||||
}
|
||||
|
||||
_LOG3D("link: change wireguard ifindex %d, %s, (%s), %u peers%s",
|
||||
@@ -2620,30 +2620,30 @@ nm_platform_link_vlan_change(NMPlatform * self,
|
||||
len = sizeof(buf);
|
||||
|
||||
if (flags_mask)
|
||||
nm_utils_strbuf_append(&b,
|
||||
&len,
|
||||
" flags 0x%x/0x%x",
|
||||
(unsigned) flags_set,
|
||||
(unsigned) flags_mask);
|
||||
nm_strbuf_append(&b,
|
||||
&len,
|
||||
" flags 0x%x/0x%x",
|
||||
(unsigned) flags_set,
|
||||
(unsigned) flags_mask);
|
||||
|
||||
if (ingress_reset_all || n_ingress_map) {
|
||||
nm_utils_strbuf_append_str(&b, &len, " ingress-qos-map");
|
||||
nm_strbuf_append_str(&b, &len, " ingress-qos-map");
|
||||
nm_platform_vlan_qos_mapping_to_string("", ingress_map, n_ingress_map, b, len);
|
||||
i = strlen(b);
|
||||
b += i;
|
||||
len -= i;
|
||||
if (ingress_reset_all)
|
||||
nm_utils_strbuf_append_str(&b, &len, " (reset-all)");
|
||||
nm_strbuf_append_str(&b, &len, " (reset-all)");
|
||||
}
|
||||
|
||||
if (egress_reset_all || n_egress_map) {
|
||||
nm_utils_strbuf_append_str(&b, &len, " egress-qos-map");
|
||||
nm_strbuf_append_str(&b, &len, " egress-qos-map");
|
||||
nm_platform_vlan_qos_mapping_to_string("", egress_map, n_egress_map, b, len);
|
||||
i = strlen(b);
|
||||
b += i;
|
||||
len -= i;
|
||||
if (egress_reset_all)
|
||||
nm_utils_strbuf_append_str(&b, &len, " (reset-all)");
|
||||
nm_strbuf_append_str(&b, &len, " (reset-all)");
|
||||
}
|
||||
|
||||
_LOG3D("link: change vlan %s", buf);
|
||||
@@ -5454,7 +5454,7 @@ nm_platform_vlan_qos_mapping_to_string(const char * name,
|
||||
nm_utils_to_string_buffer_init(&buf, &len);
|
||||
|
||||
if (!n_map) {
|
||||
nm_utils_strbuf_append_str(&buf, &len, "");
|
||||
nm_strbuf_append_str(&buf, &len, "");
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -5464,14 +5464,14 @@ nm_platform_vlan_qos_mapping_to_string(const char * name,
|
||||
b = buf;
|
||||
|
||||
if (name) {
|
||||
nm_utils_strbuf_append_str(&b, &len, name);
|
||||
nm_utils_strbuf_append_str(&b, &len, " {");
|
||||
nm_strbuf_append_str(&b, &len, name);
|
||||
nm_strbuf_append_str(&b, &len, " {");
|
||||
} else
|
||||
nm_utils_strbuf_append_c(&b, &len, '{');
|
||||
nm_strbuf_append_c(&b, &len, '{');
|
||||
|
||||
for (i = 0; i < n_map; i++)
|
||||
nm_utils_strbuf_append(&b, &len, " %u:%u", map[i].from, map[i].to);
|
||||
nm_utils_strbuf_append_str(&b, &len, " }");
|
||||
nm_strbuf_append(&b, &len, " %u:%u", map[i].from, map[i].to);
|
||||
nm_strbuf_append_str(&b, &len, " }");
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -5537,13 +5537,13 @@ nm_platform_link_to_string(const NMPlatformLink *link, char *buf, gsize len)
|
||||
s = str_highlighted_flags;
|
||||
l = sizeof(str_highlighted_flags);
|
||||
if (NM_FLAGS_HAS(link->n_ifi_flags, IFF_NOARP))
|
||||
nm_utils_strbuf_append_str(&s, &l, "NOARP,");
|
||||
nm_strbuf_append_str(&s, &l, "NOARP,");
|
||||
if (NM_FLAGS_HAS(link->n_ifi_flags, IFF_UP))
|
||||
nm_utils_strbuf_append_str(&s, &l, "UP");
|
||||
nm_strbuf_append_str(&s, &l, "UP");
|
||||
else
|
||||
nm_utils_strbuf_append_str(&s, &l, "DOWN");
|
||||
nm_strbuf_append_str(&s, &l, "DOWN");
|
||||
if (link->connected)
|
||||
nm_utils_strbuf_append_str(&s, &l, ",LOWER_UP");
|
||||
nm_strbuf_append_str(&s, &l, ",LOWER_UP");
|
||||
nm_assert(s > str_highlighted_flags && l > 0);
|
||||
|
||||
if (link->n_ifi_flags) {
|
||||
@@ -6028,9 +6028,9 @@ nm_platform_lnk_vlan_to_string(const NMPlatformLnkVlan *lnk, char *buf, gsize le
|
||||
|
||||
b = buf;
|
||||
|
||||
nm_utils_strbuf_append(&b, &len, "vlan %u", lnk->id);
|
||||
nm_strbuf_append(&b, &len, "vlan %u", lnk->id);
|
||||
if (lnk->flags)
|
||||
nm_utils_strbuf_append(&b, &len, " flags 0x%x", lnk->flags);
|
||||
nm_strbuf_append(&b, &len, " flags 0x%x", lnk->flags);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -6044,7 +6044,7 @@ nm_platform_lnk_vrf_to_string(const NMPlatformLnkVrf *lnk, char *buf, gsize len)
|
||||
|
||||
b = buf;
|
||||
|
||||
nm_utils_strbuf_append(&b, &len, "table %u", lnk->table);
|
||||
nm_strbuf_append(&b, &len, "table %u", lnk->table);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -6169,36 +6169,36 @@ nm_platform_wireguard_peer_to_string(const NMPWireGuardPeer *peer, char *buf, gs
|
||||
} else
|
||||
s_endpoint[0] = '\0';
|
||||
|
||||
nm_utils_strbuf_append(
|
||||
&buf,
|
||||
&len,
|
||||
"public-key %s"
|
||||
"%s" /* preshared-key */
|
||||
"%s" /* endpoint */
|
||||
" rx %" G_GUINT64_FORMAT " tx %" G_GUINT64_FORMAT "%s" /* persistent-keepalive */
|
||||
"%s", /* allowed-ips */
|
||||
public_key_b64,
|
||||
nm_utils_memeqzero_secret(peer->preshared_key, sizeof(peer->preshared_key))
|
||||
? ""
|
||||
: " preshared-key (hidden)",
|
||||
s_endpoint,
|
||||
peer->rx_bytes,
|
||||
peer->tx_bytes,
|
||||
peer->persistent_keepalive_interval > 0
|
||||
? nm_sprintf_buf(s_keepalive,
|
||||
" keepalive %u",
|
||||
(guint) peer->persistent_keepalive_interval)
|
||||
: "",
|
||||
peer->allowed_ips_len > 0 ? " allowed-ips" : "");
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"public-key %s"
|
||||
"%s" /* preshared-key */
|
||||
"%s" /* endpoint */
|
||||
" rx %" G_GUINT64_FORMAT " tx %" G_GUINT64_FORMAT
|
||||
"%s" /* persistent-keepalive */
|
||||
"%s", /* allowed-ips */
|
||||
public_key_b64,
|
||||
nm_utils_memeqzero_secret(peer->preshared_key, sizeof(peer->preshared_key))
|
||||
? ""
|
||||
: " preshared-key (hidden)",
|
||||
s_endpoint,
|
||||
peer->rx_bytes,
|
||||
peer->tx_bytes,
|
||||
peer->persistent_keepalive_interval > 0
|
||||
? nm_sprintf_buf(s_keepalive,
|
||||
" keepalive %u",
|
||||
(guint) peer->persistent_keepalive_interval)
|
||||
: "",
|
||||
peer->allowed_ips_len > 0 ? " allowed-ips" : "");
|
||||
|
||||
for (i = 0; i < peer->allowed_ips_len; i++) {
|
||||
const NMPWireGuardAllowedIP *allowed_ip = &peer->allowed_ips[i];
|
||||
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" %s/%u",
|
||||
nm_utils_inet_ntop(allowed_ip->family, &allowed_ip->addr, s_addr),
|
||||
allowed_ip->mask);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" %s/%u",
|
||||
nm_utils_inet_ntop(allowed_ip->family, &allowed_ip->addr, s_addr),
|
||||
allowed_ip->mask);
|
||||
}
|
||||
|
||||
return buf0;
|
||||
@@ -6490,7 +6490,7 @@ _rtm_flags_to_string_full(char *buf, gsize buf_size, unsigned rtm_flags)
|
||||
if (!rtm_flags)
|
||||
return "";
|
||||
|
||||
nm_utils_strbuf_append_str(&buf, &buf_size, " rtm_flags ");
|
||||
nm_strbuf_append_str(&buf, &buf_size, " rtm_flags ");
|
||||
_rtm_flags_to_string(rtm_flags, buf, buf_size);
|
||||
nm_assert(strlen(buf) < buf_size);
|
||||
return buf0;
|
||||
@@ -6762,18 +6762,18 @@ _routing_rule_addr_to_string(char ** buf,
|
||||
|
||||
if (plen == 0 && is_zero) {
|
||||
if (is_src)
|
||||
nm_utils_strbuf_append_str(buf, len, " from all");
|
||||
nm_strbuf_append_str(buf, len, " from all");
|
||||
else
|
||||
nm_utils_strbuf_append_str(buf, len, "");
|
||||
nm_strbuf_append_str(buf, len, "");
|
||||
return;
|
||||
}
|
||||
|
||||
nm_utils_strbuf_append_str(buf, len, is_src ? " from " : " to ");
|
||||
nm_strbuf_append_str(buf, len, is_src ? " from " : " to ");
|
||||
|
||||
nm_utils_strbuf_append_str(buf, len, nm_utils_inet_ntop(addr_family, addr, s_addr));
|
||||
nm_strbuf_append_str(buf, len, nm_utils_inet_ntop(addr_family, addr, s_addr));
|
||||
|
||||
if (plen != (addr_size * 8))
|
||||
nm_utils_strbuf_append(buf, len, "/%u", plen);
|
||||
nm_strbuf_append(buf, len, "/%u", plen);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -6783,11 +6783,11 @@ _routing_rule_port_range_to_string(char ** buf,
|
||||
const char * name)
|
||||
{
|
||||
if (port_range->start == 0 && port_range->end == 0)
|
||||
nm_utils_strbuf_append_str(buf, len, "");
|
||||
nm_strbuf_append_str(buf, len, "");
|
||||
else {
|
||||
nm_utils_strbuf_append(buf, len, " %s %u", name, port_range->start);
|
||||
nm_strbuf_append(buf, len, " %s %u", name, port_range->start);
|
||||
if (port_range->start != port_range->end)
|
||||
nm_utils_strbuf_append(buf, len, "-%u", port_range->end);
|
||||
nm_strbuf_append(buf, len, "-%u", port_range->end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6814,14 +6814,14 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
||||
rr_flags = routing_rule->flags;
|
||||
|
||||
rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_INVERT);
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"[%c] " /* addr-family */
|
||||
"%u:" /* priority */
|
||||
"%s", /* not/FIB_RULE_INVERT */
|
||||
nm_utils_addr_family_to_char(routing_rule->addr_family),
|
||||
routing_rule->priority,
|
||||
(NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_INVERT) ? " not" : ""));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"[%c] " /* addr-family */
|
||||
"%u:" /* priority */
|
||||
"%s", /* not/FIB_RULE_INVERT */
|
||||
nm_utils_addr_family_to_char(routing_rule->addr_family),
|
||||
routing_rule->priority,
|
||||
(NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_INVERT) ? " not" : ""));
|
||||
|
||||
_routing_rule_addr_to_string(&buf,
|
||||
&len,
|
||||
@@ -6838,53 +6838,53 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
||||
FALSE);
|
||||
|
||||
if (routing_rule->tos)
|
||||
nm_utils_strbuf_append(&buf, &len, " tos 0x%02x", routing_rule->tos);
|
||||
nm_strbuf_append(&buf, &len, " tos 0x%02x", routing_rule->tos);
|
||||
|
||||
if (routing_rule->fwmark != 0 || routing_rule->fwmask != 0) {
|
||||
nm_utils_strbuf_append(&buf, &len, " fwmark %#x", (unsigned) routing_rule->fwmark);
|
||||
nm_strbuf_append(&buf, &len, " fwmark %#x", (unsigned) routing_rule->fwmark);
|
||||
if (routing_rule->fwmark != 0xFFFFFFFFu)
|
||||
nm_utils_strbuf_append(&buf, &len, "/%#x", (unsigned) routing_rule->fwmask);
|
||||
nm_strbuf_append(&buf, &len, "/%#x", (unsigned) routing_rule->fwmask);
|
||||
}
|
||||
|
||||
if (routing_rule->iifname[0]) {
|
||||
nm_utils_strbuf_append(&buf, &len, " iif %s", routing_rule->iifname);
|
||||
nm_strbuf_append(&buf, &len, " iif %s", routing_rule->iifname);
|
||||
rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_IIF_DETACHED);
|
||||
if (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_IIF_DETACHED))
|
||||
nm_utils_strbuf_append_str(&buf, &len, " [detached]");
|
||||
nm_strbuf_append_str(&buf, &len, " [detached]");
|
||||
}
|
||||
|
||||
if (routing_rule->oifname[0]) {
|
||||
nm_utils_strbuf_append(&buf, &len, " oif %s", routing_rule->oifname);
|
||||
nm_strbuf_append(&buf, &len, " oif %s", routing_rule->oifname);
|
||||
rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_OIF_DETACHED);
|
||||
if (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_OIF_DETACHED))
|
||||
nm_utils_strbuf_append_str(&buf, &len, " [detached]");
|
||||
nm_strbuf_append_str(&buf, &len, " [detached]");
|
||||
}
|
||||
|
||||
if (routing_rule->l3mdev != 0) {
|
||||
if (routing_rule->l3mdev == 1)
|
||||
nm_utils_strbuf_append_str(&buf, &len, " lookup [l3mdev-table]");
|
||||
nm_strbuf_append_str(&buf, &len, " lookup [l3mdev-table]");
|
||||
else {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" lookup [l3mdev-table/%u]",
|
||||
(unsigned) routing_rule->l3mdev);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" lookup [l3mdev-table/%u]",
|
||||
(unsigned) routing_rule->l3mdev);
|
||||
}
|
||||
}
|
||||
|
||||
if (routing_rule->uid_range_has || routing_rule->uid_range.start
|
||||
|| routing_rule->uid_range.end) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" uidrange %u-%u%s",
|
||||
routing_rule->uid_range.start,
|
||||
routing_rule->uid_range.end,
|
||||
routing_rule->uid_range_has ? "" : "(?)");
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" uidrange %u-%u%s",
|
||||
routing_rule->uid_range.start,
|
||||
routing_rule->uid_range.end,
|
||||
routing_rule->uid_range_has ? "" : "(?)");
|
||||
}
|
||||
|
||||
if (routing_rule->ip_proto != 0) {
|
||||
/* we don't call getprotobynumber(), just print the numeric value.
|
||||
* This differs from what ip-rule prints. */
|
||||
nm_utils_strbuf_append(&buf, &len, " ipproto %u", routing_rule->ip_proto);
|
||||
nm_strbuf_append(&buf, &len, " ipproto %u", routing_rule->ip_proto);
|
||||
}
|
||||
|
||||
_routing_rule_port_range_to_string(&buf, &len, &routing_rule->sport_range, "sport");
|
||||
@@ -6892,25 +6892,25 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
||||
_routing_rule_port_range_to_string(&buf, &len, &routing_rule->dport_range, "dport");
|
||||
|
||||
if (routing_rule->tun_id != 0) {
|
||||
nm_utils_strbuf_append(&buf, &len, " tun_id %" G_GUINT64_FORMAT, routing_rule->tun_id);
|
||||
nm_strbuf_append(&buf, &len, " tun_id %" G_GUINT64_FORMAT, routing_rule->tun_id);
|
||||
}
|
||||
|
||||
if (routing_rule->table != 0) {
|
||||
nm_utils_strbuf_append(&buf, &len, " lookup %u", routing_rule->table);
|
||||
nm_strbuf_append(&buf, &len, " lookup %u", routing_rule->table);
|
||||
}
|
||||
|
||||
if (routing_rule->suppress_prefixlen_inverse != 0) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" suppress_prefixlen %d",
|
||||
(int) (~routing_rule->suppress_prefixlen_inverse));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" suppress_prefixlen %d",
|
||||
(int) (~routing_rule->suppress_prefixlen_inverse));
|
||||
}
|
||||
|
||||
if (routing_rule->suppress_ifgroup_inverse != 0) {
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" suppress_ifgroup %d",
|
||||
(int) (~routing_rule->suppress_ifgroup_inverse));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" suppress_ifgroup %d",
|
||||
(int) (~routing_rule->suppress_ifgroup_inverse));
|
||||
}
|
||||
|
||||
if (routing_rule->flow) {
|
||||
@@ -6919,7 +6919,7 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
||||
*
|
||||
* We don't follow the style how ip-rule prints flow/realms. It's confusing. Just
|
||||
* print the value hex. */
|
||||
nm_utils_strbuf_append(&buf, &len, " realms 0x%08x", routing_rule->flow);
|
||||
nm_strbuf_append(&buf, &len, " realms 0x%08x", routing_rule->flow);
|
||||
}
|
||||
|
||||
if (routing_rule->action == RTN_NAT) {
|
||||
@@ -6927,36 +6927,36 @@ nm_platform_routing_rule_to_string(const NMPlatformRoutingRule *routing_rule, ch
|
||||
|
||||
/* NAT is deprecated for many years. We don't support RTA_GATEWAY/FRA_UNUSED2
|
||||
* for the gateway, and so do recent kernels ignore that parameter. */
|
||||
nm_utils_strbuf_append_str(&buf, &len, " masquerade");
|
||||
nm_strbuf_append_str(&buf, &len, " masquerade");
|
||||
} else if (routing_rule->action == FR_ACT_GOTO) {
|
||||
if (routing_rule->goto_target != 0)
|
||||
nm_utils_strbuf_append(&buf, &len, " goto %u", routing_rule->goto_target);
|
||||
nm_strbuf_append(&buf, &len, " goto %u", routing_rule->goto_target);
|
||||
else
|
||||
nm_utils_strbuf_append_str(&buf, &len, " goto none");
|
||||
nm_strbuf_append_str(&buf, &len, " goto none");
|
||||
rr_flags = NM_FLAGS_UNSET(rr_flags, FIB_RULE_UNRESOLVED);
|
||||
if (NM_FLAGS_HAS(routing_rule->flags, FIB_RULE_UNRESOLVED))
|
||||
nm_utils_strbuf_append_str(&buf, &len, " unresolved");
|
||||
nm_strbuf_append_str(&buf, &len, " unresolved");
|
||||
} else if (routing_rule->action != FR_ACT_TO_TBL) {
|
||||
char ss_buf[60];
|
||||
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
" %s",
|
||||
nm_net_aux_rtnl_rtntype_n2a(routing_rule->action)
|
||||
?: nm_sprintf_buf(ss_buf, "action-%u", routing_rule->action));
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
" %s",
|
||||
nm_net_aux_rtnl_rtntype_n2a(routing_rule->action)
|
||||
?: nm_sprintf_buf(ss_buf, "action-%u", routing_rule->action));
|
||||
}
|
||||
|
||||
if (routing_rule->protocol != RTPROT_UNSPEC)
|
||||
nm_utils_strbuf_append(&buf, &len, " protocol %u", routing_rule->protocol);
|
||||
nm_strbuf_append(&buf, &len, " protocol %u", routing_rule->protocol);
|
||||
|
||||
if (routing_rule->goto_target != 0 && routing_rule->action != FR_ACT_GOTO) {
|
||||
/* a trailing target is set for an unexpected action. Print it. */
|
||||
nm_utils_strbuf_append(&buf, &len, " goto-target %u", routing_rule->goto_target);
|
||||
nm_strbuf_append(&buf, &len, " goto-target %u", routing_rule->goto_target);
|
||||
}
|
||||
|
||||
if (rr_flags != 0) {
|
||||
/* we have some flags we didn't print about yet. */
|
||||
nm_utils_strbuf_append(&buf, &len, " remaining-flags %x", rr_flags);
|
||||
nm_strbuf_append(&buf, &len, " remaining-flags %x", rr_flags);
|
||||
}
|
||||
|
||||
return buf0;
|
||||
@@ -6973,53 +6973,53 @@ nm_platform_qdisc_to_string(const NMPlatformQdisc *qdisc, char *buf, gsize len)
|
||||
|
||||
buf0 = buf;
|
||||
|
||||
nm_utils_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s%s family %u handle %x parent %x info %x",
|
||||
qdisc->kind,
|
||||
_to_string_dev(NULL, qdisc->ifindex, str_dev, sizeof(str_dev)),
|
||||
qdisc->addr_family,
|
||||
qdisc->handle,
|
||||
qdisc->parent,
|
||||
qdisc->info);
|
||||
nm_strbuf_append(&buf,
|
||||
&len,
|
||||
"%s%s family %u handle %x parent %x info %x",
|
||||
qdisc->kind,
|
||||
_to_string_dev(NULL, qdisc->ifindex, str_dev, sizeof(str_dev)),
|
||||
qdisc->addr_family,
|
||||
qdisc->handle,
|
||||
qdisc->parent,
|
||||
qdisc->info);
|
||||
|
||||
if (nm_streq0(qdisc->kind, "fq_codel")) {
|
||||
if (qdisc->fq_codel.limit)
|
||||
nm_utils_strbuf_append(&buf, &len, " limit %u", qdisc->fq_codel.limit);
|
||||
nm_strbuf_append(&buf, &len, " limit %u", qdisc->fq_codel.limit);
|
||||
if (qdisc->fq_codel.flows)
|
||||
nm_utils_strbuf_append(&buf, &len, " flows %u", qdisc->fq_codel.flows);
|
||||
nm_strbuf_append(&buf, &len, " flows %u", qdisc->fq_codel.flows);
|
||||
if (qdisc->fq_codel.target)
|
||||
nm_utils_strbuf_append(&buf, &len, " target %u", qdisc->fq_codel.target);
|
||||
nm_strbuf_append(&buf, &len, " target %u", qdisc->fq_codel.target);
|
||||
if (qdisc->fq_codel.interval)
|
||||
nm_utils_strbuf_append(&buf, &len, " interval %u", qdisc->fq_codel.interval);
|
||||
nm_strbuf_append(&buf, &len, " interval %u", qdisc->fq_codel.interval);
|
||||
if (qdisc->fq_codel.quantum)
|
||||
nm_utils_strbuf_append(&buf, &len, " quantum %u", qdisc->fq_codel.quantum);
|
||||
nm_strbuf_append(&buf, &len, " quantum %u", qdisc->fq_codel.quantum);
|
||||
if (qdisc->fq_codel.ce_threshold != NM_PLATFORM_FQ_CODEL_CE_THRESHOLD_DISABLED)
|
||||
nm_utils_strbuf_append(&buf, &len, " ce_threshold %u", qdisc->fq_codel.ce_threshold);
|
||||
nm_strbuf_append(&buf, &len, " ce_threshold %u", qdisc->fq_codel.ce_threshold);
|
||||
if (qdisc->fq_codel.memory_limit != NM_PLATFORM_FQ_CODEL_MEMORY_LIMIT_UNSET)
|
||||
nm_utils_strbuf_append(&buf, &len, " memory_limit %u", qdisc->fq_codel.memory_limit);
|
||||
nm_strbuf_append(&buf, &len, " memory_limit %u", qdisc->fq_codel.memory_limit);
|
||||
if (qdisc->fq_codel.ecn)
|
||||
nm_utils_strbuf_append(&buf, &len, " ecn");
|
||||
nm_strbuf_append(&buf, &len, " ecn");
|
||||
} else if (nm_streq0(qdisc->kind, "sfq")) {
|
||||
if (qdisc->sfq.quantum)
|
||||
nm_utils_strbuf_append(&buf, &len, " quantum %u", qdisc->sfq.quantum);
|
||||
nm_strbuf_append(&buf, &len, " quantum %u", qdisc->sfq.quantum);
|
||||
if (qdisc->sfq.perturb_period)
|
||||
nm_utils_strbuf_append(&buf, &len, " perturb %d", qdisc->sfq.perturb_period);
|
||||
nm_strbuf_append(&buf, &len, " perturb %d", qdisc->sfq.perturb_period);
|
||||
if (qdisc->sfq.limit)
|
||||
nm_utils_strbuf_append(&buf, &len, " limit %u", (guint) qdisc->sfq.limit);
|
||||
nm_strbuf_append(&buf, &len, " limit %u", (guint) qdisc->sfq.limit);
|
||||
if (qdisc->sfq.divisor)
|
||||
nm_utils_strbuf_append(&buf, &len, " divisor %u", qdisc->sfq.divisor);
|
||||
nm_strbuf_append(&buf, &len, " divisor %u", qdisc->sfq.divisor);
|
||||
if (qdisc->sfq.flows)
|
||||
nm_utils_strbuf_append(&buf, &len, " flows %u", qdisc->sfq.flows);
|
||||
nm_strbuf_append(&buf, &len, " flows %u", qdisc->sfq.flows);
|
||||
if (qdisc->sfq.depth)
|
||||
nm_utils_strbuf_append(&buf, &len, " depth %u", qdisc->sfq.depth);
|
||||
nm_strbuf_append(&buf, &len, " depth %u", qdisc->sfq.depth);
|
||||
} else if (nm_streq0(qdisc->kind, "tbf")) {
|
||||
nm_utils_strbuf_append(&buf, &len, " rate %" G_GUINT64_FORMAT, qdisc->tbf.rate);
|
||||
nm_utils_strbuf_append(&buf, &len, " burst %u", qdisc->tbf.burst);
|
||||
nm_strbuf_append(&buf, &len, " rate %" G_GUINT64_FORMAT, qdisc->tbf.rate);
|
||||
nm_strbuf_append(&buf, &len, " burst %u", qdisc->tbf.burst);
|
||||
if (qdisc->tbf.limit)
|
||||
nm_utils_strbuf_append(&buf, &len, " limit %u", qdisc->tbf.limit);
|
||||
nm_strbuf_append(&buf, &len, " limit %u", qdisc->tbf.limit);
|
||||
if (qdisc->tbf.latency)
|
||||
nm_utils_strbuf_append(&buf, &len, " latency %uns", qdisc->tbf.latency);
|
||||
nm_strbuf_append(&buf, &len, " latency %uns", qdisc->tbf.latency);
|
||||
}
|
||||
|
||||
return buf0;
|
||||
@@ -7114,11 +7114,11 @@ nm_platform_tfilter_to_string(const NMPlatformTfilter *tfilter, char *buf, gsize
|
||||
p = act_buf;
|
||||
l = sizeof(act_buf);
|
||||
|
||||
nm_utils_strbuf_append(&p, &l, " \"%s\"", tfilter->action.kind);
|
||||
nm_strbuf_append(&p, &l, " \"%s\"", tfilter->action.kind);
|
||||
if (nm_streq(tfilter->action.kind, NM_PLATFORM_ACTION_KIND_SIMPLE)) {
|
||||
gs_free char *t = NULL;
|
||||
|
||||
nm_utils_strbuf_append(
|
||||
nm_strbuf_append(
|
||||
&p,
|
||||
&l,
|
||||
" (\"%s\")",
|
||||
@@ -7127,14 +7127,14 @@ nm_platform_tfilter_to_string(const NMPlatformTfilter *tfilter, char *buf, gsize
|
||||
| NM_UTILS_STR_UTF8_SAFE_FLAG_ESCAPE_NON_ASCII,
|
||||
&t));
|
||||
} else if (nm_streq(tfilter->action.kind, NM_PLATFORM_ACTION_KIND_MIRRED)) {
|
||||
nm_utils_strbuf_append(&p,
|
||||
&l,
|
||||
"%s%s%s%s dev %d",
|
||||
tfilter->action.mirred.ingress ? " ingress" : "",
|
||||
tfilter->action.mirred.egress ? " egress" : "",
|
||||
tfilter->action.mirred.mirror ? " mirror" : "",
|
||||
tfilter->action.mirred.redirect ? " redirect" : "",
|
||||
tfilter->action.mirred.ifindex);
|
||||
nm_strbuf_append(&p,
|
||||
&l,
|
||||
"%s%s%s%s dev %d",
|
||||
tfilter->action.mirred.ingress ? " ingress" : "",
|
||||
tfilter->action.mirred.egress ? " egress" : "",
|
||||
tfilter->action.mirred.mirror ? " mirror" : "",
|
||||
tfilter->action.mirred.redirect ? " redirect" : "",
|
||||
tfilter->action.mirred.ifindex);
|
||||
}
|
||||
} else
|
||||
act_buf[0] = '\0';
|
||||
|
@@ -43,22 +43,20 @@ __ns_types_to_str(int ns_types, int ns_types_already_set, char *buf, gsize len)
|
||||
const char *b = buf;
|
||||
char bb[200];
|
||||
|
||||
nm_utils_strbuf_append_c(&buf, &len, '[');
|
||||
nm_strbuf_append_c(&buf, &len, '[');
|
||||
if (ns_types & ~ns_types_already_set) {
|
||||
nm_utils_strbuf_append_str(
|
||||
&buf,
|
||||
&len,
|
||||
_clone_ns_to_str(ns_types & ~ns_types_already_set, bb, sizeof(bb)));
|
||||
nm_strbuf_append_str(&buf,
|
||||
&len,
|
||||
_clone_ns_to_str(ns_types & ~ns_types_already_set, bb, sizeof(bb)));
|
||||
}
|
||||
if (ns_types & ns_types_already_set) {
|
||||
if (ns_types & ~ns_types_already_set)
|
||||
nm_utils_strbuf_append_c(&buf, &len, '/');
|
||||
nm_utils_strbuf_append_str(
|
||||
&buf,
|
||||
&len,
|
||||
_clone_ns_to_str(ns_types & ns_types_already_set, bb, sizeof(bb)));
|
||||
nm_strbuf_append_c(&buf, &len, '/');
|
||||
nm_strbuf_append_str(&buf,
|
||||
&len,
|
||||
_clone_ns_to_str(ns_types & ns_types_already_set, bb, sizeof(bb)));
|
||||
}
|
||||
nm_utils_strbuf_append_c(&buf, &len, ']');
|
||||
nm_strbuf_append_c(&buf, &len, ']');
|
||||
return b;
|
||||
}
|
||||
#define _ns_types_to_str(ns_types, ns_types_already_set, buf) \
|
||||
|
@@ -949,30 +949,30 @@ _vt_cmd_obj_to_string_link(const NMPObject * obj,
|
||||
case NMP_OBJECT_TO_STRING_ID:
|
||||
return klass->cmd_plobj_to_string_id(&obj->object, buf, buf_size);
|
||||
case NMP_OBJECT_TO_STRING_ALL:
|
||||
nm_utils_strbuf_append(&b,
|
||||
&buf_size,
|
||||
"[%s,%p,%u,%calive,%cvisible,%cin-nl,%p; ",
|
||||
klass->obj_type_name,
|
||||
obj,
|
||||
obj->parent._ref_count,
|
||||
nmp_object_is_alive(obj) ? '+' : '-',
|
||||
nmp_object_is_visible(obj) ? '+' : '-',
|
||||
obj->_link.netlink.is_in_netlink ? '+' : '-',
|
||||
obj->_link.udev.device);
|
||||
nm_strbuf_append(&b,
|
||||
&buf_size,
|
||||
"[%s,%p,%u,%calive,%cvisible,%cin-nl,%p; ",
|
||||
klass->obj_type_name,
|
||||
obj,
|
||||
obj->parent._ref_count,
|
||||
nmp_object_is_alive(obj) ? '+' : '-',
|
||||
nmp_object_is_visible(obj) ? '+' : '-',
|
||||
obj->_link.netlink.is_in_netlink ? '+' : '-',
|
||||
obj->_link.udev.device);
|
||||
NMP_OBJECT_GET_CLASS(obj)->cmd_plobj_to_string(&obj->object, b, buf_size);
|
||||
nm_utils_strbuf_seek_end(&b, &buf_size);
|
||||
nm_strbuf_seek_end(&b, &buf_size);
|
||||
if (obj->_link.netlink.lnk) {
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, "; ");
|
||||
nm_strbuf_append_str(&b, &buf_size, "; ");
|
||||
nmp_object_to_string(obj->_link.netlink.lnk, NMP_OBJECT_TO_STRING_ALL, b, buf_size);
|
||||
nm_utils_strbuf_seek_end(&b, &buf_size);
|
||||
nm_strbuf_seek_end(&b, &buf_size);
|
||||
}
|
||||
nm_utils_strbuf_append_c(&b, &buf_size, ']');
|
||||
nm_strbuf_append_c(&b, &buf_size, ']');
|
||||
return buf;
|
||||
case NMP_OBJECT_TO_STRING_PUBLIC:
|
||||
NMP_OBJECT_GET_CLASS(obj)->cmd_plobj_to_string(&obj->object, b, buf_size);
|
||||
if (obj->_link.netlink.lnk) {
|
||||
nm_utils_strbuf_seek_end(&b, &buf_size);
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, "; ");
|
||||
nm_strbuf_seek_end(&b, &buf_size);
|
||||
nm_strbuf_append_str(&b, &buf_size, "; ");
|
||||
nmp_object_to_string(obj->_link.netlink.lnk, NMP_OBJECT_TO_STRING_PUBLIC, b, buf_size);
|
||||
}
|
||||
return buf;
|
||||
@@ -1065,29 +1065,28 @@ _vt_cmd_obj_to_string_lnk_wireguard(const NMPObject * obj,
|
||||
case NMP_OBJECT_TO_STRING_ALL:
|
||||
b = buf;
|
||||
|
||||
nm_utils_strbuf_append(
|
||||
&b,
|
||||
&buf_size,
|
||||
"[%s,%p,%u,%calive,%cvisible; %s"
|
||||
"%s",
|
||||
klass->obj_type_name,
|
||||
obj,
|
||||
obj->parent._ref_count,
|
||||
nmp_object_is_alive(obj) ? '+' : '-',
|
||||
nmp_object_is_visible(obj) ? '+' : '-',
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, buf2, sizeof(buf2)),
|
||||
obj->_lnk_wireguard.peers_len > 0 ? " peers {" : "");
|
||||
nm_strbuf_append(&b,
|
||||
&buf_size,
|
||||
"[%s,%p,%u,%calive,%cvisible; %s"
|
||||
"%s",
|
||||
klass->obj_type_name,
|
||||
obj,
|
||||
obj->parent._ref_count,
|
||||
nmp_object_is_alive(obj) ? '+' : '-',
|
||||
nmp_object_is_visible(obj) ? '+' : '-',
|
||||
nmp_object_to_string(obj, NMP_OBJECT_TO_STRING_PUBLIC, buf2, sizeof(buf2)),
|
||||
obj->_lnk_wireguard.peers_len > 0 ? " peers {" : "");
|
||||
|
||||
for (i = 0; i < obj->_lnk_wireguard.peers_len; i++) {
|
||||
const NMPWireGuardPeer *peer = &obj->_lnk_wireguard.peers[i];
|
||||
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, " { ");
|
||||
nm_strbuf_append_str(&b, &buf_size, " { ");
|
||||
nm_platform_wireguard_peer_to_string(peer, b, buf_size);
|
||||
nm_utils_strbuf_seek_end(&b, &buf_size);
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, " }");
|
||||
nm_strbuf_seek_end(&b, &buf_size);
|
||||
nm_strbuf_append_str(&b, &buf_size, " }");
|
||||
}
|
||||
if (obj->_lnk_wireguard.peers_len)
|
||||
nm_utils_strbuf_append_str(&b, &buf_size, " }");
|
||||
nm_strbuf_append_str(&b, &buf_size, " }");
|
||||
|
||||
return buf;
|
||||
case NMP_OBJECT_TO_STRING_PUBLIC:
|
||||
|
Reference in New Issue
Block a user