@@ -12,7 +12,8 @@ package ibmmq
12
12
Unless required by applicable law or agreed to in writing, software
13
13
distributed under the License is distributed on an "AS IS" BASIS,
14
14
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- See the License for the specific
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
16
17
17
18
Contributors:
18
19
Mark Taylor - Initial Contribution
@@ -29,7 +30,7 @@ package ibmmq
29
30
import "C"
30
31
31
32
import (
32
- "unsafe"
33
+ "unsafe"
33
34
)
34
35
35
36
/*
@@ -38,23 +39,23 @@ Only fields relevant to a client connection are included in the
38
39
Go version of this structure.
39
40
*/
40
41
type MQCD struct {
41
- ChannelName string
42
- ConnectionName string
43
- DiscInterval int32
44
- SecurityExit string
45
- SecurityUserData string
46
- MaxMsgLength int32
47
- HeartbeatInterval int32
48
- SSLCipherSpec string
49
- SSLPeerName string
50
- SSLClientAuth int32
51
- KeepAliveInterval int32
52
- SharingConversations int32
53
- PropertyControl int32
54
- ClientChannelWeight int32
55
- ConnectionAffinity int32
56
- DefReconnect int32
57
- CertificateLabel string
42
+ ChannelName string
43
+ ConnectionName string
44
+ DiscInterval int32
45
+ SecurityExit string
46
+ SecurityUserData string
47
+ MaxMsgLength int32
48
+ HeartbeatInterval int32
49
+ SSLCipherSpec string
50
+ SSLPeerName string
51
+ SSLClientAuth int32
52
+ KeepAliveInterval int32
53
+ SharingConversations int32
54
+ PropertyControl int32
55
+ ClientChannelWeight int32
56
+ ConnectionAffinity int32
57
+ DefReconnect int32
58
+ CertificateLabel string
58
59
}
59
60
60
61
/*
@@ -63,27 +64,27 @@ MQCD_CLIENT_CONN_DEFAULT
63
64
*/
64
65
func NewMQCD () * MQCD {
65
66
66
- cd := new (MQCD )
67
-
68
- cd .ChannelName = ""
69
- cd .DiscInterval = 6000
70
- cd .SecurityExit = ""
71
- cd .SecurityUserData = ""
72
- cd .MaxMsgLength = 4194304
73
- cd .ConnectionName = ""
74
- cd .HeartbeatInterval = 1
75
- cd .SSLCipherSpec = ""
76
- cd .SSLPeerName = ""
77
- cd .SSLClientAuth = int32 (C .MQSCA_REQUIRED )
78
- cd .KeepAliveInterval = - 1
79
- cd .SharingConversations = 10
80
- cd .PropertyControl = int32 (C .MQPROP_COMPATIBILITY )
81
- cd .ClientChannelWeight = 0
82
- cd .ConnectionAffinity = int32 (C .MQCAFTY_PREFERRED )
83
- cd .DefReconnect = int32 (C .MQRCN_NO )
84
- cd .CertificateLabel = ""
85
-
86
- return cd
67
+ cd := new (MQCD )
68
+
69
+ cd .ChannelName = ""
70
+ cd .DiscInterval = 6000
71
+ cd .SecurityExit = ""
72
+ cd .SecurityUserData = ""
73
+ cd .MaxMsgLength = 4194304
74
+ cd .ConnectionName = ""
75
+ cd .HeartbeatInterval = 1
76
+ cd .SSLCipherSpec = ""
77
+ cd .SSLPeerName = ""
78
+ cd .SSLClientAuth = int32 (C .MQSCA_REQUIRED )
79
+ cd .KeepAliveInterval = - 1
80
+ cd .SharingConversations = 10
81
+ cd .PropertyControl = int32 (C .MQPROP_COMPATIBILITY )
82
+ cd .ClientChannelWeight = 0
83
+ cd .ConnectionAffinity = int32 (C .MQCAFTY_PREFERRED )
84
+ cd .DefReconnect = int32 (C .MQRCN_NO )
85
+ cd .CertificateLabel = ""
86
+
87
+ return cd
87
88
}
88
89
89
90
/*
@@ -96,104 +97,104 @@ MQ_CLIENT_CONN_DEFAULT structure for consistency.
96
97
*/
97
98
func copyCDtoC (mqcd * C.MQCD , gocd * MQCD ) {
98
99
99
- setMQIString ((* C .char )(& mqcd .ChannelName [0 ]), gocd .ChannelName , C .MQ_CHANNEL_NAME_LENGTH )
100
- mqcd .Version = C .MQCD_VERSION_11 // The version this is written to match
101
- mqcd .ChannelType = C .MQCHT_CLNTCONN
102
- mqcd .TransportType = C .MQXPT_TCP
103
- setMQIString ((* C .char )(& mqcd .Desc [0 ]), "" , C .MQ_CHANNEL_DESC_LENGTH )
104
- setMQIString ((* C .char )(& mqcd .QMgrName [0 ]), "" , C .MQ_OBJECT_NAME_LENGTH )
105
- setMQIString ((* C .char )(& mqcd .XmitQName [0 ]), "" , C .MQ_OBJECT_NAME_LENGTH )
106
- setMQIString ((* C .char )(& mqcd .ShortConnectionName [0 ]), "" , C .MQ_SHORT_CONN_NAME_LENGTH )
107
- setMQIString ((* C .char )(& mqcd .MCAName [0 ]), "" , C .MQ_MCA_NAME_LENGTH )
108
- setMQIString ((* C .char )(& mqcd .ModeName [0 ]), "" , C .MQ_MODE_NAME_LENGTH )
109
- setMQIString ((* C .char )(& mqcd .TpName [0 ]), "" , C .MQ_TP_NAME_LENGTH )
110
- mqcd .BatchSize = 50
111
- mqcd .DiscInterval = 6000
112
- mqcd .ShortRetryCount = 10
113
- mqcd .ShortRetryInterval = 60
114
- mqcd .LongRetryCount = 999999999
115
- mqcd .LongRetryInterval = 1200
116
- setMQIString ((* C .char )(& mqcd .SecurityExit [0 ]), gocd .SecurityExit , C .MQ_EXIT_NAME_LENGTH )
117
- setMQIString ((* C .char )(& mqcd .MsgExit [0 ]), "" , C .MQ_EXIT_NAME_LENGTH )
118
- setMQIString ((* C .char )(& mqcd .SendExit [0 ]), "" , C .MQ_EXIT_NAME_LENGTH )
119
- setMQIString ((* C .char )(& mqcd .ReceiveExit [0 ]), "" , C .MQ_EXIT_NAME_LENGTH )
120
- mqcd .SeqNumberWrap = 999999999
121
- mqcd .MaxMsgLength = C .MQLONG (gocd .MaxMsgLength )
122
- mqcd .PutAuthority = C .MQPA_DEFAULT
123
- mqcd .DataConversion = C .MQCDC_NO_SENDER_CONVERSION
124
- setMQIString ((* C .char )(& mqcd .SecurityUserData [0 ]), gocd .SecurityUserData , C .MQ_EXIT_DATA_LENGTH )
125
- setMQIString ((* C .char )(& mqcd .MsgUserData [0 ]), "" , C .MQ_EXIT_DATA_LENGTH )
126
- setMQIString ((* C .char )(& mqcd .SendUserData [0 ]), "" , C .MQ_EXIT_DATA_LENGTH )
127
- setMQIString ((* C .char )(& mqcd .ReceiveUserData [0 ]), "" , C .MQ_EXIT_DATA_LENGTH )
128
- setMQIString ((* C .char )(& mqcd .UserIdentifier [0 ]), "" , C .MQ_USER_ID_LENGTH )
129
- setMQIString ((* C .char )(& mqcd .Password [0 ]), "" , C .MQ_PASSWORD_LENGTH )
130
- setMQIString ((* C .char )(& mqcd .MCAUserIdentifier [0 ]), "" , C .MQ_USER_ID_LENGTH )
131
- mqcd .MCAType = C .MQMCAT_PROCESS
132
- setMQIString ((* C .char )(& mqcd .ConnectionName [0 ]), gocd .ConnectionName , C .MQ_CONN_NAME_LENGTH )
133
- setMQIString ((* C .char )(& mqcd .RemoteUserIdentifier [0 ]), "" , C .MQ_USER_ID_LENGTH )
134
- setMQIString ((* C .char )(& mqcd .RemotePassword [0 ]), "" , C .MQ_PASSWORD_LENGTH )
135
- setMQIString ((* C .char )(& mqcd .MsgRetryExit [0 ]), "" , C .MQ_EXIT_NAME_LENGTH )
136
- setMQIString ((* C .char )(& mqcd .MsgRetryUserData [0 ]), "" , C .MQ_EXIT_DATA_LENGTH )
137
- mqcd .MsgRetryCount = 10
138
- mqcd .MsgRetryInterval = 1000
139
- mqcd .HeartbeatInterval = 1
140
- mqcd .BatchInterval = 0
141
- mqcd .NonPersistentMsgSpeed = C .MQNPMS_FAST
142
- mqcd .StrucLength = C .MQCD_LENGTH_11
143
- mqcd .ExitNameLength = C .MQ_EXIT_NAME_LENGTH
144
- mqcd .ExitDataLength = C .MQ_EXIT_DATA_LENGTH
145
- mqcd .MsgExitsDefined = 0
146
- mqcd .SendExitsDefined = 0
147
- mqcd .ReceiveExitsDefined = 0
148
- mqcd .MsgExitPtr = C .MQPTR (nil )
149
- mqcd .MsgUserDataPtr = C .MQPTR (nil )
150
- mqcd .SendExitPtr = C .MQPTR (nil )
151
- mqcd .SendUserDataPtr = C .MQPTR (nil )
152
- mqcd .ReceiveExitPtr = C .MQPTR (nil )
153
- mqcd .ReceiveUserDataPtr = C .MQPTR (nil )
154
- mqcd .ClusterPtr = C .MQPTR (nil )
155
- mqcd .ClustersDefined = 0
156
- mqcd .NetworkPriority = 0
157
- mqcd .LongMCAUserIdLength = 0
158
- mqcd .LongRemoteUserIdLength = 0
159
- mqcd .LongMCAUserIdPtr = C .MQPTR (nil )
160
- mqcd .LongRemoteUserIdPtr = C .MQPTR (nil )
161
- C .memset ((unsafe .Pointer )(& mqcd .MCASecurityId [0 ]), 0 , C .MQ_SECURITY_ID_LENGTH )
162
- C .memset ((unsafe .Pointer )(& mqcd .RemoteSecurityId [0 ]), 0 , C .MQ_SECURITY_ID_LENGTH )
163
- setMQIString ((* C .char )(& mqcd .SSLCipherSpec [0 ]), gocd .SSLCipherSpec , C .MQ_SSL_CIPHER_SPEC_LENGTH )
164
- mqcd .SSLPeerNamePtr = C .MQPTR (nil )
165
- mqcd .SSLPeerNameLength = 0
166
- if gocd .SSLPeerName != "" {
167
- mqcd .SSLPeerNamePtr = C .MQPTR (unsafe .Pointer (C .CString (gocd .SSLPeerName )))
168
- mqcd .SSLPeerNameLength = C .MQLONG (len (gocd .SSLPeerName ))
169
- }
170
- mqcd .SSLClientAuth = C .MQLONG (gocd .SSLClientAuth )
171
- mqcd .KeepAliveInterval = C .MQLONG (gocd .KeepAliveInterval )
172
- setMQIString ((* C .char )(& mqcd .LocalAddress [0 ]), "" , C .MQ_LOCAL_ADDRESS_LENGTH )
173
- mqcd .BatchHeartbeat = 0
174
- for i := 0 ; i < 2 ; i ++ {
175
- mqcd .HdrCompList [i ] = C .MQCOMPRESS_NOT_AVAILABLE
176
- }
177
- for i := 0 ; i < 16 ; i ++ {
178
- mqcd .MsgCompList [i ] = C .MQCOMPRESS_NOT_AVAILABLE
179
- }
180
- mqcd .CLWLChannelRank = 0
181
- mqcd .CLWLChannelPriority = 0
182
- mqcd .CLWLChannelWeight = 50
183
- mqcd .ChannelMonitoring = C .MQMON_OFF
184
- mqcd .ChannelStatistics = C .MQMON_OFF
185
- mqcd .SharingConversations = C .MQLONG (gocd .SharingConversations )
186
- mqcd .PropertyControl = C .MQLONG (gocd .PropertyControl )
187
- mqcd .MaxInstances = 999999999
188
- mqcd .MaxInstancesPerClient = 999999999
189
- mqcd .ClientChannelWeight = C .MQLONG (gocd .ClientChannelWeight )
190
- mqcd .ConnectionAffinity = C .MQLONG (gocd .ConnectionAffinity )
191
- mqcd .BatchDataLimit = 5000
192
- mqcd .UseDLQ = C .MQUSEDLQ_YES
193
- mqcd .DefReconnect = C .MQLONG (gocd .DefReconnect )
194
- setMQIString ((* C .char )(& mqcd .CertificateLabel [0 ]), gocd .CertificateLabel , C .MQ_CERT_LABEL_LENGTH )
195
-
196
- return
100
+ setMQIString ((* C .char )(& mqcd .ChannelName [0 ]), gocd .ChannelName , C .MQ_CHANNEL_NAME_LENGTH )
101
+ mqcd .Version = C .MQCD_VERSION_11 // The version this is written to match
102
+ mqcd .ChannelType = C .MQCHT_CLNTCONN
103
+ mqcd .TransportType = C .MQXPT_TCP
104
+ setMQIString ((* C .char )(& mqcd .Desc [0 ]), "" , C .MQ_CHANNEL_DESC_LENGTH )
105
+ setMQIString ((* C .char )(& mqcd .QMgrName [0 ]), "" , C .MQ_OBJECT_NAME_LENGTH )
106
+ setMQIString ((* C .char )(& mqcd .XmitQName [0 ]), "" , C .MQ_OBJECT_NAME_LENGTH )
107
+ setMQIString ((* C .char )(& mqcd .ShortConnectionName [0 ]), "" , C .MQ_SHORT_CONN_NAME_LENGTH )
108
+ setMQIString ((* C .char )(& mqcd .MCAName [0 ]), "" , C .MQ_MCA_NAME_LENGTH )
109
+ setMQIString ((* C .char )(& mqcd .ModeName [0 ]), "" , C .MQ_MODE_NAME_LENGTH )
110
+ setMQIString ((* C .char )(& mqcd .TpName [0 ]), "" , C .MQ_TP_NAME_LENGTH )
111
+ mqcd .BatchSize = 50
112
+ mqcd .DiscInterval = 6000
113
+ mqcd .ShortRetryCount = 10
114
+ mqcd .ShortRetryInterval = 60
115
+ mqcd .LongRetryCount = 999999999
116
+ mqcd .LongRetryInterval = 1200
117
+ setMQIString ((* C .char )(& mqcd .SecurityExit [0 ]), gocd .SecurityExit , C .MQ_EXIT_NAME_LENGTH )
118
+ setMQIString ((* C .char )(& mqcd .MsgExit [0 ]), "" , C .MQ_EXIT_NAME_LENGTH )
119
+ setMQIString ((* C .char )(& mqcd .SendExit [0 ]), "" , C .MQ_EXIT_NAME_LENGTH )
120
+ setMQIString ((* C .char )(& mqcd .ReceiveExit [0 ]), "" , C .MQ_EXIT_NAME_LENGTH )
121
+ mqcd .SeqNumberWrap = 999999999
122
+ mqcd .MaxMsgLength = C .MQLONG (gocd .MaxMsgLength )
123
+ mqcd .PutAuthority = C .MQPA_DEFAULT
124
+ mqcd .DataConversion = C .MQCDC_NO_SENDER_CONVERSION
125
+ setMQIString ((* C .char )(& mqcd .SecurityUserData [0 ]), gocd .SecurityUserData , C .MQ_EXIT_DATA_LENGTH )
126
+ setMQIString ((* C .char )(& mqcd .MsgUserData [0 ]), "" , C .MQ_EXIT_DATA_LENGTH )
127
+ setMQIString ((* C .char )(& mqcd .SendUserData [0 ]), "" , C .MQ_EXIT_DATA_LENGTH )
128
+ setMQIString ((* C .char )(& mqcd .ReceiveUserData [0 ]), "" , C .MQ_EXIT_DATA_LENGTH )
129
+ setMQIString ((* C .char )(& mqcd .UserIdentifier [0 ]), "" , C .MQ_USER_ID_LENGTH )
130
+ setMQIString ((* C .char )(& mqcd .Password [0 ]), "" , C .MQ_PASSWORD_LENGTH )
131
+ setMQIString ((* C .char )(& mqcd .MCAUserIdentifier [0 ]), "" , C .MQ_USER_ID_LENGTH )
132
+ mqcd .MCAType = C .MQMCAT_PROCESS
133
+ setMQIString ((* C .char )(& mqcd .ConnectionName [0 ]), gocd .ConnectionName , C .MQ_CONN_NAME_LENGTH )
134
+ setMQIString ((* C .char )(& mqcd .RemoteUserIdentifier [0 ]), "" , C .MQ_USER_ID_LENGTH )
135
+ setMQIString ((* C .char )(& mqcd .RemotePassword [0 ]), "" , C .MQ_PASSWORD_LENGTH )
136
+ setMQIString ((* C .char )(& mqcd .MsgRetryExit [0 ]), "" , C .MQ_EXIT_NAME_LENGTH )
137
+ setMQIString ((* C .char )(& mqcd .MsgRetryUserData [0 ]), "" , C .MQ_EXIT_DATA_LENGTH )
138
+ mqcd .MsgRetryCount = 10
139
+ mqcd .MsgRetryInterval = 1000
140
+ mqcd .HeartbeatInterval = 1
141
+ mqcd .BatchInterval = 0
142
+ mqcd .NonPersistentMsgSpeed = C .MQNPMS_FAST
143
+ mqcd .StrucLength = C .MQCD_LENGTH_11
144
+ mqcd .ExitNameLength = C .MQ_EXIT_NAME_LENGTH
145
+ mqcd .ExitDataLength = C .MQ_EXIT_DATA_LENGTH
146
+ mqcd .MsgExitsDefined = 0
147
+ mqcd .SendExitsDefined = 0
148
+ mqcd .ReceiveExitsDefined = 0
149
+ mqcd .MsgExitPtr = C .MQPTR (nil )
150
+ mqcd .MsgUserDataPtr = C .MQPTR (nil )
151
+ mqcd .SendExitPtr = C .MQPTR (nil )
152
+ mqcd .SendUserDataPtr = C .MQPTR (nil )
153
+ mqcd .ReceiveExitPtr = C .MQPTR (nil )
154
+ mqcd .ReceiveUserDataPtr = C .MQPTR (nil )
155
+ mqcd .ClusterPtr = C .MQPTR (nil )
156
+ mqcd .ClustersDefined = 0
157
+ mqcd .NetworkPriority = 0
158
+ mqcd .LongMCAUserIdLength = 0
159
+ mqcd .LongRemoteUserIdLength = 0
160
+ mqcd .LongMCAUserIdPtr = C .MQPTR (nil )
161
+ mqcd .LongRemoteUserIdPtr = C .MQPTR (nil )
162
+ C .memset ((unsafe .Pointer )(& mqcd .MCASecurityId [0 ]), 0 , C .MQ_SECURITY_ID_LENGTH )
163
+ C .memset ((unsafe .Pointer )(& mqcd .RemoteSecurityId [0 ]), 0 , C .MQ_SECURITY_ID_LENGTH )
164
+ setMQIString ((* C .char )(& mqcd .SSLCipherSpec [0 ]), gocd .SSLCipherSpec , C .MQ_SSL_CIPHER_SPEC_LENGTH )
165
+ mqcd .SSLPeerNamePtr = C .MQPTR (nil )
166
+ mqcd .SSLPeerNameLength = 0
167
+ if gocd .SSLPeerName != "" {
168
+ mqcd .SSLPeerNamePtr = C .MQPTR (unsafe .Pointer (C .CString (gocd .SSLPeerName )))
169
+ mqcd .SSLPeerNameLength = C .MQLONG (len (gocd .SSLPeerName ))
170
+ }
171
+ mqcd .SSLClientAuth = C .MQLONG (gocd .SSLClientAuth )
172
+ mqcd .KeepAliveInterval = C .MQLONG (gocd .KeepAliveInterval )
173
+ setMQIString ((* C .char )(& mqcd .LocalAddress [0 ]), "" , C .MQ_LOCAL_ADDRESS_LENGTH )
174
+ mqcd .BatchHeartbeat = 0
175
+ for i := 0 ; i < 2 ; i ++ {
176
+ mqcd .HdrCompList [i ] = C .MQCOMPRESS_NOT_AVAILABLE
177
+ }
178
+ for i := 0 ; i < 16 ; i ++ {
179
+ mqcd .MsgCompList [i ] = C .MQCOMPRESS_NOT_AVAILABLE
180
+ }
181
+ mqcd .CLWLChannelRank = 0
182
+ mqcd .CLWLChannelPriority = 0
183
+ mqcd .CLWLChannelWeight = 50
184
+ mqcd .ChannelMonitoring = C .MQMON_OFF
185
+ mqcd .ChannelStatistics = C .MQMON_OFF
186
+ mqcd .SharingConversations = C .MQLONG (gocd .SharingConversations )
187
+ mqcd .PropertyControl = C .MQLONG (gocd .PropertyControl )
188
+ mqcd .MaxInstances = 999999999
189
+ mqcd .MaxInstancesPerClient = 999999999
190
+ mqcd .ClientChannelWeight = C .MQLONG (gocd .ClientChannelWeight )
191
+ mqcd .ConnectionAffinity = C .MQLONG (gocd .ConnectionAffinity )
192
+ mqcd .BatchDataLimit = 5000
193
+ mqcd .UseDLQ = C .MQUSEDLQ_YES
194
+ mqcd .DefReconnect = C .MQLONG (gocd .DefReconnect )
195
+ setMQIString ((* C .char )(& mqcd .CertificateLabel [0 ]), gocd .CertificateLabel , C .MQ_CERT_LABEL_LENGTH )
196
+
197
+ return
197
198
}
198
199
199
200
/*
@@ -202,9 +203,9 @@ Just need to clear up anything that was allocated in the copyCDtoC function
202
203
*/
203
204
func copyCDfromC (mqcd * C.MQCD , gocd * MQCD ) {
204
205
205
- if mqcd .SSLPeerNamePtr != nil {
206
- C .free (unsafe .Pointer (mqcd .SSLPeerNamePtr ))
207
- }
206
+ if mqcd .SSLPeerNamePtr != nil {
207
+ C .free (unsafe .Pointer (mqcd .SSLPeerNamePtr ))
208
+ }
208
209
209
- return
210
+ return
210
211
}
0 commit comments