2 * Routines for Distributed Relational Database Architecture packet dissection
4 * metatech <metatech@flashmail.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 * DRDA stands for Distributed Relational Database Architecture.
30 * It is a protocol between database client and database server published by
31 * the Open Group (www.opengroup.org) DDM (Distributed Data Management) is an
32 * data management interface which allows to exchange structured data between
33 * systems. DRDA is specific to relational databases and uses a subset of DDM
34 * to transport its data. The IBM DB2 product uses the DRDA protocol from
35 * version V8. Unless negotiated differently during the handshake, the fields
36 * of the DDM commands and reply messages are in EBCDIC.
39 * DRDA Version 3 Vol. 3: Distributed Relational Database Architecture,
41 * Version 3 is no longer available; for the latest version, see
43 * http://www.opengroup.org/dbiop/
45 * Reference for Remote DRDA Requesters and Servers, IBM.
47 * https://www-304.ibm.com/support/docview.wss?uid=pub1sc18985301
53 #include <epan/packet.h>
54 #include <epan/conversation.h>
55 #include <epan/prefs.h>
56 #include <epan/expert.h>
57 #include "packet-tcp.h"
59 void proto_register_drda(void);
60 void proto_reg_handoff_drda(void);
62 static int proto_drda
= -1;
63 static int hf_drda_ddm_length
= -1;
64 static int hf_drda_ddm_magic
= -1;
65 static int hf_drda_ddm_format
= -1;
66 static int hf_drda_ddm_fmt_reserved
= -1;
67 static int hf_drda_ddm_fmt_chained
= -1;
68 static int hf_drda_ddm_fmt_errcont
= -1;
69 static int hf_drda_ddm_fmt_samecorr
= -1;
70 static int hf_drda_ddm_fmt_dsstyp
= -1;
71 static int hf_drda_ddm_rc
= -1;
72 static int hf_drda_ddm_length2
= -1;
73 static int hf_drda_ddm_codepoint
= -1;
74 static int hf_drda_param_length
= -1;
75 static int hf_drda_param_codepoint
= -1;
76 static int hf_drda_param_data
= -1;
77 static int hf_drda_param_data_ebcdic
= -1;
78 static int hf_drda_sqlstatement
= -1;
79 static int hf_drda_sqlstatement_ebcdic
= -1;
81 static gint ett_drda
= -1;
82 static gint ett_drda_ddm
= -1;
83 static gint ett_drda_ddm_format
= -1;
84 static gint ett_drda_param
= -1;
86 static expert_field ei_drda_opcode_invalid_length
= EI_INIT
;
88 static dissector_handle_t drda_tcp_handle
;
90 static gboolean drda_desegment
= TRUE
;
92 #define DRDA_MAGIC 0xD0
94 #define DRDA_CP_DATA 0x0000
95 #define DRDA_CP_CODPNT 0x000C
96 #define DRDA_CP_FDODSC 0x0010
97 #define DRDA_CP_TYPDEFNAM 0x002F
98 #define DRDA_CP_TYPDEFOVR 0x0035
99 #define DRDA_CP_CODPNTDR 0x0064
100 #define DRDA_CP_EXCSAT 0x1041
101 #define DRDA_CP_SYNCCTL 0x1055
102 #define DRDA_CP_SYNCRSY 0x1069
103 #define DRDA_CP_ACCSEC 0x106D
104 #define DRDA_CP_SECCHK 0x106E
105 #define DRDA_CP_SYNCLOG 0x106F
106 #define DRDA_CP_RSCTYP 0x111F
107 #define DRDA_CP_RSNCOD 0x1127
108 #define DRDA_CP_RSCNAM 0x112D
109 #define DRDA_CP_PRDID 0x112E
110 #define DRDA_CP_PRCCNVCD 0x113F
111 #define DRDA_CP_VRSNAM 0x1144
112 #define DRDA_CP_SRVCLSNM 0x1147
113 #define DRDA_CP_SVRCOD 0x1149
114 #define DRDA_CP_SYNERRCD 0x114A
115 #define DRDA_CP_SRVDGN 0x1153
116 #define DRDA_CP_SRVRLSLV 0x115A
117 #define DRDA_CP_SPVNAM 0x115D
118 #define DRDA_CP_EXTNAM 0x115E
119 #define DRDA_CP_SRVNAM 0x116D
120 #define DRDA_CP_SECMGRNM 0x1196
121 #define DRDA_CP_DEPERRCD 0x119B
122 #define DRDA_CP_CCSIDSBC 0x119C
123 #define DRDA_CP_CCSIDDBC 0x119D
124 #define DRDA_CP_CCSIDMBC 0x119E
125 #define DRDA_CP_USRID 0x11A0
126 #define DRDA_CP_PASSWORD 0x11A1
127 #define DRDA_CP_SECMEC 0x11A2
128 #define DRDA_CP_SECCHKCD 0x11A4
129 #define DRDA_CP_SVCERRNO 0x11B4
130 #define DRDA_CP_SECTKN 0x11DC
131 #define DRDA_CP_NEWPASSWORD 0x11DE
132 #define DRDA_CP_MGRLVLRM 0x1210
133 #define DRDA_CP_MGRDEPRM 0x1218
134 #define DRDA_CP_SECCHKRM 0x1219
135 #define DRDA_CP_CMDATHRM 0x121C
136 #define DRDA_CP_AGNPRMRM 0x1232
137 #define DRDA_CP_RSCLMTRM 0x1233
138 #define DRDA_CP_PRCCNVRM 0x1245
139 #define DRDA_CP_CMDCMPRM 0x124B
140 #define DRDA_CP_SYNTAXRM 0x124C
141 #define DRDA_CP_CMDNSPRM 0x1250
142 #define DRDA_CP_PRMNSPRM 0x1251
143 #define DRDA_CP_VALNSPRM 0x1252
144 #define DRDA_CP_OBJNSPRM 0x1253
145 #define DRDA_CP_CMDCHKRM 0x1254
146 #define DRDA_CP_TRGNSPRM 0x125F
147 #define DRDA_CP_AGENT 0x1403
148 #define DRDA_CP_MGRLVLLS 0x1404
149 #define DRDA_CP_SUPERVISOR 0x143C
150 #define DRDA_CP_SECMGR 0x1440
151 #define DRDA_CP_EXCSATRD 0x1443
152 #define DRDA_CP_CMNAPPC 0x1444
153 #define DRDA_CP_DICTIONARY 0x1458
154 #define DRDA_CP_MGRLVLN 0x1473
155 #define DRDA_CP_CMNTCPIP 0x1474
156 #define DRDA_CP_FDODTA 0x147A
157 #define DRDA_CP_CMNSYNCPT 0x147C
158 #define DRDA_CP_ACCSECRD 0x14AC
159 #define DRDA_CP_SYNCPTMGR 0x14C0
160 #define DRDA_CP_RSYNCMGR 0x14C1
161 #define DRDA_CP_CCSIDMGR 0x14CC
162 #define DRDA_CP_MONITOR 0x1900
163 #define DRDA_CP_MONITORRD 0x1C00
164 #define DRDA_CP_XAMGR 0x1C01
165 #define DRDA_CP_ACCRDB 0x2001
166 #define DRDA_CP_BGNBND 0x2002
167 #define DRDA_CP_BNDSQLSTT 0x2004
168 #define DRDA_CP_CLSQRY 0x2005
169 #define DRDA_CP_CNTQRY 0x2006
170 #define DRDA_CP_DRPPKG 0x2007
171 #define DRDA_CP_DSCSQLSTT 0x2008
172 #define DRDA_CP_ENDBND 0x2009
173 #define DRDA_CP_EXCSQLIMM 0x200A
174 #define DRDA_CP_EXCSQLSTT 0x200B
175 #define DRDA_CP_OPNQRY 0x200C
176 #define DRDA_CP_PRPSQLSTT 0x200D
177 #define DRDA_CP_RDBCMM 0x200E
178 #define DRDA_CP_RDBRLLBCK 0x200F
179 #define DRDA_CP_REBIND 0x2010
180 #define DRDA_CP_DSCRDBTBL 0x2012
181 #define DRDA_CP_EXCSQLSET 0x2014
182 #define DRDA_CP_DSCERRCD 0x2101
183 #define DRDA_CP_QRYPRCTYP 0x2102
184 #define DRDA_CP_RDBINTTKN 0x2103
185 #define DRDA_CP_PRDDTA 0x2104
186 #define DRDA_CP_RDBCMTOK 0x2105
187 #define DRDA_CP_RDBCOLID 0x2108
188 #define DRDA_CP_PKGID 0x2109
189 #define DRDA_CP_PKGCNSTKN 0x210D
190 #define DRDA_CP_RTNSETSTT 0x210E
191 #define DRDA_CP_RDBACCCL 0x210F
192 #define DRDA_CP_RDBNAM 0x2110
193 #define DRDA_CP_OUTEXP 0x2111
194 #define DRDA_CP_PKGNAMCT 0x2112
195 #define DRDA_CP_PKGNAMCSN 0x2113
196 #define DRDA_CP_QRYBLKSZ 0x2114
197 #define DRDA_CP_UOWDSP 0x2115
198 #define DRDA_CP_RTNSQLDA 0x2116
199 #define DRDA_CP_RDBALWUPD 0x211A
200 #define DRDA_CP_SQLCSRHLD 0x211F
201 #define DRDA_CP_STTSTRDEL 0x2120
202 #define DRDA_CP_STTDECDEL 0x2121
203 #define DRDA_CP_PKGDFTCST 0x2125
204 #define DRDA_CP_QRYBLKCTL 0x2132
205 #define DRDA_CP_CRRTKN 0x2135
206 #define DRDA_CP_PRCNAM 0x2138
207 #define DRDA_CP_PKGSNLST 0x2139
208 #define DRDA_CP_NBRROW 0x213A
209 #define DRDA_CP_TRGDFTRT 0x213B
210 #define DRDA_CP_QRYRELSCR 0x213C
211 #define DRDA_CP_QRYROWNBR 0x213D
212 #define DRDA_CP_QRYRFRTBL 0x213E
213 #define DRDA_CP_MAXRSLCNT 0x2140
214 #define DRDA_CP_MAXBLKEXT 0x2141
215 #define DRDA_CP_RSLSETFLG 0x2142
216 #define DRDA_CP_TYPSQLDA 0x2146
217 #define DRDA_CP_OUTOVROPT 0x2147
218 #define DRDA_CP_RTNEXTDTA 0x2148
219 #define DRDA_CP_QRYATTSCR 0x2149
220 #define DRDA_CP_QRYATTUPD 0x2150
221 #define DRDA_CP_QRYSCRORN 0x2152
222 #define DRDA_CP_QRYROWSNS 0x2153
223 #define DRDA_CP_QRYBLKRST 0x2154
224 #define DRDA_CP_QRYRTNDTA 0x2155
225 #define DRDA_CP_QRYROWSET 0x2156
226 #define DRDA_CP_QRYATTSNS 0x2157
227 #define DRDA_CP_QRYINSID 0x215B
228 #define DRDA_CP_QRYCLSIMP 0x215D
229 #define DRDA_CP_QRYCLSRLS 0x215E
230 #define DRDA_CP_QRYOPTVAL 0x215F
231 #define DRDA_CP_DIAGLVL 0x2160
232 #define DRDA_CP_ACCRDBRM 0x2201
233 #define DRDA_CP_QRYNOPRM 0x2202
234 #define DRDA_CP_RDBNACRM 0x2204
235 #define DRDA_CP_OPNQRYRM 0x2205
236 #define DRDA_CP_PKGBNARM 0x2206
237 #define DRDA_CP_RDBACCRM 0x2207
238 #define DRDA_CP_BGNBNDRM 0x2208
239 #define DRDA_CP_PKGBPARM 0x2209
240 #define DRDA_CP_DSCINVRM 0x220A
241 #define DRDA_CP_ENDQRYRM 0x220B
242 #define DRDA_CP_ENDUOWRM 0x220C
243 #define DRDA_CP_ABNUOWRM 0x220D
244 #define DRDA_CP_DTAMCHRM 0x220E
245 #define DRDA_CP_QRYPOPRM 0x220F
246 #define DRDA_CP_RDBNFNRM 0x2211
247 #define DRDA_CP_OPNQFLRM 0x2212
248 #define DRDA_CP_SQLERRRM 0x2213
249 #define DRDA_CP_RDBUPDRM 0x2218
250 #define DRDA_CP_RSLSETRM 0x2219
251 #define DRDA_CP_RDBAFLRM 0x221A
252 #define DRDA_CP_CMDVLTRM 0x221D
253 #define DRDA_CP_CMMRQSRM 0x2225
254 #define DRDA_CP_RDBATHRM 0x22CB
255 #define DRDA_CP_SQLAM 0x2407
256 #define DRDA_CP_SQLCARD 0x2408
257 #define DRDA_CP_SQLCINRD 0x240B
258 #define DRDA_CP_SQLRSLRD 0x240E
259 #define DRDA_CP_RDB 0x240F
260 #define DRDA_CP_FRCFIXROW 0x2410
261 #define DRDA_CP_SQLDARD 0x2411
262 #define DRDA_CP_SQLDTA 0x2412
263 #define DRDA_CP_SQLDTARD 0x2413
264 #define DRDA_CP_SQLSTT 0x2414
265 #define DRDA_CP_OUTOVR 0x2415
266 #define DRDA_CP_LMTBLKPRC 0x2417
267 #define DRDA_CP_FIXROWPRC 0x2418
268 #define DRDA_CP_SQLSTTVRB 0x2419
269 #define DRDA_CP_QRYDSC 0x241A
270 #define DRDA_CP_QRYDTA 0x241B
271 #define DRDA_CP_CSTMBCS 0x2435
272 #define DRDA_CP_SRVLST 0x244E
273 #define DRDA_CP_SQLATTR 0x2450
275 #define DRDA_DSSFMT_SAME_CORR 0x01
276 #define DRDA_DSSFMT_CONTINUE 0x02
277 #define DRDA_DSSFMT_CHAINED 0x04
278 #define DRDA_DSSFMT_RESERVED 0x08
280 #define DRDA_DSSFMT_RQSDSS 0x01
281 #define DRDA_DSSFMT_RPYDSS 0x02
282 #define DRDA_DSSFMT_OBJDSS 0x03
283 #define DRDA_DSSFMT_CMNDSS 0x04
284 #define DRDA_DSSFMT_NORPYDSS 0x05
286 #define DRDA_TEXT_DDM "DDM"
287 #define DRDA_TEXT_PARAM "Parameter"
289 static const value_string drda_opcode_vals
[] = {
290 { DRDA_CP_DATA
, "Data" },
291 { DRDA_CP_CODPNT
, "Code Point" },
292 { DRDA_CP_FDODSC
, "FD:OCA Data Descriptor" },
293 { DRDA_CP_TYPDEFNAM
, "Data Type Definition Name" },
294 { DRDA_CP_TYPDEFOVR
, "TYPDEF Overrides" },
295 { DRDA_CP_CODPNTDR
, "Code Point Data Representation" },
296 { DRDA_CP_EXCSAT
, "Exchange Server Attributes" },
297 { DRDA_CP_SYNCCTL
, "Sync Point Control Request" },
298 { DRDA_CP_SYNCRSY
, "Sync Point Resync Command" },
299 { DRDA_CP_ACCSEC
, "Access Security" },
300 { DRDA_CP_SECCHK
, "Security Check" },
301 { DRDA_CP_SYNCLOG
, "Sync Point Log" },
302 { DRDA_CP_RSCTYP
, "Resource Type Information" },
303 { DRDA_CP_RSNCOD
, "Reason Code Information" },
304 { DRDA_CP_RSCNAM
, "Resource Name Information" },
305 { DRDA_CP_PRDID
, "Product-Specific Identifier" },
306 { DRDA_CP_PRCCNVCD
, "Conversation Protocol Error Code" },
307 { DRDA_CP_VRSNAM
, "Version Name" },
308 { DRDA_CP_SRVCLSNM
, "Server Class Name" },
309 { DRDA_CP_SVRCOD
, "Severity Code" },
310 { DRDA_CP_SYNERRCD
, "Syntax Error Code" },
311 { DRDA_CP_SRVDGN
, "Server Diagnostic Information" },
312 { DRDA_CP_SRVRLSLV
, "Server Product Release Level" },
313 { DRDA_CP_SPVNAM
, "Supervisor Name" },
314 { DRDA_CP_EXTNAM
, "External Name" },
315 { DRDA_CP_SRVNAM
, "Server Name" },
316 { DRDA_CP_SECMGRNM
, "Security Manager Name" },
317 { DRDA_CP_DEPERRCD
, "Manager Dependency Error Code" },
318 { DRDA_CP_CCSIDSBC
, "CCSID for Single-Byte Characters" },
319 { DRDA_CP_CCSIDDBC
, "CCSID for Double-byte Characters" },
320 { DRDA_CP_CCSIDMBC
, "CCSID for Mixed-byte Characters" },
321 { DRDA_CP_USRID
, "User ID at the Target System" },
322 { DRDA_CP_PASSWORD
, "Password" },
323 { DRDA_CP_SECMEC
, "Security Mechanism" },
324 { DRDA_CP_SECCHKCD
, "Security Check Code" },
325 { DRDA_CP_SVCERRNO
, "Security Service ErrorNumber" },
326 { DRDA_CP_SECTKN
, "Security Token" },
327 { DRDA_CP_NEWPASSWORD
, "New Password" },
328 { DRDA_CP_MGRLVLRM
, "Manager-Level Conflict" },
329 { DRDA_CP_MGRDEPRM
, "Manager Dependency Error" },
330 { DRDA_CP_SECCHKRM
, "Security Check" },
331 { DRDA_CP_CMDATHRM
, "Not Authorized to Command" },
332 { DRDA_CP_AGNPRMRM
, "Permanent Agent Error" },
333 { DRDA_CP_RSCLMTRM
, "Resource Limits Reached" },
334 { DRDA_CP_PRCCNVRM
, "Conversational Protocol Error" },
335 { DRDA_CP_CMDCMPRM
, "Command Processing Completed" },
336 { DRDA_CP_SYNTAXRM
, "Data Stream Syntax Error" },
337 { DRDA_CP_CMDNSPRM
, "Command Not Supported" },
338 { DRDA_CP_PRMNSPRM
, "Parameter Not Supported" },
339 { DRDA_CP_VALNSPRM
, "Parameter Value Not Supported" },
340 { DRDA_CP_OBJNSPRM
, "Object Not Supported" },
341 { DRDA_CP_CMDCHKRM
, "Command Check" },
342 { DRDA_CP_TRGNSPRM
, "Target Not Supported" },
343 { DRDA_CP_AGENT
, "Agent" },
344 { DRDA_CP_MGRLVLLS
, "Manager-Level List" },
345 { DRDA_CP_SUPERVISOR
, "Supervisor" },
346 { DRDA_CP_SECMGR
, "Security Manager" },
347 { DRDA_CP_EXCSATRD
, "Server Attributes Reply Data" },
348 { DRDA_CP_CMNAPPC
, "LU 6.2 Conversational Communications Manager" },
349 { DRDA_CP_DICTIONARY
, "Dictionary" },
350 { DRDA_CP_MGRLVLN
, "Manager-Level Number Attribute" },
351 { DRDA_CP_CMNTCPIP
, "TCP/IP CommunicationManager" },
352 { DRDA_CP_FDODTA
, "FD:OCA Data" },
354 "SNA LU 6.2 Sync Point Conversational Communications Manager" },
355 { DRDA_CP_ACCSECRD
, "Access Security Reply Data" },
356 { DRDA_CP_SYNCPTMGR
, "Sync Point Manager" },
357 { DRDA_CP_RSYNCMGR
, "ResynchronizationManager" },
358 { DRDA_CP_CCSIDMGR
, "CCSID Manager" },
359 { DRDA_CP_MONITOR
, "Monitor Events" },
360 { DRDA_CP_MONITORRD
, "Monitor Reply Data" },
361 { DRDA_CP_XAMGR
, "XAManager" },
362 { DRDA_CP_ACCRDB
, "Access RDB" },
363 { DRDA_CP_BGNBND
, "Begin Binding a Package to an RDB" },
364 { DRDA_CP_BNDSQLSTT
, "Bind SQL Statement to an RDB Package" },
365 { DRDA_CP_CLSQRY
, "Close Query" },
366 { DRDA_CP_CNTQRY
, "Continue Query" },
367 { DRDA_CP_DRPPKG
, "Drop RDB Package" },
368 { DRDA_CP_DSCSQLSTT
, "Describe SQL Statement" },
369 { DRDA_CP_ENDBND
, "End Binding a Package to an RDB" },
370 { DRDA_CP_EXCSQLIMM
, "Execute Immediate SQL Statement" },
371 { DRDA_CP_EXCSQLSTT
, "Execute SQL Statement" },
372 { DRDA_CP_OPNQRY
, "Open Query" },
373 { DRDA_CP_PRPSQLSTT
, "Prepare SQL Statement" },
374 { DRDA_CP_RDBCMM
, "RDB Commit Unit of Work" },
375 { DRDA_CP_RDBRLLBCK
, "RDB Rollback Unit of Work" },
376 { DRDA_CP_REBIND
, "Rebind an Existing RDB Package" },
377 { DRDA_CP_DSCRDBTBL
, "Describe RDB Table" },
378 { DRDA_CP_EXCSQLSET
, "Set SQL Environment" },
379 { DRDA_CP_DSCERRCD
, "Description Error Code" },
380 { DRDA_CP_QRYPRCTYP
, "Query Protocol Type" },
381 { DRDA_CP_RDBINTTKN
, "RDB Interrupt Token" },
382 { DRDA_CP_PRDDTA
, "Product-Specific Data" },
383 { DRDA_CP_RDBCMTOK
, "RDB Commit Allowed" },
384 { DRDA_CP_RDBCOLID
, "RDB Collection Identifier" },
385 { DRDA_CP_PKGID
, "RDB Package Identifier" },
386 { DRDA_CP_PKGCNSTKN
, "RDB Package Consistency Token" },
387 { DRDA_CP_RTNSETSTT
, "Return SET Statement" },
388 { DRDA_CP_RDBACCCL
, "RDB Access Manager Class" },
389 { DRDA_CP_RDBNAM
, "Relational Database Name" },
390 { DRDA_CP_OUTEXP
, "Output Expected" },
391 { DRDA_CP_PKGNAMCT
, "RDB Package Name and Consistency Token" },
393 "RDB Package Name, Consistency Token, and Section Number" },
394 { DRDA_CP_QRYBLKSZ
, "Query Block Size" },
395 { DRDA_CP_UOWDSP
, "Unit of Work Disposition" },
396 { DRDA_CP_RTNSQLDA
, "Maximum Result Set Count" },
397 { DRDA_CP_RDBALWUPD
, "RDB Allow Updates" },
398 { DRDA_CP_SQLCSRHLD
, "Hold Cursor Position" },
399 { DRDA_CP_STTSTRDEL
, "Statement String Delimiter" },
400 { DRDA_CP_STTDECDEL
, "Statement Decimal Delimiter" },
401 { DRDA_CP_PKGDFTCST
, "Package Default Character Subtype" },
402 { DRDA_CP_QRYBLKCTL
, "Query Block Protocol Control" },
403 { DRDA_CP_CRRTKN
, "Correlation Token" },
404 { DRDA_CP_PRCNAM
, "Procedure Name" },
405 { DRDA_CP_PKGSNLST
, "RDB Result Set Reply Message" },
406 { DRDA_CP_NBRROW
, "Number of Fetch or Insert Rows" },
407 { DRDA_CP_TRGDFTRT
, "Target Default Value Return" },
408 { DRDA_CP_QRYRELSCR
, "Query Relative Scrolling Action" },
409 { DRDA_CP_QRYROWNBR
, "Query Row Number" },
410 { DRDA_CP_QRYRFRTBL
, "Query Refresh Answer Set Table" },
411 { DRDA_CP_MAXRSLCNT
, "Maximum Result Set Count" },
412 { DRDA_CP_MAXBLKEXT
, "Maximum Number of Extra Blocks" },
413 { DRDA_CP_RSLSETFLG
, "Result Set Flags" },
414 { DRDA_CP_TYPSQLDA
, "Type of SQL Descriptor Area" },
415 { DRDA_CP_OUTOVROPT
, "Output Override Option" },
416 { DRDA_CP_RTNEXTDTA
, "Return of EXTDTA Option" },
417 { DRDA_CP_QRYATTSCR
, "Query Attribute for Scrollability" },
418 { DRDA_CP_QRYATTUPD
, "Query Attribute for Updatability" },
419 { DRDA_CP_QRYSCRORN
, "Query Scroll Orientation" },
420 { DRDA_CP_QRYROWSNS
, "Query Row Sensitivity" },
421 { DRDA_CP_QRYBLKRST
, "Query Block Reset" },
422 { DRDA_CP_QRYRTNDTA
, "Query Returns Datat" },
423 { DRDA_CP_QRYROWSET
, "Query Rowset Size" },
424 { DRDA_CP_QRYATTSNS
, "Query Attribute for Sensitivity" },
425 { DRDA_CP_QRYINSID
, "Query Instance Identifier" },
426 { DRDA_CP_QRYCLSIMP
, "Query Close Implicit" },
427 { DRDA_CP_QRYCLSRLS
, "Query Close Lock Release" },
428 { DRDA_CP_QRYOPTVAL
, "QRYOPTVAL" },
429 { DRDA_CP_DIAGLVL
, "SQL Error Diagnostic Level" },
430 { DRDA_CP_ACCRDBRM
, "Access to RDB Completed" },
431 { DRDA_CP_QRYNOPRM
, "Query Not Open" },
432 { DRDA_CP_RDBNACRM
, "RDB Not Accessed" },
433 { DRDA_CP_OPNQRYRM
, "Open Query Complete" },
434 { DRDA_CP_PKGBNARM
, "RDB Package Binding Not Active" },
435 { DRDA_CP_RDBACCRM
, "RDB Currently Accessed" },
436 { DRDA_CP_BGNBNDRM
, "Begin Bind Error" },
437 { DRDA_CP_PKGBPARM
, "RDB Package Binding Process Active" },
438 { DRDA_CP_DSCINVRM
, "Invalid Description" },
439 { DRDA_CP_ENDQRYRM
, "End of Query" },
440 { DRDA_CP_ENDUOWRM
, "End Unit of Work Condition" },
441 { DRDA_CP_ABNUOWRM
, "Abnormal End Unit ofWork Condition" },
442 { DRDA_CP_DTAMCHRM
, "Data Descriptor Mismatch" },
443 { DRDA_CP_QRYPOPRM
, "Query Previously Opened" },
444 { DRDA_CP_RDBNFNRM
, "RDB Not Found" },
445 { DRDA_CP_OPNQFLRM
, "Open Query Failure" },
446 { DRDA_CP_SQLERRRM
, "SQL Error Condition" },
447 { DRDA_CP_RDBUPDRM
, "RDB Update Reply Message" },
448 { DRDA_CP_RSLSETRM
, "RDB Result Set Reply Message" },
449 { DRDA_CP_RDBAFLRM
, "RDB Access Failed Reply Message" },
450 { DRDA_CP_CMDVLTRM
, "Command Violation" },
451 { DRDA_CP_CMMRQSRM
, "Commitment Request" },
452 { DRDA_CP_RDBATHRM
, "Not Authorized to RDB" },
453 { DRDA_CP_SQLAM
, "SQL Application Manager" },
454 { DRDA_CP_SQLCARD
, "SQL Communications Area Reply Data" },
455 { DRDA_CP_SQLCINRD
, "SQL Result Set Column Information Reply Data" },
456 { DRDA_CP_SQLRSLRD
, "SQL Result Set Reply Data" },
457 { DRDA_CP_RDB
, "Relational Database" },
458 { DRDA_CP_FRCFIXROW
, "Force Fixed Row Query Protocol" },
459 { DRDA_CP_SQLDARD
, "SQLDA Reply Data" },
460 { DRDA_CP_SQLDTA
, "SQL Program Variable Data" },
461 { DRDA_CP_SQLDTARD
, "SQL Data Reply Data" },
462 { DRDA_CP_SQLSTT
, "SQL Statement" },
463 { DRDA_CP_OUTOVR
, "Output Override Descriptor" },
464 { DRDA_CP_LMTBLKPRC
, "Limited Block Protocol" },
465 { DRDA_CP_FIXROWPRC
, "Fixed Row Query Protocol" },
466 { DRDA_CP_SQLSTTVRB
, "SQL Statement Variable Descriptions" },
467 { DRDA_CP_QRYDSC
, "Query Answer Set Description" },
468 { DRDA_CP_QRYDTA
, "Query Answer Set Data" },
469 { DRDA_CP_SQLATTR
, "SQL Statement Attributes" },
472 static value_string_ext drda_opcode_vals_ext
= VALUE_STRING_EXT_INIT(drda_opcode_vals
);
474 static const value_string drda_opcode_abbr
[] = {
475 { DRDA_CP_DATA
, "DATA" },
476 { DRDA_CP_CODPNT
, "CODPNT" },
477 { DRDA_CP_FDODSC
, "FDODSC" },
478 { DRDA_CP_TYPDEFNAM
, "TYPDEFNAM" },
479 { DRDA_CP_TYPDEFOVR
, "TYPDEFOVR" },
480 { DRDA_CP_CODPNTDR
, "CODPNTDR" },
481 { DRDA_CP_EXCSAT
, "EXCSAT" },
482 { DRDA_CP_SYNCCTL
, "SYNCCTL" },
483 { DRDA_CP_SYNCRSY
, "SYNCRSY" },
484 { DRDA_CP_ACCSEC
, "ACCSEC" },
485 { DRDA_CP_SECCHK
, "SECCHK" },
486 { DRDA_CP_SYNCLOG
, "SYNCLOG" },
487 { DRDA_CP_RSCTYP
, "RSCTYP" },
488 { DRDA_CP_RSNCOD
, "RSNCOD" },
489 { DRDA_CP_RSCNAM
, "RSCNAM" },
490 { DRDA_CP_PRDID
, "PRDID" },
491 { DRDA_CP_PRCCNVCD
, "PRCCNVCD" },
492 { DRDA_CP_VRSNAM
, "VRSNAM" },
493 { DRDA_CP_SRVCLSNM
, "SRVCLSNM" },
494 { DRDA_CP_SVRCOD
, "SVRCOD" },
495 { DRDA_CP_SYNERRCD
, "SYNERRCD" },
496 { DRDA_CP_SRVDGN
, "SRVDGN" },
497 { DRDA_CP_SRVRLSLV
, "SRVRLSLV" },
498 { DRDA_CP_SPVNAM
, "SPVNAM" },
499 { DRDA_CP_EXTNAM
, "EXTNAM" },
500 { DRDA_CP_SRVNAM
, "SRVNAM" },
501 { DRDA_CP_SECMGRNM
, "SECMGRNM" },
502 { DRDA_CP_DEPERRCD
, "DEPERRCD" },
503 { DRDA_CP_CCSIDSBC
, "CCSIDSBC" },
504 { DRDA_CP_CCSIDDBC
, "CCSIDDBC" },
505 { DRDA_CP_CCSIDMBC
, "CCSIDMBC" },
506 { DRDA_CP_USRID
, "USRID" },
507 { DRDA_CP_PASSWORD
, "PASSWORD" },
508 { DRDA_CP_SECMEC
, "SECMEC" },
509 { DRDA_CP_SECCHKCD
, "SECCHKCD" },
510 { DRDA_CP_SVCERRNO
, "SVCERRNO" },
511 { DRDA_CP_SECTKN
, "SECTKN" },
512 { DRDA_CP_NEWPASSWORD
, "NEWPASSWORD" },
513 { DRDA_CP_MGRLVLRM
, "MGRLVLRM" },
514 { DRDA_CP_MGRDEPRM
, "MGRDEPRM" },
515 { DRDA_CP_SECCHKRM
, "SECCHKRM" },
516 { DRDA_CP_CMDATHRM
, "CMDATHRM" },
517 { DRDA_CP_AGNPRMRM
, "AGNPRMRM" },
518 { DRDA_CP_RSCLMTRM
, "RSCLMTRM" },
519 { DRDA_CP_PRCCNVRM
, "PRCCNVRM" },
520 { DRDA_CP_CMDCMPRM
, "CMDCMPRM" },
521 { DRDA_CP_SYNTAXRM
, "SYNTAXRM" },
522 { DRDA_CP_CMDNSPRM
, "CMDNSPRM" },
523 { DRDA_CP_PRMNSPRM
, "PRMNSPRM" },
524 { DRDA_CP_VALNSPRM
, "VALNSPRM" },
525 { DRDA_CP_OBJNSPRM
, "OBJNSPRM" },
526 { DRDA_CP_CMDCHKRM
, "CMDCHKRM" },
527 { DRDA_CP_TRGNSPRM
, "TRGNSPRM" },
528 { DRDA_CP_AGENT
, "AGENT" },
529 { DRDA_CP_MGRLVLLS
, "MGRLVLLS" },
530 { DRDA_CP_SUPERVISOR
, "SUPERVISOR" },
531 { DRDA_CP_SECMGR
, "SECMGR" },
532 { DRDA_CP_EXCSATRD
, "EXCSATRD" },
533 { DRDA_CP_CMNAPPC
, "CMNAPPC" },
534 { DRDA_CP_DICTIONARY
, "DICTIONARY" },
535 { DRDA_CP_MGRLVLN
, "MGRLVLN" },
536 { DRDA_CP_CMNTCPIP
, "CMNTCPIP" },
537 { DRDA_CP_FDODTA
, "FDODTA" },
538 { DRDA_CP_CMNSYNCPT
, "CMNSYNCPT" },
539 { DRDA_CP_ACCSECRD
, "ACCSECRD" },
540 { DRDA_CP_SYNCPTMGR
, "SYNCPTMGR" },
541 { DRDA_CP_RSYNCMGR
, "RSYNCMGR" },
542 { DRDA_CP_CCSIDMGR
, "CCSIDMGR" },
543 { DRDA_CP_MONITOR
, "MONITOR" },
544 { DRDA_CP_MONITORRD
, "MONITORRD" },
545 { DRDA_CP_XAMGR
, "XAMGR" },
546 { DRDA_CP_ACCRDB
, "ACCRDB" },
547 { DRDA_CP_BGNBND
, "BGNBND" },
548 { DRDA_CP_BNDSQLSTT
, "BNDSQLSTT" },
549 { DRDA_CP_CLSQRY
, "CLSQRY" },
550 { DRDA_CP_CNTQRY
, "CNTQRY" },
551 { DRDA_CP_DRPPKG
, "DRPPKG" },
552 { DRDA_CP_DSCSQLSTT
, "DSCSQLSTT" },
553 { DRDA_CP_ENDBND
, "ENDBND" },
554 { DRDA_CP_EXCSQLIMM
, "EXCSQLIMM" },
555 { DRDA_CP_EXCSQLSTT
, "EXCSQLSTT" },
556 { DRDA_CP_OPNQRY
, "OPNQRY" },
557 { DRDA_CP_PRPSQLSTT
, "PRPSQLSTT" },
558 { DRDA_CP_RDBCMM
, "RDBCMM" },
559 { DRDA_CP_RDBRLLBCK
, "RDBRLLBCK" },
560 { DRDA_CP_REBIND
, "REBIND" },
561 { DRDA_CP_DSCRDBTBL
, "DSCRDBTBL" },
562 { DRDA_CP_EXCSQLSET
, "EXCSQLSET" },
563 { DRDA_CP_DSCERRCD
, "DSCERRCD" },
564 { DRDA_CP_QRYPRCTYP
, "QRYPRCTYP" },
565 { DRDA_CP_RDBINTTKN
, "RDBINTTKN" },
566 { DRDA_CP_PRDDTA
, "PRDDTA" },
567 { DRDA_CP_RDBCMTOK
, "RDBCMTOK" },
568 { DRDA_CP_RDBCOLID
, "RDBCOLID" },
569 { DRDA_CP_PKGID
, "PKGID" },
570 { DRDA_CP_PKGCNSTKN
, "PKGCNSTKN" },
571 { DRDA_CP_RTNSETSTT
, "RTNSETSTT" },
572 { DRDA_CP_RDBACCCL
, "RDBACCCL" },
573 { DRDA_CP_RDBNAM
, "RDBNAM" },
574 { DRDA_CP_OUTEXP
, "OUTEXP" },
575 { DRDA_CP_PKGNAMCT
, "PKGNAMCT" },
576 { DRDA_CP_PKGNAMCSN
, "PKGNAMCSN" },
577 { DRDA_CP_QRYBLKSZ
, "QRYBLKSZ" },
578 { DRDA_CP_UOWDSP
, "UOWDSP" },
579 { DRDA_CP_RTNSQLDA
, "RTNSQLDA" },
580 { DRDA_CP_RDBALWUPD
, "RDBALWUPD" },
581 { DRDA_CP_SQLCSRHLD
, "SQLCSRHLD" },
582 { DRDA_CP_STTSTRDEL
, "STTSTRDEL" },
583 { DRDA_CP_STTDECDEL
, "STTDECDEL" },
584 { DRDA_CP_PKGDFTCST
, "PKGDFTCST" },
585 { DRDA_CP_QRYBLKCTL
, "QRYBLKCTL" },
586 { DRDA_CP_CRRTKN
, "CRRTKN" },
587 { DRDA_CP_PRCNAM
, "PRCNAM" },
588 { DRDA_CP_PKGSNLST
, "PKGSNLST" },
589 { DRDA_CP_NBRROW
, "NBRROW" },
590 { DRDA_CP_TRGDFTRT
, "TRGDFTRT" },
591 { DRDA_CP_QRYRELSCR
, "QRYRELSCR" },
592 { DRDA_CP_QRYROWNBR
, "QRYROWNBR" },
593 { DRDA_CP_QRYRFRTBL
, "QRYRFRTBL" },
594 { DRDA_CP_MAXRSLCNT
, "MAXRSLCNT" },
595 { DRDA_CP_MAXBLKEXT
, "MAXBLKEXT" },
596 { DRDA_CP_RSLSETFLG
, "RSLSETFLG" },
597 { DRDA_CP_TYPSQLDA
, "TYPSQLDA" },
598 { DRDA_CP_OUTOVROPT
, "OUTOVROPT" },
599 { DRDA_CP_RTNEXTDTA
, "RTNEXTDTA" },
600 { DRDA_CP_QRYATTSCR
, "QRYATTSCR" },
601 { DRDA_CP_QRYATTUPD
, "QRYATTUPD" },
602 { DRDA_CP_QRYSCRORN
, "QRYSCRORN" },
603 { DRDA_CP_QRYROWSNS
, "QRYROWSNS" },
604 { DRDA_CP_QRYBLKRST
, "QRYBLKRST" },
605 { DRDA_CP_QRYRTNDTA
, "QRYRTNDTA" },
606 { DRDA_CP_QRYROWSET
, "QRYROWSET" },
607 { DRDA_CP_QRYATTSNS
, "QRYATTSNS" },
608 { DRDA_CP_QRYINSID
, "QRYINSID" },
609 { DRDA_CP_QRYCLSIMP
, "QRYCLSIMP" },
610 { DRDA_CP_QRYCLSRLS
, "QRYCLSRLS" },
611 { DRDA_CP_QRYOPTVAL
, "QRYOPTVAL" },
612 { DRDA_CP_DIAGLVL
, "DIAGLVL" },
613 { DRDA_CP_ACCRDBRM
, "ACCRDBRM" },
614 { DRDA_CP_QRYNOPRM
, "QRYNOPRM" },
615 { DRDA_CP_RDBNACRM
, "RDBNACRM" },
616 { DRDA_CP_OPNQRYRM
, "OPNQRYRM" },
617 { DRDA_CP_PKGBNARM
, "PKGBNARM" },
618 { DRDA_CP_RDBACCRM
, "RDBACCRM" },
619 { DRDA_CP_BGNBNDRM
, "BGNBNDRM" },
620 { DRDA_CP_PKGBPARM
, "PKGBPARM" },
621 { DRDA_CP_DSCINVRM
, "DSCINVRM" },
622 { DRDA_CP_ENDQRYRM
, "ENDQRYRM" },
623 { DRDA_CP_ENDUOWRM
, "ENDUOWRM" },
624 { DRDA_CP_ABNUOWRM
, "ABNUOWRM" },
625 { DRDA_CP_DTAMCHRM
, "DTAMCHRM" },
626 { DRDA_CP_QRYPOPRM
, "QRYPOPRM" },
627 { DRDA_CP_RDBNFNRM
, "RDBNFNRM" },
628 { DRDA_CP_OPNQFLRM
, "OPNQFLRM" },
629 { DRDA_CP_SQLERRRM
, "SQLERRRM" },
630 { DRDA_CP_RDBUPDRM
, "RDBUPDRM" },
631 { DRDA_CP_RSLSETRM
, "RSLSETRM" },
632 { DRDA_CP_RDBAFLRM
, "RDBAFLRM" },
633 { DRDA_CP_CMDVLTRM
, "CMDVLTRM" },
634 { DRDA_CP_CMMRQSRM
, "CMMRQSRM" },
635 { DRDA_CP_RDBATHRM
, "RDBATHRM" },
636 { DRDA_CP_SQLAM
, "SQLAM" },
637 { DRDA_CP_SQLCARD
, "SQLCARD" },
638 { DRDA_CP_SQLCINRD
, "SQLCINRD" },
639 { DRDA_CP_SQLRSLRD
, "SQLRSLRD" },
640 { DRDA_CP_RDB
, "RDB" },
641 { DRDA_CP_FRCFIXROW
, "FRCFIXROW" },
642 { DRDA_CP_SQLDARD
, "SQLDARD" },
643 { DRDA_CP_SQLDTA
, "SQLDTA" },
644 { DRDA_CP_SQLDTARD
, "SQLDTARD" },
645 { DRDA_CP_SQLSTT
, "SQLSTT" },
646 { DRDA_CP_OUTOVR
, "OUTOVR" },
647 { DRDA_CP_LMTBLKPRC
, "LMTBLKPRC" },
648 { DRDA_CP_FIXROWPRC
, "FIXROWPRC" },
649 { DRDA_CP_SQLSTTVRB
, "SQLSTTVRB" },
650 { DRDA_CP_QRYDSC
, "QRYDSC" },
651 { DRDA_CP_QRYDTA
, "QRYDTA" },
652 { DRDA_CP_SQLATTR
, "SQLATTR" },
655 static value_string_ext drda_opcode_abbr_ext
= VALUE_STRING_EXT_INIT(drda_opcode_abbr
);
657 static const value_string drda_dsstyp_abbr
[] = {
658 { DRDA_DSSFMT_RQSDSS
, "RQSDSS" },
659 { DRDA_DSSFMT_RPYDSS
, "RPYDSS" },
660 { DRDA_DSSFMT_OBJDSS
, "OBJDSS" },
661 { DRDA_DSSFMT_CMNDSS
, "CMNDSS" },
662 { DRDA_DSSFMT_NORPYDSS
, "NORPYDSS" },
666 static guint iPreviousFrameNumber
= 0;
671 iPreviousFrameNumber
= 0;
675 dissect_drda(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
681 guint16 iCommandEnd
= 0;
687 guint16 iParameterCP
;
690 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "DRDA");
691 /* This is a trick to know whether this is the first PDU in this packet or not */
692 if (iPreviousFrameNumber
!= pinfo
->fd
->num
)
693 col_clear(pinfo
->cinfo
, COL_INFO
);
695 col_append_str(pinfo
->cinfo
, COL_INFO
, " | ");
697 iPreviousFrameNumber
= pinfo
->fd
->num
;
698 /* There may be multiple DRDA commands in one frame */
699 while ((guint
) (offset
+ 10) <= tvb_length(tvb
))
701 iCommand
= tvb_get_ntohs(tvb
, offset
+ 8);
702 iLength
= tvb_get_ntohs(tvb
, offset
+ 0);
704 expert_add_info_format(pinfo
, NULL
, &ei_drda_opcode_invalid_length
, "Invalid length detected (%u): should be at least 10 bytes long", iLength
);
707 /* iCommandEnd is the length of the packet up to the end of the current command */
708 iCommandEnd
+= iLength
;
711 col_append_str(pinfo
->cinfo
, COL_INFO
, " | ");
712 col_append_str(pinfo
->cinfo
, COL_INFO
, val_to_str_ext(iCommand
, &drda_opcode_abbr_ext
, "Unknown (0x%02x)"));
716 proto_tree
*drda_tree
;
717 proto_tree
*drdaroot_tree
;
718 proto_tree
*drda_tree_sub
;
721 ti
= proto_tree_add_item(tree
, proto_drda
, tvb
, offset
, -1, ENC_NA
);
722 proto_item_append_text(ti
, " (%s)", val_to_str_ext(iCommand
, &drda_opcode_vals_ext
, "Unknown (0x%02x)"));
723 drdaroot_tree
= proto_item_add_subtree(ti
, ett_drda
);
725 ti
= proto_tree_add_text(drdaroot_tree
, tvb
, offset
, 10, DRDA_TEXT_DDM
);
726 proto_item_append_text(ti
, " (%s)", val_to_str_ext(iCommand
, &drda_opcode_abbr_ext
, "Unknown (0x%02x)"));
727 drda_tree
= proto_item_add_subtree(ti
, ett_drda_ddm
);
729 proto_tree_add_item(drda_tree
, hf_drda_ddm_length
, tvb
, offset
+ 0, 2, ENC_BIG_ENDIAN
);
730 proto_tree_add_item(drda_tree
, hf_drda_ddm_magic
, tvb
, offset
+ 2, 1, ENC_BIG_ENDIAN
);
732 iFormatFlags
= tvb_get_guint8(tvb
, offset
+ 3);
733 iDSSType
= iFormatFlags
& 0x0F;
734 iDSSFlags
= iFormatFlags
>> 4;
736 ti
= proto_tree_add_item(drda_tree
, hf_drda_ddm_format
, tvb
, offset
+ 3, 1, ENC_BIG_ENDIAN
);
737 drda_tree_sub
= proto_item_add_subtree(ti
, ett_drda_ddm_format
);
739 proto_tree_add_boolean(drda_tree_sub
, hf_drda_ddm_fmt_reserved
, tvb
, offset
+ 3, 1, iDSSFlags
);
740 proto_tree_add_boolean(drda_tree_sub
, hf_drda_ddm_fmt_chained
, tvb
, offset
+ 3, 1, iDSSFlags
);
741 proto_tree_add_boolean(drda_tree_sub
, hf_drda_ddm_fmt_errcont
, tvb
, offset
+ 3, 1, iDSSFlags
);
742 proto_tree_add_boolean(drda_tree_sub
, hf_drda_ddm_fmt_samecorr
, tvb
, offset
+ 3, 1, iDSSFlags
);
743 proto_tree_add_uint(drda_tree_sub
, hf_drda_ddm_fmt_dsstyp
, tvb
, offset
+ 3, 1, iDSSType
);
745 proto_tree_add_item(drda_tree
, hf_drda_ddm_rc
, tvb
, offset
+ 4, 2, ENC_BIG_ENDIAN
);
746 proto_tree_add_item(drda_tree
, hf_drda_ddm_length2
, tvb
, offset
+ 6, 2, ENC_BIG_ENDIAN
);
747 proto_tree_add_item(drda_tree
, hf_drda_ddm_codepoint
, tvb
, offset
+ 8, 2, ENC_BIG_ENDIAN
);
749 /* The number of attributes is variable */
750 for (offset
+= 10; offset
< iCommandEnd
; )
752 if (tvb_length_remaining(tvb
, offset
) >= 2)
754 iLengthParam
= tvb_get_ntohs(tvb
, offset
+ 0);
755 if (iLengthParam
== 0 || iLengthParam
== 1) iLengthParam
= iLength
- 10;
756 if (tvb_length_remaining(tvb
, offset
) >= iLengthParam
)
758 iParameterCP
= tvb_get_ntohs(tvb
, offset
+ 2);
759 ti
= proto_tree_add_text(drdaroot_tree
, tvb
, offset
, iLengthParam
,
761 proto_item_append_text(ti
, " (%s)", val_to_str_ext(iParameterCP
, &drda_opcode_vals_ext
, "Unknown (0x%02x)"));
762 drda_tree_sub
= proto_item_add_subtree(ti
, ett_drda_param
);
763 proto_tree_add_item(drda_tree_sub
, hf_drda_param_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
764 proto_tree_add_item(drda_tree_sub
, hf_drda_param_codepoint
, tvb
, offset
+ 2, 2, ENC_BIG_ENDIAN
);
765 proto_tree_add_item(drda_tree_sub
, hf_drda_param_data
, tvb
, offset
+ 4, iLengthParam
- 4, ENC_UTF_8
|ENC_NA
);
766 proto_tree_add_item(drda_tree_sub
, hf_drda_param_data_ebcdic
, tvb
, offset
+ 4, iLengthParam
- 4, ENC_EBCDIC
|ENC_NA
);
767 if (iCommand
== DRDA_CP_SQLSTT
)
769 /* Extract SQL statement from packet */
770 tvbuff_t
* next_tvb
= NULL
;
771 next_tvb
= tvb_new_subset(tvb
, offset
+ 4, iLengthParam
- 4, iLengthParam
- 4);
772 add_new_data_source(pinfo
, next_tvb
, "SQL statement");
773 proto_tree_add_item(drdaroot_tree
, hf_drda_sqlstatement
, next_tvb
, 0, iLengthParam
- 5, ENC_UTF_8
|ENC_NA
);
774 proto_tree_add_item(drdaroot_tree
, hf_drda_sqlstatement_ebcdic
, next_tvb
, 0, iLengthParam
- 4, ENC_EBCDIC
|ENC_NA
);
777 offset
+= iLengthParam
;
787 /* No tree, advance directly to next command */
792 return tvb_length(tvb
);
796 get_drda_pdu_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
, int offset
)
798 if (tvb_length_remaining(tvb
, offset
) >= 10)
800 return (tvb_get_ntohs(tvb
, offset
));
806 dissect_drda_tcp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data
)
808 tcp_dissect_pdus(tvb
, pinfo
, tree
, drda_desegment
, 10, get_drda_pdu_len
, dissect_drda
, data
);
809 return tvb_length(tvb
);
814 dissect_drda_heur(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
816 conversation_t
* conversation
;
817 if (tvb_length(tvb
) >= 10)
819 /* The first header is 6 bytes long, so the length in the second header should 6 bytes less */
820 guint16 cOuterLength
, cInnerLength
;
821 cOuterLength
= tvb_get_ntohs(tvb
, 0);
822 cInnerLength
= tvb_get_ntohs(tvb
, 6);
823 if ((tvb_get_guint8(tvb
, 2) == DRDA_MAGIC
) && ((cOuterLength
- cInnerLength
) == 6))
825 /* Register this dissector for this conversation */
826 conversation
= find_or_create_conversation(pinfo
);
827 conversation_set_dissector(conversation
, drda_tcp_handle
);
829 /* Dissect the packet */
830 dissect_drda(tvb
, pinfo
, tree
, data
);
838 proto_register_drda(void)
840 static hf_register_info hf
[] = {
841 { &hf_drda_ddm_length
,
842 { "Length", "drda.ddm.length",
843 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
844 "DDM length", HFILL
}},
846 { &hf_drda_ddm_magic
,
847 { "Magic", "drda.ddm.ddmid",
848 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
849 "DDM magic", HFILL
}},
851 { &hf_drda_ddm_format
,
852 { "Format", "drda.ddm.format",
853 FT_UINT8
, BASE_HEX
, NULL
, 0x0,
854 "DDM format", HFILL
}},
856 { &hf_drda_ddm_fmt_reserved
,
857 { "Reserved", "drda.ddm.fmt.bit0",
858 FT_BOOLEAN
, 4, TFS(&tfs_set_notset
), DRDA_DSSFMT_RESERVED
,
859 "DSSFMT reserved", HFILL
}},
861 { &hf_drda_ddm_fmt_chained
,
862 { "Chained", "drda.ddm.fmt.bit1",
863 FT_BOOLEAN
, 4, TFS(&tfs_set_notset
), DRDA_DSSFMT_CHAINED
,
864 "DSSFMT chained", HFILL
}},
866 { &hf_drda_ddm_fmt_errcont
,
867 { "Continue", "drda.ddm.fmt.bit2",
868 FT_BOOLEAN
, 4, TFS(&tfs_set_notset
), DRDA_DSSFMT_CONTINUE
,
869 "DSSFMT continue on error", HFILL
}},
871 { &hf_drda_ddm_fmt_samecorr
,
872 { "Same correlation", "drda.ddm.fmt.bit3",
873 FT_BOOLEAN
, 4, TFS(&tfs_set_notset
), DRDA_DSSFMT_SAME_CORR
,
874 "DSSFMT same correlation", HFILL
}},
876 { &hf_drda_ddm_fmt_dsstyp
,
877 { "DSS type", "drda.ddm.fmt.dsstyp",
878 FT_UINT8
, BASE_DEC
, VALS(drda_dsstyp_abbr
), 0x0,
879 "DSSFMT type", HFILL
}},
882 { "CorrelId", "drda.ddm.rqscrr",
883 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
884 "DDM correlation identifier", HFILL
}},
886 { &hf_drda_ddm_length2
,
887 { "Length2", "drda.ddm.length2",
888 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
889 "DDM length2", HFILL
}},
891 { &hf_drda_ddm_codepoint
,
892 { "Code point", "drda.ddm.codepoint",
893 FT_UINT16
, BASE_HEX
|BASE_EXT_STRING
, &drda_opcode_abbr_ext
, 0x0,
894 "DDM code point", HFILL
}},
896 { &hf_drda_param_length
,
897 { "Length", "drda.param.length",
898 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
899 "Param length", HFILL
}},
901 { &hf_drda_param_codepoint
,
902 { "Code point", "drda.param.codepoint",
903 FT_UINT16
, BASE_HEX
|BASE_EXT_STRING
, &drda_opcode_abbr_ext
, 0x0,
904 "Param code point", HFILL
}},
906 { &hf_drda_param_data
,
907 { "Data (ASCII)", "drda.param.data",
908 FT_STRING
, BASE_NONE
, NULL
, 0x0,
909 "Param data left as ASCII for display", HFILL
}},
911 { &hf_drda_param_data_ebcdic
,
912 { "Data (EBCDIC)", "drda.param.data.ebcdic",
913 FT_STRING
, BASE_NONE
, NULL
, 0x0,
914 "Param data converted from EBCDIC to ASCII for display", HFILL
}},
916 { &hf_drda_sqlstatement
,
917 { "SQL statement (ASCII)", "drda.sqlstatement",
918 FT_STRING
, BASE_NONE
, NULL
, 0x0,
919 "SQL statement left as ASCII for display", HFILL
}},
921 { &hf_drda_sqlstatement_ebcdic
,
922 { "SQL statement (EBCDIC)", "drda.sqlstatement.ebcdic",
923 FT_STRING
, BASE_NONE
, NULL
, 0x0,
924 "SQL statement converted from EBCDIC to ASCII for display", HFILL
}}
927 static gint
*ett
[] = {
930 &ett_drda_ddm_format
,
934 static ei_register_info ei
[] = {
935 { &ei_drda_opcode_invalid_length
, { "drda.opcode.invalid_length", PI_MALFORMED
, PI_ERROR
, "Invalid length detected", EXPFILL
}},
938 module_t
*drda_module
;
939 expert_module_t
* expert_drda
;
941 proto_drda
= proto_register_protocol("DRDA", "DRDA", "drda");
942 proto_register_field_array(proto_drda
, hf
, array_length(hf
));
943 proto_register_subtree_array(ett
, array_length(ett
));
944 expert_drda
= expert_register_protocol(proto_drda
);
945 expert_register_field_array(expert_drda
, ei
, array_length(ei
));
947 drda_module
= prefs_register_protocol(proto_drda
, NULL
);
948 prefs_register_bool_preference(drda_module
, "desegment",
949 "Reassemble DRDA messages spanning multiple TCP segments",
950 "Whether the DRDA dissector should reassemble messages spanning"
951 " multiple TCP segments."
952 " To use this option, you must also enable"
953 " \"Allow subdissectors to reassemble TCP streams\""
954 " in the TCP protocol settings.",
956 register_init_routine(&drda_init
);
960 proto_reg_handoff_drda(void)
962 heur_dissector_add("tcp", dissect_drda_heur
, proto_drda
);
963 drda_tcp_handle
= new_create_dissector_handle(dissect_drda_tcp
, proto_drda
);