// -*- mode: C++; tab-width: 4; -*- // vi:ts=8 sw=4 noexpandtab autoindent /* * Copyright 2011 Perforce Software. All rights reserved. * * This file is part of Perforce - the FAST SCM System. */ /* * netutils - Utility routines for network support * * Classes Defined: * * NetUtils - IP network address utilities */ # define do_setsockopt( module, fd, level, optname, optval, optlen ) NetUtils::setsockopt( module, fd, level, optname, optval, optlen, #optname ) class NetUtils { public: static const bool IPADDR_PREFIX_PROHIBIT = false; static const bool IPADDR_PREFIX_ALLOW = true; static int setsockopt( const char *module, int sockfd, int level, int optname, const SOCKOPT_T *optval, socklen_t optlen, const char *name ); /* * Get IPv4 or IPv6 sin[6]_addr ptr convenience function. * Returns the sockaddr's sin_addr or sin6_addr pointer, * depending on the sockaddr's family. * Returns NULL if the sockaddr is neither IPv4 nor IPv6. */ static const void * GetInAddr(const sockaddr *sa); /* * Get IPv4 or IPv6 sockaddr size convenience function. * Returns 0 if the sockaddr is neither IPv4 nor IPv6. */ static size_t GetAddrSize(const sockaddr *sa); /* * Get IPv4 or IPv6 sin[6]_port convenience function. * Returns the sockaddr's sin_addr or sin6_addr port, * depending on the sockaddr's family. * Returns -1 if the sockaddr is neither IPv4 nor IPv6. */ static int GetInPort(const sockaddr *sa); /* * Return true iff this address is unspecified ("0.0.0.0" or "::"). */ static bool IsAddrUnspecified(const sockaddr *sa); static bool IsAddrIPv6(const sockaddr *sa); static bool IsIpV4Address(const char *addr, bool allowPrefix); // allowPrefix is ignored for IPv6 static bool IsIpV6Address(const char *addr, bool allowPrefix = true); // return a printable address static void GetAddress( int family, const sockaddr *addr, int raf_flags, StrBuf &printableAddress); // currently no-op except on Windows static int InitNetwork(); // currently no-op except on Windows static void CleanupNetwork(); }; # if defined(OS_MINGW) || (defined(OS_NT) && defined(_MSC_VER)) // ensure that we don't conflict with a global DLL version # define inet_ntop p4_inet_ntop # define inet_pton p4_inet_pton // MINGW doesn't currently (v4.5) provide inet_ntop() or inet_pton() const char * p4_inet_ntop( int af, const void *src, char *dst, TYPE_SOCKLEN size); int p4_inet_pton( int af, const char *src, void *dst); # endif // OS_MINGW || (OS_NT && Visual Studio) # if defined(OS_MINGW) || defined(OS_NT) // Windows doesn't yet provide inet_aton(); this handles only IPv4 addresses. int inet_aton( const char *cp, in_addr *addr); # endif // OS_MINGW || OS_NT
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 18760 | rlranft |
Populate -o //guest/perforce_software/p4/... //guest/rlranft/p4/.... |
||
//guest/perforce_software/p4/2014-2/net/netutils.h | |||||
#1 | 15903 | Matt Attaway | Everything should be happy now between the Workshop and the depot paths | ||
//guest/perforce_software/p4/2014_2/net/netutils.h | |||||
#1 | 15901 | Matt Attaway | Clean up code to fit modern Workshop naming standards | ||
//guest/perforce_software/p4/2014.2/net/netutils.h | |||||
#1 | 12189 | Matt Attaway | Initial (and much belated) drop of 2014.2 p4 source code |