From d054bf40d18fadaf90c28c8703d332efd3a55dad Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Tue, 11 Mar 2014 07:55:43 +0800 Subject: [PATCH] Usermode/libnet - Fix bug with IPv6 parsing, constify --- Usermode/Libraries/libnet.so_src/address.c | 10 +++++----- Usermode/Libraries/libnet.so_src/include_exp/net.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Usermode/Libraries/libnet.so_src/address.c b/Usermode/Libraries/libnet.so_src/address.c index 0430c84d..66a28b1b 100644 --- a/Usermode/Libraries/libnet.so_src/address.c +++ b/Usermode/Libraries/libnet.so_src/address.c @@ -160,8 +160,8 @@ static int Net_ParseIPv6Addr(const char *String, uint8_t *Addr) k = 0; for( ; j < 8; j ++, k++) { - Addr[j*2] = hi[k]>>8; - Addr[j*2+1] = hi[k]&0xFF; + Addr[j*2] = low[k]>>8; + Addr[j*2+1] = low[k]&0xFF; } return 1; @@ -187,7 +187,7 @@ int Net_ParseAddress(const char *String, void *Addr) return 0; } -static const char *Net_PrintIPv4Address(uint8_t *Address) +static const char *Net_PrintIPv4Address(const uint8_t *Address) { static __thread char ret[4*3+3+1]; // '255.255.255.255\0' @@ -196,7 +196,7 @@ static const char *Net_PrintIPv4Address(uint8_t *Address) return ret; } -static const char *Net_PrintIPv6Address(uint16_t *Address) +static const char *Net_PrintIPv6Address(const uint16_t *Address) { static __thread char ret[8*4+7+1]; // 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF\0' #if 0 @@ -215,7 +215,7 @@ static const char *Net_PrintIPv6Address(uint16_t *Address) return ret; } -const char *Net_PrintAddress(int AddressType, void *Address) +const char *Net_PrintAddress(int AddressType, const void *Address) { switch( AddressType ) { diff --git a/Usermode/Libraries/libnet.so_src/include_exp/net.h b/Usermode/Libraries/libnet.so_src/include_exp/net.h index 43445d19..5fe4ba10 100644 --- a/Usermode/Libraries/libnet.so_src/include_exp/net.h +++ b/Usermode/Libraries/libnet.so_src/include_exp/net.h @@ -25,7 +25,7 @@ extern int Net_ParseAddress(const char *String, void *Addr); * \param AddressType Address family as returned by Net_ParseAddress * \param Address Address data */ -extern const char *Net_PrintAddress(int AddressType, void *Address); +extern const char *Net_PrintAddress(int AddressType, const void *Address); /** * \brief Get the size in bytes of an address type -- 2.20.1