Code

Initial commit.
[pkg-collectd.git] / debian / patches / getifaddrs.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## getifaddrs.dpatch by Sebastian Harl <sh@tokkee.org>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Read traffic information from /proc by default instead of using 
6 ## DP: getifaddrs(). getifaddrs() does not seem to work correctly on AMD64.
8 @DPATCH@
10 diff -urN collectd-3.9.2/src/traffic.c collectd-3.9.2.patched/src/traffic.c
11 --- collectd-3.9.2/src/traffic.c        2006-05-09 11:10:34.000000000 +0200
12 +++ collectd-3.9.2.patched/src/traffic.c        2006-06-02 16:12:28.000000000 +0200
13 @@ -143,41 +143,7 @@
14  
15  static void traffic_read (void)
16  {
17 -#if HAVE_GETIFADDRS
18 -       struct ifaddrs *if_list;
19 -       struct ifaddrs *if_ptr;
20 -
21 -#if HAVE_STRUCT_IF_DATA
22 -#  define IFA_DATA if_data
23 -#  define IFA_INCOMING ifi_ibytes
24 -#  define IFA_OUTGOING ifi_obytes
25 -#elif HAVE_STRUCT_NET_DEVICE_STATS
26 -#  define IFA_DATA net_device_stats
27 -#  define IFA_INCOMING rx_bytes
28 -#  define IFA_OUTGOING tx_bytes
29 -#else
30 -#  error "No suitable type for `struct ifaddrs->ifa_data' found."
31 -#endif
32 -
33 -       struct IFA_DATA *if_data;
34 -
35 -       if (getifaddrs (&if_list) != 0)
36 -               return;
37 -
38 -       for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
39 -       {
40 -               if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL)
41 -                       continue;
42 -
43 -               traffic_submit (if_ptr->ifa_name,
44 -                               if_data->IFA_INCOMING,
45 -                               if_data->IFA_OUTGOING);
46 -       }
47 -
48 -       freeifaddrs (if_list);
49 -/* #endif HAVE_GETIFADDRS */
50 -
51 -#elif KERNEL_LINUX
52 +#if KERNEL_LINUX
53         FILE *fh;
54         char buffer[1024];
55         unsigned long long incoming, outgoing;
56 @@ -221,6 +187,40 @@
57         fclose (fh);
58  /* #endif KERNEL_LINUX */
59  
60 +#elif HAVE_GETIFADDRS
61 +       struct ifaddrs *if_list;
62 +       struct ifaddrs *if_ptr;
63 +
64 +#if HAVE_STRUCT_IF_DATA
65 +#  define IFA_DATA if_data
66 +#  define IFA_INCOMING ifi_ibytes
67 +#  define IFA_OUTGOING ifi_obytes
68 +#elif HAVE_STRUCT_NET_DEVICE_STATS
69 +#  define IFA_DATA net_device_stats
70 +#  define IFA_INCOMING rx_bytes
71 +#  define IFA_OUTGOING tx_bytes
72 +#else
73 +#  error "No suitable type for `struct ifaddrs->ifa_data' found."
74 +#endif
75 +
76 +       struct IFA_DATA *if_data;
77 +
78 +       if (getifaddrs (&if_list) != 0)
79 +               return;
80 +
81 +       for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
82 +       {
83 +               if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL)
84 +                       continue;
85 +
86 +               traffic_submit (if_ptr->ifa_name,
87 +                               if_data->IFA_INCOMING,
88 +                               if_data->IFA_OUTGOING);
89 +       }
90 +
91 +       freeifaddrs (if_list);
92 +/* #endif HAVE_GETIFADDRS */
93 +
94  #elif defined(HAVE_LIBKSTAT)
95         int i;
96         unsigned long long incoming, outgoing;