traffic-selector: Store ICMP[v6] message type and code properly

We now store them as defined in RFC 4301, section 4.4.1.1.
This commit is contained in:
Tobias Brunner
2013-10-17 16:57:39 +02:00
parent d6a1960d34
commit 4bebe45abb
2 changed files with 70 additions and 8 deletions
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2007-2009 Tobias Brunner
* Copyright (C) 2007-2013 Tobias Brunner
* Copyright (C) 2005-2007 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
@@ -910,6 +910,10 @@ static private_traffic_selector_t *traffic_selector_create(u_int8_t protocol,
.protocol = protocol,
.type = type,
);
if (protocol == IPPROTO_ICMP || protocol == IPPROTO_ICMPV6)
{
this->from_port = from_port < 256 ? from_port << 8 : from_port;
this->to_port = to_port < 256 ? to_port << 8 : to_port;
}
return this;
}