~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to lib/ts/ink_inet.h

  • Committer: Package Import Robot
  • Author(s): Aron Xu
  • Date: 2013-05-09 01:00:04 UTC
  • mto: (1.1.11) (5.3.3 experimental)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20130509010004-9fqq9n0adseg3f8w
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1016
1016
  explicit IpAddr(IpEndpoint const* addr) { this->assign(&addr->sa); }
1017
1017
 
1018
1018
  /// Assign sockaddr storage.
1019
 
  self& assign(sockaddr const* addr) {
1020
 
    _family = addr->sa_family;
1021
 
    if (ats_is_ip4(addr)) {
1022
 
      _addr._ip4 = ats_ip4_addr_cast(addr);
1023
 
    } else if (ats_is_ip6(addr)) {
1024
 
      _addr._ip6 = ats_ip6_addr_cast(addr);
1025
 
    } else {
1026
 
      _family = AF_UNSPEC;
1027
 
    }
1028
 
    return *this;
1029
 
  }
 
1019
  self& assign(
 
1020
               sockaddr const* addr ///< May be @c NULL
 
1021
               );
 
1022
 
1030
1023
  /// Assign from end point.
1031
1024
  self& operator = (IpEndpoint const& ip) {
1032
1025
    return this->assign(&ip.sa);
1035
1028
  self& operator = (
1036
1029
    in_addr_t ip ///< Network order IPv4 address.
1037
1030
  );
 
1031
  /// Assign from IPv6 raw address.
 
1032
  self& operator = (
 
1033
    in6_addr const& ip
 
1034
  );
1038
1035
 
1039
1036
  /** Load from string.
1040
1037
      The address is copied to this object if the conversion is successful,
1107
1104
  return *this;
1108
1105
}
1109
1106
 
 
1107
inline IpAddr&
 
1108
IpAddr::operator = (in6_addr const& ip) {
 
1109
  _family = AF_INET6;
 
1110
  _addr._ip6 = ip;
 
1111
  return *this;
 
1112
}
 
1113
 
1110
1114
inline uint16_t IpAddr::family() const { return _family; }
1111
1115
 
1112
1116
inline bool
1116
1120
 
1117
1121
inline bool IpAddr::isIp4() const { return AF_INET == _family; }
1118
1122
inline bool IpAddr::isIp6() const { return AF_INET6 == _family; }
 
1123
  /// Assign sockaddr storage.
 
1124
inline IpAddr&
 
1125
IpAddr::assign(sockaddr const* addr) {
 
1126
  if (addr) {
 
1127
    _family = addr->sa_family;
 
1128
    if (ats_is_ip4(addr)) {
 
1129
      _addr._ip4 = ats_ip4_addr_cast(addr);
 
1130
    } else if (ats_is_ip6(addr)) {
 
1131
      _addr._ip6 = ats_ip6_addr_cast(addr);
 
1132
    } else {
 
1133
      _family = AF_UNSPEC;
 
1134
    }
 
1135
  } else {
 
1136
    _family = AF_UNSPEC;
 
1137
  }
 
1138
  return *this;
 
1139
}
1119
1140
 
1120
1141
// Associated operators.
1121
1142
bool operator == (IpAddr const& lhs, sockaddr const* rhs);