mirror of
https://github.com/dennypage/dpinger.git
synced 2024-05-19 06:50:01 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c5bac8658 | ||
|
|
3a19391cee | ||
|
|
570ade420a | ||
|
|
3825066db9 | ||
|
|
f06b3c8f36 |
2
LICENSE
2
LICENSE
@@ -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
|
||||
|
||||
10
Makefile
10
Makefile
@@ -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
9
Makefile.freebsd
Normal file
@@ -0,0 +1,9 @@
|
||||
PROG= dpinger
|
||||
MAN=
|
||||
|
||||
BINDIR= ${PREFIX}/bin
|
||||
WARNS= 6
|
||||
|
||||
LDADD= -lpthread
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
20
dpinger.c
20
dpinger.c
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user