traffic-selector: Don't end printf'ed list of traffic selectors with a space
authorTobias Brunner <tobias@strongswan.org>
Wed, 7 Oct 2015 14:25:05 +0000 (16:25 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 10 Nov 2015 11:13:06 +0000 (12:13 +0100)
src/libcharon/config/peer_cfg.c
src/libcharon/plugins/error_notify/error_notify_listener.c
src/libcharon/plugins/ha/ha_child.c
src/libcharon/plugins/ha/ha_dispatcher.c
src/libcharon/plugins/stroke/stroke_list.c
src/libcharon/sa/ikev1/tasks/quick_delete.c
src/libcharon/sa/ikev1/tasks/quick_mode.c
src/libcharon/sa/ikev2/tasks/child_create.c
src/libcharon/sa/ikev2/tasks/child_delete.c
src/libstrongswan/selectors/traffic_selector.c
src/libstrongswan/tests/suites/test_traffic_selector.c

index ce93010..aa2a39c 100644 (file)
@@ -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, &current))
        {
index f7a1f49..ce577c6 100644 (file)
@@ -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);
index 17f2d50..dbb6adc 100644 (file)
@@ -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) ? "*" : "",
index afa0993..07ef607 100644 (file)
@@ -848,7 +848,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) ? "*" : "",
index c7e4c9c..c0192b5 100644 (file)
@@ -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));
index 1b95a8b..ade59a2 100644 (file)
@@ -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,
index 45eb7f0..e7d2644 100644 (file)
@@ -388,7 +388,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)),
index e08f3da..97f73d8 100644 (file)
@@ -712,7 +712,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)),
@@ -1245,7 +1245,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);
index f0b11e2..877ae05 100644 (file)
@@ -266,7 +266,7 @@ static void log_children(private_child_delete_t *this)
                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);
@@ -277,7 +277,7 @@ static void log_children(private_child_delete_t *this)
                        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",
+                                "(%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,
index 6686324..a6298b3 100644 (file)
@@ -219,9 +219,8 @@ int traffic_selector_printf_hook(printf_hook_data_t *data,
        enumerator_t *enumerator;
        char from_str[INET6_ADDRSTRLEN] = "";
        char to_str[INET6_ADDRSTRLEN] = "";
-       char *serv_proto = NULL;
-       bool has_proto;
-       bool has_ports;
+       char *serv_proto = NULL, *sep = "";
+       bool has_proto, has_ports;
        size_t written = 0;
        u_int32_t from[4], to[4];
 
@@ -235,8 +234,8 @@ int traffic_selector_printf_hook(printf_hook_data_t *data,
                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;
index bec32d2..5c0fb75 100644 (file)
@@ -770,17 +770,17 @@ START_TEST(test_printf_hook_hash)
        list = linked_list_create_with_items(
                                traffic_selector_create_from_cidr("10.1.0.0/16", 0, 0, 65535),
                                NULL);
-       verify_list("10.1.0.0/16 ", NULL, list);
+       verify_list("10.1.0.0/16", NULL, list);
        list = linked_list_create_with_items(
                                traffic_selector_create_from_cidr("10.1.0.0/16", 0, 0, 65535),
                                traffic_selector_create_from_cidr("10.1.0.1/32", IPPROTO_UDP, 1234, 1235),
                                NULL);
-       verify_list("10.1.0.0/16 10.1.0.1/32[udp/1234-1235] ", "10.1.0.0/16 10.1.0.1/32[17/1234-1235] ", list);
+       verify_list("10.1.0.0/16 10.1.0.1/32[udp/1234-1235]", "10.1.0.0/16 10.1.0.1/32[17/1234-1235]", list);
        list = linked_list_create_with_items(
                                traffic_selector_create_from_cidr("10.1.0.0/16", 0, 0, 65535),
                                traffic_selector_create_from_string(IPPROTO_UDP, TS_IPV4_ADDR_RANGE, "10.1.0.1", 1234, "10.1.0.99", 1235),
                                NULL);
-       verify_list("10.1.0.0/16 10.1.0.1..10.1.0.99[udp/1234-1235] ", "10.1.0.0/16 10.1.0.1..10.1.0.99[17/1234-1235] ", list);
+       verify_list("10.1.0.0/16 10.1.0.1..10.1.0.99[udp/1234-1235]", "10.1.0.0/16 10.1.0.1..10.1.0.99[17/1234-1235]", list);
 }
 END_TEST