MCPcopy Create free account
hub / github.com/Icinga/icinga2 / IpMaskCheck

Function IpMaskCheck

lib/base/utility.cpp:220–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220static bool IpMaskCheck(char addr[16], char mask[16], int bits)
221{
222 for (int i = 0; i < 16; i++) {
223 if (bits < 8)
224 return !((addr[i] ^ mask[i]) >> (8 - bits));
225
226 if (mask[i] != addr[i])
227 return false;
228
229 bits -= 8;
230
231 if (bits == 0)
232 return true;
233 }
234
235 return true;
236}
237
238bool Utility::CidrMatch(const String& pattern, const String& ip)
239{

Callers 1

CidrMatchMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected