void-packages/srcpkgs/traceroute/patches/musl.patch

358 lines
10 KiB
Diff

--- traceroute/csum.c 2013-07-19 16:47:55.000000000 +0200
+++ traceroute/csum.c 2014-12-28 06:31:08.164629774 +0100
@@ -12,11 +12,11 @@
#include "traceroute.h"
-u_int16_t in_csum (const void *ptr, size_t len) {
- const u_int16_t *p = (const u_int16_t *) ptr;
+uint16_t in_csum (const void *ptr, size_t len) {
+ const uint16_t *p = (const uint16_t *) ptr;
size_t nw = len / 2;
unsigned int sum = 0;
- u_int16_t res;
+ uint16_t res;
while (nw--) sum += *p++;
--- traceroute/extension.c 2013-07-14 16:29:08.000000000 +0200
+++ traceroute/extension.c 2014-12-28 06:31:08.164629774 +0100
@@ -14,16 +14,16 @@ struct icmp_ext_header {
unsigned int reserved:4;
unsigned int version:4;
#endif
- u_int8_t reserved1;
- u_int16_t checksum;
+ uint8_t reserved1;
+ uint16_t checksum;
} __attribute__ ((packed));
struct icmp_ext_object {
- u_int16_t length;
- u_int8_t class;
- u_int8_t c_type;
- u_int8_t data[0];
+ uint16_t length;
+ uint8_t class;
+ uint8_t c_type;
+ uint8_t data[0];
};
#define MPLS_CLASS 1
@@ -49,7 +49,7 @@ static int try_extension (probe *pb, cha
if (iext->version != 2) return -1;
if (iext->checksum &&
- in_csum (iext, len) != (u_int16_t) ~0
+ in_csum (iext, len) != (uint16_t) ~0
) return -1;
buf += sizeof (*iext);
@@ -60,7 +60,7 @@ static int try_extension (probe *pb, cha
struct icmp_ext_object *obj = (struct icmp_ext_object *) buf;
size_t objlen = ntohs (obj->length);
size_t data_len;
- u_int32_t *ui = (u_int32_t *) obj->data;
+ uint32_t *ui = (uint32_t *) obj->data;
int i, n;
if (objlen < sizeof (*obj) ||
@@ -68,7 +68,7 @@ static int try_extension (probe *pb, cha
) return -1;
data_len = objlen - sizeof (*obj);
- if (data_len % sizeof (u_int32_t))
+ if (data_len % sizeof (uint32_t))
return -1; /* must be 32bit rounded... */
n = data_len / sizeof (*ui);
@@ -85,7 +85,7 @@ static int try_extension (probe *pb, cha
do_snprintf (curr, end, "MPLS:");
for (i = 0; i < n; i++, ui++) {
- u_int32_t mpls = ntohl (*ui);
+ uint32_t mpls = ntohl (*ui);
do_snprintf (curr, end, "%sL=%u,E=%u,S=%u,T=%u",
i ? "/" : "",
--- traceroute/mod-dccp.c 2013-11-19 16:51:53.000000000 +0100
+++ traceroute/mod-dccp.c 2014-12-28 06:31:08.166629774 +0100
@@ -30,7 +30,7 @@ static unsigned int dest_port = 0;
static int raw_sk = -1;
static int last_ttl = 0;
-static u_int8_t buf[1024]; /* enough, enough... */
+static uint8_t buf[1024]; /* enough, enough... */
static size_t csum_len = 0;
static struct dccp_hdr *dh = NULL;
static struct dccp_hdr_ext *dhe = NULL;
@@ -51,8 +51,8 @@ static int dccp_init (const sockaddr_any
int af = dest->sa.sa_family;
sockaddr_any src;
socklen_t len;
- u_int8_t *ptr;
- u_int16_t *lenp;
+ uint8_t *ptr;
+ uint16_t *lenp;
dest_addr = *dest;
@@ -117,10 +117,10 @@ static int dccp_init (const sockaddr_any
ptr += len;
}
- lenp = (u_int16_t *) ptr;
- ptr += sizeof (u_int16_t);
- *((u_int16_t *) ptr) = htons ((u_int16_t) IPPROTO_DCCP);
- ptr += sizeof (u_int16_t);
+ lenp = (uint16_t *) ptr;
+ ptr += sizeof (uint16_t);
+ *((uint16_t *) ptr) = htons ((uint16_t) IPPROTO_DCCP);
+ ptr += sizeof (uint16_t);
/* Construct DCCP header */
@@ -153,7 +153,7 @@ static int dccp_init (const sockaddr_any
if (csum_len > sizeof (buf))
error ("impossible"); /* paranoia */
- len = ptr - (u_int8_t *) dh;
+ len = ptr - (uint8_t *) dh;
if (len & 0x03) error ("impossible"); /* as >>2 ... */
*lenp = htons (len);
@@ -232,7 +232,7 @@ static probe *dccp_check_reply (int sk,
char *buf, size_t len) {
probe *pb;
struct dccp_hdr *ndh = (struct dccp_hdr *) buf;
- u_int16_t sport, dport;
+ uint16_t sport, dport;
if (len < 8) return NULL; /* too short */
--- traceroute/mod-icmp.c 2014-11-12 00:55:56.000000000 +0100
+++ traceroute/mod-icmp.c 2014-12-28 06:31:08.167629774 +0100
@@ -20,8 +20,8 @@
static sockaddr_any dest_addr = {{ 0, }, };
-static u_int16_t seq = 1;
-static u_int16_t ident = 0;
+static uint16_t seq = 1;
+static uint16_t ident = 0;
static char *data;
static size_t *length_p;
@@ -173,7 +173,7 @@ static probe *icmp_check_reply (int sk,
char *buf, size_t len) {
int af = dest_addr.sa.sa_family;
int type;
- u_int16_t recv_id, recv_seq;
+ uint16_t recv_id, recv_seq;
probe *pb;
--- traceroute/mod-tcp.c 2013-03-27 15:01:15.000000000 +0100
+++ traceroute/mod-tcp.c 2014-12-28 06:35:44.165642089 +0100
@@ -26,6 +26,37 @@
#define IP_MTU 14
#endif
+#ifndef TCPOPT_NOP
+# define TCPOPT_NOP 1
+#endif
+#ifndef TCPOPT_MAXSEG
+# define TCPOPT_MAXSEG 2
+#endif
+#ifndef TCPOPT_WINDOW
+# define TCPOPT_WINDOW 3
+#endif
+#ifndef TCPOPT_SACK_PERMITTED
+# define TCPOPT_SACK_PERMITTED 4
+#endif
+#ifndef TCPOPT_SACK
+# define TCPOPT_SACK 5
+#endif
+#ifndef TCPOPT_TIMESTAMP
+# define TCPOPT_TIMESTAMP 8
+#endif
+
+#ifndef TCPOLEN_MAXSEG
+# define TCPOLEN_MAXSEG 4
+#endif
+#ifndef TCPOLEN_WINDOW
+# define TCPOLEN_WINDOW 3
+#endif
+#ifndef TCPOLEN_SACK_PERMITTED
+# define TCPOLEN_SACK_PERMITTED 2
+#endif
+#ifndef TCPOLEN_TIMESTAMP
+# define TCPOLEN_TIMESTAMP 10
+#endif
static sockaddr_any dest_addr = {{ 0, }, };
static unsigned int dest_port = 0;
@@ -33,11 +64,11 @@ static unsigned int dest_port = 0;
static int raw_sk = -1;
static int last_ttl = 0;
-static u_int8_t buf[1024]; /* enough, enough... */
+static uint8_t buf[1024]; /* enough, enough... */
static size_t csum_len = 0;
static struct tcphdr *th = NULL;
-#define TH_FLAGS(TH) (((u_int8_t *) (TH))[13])
+#define TH_FLAGS(TH) (((uint8_t *) (TH))[13])
#define TH_FIN 0x01
#define TH_SYN 0x02
#define TH_RST 0x04
@@ -164,7 +195,7 @@ static CLIF_option tcp_options[] = {
static int check_sysctl (const char *name) {
int fd, res;
char buf[sizeof (SYSCTL_PREFIX) + strlen (name) + 1];
- u_int8_t ch;
+ uint8_t ch;
strcpy (buf, SYSCTL_PREFIX);
strcat (buf, name);
@@ -191,8 +222,8 @@ static int tcp_init (const sockaddr_any
sockaddr_any src;
int mtu;
socklen_t len;
- u_int8_t *ptr;
- u_int16_t *lenp;
+ uint8_t *ptr;
+ uint16_t *lenp;
dest_addr = *dest;
@@ -286,10 +317,10 @@ static int tcp_init (const sockaddr_any
ptr += len;
}
- lenp = (u_int16_t *) ptr;
- ptr += sizeof (u_int16_t);
- *((u_int16_t *) ptr) = htons ((u_int16_t) IPPROTO_TCP);
- ptr += sizeof (u_int16_t);
+ lenp = (uint16_t *) ptr;
+ ptr += sizeof (uint16_t);
+ *((uint16_t *) ptr) = htons ((uint16_t) IPPROTO_TCP);
+ ptr += sizeof (uint16_t);
/* Construct TCP header */
@@ -309,13 +340,13 @@ static int tcp_init (const sockaddr_any
/* Build TCP options */
- ptr = (u_int8_t *) (th + 1);
+ ptr = (uint8_t *) (th + 1);
if (flags & TH_SYN) {
*ptr++ = TCPOPT_MAXSEG; /* 2 */
*ptr++ = TCPOLEN_MAXSEG; /* 4 */
- *((u_int16_t *) ptr) = htons (mss ? mss : mtu);
- ptr += sizeof (u_int16_t);
+ *((uint16_t *) ptr) = htons (mss ? mss : mtu);
+ ptr += sizeof (uint16_t);
}
if (flags & FL_TSTAMP) {
@@ -330,10 +361,10 @@ static int tcp_init (const sockaddr_any
*ptr++ = TCPOPT_TIMESTAMP; /* 8 */
*ptr++ = TCPOLEN_TIMESTAMP; /* 10 */
- *((u_int32_t *) ptr) = random_seq (); /* really! */
- ptr += sizeof (u_int32_t);
- *((u_int32_t *) ptr) = (flags & TH_ACK) ? random_seq () : 0;
- ptr += sizeof (u_int32_t);
+ *((uint32_t *) ptr) = random_seq (); /* really! */
+ ptr += sizeof (uint32_t);
+ *((uint32_t *) ptr) = (flags & TH_ACK) ? random_seq () : 0;
+ ptr += sizeof (uint32_t);
}
else if (flags & FL_SACK) {
*ptr++ = TCPOPT_NOP; /* 1 */
@@ -355,7 +386,7 @@ static int tcp_init (const sockaddr_any
if (csum_len > sizeof (buf))
error ("impossible"); /* paranoia */
- len = ptr - (u_int8_t *) th;
+ len = ptr - (uint8_t *) th;
if (len & 0x03) error ("impossible"); /* as >>2 ... */
*lenp = htons (len);
@@ -436,7 +467,7 @@ static probe *tcp_check_reply (int sk, i
char *buf, size_t len) {
probe *pb;
struct tcphdr *tcp = (struct tcphdr *) buf;
- u_int16_t sport, dport;
+ uint16_t sport, dport;
if (len < 8) return NULL; /* too short */
--- traceroute/mod-udp.c 2013-12-14 15:51:44.000000000 +0100
+++ traceroute/mod-udp.c 2014-12-28 06:31:08.172629774 +0100
@@ -71,7 +71,7 @@ static int udp_init (const sockaddr_any
dest_addr = *dest;
if (!port_seq) port_seq = DEF_UDP_PORT;
- dest_addr.sin.sin_port = htons ((u_int16_t) port_seq);
+ dest_addr.sin.sin_port = htons ((uint16_t) port_seq);
fill_data (packet_len_p);
@@ -107,7 +107,7 @@ static int udplite_init (const sockaddr_
dest_addr = *dest;
if (!port_seq) port_seq = DEF_UDP_PORT; /* XXX: Hmmm... */
- dest_addr.sin.sin_port = htons ((u_int16_t) port_seq);
+ dest_addr.sin.sin_port = htons ((uint16_t) port_seq);
protocol = IPPROTO_UDPLITE;
--- traceroute/traceroute.c 2014-11-12 04:33:00.000000000 +0100
+++ traceroute/traceroute.c 2014-12-28 06:32:30.278633438 +0100
@@ -52,6 +52,12 @@
#define IPV6_PMTUDISC_PROBE 3
#endif
+#ifndef AI_IDN
+#define AI_IDN 0
+#endif
+#ifndef NI_IDN
+#define NI_IDN 0
+#endif
#define MAX_HOPS 255
#define MAX_PROBES 10
@@ -325,7 +331,7 @@ static void init_ip_options (void) {
rth->ip6r_type = ipv6_rthdr_type;
rth->ip6r_segleft = num_gateways;
- *((u_int32_t *) (rth + 1)) = 0;
+ *((uint32_t *) (rth + 1)) = 0;
in6 = (struct in6_addr *) (rtbuf + 8);
for (i = 0; i < num_gateways; i++)
@@ -606,7 +612,7 @@ int main (int argc, char *argv[]) {
htonl (((tos & 0xff) << 20) | (flow_label & 0x000fffff));
if (src_port) {
- src_addr.sin.sin_port = htons ((u_int16_t) src_port);
+ src_addr.sin.sin_port = htons ((uint16_t) src_port);
src_addr.sa.sa_family = af;
}
--- traceroute/traceroute.h 2013-11-19 15:46:11.000000000 +0100
+++ traceroute/traceroute.h 2014-12-28 06:31:08.180629775 +0100
@@ -92,7 +92,7 @@ const char *get_as_path (const char *que
int raw_can_connect (void);
unsigned int random_seq (void);
-u_int16_t in_csum (const void *ptr, size_t len);
+uint16_t in_csum (const void *ptr, size_t len);
void tr_register_module (tr_module *module);