MCPcopy Create free account
hub / github.com/ElementsProject/elements / NetmaskBits

Function NetmaskBits

src/netaddress.cpp:1076–1090  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

1074 * the specified subnet mask is not a valid one, -1.
1075 */
1076static 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
1092CSubNet::CSubNet(const CNetAddr& addr, const CNetAddr& mask) : CSubNet()
1093{

Callers 2

CSubNetMethod · 0.85
ToStringMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected