From 86460e9be93df399286e63b8142853d6e5aee5a9 Mon Sep 17 00:00:00 2001 From: Håkon Nessjøen Date: Mon, 27 Sep 2010 16:46:07 +0200 Subject: Minifixes --- main.c | 4 +--- udp.c | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 0d90b0e..df91f94 100644 --- a/main.c +++ b/main.c @@ -34,7 +34,6 @@ int sockfd; int deviceIndex; -int counter=0; int outcounter=0; int sessionkey=0; @@ -88,8 +87,7 @@ void handlePacket(unsigned char *data, int data_len) { int plen=0,result=0; int rest = 0; unsigned char *p = data; - counter += data_len - 22; - plen = initPacket(odata, MT_PTYPE_ACK, srcmac, dstmac, pkthdr.seskey, counter); + plen = initPacket(odata, MT_PTYPE_ACK, srcmac, dstmac, pkthdr.seskey, pkthdr.counter + (data_len - 22)); result = sendCustomUDP(sockfd, deviceIndex, srcmac, dstmac, &sourceip, 20561, &destip, 20561, odata, plen); if (DEBUG) diff --git a/udp.c b/udp.c index e8e0861..0cfce5b 100644 --- a/udp.c +++ b/udp.c @@ -8,6 +8,7 @@ #include #include #include +#include #include unsigned short in_cksum(unsigned short *addr, int len) @@ -43,6 +44,11 @@ int sendCustomUDP(const int socket, const int ifindex, const unsigned char *sour static unsigned int id = 1; int send_result = 0; + if (buffer == NULL) { + perror("malloc"); + exit(1); + } + // Ethernet header memcpy(eh->h_source, sourcemac, ETH_ALEN); memcpy(eh->h_dest, destmac, ETH_ALEN); -- cgit v1.2.3