Hello,
We noticed the printf hook used to print traffic selectors always puts a
trailing space char.
This may be annoying when using this hook in plugins.
Please find attached a patch proposal to correct this simple issue.
Best Regards,
diff --git src/libcharon/config/peer_cfg.c src/libcharon/config/peer_cfg.c
index ce93010..aa2a39c 100644
--- src/libcharon/config/peer_cfg.c
+++ src/libcharon/config/peer_cfg.c
@@ -302,7 +302,7 @@ METHOD(peer_cfg_t, select_child_cfg, child_cfg_t*,
enumerator_t *enumerator;
int best = 0;
- DBG2(DBG_CFG, "looking for a child config for %#R=== %#R", my_ts, other_ts);
+ DBG2(DBG_CFG, "looking for a child config for %#R === %#R", my_ts, other_ts);
enumerator = create_child_cfg_enumerator(this);
while (enumerator->enumerate(enumerator, ¤t))
{
diff --git src/libcharon/plugins/error_notify/error_notify_listener.c src/libcharon/plugins/error_notify/error_notify_listener.c
index 13860fe..cabd167 100644
--- src/libcharon/plugins/error_notify/error_notify_listener.c
+++ src/libcharon/plugins/error_notify/error_notify_listener.c
@@ -110,7 +110,7 @@ METHOD(listener_t, alert, bool,
list = va_arg(args, linked_list_t*);
list2 = va_arg(args, linked_list_t*);
snprintf(msg.str, sizeof(msg.str), "the received traffic selectors "
- "did not match: %#R=== %#R", list, list2);
+ "did not match: %#R === %#R", list, list2);
break;
case ALERT_INSTALL_CHILD_SA_FAILED:
msg.type = htonl(ERROR_NOTIFY_INSTALL_CHILD_SA_FAILED);
diff --git src/libcharon/plugins/ha/ha_child.c src/libcharon/plugins/ha/ha_child.c
index 17f2d50..dbb6adc 100644
--- src/libcharon/plugins/ha/ha_child.c
+++ src/libcharon/plugins/ha/ha_child.c
@@ -126,7 +126,7 @@ METHOD(listener_t, child_keys, bool,
ike_sa->get_my_host(ike_sa), child_sa->get_spi(child_sa, TRUE));
seg_o = this->kernel->get_segment_spi(this->kernel,
ike_sa->get_other_host(ike_sa), child_sa->get_spi(child_sa, FALSE));
- DBG1(DBG_CFG, "handling HA CHILD_SA %s{%d} %#R=== %#R "
+ DBG1(DBG_CFG, "handling HA CHILD_SA %s{%d} %#R === %#R "
"(segment in: %d%s, out: %d%s)", child_sa->get_name(child_sa),
child_sa->get_unique_id(child_sa), local_ts, remote_ts,
seg_i, this->segments->is_active(this->segments, seg_i) ? "*" : "",
diff --git src/libcharon/plugins/ha/ha_dispatcher.c src/libcharon/plugins/ha/ha_dispatcher.c
index 31eeb93..c11911b 100644
--- src/libcharon/plugins/ha/ha_dispatcher.c
+++ src/libcharon/plugins/ha/ha_dispatcher.c
@@ -838,7 +838,7 @@ static void process_child_add(private_ha_dispatcher_t *this,
seg_o = this->kernel->get_segment_spi(this->kernel,
ike_sa->get_other_host(ike_sa), outbound_spi);
- DBG1(DBG_CFG, "installed HA CHILD_SA %s{%d} %#R=== %#R "
+ DBG1(DBG_CFG, "installed HA CHILD_SA %s{%d} %#R === %#R "
"(segment in: %d%s, out: %d%s)", child_sa->get_name(child_sa),
child_sa->get_unique_id(child_sa), local_ts, remote_ts,
seg_i, this->segments->is_active(this->segments, seg_i) ? "*" : "",
diff --git src/libcharon/plugins/stroke/stroke_list.c src/libcharon/plugins/stroke/stroke_list.c
index 68b8232..0b2d5bd 100644
--- src/libcharon/plugins/stroke/stroke_list.c
+++ src/libcharon/plugins/stroke/stroke_list.c
@@ -334,7 +334,7 @@ static void log_child_sa(FILE *out, child_sa_t *child_sa, bool all)
child_sa->create_ts_enumerator(child_sa, TRUE));
other_ts = linked_list_create_from_enumerator(
child_sa->create_ts_enumerator(child_sa, FALSE));
- fprintf(out, "\n%12s{%d}: %#R=== %#R\n",
+ fprintf(out, "\n%12s{%d}: %#R === %#R\n",
child_sa->get_name(child_sa), child_sa->get_unique_id(child_sa),
my_ts, other_ts);
my_ts->destroy(my_ts);
@@ -586,7 +586,7 @@ METHOD(stroke_list_t, status, void,
{
my_ts = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
other_ts = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
- fprintf(out, "%12s: child: %#R=== %#R%N",
+ fprintf(out, "%12s: child: %#R === %#R %N",
child_cfg->get_name(child_cfg), my_ts, other_ts,
ipsec_mode_names, child_cfg->get_mode(child_cfg));
my_ts->destroy_offset(my_ts, offsetof(traffic_selector_t, destroy));
@@ -620,7 +620,7 @@ METHOD(stroke_list_t, status, void,
}
my_ts = child_cfg->get_traffic_selectors(child_cfg, TRUE, NULL, NULL);
other_ts = child_cfg->get_traffic_selectors(child_cfg, FALSE, NULL, NULL);
- fprintf(out, "%12s: %#R=== %#R%N\n",
+ fprintf(out, "%12s: %#R === %#R %N\n",
child_cfg->get_name(child_cfg), my_ts, other_ts,
ipsec_mode_names, child_cfg->get_mode(child_cfg));
my_ts->destroy_offset(my_ts, offsetof(traffic_selector_t, destroy));
diff --git src/libcharon/plugins/uci/uci_control.c src/libcharon/plugins/uci/uci_control.c
index cebc389..a21d4c3 100644
--- src/libcharon/plugins/uci/uci_control.c
+++ src/libcharon/plugins/uci/uci_control.c
@@ -111,7 +111,7 @@ static void status(private_uci_control_t *this, char *name)
{
list = linked_list_create_from_enumerator(
child_sa->create_ts_enumerator(child_sa, FALSE));
- fprintf(out, "%#R", list);
+ fprintf(out, "%#R ", list);
list->destroy(list);
}
children->destroy(children);
diff --git src/libcharon/sa/ikev1/tasks/quick_delete.c src/libcharon/sa/ikev1/tasks/quick_delete.c
index 1b95a8b..ade59a2 100644
--- src/libcharon/sa/ikev1/tasks/quick_delete.c
+++ src/libcharon/sa/ikev1/tasks/quick_delete.c
@@ -115,7 +115,7 @@ static bool delete_child(private_quick_delete_t *this, protocol_id_t protocol,
if (this->expired)
{
DBG0(DBG_IKE, "closing expired CHILD_SA %s{%d} "
- "with SPIs %.8x_i %.8x_o and TS %#R=== %#R",
+ "with SPIs %.8x_i %.8x_o and TS %#R === %#R",
child_sa->get_name(child_sa), child_sa->get_unique_id(child_sa),
ntohl(child_sa->get_spi(child_sa, TRUE)),
ntohl(child_sa->get_spi(child_sa, FALSE)), my_ts, other_ts);
@@ -126,7 +126,7 @@ static bool delete_child(private_quick_delete_t *this, protocol_id_t protocol,
child_sa->get_usestats(child_sa, FALSE, NULL, &bytes_out, NULL);
DBG0(DBG_IKE, "closing CHILD_SA %s{%d} with SPIs "
- "%.8x_i (%llu bytes) %.8x_o (%llu bytes) and TS %#R=== %#R",
+ "%.8x_i (%llu bytes) %.8x_o (%llu bytes) and TS %#R === %#R",
child_sa->get_name(child_sa), child_sa->get_unique_id(child_sa),
ntohl(child_sa->get_spi(child_sa, TRUE)), bytes_in,
ntohl(child_sa->get_spi(child_sa, FALSE)), bytes_out,
diff --git src/libcharon/sa/ikev1/tasks/quick_mode.c src/libcharon/sa/ikev1/tasks/quick_mode.c
index 96edfd8..da1f17e 100644
--- src/libcharon/sa/ikev1/tasks/quick_mode.c
+++ src/libcharon/sa/ikev1/tasks/quick_mode.c
@@ -383,7 +383,7 @@ static bool install(private_quick_mode_t *this)
this->child_sa->create_ts_enumerator(this->child_sa, FALSE));
DBG0(DBG_IKE, "CHILD_SA %s{%d} established "
- "with SPIs %.8x_i %.8x_o and TS %#R=== %#R",
+ "with SPIs %.8x_i %.8x_o and TS %#R === %#R",
this->child_sa->get_name(this->child_sa),
this->child_sa->get_unique_id(this->child_sa),
ntohl(this->child_sa->get_spi(this->child_sa, TRUE)),
diff --git src/libcharon/sa/ikev2/tasks/child_create.c src/libcharon/sa/ikev2/tasks/child_create.c
index e0f930c..087368e 100644
--- src/libcharon/sa/ikev2/tasks/child_create.c
+++ src/libcharon/sa/ikev2/tasks/child_create.c
@@ -707,7 +707,7 @@ static status_t select_and_install(private_child_create_t *this,
this->child_sa->create_ts_enumerator(this->child_sa, FALSE));
DBG0(DBG_IKE, "CHILD_SA %s{%d} established "
- "with SPIs %.8x_i %.8x_o and TS %#R=== %#R",
+ "with SPIs %.8x_i %.8x_o and TS %#R === %#R",
this->child_sa->get_name(this->child_sa),
this->child_sa->get_unique_id(this->child_sa),
ntohl(this->child_sa->get_spi(this->child_sa, TRUE)),
@@ -1240,7 +1240,7 @@ METHOD(task_t, build_r, status_t,
}
if (this->config == NULL)
{
- DBG1(DBG_IKE, "traffic selectors %#R=== %#R inacceptable",
+ DBG1(DBG_IKE, "traffic selectors %#R === %#R inacceptable",
this->tsr, this->tsi);
charon->bus->alert(charon->bus, ALERT_TS_MISMATCH, this->tsi, this->tsr);
message->add_notify(message, FALSE, TS_UNACCEPTABLE, chunk_empty);
diff --git src/libstrongswan/selectors/traffic_selector.c src/libstrongswan/selectors/traffic_selector.c
index 3b7f8c5..482e9b6 100644
--- src/libstrongswan/selectors/traffic_selector.c
+++ src/libstrongswan/selectors/traffic_selector.c
@@ -224,6 +224,7 @@ int traffic_selector_printf_hook(printf_hook_data_t *data,
bool has_ports;
size_t written = 0;
u_int32_t from[4], to[4];
+ const char *sep;
if (this == NULL)
{
@@ -232,11 +233,12 @@ int traffic_selector_printf_hook(printf_hook_data_t *data,
if (spec->hash)
{
+ sep = "";
enumerator = list->create_enumerator(list);
while (enumerator->enumerate(enumerator, (void**)&this))
{
- /* call recursivly */
- written += print_in_hook(data, "%R ", this);
+ written += print_in_hook(data, "%s%R", sep, this);
+ sep = " ";
}
enumerator->destroy(enumerator);
return written;
@@ -1000,3 +1002,4 @@ static private_traffic_selector_t *traffic_selector_create(u_int8_t protocol,
}
return this;
}
+
_______________________________________________
Dev mailing list
[email protected]
https://lists.strongswan.org/mailman/listinfo/dev