Move 3 ASN1 dissectors to 'clean' group; move 1 PIDL dissector to 'dirty' group.
[metze/wireshark/wip.git] / epan / dissectors / packet-nasdaq-itch.c
1 /* packet-nasdaq-itch.c
2  * Routines for NASDAQ TotalView-ITCH version 2.00/3.00 (with Chi-X extension) Protocol dissection
3  * Copyright 2007,2008 Didier Gautheron <dgautheron@magic.fr>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  *
25  * Documentation:
26  * http://www.nasdaqtrader.com/Trader.aspx?id=DPSpecs
27  * ex:
28  * http://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/tv-itch2a.pdf
29  * http://www.nasdaqtrader.com/content/technicalsupport/specifications/dataproducts/tvitch-v3.pdf
30  *
31  * Chi-X
32  * http://www.chi-x.com/docs/Chi-X%20CHIXMD.pdf
33
34  */
35
36 #include "config.h"
37
38 #include <stdlib.h>
39 #include <string.h>
40
41 #include <glib.h>
42
43 #include <epan/packet.h>
44 #include <epan/prefs.h>
45 #include <wsutil/type_util.h>
46
47 /* Chi-X version */
48 static gboolean nasdaq_itch_chi_x = TRUE;
49
50 static const value_string message_types_val[] = {
51  { 'A', "Add Order " },
52  { 'X', "Order Cancel " },
53  { 'M', "Milliseconds " },
54  { 'E', "Order Executed " },
55  { 'T', "Second " },
56  { 'P', "Trade Message Identifier " },
57  { 'C', "Order Executed With Price " },
58  { 'D', "Order Delete " },
59  { 'Q', "Cross Trade " },
60  { 'S', "System Event " },
61  { 'R' , "Stock Directory " },
62  { 'H', "Stock Trading Action " },
63  { 'F', "Add Order (MPID) " },
64  { 'I', "Net Order Imbalance Indicator (NOII) " },
65  { 'B', "Broken Trade " },
66  /* Chi-X msg with big size,price */
67  { 'a', "Add Order (big)" },
68  { 'p', "Trade Message Identifier (big)" },
69  { 'e', "Order Executed (big)" },
70  { 'x', "Order Cancel (big)" },
71  { 0, NULL }
72 };
73
74 static char chix_msg[] = "apex";
75
76 static const value_string system_event_val[] = {
77  { 'O', "Start of Messages" },
78  { 'S', "Start of System hours" },
79  { 'Q', "Start of Market hours" },
80  { 'M', "End of Market hours" },
81  { 'E', "End of System hours" },
82  { 'C', "End of Messages" },
83  { 0, NULL }
84 };
85
86 static const value_string market_category_val[] = {
87  { 'T', "CQS (NYSE, Amex or regional exchange)" },
88  { 'Q', "NASDAQ Global Select MarketSM" },
89  { 'G', "NASDAQ Global MarketSM" },
90  { 'S', "NASDAQ Capital Market" },
91  { ' ', "Not available" },
92  { 0, NULL }
93 };
94
95 static const value_string financial_status_val[] = {
96  { 'D', "Deficient" },
97  { 'E', "Delinquent" },
98  { 'Q', "Bankrupt" },
99  { 'S', "Suspended" },
100  { 'G', "Deficient and Bankrupt" },
101  { 'H', "Deficient and Delinquent" },
102  { 'J', "Delinquent and Bankrupt" },
103  { 'K', "Deficient, Delinquent and Bankrupt" },
104  { ' ', "Company is in compliance" },
105  { 0, NULL }
106 };
107
108 static const value_string round_lots_only_val[] = {
109  { 'Y', "only round lots are accepted in this stock" },
110  { 'N', "odd/mixed lots are allowed" },
111  { 0, NULL }
112 };
113
114 /* Initialize the protocol and registered fields */
115 static int proto_nasdaq_itch = -1;
116
117 /* Initialize the subtree pointers */
118 static gint ett_nasdaq_itch = -1;
119
120 static int hf_nasdaq_itch_version = -1;
121
122 static int hf_nasdaq_itch_message_type = -1;
123 static int hf_nasdaq_itch_market_category = -1;
124 static int hf_nasdaq_itch_financial_status = -1;
125 static int hf_nasdaq_itch_stock = -1;
126 static int hf_nasdaq_itch_round_lot_size = -1;
127 static int hf_nasdaq_itch_round_lots_only = -1;
128
129 static int hf_nasdaq_itch_system_event = -1;
130 static int hf_nasdaq_itch_second = -1;
131 static int hf_nasdaq_itch_millisecond = -1;
132
133 static int hf_nasdaq_itch_message = -1;
134
135 static int hf_nasdaq_itch_trading_state = -1;
136 static int hf_nasdaq_itch_reserved = -1;
137 static int hf_nasdaq_itch_reason = -1;
138 static int hf_nasdaq_itch_order_reference = -1;
139 static int hf_nasdaq_itch_buy_sell = -1;
140 static int hf_nasdaq_itch_shares = -1;
141 static int hf_nasdaq_itch_price = -1;
142 static int hf_nasdaq_itch_attribution = -1;
143 static int hf_nasdaq_itch_executed = -1;
144 static int hf_nasdaq_itch_match = -1;
145 static int hf_nasdaq_itch_printable = -1;
146 static int hf_nasdaq_itch_execution_price = -1;
147 static int hf_nasdaq_itch_canceled = -1;
148 static int hf_nasdaq_itch_cross = -1;
149
150 #define PINFO_COL(a) (check_col((a)->cinfo, COL_INFO))
151
152 /* ---------------------- */
153 static int
154 order_ref_number(tvbuff_t *tvb, packet_info *pinfo, proto_tree *nasdaq_itch_tree, int offset)
155 {
156   gint col_info = PINFO_COL(pinfo);
157
158   if (nasdaq_itch_tree || col_info) {
159       const char *str_value = tvb_get_ephemeral_string(tvb, offset, 9);
160       guint32 value = (guint32)strtoul(str_value, NULL, 10);
161
162       proto_tree_add_uint(nasdaq_itch_tree, hf_nasdaq_itch_order_reference, tvb, offset, 9, value);
163       if (col_info) {
164           col_append_fstr(pinfo->cinfo, COL_INFO, "%u ", value);
165       }
166   }
167   return offset+9;
168 }
169
170 /* -------------------------- */
171 static int
172 time_stamp(tvbuff_t *tvb, proto_tree *nasdaq_itch_tree, int id, int offset, int size)
173 {
174
175   if (nasdaq_itch_tree) {
176       guint32 ms, val;
177       const char *display = "";
178       const char *str_value = tvb_get_ephemeral_string(tvb, offset, size);
179
180       ms = val = (guint32)strtoul(str_value, NULL, 10);
181       switch (size) {
182       case 3:
183           display = ep_strdup_printf(" %03u" , val);
184           break;
185       case 5:
186           ms = val *1000;
187       case 8: /* 0 86 400 000 */
188           display = ep_strdup_printf(" %u (%02u:%02u:%02u.%03u)", val,
189               ms/3600000, (ms % 3600000)/60000, (ms % 60000)/1000, ms %1000);
190           break;
191       }
192       proto_tree_add_uint_format_value(nasdaq_itch_tree, id, tvb, offset, size, val, "%s", display);
193   }
194   return offset+size;
195 }
196
197 /* -------------------------- */
198 static int
199 number_of_shares(tvbuff_t *tvb, packet_info *pinfo, proto_tree *nasdaq_itch_tree, int id, int offset, int big)
200 {
201   gint col_info = PINFO_COL(pinfo);
202   gint size = (big)?10:6;
203
204   if (nasdaq_itch_tree || col_info) {
205       const char *str_value = tvb_get_ephemeral_string(tvb, offset, size);
206       guint32 value = (guint32)strtoul(str_value, NULL, 10);
207
208       proto_tree_add_uint(nasdaq_itch_tree, id, tvb, offset, size, value);
209       if (col_info) {
210           col_append_fstr(pinfo->cinfo, COL_INFO, "qty %u ", value);
211       }
212   }
213   return offset +size;
214 }
215
216 /* -------------------------- */
217 static int
218 price(tvbuff_t *tvb, packet_info *pinfo, proto_tree *nasdaq_itch_tree, int id, int offset, int big)
219 {
220   gint col_info = PINFO_COL(pinfo);
221   gint size = (big)?19:10;
222
223   if (nasdaq_itch_tree || col_info) {
224       const char *str_value = tvb_get_ephemeral_string(tvb, offset, size);
225       gdouble value = guint64_to_gdouble(g_ascii_strtoull(str_value, NULL, 10))/((big)?1000000.0:10000.0);
226
227       proto_tree_add_double(nasdaq_itch_tree, id, tvb, offset, size, value);
228       if (col_info) {
229           col_append_fstr(pinfo->cinfo, COL_INFO, "price %g ", value);
230       }
231   }
232   return offset+size;
233 }
234
235 /* -------------------------- */
236 static int
237 stock(tvbuff_t *tvb, packet_info *pinfo, proto_tree *nasdaq_itch_tree, int offset)
238 {
239   gint col_info = PINFO_COL(pinfo);
240   if (nasdaq_itch_tree || col_info) {
241       char *stock_p = tvb_get_ephemeral_string(tvb, offset, 6);
242
243       proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_stock, tvb, offset, 6, ENC_ASCII|ENC_NA);
244       if (col_info) {
245           col_append_fstr(pinfo->cinfo, COL_INFO, "<%s> ", stock_p);
246       }
247   }
248   return offset+6;
249 }
250
251 /* -------------------------- */
252 static int
253 order(tvbuff_t *tvb, packet_info *pinfo, proto_tree *nasdaq_itch_tree, int offset, int big)
254 {
255   gint col_info = PINFO_COL(pinfo);
256   guint8 value;
257
258   offset = order_ref_number(tvb, pinfo, nasdaq_itch_tree, offset);
259
260   value = tvb_get_guint8(tvb, offset);
261   if (col_info) {
262       col_append_fstr(pinfo->cinfo, COL_INFO, "%c ", value);
263   }
264   proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_buy_sell, tvb, offset, 1, ENC_ASCII|ENC_NA);
265   offset += 1;
266
267   offset = number_of_shares(tvb, pinfo, nasdaq_itch_tree, hf_nasdaq_itch_shares, offset, big);
268
269   offset = stock(tvb, pinfo, nasdaq_itch_tree, offset);
270
271   offset = price(tvb, pinfo, nasdaq_itch_tree, hf_nasdaq_itch_price, offset, big);
272   return offset;
273 }
274
275 /* -------------------------- */
276 static int
277 executed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *nasdaq_itch_tree, int offset, int big)
278 {
279   offset = order_ref_number(tvb, pinfo, nasdaq_itch_tree, offset);
280
281   offset = number_of_shares(tvb, pinfo, nasdaq_itch_tree, hf_nasdaq_itch_executed, offset, big);
282
283   proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_match, tvb, offset, 9, ENC_ASCII|ENC_NA);
284   offset += 9;
285   return offset;
286 }
287
288 /* ---------------------------- */
289 static void
290 dissect_nasdaq_itch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
291 {
292     proto_item *ti;
293     proto_tree *nasdaq_itch_tree = NULL;
294     guint8 nasdaq_itch_type;
295     int  offset = 0;
296     gint col_info;
297     int version = 3;
298     int big = 0;
299
300     col_info = PINFO_COL(pinfo);
301
302     col_set_str(pinfo->cinfo, COL_PROTOCOL, "Nasdaq-ITCH");
303
304     nasdaq_itch_type = tvb_get_guint8(tvb, offset);
305     if (nasdaq_itch_type >= '0' && nasdaq_itch_type <= '9') {
306         version = 2;
307         nasdaq_itch_type = tvb_get_guint8(tvb, offset +8);
308     }
309
310     if ((!nasdaq_itch_chi_x || version == 3) && strchr(chix_msg, nasdaq_itch_type)) {
311         nasdaq_itch_type = 0; /* unknown */
312     }
313     if (col_info || tree) {
314         const gchar *rep = val_to_str(nasdaq_itch_type, message_types_val, "Unknown packet type (0x%02x) ");
315         if (col_info ) {
316             col_clear(pinfo->cinfo, COL_INFO);
317             col_add_str(pinfo->cinfo, COL_INFO, rep);
318         }
319         if (tree) {
320             proto_item *item;
321
322             ti = proto_tree_add_protocol_format(tree, proto_nasdaq_itch, tvb, offset, -1, "Nasdaq TotalView-ITCH %s, %s",
323                     version == 2?"2.0":"3.0", rep);
324
325             nasdaq_itch_tree = proto_item_add_subtree(ti, ett_nasdaq_itch);
326
327             item=proto_tree_add_uint(nasdaq_itch_tree, hf_nasdaq_itch_version, tvb, 0, 0, version);
328             PROTO_ITEM_SET_GENERATED(item);
329         }
330     }
331
332     if (version == 2) {
333         offset = time_stamp (tvb, nasdaq_itch_tree, hf_nasdaq_itch_millisecond, offset, 8);
334     }
335
336     proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_message_type, tvb, offset, 1, ENC_BIG_ENDIAN);
337     offset++;
338
339     if (version == 3) {
340       switch (nasdaq_itch_type) {
341       case 'T': /* seconds */
342           offset = time_stamp (tvb, nasdaq_itch_tree, hf_nasdaq_itch_second, offset, 5);
343           return;
344
345       case 'M': /* milliseconds */
346           offset = time_stamp (tvb, nasdaq_itch_tree, hf_nasdaq_itch_millisecond, offset, 3);
347           return;
348       }
349     }
350
351     switch (nasdaq_itch_type) {
352     case 'S': /* system event */
353         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_system_event, tvb, offset, 1, ENC_BIG_ENDIAN);
354         offset++;
355         break;
356
357     case 'R': /* Stock Directory */
358         offset = stock(tvb, pinfo, nasdaq_itch_tree, offset);
359
360         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_market_category, tvb, offset, 1, ENC_BIG_ENDIAN);
361         offset += 1;
362         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_financial_status, tvb, offset, 1, ENC_BIG_ENDIAN);
363         offset += 1;
364         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_round_lot_size, tvb, offset, 6, ENC_ASCII|ENC_NA);
365         offset += 6;
366         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_round_lots_only, tvb, offset, 1, ENC_BIG_ENDIAN);
367         offset += 1;
368         break;
369
370     case 'H': /* Stock trading action */
371         offset = stock(tvb, pinfo, nasdaq_itch_tree, offset);
372
373         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_trading_state, tvb, offset, 1, ENC_ASCII|ENC_NA);
374         offset += 1;
375         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_reserved, tvb, offset, 1, ENC_ASCII|ENC_NA);
376         offset += 1;
377         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_reason, tvb, offset, 4, ENC_ASCII|ENC_NA);
378         offset += 4;
379         break;
380
381     case 'a' :
382         big = 1;
383     case 'A': /* Add order, no MPID */
384         offset = order(tvb, pinfo, nasdaq_itch_tree, offset, big);
385         if (version == 2) {
386             proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_printable, tvb, offset, 1, ENC_ASCII|ENC_NA);
387             offset += 1;
388         }
389         break;
390
391     case 'F': /* Add order, MPID */
392         offset = order(tvb, pinfo, nasdaq_itch_tree, offset, big);
393         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_attribution, tvb, offset, 4, ENC_ASCII|ENC_NA);
394         offset += 4;
395         break;
396
397     case 'e' :
398         big = 1;
399     case 'E' : /* Order executed */
400         offset = executed(tvb, pinfo, nasdaq_itch_tree, offset, big);
401         break;
402
403     case 'C' : /* Order executed with price */
404         offset = executed(tvb, pinfo, nasdaq_itch_tree, offset, big);
405         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_printable, tvb, offset, 1, ENC_ASCII|ENC_NA);
406         offset += 1;
407
408         offset = price(tvb, pinfo, nasdaq_itch_tree, hf_nasdaq_itch_execution_price, offset, big);
409         break;
410
411     case 'x' :
412         big = 1;
413     case 'X' : /* Order cancel */
414         offset = order_ref_number(tvb, pinfo, nasdaq_itch_tree, offset);
415         offset = number_of_shares(tvb, pinfo, nasdaq_itch_tree, hf_nasdaq_itch_canceled, offset, big);
416         break;
417
418     case 'D' : /* Order delete */
419         offset = order_ref_number(tvb, pinfo, nasdaq_itch_tree, offset);
420         offset += 9;
421         break;
422
423     case 'p' :
424         big = 1;
425     case 'P' : /* Trade identifier */
426         offset = order(tvb, pinfo, nasdaq_itch_tree, offset, big);
427         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_match, tvb, offset, 9, ENC_ASCII|ENC_NA);
428         offset += 9;
429         break;
430
431     case 'Q' : /* Cross Trade */
432         offset = number_of_shares(tvb, pinfo, nasdaq_itch_tree, hf_nasdaq_itch_shares, offset, big);
433
434         offset = stock(tvb, pinfo, nasdaq_itch_tree, offset);
435
436         offset = price(tvb, pinfo, nasdaq_itch_tree, hf_nasdaq_itch_price, offset, big);
437
438         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_match, tvb, offset, 9, ENC_ASCII|ENC_NA);
439         offset += 9;
440         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_cross, tvb, offset, 1, ENC_ASCII|ENC_NA);
441         offset += 1;
442         break;
443
444     case 'B' : /* Broken Trade */
445         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_match, tvb, offset, 9, ENC_ASCII|ENC_NA);
446         offset += 9;
447         break;
448
449     case 'I': /* NOII, FIXME */
450         offset = stock(tvb, pinfo, nasdaq_itch_tree, offset);
451
452         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_cross, tvb, offset, 1, ENC_ASCII|ENC_NA);
453         offset += 1;
454         break;
455
456     default:
457         /* unknown */
458         proto_tree_add_item(nasdaq_itch_tree, hf_nasdaq_itch_message, tvb, offset, -1, ENC_ASCII|ENC_NA);
459         offset += 5-1;
460         break;
461     }
462 }
463
464 /* Register the protocol with Wireshark */
465
466 void
467 proto_register_nasdaq_itch(void)
468 {
469
470 /* Setup list of header fields  See Section 1.6.1 for details*/
471     static hf_register_info hf[] = {
472     { &hf_nasdaq_itch_version,
473       { "Version",         "nasdaq-itch.version",
474         FT_UINT8, BASE_DEC, NULL, 0x0,
475         NULL, HFILL }},
476
477     { &hf_nasdaq_itch_message_type,
478       { "Message Type",         "nasdaq-itch.message_type",
479         FT_UINT8, BASE_DEC, VALS(message_types_val), 0x0,
480         NULL, HFILL }},
481
482     { &hf_nasdaq_itch_second,
483       { "Second",         "nasdaq-itch.second",
484         FT_UINT32, BASE_DEC, NULL, 0x0,
485         NULL, HFILL }},
486
487     { &hf_nasdaq_itch_millisecond,
488       { "Millisecond",         "nasdaq-itch.millisecond",
489         FT_UINT32, BASE_DEC,  NULL, 0x0,
490         NULL, HFILL }},
491
492     { &hf_nasdaq_itch_system_event,
493       { "System Event",         "nasdaq-itch.system_event",
494         FT_UINT8, BASE_DEC, VALS(system_event_val), 0x0,
495         NULL, HFILL }},
496
497     { &hf_nasdaq_itch_market_category,
498       { "Market Category",         "nasdaq-itch.market_category",
499         FT_UINT8, BASE_DEC, VALS(market_category_val), 0x0,
500         NULL, HFILL }},
501
502     { &hf_nasdaq_itch_financial_status,
503       { "Financial Status Indicator",         "nasdaq-itch.financial_status",
504         FT_UINT8, BASE_DEC, VALS(financial_status_val), 0x0,
505         NULL, HFILL }},
506
507     { &hf_nasdaq_itch_stock,
508       { "Stock",         "nasdaq-itch.stock",
509         FT_STRING, BASE_NONE, NULL, 0x0,
510         NULL, HFILL }},
511
512     { &hf_nasdaq_itch_round_lot_size,
513       { "Round Lot Size",         "nasdaq-itch.round_lot_size",
514         FT_STRING, BASE_NONE, NULL, 0x0,
515         NULL, HFILL }},
516
517     { &hf_nasdaq_itch_round_lots_only,
518       { "Round Lots Only",         "nasdaq-itch.round_lots_only",
519         FT_UINT8, BASE_DEC, VALS(round_lots_only_val), 0x0,
520         NULL, HFILL }},
521
522     { &hf_nasdaq_itch_trading_state,
523       { "Trading State",         "nasdaq-itch.trading_state",
524         FT_STRING, BASE_NONE, NULL, 0x0,
525         NULL, HFILL }},
526
527     { &hf_nasdaq_itch_reserved,
528       { "Reserved",         "nasdaq-itch.reserved",
529         FT_STRING, BASE_NONE, NULL, 0x0,
530         NULL, HFILL }},
531
532     { &hf_nasdaq_itch_reason,
533       { "Reason",         "nasdaq-itch.reason",
534         FT_STRING, BASE_NONE, NULL, 0x0,
535         NULL, HFILL }},
536
537     { &hf_nasdaq_itch_order_reference,
538       { "Order Reference",         "nasdaq-itch.order_reference",
539         FT_UINT32, BASE_DEC, NULL, 0x0,
540         "Order reference number", HFILL }},
541
542     { &hf_nasdaq_itch_buy_sell,
543       { "Buy/Sell",         "nasdaq-itch.buy_sell",
544         FT_STRING, BASE_NONE, NULL, 0x0,
545         "Buy/Sell indicator", HFILL }},
546
547     { &hf_nasdaq_itch_shares,
548       { "Shares",         "nasdaq-itch.shares",
549         FT_UINT32, BASE_DEC,  NULL, 0x0,
550         "Number of shares", HFILL }},
551
552     { &hf_nasdaq_itch_price,
553       { "Price",         "nasdaq-itch.price",
554         FT_DOUBLE, BASE_NONE, NULL, 0x0,
555         NULL, HFILL }},
556
557     { &hf_nasdaq_itch_attribution,
558       { "Attribution",         "nasdaq-itch.attribution",
559         FT_STRING, BASE_NONE, NULL, 0x0,
560         "Market participant identifier", HFILL }},
561
562     { &hf_nasdaq_itch_executed,
563       { "Executed Shares",         "nasdaq-itch.executed",
564         FT_UINT32, BASE_DEC,  NULL, 0x0,
565         "Number of shares executed", HFILL }},
566
567     { &hf_nasdaq_itch_match,
568       { "Matched",         "nasdaq-itch.match",
569         FT_STRING, BASE_NONE, NULL, 0x0,
570         "Match number", HFILL }},
571
572     { &hf_nasdaq_itch_printable,
573       { "Printable",         "nasdaq-itch.printable",
574         FT_STRING, BASE_NONE, NULL, 0x0,
575         NULL, HFILL }},
576
577     { &hf_nasdaq_itch_execution_price,
578       { "Execution Price",         "nasdaq-itch.execution_price",
579         FT_DOUBLE, BASE_NONE, NULL, 0x0,
580         NULL, HFILL }},
581
582     { &hf_nasdaq_itch_canceled,
583       { "Canceled Shares",         "nasdaq-itch.canceled",
584         FT_UINT32, BASE_DEC,  NULL, 0x0,
585         "Number of shares to be removed", HFILL }},
586
587     { &hf_nasdaq_itch_cross,
588       { "Cross Type",         "nasdaq-itch.cross",
589         FT_STRING, BASE_NONE, NULL, 0x0,
590         "Cross trade type", HFILL }},
591
592     { &hf_nasdaq_itch_message,
593       { "Message",         "nasdaq-itch.message",
594         FT_STRING, BASE_NONE, NULL, 0x0,
595         NULL, HFILL }}
596     };
597
598 /* Setup protocol subtree array */
599     static gint *ett[] = {
600         &ett_nasdaq_itch
601     };
602
603     module_t *nasdaq_itch_module;
604
605     /* Register the protocol name and description */
606     proto_nasdaq_itch = proto_register_protocol("Nasdaq TotalView-ITCH", "NASDAQ-ITCH", "nasdaq_itch");
607
608     /* Required function calls to register the header fields and subtrees used */
609     proto_register_field_array(proto_nasdaq_itch, hf, array_length(hf));
610     proto_register_subtree_array(ett, array_length(ett));
611
612     nasdaq_itch_module = prefs_register_protocol(proto_nasdaq_itch, NULL);
613     prefs_register_bool_preference(nasdaq_itch_module, "chi_x", "Decode Chi X extensions",
614         "Whether the Nasdaq ITCH dissector should decode Chi X extensions.",
615         &nasdaq_itch_chi_x);
616
617     register_dissector("nasdaq-itch", dissect_nasdaq_itch, proto_nasdaq_itch);
618 }
619
620
621 /* If this dissector uses sub-dissector registration add a registration routine.
622    This format is required because a script is used to find these routines and
623    create the code that calls these routines.
624 */
625 void
626 proto_reg_handoff_nasdaq_itch(void)
627 {
628 }
629