* @returns The number of 1-bits in the prefix of the specified subnet mask. If * the specified subnet mask is not a valid one, -1. */
| 1074 | * the specified subnet mask is not a valid one, -1. |
| 1075 | */ |
| 1076 | static inline int NetmaskBits(uint8_t x) |
| 1077 | { |
| 1078 | switch(x) { |
| 1079 | case 0x00: return 0; |
| 1080 | case 0x80: return 1; |
| 1081 | case 0xc0: return 2; |
| 1082 | case 0xe0: return 3; |
| 1083 | case 0xf0: return 4; |
| 1084 | case 0xf8: return 5; |
| 1085 | case 0xfc: return 6; |
| 1086 | case 0xfe: return 7; |
| 1087 | case 0xff: return 8; |
| 1088 | default: return -1; |
| 1089 | } |
| 1090 | } |
| 1091 | |
| 1092 | CSubNet::CSubNet(const CNetAddr& addr, const CNetAddr& mask) : CSubNet() |
| 1093 | { |