id-payload: Enable multiple calls to get_ts() for subnet traffic selectors
The second call resulted in a /32 subnet previously.
This commit is contained in:
@@ -258,17 +258,20 @@ static traffic_selector_t *get_ts_from_range(private_id_payload_t *this,
|
|||||||
static traffic_selector_t *get_ts_from_subnet(private_id_payload_t *this,
|
static traffic_selector_t *get_ts_from_subnet(private_id_payload_t *this,
|
||||||
ts_type_t type)
|
ts_type_t type)
|
||||||
{
|
{
|
||||||
|
traffic_selector_t *ts;
|
||||||
chunk_t net, netmask;
|
chunk_t net, netmask;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
net = chunk_create(this->id_data.ptr, this->id_data.len / 2);
|
net = chunk_create(this->id_data.ptr, this->id_data.len / 2);
|
||||||
netmask = chunk_skip(this->id_data, this->id_data.len / 2);
|
netmask = chunk_clone(chunk_skip(this->id_data, this->id_data.len / 2));
|
||||||
for (i = 0; i < net.len; i++)
|
for (i = 0; i < net.len; i++)
|
||||||
{
|
{
|
||||||
netmask.ptr[i] = (netmask.ptr[i] ^ 0xFF) | net.ptr[i];
|
netmask.ptr[i] = (netmask.ptr[i] ^ 0xFF) | net.ptr[i];
|
||||||
}
|
}
|
||||||
return traffic_selector_create_from_bytes(this->protocol_id, type,
|
ts = traffic_selector_create_from_bytes(this->protocol_id, type,
|
||||||
net, this->port, netmask, this->port ?: 65535);
|
net, this->port, netmask, this->port ?: 65535);
|
||||||
|
chunk_free(&netmask);
|
||||||
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user