diff --git a/Makefile.dep b/Makefile.dep index b265929a77..369556ff5d 100644 --- a/Makefile.dep +++ b/Makefile.dep @@ -99,12 +99,12 @@ ifneq (,$(filter ng_icmpv6_echo,$(USEMODULE))) endif ifneq (,$(filter ng_icmpv6,$(USEMODULE))) - USEMODULE += ng_inet_csum + USEMODULE += inet_csum USEMODULE += ng_ipv6 endif ifneq (,$(filter ng_ipv6_hdr,$(USEMODULE))) - USEMODULE += ng_inet_csum + USEMODULE += inet_csum USEMODULE += ng_pktbuf endif @@ -125,7 +125,7 @@ ifneq (,$(filter ng_ipv6_router,$(USEMODULE))) endif ifneq (,$(filter ng_ipv6,$(USEMODULE))) - USEMODULE += ng_inet_csum + USEMODULE += inet_csum USEMODULE += ng_ipv6_addr USEMODULE += ng_ipv6_hdr USEMODULE += ng_ipv6_nc @@ -144,7 +144,7 @@ endif ifneq (,$(filter ng_udp,$(USEMODULE))) USEMODULE += ng_netbase - USEMODULE += ng_inet_csum + USEMODULE += inet_csum endif ifneq (,$(filter ng_nettest,$(USEMODULE))) diff --git a/sys/Makefile b/sys/Makefile index e1313c6032..2e616b9f49 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -43,8 +43,8 @@ endif ifneq (,$(filter ng_ipv6_netif,$(USEMODULE))) DIRS += net/network_layer/ng_ipv6/netif endif -ifneq (,$(filter ng_inet_csum,$(USEMODULE))) - DIRS += net/crosslayer/ng_inet_csum +ifneq (,$(filter inet_csum,$(USEMODULE))) + DIRS += net/crosslayer/inet_csum endif ifneq (,$(filter ng_ndp,$(USEMODULE))) DIRS += net/network_layer/ng_ndp diff --git a/sys/include/net/ng_inet_csum.h b/sys/include/net/inet_csum.h similarity index 84% rename from sys/include/net/ng_inet_csum.h rename to sys/include/net/inet_csum.h index 97550baa94..53134053f6 100644 --- a/sys/include/net/ng_inet_csum.h +++ b/sys/include/net/inet_csum.h @@ -7,7 +7,7 @@ */ /** - * @defgroup net_ng_inet_csum Internet Checksum + * @defgroup net_inet_csum Internet Checksum * @ingroup net * @brief Provides a function to calculate the Internet Checksum * @{ @@ -17,8 +17,8 @@ * * @author Martine Lenders */ -#ifndef NG_INET_CSUM_H_ -#define NG_INET_CSUM_H_ +#ifndef INET_CSUM_H_ +#define INET_CSUM_H_ #include @@ -42,11 +42,11 @@ extern "C" { * * @return The unnormalized Internet Checksum of @p buf. */ -uint16_t ng_inet_csum(uint16_t sum, const uint8_t *buf, uint16_t len); +uint16_t inet_csum(uint16_t sum, const uint8_t *buf, uint16_t len); #ifdef __cplusplus } #endif -#endif /* NG_INET_CSUM_H_ */ +#endif /* INET_CSUM_H_ */ /** @} */ diff --git a/sys/include/net/ng_ipv6/hdr.h b/sys/include/net/ng_ipv6/hdr.h index cb7c842885..90e6b58c1e 100644 --- a/sys/include/net/ng_ipv6/hdr.h +++ b/sys/include/net/ng_ipv6/hdr.h @@ -24,7 +24,7 @@ #include "byteorder.h" #include "net/ng_ipv6/addr.h" -#include "net/ng_inet_csum.h" +#include "net/inet_csum.h" #include "net/ng_pkt.h" #ifdef __cplusplus @@ -294,8 +294,8 @@ static inline uint16_t ng_ipv6_hdr_inet_csum(uint16_t sum, ng_ipv6_hdr_t *hdr, sum++; } - return ng_inet_csum(sum + len + prot_num, hdr->src.u8, - (2 * sizeof(ng_ipv6_addr_t))); + return inet_csum(sum + len + prot_num, hdr->src.u8, + (2 * sizeof(ng_ipv6_addr_t))); } /** diff --git a/sys/net/crosslayer/ng_inet_csum/Makefile b/sys/net/crosslayer/inet_csum/Makefile similarity index 100% rename from sys/net/crosslayer/ng_inet_csum/Makefile rename to sys/net/crosslayer/inet_csum/Makefile diff --git a/sys/net/crosslayer/ng_inet_csum/ng_inet_csum.c b/sys/net/crosslayer/inet_csum/inet_csum.c similarity index 92% rename from sys/net/crosslayer/ng_inet_csum/ng_inet_csum.c rename to sys/net/crosslayer/inet_csum/inet_csum.c index f38935bbf6..c53c025d60 100644 --- a/sys/net/crosslayer/ng_inet_csum/ng_inet_csum.c +++ b/sys/net/crosslayer/inet_csum/inet_csum.c @@ -15,12 +15,12 @@ #include #include #include "od.h" -#include "net/ng_inet_csum.h" +#include "net/inet_csum.h" #define ENABLE_DEBUG (0) #include "debug.h" -uint16_t ng_inet_csum(uint16_t sum, const uint8_t *buf, uint16_t len) +uint16_t inet_csum(uint16_t sum, const uint8_t *buf, uint16_t len) { uint32_t csum = sum; diff --git a/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c b/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c index 3b1a97e01e..11913f598a 100644 --- a/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c +++ b/sys/net/network_layer/ng_icmpv6/ng_icmpv6.c @@ -42,12 +42,12 @@ static inline uint16_t _calc_csum(ng_pktsnip_t *hdr, uint16_t len = (uint16_t)hdr->size; while (payload && (payload != hdr)) { - csum = ng_inet_csum(csum, payload->data, payload->size); + csum = inet_csum(csum, payload->data, payload->size); len += (uint16_t)payload->size; payload = payload->next; } - csum = ng_inet_csum(csum, hdr->data, hdr->size); + csum = inet_csum(csum, hdr->data, hdr->size); csum = ng_ipv6_hdr_inet_csum(csum, pseudo_hdr->data, PROTNUM_ICMPV6, len); diff --git a/sys/net/transport_layer/ng_udp/ng_udp.c b/sys/net/transport_layer/ng_udp/ng_udp.c index 4e24076a3c..f43f68e29e 100644 --- a/sys/net/transport_layer/ng_udp/ng_udp.c +++ b/sys/net/transport_layer/ng_udp/ng_udp.c @@ -27,7 +27,7 @@ #include "utlist.h" #include "net/ng_udp.h" #include "net/ng_netbase.h" -#include "net/ng_inet_csum.h" +#include "net/inet_csum.h" #ifdef MODULE_NG_IPV6 #include "net/ng_ipv6/hdr.h" @@ -71,12 +71,12 @@ static uint16_t _calc_csum(ng_pktsnip_t *hdr, ng_pktsnip_t *pseudo_hdr, /* process the payload */ while (payload && payload != hdr) { - csum = ng_inet_csum(csum, (uint8_t *)(payload->data), payload->size); + csum = inet_csum(csum, (uint8_t *)(payload->data), payload->size); len += (uint16_t)payload->size; payload = payload->next; } /* process applicable UDP header bytes */ - csum = ng_inet_csum(csum, (uint8_t *)hdr->data, sizeof(ng_udp_hdr_t)); + csum = inet_csum(csum, (uint8_t *)hdr->data, sizeof(ng_udp_hdr_t)); switch (pseudo_hdr->type) { #ifdef MODULE_NG_IPV6 diff --git a/tests/unittests/tests-inet_csum/Makefile.include b/tests/unittests/tests-inet_csum/Makefile.include index a75cf2bcc2..5d3c05cf3a 100644 --- a/tests/unittests/tests-inet_csum/Makefile.include +++ b/tests/unittests/tests-inet_csum/Makefile.include @@ -1 +1 @@ -USEMODULE += ng_inet_csum +USEMODULE += inet_csum diff --git a/tests/unittests/tests-inet_csum/tests-inet_csum.c b/tests/unittests/tests-inet_csum/tests-inet_csum.c index 589d18f32e..1af7299ca0 100644 --- a/tests/unittests/tests-inet_csum/tests-inet_csum.c +++ b/tests/unittests/tests-inet_csum/tests-inet_csum.c @@ -16,7 +16,7 @@ #include "embUnit.h" -#include "net/ng_inet_csum.h" +#include "net/inet_csum.h" #include "unittests-constants.h" #include "tests-inet_csum.h" @@ -28,7 +28,7 @@ static void test_inet_csum__rfc_example(void) 0x00, 0x01, 0xf2, 0x03, 0xf4, 0xf5, 0xf6, 0xf7 }; - TEST_ASSERT_EQUAL_INT(0xddf2, ng_inet_csum(0, data, sizeof(data))); + TEST_ASSERT_EQUAL_INT(0xddf2, inet_csum(0, data, sizeof(data))); } static void test_inet_csum__ipv6_pseudo_hdr(void) @@ -50,7 +50,7 @@ static void test_inet_csum__ipv6_pseudo_hdr(void) }; /* result unnormalized: take 1's-complement of 0 */ - TEST_ASSERT_EQUAL_INT(0xffff, ng_inet_csum(0x0, data, sizeof(data))); + TEST_ASSERT_EQUAL_INT(0xffff, inet_csum(0x0, data, sizeof(data))); } static void test_inet_csum__set_initial_sum(void) @@ -72,7 +72,7 @@ static void test_inet_csum__set_initial_sum(void) /* result unnormalized: take 1's-complement of 0 * set next header and payload length as initial value */ - TEST_ASSERT_EQUAL_INT(0xffff, ng_inet_csum(0x38 + 0x3a, data, sizeof(data))); + TEST_ASSERT_EQUAL_INT(0xffff, inet_csum(0x38 + 0x3a, data, sizeof(data))); } static void test_inet_csum__wraps_more_than_once(void) @@ -87,7 +87,7 @@ static void test_inet_csum__wraps_more_than_once(void) }; /* values were taken from a case I encountered in the wild */ - TEST_ASSERT_EQUAL_INT(0x0002, ng_inet_csum(0x1785, data, sizeof(data))); + TEST_ASSERT_EQUAL_INT(0x0002, inet_csum(0x1785, data, sizeof(data))); } static void test_inet_csum__calculate_csum(void) @@ -101,7 +101,7 @@ static void test_inet_csum__calculate_csum(void) }; /* result unnormalized: take 1's-complement of 0xb861 */ - TEST_ASSERT_EQUAL_INT(0x479e, ng_inet_csum(0, data, sizeof(data))); + TEST_ASSERT_EQUAL_INT(0x479e, inet_csum(0, data, sizeof(data))); } static void test_inet_csum__odd_len(void) @@ -118,7 +118,7 @@ static void test_inet_csum__odd_len(void) /* result unnormalized: take 1's-complement of 0 * set next header and payload length as initial value */ - TEST_ASSERT_EQUAL_INT(0xffff, ng_inet_csum(17 + 39, data, sizeof(data))); + TEST_ASSERT_EQUAL_INT(0xffff, inet_csum(17 + 39, data, sizeof(data))); } Test *tests_inet_csum_tests(void) diff --git a/tests/unittests/tests-ipv6_hdr/tests-ipv6_hdr.c b/tests/unittests/tests-ipv6_hdr/tests-ipv6_hdr.c index 5e1f73e485..30f6607a2e 100644 --- a/tests/unittests/tests-ipv6_hdr/tests-ipv6_hdr.c +++ b/tests/unittests/tests-ipv6_hdr/tests-ipv6_hdr.c @@ -20,7 +20,7 @@ #include "net/ng_ipv6/hdr.h" #include "net/ng_pktbuf.h" #include "net/protnum.h" -#include "net/ng_inet_csum.h" +#include "net/inet_csum.h" #include "unittests-constants.h" #include "tests-ipv6_hdr.h" @@ -293,7 +293,7 @@ static void test_ipv6_hdr_inet_csum__initial_sum_0(void) res = ng_ipv6_hdr_inet_csum(0, (ng_ipv6_hdr_t *)&val, PROTNUM_ICMPV6, payload_len); /* calculate checksum of payload */ - res = ng_inet_csum(res, val + sizeof(ng_ipv6_hdr_t), payload_len); + res = inet_csum(res, val + sizeof(ng_ipv6_hdr_t), payload_len); res = ~res; /* take 1's-complement for correct checksum */ TEST_ASSERT_EQUAL_INT(0xab32, res);