1 /* Copyright (c) 2003-2006 MySQL AB
2    Use is subject to license terms
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; version 2 of the License.
7 
8    This program is distributed in the hope that it will be useful,
9    but WITHOUT ANY WARRANTY; without even the implied warranty of
10    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11    GNU General Public License for more details.
12 
13    You should have received a copy of the GNU General Public License
14    along with this program; if not, write to the Free Software
15    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA */
16 
17 #ifndef TransporterDefinitions_H
18 #define TransporterDefinitions_H
19 
20 #include <ndb_global.h>
21 #include <kernel_types.h>
22 #include <NdbOut.hpp>
23 
24 /**
25  * The maximum number of transporters allowed
26  * A maximum is needed to be able to allocate the array of transporters
27  */
28 const int MAX_NTRANSPORTERS = 128;
29 
30 /**
31  * The sendbuffer limit after which the contents of the buffer is sent
32  */
33 const int TCP_SEND_LIMIT = 64000;
34 
35 enum SendStatus {
36   SEND_OK = 0,
37   SEND_BLOCKED = 1,
38   SEND_DISCONNECTED = 2,
39   SEND_BUFFER_FULL = 3,
40   SEND_MESSAGE_TOO_BIG = 4,
41   SEND_UNKNOWN_NODE = 5
42 };
43 
44 /**
45  * Protocol6 Header +
46  *  (optional signal id) + (optional checksum) + (signal data)
47  */
48 //const Uint32 MAX_MESSAGE_SIZE = (12+4+4+(4*25));
49 const Uint32 MAX_MESSAGE_SIZE = (12+4+4+(4*25)+(3*4)+4*4096);
50 
51 /**
52  * TransporterConfiguration
53  *
54  * used for setting up a transporter. the union member specific is for
55  * information specific to a transporter type.
56  */
57 struct TransporterConfiguration {
58   Int32 s_port; // negative port number implies dynamic port
59   const char *remoteHostName;
60   const char *localHostName;
61   NodeId remoteNodeId;
62   NodeId localNodeId;
63   NodeId serverNodeId;
64   bool checksum;
65   bool signalId;
66   bool isMgmConnection; // is a mgm connection, requires transforming
67 
68   union { // Transporter specific configuration information
69 
70     struct {
71       Uint32 sendBufferSize;     // Size of SendBuffer of priority B
72       Uint32 maxReceiveSize;     // Maximum no of bytes to receive
73     } tcp;
74 
75     struct {
76       Uint32 shmKey;
77       Uint32 shmSize;
78       int    signum;
79     } shm;
80 
81     struct {
82       Uint32 prioASignalSize;
83       Uint32 prioBSignalSize;
84     } ose;
85 
86     struct {
87       Uint32 sendLimit;        // Packet size
88       Uint32 bufferSize;       // Buffer size
89 
90       Uint32 nLocalAdapters;   // 1 or 2, the number of adapters on local host
91 
92       Uint32 remoteSciNodeId0; // SCInodeId for adapter 1
93       Uint32 remoteSciNodeId1; // SCInodeId for adapter 2
94     } sci;
95   };
96 };
97 
98 struct SignalHeader {
99   Uint32 theVerId_signalNumber;    // 4 bit ver id - 16 bit gsn
100   Uint32 theReceiversBlockNumber;  // Only 16 bit blocknum
101   Uint32 theSendersBlockRef;
102   Uint32 theLength;
103   Uint32 theSendersSignalId;
104   Uint32 theSignalId;
105   Uint16 theTrace;
106   Uint8  m_noOfSections;
107   Uint8  m_fragmentInfo;
108 }; /** 7x4 = 28 Bytes */
109 
110 struct LinearSectionPtr {
111   Uint32 sz;
112   Uint32 * p;
113 };
114 
115 struct SegmentedSectionPtr {
116   Uint32 sz;
117   Uint32 i;
118   struct SectionSegment * p;
119 
SegmentedSectionPtrSegmentedSectionPtr120   SegmentedSectionPtr() {}
SegmentedSectionPtrSegmentedSectionPtr121   SegmentedSectionPtr(Uint32 sz_arg, Uint32 i_arg,
122                       struct SectionSegment *p_arg)
123     :sz(sz_arg), i(i_arg), p(p_arg)
124   {}
setNullSegmentedSectionPtr125   void setNull() { p = 0;}
isNullSegmentedSectionPtr126   bool isNull() const { return p == 0;}
127 };
128 
129 class NdbOut & operator <<(class NdbOut & out, SignalHeader & sh);
130 
131 #endif // Define of TransporterDefinitions_H
132