diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2010-04-22 18:24:53 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-04-22 18:24:53 -0400 |
commit | e802af9cabb011f09b9c19a82faef3dd315f27eb (patch) | |
tree | 9a8ef1163b9b40fef8860b08ea4dcb4ff3916098 /include | |
parent | 9ccb8975940c4ee51161152e37058e3d9e06c62f (diff) |
IPv6: Generic TTL Security Mechanism (final version)
This patch adds IPv6 support for RFC5082 Generalized TTL Security Mechanism.
Not to users of mapped address; the IPV6 and IPV4 socket options are seperate.
The server does have to deal with both IPv4 and IPv6 socket options
and the client has to handle the different for each family.
On client:
int ttl = 255;
getaddrinfo(argv[1], argv[2], &hint, &result);
for (rp = result; rp != NULL; rp = rp->ai_next) {
s = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (s < 0) continue;
if (rp->ai_family == AF_INET) {
setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
} else if (rp->ai_family == AF_INET6) {
setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS,
&ttl, sizeof(ttl)))
}
if (connect(s, rp->ai_addr, rp->ai_addrlen) == 0) {
...
On server:
int minttl = 255 - maxhops;
getaddrinfo(NULL, port, &hints, &result);
for (rp = result; rp != NULL; rp = rp->ai_next) {
s = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (s < 0) continue;
if (rp->ai_family == AF_INET6)
setsockopt(s, IPPROTO_IPV6, IPV6_MINHOPCOUNT,
&minttl, sizeof(minttl));
setsockopt(s, IPPROTO_IP, IP_MINTTL, &minttl, sizeof(minttl));
if (bind(s, rp->ai_addr, rp->ai_addrlen) == 0)
break
...
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/in6.h | 3 | ||||
-rw-r--r-- | include/linux/ipv6.h | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/in6.h b/include/linux/in6.h index bd55c6e46b2e..9b90cb296eb1 100644 --- a/include/linux/in6.h +++ b/include/linux/in6.h | |||
@@ -265,6 +265,9 @@ struct in6_flowlabel_req { | |||
265 | #define IPV6_PREFER_SRC_CGA 0x0008 | 265 | #define IPV6_PREFER_SRC_CGA 0x0008 |
266 | #define IPV6_PREFER_SRC_NONCGA 0x0800 | 266 | #define IPV6_PREFER_SRC_NONCGA 0x0800 |
267 | 267 | ||
268 | /* RFC5082: Generalized Ttl Security Mechanism */ | ||
269 | #define IPV6_MINHOPCOUNT 73 | ||
270 | |||
268 | /* | 271 | /* |
269 | * Multicast Routing: | 272 | * Multicast Routing: |
270 | * see include/linux/mroute6.h. | 273 | * see include/linux/mroute6.h. |
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index e0cc9a7db2b5..1bdbebf08d16 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h | |||
@@ -348,6 +348,7 @@ struct ipv6_pinfo { | |||
348 | * 010: prefer public address | 348 | * 010: prefer public address |
349 | * 100: prefer care-of address | 349 | * 100: prefer care-of address |
350 | */ | 350 | */ |
351 | __u8 min_hopcount; | ||
351 | __u8 tclass; | 352 | __u8 tclass; |
352 | 353 | ||
353 | __u32 dst_cookie; | 354 | __u32 dst_cookie; |