summaryrefslogtreecommitdiffstats
path: root/tapset/ip.stp
diff options
context:
space:
mode:
Diffstat (limited to 'tapset/ip.stp')
-rw-r--r--tapset/ip.stp23
1 files changed, 13 insertions, 10 deletions
diff --git a/tapset/ip.stp b/tapset/ip.stp
index ec17b7c0..123a2728 100644
--- a/tapset/ip.stp
+++ b/tapset/ip.stp
@@ -1,5 +1,8 @@
// IP tapset
+//
// Copyright (C) 2009, IBM Inc.
+// Copyright (C) 2010, Red Hat Inc.
+//
// Author : Breno Leitao <leitao@linux.vnet.ibm.com>
//
// This file is free software. You can redistribute it and/or modify it under
@@ -26,21 +29,21 @@ function ip_ntop:string (addr:long)
/* return the source IP address for a given sock */
function __ip_sock_saddr:long (sock:long)
{
-%(kernel_v < "2.6.33" %?
- return @cast(sock, "inet_sock")->saddr
-%:
- return @cast(sock, "inet_sock")->inet_saddr
-%)
+ return (@defined(@cast(sock, "inet_sock")->inet_saddr)
+ ? @cast(sock, "inet_sock")->inet_saddr # kernel >= 2.6.33
+ : (@defined(@cast(sock, "inet_sock")->saddr)
+ ? @cast(sock, "inet_sock", "kernel")->saddr # kernel >= 2.6.11
+ : @cast(sock, "inet_sock", "kernel<net/ip.h>")->inet->saddr))
}
/* return the destination IP address for a given sock */
function __ip_sock_daddr:long (sock:long)
{
-%(kernel_v < "2.6.33" %?
- return @cast(sock, "inet_sock")->daddr
-%:
- return @cast(sock, "inet_sock")->inet_daddr
-%)
+ return (@defined(@cast(sock, "inet_sock")->inet_daddr)
+ ? @cast(sock, "inet_sock")->inet_daddr # kernel >= 2.6.33
+ : (@defined(@cast(sock, "inet_sock")->daddr)
+ ? @cast(sock, "inet_sock", "kernel")->daddr # kernel >= 2.6.11
+ : @cast(sock, "inet_sock", "kernel<net/ip.h>")->inet->daddr))
}
/* Get the IP header for recent (> 2.6.21) kernels */