2 * Routines for SQL ORcle packet dissection
4 * The initial Wireshark version of this file was imported from the
5 * ClearSight source code package.
6 * No author/copyright given in the original file.
10 * Wireshark - Network traffic analyzer
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #define TCP_PORT_TNS 1522 /* XXX 1521 collides with packet-tns.c */
34 #include <epan/packet.h>
35 #include "packet-sqloracle.h"
37 #define SWAP_UI16(ui16) (((ui16)>>8 & 0xff) | ((ui16)<<8 & 0xff00))
40 #define OPTION_CANCEL 0x80
41 #define OPTION_FETCH 0x40
42 #define OPTION_EXCUTE 0x20
43 #define OPTION_DEFINE 0x10
44 #define OPTION_BIND 0x08
45 #define OPTION_DESC_BIND 0x04
46 #define OPTION_PARSE 0x02
49 #define OPTION_PLSQL 0x80
50 #define OPTION_PARSE2 0x40
51 #define OPTION_VECTOR 0x04
52 #define OPTION_FETCH2 0x02
53 #define OPTION_COMMIT 0x01
58 static gint proto_sqloracle = -1;
59 static gint ett_sqloracle = -1;
60 static gint ett_sqloracle_operation = -1;
62 static int hf_sqloracle_operation = -1;
63 static int hf_sqloracle_func_type = -1;
64 /* static int hf_sqloracle_stmt_length = -1; */
65 static int hf_sqloracle_stmt = -1;
66 /* static int hf_sqloracle_v8ttluds_tname = -1;
67 static int hf_sqloracle_v8ttluds_sname = -1;
68 static int hf_sqloracle_v8ttluds_columnname = -1;
69 static int hf_sqloracle_v8ttluds_scrlength = -1;
70 static int hf_sqloracle_v8ttluds_nullallow = -1;
71 static int hf_sqloracle_v8ttluds_header= -1;
72 static int hf_sqloracle_v8ttloac_formuse = -1;
73 static int hf_sqloracle_v8ttloac_ncs = -1;
74 static int hf_sqloracle_v8ttloac_oid = -1;
75 static int hf_sqloracle_v8ttloac_header =-1;
76 static int hf_sqloracle_ttloac_flag2 = -1;
77 static int hf_sqloracle_ttloac_mal = -1;
78 static int hf_sqloracle_ttloac_varcharlen = -1;
79 static int hf_sqloracle_ttloac_dummy = -1;
80 static int hf_sqloracle_ttloac_scalesize = -1;
81 static int hf_sqloracle_ttloac_prefix = -1;
82 static int hf_sqloracle_ttloac_flag1 = -1;
83 static int hf_sqloracle_ttloac_type = -1;
84 static int hf_sqloracle_ttloac_header = -1;
86 static int hf_sqloracle_flag = -1;
87 static int hf_sqloracle_num_column = -1;
88 /* static int hf_sqloracle_v8ttloac_vsn = -1; */
89 static int hf_sqloracle_itemNum = -1;
90 static int hf_sqloracle_numItersThisTime = -1;
91 static int hf_sqloracle_uacBufLength = -1;
93 static char m_pCurQuery[2025];
95 static int m_numOfUpdate =0;
96 /* static int m_tnsErrors = 0; */
97 static int m_numOfSelect = 0;
98 static int m_numOfInsert = 0;
99 static int m_numOfDelete = 0;
100 static int m_numOfRollback = 0;
101 static int m_numOfSet = 0;
102 static int m_numOfStart = 0;
103 static int m_numOfCommit = 0;
104 static int m_numOfOtherStatement = 0;
105 static int m_numOfTransaction = 0;
106 /* static int m_bReAssembling = 0; */
107 /* SQLORACLE flags */
108 /*static const true_false_string flags_set_truth =
113 static const value_string sqloracle_operation_type[] = {
114 {NET8_TYPE_SETPROP, "Set protocol" },
115 {NET8_TYPE_SETDATAREP, "Set data representations" },
116 {NET8_TYPE_USERTOSERVER, "User request" },
117 {NET8_TYPE_ERRORSTATUS, "Error: No data found" },
118 {NET8_TYPE_AUAS, "Access user address space" },
119 {NET8_TYPE_ROWTRANSFER, "Row transfer header" },
120 {NET8_TYPE_ROWDATA, "Row transfer data follows" },
121 {NET8_TYPE_OPIPARAM, "Return OPI parameter" },
122 {NET8_TYPE_FUNCCOMPLETE, "Oracle function complete"},
123 {NET8_TYPE_TTINOER, "N Error return definitions follow"},
124 {NET8_TYPE_TTIIOV, "Sending I/O Vec only for fast UPI"},
125 {NET8_TYPE_TTISLG, "Send long for fast UPI"},
126 {NET8_TYPE_TTIICA, "Invoke user callback"},
127 {NET8_TYPE_TTILOBD, "LOB/FILE data follows"},
128 {NET8_TYPE_TTIWRN, "Warning messages - may be a set of them"},
129 {NET8_TYPE_DESCINFO, "Describe information"},
130 {NET8_TYPE_PIGGYBACKFUNC, "Piggyback function follows"},
131 {NET8_TYPE_TTI3GL, "signals special action for untrusted callout support"},
132 {NET8_TYPE_TTIFOB, "Flush Out Bind data in DML/w RETURN when error"},
133 {NET8_TYPE_SECURENEG, "Secure Network Services Negotiation"},
137 static const value_string sql_func_type[] = {
138 {NET8_USER_FUNC_OLOGON, " Logon to Oracle"},
139 {NET8_USER_FUNC_OPENCURSOR, "Open cursor" },
140 {NET8_USER_FUNC_PARSE, "Parse statement" },
141 {NET8_USER_FUNC_EXECUTE, "Execute statement" },
142 {NET8_USER_FUNC_OFETCH, " Fetch row" },
143 {NET8_USER_FUNC_CLOSECURSOR, "Close cursor" },
144 {NET8_USER_FUNC_OLOGOFF, "Logoff" },
145 {NET8_USER_FUNC_ODSCRIBE, "Describe select list column" },
146 {NET8_USER_FUNC_ODEFIN, "Define where column goes" },
147 {NET8_USER_FUNC_OCOMON, "Autocommit On" },
148 {NET8_USER_FUNC_OCOMOFF, "Autocommit Off" },
149 {NET8_USER_FUNC_OCOMMIT, "Commit" },
150 {NET8_USER_FUNC_OROLLBACK, "Rollback" },
151 {NET8_USER_FUNC_OSFE, "Set fatal error options" },
152 {NET8_USER_FUNC_ORESUME, "Resume current operation" },
153 {NET8_USER_FUNC_OVERSN, "Get version-date string" },
154 {NET8_USER_FUNC_OTEMP, "(Obsolete)" },
155 {NET8_USER_FUNC_CANCEL, "Cancel Operation" },
156 {NET8_USER_FUNC_OGEM, "Get error message" },
157 {NET8_USER_FUNC_OSPECIAL, "Special function" },
158 {NET8_USER_FUNC_OABORT, "Abort" },
159 {NET8_USER_FUNC_ODQRID, "Dequeue by rowid" },
160 {NET8_USER_FUNC_OLNGF6, "Fetch long value" },
161 {NET8_USER_FUNC_OHOWMANY, "How Many Items?" },
162 {NET8_USER_FUNC_OINIT, "Initialize Database" },
163 {NET8_USER_FUNC_OCHANGEU, "Change user_id" },
164 {NET8_USER_FUNC_OBINDRP, "Bind by reference positional" },
165 {NET8_USER_FUNC_OGETBV, "Get n'th Bind Variable" },
166 {NET8_USER_FUNC_OGETIV, "Get n'th Into Variable" },
167 {NET8_USER_FUNC_OBINDRV, "Bind by reference" },
168 {NET8_USER_FUNC_OBINDRN, "Bind by reference numeric" },
169 {NET8_USER_FUNC_OPARSEX, "Parse And Execute" },
170 {NET8_USER_FUNC_OPARSYN, "Parse for Syntax only" },
171 {NET8_USER_FUNC_OPARSDI, "Parse for Syntax & SQL Dictionary lookup" },
172 {NET8_USER_FUNC_OCONTINUE, "Continue serving after eof" },
173 {NET8_USER_FUNC_ODSCRARR, "Describe Columns" },
174 {NET8_USER_FUNC_OLCCINI, "Init sys pars command table" },
175 {NET8_USER_FUNC_OLCCFIN, "Finalize sys pars command table" },
176 {NET8_USER_FUNC_OLCCPUT, "Put sys par in command table" },
177 {NET8_USER_FUNC_OV6STRT, "Start Oracle (V6)" },
178 {NET8_USER_FUNC_OV6STOP, "Poll for shut down Oracle (V6)" },
179 {NET8_USER_FUNC_ORIP, "Run independent process (V6)" },
180 {NET8_USER_FUNC_OARCHIVE, "Archive op (V6)" },
181 {NET8_USER_FUNC_OMRSTART, "Media recovery - start (V6)" },
182 {NET8_USER_FUNC_OMRRECTS, "Media recovery - record tablespace to recover (V6)"},
183 {NET8_USER_FUNC_OMRGSLSQ, "Media recovery - get starting log seq # (V6)" },
184 {NET8_USER_FUNC_OMRREC, "Media recovery - recover using offline log (V6)" },
185 {NET8_USER_FUNC_OMRCAN, "Media recovery - cancel media recovery (V6)" },
186 {NET8_USER_FUNC_O2LOGON, "Logon to ORACLE" },
187 {NET8_USER_FUNC_OVERSION, "Get Version/Date String" },
188 {NET8_USER_FUNC_OINIT2, "New init call (supersedes OINIT)" },
189 {NET8_USER_FUNC_OCLOALL, "Reserved for MAC; close all cursors" },
190 {NET8_USER_FUNC_OALL, "Bundled execution call" },
191 {NET8_USER_FUNC_OTEX, "Transaction execute call (OS/2)" },
192 {NET8_USER_FUNC_OSDAUTH, "Set DBA authorization call (OS/2)" },
193 {NET8_USER_FUNC_OUDLFUN, "Direct loader: functions" },
194 {NET8_USER_FUNC_OUDLBUF, "Direct loader: buffer transfer" },
195 {NET8_USER_FUNC_OK2RPC, "Distrib. trans. mgr. RPC" },
196 {NET8_USER_FUNC_ODSCIDX, "Describe indexes for distributed query" },
197 {NET8_USER_FUNC_OSESOPN, "Session operations" },
198 {NET8_USER_FUNC_OEXECSCN, "Execute using synchronized system commit numbers" },
199 {NET8_USER_FUNC_OALL7, "New V8 Bundle call" },
200 {NET8_USER_FUNC_OLONGF, "Long fetch version 7" },
201 {NET8_USER_FUNC_OEXECA, "Call opiexe from opiall" },
202 {NET8_USER_FUNC_OSQL7, "Parse call" },
203 {NET8_USER_FUNC_OOBS, "(Obsolete)" },
204 {NET8_USER_FUNC_ORPC, "RPC Call from pl" },
205 {NET8_USER_FUNC_OEXFEN, "OEXFEN" },
206 {NET8_USER_FUNC_OXAOPN, "XA operation" },
207 {NET8_USER_FUNC_OKGL, "KGL call" },
208 {NET8_USER_FUNC_03LOGON, "LogonB"},
209 {NET8_USER_FUNC_03LOGA, "LogonA"},
210 {NET8_USER_FUNC_OFNSTM, "Do Streaming Operation"},
211 {NET8_USER_FUNC_OPENSESS, "Open Session"},
212 {NET8_USER_FUNC_O71XAOPN, "X/Open XA operations"},
213 {NET8_USER_FUNC_ODEBUG, "Debug"},
214 {NET8_USER_FUNC_ODEBUGS, "Special Debug"},
215 {NET8_USER_FUNC_OXAST, "XA Start"},
216 {NET8_USER_FUNC_OXACM, "XA Commit"},
217 {NET8_USER_FUNC_OXAPR, "XA Prepare"},
218 {NET8_USER_FUNC_OXDP, "XA Import"},
219 {NET8_USER_FUNC_OKOD, "Get Object Value From Reference"},
220 {NET8_USER_FUNC_OCONNECT, "Connect"},
221 {NET8_USER_FUNC_OCBK, "call (kernel side only)"},
222 {NET8_USER_FUNC_OALL8, "OALL8"},
223 {NET8_USER_FUNC_OFNSTM2, "OFNSTM without the begintxn"},
224 {NET8_USER_FUNC_OLOBOPS, "LOB Operation"},
225 {NET8_USER_FUNC_OFILECRT, "FILE create call"},
226 {NET8_USER_FUNC_ODNY, "New Describe"},
227 {NET8_USER_FUNC_OCONNECT, "code for non blocking attach host"},
228 {NET8_USER_FUNC_OOPENRCS, "Open a recursive cursor"},
229 {NET8_USER_FUNC_OKPRALL, "Bundled KPR execution"},
230 {NET8_USER_FUNC_OPLS, "Bundled PL/SQL execution"},
231 {NET8_USER_FUNC_OTXSE, "transaction start, attach, detach"},
232 {NET8_USER_FUNC_OTXEN, "transaction commit, rollback, recover"},
233 {NET8_USER_FUNC_OCCA, "Cursor Close All"},
234 {NET8_USER_FUNC_OFOI, "Failover info piggyback"},
235 {NET8_USER_FUNC_O80SES, "V8 session switching piggyback"},
236 {NET8_USER_FUNC_ODDF, "Do Dummy Defines"},
237 {NET8_USER_FUNC_OLRMINI, "init sys pars"},
238 {NET8_USER_FUNC_OLRMFIN, "finalize sys pars"},
239 {NET8_USER_FUNC_OLRMPUT, "put sys par in par space"},
240 {NET8_USER_FUNC_OLRMTRM, "terminate sys pars"},
241 {NET8_USER_FUNC_OEXFENA, "execute but don't unmap (used from opiall0)"},
242 {NET8_USER_FUNC_OINIUCB, "OINIT for Untrusted CallBacks"},
243 {NET8_USER_FUNC_AUTH, "Authentication Call"},
244 {NET8_USER_FUNC_OFGI, "FailOver Get Instance Info"},
245 {NET8_USER_FUNC_OOTCO, "Oracle Transaction service COmmit remote sites"},
246 {NET8_USER_FUNC_GETSESSKEY, "Get the session key"},
247 {NET8_USER_FUNC_ODSY, "V8 Describe Any"},
248 {NET8_USER_FUNC_OCANA, "Cancel All"},
249 {NET8_USER_FUNC_OAQEQ, "AQ EnQueue"},
250 {NET8_USER_FUNC_OAQDQ, "AQ Dequeue"},
251 {NET8_USER_FUNC_ORFS, "RFS call"},
252 {NET8_USER_FUNC_OKPN, "Kernel Programmatic Notification"},
260 /*+------------------------------------------------------
262 * Convert hex data to character string
263 *--------------------------------------------------------
265 char * convertHexToString(BYTE *pSrc, UI16_T length)
269 char hex[17] = "0123456789ABCDEF";
271 int limit = 2*length;
272 if (limit >= sizeof(buf) - 3)
273 limit = sizeof(buf) - 3;
276 for( i=0; i<limit; i+=2)
278 buf[i] = hex[*pSrc>>4];
279 buf[i+1] = hex[*pSrc&0x0F];
285 for(int i=0; i<length*2; i++)
287 buf[i] = hex[*pSrc>>4];
288 buf[++i] = hex[*pSrc&0x0F];
291 buf[length*2] = '\0';
294 /* hexString = buf; */
295 /* strcpy (hexString, buf); */
300 static void ParseSqlStatement(/*char *appMsg,*/ UI8_P pSqlData, UI16_T dataLen)
302 char *pSqlModifyData = (I8_P)m_pCurQuery;
305 while (*pSqlData != '\1' && *pSqlData != '\0' && i < dataLen)
309 *pSqlModifyData = ' ';
313 *pSqlModifyData = *pSqlData;
321 *pSqlModifyData = '\0';
324 appMsg = (I8_P)m_pCurQuery;
327 if (g_ascii_strncasecmp((I8_P)m_pCurQuery, "update", 6) == 0)
331 pSummaryStat->m_numOfUpdate++;
332 if (m_pServerNode != NULL)
333 m_pServerNode->m_numOfUpdate++;
336 else if (g_ascii_strncasecmp((I8_P)m_pCurQuery, "select", 6) == 0)
340 pSummaryStat->m_numOfSelect++;
341 if (m_pServerNode != NULL)
342 m_pServerNode->m_numOfSelect++;
345 else if (g_ascii_strncasecmp((I8_P)m_pCurQuery, "insert", 6) == 0)
349 pSummaryStat->m_numOfInsert++;
350 if (m_pServerNode != NULL)
351 m_pServerNode->m_numOfInsert++;
354 else if (g_ascii_strncasecmp((I8_P)m_pCurQuery, "delete", 6) == 0)
358 pSummaryStat->m_numOfDelete++;
359 if (m_pServerNode != NULL)
360 m_pServerNode->m_numOfDelete++;
363 else if (g_ascii_strncasecmp((I8_P)m_pCurQuery, "rollback", 8) == 0)
367 pSummaryStat->m_numOfRollback++;
368 if (m_pServerNode != NULL)
369 m_pServerNode->m_numOfRollback++;
372 else if (g_ascii_strncasecmp((I8_P)m_pCurQuery, "set", 3) == 0)
376 pSummaryStat->m_numOfSet++;
377 if (m_pServerNode != NULL)
378 m_pServerNode->m_numOfSet++;
381 else if (g_ascii_strncasecmp((I8_P)m_pCurQuery, "start", 5) == 0)
385 pSummaryStat->m_numOfStart++;
386 if (m_pServerNode != NULL)
387 m_pServerNode->m_numOfStart++;
390 else if (g_ascii_strncasecmp((I8_P)m_pCurQuery, "commit", 6) == 0)
394 pSummaryStat->m_numOfCommit++;
395 if (m_pServerNode != NULL)
396 m_pServerNode->m_numOfCommit++;
401 m_numOfOtherStatement++;
403 pSummaryStat->m_numOfOtherStatement++;
404 if (m_pServerNode != NULL)
405 m_pServerNode->m_numOfOtherStatement++;
409 m_numOfTransaction++;
411 m_pSummaryStat->m_numOfTransaction++;
412 if (m_pServerNode != NULL)
413 m_pServerNode->m_numOfTransaction++;
418 static gboolean FindBeginningSQLString(UI8_P *pBuf, UI16_T *pDataLen, int lookSize)
420 /* the position could still be off by x bytes, check if it happened to be landing on an address */
421 /* int i = 31; /+ allow upto 8 bad bytes */
422 UI8_P pString = *pBuf;
423 gboolean bAlpha1 = isalpha(pString[0]) != 0;
424 gboolean bAlpha2 = isalpha(pString[1]) != 0;
425 gboolean bAlpha3 = isalpha(pString[2]) != 0;
426 gboolean bAlpha4 = isalpha(pString[3]) != 0;
427 gboolean bComment = FALSE;
428 UI16_T dataLen = *pDataLen;
429 while ( (dataLen > 2) && (lookSize > 0) && ((bAlpha1 == FALSE) || (bAlpha2 == FALSE) || (bAlpha3 == FALSE) || (bAlpha4 == FALSE)))
431 /* check if we need to find the ending comment */
434 if (*((UI16_P)pString) == 0x2F2A) /* ending comment */
437 pString ++; /* skip the comment */
445 /* check if there is a comment string prepended to the statement */
446 if (*((UI16_P)pString) == 0x2A2F) /* beginning of comment */
451 bAlpha2 = isalpha(pString[1]) != 0;
452 bAlpha3 = isalpha(pString[2]) != 0;
453 bAlpha4 = isalpha(pString[3]) != 0;
458 bAlpha2 = isalpha(pString[1]) != 0;
459 bAlpha3 = isalpha(pString[2]) != 0;
460 bAlpha4 = isalpha(pString[3]) != 0;
462 /* don't count the zeros */
463 if (*((UI8_P)pString) != 0x0)
467 if (bAlpha1 && bAlpha2 && bAlpha3 && bAlpha4)
477 static gboolean ParseCommand(proto_tree *tree,tvbuff_t *tvb, int offset, packet_info *pinfo,UI16_T dataLen)
479 UI8_T pAddress[1024];
480 UI16_T SQLDataLen = dataLen;
483 for (i=0; i<1024;i++)
487 tvb_memcpy (tvb, pAddress,offset, dataLen);
488 pAddr = (UI8_P)pAddress;
489 /* see if SQL statement is there */
490 if (FindBeginningSQLString((UI8_P*)&pAddr, &SQLDataLen, 0x30) == TRUE)
492 ParseSqlStatement( pAddr, dataLen);
494 proto_tree_add_text(tree, tvb, offset+dataLen-SQLDataLen, SQLDataLen,
495 "SQL statement = %s",m_pCurQuery);
496 if (check_col(pinfo->cinfo, COL_INFO))
497 col_clear(pinfo->cinfo, COL_INFO);
498 if (check_col(pinfo->cinfo, COL_INFO))
499 col_add_str(pinfo->cinfo, COL_INFO, m_pCurQuery );
506 static gboolean ParseNewCommand( proto_tree *tree,tvbuff_t *tvb, int offset, packet_info *pinfo, UI16_T dataLen)
508 UI8_T pAddress[1024];
509 /* find the first sequence of zeros */
510 int amount = dataLen - 12;
511 int i = 0, sqlamount;
513 tvb_memcpy (tvb, pAddress,offset, dataLen);
514 pAddr = (UI8_P)&pAddress;
515 for (; i < amount; i++)
517 if (*((UI32_P)((UI8_P)pAddr++)) == 0x0000)
520 /* was there a sequence of 4 zeros */
524 return FALSE; /* went past, can not be a sql command */
526 /* look for the end of the zeros */
527 amount = dataLen - i - 4; /* rest of the data */
529 for (i = 0; *pAddr++ == 0 && i < amount; i++);
533 return FALSE; /* no values after zeros */
536 amount -= i + 1; /* rest of the data */
538 /* see if SQL statement is there */
540 if (FindBeginningSQLString((UI8_P*)&pAddr, (UI16_P)&sqlamount, 13) == TRUE)
542 ParseSqlStatement( pAddr, amount);
543 if (check_col(pinfo->cinfo, COL_INFO))
544 col_clear(pinfo->cinfo, COL_INFO);
545 if (check_col(pinfo->cinfo, COL_INFO))
546 col_add_str(pinfo->cinfo, COL_INFO, m_pCurQuery );
547 proto_tree_add_text(tree, tvb, offset+amount-sqlamount, sqlamount,
548 "SQL statement = %s",m_pCurQuery);
559 dissect_sqloracle(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
561 proto_item *ti = NULL;
562 proto_tree *sqloracle_tree = NULL;
563 int offset = 0,dataLen,nocol,numItersThisTime,flag,iterNum,uacBufLength;
564 guint8 header_operation,func_type=0;
565 m_pCurQuery[0] = '0';
568 pinfo->current_proto = "SQLORACLE";
569 if ( check_col( pinfo->cinfo, COL_PROTOCOL ))
570 col_set_str( pinfo->cinfo, COL_PROTOCOL, "SQL" );
571 if (check_col(pinfo->cinfo, COL_INFO))
572 col_clear(pinfo->cinfo, COL_INFO);
574 header_operation = tvb_get_guint8(tvb, offset);
575 dataLen = tvb_reported_length_remaining(tvb, offset);
576 if (header_operation != NET8_TYPE_FUNCCOMPLETE)
577 func_type = tvb_get_guint8(tvb, offset+1);
579 if ( check_col(pinfo->cinfo, COL_INFO))
581 col_add_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str(header_operation, sqloracle_operation_type, ""));
586 ti = proto_tree_add_item(tree, proto_sqloracle, tvb, 0, -1, FALSE);
587 sqloracle_tree = proto_item_add_subtree(ti, ett_sqloracle);
588 proto_tree_add_uint(sqloracle_tree, hf_sqloracle_operation, tvb, offset, 1,header_operation);
589 if (func_type && header_operation !=NET8_TYPE_ROWTRANSFER)
590 proto_tree_add_uint(sqloracle_tree, hf_sqloracle_func_type, tvb, offset+1, 1,func_type);
593 switch (header_operation)
595 case NET8_TYPE_USERTOSERVER: /* 0x3 */
596 if ( check_col(pinfo->cinfo, COL_INFO))
598 col_append_fstr(pinfo->cinfo, COL_INFO, ":%s ", val_to_str(func_type, sql_func_type, ""));
602 case NET8_USER_FUNC_PARSE:
603 ParseCommand(sqloracle_tree,tvb,offset+0x0B,pinfo,dataLen-0x0B);
605 case NET8_USER_FUNC_OALL:
606 case NET8_USER_FUNC_OALL8:
607 /* command could be embedded in this packet
608 * filtered_for_hh02_and_hh05.enc has commands that are not 0x2f offset
609 * try to detect the difference by looking at the offset 0x12 for 6 zeros
611 if (dataLen > (0x19 + 8)) /* assume minimum of 8 chars for the command */
613 /* piggybacked functions will recursive call this routine to process the command */
614 if (ParseCommand(sqloracle_tree,tvb, offset+0x12, pinfo,dataLen - 0x12) == TRUE)
618 case NET8_USER_FUNC_OSQL7: /* 0x4A */
619 /* command could be embedded in this packet */
620 /* aig oracle.enc has smaller data */
621 if (dataLen > (0x2A /*0x30/0x14*/ + 8)) /* minimum of 8 chars */
623 if (ParseCommand(sqloracle_tree,tvb, offset + 0x2A /*0x30/0x14*/, pinfo,dataLen - 0x2A /*0x30/0x14*/) == TRUE)
628 case NET8_USER_FUNC_OALL7: /* 0x47 */
629 /* command could be embedded in this packet */
630 if (dataLen > (0x2A /*0x30/0x14*/ + 8)) /* minimum of 8 chars */
632 if (ParseCommand(sqloracle_tree,tvb, offset + 0x14, pinfo,dataLen - 0x14) == TRUE)
634 if (check_col(pinfo->cinfo, COL_INFO))
635 col_add_str(pinfo->cinfo, COL_INFO, m_pCurQuery );
639 /* appdncr.enc has this smaller command */
640 if (ParseCommand(sqloracle_tree,tvb, offset + 0x30, pinfo,dataLen - 0x30) == TRUE)
646 case NET8_TYPE_ROWTRANSFER: /* 0x06 */
648 proto_tree_add_uint(sqloracle_tree, hf_sqloracle_flag, tvb, offset+1, 1,flag);
649 nocol = tvb_get_guint8(tvb, offset+2);
650 iterNum = tvb_get_guint8(tvb, offset+3);
651 numItersThisTime = tvb_get_ntohs(tvb, offset+5);
652 uacBufLength = tvb_get_ntohs(tvb, offset+7);
653 proto_tree_add_uint(sqloracle_tree, hf_sqloracle_num_column, tvb, offset+2, 1,nocol);
654 proto_tree_add_uint(sqloracle_tree, hf_sqloracle_itemNum, tvb, offset+3, 1,iterNum);
655 proto_tree_add_uint(sqloracle_tree, hf_sqloracle_numItersThisTime, tvb, offset+5, 2,numItersThisTime);
656 proto_tree_add_uint(sqloracle_tree, hf_sqloracle_uacBufLength, tvb, offset+7, 2,uacBufLength);
664 } /* dissect_sqloracle */
667 proto_register_sqloracle(void)
669 static hf_register_info hf[] =
671 { &hf_sqloracle_operation,
672 { "Basic Operation", "sqloracle.operation", FT_UINT8, BASE_DEC, VALS(sqloracle_operation_type), 0x0, "", HFILL }
674 { &hf_sqloracle_func_type,
675 { "Function Type", "sqloracle.type", FT_UINT8, BASE_DEC, VALS(sql_func_type), 0x0, "", HFILL }
677 { &hf_sqloracle_flag,
678 { "flag", "sqloracle.flag", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
680 { &hf_sqloracle_num_column,
681 { "Number of Columns", "sqloracle.nocolumn", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
683 { &hf_sqloracle_itemNum,
684 { "Iteration Number", "sqloracle.itemNum", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }
686 { &hf_sqloracle_numItersThisTime,
687 { "# of iterations this time", "sqloracle.numItersThisTime", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }
689 { &hf_sqloracle_uacBufLength,
690 { "user access buffer length", "sqloracle.uacBufLength", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }
692 /* { &hf_sqloracle_ttloac_header,
693 { "TTLOAC Header", "sqloracle.ttloac_header", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
696 { &hf_sqloracle_ttloac_type,
697 { "type", "sqloracle.ttloac_type", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
699 { &hf_sqloracle_ttloac_flag1,
700 { "flag1", "sqloracle.ttloac_flag1", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
702 { &hf_sqloracle_ttloac_prefix,
703 { "prefix", "sqloracle.ttloac_prefix", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
705 { &hf_sqloracle_ttloac_scalesize,
706 { "scale size", "sqloracle.ttloac_scalesize", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
708 { &hf_sqloracle_ttloac_dummy,
709 { "dummy", "sqloracle.ottloac_dummy", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
711 { &hf_sqloracle_ttloac_varcharlen,
712 { "varcharlen", "sqloracle.ttloac_varcharlen", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
714 { &hf_sqloracle_ttloac_mal,
715 { "mal", "sqloracle.ttloac_mal", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
717 { &hf_sqloracle_ttloac_flag2,
718 { "flag2", "sqloracle.ttloac_flag2", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
720 { &hf_sqloracle_v8ttloac_header,
721 { "V8TTLOAC Header", "sqloracle.v8ttloac_header", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
724 { &hf_sqloracle_v8ttloac_oid,
725 { "oid", "sqloracle.v8ttloac_oid", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
727 { &hf_sqloracle_v8ttloac_vsn,
728 { "vsn", "sqloracle.v8ttloac_vsn", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
730 { &hf_sqloracle_v8ttloac_ncs,
731 { "ncs", "sqloracle.v8ttloac_ncs", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
733 { &hf_sqloracle_v8ttloac_formuse,
734 { "FormUse", "sqloracle.v8ttloac_formuse", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
736 { &hf_sqloracle_v8ttluds_header,
737 { "V8TTLUDS Header", "sqloracle.v8ttluds_header", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
740 { &hf_sqloracle_v8ttluds_nullallow,
741 { "null allowed", "sqloracle.v8ttluds_nullallow", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
743 { &hf_sqloracle_v8ttluds_scrlength,
744 { "screen length", "sqloracle.v8ttluds_scrlength", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
746 { &hf_sqloracle_v8ttluds_columnname,
747 { "column name", "sqloracle.v8ttluds_columnname", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
749 { &hf_sqloracle_v8ttluds_sname,
750 { "sName", "sqloracle.v8ttluds_snname", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
752 { &hf_sqloracle_v8ttluds_tname,
753 { "tName", "sqloracle.v8ttluds_tname", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }
755 { &hf_sqloracle_stmt_length,
756 { "SQL Statement Length", "sqloracle.stmtlength", FT_UINT8, BASE_DEC, NULL, 0x0,
758 */ { &hf_sqloracle_stmt,
759 { "SQL statement", "sqloracle.stmt", FT_BYTES, BASE_HEX, NULL, 0x0, "", HFILL }
766 &ett_sqloracle_operation,
769 proto_sqloracle = proto_register_protocol("SQL -Net8 Data", "SQL", "sqloracle");
770 proto_register_field_array(proto_sqloracle, hf, array_length(hf));
771 proto_register_subtree_array(ett, array_length(ett));
774 register_dissector("sqloracle", dissect_sqloracle, proto_sqloracle);
778 proto_reg_handoff_sqloracle(void)
780 dissector_handle_t sqloracle_handle;
782 sqloracle_handle = find_dissector("sqloracle");
783 dissector_add("tns.port", TCP_PORT_TNS, sqloracle_handle);