stopped caring 23 commits ago

This commit is contained in:
Jack Halford 2017-09-01 10:39:21 +02:00
parent b042d94bf6
commit 4e9160f0dd
3 changed files with 5 additions and 6 deletions

View file

@ -11,6 +11,7 @@
# **************************************************************************** # # **************************************************************************** #
NAME = ft_traceroute NAME = ft_traceroute
SHELL := /bin/bash
CC = gcc CC = gcc
W_FLAGS = -Wall -Wextra -Werror W_FLAGS = -Wall -Wextra -Werror

@ -1 +1 @@
Subproject commit 23c69f13242ecbff493356c57cb1384eb1dd45f5 Subproject commit dd612f58c973b6fe9d825557bfa0f62df1e237ef

View file

@ -18,7 +18,6 @@ unsigned short checksum(void *b, int len)
{ {
unsigned short *buf = b; unsigned short *buf = b;
unsigned int sum=0; unsigned int sum=0;
unsigned short result;
for (sum = 0; len > 1; len -= 2) for (sum = 0; len > 1; len -= 2)
sum += *buf++; sum += *buf++;
@ -26,8 +25,7 @@ unsigned short checksum(void *b, int len)
sum += *(unsigned char*)buf; sum += *(unsigned char*)buf;
sum = (sum >> 16) + (sum & 0xFFFF); sum = (sum >> 16) + (sum & 0xFFFF);
sum += (sum >> 16); sum += (sum >> 16);
result = ~sum; return (~sum);
return (result);
} }
int wait_for_reply(struct sockaddr_in *addr, unsigned char buf[1024]) int wait_for_reply(struct sockaddr_in *addr, unsigned char buf[1024])
@ -36,7 +34,7 @@ int wait_for_reply(struct sockaddr_in *addr, unsigned char buf[1024])
if (sd == 0) if (sd == 0)
{ {
if ((sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_ICMP)) < 0) if ((sd = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
{ {
perror("socket"); perror("socket");
exit(0); exit(0);
@ -75,7 +73,7 @@ int traceroute(struct sockaddr_in *dest)
struct timeval t1, t2, trip; struct timeval t1, t2, trip;
double diff; double diff;
if ((sd = socket(PF_INET, SOCK_DGRAM, IPPROTO_ICMP)) < 0) if ((sd = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
{ {
perror("socket"); perror("socket");
return (1); return (1);