mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
Fix definion of udphdr and use it.
svn path=/trunk/; revision=12997
This commit is contained in:
parent
85cffe692b
commit
e8d6b09951
1 changed files with 26 additions and 26 deletions
|
@ -231,10 +231,10 @@ static char sccsid[] = "@(#)traceroute.c 8.1 (Berkeley) 6/6/93";
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
|
|
||||||
//void print(buf, cc, from);
|
//void print(buf, cc, from);
|
||||||
char * inetname(in);
|
char * inetname(struct in_addr);
|
||||||
double deltaT(t1p, t2p);
|
double deltaT(struct timeval *, struct timeval *);
|
||||||
void usage();
|
void usage();
|
||||||
void send_probe(seq, ttl);
|
void send_probe(int, int);
|
||||||
|
|
||||||
#define bzero( ptr, count ) memset( ptr, 0, count )
|
#define bzero( ptr, count ) memset( ptr, 0, count )
|
||||||
#define bcopy(src,dest,len) memcpy(dest,src,len)
|
#define bcopy(src,dest,len) memcpy(dest,src,len)
|
||||||
|
@ -336,22 +336,22 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
#define Sprintf (void)sprintf
|
#define Sprintf (void)sprintf
|
||||||
#define Printf (void)printf
|
#define Printf (void)printf
|
||||||
|
|
||||||
// Define the UDP header
|
/*
|
||||||
//
|
* Define the UDP header
|
||||||
typedef struct udp_hdr
|
*/
|
||||||
{
|
typedef struct udphdr {
|
||||||
unsigned short src_portno; // Source port number
|
u_short uh_dport;
|
||||||
unsigned short dst_portno; // Destination port number
|
u_short uh_sport;
|
||||||
unsigned short udp_length; // UDP packet length
|
u_short uh_sum;
|
||||||
unsigned short udp_checksum; // UDP checksum (optional)
|
u_short uh_ulen;
|
||||||
} UDP_HDR, *PUDP_HDR;
|
} udphdr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* format of a (udp) probe packet.
|
* format of a (udp) probe packet.
|
||||||
*/
|
*/
|
||||||
struct opacket {
|
struct opacket {
|
||||||
struct ip ip;
|
struct ip ip;
|
||||||
UDP_HDR udp;
|
udphdr udp;
|
||||||
u_char seq; /* sequence number of this packet */
|
u_char seq; /* sequence number of this packet */
|
||||||
u_char ttl; /* ttl packet left with */
|
u_char ttl; /* ttl packet left with */
|
||||||
struct timeval tv; /* time packet left */
|
struct timeval tv; /* time packet left */
|
||||||
|
@ -428,12 +428,6 @@ main(argc, argv)
|
||||||
WSADATA wsadata;
|
WSADATA wsadata;
|
||||||
INT status;
|
INT status;
|
||||||
|
|
||||||
status = WSAStartup(MAKEWORD(2, 2), &wsadata);
|
|
||||||
if (status != 0) {
|
|
||||||
printf("Could not initialize winsock dll.\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
on = 1;
|
on = 1;
|
||||||
seq = tos = 0;
|
seq = tos = 0;
|
||||||
to = (struct sockaddr_in *)&whereto;
|
to = (struct sockaddr_in *)&whereto;
|
||||||
|
@ -512,6 +506,12 @@ main(argc, argv)
|
||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
status = WSAStartup(MAKEWORD(2, 2), &wsadata);
|
||||||
|
if (status != 0) {
|
||||||
|
printf("Could not initialize winsock dll.\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
setlinebuf (stdout);
|
setlinebuf (stdout);
|
||||||
|
|
||||||
(void) bzero((char *)&whereto, sizeof(struct sockaddr));
|
(void) bzero((char *)&whereto, sizeof(struct sockaddr));
|
||||||
|
@ -736,10 +736,10 @@ send_probe(seq, ttl)
|
||||||
ip->ip_v = IPVERSION;
|
ip->ip_v = IPVERSION;
|
||||||
ip->ip_id = htons(ident+seq);
|
ip->ip_id = htons(ident+seq);
|
||||||
|
|
||||||
// up->uh_sport = htons(ident);
|
up->uh_sport = htons(ident);
|
||||||
// up->uh_dport = htons(port+seq);
|
up->uh_dport = htons(port+seq);
|
||||||
// up->uh_ulen = htons((u_short)(datalen - sizeof(struct ip)));
|
up->uh_ulen = htons((u_short)(datalen - sizeof(struct ip)));
|
||||||
// up->uh_sum = 0;
|
up->uh_sum = 0;
|
||||||
|
|
||||||
op->seq = seq;
|
op->seq = seq;
|
||||||
op->ttl = ttl;
|
op->ttl = ttl;
|
||||||
|
@ -826,9 +826,9 @@ packet_ok(buf, cc, from, seq)
|
||||||
hip = &icp->icmp_ip;
|
hip = &icp->icmp_ip;
|
||||||
hlen = hip->ip_hl << 2;
|
hlen = hip->ip_hl << 2;
|
||||||
up = (struct udphdr *)((u_char *)hip + hlen);
|
up = (struct udphdr *)((u_char *)hip + hlen);
|
||||||
// if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP &&
|
if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP &&
|
||||||
// up->uh_sport == htons(ident) &&
|
up->uh_sport == htons(ident) &&
|
||||||
// up->uh_dport == htons(port+seq))
|
up->uh_dport == htons(port+seq))
|
||||||
if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP)
|
if (hlen + 12 <= cc && hip->ip_p == IPPROTO_UDP)
|
||||||
return (type == ICMP_TIMXCEED? -1 : code+1);
|
return (type == ICMP_TIMXCEED? -1 : code+1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue