[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Remove the unused parse_addr_and_port_range



commit 24fb9267268cda0edd9f07ddb298dfe24af760d9
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Mar 1 14:35:17 2013 -0500

    Remove the unused parse_addr_and_port_range
---
 src/common/address.c |   87 --------------------------------------------------
 src/common/address.h |    3 --
 2 files changed, 0 insertions(+), 90 deletions(-)

diff --git a/src/common/address.c b/src/common/address.c
index 6fc9fb3..67a11d7 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1643,93 +1643,6 @@ parse_port_range(const char *port, uint16_t *port_min_out,
   return 0;
 }
 
-/** Parse a string <b>s</b> in the format of
- * (IP(/mask|/mask-bits)?|*)(:(*|port(-maxport))?)?, setting the various
- * *out pointers as appropriate.  Return 0 on success, -1 on failure.
- */
-int
-parse_addr_and_port_range(const char *s, uint32_t *addr_out,
-                          maskbits_t *maskbits_out, uint16_t *port_min_out,
-                          uint16_t *port_max_out)
-{
-  char *address;
-  char *mask, *port, *endptr;
-  struct in_addr in;
-  int bits;
-
-  tor_assert(s);
-  tor_assert(addr_out);
-  tor_assert(maskbits_out);
-  tor_assert(port_min_out);
-  tor_assert(port_max_out);
-
-  address = tor_strdup(s);
-  /* Break 'address' into separate strings.
-   */
-  mask = strchr(address,'/');
-  port = strchr(mask?mask:address,':');
-  if (mask)
-    *mask++ = '\0';
-  if (port)
-    *port++ = '\0';
-  /* Now "address" is the IP|'*' part...
-   *     "mask" is the Mask|Maskbits part...
-   * and "port" is the *|port|min-max part.
-   */
-
-  if (strcmp(address,"*")==0) {
-    *addr_out = 0;
-  } else if (tor_inet_aton(address, &in) != 0) {
-    *addr_out = ntohl(in.s_addr);
-  } else {
-    log_warn(LD_GENERAL, "Malformed IP %s in address pattern; rejecting.",
-             escaped(address));
-    goto err;
-  }
-
-  if (!mask) {
-    if (strcmp(address,"*")==0)
-      *maskbits_out = 0;
-    else
-      *maskbits_out = 32;
-  } else {
-    endptr = NULL;
-    bits = (int) strtol(mask, &endptr, 10);
-    if (!*endptr) {
-      /* strtol handled the whole mask. */
-      if (bits < 0 || bits > 32) {
-        log_warn(LD_GENERAL,
-                 "Bad number of mask bits on address range; rejecting.");
-        goto err;
-      }
-      *maskbits_out = bits;
-    } else if (tor_inet_aton(mask, &in) != 0) {
-      bits = addr_mask_get_bits(ntohl(in.s_addr));
-      if (bits < 0) {
-        log_warn(LD_GENERAL,
-                 "Mask %s on address range isn't a prefix; dropping",
-                 escaped(mask));
-        goto err;
-      }
-      *maskbits_out = bits;
-    } else {
-      log_warn(LD_GENERAL,
-               "Malformed mask %s on address range; rejecting.",
-               escaped(mask));
-      goto err;
-    }
-  }
-
-  if (parse_port_range(port, port_min_out, port_max_out)<0)
-    goto err;
-
-  tor_free(address);
-  return 0;
- err:
-  tor_free(address);
-  return -1;
-}
-
 /** Given an IPv4 in_addr struct *<b>in</b> (in network order, as usual),
  *  write it as a string into the <b>buf_len</b>-byte buffer in
  *  <b>buf</b>.
diff --git a/src/common/address.h b/src/common/address.h
index 9cbc32c..ec63257 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -219,9 +219,6 @@ int addr_port_lookup(int severity, const char *addrport, char **address,
                     uint32_t *addr, uint16_t *port_out);
 int parse_port_range(const char *port, uint16_t *port_min_out,
                      uint16_t *port_max_out);
-int parse_addr_and_port_range(const char *s, uint32_t *addr_out,
-                              maskbits_t *maskbits_out, uint16_t *port_min_out,
-                              uint16_t *port_max_out);
 int addr_mask_get_bits(uint32_t mask);
 int addr_mask_cmp_bits(uint32_t a1, uint32_t a2, maskbits_t bits);
 /** Length of a buffer to allocate to hold the results of tor_inet_ntoa.*/



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits