1
0
mirror of https://github.com/dennypage/dpinger.git synced 2024-05-19 06:50:01 +00:00

5 Commits
v1.5 ... v1.6

Author SHA1 Message Date
Denny Page
9c5bac8658 Add casts to eliminate some warnings from clang -Weverything 2016-02-01 13:21:46 -08:00
Denny Page
3a19391cee Update Copyright 2016-02-01 13:21:11 -08:00
Denny Page
570ade420a Add simple Makefile 2016-02-01 13:16:02 -08:00
Denny Page
3825066db9 Rename Makefile to Makefile.freebsd 2016-02-01 10:57:32 -08:00
Denny Page
f06b3c8f36 Fix compile warnings for FreeBSD ports 2016-02-01 09:27:55 -08:00
4 changed files with 23 additions and 18 deletions

View File

@@ -1,4 +1,4 @@
Copyright (c) 2015, Denny Page
Copyright (c) 2015-2016, Denny Page
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -1,9 +1,5 @@
PROG= dpinger
MAN=
WARNINGS=-Wall -Wextra -Wformat=2
BINDIR= ${PREFIX}/bin
WARNS= 6
CFLAGS=${WARNINGS} -pthread -g
LDADD= -lpthread
.include <bsd.prog.mk>
all: dpinger

9
Makefile.freebsd Normal file
View File

@@ -0,0 +1,9 @@
PROG= dpinger
MAN=
BINDIR= ${PREFIX}/bin
WARNS= 6
LDADD= -lpthread
.include <bsd.prog.mk>

View File

@@ -150,8 +150,8 @@ static int recv_sock;
// IPv4 / IPv6 parameters
static uint16_t af_family = AF_INET; // IPv6: AF_INET6
static uint16_t echo_request_type = ICMP_ECHO; // IPv6: ICMP6_ECHO_REQUEST
static uint16_t echo_reply_type = ICMP_ECHOREPLY; // IPv6: ICMP6_ECHO_REPLY
static uint8_t echo_request_type = ICMP_ECHO; // IPv6: ICMP6_ECHO_REQUEST
static uint8_t echo_reply_type = ICMP_ECHOREPLY; // IPv6: ICMP6_ECHO_REPLY
static int ip_proto = IPPROTO_ICMP; // IPv6: IPPROTO_ICMPV6
// Destination address
@@ -180,7 +180,7 @@ typedef struct
#define IPV6_ICMP_DATA_MAX (IP_MAXPACKET - sizeof(icmphdr_t))
#define PACKET_BUFLEN (IP_MAXPACKET + 256)
unsigned long echo_data_len = 0;
static unsigned long echo_data_len = 0;
static unsigned int echo_request_len = sizeof(icmphdr_t);
static unsigned int echo_reply_len = IP_MAXPACKET;
static icmphdr_t * echo_request;
@@ -262,7 +262,7 @@ cksum(
sum = (sum >> 16) + (sum & 0xFFFF);
sum += (sum >> 16);
return ~sum;
return (uint16_t) ~sum;
}
@@ -378,7 +378,7 @@ recv_thread(
{
struct sockaddr_storage src_addr;
socklen_t src_addr_len;
unsigned int len;
size_t len;
icmphdr_t * icmp;
struct timespec now;
unsigned int array_slot;
@@ -406,9 +406,9 @@ recv_thread(
continue;
}
ip = echo_reply;
ip_len = ip->ip_hl << 2;
ip_len = (size_t) ip->ip_hl << 2;
icmp = (void *) ip + ip_len;
icmp = (void *) ((char *) ip + ip_len);
len -= ip_len;
}
else
@@ -1305,7 +1305,7 @@ main(
}
// Create the array
array_size = time_period_msec / send_interval_msec;
array_size = (unsigned int) (time_period_msec / send_interval_msec);
array = calloc(array_size, sizeof(*array));
if (array == NULL)
{
@@ -1352,10 +1352,10 @@ main(
echo_id = htons(getpid());
// Set the limit for sequence number to ensure a multiple of array size
sequence_limit = array_size;
sequence_limit = (uint16_t) array_size;
while ((sequence_limit & 0x8000) == 0)
{
sequence_limit = sequence_limit << 1;
sequence_limit <<= 1;
}
// Create recv thread