openbsd-ports/net/queso/patches/patch-tcpip_c
2003-04-22 12:08:05 +00:00

127 lines
4.0 KiB
Plaintext

$OpenBSD: patch-tcpip_c,v 1.1 2003/04/22 12:08:05 avsm Exp $
--- tcpip.c.orig Tue Sep 22 21:35:43 1998
+++ tcpip.c Mon Apr 14 23:50:21 2003
@@ -40,7 +40,7 @@ interfacerec;
typedef struct
{
struct in_addr addr;
- unsigned long naddr; /* netmask */
+ u_int32_t naddr; /* netmask */
interfacerec *iface;
}
routerec;
@@ -61,11 +61,11 @@ pcap_t *PCapHdlr=NULL;
#endif
int sendsock, readsock;
-unsigned short ipident;
+u_int16_t ipident;
/* This function will determine the checksum for a specific packet. Used by */
/* nearly EVERYTHING on the internet */
-unsigned short
+u_int16_t
inet_checksum (void *addr, int len)
{
register int nleft = len;
@@ -106,16 +106,16 @@ struct psuedohdr {
struct in_addr dest_address;
unsigned char place_holder;
unsigned char protocol;
- unsigned short length;
+ u_int16_t length;
} psuedohdr;
-unsigned short tcp_checksum(char *packet,
+u_int16_t tcp_checksum(char *packet,
int length,
struct in_addr source_address,
struct in_addr dest_address)
{
char *psuedo_packet;
- unsigned short cksum;
+ u_int16_t cksum;
psuedohdr.protocol = IPPROTO_TCP;
psuedohdr.length = htons(length);
@@ -133,7 +133,7 @@ unsigned short tcp_checksum(char *packet
memcpy((psuedo_packet + sizeof(psuedohdr)),
packet,length);
- cksum = inet_checksum((unsigned short *)psuedo_packet,(length + sizeof(psuedohdr)));
+ cksum = inet_checksum((u_int16_t *)psuedo_packet,(length + sizeof(psuedohdr)));
free(psuedo_packet);
return cksum;
}
@@ -153,7 +153,7 @@ resolve_host (char *host, struct sockadd
memset (sa, 0, sizeof (struct sockaddr));
sa->sin_family = AF_INET;
sa->sin_addr.s_addr = inet_addr (host);
- if ((long) inet_addr (host) == -1)
+ if ((int32_t) inet_addr (host) == -1)
{
ent = gethostbyname (host);
if (ent != NULL)
@@ -173,7 +173,7 @@ resolve_host (char *host, struct sockadd
/* Sends a TCP packet */
void
-sendtcp (spoofrec * spoof, unsigned short flags, short rep)
+sendtcp (spoofrec * spoof, u_int16_t flags, short rep)
{
struct tcphdr tcp;
struct ip ip;
@@ -271,6 +271,7 @@ gettcp (spoofrec * spoof, tcprec * dtcp)
switch(datalink) {
case DLT_EN10MB:
offset = 14; break;
+ case DLT_LOOP:
case DLT_NULL:
case DLT_PPP:
offset = 4; break;
@@ -285,6 +286,8 @@ gettcp (spoofrec * spoof, tcprec * dtcp)
offset = 8; break;
case DLT_IEEE802:
offset = 22; break;
+ case DLT_ENC:
+ offset = 12; break;
default:
fprintf(stderr, "unknown datalink type (%d)", datalink);
return(0);
@@ -319,7 +322,7 @@ gettcp (spoofrec * spoof, tcprec * dtcp)
/*-- Linux: Search out IP in Routing tables --*/
/*-- Other: Return hostname ip ---------------*/
struct in_addr
-getlocalip (unsigned long dest)
+getlocalip (u_int32_t dest)
{
static struct in_addr ina;
#ifdef LINUX /*---------------------------------------------- LINUX --*/
@@ -327,7 +330,7 @@ getlocalip (unsigned long dest)
for (i = 0; i < numroutes; i++)
{
- if ((dest & routes[i].naddr) == (unsigned long) routes[i].addr.s_addr)
+ if ((dest & routes[i].naddr) == (u_int32_t) routes[i].addr.s_addr)
{
return (routes[i].iface->addr);
}
@@ -434,7 +437,7 @@ void init_route_tables(void)
else
strcpy (iface, ptr);
ptr = strtok (NULL, "\t "); /* hack avoiding fscanf */
- routes[i].addr.s_addr=(unsigned long)strtol(ptr,NULL,16);
+ routes[i].addr.s_addr=(u_int32_t)strtol(ptr,NULL,16);
for (i1 = 0; i1 < 6; i1++)
{
ptr = strtok (NULL, "\t "); /* ignore Gateway Flags RefCnt Use Metric */
@@ -443,7 +446,7 @@ void init_route_tables(void)
fputs ("Error parsing /proc/net/route\n", stderr);
continue;
}
- routes[i].naddr=(unsigned long)strtol(ptr,NULL,16); /* Netmask */
+ routes[i].naddr=(u_int32_t)strtol(ptr,NULL,16); /* Netmask */
found = 0;
for (i1 = 0; i1 < numinterfaces; i1++)