From e899eba76f7b8f91805176db4460f91e0a4dd487 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 9 Jan 2016 17:20:03 +0900 Subject: Define SockAddr and use it instead of raw std::pair --- src/SocketCore.h | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'src/SocketCore.h') 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> bindAddrs_; - static std::vector>> - bindAddrsList_; - static std::vector>>:: - iterator bindAddrsListIt_; + static std::vector bindAddrs_; + static std::vector> bindAddrsList_; + static std::vector>::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>& 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 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>& 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). -- cgit