From dcf815703b327bd6500c0bdea60cb85f67994d5a Mon Sep 17 00:00:00 2001 From: Håkon Nessjøen Date: Sun, 26 Sep 2010 22:13:47 +0200 Subject: Cleanup, and correctly handle connection closing --- udp.c | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) (limited to 'udp.c') diff --git a/udp.c b/udp.c index 96fd906..2881f89 100644 --- a/udp.c +++ b/udp.c @@ -10,52 +10,6 @@ #include #include -unsigned short udp_sum_calc(unsigned short len_udp, unsigned char src_addr[],unsigned char dest_addr[], unsigned char buff[]) { - unsigned short prot_udp=17; - unsigned short padd=0; - unsigned short word16; - unsigned long sum; - int i; - - // Find out if the length of data is even or odd number. If odd, - // add a padding byte = 0 at the end of packet - if (len_udp % 2 == 1){ - padd=1; - buff[len_udp]=0; - } - - //initialize sum to zero - sum=0; - - // make 16 bit words out of every two adjacent 8 bit words and - // calculate the sum of all 16 vit words - for (i=0;i>16) - sum = (sum & 0xFFFF)+(sum >> 16); - - // Take the one's complement of sum - sum = ~sum; - - return ((unsigned short) sum); -} - -//#define ETH_FRAME_LEN 1518 unsigned short in_cksum(unsigned short *addr, int len) { int nleft = len; @@ -161,7 +115,6 @@ int sendCustomUDP(const int socket, const char *sourcemac, const char *destmac, udp->dest = htons(20561); udp->check = 0; udp->len = htons(sizeof(struct udphdr) + datalen); - //udp->check = udp_sum_calc(datalen+8, (unsigned char *)&(ip->saddr), (unsigned char *)&(ip->daddr), (unsigned char *)udp); memcpy(resten, data, datalen); -- cgit v1.2.3