[toolchain] cosmetic & coherency fixes
[openwrt-10.03/.git] / toolchain / uClibc / patches / 170-enable-getifaddrs.patch
1 Index: uclibc/libc/inet/ifaddrs.c
2 ===================================================================
3 --- uclibc.orig/libc/inet/ifaddrs.c
4 +++ uclibc/libc/inet/ifaddrs.c
5 @@ -38,6 +38,7 @@
6  #include <unistd.h>
7  
8  #include "netlinkaccess.h"
9 +#include "ifaddrs.h"
10  
11  libc_hidden_proto(socket)
12  libc_hidden_proto(close)
13 @@ -57,7 +58,6 @@ libc_hidden_proto(abort)
14  
15  
16  #if __ASSUME_NETLINK_SUPPORT
17 -#if 0 /* unused code */
18  /* struct to hold the data for one ifaddrs entry, so we can allocate
19     everything at once.  */
20  struct ifaddrs_storage
21 @@ -74,8 +74,6 @@ struct ifaddrs_storage
22    } addr, netmask, broadaddr;
23    char name[IF_NAMESIZE + 1];
24  };
25 -#endif /* unused code */
26 -
27  
28  void
29  __netlink_free_handle (struct netlink_handle *h)
30 @@ -323,8 +321,6 @@ __netlink_open (struct netlink_handle *h
31    return 0;
32  }
33  
34 -
35 -#if 0 /* unused code */
36  /* We know the number of RTM_NEWLINK entries, so we reserve the first
37     # of entries for this type. All RTM_NEWADDR entries have an index
38     pointer to the RTM_NEWLINK entry.  To find the entry, create
39 @@ -562,7 +558,7 @@ getifaddrs (struct ifaddrs **ifap)
40                       if ((rta_payload + 1) <= sizeof (ifas[ifa_index].name))
41                         {
42                           ifas[ifa_index].ifa.ifa_name = ifas[ifa_index].name;
43 -                         *(char *) __mempcpy (ifas[ifa_index].name, rta_data,
44 +                         *(char *) mempcpy (ifas[ifa_index].name, rta_data,
45                                                rta_payload) = '\0';
46                         }
47                       break;
48 @@ -761,7 +757,7 @@ getifaddrs (struct ifaddrs **ifap)
49                       if (rta_payload + 1 <= sizeof (ifas[ifa_index].name))
50                         {
51                           ifas[ifa_index].ifa.ifa_name = ifas[ifa_index].name;
52 -                         *(char *) __mempcpy (ifas[ifa_index].name, rta_data,
53 +                         *(char *) mempcpy (ifas[ifa_index].name, rta_data,
54                                                rta_payload) = '\0';
55                         }
56                       else
57 @@ -872,6 +868,4 @@ freeifaddrs (struct ifaddrs *ifa)
58  }
59  #endif
60  
61 -#endif /* unused code */
62 -
63  #endif /* __ASSUME_NETLINK_SUPPORT */
64 Index: uclibc/libc/inet/netlinkaccess.h
65 ===================================================================
66 --- uclibc.orig/libc/inet/netlinkaccess.h
67 +++ uclibc/libc/inet/netlinkaccess.h
68 @@ -61,14 +61,11 @@ struct netlink_handle
69  };
70  
71  
72 -#if 0 /* unused code */
73  #if __ASSUME_NETLINK_SUPPORT == 0
74  extern int __no_netlink_support attribute_hidden;
75  #else
76  # define __no_netlink_support 0
77  #endif
78 -#endif /* unused code */
79 -
80  
81  extern int __netlink_open (struct netlink_handle *h) attribute_hidden;
82  extern void __netlink_close (struct netlink_handle *h) attribute_hidden;
83 Index: uclibc/include/ifaddrs.h
84 ===================================================================
85 --- /dev/null
86 +++ uclibc/include/ifaddrs.h
87 @@ -0,0 +1,74 @@
88 +/* ifaddrs.h -- declarations for getting network interface addresses
89 +   Copyright (C) 2002 Free Software Foundation, Inc.
90 +   This file is part of the GNU C Library.
91 +
92 +   The GNU C Library is free software; you can redistribute it and/or
93 +   modify it under the terms of the GNU Lesser General Public
94 +   License as published by the Free Software Foundation; either
95 +   version 2.1 of the License, or (at your option) any later version.
96 +
97 +   The GNU C Library is distributed in the hope that it will be useful,
98 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
99 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
100 +   Lesser General Public License for more details.
101 +
102 +   You should have received a copy of the GNU Lesser General Public
103 +   License along with the GNU C Library; if not, write to the Free
104 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
105 +   02111-1307 USA.  */
106 +
107 +#ifndef _IFADDRS_H
108 +#define _IFADDRS_H     1
109 +
110 +#include <features.h>
111 +#include <sys/socket.h>
112 +
113 +__BEGIN_DECLS
114 +
115 +/* The `getifaddrs' function generates a linked list of these structures.
116 +   Each element of the list describes one network interface.  */
117 +struct ifaddrs
118 +{
119 +  struct ifaddrs *ifa_next;    /* Pointer to the next structure.  */
120 +
121 +  char *ifa_name;              /* Name of this network interface.  */
122 +  unsigned int ifa_flags;      /* Flags as from SIOCGIFFLAGS ioctl.  */
123 +
124 +  struct sockaddr *ifa_addr;   /* Network address of this interface.  */
125 +  struct sockaddr *ifa_netmask; /* Netmask of this interface.  */
126 +  union
127 +  {
128 +    /* At most one of the following two is valid.  If the IFF_BROADCAST
129 +       bit is set in `ifa_flags', then `ifa_broadaddr' is valid.  If the
130 +       IFF_POINTOPOINT bit is set, then `ifa_dstaddr' is valid.
131 +       It is never the case that both these bits are set at once.  */
132 +    struct sockaddr *ifu_broadaddr; /* Broadcast address of this interface. */
133 +    struct sockaddr *ifu_dstaddr; /* Point-to-point destination address.  */
134 +  } ifa_ifu;
135 +  /* These very same macros are defined by <net/if.h> for `struct ifaddr'.
136 +     So if they are defined already, the existing definitions will be fine.  */
137 +# ifndef ifa_broadaddr
138 +#  define ifa_broadaddr        ifa_ifu.ifu_broadaddr
139 +# endif
140 +# ifndef ifa_dstaddr
141 +#  define ifa_dstaddr  ifa_ifu.ifu_dstaddr
142 +# endif
143 +
144 +  void *ifa_data;              /* Address-specific data (may be unused).  */
145 +};
146 +
147 +
148 +/* Create a linked list of `struct ifaddrs' structures, one for each
149 +   network interface on the host machine.  If successful, store the
150 +   list in *IFAP and return 0.  On errors, return -1 and set `errno'.
151 +
152 +   The storage returned in *IFAP is allocated dynamically and can
153 +   only be properly freed by passing it to `freeifaddrs'.  */
154 +extern int getifaddrs (struct ifaddrs **__ifap) __THROW;
155 +
156 +/* Reclaim the storage allocated by a previous `getifaddrs' call.  */
157 +extern void freeifaddrs (struct ifaddrs *__ifa)  __THROW;
158 +
159 +__END_DECLS
160 +
161 +#endif /* ifaddrs.h */
162