diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-01-09 17:20:03 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-01-09 17:20:03 +0900 |
| commit | e899eba76f7b8f91805176db4460f91e0a4dd487 (patch) | |
| tree | 0c4a6a00bae4ce02f83819786be91aeb6351fab8 /src/SocketCore.h | |
| parent | d2d06395d985c08aacf497a6ecc37d757ef990e0 (diff) | |
Define SockAddr and use it instead of raw std::pair
Diffstat (limited to 'src/SocketCore.h')
| -rw-r--r-- | src/SocketCore.h | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/SocketCore.h b/src/SocketCore.h index a4aeaa2c..2f57da14 100644 --- a/src/SocketCore.h +++ b/src/SocketCore.h @@ -73,11 +73,9 @@ private: static int protocolFamily_; static int ipDscp_; - static std::vector<std::pair<sockaddr_union, socklen_t>> bindAddrs_; - static std::vector<std::vector<std::pair<sockaddr_union, socklen_t>>> - bindAddrsList_; - static std::vector<std::vector<std::pair<sockaddr_union, socklen_t>>>:: - iterator bindAddrsListIt_; + static std::vector<SockAddr> bindAddrs_; + static std::vector<std::vector<SockAddr>> bindAddrsList_; + static std::vector<std::vector<SockAddr>>::iterator bindAddrsListIt_; static int socketRecvBufferSize_; @@ -372,9 +370,14 @@ public: static void bindAddress(const std::string& iface); static void bindAllAddress(const std::string& ifaces); - friend void getInterfaceAddress( - std::vector<std::pair<sockaddr_union, socklen_t>>& ifAddrs, - const std::string& iface, int family, int aiFlags); + // Collects IP addresses of given interface iface and stores in + // ifAddres. iface may be specified as a hostname, IP address or + // interface name like eth0. You can limit the family of IP + // addresses to collect using family argument. aiFlags is passed to + // getaddrinfo() as hints.ai_flags. No throw. + static std::vector<SockAddr> getInterfaceAddress(const std::string& iface, + int family = AF_UNSPEC, + int aiFlags = 0); }; // Set default ai_flags. hints.ai_flags is initialized with this @@ -389,15 +392,6 @@ int callGetaddrinfo(struct addrinfo** resPtr, const char* host, const char* service, int family, int sockType, int flags, int protocol); -// Collects IP addresses of given interface iface and stores in -// ifAddres. iface may be specified as a hostname, IP address or -// interface name like eth0. You can limit the family of IP addresses -// to collect using family argument. aiFlags is passed to -// getaddrinfo() as hints.ai_flags. No throw. -void getInterfaceAddress( - std::vector<std::pair<sockaddr_union, socklen_t>>& ifAddrs, - const std::string& iface, int family = AF_UNSPEC, int aiFlags = 0); - // Provides functionality of inet_ntop using getnameinfo. The return // value is the exact value of getnameinfo returns. You can get error // message using gai_strerror(3). |
