00001 /****************** <VPR heading BEGIN do not edit this line> ***************** 00002 * 00003 * VR Juggler Portable Runtime 00004 * 00005 * Original Authors: 00006 * Allen Bierbaum, Patrick Hartling, Kevin Meinert, Carolina Cruz-Neira 00007 * 00008 * ----------------------------------------------------------------- 00009 * File: $RCSfile$ 00010 * Date modified: $Date: 2005-12-16 08:07:50 -0600 (Fri, 16 Dec 2005) $ 00011 * Version: $Revision: 18288 $ 00012 * ----------------------------------------------------------------- 00013 * 00014 ****************** <VPR heading END do not edit this line> ******************/ 00015 00016 /*************** <auto-copyright.pl BEGIN do not edit this line> ************** 00017 * 00018 * VR Juggler is (C) Copyright 1998-2005 by Iowa State University 00019 * 00020 * Original Authors: 00021 * Allen Bierbaum, Christopher Just, 00022 * Patrick Hartling, Kevin Meinert, 00023 * Carolina Cruz-Neira, Albert Baker 00024 * 00025 * This library is free software; you can redistribute it and/or 00026 * modify it under the terms of the GNU Library General Public 00027 * License as published by the Free Software Foundation; either 00028 * version 2 of the License, or (at your option) any later version. 00029 * 00030 * This library is distributed in the hope that it will be useful, 00031 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00032 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00033 * Library General Public License for more details. 00034 * 00035 * You should have received a copy of the GNU Library General Public 00036 * License along with this library; if not, write to the 00037 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00038 * Boston, MA 02111-1307, USA. 00039 * 00040 *************** <auto-copyright.pl END do not edit this line> ***************/ 00041 00042 #ifndef _VPR_INET_ADDR_BSD_H_ 00043 #define _VPR_INET_ADDR_BSD_H_ 00044 00045 #include <vpr/vprConfig.h> 00046 00047 #include <sys/types.h> 00048 #include <netinet/in.h> 00049 #include <string> 00050 #include <vector> 00051 00052 #include <vpr/IO/Socket/InetAddrBase.h> 00053 #include <vpr/IO/Socket/SocketTypes.h> 00054 00055 00056 // XXX: Extend to work with IPv6. 00057 00058 namespace vpr 00059 { 00060 00061 // Forward declare this. It is defined in vpr/IO/Socket/InetAddr.h which may 00062 // not be included by this file. 00063 struct InetAddrHash; 00064 00070 class InetAddrBSD : public InetAddrBase 00071 { 00072 public: 00073 static const InetAddrBSD AnyAddr; 00074 00075 typedef vpr::InetAddrHash hash; 00076 00084 InetAddrBSD(); 00085 00094 InetAddrBSD(const InetAddrBSD& addr) 00095 { 00096 copy(addr); 00097 } 00098 00107 static vpr::ReturnStatus getLocalHost(vpr::InetAddrBSD& hostAddr); 00108 00132 static vpr::ReturnStatus 00133 getAllLocalAddrs(std::vector<vpr::InetAddrBSD>& hostAddrs, 00134 const bool withLoopback = false); 00135 00145 vpr::ReturnStatus setAddress(const std::string& address); 00146 00156 vpr::ReturnStatus setAddress(const std::string& address, const Uint16 port); 00157 00165 vpr::ReturnStatus setAddress(const vpr::Uint32 address, 00166 const vpr::Uint16 port); 00167 00179 unsigned char getLength() const; 00180 00191 void setLength(const unsigned char length); 00192 00203 vpr::SocketTypes::Domain getFamily() const; 00204 00215 void setFamily(const vpr::SocketTypes::Domain family); 00216 00227 vpr::Uint16 getPort() const; 00228 00238 void setPort(const vpr::Uint16 port); 00239 00251 vpr::Uint32 getAddressValue() const; 00252 00264 std::string getAddressString() const; 00265 00269 vpr::ReturnStatus getHostname(std::string& hostname) const; 00270 00275 std::vector<std::string> getHostnames() const; 00276 00289 InetAddrBSD& operator= (const InetAddrBSD& addr) 00290 { 00291 copy(addr); 00292 return *this; 00293 } 00294 00298 bool operator== (const InetAddrBSD& addr) const; 00299 00303 bool operator!= (const InetAddrBSD& addr) const 00304 { 00305 return ! (*this == addr); 00306 } 00307 00308 protected: 00309 friend class vpr::SocketImplBSD; 00310 friend class vpr::SocketDatagramImplBSD; 00311 friend class vpr::SocketStreamImplBSD; 00312 00323 InetAddrBSD(const struct sockaddr* addr) 00324 { 00325 setSockaddr(addr); 00326 } 00327 00340 void copyAddressValue(const char* addrValue); 00341 00352 void setAddressValue(const vpr::Uint32 addrValue); 00353 00363 size_t size() const; 00364 00374 size_t addressSize() const; 00375 00386 void setSockaddr(const struct sockaddr* addr); 00387 00395 struct sockaddr_in toSockaddrInet(); 00396 00406 void copy(const InetAddrBSD& addr); 00407 00418 vpr::ReturnStatus lookupAddress(const std::string& addr); 00419 00420 struct sockaddr_in mAddr; 00421 }; 00422 00423 } // End of vpr namespace 00424 00425 00426 #endif /* _VPR_INET_ADDR_H_ */
1.5.1