summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2013-08-08 17:07:26 +0200
committerTobias Klauser <tklauser@distanz.ch>2013-08-08 17:07:26 +0200
commit74c8dc28231e004b898657622b3e7d3eafd4567c (patch)
treead4ed8c1a4b4fa6ab700d3731682af1a111b7c5a
parent25192f6f7825b1908e825d0fca55db88610038e1 (diff)
astraceroute: Use size_t for struct members storing packet lengths
Packet lengths are strictly positive and the functions dealing with them (sendto(), recvfrom() etc.) take size_t, thus use size_t. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--astraceroute.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/astraceroute.c b/astraceroute.c
index ddf352b..45b4550 100644
--- a/astraceroute.c
+++ b/astraceroute.c
@@ -49,7 +49,8 @@
struct ctx {
char *host, *port, *dev, *payload;
- int init_ttl, max_ttl, dns_resolv, queries, timeout, totlen, rcvlen;
+ size_t totlen, rcvlen;
+ int init_ttl, max_ttl, dns_resolv, queries, timeout;
int syn, ack, ecn, fin, psh, rst, urg, tos, nofrag, proto, show;
int sd_len, dport, latitude;
};
@@ -60,7 +61,7 @@ struct proto_ops {
const struct sockaddr *src);
const struct sock_filter *filter;
unsigned int flen;
- unsigned int min_len_tcp, min_len_icmp;
+ size_t min_len_tcp, min_len_icmp;
int (*check)(uint8_t *packet, size_t len, int ttl, int id,
const struct sockaddr *src);
void (*handler)(uint8_t *packet, size_t len, int dns_resolv,
@@ -566,7 +567,7 @@ static void show_trace_info(struct ctx *ctx, const struct sockaddr_storage *ss,
getnameinfo((struct sockaddr *) ss, sizeof(*ss),
hbuffs, sizeof(hbuffs), NULL, 0, NI_NUMERICHOST);
- printf("AS path IPv%d TCP trace from %s to %s:%s (%s) with len %d "
+ printf("AS path IPv%d TCP trace from %s to %s:%s (%s) with len %zu "
"Bytes, %u max hops\n", ctx->proto == IPPROTO_IP ? 4 : 6,
hbuffs, hbuffd, ctx->port, ctx->host, ctx->totlen, ctx->max_ttl);
@@ -1021,8 +1022,8 @@ int main(int argc, char **argv)
ctx.payload = xstrdup(optarg);
break;
case 'l':
- ctx.totlen = atoi(optarg);
- if (ctx.totlen <= 0)
+ ctx.totlen = strtoul(optarg, NULL, 10);
+ if (ctx.totlen == 0)
help();
break;
case '?':