OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2007-2008 Louis Pasteur University | 3 * Copyright (c) 2007-2008 Louis Pasteur University |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 29 matching lines...) Expand all Loading... |
40 * \brief Get a hash key. | 40 * \brief Get a hash key. |
41 * \param k the key | 41 * \param k the key |
42 * \param length the length of the key | 42 * \param length the length of the key |
43 * \param level the previous hash, or an arbitrary value | 43 * \param level the previous hash, or an arbitrary value |
44 * \return hash | 44 * \return hash |
45 * \note Adapted from Jens Jakobsen implementation (chillispot). | 45 * \note Adapted from Jens Jakobsen implementation (chillispot). |
46 */ | 46 */ |
47 static uint32_t lookuphash (unsigned char* k, uint32_t length, uint32_t level) | 47 static uint32_t lookuphash (unsigned char* k, uint32_t length, uint32_t level) |
48 { | 48 { |
49 NS_LOG_FUNCTION (k << length << level); | 49 NS_LOG_FUNCTION (k << length << level); |
| 50 #ifndef WIN32 |
50 #define mix(a, b, c) \ | 51 #define mix(a, b, c) \ |
51 ({ \ | 52 ({ \ |
52 (a) -= (b); (a) -= (c); (a) ^= ((c) >> 13); \ | 53 (a) -= (b); (a) -= (c); (a) ^= ((c) >> 13); \ |
53 (b) -= (c); (b) -= (a); (b) ^= ((a) << 8); \ | 54 (b) -= (c); (b) -= (a); (b) ^= ((a) << 8); \ |
54 (c) -= (a); (c) -= (b); (c) ^= ((b) >> 13); \ | 55 (c) -= (a); (c) -= (b); (c) ^= ((b) >> 13); \ |
55 (a) -= (b); (a) -= (c); (a) ^= ((c) >> 12); \ | 56 (a) -= (b); (a) -= (c); (a) ^= ((c) >> 12); \ |
56 (b) -= (c); (b) -= (a); (b) ^= ((a) << 16); \ | 57 (b) -= (c); (b) -= (a); (b) ^= ((a) << 16); \ |
57 (c) -= (a); (c) -= (b); (c) ^= ((b) >> 5); \ | 58 (c) -= (a); (c) -= (b); (c) ^= ((b) >> 5); \ |
58 (a) -= (b); (a) -= (c); (a) ^= ((c) >> 3); \ | 59 (a) -= (b); (a) -= (c); (a) ^= ((c) >> 3); \ |
59 (b) -= (c); (b) -= (a); (b) ^= ((a) << 10); \ | 60 (b) -= (c); (b) -= (a); (b) ^= ((a) << 10); \ |
60 (c) -= (a); (c) -= (b); (c) ^= ((b) >> 15); \ | 61 (c) -= (a); (c) -= (b); (c) ^= ((b) >> 15); \ |
61 }) | 62 }) |
| 63 #else |
| 64 #define mix(a, b, c) \ |
| 65 { \ |
| 66 (a) -= (b); (a) -= (c); (a) ^= ((c) >> 13); \ |
| 67 (b) -= (c); (b) -= (a); (b) ^= ((a) << 8); \ |
| 68 (c) -= (a); (c) -= (b); (c) ^= ((b) >> 13); \ |
| 69 (a) -= (b); (a) -= (c); (a) ^= ((c) >> 12); \ |
| 70 (b) -= (c); (b) -= (a); (b) ^= ((a) << 16); \ |
| 71 (c) -= (a); (c) -= (b); (c) ^= ((b) >> 5); \ |
| 72 (a) -= (b); (a) -= (c); (a) ^= ((c) >> 3); \ |
| 73 (b) -= (c); (b) -= (a); (b) ^= ((a) << 10); \ |
| 74 (c) -= (a); (c) -= (b); (c) ^= ((b) >> 15); \ |
| 75 } |
| 76 |
| 77 #endif |
62 | 78 |
63 typedef uint32_t ub4; /* unsigned 4-byte quantities */ | 79 typedef uint32_t ub4; /* unsigned 4-byte quantities */ |
64 typedef unsigned char ub1; /* unsigned 1-byte quantities */ | 80 typedef unsigned char ub1; /* unsigned 1-byte quantities */ |
65 uint32_t a = 0; | 81 uint32_t a = 0; |
66 uint32_t b = 0; | 82 uint32_t b = 0; |
67 uint32_t c = 0; | 83 uint32_t c = 0; |
68 uint32_t len = 0; | 84 uint32_t len = 0; |
69 | 85 |
70 /* Set up the internal state */ | 86 /* Set up the internal state */ |
71 len = length; | 87 len = length; |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 x.GetBytes (buf); | 862 x.GetBytes (buf); |
847 | 863 |
848 return lookuphash (buf, sizeof (buf), 0); | 864 return lookuphash (buf, sizeof (buf), 0); |
849 } | 865 } |
850 | 866 |
851 ATTRIBUTE_HELPER_CPP (Ipv6Address); | 867 ATTRIBUTE_HELPER_CPP (Ipv6Address); |
852 ATTRIBUTE_HELPER_CPP (Ipv6Prefix); | 868 ATTRIBUTE_HELPER_CPP (Ipv6Prefix); |
853 | 869 |
854 } /* namespace ns3 */ | 870 } /* namespace ns3 */ |
855 | 871 |
OLD | NEW |