aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexis La Goutte <alexis.lagoutte@gmail.com>2015-05-07 14:04:05 +0200
committerAnders Broman <a.broman58@gmail.com>2015-05-08 04:28:39 +0000
commit3d7ff97e4fa9211a064acbac0ec0c025a164d69e (patch)
tree5b1f48e27b328c83addeb95c4640ec19a4563127
parent1439eb677820fff055df86e43341fde1d94a64d1 (diff)
downloadwireshark-3d7ff97e4fa9211a064acbac0ec0c025a164d69e.tar.gz
wireshark-3d7ff97e4fa9211a064acbac0ec0c025a164d69e.tar.bz2
wireshark-3d7ff97e4fa9211a064acbac0ec0c025a164d69e.zip
nghttp2: use g_ntoh[ls], g_hton[ls] from glib
Change-Id: I9e4278d469579022dd82bed4e40ff582fff266b6 Reviewed-on: https://code.wireshark.org/review/8328 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--epan/nghttp2/README.nghttp28
-rw-r--r--epan/nghttp2/nghttp2_helper.c10
-rw-r--r--epan/nghttp2/nghttp2_net.h91
3 files changed, 12 insertions, 97 deletions
diff --git a/epan/nghttp2/README.nghttp2 b/epan/nghttp2/README.nghttp2
index e24040babc..1b13871221 100644
--- a/epan/nghttp2/README.nghttp2
+++ b/epan/nghttp2/README.nghttp2
@@ -11,7 +11,6 @@ cp ../../../nghttp2/lib/nghttp2_hd*.[ch] .
cp ../../../nghttp2/lib/nghttp2_helper.[ch] .
cp ../../../nghttp2/lib/nghttp2_int.h .
cp ../../../nghttp2/lib/nghttp2_mem.[ch] .
-cp ../../../nghttp2/lib/nghttp2_net.h .
cp ../../../nghttp2/lib/includes/nghttp2/nghttp2.h .
cp ../../../nghttp2/lib/includes/nghttp2/nghttp2ver.h .
@@ -21,6 +20,13 @@ find . -name "nghttp2*" -type f -exec sed -i 's/<nghttp2\/nghttp2.h>/<nghttp2.h>
Change path to nghttp2ver.h
find . -name "nghttp2*" -type f -exec sed -i 's/<nghttp2\/nghttp2ver.h>/"nghttp2ver.h"/g' {} \;
+Change ntoh[ls], hton[ls] to use g_ntoh[ls], g_hton[ls] from glib
+find . -name "nghttp2*" -type f -exec sed -i 's/ntoh/g_ntoh/g' {} \;
+find . -name "nghttp2*" -type f -exec sed -i 's/hton/g_hton/g' {} \;
+
+Use glib.h and no nghttp2_net.h for ntoh/hton
+find . -name "nghttp2*" -type f -exec sed -i 's/"nghttp2_net.h"/"glib.h"/g' {} \;
+
Fix c++-compat error and documentation (struct => typedef) error
in nghttp2/nghttp2_helper.h remove check for CONFIG.H
diff --git a/epan/nghttp2/nghttp2_helper.c b/epan/nghttp2/nghttp2_helper.c
index 79f8e92b4d..7fa90a1e26 100644
--- a/epan/nghttp2/nghttp2_helper.c
+++ b/epan/nghttp2/nghttp2_helper.c
@@ -27,28 +27,28 @@
#include <assert.h>
#include <string.h>
-#include "nghttp2_net.h"
+#include "glib.h"
void nghttp2_put_uint16be(uint8_t *buf, uint16_t n) {
- uint16_t x = htons(n);
+ uint16_t x = g_htons(n);
memcpy(buf, &x, sizeof(uint16_t));
}
void nghttp2_put_uint32be(uint8_t *buf, uint32_t n) {
- uint32_t x = htonl(n);
+ uint32_t x = g_htonl(n);
memcpy(buf, &x, sizeof(uint32_t));
}
uint16_t nghttp2_get_uint16(const uint8_t *data) {
uint16_t n;
memcpy(&n, data, sizeof(uint16_t));
- return ntohs(n);
+ return g_ntohs(n);
}
uint32_t nghttp2_get_uint32(const uint8_t *data) {
uint32_t n;
memcpy(&n, data, sizeof(uint32_t));
- return ntohl(n);
+ return g_ntohl(n);
}
void *nghttp2_memdup(const void *src, size_t n, nghttp2_mem *mem) {
diff --git a/epan/nghttp2/nghttp2_net.h b/epan/nghttp2/nghttp2_net.h
deleted file mode 100644
index 16b52b3263..0000000000
--- a/epan/nghttp2/nghttp2_net.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * nghttp2 - HTTP/2 C Library
- *
- * Copyright (c) 2012 Tatsuhiro Tsujikawa
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-#ifndef NGHTTP2_NET_H
-#define NGHTTP2_NET_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif /* HAVE_CONFIG_H */
-
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif /* HAVE_ARPA_INET_H */
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif /* HAVE_NETINET_IN_H */
-
-#include <nghttp2.h>
-
-#if defined(WIN32)
-/* Windows requires ws2_32 library for ntonl family functions. We
- define inline functions for those function so that we don't have
- dependeny on that lib. */
-
-#ifdef _MSC_VER
-#define STIN static __inline
-#else
-#define STIN static inline
-#endif
-
-STIN uint32_t htonl(uint32_t hostlong) {
- uint32_t res;
- unsigned char *p = (unsigned char *)&res;
- *p++ = hostlong >> 24;
- *p++ = (hostlong >> 16) & 0xffu;
- *p++ = (hostlong >> 8) & 0xffu;
- *p = hostlong & 0xffu;
- return res;
-}
-
-STIN uint16_t htons(uint16_t hostshort) {
- uint16_t res;
- unsigned char *p = (unsigned char *)&res;
- *p++ = hostshort >> 8;
- *p = hostshort & 0xffu;
- return res;
-}
-
-STIN uint32_t ntohl(uint32_t netlong) {
- uint32_t res;
- unsigned char *p = (unsigned char *)&netlong;
- res = *p++ << 24;
- res += *p++ << 16;
- res += *p++ << 8;
- res += *p;
- return res;
-}
-
-STIN uint16_t ntohs(uint16_t netshort) {
- uint16_t res;
- unsigned char *p = (unsigned char *)&netshort;
- res = *p++ << 8;
- res += *p;
- return res;
-}
-
-#endif /* WIN32 */
-
-#endif /* NGHTTP2_NET_H */