[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18930 - gnunet/src/vpn
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18930 - gnunet/src/vpn |
Date: |
Mon, 2 Jan 2012 11:22:43 +0100 |
Author: grothoff
Date: 2012-01-02 11:22:43 +0100 (Mon, 02 Jan 2012)
New Revision: 18930
Removed:
gnunet/src/vpn/gnunet-vpn-checksum.c
gnunet/src/vpn/gnunet-vpn-checksum.h
Modified:
gnunet/src/vpn/Makefile.am
gnunet/src/vpn/gnunet-daemon-exit.c
gnunet/src/vpn/gnunet-daemon-vpn.c
Log:
-vpn should use crc16 from util
Modified: gnunet/src/vpn/Makefile.am
===================================================================
--- gnunet/src/vpn/Makefile.am 2012-01-02 10:22:17 UTC (rev 18929)
+++ gnunet/src/vpn/Makefile.am 2012-01-02 10:22:43 UTC (rev 18930)
@@ -33,8 +33,7 @@
gnunet-helper-vpn.c
gnunet_daemon_vpn_SOURCES = \
- gnunet-daemon-vpn.c gnunet-daemon-vpn.h \
- gnunet-vpn-checksum.c gnunet-vpn-checksum.h
+ gnunet-daemon-vpn.c gnunet-daemon-vpn.h
gnunet_daemon_vpn_LDADD = \
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
@@ -45,8 +44,7 @@
$(GN_LIBINTL)
gnunet_daemon_exit_SOURCES = \
- gnunet-daemon-exit.c \
- gnunet-vpn-checksum.c gnunet-vpn-checksum.h
+ gnunet-daemon-exit.c
gnunet_daemon_exit_LDADD = \
$(top_builddir)/src/core/libgnunetcore.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
Modified: gnunet/src/vpn/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-exit.c 2012-01-02 10:22:17 UTC (rev 18929)
+++ gnunet/src/vpn/gnunet-daemon-exit.c 2012-01-02 10:22:43 UTC (rev 18930)
@@ -835,8 +835,8 @@
pkt4_tcp->tcp_hdr.crc = 0;
uint32_t sum = 0;
- sum = calculate_checksum_update (sum, (uint16_t *) &pkt4->ip_hdr.sadr,
sizeof (struct in_addr));
- sum = calculate_checksum_update (sum, (uint16_t *) &pkt4->ip_hdr.dadr,
sizeof (struct in_addr));
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) &pkt4->ip_hdr.sadr,
sizeof (struct in_addr));
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) &pkt4->ip_hdr.dadr,
sizeof (struct in_addr));
tmp = (protocol << 16) | (0xffff & pktlen);
@@ -845,16 +845,16 @@
tmp = htonl (tmp);
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt4_tcp->tcp_hdr,
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt4_tcp->tcp_hdr,
pktlen);
- pkt4_tcp->tcp_hdr.crc = calculate_checksum_end (sum);
+ pkt4_tcp->tcp_hdr.crc = GNUNET_CRYPTO_crc16_finish (sum);
}
pkt4->ip_hdr.chks =
- calculate_ip_checksum ((uint16_t *) & pkt4->ip_hdr, 5 * 4);
+ GNUNET_CRYPTO_crc16_n ((uint16_t *) & pkt4->ip_hdr, 5 * 4);
}
static void
@@ -919,20 +919,20 @@
uint32_t sum = 0;
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6_udp->ip6_hdr.sadr,
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6_udp->ip6_hdr.sadr,
16);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6_udp->ip6_hdr.dadr,
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6_udp->ip6_hdr.dadr,
16);
tmp = (htons (pktlen) & 0xffff);
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
tmp = htons (((pkt6_udp->ip6_hdr.nxthdr & 0x00ff)));
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6_udp->udp_hdr,
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6_udp->udp_hdr,
ntohs (pkt6_udp->udp_hdr.len));
- pkt6_udp->udp_hdr.crc = calculate_checksum_end (sum);
+ pkt6_udp->udp_hdr.crc = GNUNET_CRYPTO_crc16_finish (sum);
}
else if (IPPROTO_TCP == protocol)
{
@@ -944,18 +944,18 @@
uint32_t sum = 0;
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6->ip6_hdr.sadr, 16);
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6->ip6_hdr.sadr, 16);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6->ip6_hdr.dadr, 16);
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6->ip6_hdr.dadr, 16);
tmp = htonl (pktlen);
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
tmp = htonl (((pkt6->ip6_hdr.nxthdr & 0x000000ff)));
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6_tcp->tcp_hdr,
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6_tcp->tcp_hdr,
ntohs (pkt6->ip6_hdr.paylgth));
- pkt6_tcp->tcp_hdr.crc = calculate_checksum_end (sum);
+ pkt6_tcp->tcp_hdr.crc = GNUNET_CRYPTO_crc16_finish (sum);
}
}
Modified: gnunet/src/vpn/gnunet-daemon-vpn.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-vpn.c 2012-01-02 10:22:17 UTC (rev 18929)
+++ gnunet/src/vpn/gnunet-daemon-vpn.c 2012-01-02 10:22:43 UTC (rev 18930)
@@ -299,18 +299,18 @@
pkt->udp_dns.udp_hdr.crc = 0;
uint32_t sum = 0;
- sum = calculate_checksum_update (sum, (uint16_t *) & pkt->ip6_hdr.sadr,
16);
- sum = calculate_checksum_update (sum, (uint16_t *) & pkt->ip6_hdr.dadr,
16);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt->ip6_hdr.sadr, 16);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt->ip6_hdr.dadr, 16);
uint32_t tmp = (pkt->udp_dns.udp_hdr.len & 0xffff);
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
tmp = htons (((pkt->ip6_hdr.nxthdr & 0x00ff)));
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt->udp_dns.udp_hdr,
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt->udp_dns.udp_hdr,
ntohs (net_len - sizeof (struct ip6_hdr)));
- pkt->udp_dns.udp_hdr.crc = calculate_checksum_end (sum);
+ pkt->udp_dns.udp_hdr.crc = GNUNET_CRYPTO_crc16_finish (sum);
pkt->ip6_hdr.version = 6;
pkt->ip6_hdr.paylgth = net_len - sizeof (struct ip6_hdr);
@@ -360,7 +360,7 @@
memcpy (&pkt->ip_hdr.dadr, ans->pkt.to, 4);
pkt->ip_hdr.chks =
- calculate_ip_checksum ((uint16_t *) & pkt->ip_hdr, 5 * 4);
+ GNUNET_CRYPTO_crc16_n ((uint16_t *) & pkt->ip_hdr, 5 * 4);
/* set the udp-header */
pkt->udp_dns.udp_hdr.spt = htons (53);
@@ -805,7 +805,7 @@
response->ip_hdr.tot_lngth = request->ip_hdr.tot_lngth;
response->ip_hdr.chks =
- calculate_ip_checksum ((uint16_t *) & response->ip_hdr, 20);
+ GNUNET_CRYPTO_crc16_n ((uint16_t *) & response->ip_hdr, 20);
response->icmp_hdr.code = 0;
response->icmp_hdr.type = 0x0;
@@ -1475,19 +1475,19 @@
uint32_t sum = 0;
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6->ip6_hdr.sadr, 16);
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6->ip6_hdr.sadr, 16);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6->ip6_hdr.dadr, 16);
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6->ip6_hdr.dadr, 16);
uint32_t tmp = (pkt6->udp_hdr.len & 0xffff);
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
tmp = htons (((pkt6->ip6_hdr.nxthdr & 0x00ff)));
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6->udp_hdr,
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6->udp_hdr,
ntohs (pkt->len));
- pkt6->udp_hdr.crc = calculate_checksum_end (sum);
+ pkt6->udp_hdr.crc = GNUNET_CRYPTO_crc16_finish (sum);
(void) GNUNET_HELPER_send (helper_handle,
&pkt6->shdr,
@@ -1561,7 +1561,7 @@
pkt4->udp_hdr.crc = 0; /* Optional for IPv4 */
pkt4->ip_hdr.chks =
- calculate_ip_checksum ((uint16_t *) & pkt4->ip_hdr, 5 * 4);
+ GNUNET_CRYPTO_crc16_n ((uint16_t *) & pkt4->ip_hdr, 5 * 4);
(void) GNUNET_HELPER_send (helper_handle,
&pkt4->shdr,
@@ -1655,18 +1655,18 @@
uint32_t tmp;
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6->ip6_hdr.sadr, 16);
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6->ip6_hdr.sadr, 16);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6->ip6_hdr.dadr, 16);
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6->ip6_hdr.dadr, 16);
tmp = htonl (pktlen);
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
tmp = htonl (((pkt6->ip6_hdr.nxthdr & 0x000000ff)));
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
sum =
- calculate_checksum_update (sum, (uint16_t *) & pkt6->tcp_hdr,
+ GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt6->tcp_hdr,
ntohs (pkt6->ip6_hdr.paylgth));
- pkt6->tcp_hdr.crc = calculate_checksum_end (sum);
+ pkt6->tcp_hdr.crc = GNUNET_CRYPTO_crc16_finish (sum);
(void) GNUNET_HELPER_send (helper_handle,
&pkt6->shdr,
@@ -1737,20 +1737,20 @@
uint32_t sum = 0;
uint32_t tmp;
- sum = calculate_checksum_update (sum, (uint16_t *) &pkt4->ip_hdr.sadr, 4);
- sum = calculate_checksum_update (sum, (uint16_t *) &pkt4->ip_hdr.dadr, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) &pkt4->ip_hdr.sadr, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) &pkt4->ip_hdr.dadr, 4);
tmp = (0x06 << 16) | (0xffff & pktlen); // 0x06 for TCP?
tmp = htonl (tmp);
- sum = calculate_checksum_update (sum, (uint16_t *) & tmp, 4);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & tmp, 4);
- sum = calculate_checksum_update (sum, (uint16_t *) & pkt4->tcp_hdr,
pktlen);
- pkt4->tcp_hdr.crc = calculate_checksum_end (sum);
+ sum = GNUNET_CRYPTO_crc16_step (sum, (uint16_t *) & pkt4->tcp_hdr, pktlen);
+ pkt4->tcp_hdr.crc = GNUNET_CRYPTO_crc16_finish (sum);
pkt4->ip_hdr.chks =
- calculate_ip_checksum ((uint16_t *) & pkt4->ip_hdr, 5 * 4);
+ GNUNET_CRYPTO_crc16_n ((uint16_t *) & pkt4->ip_hdr, 5 * 4);
(void) GNUNET_HELPER_send (helper_handle,
&pkt4->shdr,
Deleted: gnunet/src/vpn/gnunet-vpn-checksum.c
===================================================================
--- gnunet/src/vpn/gnunet-vpn-checksum.c 2012-01-02 10:22:17 UTC (rev
18929)
+++ gnunet/src/vpn/gnunet-vpn-checksum.c 2012-01-02 10:22:43 UTC (rev
18930)
@@ -1,57 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010 Christian Grothoff
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file vpn/gnunet-vpn-checksum.c
- * @brief
- * @author Philipp Toelke
- */
-
-#include "gnunet-vpn-checksum.h"
-
-uint32_t
-calculate_checksum_update (uint32_t sum, uint16_t * hdr, short len)
-{
- for (; len >= 2; len -= 2)
- sum += *(hdr++);
- if (len == 1)
- sum += *((unsigned char *) hdr);
- return sum;
-}
-
-uint16_t
-calculate_checksum_end (uint32_t sum)
-{
- while (sum >> 16)
- sum = (sum >> 16) + (sum & 0xFFFF);
-
- return ~sum;
-}
-
-/**
- * Calculate the checksum of an IPv4-Header
- */
-uint16_t
-calculate_ip_checksum (uint16_t * hdr, short len)
-{
- uint32_t sum = calculate_checksum_update (0, hdr, len);
-
- return calculate_checksum_end (sum);
-}
Deleted: gnunet/src/vpn/gnunet-vpn-checksum.h
===================================================================
--- gnunet/src/vpn/gnunet-vpn-checksum.h 2012-01-02 10:22:17 UTC (rev
18929)
+++ gnunet/src/vpn/gnunet-vpn-checksum.h 2012-01-02 10:22:43 UTC (rev
18930)
@@ -1,37 +0,0 @@
-/*
- This file is part of GNUnet.
- (C) 2010 Christian Grothoff
-
- GNUnet is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3, or (at your
- option) any later version.
-
- GNUnet is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-*/
-#ifndef GNUNET_VPN_CHECKSUM_H
-#define GNUNET_VPN_CHECKSUM_H
-
-#include <platform.h>
-
-uint32_t
-calculate_checksum_update (uint32_t sum, uint16_t * hdr, short len);
-
-uint16_t
-calculate_checksum_end (uint32_t sum);
-
-/**
- * Calculate the checksum of an IPv4-Header
- */
-uint16_t
-calculate_ip_checksum (uint16_t * hdr, short len);
-
-#endif /* end of include guard: GNUNET-VPN-CHECKSUM_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18930 - gnunet/src/vpn,
gnunet <=