summaryrefslogtreecommitdiff
path: root/cs/src/Ice/Protocol.cs
blob: ad82b545b71497e08dca8c71c4fe7d203d9c7298 (plain)
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
// **********************************************************************
//
// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

namespace IceInternal
{

    sealed class Protocol
    {
	//
	// Size of the Ice protocol header
	//
	// Magic number (4 bytes)
	// Protocol version major (Byte)
	// Protocol version minor (Byte)
	// Encoding version major (Byte)
	// Encoding version minor (Byte)
	// Message type (Byte)
	// Compression status (Byte)
	// Message size (Int)
	//
	internal const int headerSize = 14;
	
	//
	// The magic number at the front of each message
	//
	internal static readonly byte[] magic
	    = new byte[] { (byte)0x49, (byte)0x63, (byte)0x65, (byte)0x50 }; // 'I', 'c', 'e', 'P'
	
	//
	// The current Ice protocol and encoding version
	//
	internal const byte protocolMajor = 1;
	internal const byte protocolMinor = 0;
	internal const byte encodingMajor = 1;
	internal const byte encodingMinor = 0;
	
	//
	// The Ice protocol message types
	//
	internal const byte requestMsg = 0;
	internal const byte requestBatchMsg = 1;
	internal const byte replyMsg = 2;
	internal const byte validateConnectionMsg = 3;
	internal const byte closeConnectionMsg = 4;

	internal static readonly byte[] requestHdr = new byte[]
	{
	    IceInternal.Protocol.magic[0], IceInternal.Protocol.magic[1], IceInternal.Protocol.magic[2], 
	    IceInternal.Protocol.magic[3],
	    IceInternal.Protocol.protocolMajor, IceInternal.Protocol.protocolMinor,
	    IceInternal.Protocol.encodingMajor, IceInternal.Protocol.encodingMinor,
	    IceInternal.Protocol.requestMsg,
	    (byte)0, // Compression status.
	    (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder).
	    (byte)0, (byte)0, (byte)0, (byte)0	// Request ID (placeholder).
	};

	internal static readonly byte[] requestBatchHdr = new byte[]
	{
	    IceInternal.Protocol.magic[0], IceInternal.Protocol.magic[1], IceInternal.Protocol.magic[2],
	    IceInternal.Protocol.magic[3],
	    IceInternal.Protocol.protocolMajor, IceInternal.Protocol.protocolMinor,
	    IceInternal.Protocol.encodingMajor, IceInternal.Protocol.encodingMinor,
	    IceInternal.Protocol.requestBatchMsg,
	    (byte)0, // Compression status.
	    (byte)0, (byte)0, (byte)0, (byte)0, // Message size (placeholder).
	    (byte)0, (byte)0, (byte)0, (byte)0	// Number of requests in batch (placeholder).
	};
	
	internal static readonly byte[] replyHdr = new byte[]
	{
	    IceInternal.Protocol.magic[0], IceInternal.Protocol.magic[1], IceInternal.Protocol.magic[2], 
	    IceInternal.Protocol.magic[3],
	    IceInternal.Protocol.protocolMajor, IceInternal.Protocol.protocolMinor,
	    IceInternal.Protocol.encodingMajor, IceInternal.Protocol.encodingMinor,
	    IceInternal.Protocol.replyMsg,
	    (byte)0, // Compression status.
	    (byte)0, (byte)0, (byte)0, (byte)0 // Message size (placeholder).
	};
	
    }

}