traffic-selector: Don't end printf'ed list of traffic selectors with a space

This commit is contained in:
Tobias Brunner
2015-11-10 12:13:06 +01:00
parent c2967484a0
commit ebeb8c87c5
11 changed files with 21 additions and 22 deletions
@@ -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;
@@ -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