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