summaryrefslogtreecommitdiffstats
path: root/3rdparty/openpgm-svn-r1135/pgm/include/pgm/ip/pgm.hh
blob: a5e260fe0f8f1222853915c44795378970a4b306 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* vim:ts=8:sts=4:sw=4:noai:noexpandtab
 * 
 * PGM protocol
 *
 * Copyright (c) 2010 Miru Limited.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __PGM_IP_PGM_HH__
#define __PGM_IP_PGM_HH__

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#	pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)

namespace pgm {
#define restrict
#include <pgm/pgm.h>
}

namespace ip {

class pgm
{
public:
	/// The type of a PGM endpoint.
	typedef pgm_endpoint<pgm> endpoint;

	/// Construct to represent PGM over IPv4.
	static pgm v4()
	{
		return pgm (PF_INET);
	}

	/// Construct to represent PGM over IPv6.
	static pgm v6()
	{
		return pgm (PF_INET6);
	}

	/// Obtain an identifier for the type of the protocol.
	int type() const
	{
		return SOCK_SEQPACKET;
	}

	/// Obtain an identifier for the protocol.
	int protocol() const
	{
		return IPPROTO_PGM;
	}

	/// Obtain an identifier for the protocol family.
	int family() const
	{
		return family_;
	}

	/// The PGM socket type.
	typedef pgm_socket<pgm> socket;

	/// Compare two protocols for equality.
	friend bool operator== (const pgm& p1, const pgm& p2)
	{
		return p1.family_ == p2.family_;
	}

	/// Compare two protocols for inequality.
	friend bool operator!= (const pgm& p1, const pgm& p2)
	{
		return p1.family_ != p2.family_;
	}

private:
	// Construct with a specific family.
	explicit pgm (int family)
	: family_ (family)
	{
	}

	int family_;
};

} // namespace ip


#endif /* __PGM_IP_PGM_HH__ */