1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-26 20:01:35 +01:00

Code cleanup and use same syntax on the entire project

Initial code cleanup

More code cleanup

Cleanup more code

Cleanup Dot11 code

Fix OSX build issue

Cleanup examples

Fix ref and pointer declaration syntax

Fix braces
This commit is contained in:
Matias Fontanini
2016-01-02 08:17:59 -08:00
parent f5a82b1a17
commit d84f10cf08
177 changed files with 13203 additions and 12272 deletions

View File

@@ -31,22 +31,27 @@
#include "ip_address.h"
#include "ipv6_address.h"
using std::logic_error;
namespace Tins {
IPv4Range operator/(const IPv4Address &addr, int mask) {
if(mask > 32)
throw std::logic_error("Prefix length cannot exceed 32");
IPv4Range operator/(const IPv4Address& addr, int mask) {
if (mask > 32) {
throw logic_error("Prefix length cannot exceed 32");
}
return IPv4Range::from_mask(
addr,
IPv4Address(Endian::host_to_be(0xffffffff << (32 - mask)))
);
}
IPv6Range operator/(const IPv6Address &addr, int mask) {
if(mask > 128)
IPv6Range operator/(const IPv6Address& addr, int mask) {
if (mask > 128) {
throw std::logic_error("Prefix length cannot exceed 128");
}
IPv6Address last_addr;
IPv6Address::iterator it = last_addr.begin();
while(mask > 8) {
while (mask > 8) {
*it = 0xff;
++it;
mask -= 8;
@@ -54,4 +59,5 @@ IPv6Range operator/(const IPv6Address &addr, int mask) {
*it = 0xff << (8 - mask);
return IPv6Range::from_mask(addr, last_addr);
}
}
} // Tins