Changeset e2839d7 in mainline


Ignore:
Timestamp:
2013-09-30T20:13:39Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
26de91a
Parents:
159ad6d
Message:

Address compare functions should return non-zero on match - logic is inverted. addr128_t is big endian in host memory, so it should never be byte-swapped.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/inet/addr.c

    r159ad6d re2839d7  
    7979}
    8080
     81/** Compare addr48.
     82  *
     83  * @return Non-zero if equal, zero if not equal.
     84  */
    8185int addr48_compare(const addr48_t a, const addr48_t b)
    8286{
    83         return memcmp(a, b, 6);
    84 }
    85 
     87        return memcmp(a, b, 6) == 0;
     88}
     89
     90/** Compare addr128.
     91  *
     92  * @return Non-zero if equal, zero if not equal.
     93  */
    8694int addr128_compare(const addr128_t a, const addr128_t b)
    8795{
    88         return memcmp(a, b, 16);
     96        return memcmp(a, b, 16) == 0;
    8997}
    9098
     
    103111void host2addr128_t_be(const addr128_t host, addr128_t be)
    104112{
    105 #ifdef __BE__
    106113        memcpy(be, host, 16);
    107 #else
    108         be[0] = host[15];
    109         be[1] = host[14];
    110         be[2] = host[13];
    111         be[3] = host[12];
    112         be[4] = host[11];
    113         be[5] = host[10];
    114         be[6] = host[9];
    115         be[7] = host[8];
    116         be[8] = host[7];
    117         be[9] = host[6];
    118         be[10] = host[5];
    119         be[11] = host[4];
    120         be[12] = host[3];
    121         be[13] = host[2];
    122         be[14] = host[1];
    123         be[15] = host[0];
    124 #endif
    125114}
    126115
    127116void addr128_t_be2host(const addr128_t be, addr128_t host)
    128117{
    129 #ifdef __BE__
    130118        memcpy(host, be, 16);
    131 #else
    132         host[0] = be[15];
    133         host[1] = be[14];
    134         host[2] = be[13];
    135         host[3] = be[12];
    136         host[4] = be[11];
    137         host[5] = be[10];
    138         host[6] = be[9];
    139         host[7] = be[8];
    140         host[8] = be[7];
    141         host[9] = be[6];
    142         host[10] = be[5];
    143         host[11] = be[4];
    144         host[12] = be[3];
    145         host[13] = be[2];
    146         host[14] = be[1];
    147         host[15] = be[0];
    148 #endif
    149119}
    150120
Note: See TracChangeset for help on using the changeset viewer.