2 * Routines for OUCH 4.x protocol dissection
3 * Copyright (C) 2013, 2015, 2016 David Arnold <d@0x1.org>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 /* OUCH is a stock exchange order entry protocol published and used by
13 * NASDAQ. This dissector supports versions 4.x, which differ from
14 * earlier versions by adopting binary encoding for numeric values.
16 * OUCH is usually encapsulated within NASDAQ's SoupBinTCP protocol,
17 * running over a TCP connection from the trading application to the
18 * exchange. SOUP provides framing, heartbeats and authentication;
19 * consequently none of these is present in OUCH.
21 * Other exchanges have created order entry protocols very similar to
22 * OUCH, but typically they differ in subtle ways (and continue to
23 * diverge as time progresses) so I have not attempted to dissect
24 * anything other than proper NASDAQ OUCH in this code.
26 * Specifications are available from NASDAQ's website, although the
27 * links to find them tend to move around over time. At the time of
28 * writing, the correct URL is:
30 * http://www.nasdaqtrader.com/content/technicalsupport/specifications/TradingProducts/OUCH4.2.pdf
36 #include <epan/packet.h>
38 void proto_register_ouch(void);
39 void proto_reg_handoff_ouch(void);
41 static const value_string pkt_type_val
[] = {
42 { 'O', "Enter Order" },
43 { 'U', "Replace Order" },
44 { 'X', "Cancel Order" },
45 { 'M', "Modify Order" },
46 { 'S', "System Event" },
48 { 'R', "Replaced" }, /* 'U' on the wire, but use 'R' to disambiguate */
50 { 'D', "AIQ Canceled" },
52 { 'F', "Trade Correction" },
53 { 'G', "Executed with Reference Price" },
54 { 'B', "Broken Trade" },
55 { 'K', "Price Correction" },
57 { 'P', "Cancel Pending" },
58 { 'I', "Cancel Reject" },
59 { 'T', "Order Priority Update" },
60 { 'm', "Order Modified" }, /* 'M' on the wire; 'm' to disambiguate */
65 static const value_string ouch_bbo_weight_indicator_val
[] = {
69 { '3', "Greater than 2%" },
70 { ' ', "Unspecified" },
71 { 'S', "Sets the QBBO while joining the NBBO" },
72 { 'N', "Improves the NBBO upon entry" },
76 static const value_string ouch_broken_trade_reason_val
[] = {
79 { 'S', "Supervisory" },
84 static const value_string ouch_buy_sell_indicator_val
[] = {
86 { 'S', "Sell Order" },
87 { 'T', "Sell Short" },
88 { 'E', "Sell Short Exempt" },
92 static const value_string ouch_cancel_reason_val
[] = {
93 { 'C', "Cross cancel" },
94 { 'D', "Regulatory restriction" },
97 { 'I', "Immediate or Cancel order" },
98 { 'K', "Market Collars" },
99 { 'Q', "Self-match prevention" },
100 { 'S', "Supervisory" },
102 { 'U', "User requested cancel" },
103 { 'X', "Open Protection" },
104 { 'Z', "System cancel" },
108 static const value_string ouch_capacity_val
[] = {
111 { 'P', "Principal" },
116 static const value_string ouch_cross_type_val
[] = {
118 { 'O', "Opening Cross" },
119 { 'C', "Closing Cross" },
120 { 'I', "Intra-day Cross" }, /* Seems to have been removed */
121 { 'H', "Halt/IPO Cross" },
122 { 'R', "Retail" }, /* Not in 4.0 */
123 { 'S', "Supplemental Order" },
128 static const value_string ouch_customer_type_val
[] = {
129 { 'R', "Retail designated order" },
130 { 'N', "Not a retail designated order" },
131 { ' ', "Default configured for port" },
135 static const value_string ouch_display_val
[] = {
136 { 'A', "Attributable-Price to Display" },
137 { 'I', "Imbalance-Only" },
138 { 'L', "Post-Only and Attributable - Price to Display" },
139 { 'M', "Mid-Point Peg" },
140 { 'N', "Non-Display" },
141 { 'O', "Retail Order Type 1" }, /* Not in 4.0 */
142 { 'P', "Post-Only" },
143 { 'Q', "Retail Price Improvement Order" }, /* Not in 4.0 */
144 { 'R', "Round-Lot Only" }, /* Seems to have been removed? */
145 { 'T', "Retail Order Type 2" }, /* Not in 4.0 */
146 { 'W', "Mid-point Peg Post Only" },
147 { 'Y', "Anonymous-Price to Comply" },
148 { 'Z', "Entered as displayed bu changed to non-displayed "
149 "(Priced to comply)" }, /* New in 4.2 */
153 static const value_string ouch_event_code_val
[] = {
154 { 'S', "Start of Day" },
155 { 'E', "End of Day" },
159 static const value_string ouch_iso_eligibility_val
[] = {
161 { 'N', "Not eligible" },
165 static const value_string ouch_liquidity_flag_val
[] = {
166 { '0', "Supplemental Order Execution" },
167 { '4', "Added displayed liquidity in a Group A Symbol" },
168 { '5', "Added non-displayed liquidity in a Group A Symbol" },
169 { '6', "Removed liquidity in a Group A Symbol" },
170 { '7', "Displayed, liquidity-adding order improves the NBBO" },
171 { '8', "Displayed, liquidity-adding order sets the QBBO while joining the NBBO" },
173 { 'C', "Closing Cross" },
174 { 'H', "Halt/IPO Cross" },
175 { 'I', "Intraday/Post-Market Cross" }, /* Seems to have been removed */
176 { 'J', "Non-displayed adding liquidity" },
177 { 'K', "Halt Cross" },
178 { 'L', "Closing Cross (imbalance-only)" },
179 { 'M', "Opening Cross (imbalance-only)" },
180 { 'N', "Halt Cross, orders entered in pilot symbols during the LULD Trading Pause" },
181 { 'O', "Opening Cross" },
183 { 'W', "Added post-only" }, /* Removed 4.2 2013/02/05 */
184 { 'a', "Added displayed liquidity in a SCIP Symbol" },
185 { 'b', "Displayed, liquidity-adding order improves the NBBO in pilot symbol during specified LULD Pricing Pilot timeframe" },
186 { 'c', "Added displayed liquidity in a pilot symbol during specified LULD Pricing Pilot timeframe" },
187 { 'd', "Retail designated execution that removed liquidity" },
188 { 'e', "Retail designated execution that added displayed liquidity" },
189 { 'f', "Retail designated execution that added non-displayed liquidity" },
190 { 'g', "Added non-displayed mid-point liquidity in a Group A Symbol" },
191 { 'h', "Removed liquidity in a pilot symbol during specified LULD Pricing Pilot timeframe" },
192 { 'j', "RPI (Retail Price Improving) order provides liquidity" },
193 { 'k', "Added liquidity via a midpoint order" },
194 { 'm', "Removed liquidity at a midpoint" },
195 { 'r', "Retail Order removes RPI liquidity" },
196 { 't', "Retail Order removes price improving non-displayed liquidity other than RPI liquidity" },
197 { 'x', "Displayed, liquidity-adding order improves the NBBO in a SCIP Symbol" },
198 { 'y', "Displayed, liquidity-adding order set the QBBO while joining the NBBO in a SCIP Symbol" },
202 static const value_string ouch_order_state_val
[] = {
203 { 'L', "Order Live" },
204 { 'D', "Order Dead" },
208 static const value_string ouch_price_correction_reason_val
[] = {
209 { 'E', "Erroneous" },
211 { 'S', "Supervisory" },
216 static const value_string ouch_reference_price_type_val
[] = {
217 { 'I', "Intraday Indicative Value" },
221 static const value_string ouch_reject_reason_val
[] = {
222 { 'T', "Test Mode" },
224 { 'Z', "Shares exceeds configured safety threshold" },
225 { 'S', "Invalid Stock" },
226 { 'D', "Invalid Display Type" },
227 { 'C', "NASDAQ is Closed" },
228 { 'L', "Requested firm not authorized for requested clearing "
229 "type on this account" },
230 { 'M', "Outside of permitted times for requested clearing type" },
231 { 'R', "This order is not allowed in this type of cross" },
232 { 'X', "Invalid Price" },
233 { 'N', "Invalid Minimum Quantity" },
235 { 'W', "Invalid Mid-point Post Only Price" },
236 { 'a', "Reject All enabled" },
237 { 'b', "Easy to Borrow (ETB) reject" },
238 { 'c', "Restricted symbol list reject" },
239 { 'd', "ISO order restriction" },
240 { 'e', "Odd lot order restriction" },
241 { 'f', "Mid-Point order restriction" },
242 { 'g', "Pre-market order restriction" },
243 { 'h', "Post-market order restriction" },
244 { 'i', "Short sale order restriction" },
245 { 'j', "On Open order restriction" },
246 { 'k', "On Close order restriction" },
247 { 'l', "Two sided quote reject" },
248 { 'm', "Exceeded shares limit" },
249 { 'n', "Exceeded dollar value limit" },
253 static const value_string ouch_trade_correction_reason_val
[] = {
254 { 'N', "Adjusted to NAV" },
259 /* Initialize the protocol and registered fields */
260 static int proto_ouch
;
261 static dissector_handle_t ouch_handle
;
263 /* Initialize the subtree pointers */
266 static int hf_ouch_bbo_weight_indicator
;
267 static int hf_ouch_broken_trade_reason
;
268 static int hf_ouch_buy_sell_indicator
;
269 static int hf_ouch_cancel_reason
;
270 static int hf_ouch_capacity
;
271 static int hf_ouch_cross_type
;
272 static int hf_ouch_customer_type
;
273 static int hf_ouch_decrement_shares
;
274 static int hf_ouch_display
;
275 static int hf_ouch_event_code
;
276 static int hf_ouch_executed_shares
;
277 static int hf_ouch_execution_price
;
278 static int hf_ouch_existing_order_token
;
279 static int hf_ouch_firm
;
280 static int hf_ouch_iso_eligible
;
281 static int hf_ouch_liquidity_flag
;
282 static int hf_ouch_match_number
;
283 static int hf_ouch_message
;
284 static int hf_ouch_min_quantity
;
285 static int hf_ouch_new_execution_price
;
286 static int hf_ouch_order_reference_number
;
287 static int hf_ouch_order_state
;
288 static int hf_ouch_order_token
;
289 static int hf_ouch_packet_type
;
290 static int hf_ouch_previous_order_token
;
291 static int hf_ouch_price
;
292 static int hf_ouch_price_correction_reason
;
293 static int hf_ouch_quantity_prevented_from_trading
;
294 static int hf_ouch_reference_price
;
295 static int hf_ouch_reference_price_type
;
296 static int hf_ouch_reject_reason
;
297 static int hf_ouch_replacement_order_token
;
298 static int hf_ouch_shares
;
299 static int hf_ouch_stock
;
300 static int hf_ouch_tif
;
301 static int hf_ouch_timestamp
;
302 static int hf_ouch_trade_correction_reason
;
305 /** Format an OUCH timestamp into a useful string
307 * We use this function rather than a BASE_CUSTOM formatter because
308 * BASE_CUSTOM doesn't support passing a 64-bit value to the
309 * formatting function. */
311 ouch_tree_add_timestamp(
318 uint64_t ts
= tvb_get_ntoh64(tvb
, offset
);
319 char *buf
= (char *)wmem_alloc(pinfo
->pool
, ITEM_LABEL_LENGTH
);
320 uint32_t tmp
, hours
, mins
, secs
, nsecs
;
322 nsecs
= (uint32_t)(ts
% UINT64_C(1000000000));
323 tmp
= (uint32_t)(ts
/ UINT64_C(1000000000));
326 mins
= (tmp
% 3600) / 60;
329 snprintf(buf
, ITEM_LABEL_LENGTH
,
331 hours
, mins
, secs
, nsecs
);
333 proto_tree_add_string(tree
, hf
, tvb
, offset
, 8, buf
);
336 /** BASE_CUSTOM formatter for prices
338 * OUCH prices are integers, with four implicit decimal places. So we
339 * insert the decimal point, and add a leading dollar sign as well. */
345 if (value
== 0x7fffffff) {
346 snprintf(buf
, ITEM_LABEL_LENGTH
, "%s", "Market");
348 snprintf(buf
, ITEM_LABEL_LENGTH
,
350 value
/ 10000, value
% 10000);
354 /** BASE_CUSTOM formatter for reference price type code
356 * Displays the code value as a character, not its ASCII value, as
357 * would be done by BASE_DEC and friends. */
359 format_reference_price_type(
363 snprintf(buf
, ITEM_LABEL_LENGTH
,
365 val_to_str_const(value
,
366 ouch_reference_price_type_val
,
371 /** BASE_CUSTOM formatter for the Time In Force (TIF) code
373 * There are three reserved values for the TIF: 0, 99998 and 99999.
374 * These are trapped and displayed as an appropriate string. All
375 * other values are printed as a duration in hours, minutes and
388 snprintf(buf
, ITEM_LABEL_LENGTH
, "Immediate Or Cancel (%u)", value
);
392 snprintf(buf
, ITEM_LABEL_LENGTH
, "Market Hours (%u)", value
);
396 snprintf(buf
, ITEM_LABEL_LENGTH
, "System Hours (%u)", value
);
400 hours
= value
/ 3600;
401 mins
= (value
% 3600) / 60;
404 snprintf(buf
, ITEM_LABEL_LENGTH
,
405 "%uh %02um %02us (%u seconds)",
421 proto_tree
*ouch_tree
= NULL
;
422 const char *pkt_name
;
423 uint16_t reported_len
;
427 /* Get the OUCH message type value */
428 pkt_type
= tvb_get_uint8(tvb
, offset
);
429 reported_len
= tvb_reported_length(tvb
);
431 /* OUCH has two messages with the same code: Replace Order and
432 * Replaced. It's possible to tell which is which because clients
433 * send the Replace Order, and NASDAQ sends Replaced replies.
434 * Nonetheless, this complicates the switch, so instead we
435 * distinguish between them by length, and use 'R' for Replaced
436 * (like XPRS does). */
437 if (pkt_type
== 'U' && (reported_len
== 79 || reported_len
== 80)) {
441 /* OUCH has two messages with the same code: Modify Order and
442 * Modified. Again, one is sent by clients, the other sent by
443 * NASDAQ. We change Modified to 'm' for simplicity in the
445 if (pkt_type
== 'M' && reported_len
== 28) {
449 /* Since we use the packet name a few times, get and save that value */
450 pkt_name
= val_to_str(pkt_type
, pkt_type_val
, "Unknown (%u)");
452 /* Set the protocol name in the summary display */
453 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "OUCH");
455 /* Set the packet name in the info column */
456 col_add_str(pinfo
->cinfo
, COL_INFO
, pkt_name
);
459 /* Create a sub-tree for the OUCH packet details */
460 ti
= proto_tree_add_item(tree
,
464 ouch_tree
= proto_item_add_subtree(ti
, ett_ouch
);
466 /* Append the packet name to the sub-tree item */
467 proto_item_append_text(ti
, ", %s", pkt_name
);
469 /* Packet type (using the cooked value). */
470 proto_tree_add_item(ouch_tree
, hf_ouch_packet_type
,
471 tvb
, offset
, 1, ENC_ASCII
|ENC_NA
);
475 case 'O': /* Enter Order */
476 proto_tree_add_item(ouch_tree
,
482 proto_tree_add_item(ouch_tree
,
483 hf_ouch_buy_sell_indicator
,
488 proto_tree_add_item(ouch_tree
,
494 proto_tree_add_item(ouch_tree
,
500 proto_tree_add_item(ouch_tree
,
506 proto_tree_add_item(ouch_tree
,
512 proto_tree_add_item(ouch_tree
,
518 proto_tree_add_item(ouch_tree
,
524 proto_tree_add_item(ouch_tree
,
530 proto_tree_add_item(ouch_tree
,
531 hf_ouch_iso_eligible
,
536 proto_tree_add_item(ouch_tree
,
537 hf_ouch_min_quantity
,
542 proto_tree_add_item(ouch_tree
,
548 if (reported_len
>= 49) { /* Added in 4.1 */
549 proto_tree_add_item(ouch_tree
,
550 hf_ouch_customer_type
,
557 case 'A': /* Accepted */
558 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
563 proto_tree_add_item(ouch_tree
,
569 proto_tree_add_item(ouch_tree
,
570 hf_ouch_buy_sell_indicator
,
575 proto_tree_add_item(ouch_tree
,
581 proto_tree_add_item(ouch_tree
,
587 proto_tree_add_item(ouch_tree
,
593 proto_tree_add_item(ouch_tree
,
599 proto_tree_add_item(ouch_tree
,
605 proto_tree_add_item(ouch_tree
,
611 proto_tree_add_item(ouch_tree
,
612 hf_ouch_order_reference_number
,
617 proto_tree_add_item(ouch_tree
,
623 proto_tree_add_item(ouch_tree
,
624 hf_ouch_iso_eligible
,
629 proto_tree_add_item(ouch_tree
,
630 hf_ouch_min_quantity
,
635 proto_tree_add_item(ouch_tree
,
641 proto_tree_add_item(ouch_tree
,
647 if (reported_len
>= 66) { /* Added in 4.2 */
648 proto_tree_add_item(ouch_tree
,
649 hf_ouch_bbo_weight_indicator
,
656 case 'U': /* Replace Order */
657 proto_tree_add_item(ouch_tree
,
658 hf_ouch_existing_order_token
,
663 proto_tree_add_item(ouch_tree
,
664 hf_ouch_replacement_order_token
,
669 proto_tree_add_item(ouch_tree
,
675 proto_tree_add_item(ouch_tree
,
681 proto_tree_add_item(ouch_tree
,
687 proto_tree_add_item(ouch_tree
,
693 proto_tree_add_item(ouch_tree
,
694 hf_ouch_iso_eligible
,
699 proto_tree_add_item(ouch_tree
,
700 hf_ouch_min_quantity
,
706 case 'X': /* Cancel Order */
707 proto_tree_add_item(ouch_tree
,
713 proto_tree_add_item(ouch_tree
,
720 case 'M': /* Modify Order (from 4.2 onwards) */
721 proto_tree_add_item(ouch_tree
,
727 proto_tree_add_item(ouch_tree
,
728 hf_ouch_buy_sell_indicator
,
733 proto_tree_add_item(ouch_tree
,
740 case 'S': /* System Event */
741 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
746 proto_tree_add_item(ouch_tree
,
753 case 'R': /* Replaced */
754 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
759 proto_tree_add_item(ouch_tree
,
760 hf_ouch_replacement_order_token
,
765 proto_tree_add_item(ouch_tree
,
766 hf_ouch_buy_sell_indicator
,
771 proto_tree_add_item(ouch_tree
,
777 proto_tree_add_item(ouch_tree
,
783 proto_tree_add_item(ouch_tree
,
789 proto_tree_add_item(ouch_tree
,
795 proto_tree_add_item(ouch_tree
,
801 proto_tree_add_item(ouch_tree
,
807 proto_tree_add_item(ouch_tree
,
808 hf_ouch_order_reference_number
,
813 proto_tree_add_item(ouch_tree
,
819 proto_tree_add_item(ouch_tree
,
820 hf_ouch_iso_eligible
,
825 proto_tree_add_item(ouch_tree
,
826 hf_ouch_min_quantity
,
831 proto_tree_add_item(ouch_tree
,
837 proto_tree_add_item(ouch_tree
,
843 proto_tree_add_item(ouch_tree
,
844 hf_ouch_previous_order_token
,
849 if (reported_len
>= 80) { /* Added in 4.2 */
850 proto_tree_add_item(ouch_tree
,
851 hf_ouch_bbo_weight_indicator
,
858 case 'C': /* Canceled */
859 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
864 proto_tree_add_item(ouch_tree
,
870 proto_tree_add_item(ouch_tree
,
871 hf_ouch_decrement_shares
,
876 proto_tree_add_item(ouch_tree
,
877 hf_ouch_cancel_reason
,
883 case 'D': /* AIQ Canceled */
884 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
889 proto_tree_add_item(ouch_tree
,
895 proto_tree_add_item(ouch_tree
,
896 hf_ouch_decrement_shares
,
901 proto_tree_add_item(ouch_tree
,
902 hf_ouch_cancel_reason
,
907 proto_tree_add_item(ouch_tree
,
908 hf_ouch_quantity_prevented_from_trading
,
913 proto_tree_add_item(ouch_tree
,
914 hf_ouch_execution_price
,
919 proto_tree_add_item(ouch_tree
,
920 hf_ouch_liquidity_flag
,
926 case 'E': /* Executed */
927 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
932 proto_tree_add_item(ouch_tree
,
938 proto_tree_add_item(ouch_tree
,
939 hf_ouch_executed_shares
,
944 proto_tree_add_item(ouch_tree
,
945 hf_ouch_execution_price
,
950 proto_tree_add_item(ouch_tree
,
951 hf_ouch_liquidity_flag
,
956 proto_tree_add_item(ouch_tree
,
957 hf_ouch_match_number
,
963 case 'B': /* Broken Trade */
964 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
969 proto_tree_add_item(ouch_tree
,
975 proto_tree_add_item(ouch_tree
,
976 hf_ouch_match_number
,
981 proto_tree_add_item(ouch_tree
,
982 hf_ouch_broken_trade_reason
,
988 case 'F': /* Trade Correction (4.2 onwards) */
989 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
994 proto_tree_add_item(ouch_tree
,
1000 proto_tree_add_item(ouch_tree
,
1001 hf_ouch_executed_shares
,
1006 proto_tree_add_item(ouch_tree
,
1007 hf_ouch_execution_price
,
1012 proto_tree_add_item(ouch_tree
,
1013 hf_ouch_liquidity_flag
,
1018 proto_tree_add_item(ouch_tree
,
1019 hf_ouch_match_number
,
1024 proto_tree_add_item(ouch_tree
,
1025 hf_ouch_trade_correction_reason
,
1031 case 'G': /* Executed with Reference Price (4.2 onwards) */
1032 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
1037 proto_tree_add_item(ouch_tree
,
1038 hf_ouch_order_token
,
1043 proto_tree_add_item(ouch_tree
,
1044 hf_ouch_executed_shares
,
1049 proto_tree_add_item(ouch_tree
,
1050 hf_ouch_execution_price
,
1055 proto_tree_add_item(ouch_tree
,
1056 hf_ouch_liquidity_flag
,
1061 proto_tree_add_item(ouch_tree
,
1062 hf_ouch_match_number
,
1067 proto_tree_add_item(ouch_tree
,
1068 hf_ouch_reference_price
,
1073 proto_tree_add_item(ouch_tree
,
1074 hf_ouch_reference_price_type
,
1080 case 'K': /* Price Correction */
1081 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
1086 proto_tree_add_item(ouch_tree
,
1087 hf_ouch_order_token
,
1092 proto_tree_add_item(ouch_tree
,
1093 hf_ouch_match_number
,
1098 proto_tree_add_item(ouch_tree
,
1099 hf_ouch_new_execution_price
,
1104 proto_tree_add_item(ouch_tree
,
1105 hf_ouch_price_correction_reason
,
1111 case 'J': /* Rejected Order */
1112 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
1117 proto_tree_add_item(ouch_tree
,
1118 hf_ouch_order_token
,
1123 proto_tree_add_item(ouch_tree
,
1124 hf_ouch_reject_reason
,
1130 case 'P': /* Cancel Pending */
1131 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
1136 proto_tree_add_item(ouch_tree
,
1137 hf_ouch_order_token
,
1143 case 'I': /* Cancel Reject */
1144 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
1149 proto_tree_add_item(ouch_tree
,
1150 hf_ouch_order_token
,
1156 case 'T': /* Order Priority Update (4.2 onwards) */
1157 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
1162 proto_tree_add_item(ouch_tree
,
1163 hf_ouch_order_token
,
1168 proto_tree_add_item(ouch_tree
,
1174 proto_tree_add_item(ouch_tree
,
1180 proto_tree_add_item(ouch_tree
,
1181 hf_ouch_order_reference_number
,
1187 case 'm': /* Order Modified (4.2 onwards) */
1188 ouch_tree_add_timestamp(pinfo
, ouch_tree
,
1193 proto_tree_add_item(ouch_tree
,
1194 hf_ouch_order_token
,
1199 proto_tree_add_item(ouch_tree
,
1200 hf_ouch_buy_sell_indicator
,
1205 proto_tree_add_item(ouch_tree
,
1214 proto_tree_add_item(tree
,
1216 tvb
, offset
, -1, ENC_NA
);
1217 offset
+= reported_len
- 1;
1225 /** Returns a guess if a packet is OUCH or not
1227 * Since SOUP doesn't have a sub-protocol type flag, we have to use a
1228 * heuristic decision to determine if the contained protocol is OUCH
1229 * or ITCH (or something else entirely). We look at the message type
1230 * code, and since we know that we're being called from SOUP, we can
1231 * check the passed-in length too: if the type code and the length
1232 * match, we guess at OUCH. */
1240 uint8_t msg_type
= tvb_get_uint8(tvb
, 0);
1241 unsigned msg_len
= tvb_reported_length(tvb
);
1244 case 'O': /* Enter order (with or without optional customer type) */
1245 if (msg_len
!= 48 && msg_len
!= 49) {
1250 case 'U': /* Replace order or Replaced (4.0, 4.1) or Replaced (4.2) */
1251 if (msg_len
!= 47 && msg_len
!= 79 && msg_len
!= 80) {
1256 case 'X': /* Cancel order */
1257 if (msg_len
!= 19) {
1262 case 'M': /* Modify Order or Order Modified (added 4.2) */
1263 if (msg_len
!= 20 && msg_len
!= 28) {
1268 case 'S': /* System event */
1269 if (msg_len
!= 10) {
1274 case 'A': /* Accepted */
1275 if (msg_len
!= 65 && msg_len
!= 66) {
1280 case 'C': /* Canceled */
1281 if (msg_len
!= 28) {
1286 case 'D': /* AIQ Canceled */
1287 if (msg_len
!= 37) {
1291 case 'E': /* Executed */
1292 if (msg_len
!= 40) {
1297 case 'F': /* Trade Correction */
1298 if (msg_len
!= 41) {
1303 case 'G': /* Executed with Reference Price */
1304 if (msg_len
!= 45) {
1309 case 'B': /* Broken Trade */
1310 if (msg_len
!= 32) {
1315 case 'K': /* Correction */
1316 if (msg_len
!= 36) {
1321 case 'J': /* Rejected */
1322 if (msg_len
!= 24) {
1327 case 'P': /* Cancel Pending */
1328 if (msg_len
!= 23) {
1333 case 'I': /* Cancel Reject */
1334 if (msg_len
!= 23) {
1339 case 'T': /* Order Priority Update */
1340 if (msg_len
!= 36) {
1346 /* Not a known OUCH message code */
1350 /* Perform dissection of this (initial) packet */
1351 dissect_ouch(tvb
, pinfo
, tree
, NULL
);
1358 proto_register_ouch(void)
1360 /* Setup list of header fields See Section 1.6.1 for details*/
1361 static hf_register_info hf
[] = {
1363 { &hf_ouch_bbo_weight_indicator
,
1364 { "BBO Weight Indicator", "ouch.bbo_weight_indicator",
1365 FT_CHAR
, BASE_HEX
, VALS(ouch_bbo_weight_indicator_val
), 0x0,
1368 { &hf_ouch_broken_trade_reason
,
1369 { "Broken Trade Reason", "ouch.broken_trade_reason",
1370 FT_CHAR
, BASE_HEX
, VALS(ouch_broken_trade_reason_val
), 0x0,
1373 { &hf_ouch_buy_sell_indicator
,
1374 { "Buy/Sell Indicator", "ouch.buy_sell_indicator",
1375 FT_CHAR
, BASE_HEX
, VALS(ouch_buy_sell_indicator_val
), 0x0,
1378 { &hf_ouch_cancel_reason
,
1379 { "Cancel Reason", "ouch.cancel_reason",
1380 FT_CHAR
, BASE_HEX
, VALS(ouch_cancel_reason_val
), 0x0,
1383 { &hf_ouch_capacity
,
1384 { "Capacity", "ouch.capacity",
1385 FT_CHAR
, BASE_HEX
, VALS(ouch_capacity_val
), 0x0,
1388 { &hf_ouch_cross_type
,
1389 { "Cross Type", "ouch.cross_type",
1390 FT_CHAR
, BASE_HEX
, VALS(ouch_cross_type_val
), 0x0,
1393 { &hf_ouch_customer_type
,
1394 { "Customer Type", "ouch.customer_type",
1395 FT_CHAR
, BASE_HEX
, VALS(ouch_customer_type_val
), 0x0,
1398 { &hf_ouch_decrement_shares
,
1399 { "Decrement Shares", "ouch.decrement_shares",
1400 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1404 { "Display", "ouch.display",
1405 FT_CHAR
, BASE_HEX
, VALS(ouch_display_val
), 0x0,
1408 { &hf_ouch_event_code
,
1409 { "Event Code", "ouch.event_code",
1410 FT_CHAR
, BASE_HEX
, VALS(ouch_event_code_val
), 0x0,
1413 { &hf_ouch_executed_shares
,
1414 { "Executed Shares", "ouch.executed_shares",
1415 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1418 { &hf_ouch_execution_price
,
1419 { "Execution Price", "ouch.execution_price",
1420 FT_UINT32
, BASE_CUSTOM
, CF_FUNC(format_price
), 0x0,
1423 { &hf_ouch_existing_order_token
,
1424 { "Existing Order Token", "ouch.existing_order_token",
1425 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1429 { "Firm", "ouch.firm",
1430 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1433 { &hf_ouch_iso_eligible
,
1434 { "Intermarket Sweep Eligibility", "ouch.iso_eligible",
1435 FT_CHAR
, BASE_HEX
, VALS(ouch_iso_eligibility_val
), 0x0,
1438 { &hf_ouch_liquidity_flag
,
1439 { "Liquidity Flag", "ouch.liquidity_flag",
1440 FT_CHAR
, BASE_HEX
, VALS(ouch_liquidity_flag_val
), 0x0,
1443 { &hf_ouch_match_number
,
1444 { "Match Number", "ouch.match_number",
1445 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
1449 { "Unknown Message", "ouch.unknown_message",
1450 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1453 { &hf_ouch_min_quantity
,
1454 { "Minimum Quantity", "ouch.min_quantity",
1455 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1458 { &hf_ouch_new_execution_price
,
1459 { "New Execution Price", "ouch.new_execution_price",
1460 FT_UINT32
, BASE_CUSTOM
, CF_FUNC(format_price
), 0x0,
1463 { &hf_ouch_order_reference_number
,
1464 { "Order Reference Number", "ouch.order_reference_number",
1465 FT_UINT64
, BASE_DEC
, NULL
, 0x0,
1468 { &hf_ouch_order_state
,
1469 { "Order State", "ouch.order_state",
1470 FT_CHAR
, BASE_HEX
, VALS(ouch_order_state_val
), 0x0,
1473 { &hf_ouch_order_token
,
1474 { "Order Token", "ouch.order_token",
1475 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1478 { &hf_ouch_packet_type
,
1479 { "Packet Type", "ouch.packet_type",
1480 FT_CHAR
, BASE_HEX
, VALS(pkt_type_val
), 0x0,
1483 { &hf_ouch_previous_order_token
,
1484 { "Previous Order Token", "ouch.previous_order_token",
1485 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1489 { "Price", "ouch.price",
1490 FT_UINT32
, BASE_CUSTOM
, CF_FUNC(format_price
), 0x0,
1493 { &hf_ouch_price_correction_reason
,
1494 { "Price Correction Reason", "ouch.price_correction_reason",
1495 FT_CHAR
, BASE_HEX
, VALS(ouch_price_correction_reason_val
), 0x0,
1498 { &hf_ouch_quantity_prevented_from_trading
,
1499 { "Quantity Prevented from Trading",
1500 "ouch.quantity_prevented_from_trading",
1501 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1504 { &hf_ouch_reference_price
,
1505 { "Reference Price", "ouch.reference_price",
1506 FT_UINT32
, BASE_CUSTOM
, CF_FUNC(format_price
), 0x0,
1509 { &hf_ouch_reference_price_type
,
1510 { "Reference Price Type", "ouch.reference_price_type",
1511 FT_UINT32
, BASE_CUSTOM
, CF_FUNC(format_reference_price_type
), 0x0,
1514 { &hf_ouch_reject_reason
,
1515 { "Reject Reason", "ouch.reject_reason",
1516 FT_CHAR
, BASE_HEX
, VALS(ouch_reject_reason_val
), 0x0,
1519 { &hf_ouch_replacement_order_token
,
1520 { "Replacement Order Token", "ouch.replacement_order_token",
1521 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1525 { "Shares", "ouch.shares",
1526 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
1530 { "Stock", "ouch.stock",
1531 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1535 { "Time In Force", "ouch.tif",
1536 FT_UINT32
, BASE_CUSTOM
, CF_FUNC(format_tif
), 0x0,
1539 { &hf_ouch_timestamp
,
1540 { "Timestamp", "ouch.timestamp",
1541 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1544 { &hf_ouch_trade_correction_reason
,
1545 { "Trade Correction Reason", "ouch.trade_correction_reason",
1546 FT_CHAR
, BASE_HEX
, VALS(ouch_trade_correction_reason_val
), 0x0,
1550 /* Setup protocol subtree array */
1551 static int *ett
[] = {
1555 /* Register the protocol name and description */
1556 proto_ouch
= proto_register_protocol("OUCH", "OUCH", "ouch");
1558 /* Required function calls to register the header fields and
1560 proto_register_field_array(proto_ouch
, hf
, array_length(hf
));
1561 proto_register_subtree_array(ett
, array_length(ett
));
1563 /* Register the dissector */
1564 ouch_handle
= register_dissector("ouch", dissect_ouch
, proto_ouch
);
1568 /* If this dissector uses sub-dissector registration add a
1569 * registration routine. This format is required because a script is
1570 * used to find these routines and create the code that calls these
1573 proto_reg_handoff_ouch(void)
1575 heur_dissector_add("soupbintcp", dissect_ouch_heur
, "OUCH over SoupBinTCP", "ouch_soupbintcp", proto_ouch
, HEURISTIC_ENABLE
);
1576 dissector_add_uint_range_with_preference("tcp.port", "", ouch_handle
);
1582 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1587 * indent-tabs-mode: nil
1590 * vi: set shiftwidth=4 tabstop=8 expandtab:
1591 * :indentSize=4:tabSize=8:noTabs=true: