chiark / gitweb /
debianutils: Update from 4.8.3 to 4.8.4
[termux-packages] / packages / inetutils / if_index.c.patch
1 diff -u -r ../inetutils-1.9.3/libinetutils/if_index.c ./libinetutils/if_index.c
2 --- ../inetutils-1.9.3/libinetutils/if_index.c  2015-03-31 11:40:48.000000000 -0400
3 +++ ./libinetutils/if_index.c   2015-05-12 15:32:45.660145151 -0400
4 @@ -37,10 +37,22 @@
5  #include <net/if.h>
6  
7  #ifndef HAVE_STRUCT_IF_NAMEINDEX
8 +
9 +#ifdef __ANDROID__
10 +struct if_nameindex {
11 +       unsigned int if_index;
12 +       char    *if_name;
13 +};
14 +# define ifr_ifindex     ifr_ifru.ifru_ivalue    /* interface index      */
15 +#endif
16 +
17  unsigned int
18  if_nametoindex (const char *ifname)
19  {
20    int result = 0;
21 +#ifdef __ANDROID__
22 +  return result;
23 +#else
24  #ifdef SIOCGIFINDEX
25    {
26      int fd = socket (AF_INET, SOCK_DGRAM, 0);
27 @@ -75,11 +87,13 @@
28        }
29      return result;
30    }
31 +#endif
32  }
33  
34  void
35  if_freenameindex (struct if_nameindex *ifn)
36  {
37 +#ifndef __ANDROID__
38    struct if_nameindex *ptr = ifn;
39    if (!ifn)
40      return;
41 @@ -88,6 +102,7 @@
42        free (ptr->if_name);
43        ++ptr;
44      }
45 +#endif
46    free (ifn);
47  }
48  
49 @@ -162,7 +177,7 @@
50           return NULL;
51         }
52  
53 -# if defined SIOCGIFINDEX
54 +# if defined SIOCGIFINDEX && !defined(__ANDROID__)
55        if (ioctl (fd, SIOCGIFINDEX, cur) >= 0)
56         idx[i].if_index = cur->ifr_index;
57        else