netaddrinfo.h #1

  • //
  • guest/
  • perforce_software/
  • p4/
  • 2016-1/
  • net/
  • netaddrinfo.h
  • View
  • Commits
  • Open Download .zip Download (1 KB)
// -*- mode: C++; tab-width: 4; -*-
// vi:ts=8 sw=4 noexpandtab autoindent

/*
 * netaddrinfo.h - network address encoding and decoding
 *
 * Copyright 2011 Perforce Software.  All rights reserved.
 *
 * This file is part of Perforce - the FAST SCM System.
 *
 * Classes Defined:
 *
 *	NetAddrInfo - Transform a network address string into a format suitable
 *	           for accept/connect
 */

# include "netportipv6.h"
# include "netport.h"

// encapsulate a struct addrinfo and its operations
class NetAddrInfo
{
public:
	enum SockType
	{
	    SockTypeStream,
	    SockTypeDatagram
	};

	NetAddrInfo(
	    const StrPtr &hostname,
	    const StrPtr &portname);

	~NetAddrInfo();

	int
	GetHintsFamily() const;

	void
	SetHintsFamily(int family);

	int
	GetHintsFlags() const;

	void
	SetHintsFlags(int flags);

	SockType
	GetHintsSockType() const;

	void
	SetHintsSockType(SockType type);

	bool
	GetInfo(Error *e);

	int
	GetStatus()
	{
	    return m_status;
	}

	const StrPtr
	Host()
	{
	    return m_hostname;
	}

	const StrPtr
	Port()
	{
	    return m_portname;
	}

	// fake iterator-like methods
	const addrinfo *
	begin() const
	{
	    return m_serverinfo;
	}

	const addrinfo *
	end() const
	{
	    return NULL;
	}

private:
	addrinfo	*m_serverinfo;
	addrinfo	m_hints;
	const StrPtr	m_hostname;
	const StrPtr	m_portname;
	int		m_status;
};
# Change User Description Committed
#1 19472 Liz Lam Initial add of the 2016.1 p4/p4api source code.