Usermode/libnet - Fix bug with IPv6 parsing, constify
authorJohn Hodge (sonata) <[email protected]>
Mon, 10 Mar 2014 23:55:43 +0000 (07:55 +0800)
committerJohn Hodge (sonata) <[email protected]>
Mon, 10 Mar 2014 23:55:43 +0000 (07:55 +0800)
Usermode/Libraries/libnet.so_src/address.c
Usermode/Libraries/libnet.so_src/include_exp/net.h

index 0430c84..66a28b1 100644 (file)
@@ -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 )
        {
index 43445d1..5fe4ba1 100644 (file)
@@ -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

UCC git Repository :: git.ucc.asn.au