summaryrefslogtreecommitdiff
path: root/ACE/ace/INET_Addr.h
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/ace/INET_Addr.h')
-rw-r--r--ACE/ace/INET_Addr.h40
1 files changed, 35 insertions, 5 deletions
diff --git a/ACE/ace/INET_Addr.h b/ACE/ace/INET_Addr.h
index 0c21df7b75b..c1a40553754 100644
--- a/ACE/ace/INET_Addr.h
+++ b/ACE/ace/INET_Addr.h
@@ -19,6 +19,7 @@
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ace/Addr.h"
+#include <vector>
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
@@ -27,6 +28,10 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL
*
* @brief Defines a C++ wrapper facade for the Internet domain address
* family format.
+ *
+ * ACE_INET_Addr can hold all of the IP addresses assigned to a single name.
+ * By default it refers only to the first, if there is more than one. The
+ * next() method can make the others available in turn.
*/
class ACE_Export ACE_INET_Addr : public ACE_Addr
{
@@ -108,6 +113,20 @@ public:
// These methods are useful after the object has been constructed.
+ /// Assignment. In a more well-ordered world, member-wise assignment would
+ /// work fine. However, because of the class design feature that all of the
+ /// acceptor/connector-type classes that can be used in the
+ /// Acceptor-Connector framework take ACE_Addr objects instead of the
+ /// addressing class matching the family in use. The mechanism used to
+ /// enable this substitution to the more-appropriate class is
+ /// ACE_sap_any_cast, which casts the ACE_Addr to the more-specific class.
+ /// In this case, casting an ACE_Addr to ACE_INET_Addr then copying it.
+ /// Since adding multiple address support to ACE_INET_Addr, that cast-copy
+ /// operation ends up, in the member-wise case, copying a bogus vector
+ /// and doing lots of random damage. Thus, this operator is used to make
+ /// life ordered in this common scenario.
+ ACE_INET_Addr & operator= (const ACE_INET_Addr &rhs);
+
/// Initializes from another ACE_INET_Addr.
int set (const ACE_INET_Addr &);
@@ -189,14 +208,14 @@ public:
int get_addr_size(void) const;
/// Set a pointer to the address.
- virtual void set_addr (void *, int len);
+ virtual void set_addr (const void *, int len);
/// Set a pointer to the address.
- virtual void set_addr (void *, int len, int map);
+ virtual void set_addr (const void *, int len, int map);
/**
* Transform the current ACE_INET_Addr address into string format.
- * If @a ipaddr_format is ttrue this produces "ip-number:port-number"
+ * If @a ipaddr_format is true this produces "ip-number:port-number"
* (e.g., "128.252.166.57:1234"), whereas if @a ipaddr_format is false
* this produces "ip-name:port-number" (e.g.,
* "tango.cs.wustl.edu:1234"). Returns -1 if the @a size of the
@@ -347,6 +366,13 @@ public:
/// Computes and returns hash value.
virtual u_long hash (void) const;
+ /// If there is another address to examine, move to it and return true;
+ /// else return false.
+ bool next (void);
+
+ /// Reset the set of address so they can be scanned again using next().
+ void reset (void);
+
/// Dump the state of an object.
void dump (void) const;
@@ -364,18 +390,22 @@ private:
int determine_type (void) const;
/// Initialize underlying inet_addr_ to default values
- void reset (void);
+ void reset_i (void);
/// Underlying representation.
/// This union uses the knowledge that the two structures share the
/// first member, sa_family (as all sockaddr structures do).
- union
+ union ip46
{
sockaddr_in in4_;
#if defined (ACE_HAS_IPV6)
sockaddr_in6 in6_;
#endif /* ACE_HAS_IPV6 */
} inet_addr_;
+ // If there is more than one address assigned to a given name, this
+ // holds all of them; one is always copied to inet_addr_.
+ std::vector<union ip46> inet_addrs_;
+ std::vector<union ip46>::iterator inet_addrs_iter_;
};
ACE_END_VERSIONED_NAMESPACE_DECL