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

[tor-commits] [tor/release-0.3.1] Function to add an ipv4 address to an address_set



commit 0640da42696a666382dd569839e98312d720a22a
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Feb 8 12:13:56 2018 -0500

    Function to add an ipv4 address to an address_set
    
    This is a convenience function, so callers don't need to wrap
    the IPv4 address.
---
 src/common/address_set.c | 9 +++++++++
 src/common/address_set.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/src/common/address_set.c b/src/common/address_set.c
index df7022174..6fa942b0d 100644
--- a/src/common/address_set.c
+++ b/src/common/address_set.c
@@ -97,6 +97,15 @@ address_set_add(address_set_t *set, const struct tor_addr_t *addr)
   }
 }
 
+/** As address_set_add(), but take an ipv4 address in host order. */
+void
+address_set_add_ipv4h(address_set_t *set, uint32_t addr)
+{
+  tor_addr_t a;
+  tor_addr_from_ipv4h(&a, addr);
+  address_set_add(set, &a);
+}
+
 /**
  * Return true if <b>addr</b> if a member of <b>set</b>.  (And probably,
  * return false if <b>addr</b> is not a member of set.)
diff --git a/src/common/address_set.h b/src/common/address_set.h
index 568528c89..aedf17fc6 100644
--- a/src/common/address_set.h
+++ b/src/common/address_set.h
@@ -14,6 +14,7 @@
 #define TOR_ADDRESS_SET_H
 
 #include "orconfig.h"
+#include "torint.h"
 
 /**
  * An address_set_t represents a set of tor_addr_t values. The implementation
@@ -26,6 +27,7 @@ struct tor_addr_t;
 address_set_t *address_set_new(int max_addresses_guess);
 void address_set_free(address_set_t *set);
 void address_set_add(address_set_t *set, const struct tor_addr_t *addr);
+void address_set_add_ipv4h(address_set_t *set, uint32_t addr);
 int address_set_probably_contains(address_set_t *set,
                                   const struct tor_addr_t *addr);
 



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