summaryrefslogtreecommitdiff
path: root/common/inet.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/inet.c')
-rw-r--r--common/inet.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/common/inet.c b/common/inet.c
index 4388d92b..dcb628ce 100644
--- a/common/inet.c
+++ b/common/inet.c
@@ -101,7 +101,7 @@ struct iaddr ip_addr (subnet, mask, host_address)
} else
rv.iabuf [i + j] = habuf [i];
}
-
+
return rv;
}
@@ -174,7 +174,7 @@ int addr_eq (addr1, addr2)
return memcmp (addr1.iabuf, addr2.iabuf, addr1.len) == 0;
}
-/* addr_match
+/* addr_match
*
* compares an IP address against a network/mask combination
* by ANDing the IP with the mask and seeing whether the result
@@ -189,7 +189,7 @@ addr_match(addr, match)
if (addr->len != match->addr.len)
return 0;
-
+
for (i = 0 ; i < addr->len ; i++) {
if ((addr->iabuf[i] & match->mask.iabuf[i]) !=
match->addr.iabuf[i])
@@ -198,7 +198,7 @@ addr_match(addr, match)
return 1;
}
-/*
+/*
* Compares the addresses a1 and a2.
*
* If a1 < a2, returns -1.
@@ -234,7 +234,7 @@ addr_cmp(const struct iaddr *a1, const struct iaddr *a2) {
*
* WARNING: if a1 and a2 differ in length, returns 0.
*/
-int
+int
addr_or(struct iaddr *result, const struct iaddr *a1, const struct iaddr *a2) {
int i;
int all_zero;
@@ -263,7 +263,7 @@ addr_or(struct iaddr *result, const struct iaddr *a1, const struct iaddr *a2) {
*
* WARNING: if a1 and a2 differ in length, returns 0.
*/
-int
+int
addr_and(struct iaddr *result, const struct iaddr *a1, const struct iaddr *a2) {
int i;
int all_zero;
@@ -323,7 +323,7 @@ is_cidr_mask_valid(const struct iaddr *addr, int bits) {
zero_bits = (addr->len * 8) - bits;
zero_bytes = zero_bits / 8;
- /*
+ /*
* Check to make sure the low-order bytes are zero.
*/
for (i=1; i<=zero_bytes; i++) {
@@ -332,11 +332,11 @@ is_cidr_mask_valid(const struct iaddr *addr, int bits) {
}
}
- /*
- * Look to see if any bits not in right-hand bytes are
- * non-zero, by making a byte that has these bits set to zero
- * comparing to the original byte. If these two values are
- * equal, then the right-hand bits are zero, and we are
+ /*
+ * Look to see if any bits not in right-hand bytes are
+ * non-zero, by making a byte that has these bits set to zero
+ * comparing to the original byte. If these two values are
+ * equal, then the right-hand bits are zero, and we are
* happy.
*/
shift_bits = zero_bits % 8;
@@ -350,14 +350,14 @@ is_cidr_mask_valid(const struct iaddr *addr, int bits) {
*
* Converts a range of IP addresses to a set of CIDR networks.
*
- * Examples:
+ * Examples:
* 192.168.0.0 - 192.168.0.255 = 192.168.0.0/24
* 10.0.0.0 - 10.0.1.127 = 10.0.0.0/24, 10.0.1.0/25
* 255.255.255.32 - 255.255.255.255 = 255.255.255.32/27, 255.255.255.64/26,
* 255.255.255.128/25
*/
-isc_result_t
-range2cidr(struct iaddrcidrnetlist **result,
+isc_result_t
+range2cidr(struct iaddrcidrnetlist **result,
const struct iaddr *lo, const struct iaddr *hi) {
struct iaddr addr;
struct iaddr mask;
@@ -395,30 +395,30 @@ range2cidr(struct iaddrcidrnetlist **result,
* Start at the low end, and keep trying larger networks
* until we get one that is too big (explained below).
*
- * We keep a "mask", which is the ones-complement of a
+ * We keep a "mask", which is the ones-complement of a
* normal netmask. So, a /23 has a netmask of 255.255.254.0,
* and a mask of 0.0.1.255.
*
- * We know when a network is too big when we bitwise-AND the
- * mask with the starting address and we get a non-zero
+ * We know when a network is too big when we bitwise-AND the
+ * mask with the starting address and we get a non-zero
* result, like this:
*
* addr: 192.168.1.0, mask: 0.0.1.255
* bitwise-AND: 0.0.1.0
- *
+ *
* A network is also too big if the bitwise-OR of the mask
* with the starting address is larger than the end address,
* like this:
*
* start: 192.168.1.0, mask: 0.0.1.255, end: 192.168.0.255
- * bitwise-OR: 192.168.1.255
+ * bitwise-OR: 192.168.1.255
*
* -------------------
- * Once we have found a network that is too big, we add the
+ * Once we have found a network that is too big, we add the
* appropriate CIDR network to our list of found networks.
*
* We then use the next IP address as our low address, and
- * begin the process of searching for a network that is
+ * begin the process of searching for a network that is
* too big again, starting with an empty mask.
*/
addr = *lo;
@@ -435,12 +435,12 @@ range2cidr(struct iaddrcidrnetlist **result,
mask.iabuf[ofs] |= val;
}
- /*
+ /*
* See if we're too big, and save this network if so.
*/
addr_or(&end_addr, &addr, &mask);
if ((ofs < 0) ||
- (addr_cmp(&end_addr, hi) > 0) ||
+ (addr_cmp(&end_addr, hi) > 0) ||
addr_and(&dummy, &addr, &mask)) {
/*
* Add a new prefix to our list.
@@ -459,8 +459,8 @@ range2cidr(struct iaddrcidrnetlist **result,
net->next = *result;
*result = net;
- /*
- * Figure out our new starting address,
+ /*
+ * Figure out our new starting address,
* by adding (1 << bit) to our previous
* starting address.
*/
@@ -534,7 +534,7 @@ piaddr(const struct iaddr addr) {
}
if (addr.len == 4) {
return inet_ntop(AF_INET, addr.iabuf, pbuf, sizeof(pbuf));
- }
+ }
if (addr.len == 16) {
return inet_ntop(AF_INET6, addr.iabuf, pbuf, sizeof(pbuf));
}
@@ -610,7 +610,7 @@ validate_port(char *port) {
errno = 0;
local_port = strtol(port, &endptr, 10);
-
+
if ((*endptr != '\0') || (errno == ERANGE) || (errno == EINVAL))
log_fatal ("Invalid port number specification: %s", port);
@@ -636,7 +636,7 @@ validate_port_pair(char *port) {
errno = 0;
local_port = strtol(port, &endptr, 10);
-
+
if ((*endptr != '\0') || (errno == ERANGE) || (errno == EINVAL))
log_fatal ("Invalid port pair specification: %s", port);