From 961479c253ded0d1a7331e8d064ffbc0ca3358d7 Mon Sep 17 00:00:00 2001 From: David Smith Date: Fri, 26 Mar 2010 13:24:38 -0500 Subject: PR 9871/11338 fix in tcpmib.stp by removing embedded-C and using @defined. * tapset/tcpmib.stp (tcpmib_get_state): Changed from embedded-C to script code. (tcpmib_local_addr): Instead of an embedded-C function, now calls function from ip.stp/tcp.stp. (tcpmib_remote_addr): Ditto. (tcpmib_local_port): Ditto. (tcpmib_remote_port): Ditto. (tcpmib.OutRsts.A): Used '@defined' instead of a kernel version check. * tapset/ip.stp (__ip_sock_saddr): Used '@defined' instead of a kernel version check. Added RHEL4 support. (__ip_sock_daddr): Ditto. * tapset/tcp.stp (__tcp_sock_dport): Ditto. (__tcp_sock_sport): Ditto. --- tapset/ip.stp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'tapset/ip.stp') 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 // // 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")->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")->inet->daddr)) } /* Get the IP header for recent (> 2.6.21) kernels */ -- cgit