add chaos_calmer branch
[15.05/openwrt.git] / package / network / utils / iproute2 / patches / 010-type_fixes.patch
1 --- a/include/iptables_common.h
2 +++ b/include/iptables_common.h
3 @@ -2,6 +2,8 @@
4  #define _IPTABLES_COMMON_H
5  /* Shared definitions between ipv4 and ipv6. */
6  
7 +#include <stdint.h>
8 +
9  enum exittype {
10         OTHER_PROBLEM = 1,
11         PARAMETER_PROBLEM,
12 @@ -43,9 +45,9 @@ extern char *lib_dir;
13    extern void init_extensions(void);
14  #endif
15  
16 -#define __be32 u_int32_t
17 -#define __le32 u_int32_t
18 -#define __be16 u_int16_t
19 -#define __le16 u_int16_t
20 +#define __be32 uint32_t
21 +#define __le32 uint32_t
22 +#define __be16 uint16_t
23 +#define __le16 uint16_t
24  
25  #endif /*_IPTABLES_COMMON_H*/
26 --- a/include/netinet/tcp.h
27 +++ /dev/null
28 @@ -1,231 +0,0 @@
29 -/*
30 - * Copyright (c) 1982, 1986, 1993
31 - *     The Regents of the University of California.  All rights reserved.
32 - *
33 - * Redistribution and use in source and binary forms, with or without
34 - * modification, are permitted provided that the following conditions
35 - * are met:
36 - * 1. Redistributions of source code must retain the above copyright
37 - *    notice, this list of conditions and the following disclaimer.
38 - * 2. Redistributions in binary form must reproduce the above copyright
39 - *    notice, this list of conditions and the following disclaimer in the
40 - *    documentation and/or other materials provided with the distribution.
41 - * 4. Neither the name of the University nor the names of its contributors
42 - *    may be used to endorse or promote products derived from this software
43 - *    without specific prior written permission.
44 - *
45 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 - * SUCH DAMAGE.
56 - *
57 - *     @(#)tcp.h       8.1 (Berkeley) 6/10/93
58 - */
59 -
60 -#ifndef _NETINET_TCP_H
61 -#define _NETINET_TCP_H 1
62 -
63 -#include <features.h>
64 -
65 -/*
66 - * User-settable options (used with setsockopt).
67 - */
68 -#define        TCP_NODELAY      1      /* Don't delay send to coalesce packets  */
69 -#define        TCP_MAXSEG       2      /* Set maximum segment size  */
70 -#define TCP_CORK        3      /* Control sending of partial frames  */
71 -#define TCP_KEEPIDLE    4      /* Start keeplives after this period */
72 -#define TCP_KEEPINTVL   5      /* Interval between keepalives */
73 -#define TCP_KEEPCNT     6      /* Number of keepalives before death */
74 -#define TCP_SYNCNT      7      /* Number of SYN retransmits */
75 -#define TCP_LINGER2     8      /* Life time of orphaned FIN-WAIT-2 state */
76 -#define TCP_DEFER_ACCEPT 9     /* Wake up listener only when data arrive */
77 -#define TCP_WINDOW_CLAMP 10    /* Bound advertised window */
78 -#define TCP_INFO        11     /* Information about this connection. */
79 -#define        TCP_QUICKACK     12     /* Bock/reenable quick ACKs.  */
80 -#define TCP_CONGESTION  13     /* Congestion control algorithm.  */
81 -
82 -#ifdef __USE_MISC
83 -# include <sys/types.h>
84 -
85 -# ifdef __FAVOR_BSD
86 -typedef        u_int32_t tcp_seq;
87 -/*
88 - * TCP header.
89 - * Per RFC 793, September, 1981.
90 - */
91 -struct tcphdr
92 -  {
93 -    u_int16_t th_sport;                /* source port */
94 -    u_int16_t th_dport;                /* destination port */
95 -    tcp_seq th_seq;            /* sequence number */
96 -    tcp_seq th_ack;            /* acknowledgement number */
97 -#  if __BYTE_ORDER == __LITTLE_ENDIAN
98 -    u_int8_t th_x2:4;          /* (unused) */
99 -    u_int8_t th_off:4;         /* data offset */
100 -#  endif
101 -#  if __BYTE_ORDER == __BIG_ENDIAN
102 -    u_int8_t th_off:4;         /* data offset */
103 -    u_int8_t th_x2:4;          /* (unused) */
104 -#  endif
105 -    u_int8_t th_flags;
106 -#  define TH_FIN       0x01
107 -#  define TH_SYN       0x02
108 -#  define TH_RST       0x04
109 -#  define TH_PUSH      0x08
110 -#  define TH_ACK       0x10
111 -#  define TH_URG       0x20
112 -    u_int16_t th_win;          /* window */
113 -    u_int16_t th_sum;          /* checksum */
114 -    u_int16_t th_urp;          /* urgent pointer */
115 -};
116 -
117 -# else /* !__FAVOR_BSD */
118 -struct tcphdr
119 -  {
120 -    u_int16_t source;
121 -    u_int16_t dest;
122 -    u_int32_t seq;
123 -    u_int32_t ack_seq;
124 -#  if __BYTE_ORDER == __LITTLE_ENDIAN
125 -    u_int16_t res1:4;
126 -    u_int16_t doff:4;
127 -    u_int16_t fin:1;
128 -    u_int16_t syn:1;
129 -    u_int16_t rst:1;
130 -    u_int16_t psh:1;
131 -    u_int16_t ack:1;
132 -    u_int16_t urg:1;
133 -    u_int16_t res2:2;
134 -#  elif __BYTE_ORDER == __BIG_ENDIAN
135 -    u_int16_t doff:4;
136 -    u_int16_t res1:4;
137 -    u_int16_t res2:2;
138 -    u_int16_t urg:1;
139 -    u_int16_t ack:1;
140 -    u_int16_t psh:1;
141 -    u_int16_t rst:1;
142 -    u_int16_t syn:1;
143 -    u_int16_t fin:1;
144 -#  else
145 -#   error "Adjust your <bits/endian.h> defines"
146 -#  endif
147 -    u_int16_t window;
148 -    u_int16_t check;
149 -    u_int16_t urg_ptr;
150 -};
151 -# endif /* __FAVOR_BSD */
152 -
153 -enum
154 -{
155 -  TCP_ESTABLISHED = 1,
156 -  TCP_SYN_SENT,
157 -  TCP_SYN_RECV,
158 -  TCP_FIN_WAIT1,
159 -  TCP_FIN_WAIT2,
160 -  TCP_TIME_WAIT,
161 -  TCP_CLOSE,
162 -  TCP_CLOSE_WAIT,
163 -  TCP_LAST_ACK,
164 -  TCP_LISTEN,
165 -  TCP_CLOSING   /* now a valid state */
166 -};
167 -
168 -# define TCPOPT_EOL            0
169 -# define TCPOPT_NOP            1
170 -# define TCPOPT_MAXSEG         2
171 -# define TCPOLEN_MAXSEG                4
172 -# define TCPOPT_WINDOW         3
173 -# define TCPOLEN_WINDOW                3
174 -# define TCPOPT_SACK_PERMITTED 4               /* Experimental */
175 -# define TCPOLEN_SACK_PERMITTED        2
176 -# define TCPOPT_SACK           5               /* Experimental */
177 -# define TCPOPT_TIMESTAMP      8
178 -# define TCPOLEN_TIMESTAMP     10
179 -# define TCPOLEN_TSTAMP_APPA   (TCPOLEN_TIMESTAMP+2) /* appendix A */
180 -
181 -# define TCPOPT_TSTAMP_HDR     \
182 -    (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP)
183 -
184 -/*
185 - * Default maximum segment size for TCP.
186 - * With an IP MSS of 576, this is 536,
187 - * but 512 is probably more convenient.
188 - * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)).
189 - */
190 -# define TCP_MSS       512
191 -
192 -# define TCP_MAXWIN    65535   /* largest value for (unscaled) window */
193 -
194 -# define TCP_MAX_WINSHIFT      14      /* maximum window shift */
195 -
196 -# define SOL_TCP               6       /* TCP level */
197 -
198 -
199 -# define TCPI_OPT_TIMESTAMPS   1
200 -# define TCPI_OPT_SACK         2
201 -# define TCPI_OPT_WSCALE       4
202 -# define TCPI_OPT_ECN          8
203 -# define TCPI_OPT_ECN_SEEN     16
204 -
205 -/* Values for tcpi_state.  */
206 -enum tcp_ca_state
207 -{
208 -  TCP_CA_Open = 0,
209 -  TCP_CA_Disorder = 1,
210 -  TCP_CA_CWR = 2,
211 -  TCP_CA_Recovery = 3,
212 -  TCP_CA_Loss = 4
213 -};
214 -
215 -struct tcp_info
216 -{
217 -  u_int8_t     tcpi_state;
218 -  u_int8_t     tcpi_ca_state;
219 -  u_int8_t     tcpi_retransmits;
220 -  u_int8_t     tcpi_probes;
221 -  u_int8_t     tcpi_backoff;
222 -  u_int8_t     tcpi_options;
223 -  u_int8_t     tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
224 -
225 -  u_int32_t    tcpi_rto;
226 -  u_int32_t    tcpi_ato;
227 -  u_int32_t    tcpi_snd_mss;
228 -  u_int32_t    tcpi_rcv_mss;
229 -
230 -  u_int32_t    tcpi_unacked;
231 -  u_int32_t    tcpi_sacked;
232 -  u_int32_t    tcpi_lost;
233 -  u_int32_t    tcpi_retrans;
234 -  u_int32_t    tcpi_fackets;
235 -
236 -  /* Times. */
237 -  u_int32_t    tcpi_last_data_sent;
238 -  u_int32_t    tcpi_last_ack_sent;     /* Not remembered, sorry.  */
239 -  u_int32_t    tcpi_last_data_recv;
240 -  u_int32_t    tcpi_last_ack_recv;
241 -
242 -  /* Metrics. */
243 -  u_int32_t    tcpi_pmtu;
244 -  u_int32_t    tcpi_rcv_ssthresh;
245 -  u_int32_t    tcpi_rtt;
246 -  u_int32_t    tcpi_rttvar;
247 -  u_int32_t    tcpi_snd_ssthresh;
248 -  u_int32_t    tcpi_snd_cwnd;
249 -  u_int32_t    tcpi_advmss;
250 -  u_int32_t    tcpi_reordering;
251 -  u_int32_t    tcpi_rcv_rtt;
252 -  u_int32_t    tcpi_rcv_space;
253 -  u_int32_t    tcpi_total_retrans;
254 -
255 -};
256 -
257 -#endif /* Misc.  */
258 -
259 -#endif /* netinet/tcp.h */
260 --- a/include/iptables.h
261 +++ b/include/iptables.h
262 @@ -20,7 +20,7 @@ struct ipt_get_revision
263  {
264         char name[IPT_FUNCTION_MAXNAMELEN-1];
265  
266 -       u_int8_t revision;
267 +       uint8_t revision;
268  };
269  #endif /* IPT_SO_GET_REVISION_MATCH   Old kernel source */
270  
271 @@ -39,7 +39,7 @@ struct iptables_match
272         ipt_chainlabel name;
273  
274         /* Revision of match (0 by default). */
275 -       u_int8_t revision;
276 +       uint8_t revision;
277  
278         const char *version;
279  
280 @@ -92,7 +92,7 @@ struct iptables_target
281         ipt_chainlabel name;
282  
283         /* Revision of target (0 by default). */
284 -       u_int8_t revision;
285 +       uint8_t revision;
286  
287         const char *version;
288  
289 @@ -153,7 +153,7 @@ extern char *mask_to_dotted(const struct
290  
291  extern void parse_hostnetworkmask(const char *name, struct in_addr **addrpp,
292                        struct in_addr *maskp, unsigned int *naddrs);
293 -extern u_int16_t parse_protocol(const char *s);
294 +extern uint16_t parse_protocol(const char *s);
295  
296  extern int do_command(int argc, char *argv[], char **table,
297                       iptc_handle_t *handle);
298 --- a/lib/dnet_ntop.c
299 +++ b/lib/dnet_ntop.c
300 @@ -1,24 +1,25 @@
301  #include <errno.h>
302  #include <string.h>
303 +#include <stdint.h>
304  #include <sys/types.h>
305  #include <netinet/in.h>
306  
307  #include "utils.h"
308  
309 -static __inline__ u_int16_t dn_ntohs(u_int16_t addr)
310 +static __inline__ uint16_t dn_ntohs(uint16_t addr)
311  {
312         union {
313 -               u_int8_t byte[2];
314 -               u_int16_t word;
315 +               uint8_t byte[2];
316 +               uint16_t word;
317         } u;
318  
319         u.word = addr;
320 -       return ((u_int16_t)u.byte[0]) | (((u_int16_t)u.byte[1]) << 8);
321 +       return ((uint16_t)u.byte[0]) | (((uint16_t)u.byte[1]) << 8);
322  }
323  
324 -static __inline__ int do_digit(char *str, u_int16_t *addr, u_int16_t scale, size_t *pos, size_t len, int *started)
325 +static __inline__ int do_digit(char *str, uint16_t *addr, uint16_t scale, size_t *pos, size_t len, int *started)
326  {
327 -       u_int16_t tmp = *addr / scale;
328 +       uint16_t tmp = *addr / scale;
329  
330         if (*pos == len)
331                 return 1;
332 @@ -36,7 +37,7 @@ static __inline__ int do_digit(char *str
333  
334  static const char *dnet_ntop1(const struct dn_naddr *dna, char *str, size_t len)
335  {
336 -       u_int16_t addr, area;
337 +       uint16_t addr, area;
338         size_t pos = 0;
339         int started = 0;
340  
341 --- a/lib/dnet_pton.c
342 +++ b/lib/dnet_pton.c
343 @@ -1,23 +1,24 @@
344  #include <errno.h>
345  #include <string.h>
346 +#include <stdint.h>
347  #include <sys/types.h>
348  #include <netinet/in.h>
349  
350  #include "utils.h"
351  
352 -static __inline__ u_int16_t dn_htons(u_int16_t addr)
353 +static __inline__ uint16_t dn_htons(uint16_t addr)
354  {
355          union {
356 -                u_int8_t byte[2];
357 -                u_int16_t word;
358 +                uint8_t byte[2];
359 +                uint16_t word;
360          } u;
361  
362          u.word = addr;
363 -        return ((u_int16_t)u.byte[0]) | (((u_int16_t)u.byte[1]) << 8);
364 +        return ((uint16_t)u.byte[0]) | (((uint16_t)u.byte[1]) << 8);
365  }
366  
367  
368 -static int dnet_num(const char *src, u_int16_t * dst)
369 +static int dnet_num(const char *src, uint16_t * dst)
370  {
371         int rv = 0;
372         int tmp;
373 @@ -38,9 +39,9 @@ static int dnet_num(const char *src, u_i
374  
375  static int dnet_pton1(const char *src, struct dn_naddr *dna)
376  {
377 -       u_int16_t addr;
378 -       u_int16_t area = 0;
379 -       u_int16_t node = 0;
380 +       uint16_t addr;
381 +       uint16_t area = 0;
382 +       uint16_t node = 0;
383         int pos;
384  
385         pos = dnet_num(src, &area);
386 --- a/include/libiptc/ipt_kernel_headers.h
387 +++ b/include/libiptc/ipt_kernel_headers.h
388 @@ -5,7 +5,7 @@
389  
390  #include <limits.h>
391  
392 -#if defined(__GLIBC__) && __GLIBC__ == 2
393 +#if 1
394  #include <netinet/ip.h>
395  #include <netinet/in.h>
396  #include <netinet/ip_icmp.h>