/usr/share/systemtap/tapset/ip.stp is in systemtap-common 1.7-1+deb7u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | // 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
// the terms of the GNU General Public License (GPL), version 2.
//
// Based on previous work done by Arnaldo Carvalho de Melo <acme@redhat.com>
%{
#include <linux/skbuff.h>
#ifndef NIPQUAD
#define NIPQUAD(addr) \
((unsigned char *)&addr)[0], \
((unsigned char *)&addr)[1], \
((unsigned char *)&addr)[2], \
((unsigned char *)&addr)[3]
#endif
#ifndef NIPQUAD_FMT
#define NIPQUAD_FMT "%u.%u.%u.%u"
#endif
%}
/**
* sfunction ip_ntop - Returns a string representation from an integer IP number
*
* @addr: the IP represented as an integer
*/
function ip_ntop:string (addr:long)
%{
__be32 ip;
ip = THIS->addr;
snprintf(THIS->__retvalue, MAXSTRINGLEN, NIPQUAD_FMT, NIPQUAD(ip));
%}
/* return the source IP address for a given sock */
function __ip_sock_saddr:long (sock:long)
{
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)
{
return (@defined(@cast(sock, "inet_sock")->sk->__sk_common->skc_daddr)
? # kernel >= 2.6.38
@cast(sock, "inet_sock")->sk->__sk_common->skc_daddr
: (@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 from a sk_buff struct */
function __get_skb_iphdr:long(skb:long)
%( kernel_v < "2.6.21" %?
{
iphdr = @cast(skb, "sk_buff")->nh->raw
return iphdr
}
%:
%{ /* pure */
struct sk_buff *skb;
skb = (struct sk_buff *)(long)THIS->skb;
/* as done by skb_network_header() */
#ifdef NET_SKBUFF_DATA_USES_OFFSET
THIS->__retvalue = (long)(kread(&(skb->head)) + kread(&(skb->network_header)));
#else
THIS->__retvalue = (long)kread(&(skb->network_header));
#endif
CATCH_DEREF_FAULT();
%}
%)
/* return the source next layer protocol for a given sk_buff structure */
function __ip_skb_proto:long (iphdr)
{
return @cast(iphdr, "iphdr")->protocol
}
/* return the source IP address for a given sk_buff structure */
function __ip_skb_saddr:long (iphdr)
{
return @cast(iphdr, "iphdr")->saddr
}
/* return the destination IP address for a given skb */
function __ip_skb_daddr:long (iphdr)
{
return @cast(iphdr, "iphdr")->daddr
}
|