Coverage Report

Created: 2026-01-02 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-ouch.c
Line
Count
Source
1
/* packet-ouch.c
2
 * Routines for OUCH 4.x protocol dissection
3
 * Copyright (C) 2013, 2015, 2016 David Arnold <d@0x1.org>
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
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.
15
 *
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.
20
 *
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.
25
 *
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:
29
 *
30
 * http://www.nasdaqtrader.com/content/technicalsupport/specifications/TradingProducts/OUCH4.2.pdf
31
 */
32
33
34
#include "config.h"
35
36
#include <epan/packet.h>
37
38
void proto_register_ouch(void);
39
void proto_reg_handoff_ouch(void);
40
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" },
47
    { 'A', "Accepted" },
48
    { 'R', "Replaced" }, /* 'U' on the wire, but use 'R' to disambiguate */
49
    { 'C', "Canceled" },
50
    { 'D', "AIQ Canceled" },
51
    { 'E', "Executed" },
52
    { 'F', "Trade Correction" },
53
    { 'G', "Executed with Reference Price" },
54
    { 'B', "Broken Trade" },
55
    { 'K', "Price Correction" },
56
    { 'J', "Rejected" },
57
    { 'P', "Cancel Pending" },
58
    { 'I', "Cancel Reject" },
59
    { 'T', "Order Priority Update" },
60
    { 'm', "Order Modified" }, /* 'M' on the wire; 'm' to disambiguate */
61
    { 0, NULL }
62
};
63
64
65
static const value_string ouch_bbo_weight_indicator_val[] = {
66
    { '0', "0 - 0.2%" },
67
    { '1', "0.2 - 1%" },
68
    { '2', "1 - 2%" },
69
    { '3', "Greater than 2%" },
70
    { ' ', "Unspecified" },
71
    { 'S', "Sets the QBBO while joining the NBBO" },
72
    { 'N', "Improves the NBBO upon entry" },
73
    { 0, NULL }
74
};
75
76
static const value_string ouch_broken_trade_reason_val[] = {
77
    { 'E', "Erroneous" },
78
    { 'C', "Consent" },
79
    { 'S', "Supervisory" },
80
    { 'X', "External" },
81
    { 0, NULL }
82
};
83
84
static const value_string ouch_buy_sell_indicator_val[] = {
85
    { 'B', "Buy Order" },
86
    { 'S', "Sell Order" },
87
    { 'T', "Sell Short" },
88
    { 'E', "Sell Short Exempt" },
89
    { 0, NULL }
90
};
91
92
static const value_string ouch_cancel_reason_val[] = {
93
    { 'C', "Cross cancel" },
94
    { 'D', "Regulatory restriction" },
95
    { 'E', "Closed" },
96
    { 'H', "Halted" },
97
    { 'I', "Immediate or Cancel order" },
98
    { 'K', "Market Collars" },
99
    { 'Q', "Self-match prevention" },
100
    { 'S', "Supervisory" },
101
    { 'T', "Timeout" },
102
    { 'U', "User requested cancel" },
103
    { 'X', "Open Protection" },
104
    { 'Z', "System cancel" },
105
    { 0, NULL }
106
};
107
108
static const value_string ouch_capacity_val[] = {
109
    { 'A', "Agency" },
110
    { 'O', "Other" },
111
    { 'P', "Principal" },
112
    { 'R', "Riskless" },
113
    { 0, NULL }
114
};
115
116
static const value_string ouch_cross_type_val[] = {
117
    { 'N', "No Cross" },
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" },
124
    { 0, NULL }
125
};
126
127
/* Not in 4.0 */
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" },
132
    { 0, NULL }
133
};
134
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 */
150
    { 0, NULL}
151
};
152
153
static const value_string ouch_event_code_val[] = {
154
    { 'S', "Start of Day" },
155
    { 'E', "End of Day" },
156
    { 0, NULL}
157
};
158
159
static const value_string ouch_iso_eligibility_val[] = {
160
    { 'Y', "Eligible" },
161
    { 'N', "Not eligible" },
162
    { 0, NULL }
163
};
164
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" },
172
    { 'A', "Added" },
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" },
182
    { 'R', "Removed" },
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" },
199
    { 0, NULL }
200
};
201
202
static const value_string ouch_order_state_val[] = {
203
    { 'L', "Order Live" },
204
    { 'D', "Order Dead" },
205
    { 0, NULL }
206
};
207
208
static const value_string ouch_price_correction_reason_val[] = {
209
    { 'E', "Erroneous" },
210
    { 'C', "Consent" },
211
    { 'S', "Supervisory" },
212
    { 'X', "External" },
213
    { 0, NULL }
214
};
215
216
static const value_string ouch_reference_price_type_val[] = {
217
    { 'I', "Intraday Indicative Value" },
218
    { 0, NULL }
219
};
220
221
static const value_string ouch_reject_reason_val[] = {
222
    { 'T', "Test Mode" },
223
    { 'H', "Halted" },
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" },
234
    { 'O', "Other" },
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" },
250
    { 0, NULL}
251
};
252
253
static const value_string ouch_trade_correction_reason_val[] = {
254
    { 'N', "Adjusted to NAV" },
255
    { 0, NULL }
256
};
257
258
259
/* Initialize the protocol and registered fields */
260
static int proto_ouch;
261
static dissector_handle_t ouch_handle;
262
263
/* Initialize the subtree pointers */
264
static int ett_ouch;
265
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;
303
304
305
/** Format an OUCH timestamp into a useful string
306
 *
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. */
310
static void
311
ouch_tree_add_timestamp(
312
    packet_info *pinfo,
313
    proto_tree *tree,
314
    const int hf,
315
    tvbuff_t *tvb,
316
    int offset)
317
0
{
318
0
    uint64_t ts = tvb_get_ntoh64(tvb, offset);
319
0
    char *buf = (char *)wmem_alloc(pinfo->pool, ITEM_LABEL_LENGTH);
320
0
    uint32_t tmp, hours, mins, secs, nsecs;
321
322
0
    nsecs = (uint32_t)(ts % UINT64_C(1000000000));
323
0
    tmp = (uint32_t)(ts / UINT64_C(1000000000));
324
325
0
    hours = tmp / 3600;
326
0
    mins = (tmp % 3600) / 60;
327
0
    secs = tmp % 60;
328
329
0
    snprintf(buf, ITEM_LABEL_LENGTH,
330
0
               "%u:%02u:%02u.%09u",
331
0
               hours, mins, secs, nsecs);
332
333
0
    proto_tree_add_string(tree, hf, tvb, offset, 8, buf);
334
0
}
335
336
/** BASE_CUSTOM formatter for prices
337
 *
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. */
340
static void
341
format_price(
342
    char *buf,
343
    uint32_t value)
344
0
{
345
0
    if (value == 0x7fffffff) {
346
0
        snprintf(buf, ITEM_LABEL_LENGTH, "%s", "Market");
347
0
    } else {
348
0
        snprintf(buf, ITEM_LABEL_LENGTH,
349
0
                   "$%u.%04u",
350
0
                   value / 10000, value % 10000);
351
0
    }
352
0
}
353
354
/** BASE_CUSTOM formatter for reference price type code
355
 *
356
 * Displays the code value as a character, not its ASCII value, as
357
 * would be done by BASE_DEC and friends. */
358
static void
359
format_reference_price_type(
360
    char *buf,
361
    uint32_t value)
362
0
{
363
0
    snprintf(buf, ITEM_LABEL_LENGTH,
364
0
               "%s (%c)",
365
0
               val_to_str_const(value,
366
0
                                ouch_reference_price_type_val,
367
0
                                "Unknown"),
368
0
               value);
369
0
}
370
371
/** BASE_CUSTOM formatter for the Time In Force (TIF) code
372
 *
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
376
 * seconds. */
377
static void
378
format_tif(
379
    char *buf,
380
    uint32_t value)
381
0
{
382
0
    uint32_t hours;
383
0
    uint32_t mins;
384
0
    uint32_t secs;
385
386
0
    switch (value) {
387
0
    case 0:
388
0
        snprintf(buf, ITEM_LABEL_LENGTH, "Immediate Or Cancel (%u)", value);
389
0
        break;
390
391
0
    case 99998:
392
0
        snprintf(buf, ITEM_LABEL_LENGTH, "Market Hours (%u)", value);
393
0
        break;
394
395
0
    case 99999:
396
0
        snprintf(buf, ITEM_LABEL_LENGTH, "System Hours (%u)", value);
397
0
        break;
398
399
0
    default:
400
0
        hours = value / 3600;
401
0
        mins = (value % 3600) / 60;
402
0
        secs = value % 60;
403
404
0
        snprintf(buf, ITEM_LABEL_LENGTH,
405
0
                   "%uh %02um %02us (%u seconds)",
406
0
                   hours, mins, secs,
407
0
                   value);
408
0
        break;
409
0
    }
410
0
}
411
412
413
static int
414
dissect_ouch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
415
0
{
416
0
    proto_item *ti;
417
0
    proto_tree *ouch_tree = NULL;
418
0
    const char *pkt_name;
419
0
    uint16_t reported_len;
420
0
    uint8_t pkt_type;
421
0
    int offset = 0;
422
423
    /* Get the OUCH message type value */
424
0
    pkt_type = tvb_get_uint8(tvb, offset);
425
0
    reported_len = tvb_reported_length(tvb);
426
427
    /* OUCH has two messages with the same code: Replace Order and
428
     * Replaced.  It's possible to tell which is which because clients
429
     * send the Replace Order, and NASDAQ sends Replaced replies.
430
     * Nonetheless, this complicates the switch, so instead we
431
     * distinguish between them by length, and use 'R' for Replaced
432
     * (like XPRS does). */
433
0
    if (pkt_type == 'U' && (reported_len == 79 || reported_len == 80)) {
434
0
        pkt_type = 'R';
435
0
    }
436
437
    /* OUCH has two messages with the same code: Modify Order and
438
     * Modified.  Again, one is sent by clients, the other sent by
439
     * NASDAQ.  We change Modified to 'm' for simplicity in the
440
     * switch. */
441
0
    if (pkt_type == 'M' && reported_len == 28) {
442
0
        pkt_type = 'm';
443
0
    }
444
445
    /* Since we use the packet name a few times, get and save that value */
446
0
    pkt_name = val_to_str(pinfo->pool, pkt_type, pkt_type_val, "Unknown (%u)");
447
448
    /* Set the protocol name in the summary display */
449
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "OUCH");
450
451
    /* Set the packet name in the info column */
452
0
    col_add_str(pinfo->cinfo, COL_INFO, pkt_name);
453
454
0
    if (tree) {
455
        /* Create a sub-tree for the OUCH packet details */
456
0
        ti = proto_tree_add_item(tree,
457
0
                                 proto_ouch,
458
0
                                 tvb, 0, -1, ENC_NA);
459
460
0
        ouch_tree = proto_item_add_subtree(ti, ett_ouch);
461
462
        /* Append the packet name to the sub-tree item */
463
0
        proto_item_append_text(ti, ", %s", pkt_name);
464
465
        /* Packet type (using the cooked value). */
466
0
        proto_tree_add_item(ouch_tree, hf_ouch_packet_type,
467
0
                                  tvb, offset, 1, ENC_ASCII);
468
0
        offset += 1;
469
470
0
        switch (pkt_type) {
471
0
        case 'O': /* Enter Order */
472
0
            proto_tree_add_item(ouch_tree,
473
0
                                hf_ouch_order_token,
474
0
                                tvb, offset, 14,
475
0
                                ENC_ASCII);
476
0
            offset += 14;
477
478
0
            proto_tree_add_item(ouch_tree,
479
0
                                hf_ouch_buy_sell_indicator,
480
0
                                tvb, offset, 1,
481
0
                                ENC_ASCII);
482
0
            offset += 1;
483
484
0
            proto_tree_add_item(ouch_tree,
485
0
                                hf_ouch_shares,
486
0
                                tvb, offset, 4,
487
0
                                ENC_BIG_ENDIAN);
488
0
            offset += 4;
489
490
0
            proto_tree_add_item(ouch_tree,
491
0
                                hf_ouch_stock,
492
0
                                tvb, offset, 8,
493
0
                                ENC_ASCII);
494
0
            offset += 8;
495
496
0
            proto_tree_add_item(ouch_tree,
497
0
                                hf_ouch_price,
498
0
                                tvb, offset, 4,
499
0
                                ENC_BIG_ENDIAN);
500
0
            offset += 4;
501
502
0
            proto_tree_add_item(ouch_tree,
503
0
                                hf_ouch_tif,
504
0
                                tvb, offset, 4,
505
0
                                ENC_BIG_ENDIAN);
506
0
            offset += 4;
507
508
0
            proto_tree_add_item(ouch_tree,
509
0
                                hf_ouch_firm,
510
0
                                tvb, offset, 4,
511
0
                                ENC_ASCII);
512
0
            offset += 4;
513
514
0
            proto_tree_add_item(ouch_tree,
515
0
                                hf_ouch_display,
516
0
                                tvb, offset, 1,
517
0
                                ENC_ASCII);
518
0
            offset += 1;
519
520
0
            proto_tree_add_item(ouch_tree,
521
0
                                hf_ouch_capacity,
522
0
                                tvb, offset, 1,
523
0
                                ENC_ASCII);
524
0
            offset += 1;
525
526
0
            proto_tree_add_item(ouch_tree,
527
0
                                hf_ouch_iso_eligible,
528
0
                                tvb, offset, 1,
529
0
                                ENC_ASCII);
530
0
            offset += 1;
531
532
0
            proto_tree_add_item(ouch_tree,
533
0
                                hf_ouch_min_quantity,
534
0
                                tvb, offset, 4,
535
0
                                ENC_BIG_ENDIAN);
536
0
            offset += 4;
537
538
0
            proto_tree_add_item(ouch_tree,
539
0
                                hf_ouch_cross_type,
540
0
                                tvb, offset, 1,
541
0
                                ENC_ASCII);
542
0
            offset += 1;
543
544
0
            if (reported_len >= 49) { /* Added in 4.1 */
545
0
                proto_tree_add_item(ouch_tree,
546
0
                                    hf_ouch_customer_type,
547
0
                                    tvb, offset, 1,
548
0
                                    ENC_ASCII);
549
0
                offset += 1;
550
0
            }
551
0
            break;
552
553
0
        case 'A': /* Accepted */
554
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
555
0
                                    hf_ouch_timestamp,
556
0
                                    tvb, offset);
557
0
            offset += 8;
558
559
0
            proto_tree_add_item(ouch_tree,
560
0
                                hf_ouch_order_token,
561
0
                                tvb, offset, 14,
562
0
                                ENC_ASCII);
563
0
            offset += 14;
564
565
0
            proto_tree_add_item(ouch_tree,
566
0
                                hf_ouch_buy_sell_indicator,
567
0
                                tvb, offset, 1,
568
0
                                ENC_ASCII);
569
0
            offset += 1;
570
571
0
            proto_tree_add_item(ouch_tree,
572
0
                                hf_ouch_shares,
573
0
                                tvb, offset, 4,
574
0
                                ENC_BIG_ENDIAN);
575
0
            offset += 4;
576
577
0
            proto_tree_add_item(ouch_tree,
578
0
                                hf_ouch_stock,
579
0
                                tvb, offset, 8,
580
0
                                ENC_ASCII);
581
0
            offset += 8;
582
583
0
            proto_tree_add_item(ouch_tree,
584
0
                                hf_ouch_price,
585
0
                                tvb, offset, 4,
586
0
                                ENC_BIG_ENDIAN);
587
0
            offset += 4;
588
589
0
            proto_tree_add_item(ouch_tree,
590
0
                                hf_ouch_tif,
591
0
                                tvb, offset, 4,
592
0
                                ENC_BIG_ENDIAN);
593
0
            offset += 4;
594
595
0
            proto_tree_add_item(ouch_tree,
596
0
                                hf_ouch_firm,
597
0
                                tvb, offset, 4,
598
0
                                ENC_ASCII);
599
0
            offset += 4;
600
601
0
            proto_tree_add_item(ouch_tree,
602
0
                                hf_ouch_display,
603
0
                                tvb, offset, 1,
604
0
                                ENC_ASCII);
605
0
            offset += 1;
606
607
0
            proto_tree_add_item(ouch_tree,
608
0
                                hf_ouch_order_reference_number,
609
0
                                tvb, offset, 8,
610
0
                                ENC_BIG_ENDIAN);
611
0
            offset += 8;
612
613
0
            proto_tree_add_item(ouch_tree,
614
0
                                hf_ouch_capacity,
615
0
                                tvb, offset, 1,
616
0
                                ENC_ASCII);
617
0
            offset += 1;
618
619
0
            proto_tree_add_item(ouch_tree,
620
0
                                hf_ouch_iso_eligible,
621
0
                                tvb, offset, 1,
622
0
                                ENC_ASCII);
623
0
            offset += 1;
624
625
0
            proto_tree_add_item(ouch_tree,
626
0
                                hf_ouch_min_quantity,
627
0
                                tvb, offset, 4,
628
0
                                ENC_BIG_ENDIAN);
629
0
            offset += 4;
630
631
0
            proto_tree_add_item(ouch_tree,
632
0
                                hf_ouch_cross_type,
633
0
                                tvb, offset, 1,
634
0
                                ENC_ASCII);
635
0
            offset += 1;
636
637
0
            proto_tree_add_item(ouch_tree,
638
0
                                hf_ouch_order_state,
639
0
                                tvb, offset, 1,
640
0
                                ENC_ASCII);
641
0
            offset += 1;
642
643
0
            if (reported_len >= 66) { /* Added in 4.2 */
644
0
                proto_tree_add_item(ouch_tree,
645
0
                                    hf_ouch_bbo_weight_indicator,
646
0
                                    tvb, offset, 1,
647
0
                                    ENC_ASCII);
648
0
                offset += 1;
649
0
            }
650
0
            break;
651
652
0
        case 'U': /* Replace Order */
653
0
            proto_tree_add_item(ouch_tree,
654
0
                                hf_ouch_existing_order_token,
655
0
                                tvb, offset, 14,
656
0
                                ENC_ASCII);
657
0
            offset += 14;
658
659
0
            proto_tree_add_item(ouch_tree,
660
0
                                hf_ouch_replacement_order_token,
661
0
                                tvb, offset, 14,
662
0
                                ENC_ASCII);
663
0
            offset += 14;
664
665
0
            proto_tree_add_item(ouch_tree,
666
0
                                hf_ouch_shares,
667
0
                                tvb, offset, 4,
668
0
                                ENC_BIG_ENDIAN);
669
0
            offset += 4;
670
671
0
            proto_tree_add_item(ouch_tree,
672
0
                                hf_ouch_price,
673
0
                                tvb, offset, 4,
674
0
                                ENC_BIG_ENDIAN);
675
0
            offset += 4;
676
677
0
            proto_tree_add_item(ouch_tree,
678
0
                                hf_ouch_tif,
679
0
                                tvb, offset, 4,
680
0
                                ENC_BIG_ENDIAN);
681
0
            offset += 4;
682
683
0
            proto_tree_add_item(ouch_tree,
684
0
                                hf_ouch_display,
685
0
                                tvb, offset, 1,
686
0
                                ENC_ASCII);
687
0
            offset += 1;
688
689
0
            proto_tree_add_item(ouch_tree,
690
0
                                hf_ouch_iso_eligible,
691
0
                                tvb, offset, 1,
692
0
                                ENC_ASCII);
693
0
            offset += 1;
694
695
0
            proto_tree_add_item(ouch_tree,
696
0
                                hf_ouch_min_quantity,
697
0
                                tvb, offset, 4,
698
0
                                ENC_BIG_ENDIAN);
699
0
            offset += 4;
700
0
            break;
701
702
0
        case 'X': /* Cancel Order */
703
0
            proto_tree_add_item(ouch_tree,
704
0
                                hf_ouch_order_token,
705
0
                                tvb, offset, 14,
706
0
                                ENC_ASCII);
707
0
            offset += 14;
708
709
0
            proto_tree_add_item(ouch_tree,
710
0
                                hf_ouch_shares,
711
0
                                tvb, offset, 4,
712
0
                                ENC_BIG_ENDIAN);
713
0
            offset += 4;
714
0
            break;
715
716
0
        case 'M': /* Modify Order (from 4.2 onwards) */
717
0
            proto_tree_add_item(ouch_tree,
718
0
                                hf_ouch_order_token,
719
0
                                tvb, offset, 14,
720
0
                                ENC_ASCII);
721
0
            offset += 14;
722
723
0
            proto_tree_add_item(ouch_tree,
724
0
                                hf_ouch_buy_sell_indicator,
725
0
                                tvb, offset, 1,
726
0
                                ENC_ASCII);
727
0
            offset += 1;
728
729
0
            proto_tree_add_item(ouch_tree,
730
0
                                hf_ouch_shares,
731
0
                                tvb, offset, 4,
732
0
                                ENC_BIG_ENDIAN);
733
0
            offset += 4;
734
0
            break;
735
736
0
        case 'S': /* System Event */
737
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
738
0
                                    hf_ouch_timestamp,
739
0
                                    tvb, offset);
740
0
            offset += 8;
741
742
0
            proto_tree_add_item(ouch_tree,
743
0
                                hf_ouch_event_code,
744
0
                                tvb, offset, 1,
745
0
                                ENC_ASCII);
746
0
            offset += 1;
747
0
            break;
748
749
0
        case 'R': /* Replaced */
750
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
751
0
                                    hf_ouch_timestamp,
752
0
                                    tvb, offset);
753
0
            offset += 8;
754
755
0
            proto_tree_add_item(ouch_tree,
756
0
                                hf_ouch_replacement_order_token,
757
0
                                tvb, offset, 14,
758
0
                                ENC_ASCII);
759
0
            offset += 14;
760
761
0
            proto_tree_add_item(ouch_tree,
762
0
                                hf_ouch_buy_sell_indicator,
763
0
                                tvb, offset, 1,
764
0
                                ENC_ASCII);
765
0
            offset += 1;
766
767
0
            proto_tree_add_item(ouch_tree,
768
0
                                hf_ouch_shares,
769
0
                                tvb, offset, 4,
770
0
                                ENC_BIG_ENDIAN);
771
0
            offset += 4;
772
773
0
            proto_tree_add_item(ouch_tree,
774
0
                                hf_ouch_stock,
775
0
                                tvb, offset, 8,
776
0
                                ENC_ASCII);
777
0
            offset += 8;
778
779
0
            proto_tree_add_item(ouch_tree,
780
0
                                hf_ouch_price,
781
0
                                tvb, offset, 4,
782
0
                                ENC_BIG_ENDIAN);
783
0
            offset += 4;
784
785
0
            proto_tree_add_item(ouch_tree,
786
0
                                hf_ouch_tif,
787
0
                                tvb, offset, 4,
788
0
                                ENC_BIG_ENDIAN);
789
0
            offset += 4;
790
791
0
            proto_tree_add_item(ouch_tree,
792
0
                                hf_ouch_firm,
793
0
                                tvb, offset, 4,
794
0
                                ENC_ASCII);
795
0
            offset += 4;
796
797
0
            proto_tree_add_item(ouch_tree,
798
0
                                hf_ouch_display,
799
0
                                tvb, offset, 1,
800
0
                                ENC_ASCII);
801
0
            offset += 1;
802
803
0
            proto_tree_add_item(ouch_tree,
804
0
                                hf_ouch_order_reference_number,
805
0
                                tvb, offset, 8,
806
0
                                ENC_BIG_ENDIAN);
807
0
            offset += 8;
808
809
0
            proto_tree_add_item(ouch_tree,
810
0
                                hf_ouch_capacity,
811
0
                                tvb, offset, 1,
812
0
                                ENC_ASCII);
813
0
            offset += 1;
814
815
0
            proto_tree_add_item(ouch_tree,
816
0
                                hf_ouch_iso_eligible,
817
0
                                tvb, offset, 1,
818
0
                                ENC_ASCII);
819
0
            offset += 1;
820
821
0
            proto_tree_add_item(ouch_tree,
822
0
                                hf_ouch_min_quantity,
823
0
                                tvb, offset, 4,
824
0
                                ENC_BIG_ENDIAN);
825
0
            offset += 4;
826
827
0
            proto_tree_add_item(ouch_tree,
828
0
                                hf_ouch_cross_type,
829
0
                                tvb, offset, 1,
830
0
                                ENC_ASCII);
831
0
            offset += 1;
832
833
0
            proto_tree_add_item(ouch_tree,
834
0
                                hf_ouch_order_state,
835
0
                                tvb, offset, 1,
836
0
                                ENC_ASCII);
837
0
            offset += 1;
838
839
0
            proto_tree_add_item(ouch_tree,
840
0
                                hf_ouch_previous_order_token,
841
0
                                tvb, offset, 14,
842
0
                                ENC_ASCII);
843
0
            offset += 14;
844
845
0
            if (reported_len >= 80) { /* Added in 4.2 */
846
0
                proto_tree_add_item(ouch_tree,
847
0
                                    hf_ouch_bbo_weight_indicator,
848
0
                                    tvb, offset, 1,
849
0
                                    ENC_ASCII);
850
0
                offset += 1;
851
0
            }
852
0
            break;
853
854
0
        case 'C': /* Canceled */
855
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
856
0
                                    hf_ouch_timestamp,
857
0
                                    tvb, offset);
858
0
            offset += 8;
859
860
0
            proto_tree_add_item(ouch_tree,
861
0
                                hf_ouch_order_token,
862
0
                                tvb, offset, 14,
863
0
                                ENC_ASCII);
864
0
            offset += 14;
865
866
0
            proto_tree_add_item(ouch_tree,
867
0
                                hf_ouch_decrement_shares,
868
0
                                tvb, offset, 4,
869
0
                                ENC_BIG_ENDIAN);
870
0
            offset += 4;
871
872
0
            proto_tree_add_item(ouch_tree,
873
0
                                hf_ouch_cancel_reason,
874
0
                                tvb, offset, 1,
875
0
                                ENC_ASCII);
876
0
            offset += 1;
877
0
            break;
878
879
0
        case 'D': /* AIQ Canceled */
880
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
881
0
                                    hf_ouch_timestamp,
882
0
                                    tvb, offset);
883
0
            offset += 8;
884
885
0
            proto_tree_add_item(ouch_tree,
886
0
                                hf_ouch_order_token,
887
0
                                tvb, offset, 14,
888
0
                                ENC_ASCII);
889
0
            offset += 14;
890
891
0
            proto_tree_add_item(ouch_tree,
892
0
                                hf_ouch_decrement_shares,
893
0
                                tvb, offset, 4,
894
0
                                ENC_BIG_ENDIAN);
895
0
            offset += 4;
896
897
0
            proto_tree_add_item(ouch_tree,
898
0
                                hf_ouch_cancel_reason,
899
0
                                tvb, offset, 1,
900
0
                                ENC_ASCII);
901
0
            offset += 1;
902
903
0
            proto_tree_add_item(ouch_tree,
904
0
                                hf_ouch_quantity_prevented_from_trading,
905
0
                                tvb, offset, 4,
906
0
                                ENC_BIG_ENDIAN);
907
0
            offset += 4;
908
909
0
            proto_tree_add_item(ouch_tree,
910
0
                                hf_ouch_execution_price,
911
0
                                tvb, offset, 4,
912
0
                                ENC_BIG_ENDIAN);
913
0
            offset += 4;
914
915
0
            proto_tree_add_item(ouch_tree,
916
0
                                hf_ouch_liquidity_flag,
917
0
                                tvb, offset, 1,
918
0
                                ENC_ASCII);
919
0
            offset += 1;
920
0
            break;
921
922
0
        case 'E': /* Executed */
923
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
924
0
                                    hf_ouch_timestamp,
925
0
                                    tvb, offset);
926
0
            offset += 8;
927
928
0
            proto_tree_add_item(ouch_tree,
929
0
                                hf_ouch_order_token,
930
0
                                tvb, offset, 14,
931
0
                                ENC_ASCII);
932
0
            offset += 14;
933
934
0
            proto_tree_add_item(ouch_tree,
935
0
                                hf_ouch_executed_shares,
936
0
                                tvb, offset, 4,
937
0
                                ENC_BIG_ENDIAN);
938
0
            offset += 4;
939
940
0
            proto_tree_add_item(ouch_tree,
941
0
                                hf_ouch_execution_price,
942
0
                                tvb, offset, 4,
943
0
                                ENC_BIG_ENDIAN);
944
0
            offset += 4;
945
946
0
            proto_tree_add_item(ouch_tree,
947
0
                                hf_ouch_liquidity_flag,
948
0
                                tvb, offset, 1,
949
0
                                ENC_ASCII);
950
0
            offset += 1;
951
952
0
            proto_tree_add_item(ouch_tree,
953
0
                                hf_ouch_match_number,
954
0
                                tvb, offset, 8,
955
0
                                ENC_BIG_ENDIAN);
956
0
            offset += 8;
957
0
            break;
958
959
0
        case 'B': /* Broken Trade */
960
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
961
0
                                    hf_ouch_timestamp,
962
0
                                    tvb, offset);
963
0
            offset += 8;
964
965
0
            proto_tree_add_item(ouch_tree,
966
0
                                hf_ouch_order_token,
967
0
                                tvb, offset, 14,
968
0
                                ENC_ASCII);
969
0
            offset += 14;
970
971
0
            proto_tree_add_item(ouch_tree,
972
0
                                hf_ouch_match_number,
973
0
                                tvb, offset, 8,
974
0
                                ENC_BIG_ENDIAN);
975
0
            offset += 8;
976
977
0
            proto_tree_add_item(ouch_tree,
978
0
                                hf_ouch_broken_trade_reason,
979
0
                                tvb, offset, 1,
980
0
                                ENC_ASCII);
981
0
            offset += 1;
982
0
            break;
983
984
0
        case 'F': /* Trade Correction (4.2 onwards) */
985
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
986
0
                                    hf_ouch_timestamp,
987
0
                                    tvb, offset);
988
0
            offset += 8;
989
990
0
            proto_tree_add_item(ouch_tree,
991
0
                                hf_ouch_order_token,
992
0
                                tvb, offset, 14,
993
0
                                ENC_ASCII);
994
0
            offset += 14;
995
996
0
            proto_tree_add_item(ouch_tree,
997
0
                                hf_ouch_executed_shares,
998
0
                                tvb, offset, 4,
999
0
                                ENC_BIG_ENDIAN);
1000
0
            offset += 4;
1001
1002
0
            proto_tree_add_item(ouch_tree,
1003
0
                                hf_ouch_execution_price,
1004
0
                                tvb, offset, 4,
1005
0
                                ENC_BIG_ENDIAN);
1006
0
            offset += 4;
1007
1008
0
            proto_tree_add_item(ouch_tree,
1009
0
                                hf_ouch_liquidity_flag,
1010
0
                                tvb, offset, 1,
1011
0
                                ENC_ASCII);
1012
0
            offset += 1;
1013
1014
0
            proto_tree_add_item(ouch_tree,
1015
0
                                hf_ouch_match_number,
1016
0
                                tvb, offset, 8,
1017
0
                                ENC_BIG_ENDIAN);
1018
0
            offset += 8;
1019
1020
0
            proto_tree_add_item(ouch_tree,
1021
0
                                hf_ouch_trade_correction_reason,
1022
0
                                tvb, offset, 1,
1023
0
                                ENC_ASCII);
1024
0
            offset += 1;
1025
0
            break;
1026
1027
0
        case 'G': /* Executed with Reference Price (4.2 onwards) */
1028
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
1029
0
                                    hf_ouch_timestamp,
1030
0
                                    tvb, offset);
1031
0
            offset += 8;
1032
1033
0
            proto_tree_add_item(ouch_tree,
1034
0
                                hf_ouch_order_token,
1035
0
                                tvb, offset, 14,
1036
0
                                ENC_ASCII);
1037
0
            offset += 14;
1038
1039
0
            proto_tree_add_item(ouch_tree,
1040
0
                                hf_ouch_executed_shares,
1041
0
                                tvb, offset, 4,
1042
0
                                ENC_BIG_ENDIAN);
1043
0
            offset += 4;
1044
1045
0
            proto_tree_add_item(ouch_tree,
1046
0
                                hf_ouch_execution_price,
1047
0
                                tvb, offset, 4,
1048
0
                                ENC_BIG_ENDIAN);
1049
0
            offset += 4;
1050
1051
0
            proto_tree_add_item(ouch_tree,
1052
0
                                hf_ouch_liquidity_flag,
1053
0
                                tvb, offset, 1,
1054
0
                                ENC_ASCII);
1055
0
            offset += 1;
1056
1057
0
            proto_tree_add_item(ouch_tree,
1058
0
                                hf_ouch_match_number,
1059
0
                                tvb, offset, 8,
1060
0
                                ENC_BIG_ENDIAN);
1061
0
            offset += 8;
1062
1063
0
            proto_tree_add_item(ouch_tree,
1064
0
                                hf_ouch_reference_price,
1065
0
                                tvb, offset, 4,
1066
0
                                ENC_BIG_ENDIAN);
1067
0
            offset += 4;
1068
1069
0
            proto_tree_add_item(ouch_tree,
1070
0
                                hf_ouch_reference_price_type,
1071
0
                                tvb, offset, 1,
1072
0
                                ENC_BIG_ENDIAN);
1073
0
            offset += 1;
1074
0
            break;
1075
1076
0
        case 'K': /* Price Correction */
1077
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
1078
0
                                    hf_ouch_timestamp,
1079
0
                                    tvb, offset);
1080
0
            offset += 8;
1081
1082
0
            proto_tree_add_item(ouch_tree,
1083
0
                                hf_ouch_order_token,
1084
0
                                tvb, offset, 14,
1085
0
                                ENC_ASCII);
1086
0
            offset += 14;
1087
1088
0
            proto_tree_add_item(ouch_tree,
1089
0
                                hf_ouch_match_number,
1090
0
                                tvb, offset, 8,
1091
0
                                ENC_BIG_ENDIAN);
1092
0
            offset += 8;
1093
1094
0
            proto_tree_add_item(ouch_tree,
1095
0
                                hf_ouch_new_execution_price,
1096
0
                                tvb, offset, 4,
1097
0
                                ENC_BIG_ENDIAN);
1098
0
            offset += 4;
1099
1100
0
            proto_tree_add_item(ouch_tree,
1101
0
                                hf_ouch_price_correction_reason,
1102
0
                                tvb, offset, 1,
1103
0
                                ENC_ASCII);
1104
0
            offset += 1;
1105
0
            break;
1106
1107
0
        case 'J': /* Rejected Order */
1108
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
1109
0
                                    hf_ouch_timestamp,
1110
0
                                    tvb, offset);
1111
0
            offset += 8;
1112
1113
0
            proto_tree_add_item(ouch_tree,
1114
0
                                hf_ouch_order_token,
1115
0
                                tvb, offset, 14,
1116
0
                                ENC_ASCII);
1117
0
            offset += 14;
1118
1119
0
            proto_tree_add_item(ouch_tree,
1120
0
                                hf_ouch_reject_reason,
1121
0
                                tvb, offset, 1,
1122
0
                                ENC_ASCII);
1123
0
            offset += 1;
1124
0
            break;
1125
1126
0
        case 'P': /* Cancel Pending */
1127
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
1128
0
                                    hf_ouch_timestamp,
1129
0
                                    tvb, offset);
1130
0
            offset += 8;
1131
1132
0
            proto_tree_add_item(ouch_tree,
1133
0
                                hf_ouch_order_token,
1134
0
                                tvb, offset, 14,
1135
0
                                ENC_ASCII);
1136
0
            offset += 14;
1137
0
            break;
1138
1139
0
        case 'I': /* Cancel Reject */
1140
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
1141
0
                                    hf_ouch_timestamp,
1142
0
                                    tvb, offset);
1143
0
            offset += 8;
1144
1145
0
            proto_tree_add_item(ouch_tree,
1146
0
                                hf_ouch_order_token,
1147
0
                                tvb, offset, 14,
1148
0
                                ENC_ASCII);
1149
0
            offset += 14;
1150
0
            break;
1151
1152
0
        case 'T': /* Order Priority Update (4.2 onwards) */
1153
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
1154
0
                                    hf_ouch_timestamp,
1155
0
                                    tvb, offset);
1156
0
            offset += 8;
1157
1158
0
            proto_tree_add_item(ouch_tree,
1159
0
                                hf_ouch_order_token,
1160
0
                                tvb, offset, 14,
1161
0
                                ENC_ASCII);
1162
0
            offset += 14;
1163
1164
0
            proto_tree_add_item(ouch_tree,
1165
0
                                hf_ouch_price,
1166
0
                                tvb, offset, 4,
1167
0
                                ENC_BIG_ENDIAN);
1168
0
            offset += 4;
1169
1170
0
            proto_tree_add_item(ouch_tree,
1171
0
                                hf_ouch_display,
1172
0
                                tvb, offset, 1,
1173
0
                                ENC_ASCII);
1174
0
            offset += 1;
1175
1176
0
            proto_tree_add_item(ouch_tree,
1177
0
                                hf_ouch_order_reference_number,
1178
0
                                tvb, offset, 8,
1179
0
                                ENC_BIG_ENDIAN);
1180
0
            offset += 8;
1181
0
            break;
1182
1183
0
        case 'm': /* Order Modified (4.2 onwards) */
1184
0
            ouch_tree_add_timestamp(pinfo, ouch_tree,
1185
0
                                    hf_ouch_timestamp,
1186
0
                                    tvb, offset);
1187
0
            offset += 8;
1188
1189
0
            proto_tree_add_item(ouch_tree,
1190
0
                                hf_ouch_order_token,
1191
0
                                tvb, offset, 14,
1192
0
                                ENC_ASCII);
1193
0
            offset += 14;
1194
1195
0
            proto_tree_add_item(ouch_tree,
1196
0
                                hf_ouch_buy_sell_indicator,
1197
0
                                tvb, offset, 1,
1198
0
                                ENC_ASCII);
1199
0
            offset += 1;
1200
1201
0
            proto_tree_add_item(ouch_tree,
1202
0
                                hf_ouch_shares,
1203
0
                                tvb, offset, 4,
1204
0
                                ENC_BIG_ENDIAN);
1205
0
            offset += 4;
1206
0
            break;
1207
1208
0
        default:
1209
            /* Unknown */
1210
0
            proto_tree_add_item(tree,
1211
0
                                hf_ouch_message,
1212
0
                                tvb, offset, -1, ENC_NA);
1213
0
            offset += reported_len - 1;
1214
0
            break;
1215
0
        }
1216
0
    }
1217
1218
0
    return offset;
1219
0
}
1220
1221
/** Returns a guess if a packet is OUCH or not
1222
 *
1223
 * Since SOUP doesn't have a sub-protocol type flag, we have to use a
1224
 * heuristic decision to determine if the contained protocol is OUCH
1225
 * or ITCH (or something else entirely).  We look at the message type
1226
 * code, and since we know that we're being called from SOUP, we can
1227
 * check the passed-in length too: if the type code and the length
1228
 * match, we guess at OUCH. */
1229
static bool
1230
dissect_ouch_heur(
1231
    tvbuff_t *tvb,
1232
    packet_info *pinfo,
1233
    proto_tree *tree,
1234
    void *data _U_)
1235
0
{
1236
0
    uint8_t msg_type = tvb_get_uint8(tvb, 0);
1237
0
    unsigned msg_len = tvb_reported_length(tvb);
1238
1239
0
    switch (msg_type) {
1240
0
    case 'O': /* Enter order (with or without optional customer type) */
1241
0
        if (msg_len != 48 && msg_len != 49) {
1242
0
            return false;
1243
0
        }
1244
0
        break;
1245
1246
0
    case 'U': /* Replace order or Replaced (4.0, 4.1) or Replaced (4.2) */
1247
0
        if (msg_len != 47 && msg_len != 79 && msg_len != 80) {
1248
0
            return false;
1249
0
        }
1250
0
        break;
1251
1252
0
    case 'X': /* Cancel order */
1253
0
        if (msg_len != 19) {
1254
0
            return false;
1255
0
        }
1256
0
        break;
1257
1258
0
    case 'M': /* Modify Order or Order Modified (added 4.2) */
1259
0
        if (msg_len != 20 && msg_len != 28) {
1260
0
            return false;
1261
0
        }
1262
0
        break;
1263
1264
0
    case 'S': /* System event */
1265
0
        if (msg_len != 10) {
1266
0
            return false;
1267
0
        }
1268
0
        break;
1269
1270
0
    case 'A': /* Accepted */
1271
0
        if (msg_len != 65 && msg_len != 66) {
1272
0
            return false;
1273
0
        }
1274
0
        break;
1275
1276
0
    case 'C': /* Canceled */
1277
0
        if (msg_len != 28) {
1278
0
            return false;
1279
0
        }
1280
0
        break;
1281
1282
0
    case 'D': /* AIQ Canceled */
1283
0
        if (msg_len != 37) {
1284
0
            return false;
1285
0
        }
1286
0
        break;
1287
0
    case 'E': /* Executed */
1288
0
        if (msg_len != 40) {
1289
0
            return false;
1290
0
        }
1291
0
        break;
1292
1293
0
    case 'F': /* Trade Correction */
1294
0
        if (msg_len != 41) {
1295
0
            return false;
1296
0
        }
1297
0
        break;
1298
1299
0
    case 'G': /* Executed with Reference Price */
1300
0
        if (msg_len != 45) {
1301
0
            return false;
1302
0
        }
1303
0
        break;
1304
1305
0
    case 'B': /* Broken Trade */
1306
0
        if (msg_len != 32) {
1307
0
            return false;
1308
0
        }
1309
0
        break;
1310
1311
0
    case 'K': /* Correction */
1312
0
        if (msg_len != 36) {
1313
0
            return false;
1314
0
        }
1315
0
        break;
1316
1317
0
    case 'J': /* Rejected */
1318
0
        if (msg_len != 24) {
1319
0
            return false;
1320
0
        }
1321
0
        break;
1322
1323
0
    case 'P': /* Cancel Pending */
1324
0
        if (msg_len != 23) {
1325
0
            return false;
1326
0
        }
1327
0
        break;
1328
1329
0
    case 'I': /* Cancel Reject */
1330
0
        if (msg_len != 23) {
1331
0
            return false;
1332
0
        }
1333
0
        break;
1334
1335
0
    case 'T': /* Order Priority Update */
1336
0
        if (msg_len != 36) {
1337
0
            return false;
1338
0
        }
1339
0
        break;
1340
1341
0
    default:
1342
        /* Not a known OUCH message code */
1343
0
        return false;
1344
0
    }
1345
1346
    /* Perform dissection of this (initial) packet */
1347
0
    dissect_ouch(tvb, pinfo, tree, NULL);
1348
1349
0
    return true;
1350
0
}
1351
1352
1353
void
1354
proto_register_ouch(void)
1355
14
{
1356
    /* Setup list of header fields  See Section 1.6.1 for details*/
1357
14
    static hf_register_info hf[] = {
1358
1359
14
        { &hf_ouch_bbo_weight_indicator,
1360
14
          { "BBO Weight Indicator", "ouch.bbo_weight_indicator",
1361
14
            FT_CHAR, BASE_HEX, VALS(ouch_bbo_weight_indicator_val), 0x0,
1362
14
            NULL, HFILL }},
1363
1364
14
        { &hf_ouch_broken_trade_reason,
1365
14
          { "Broken Trade Reason", "ouch.broken_trade_reason",
1366
14
            FT_CHAR, BASE_HEX, VALS(ouch_broken_trade_reason_val), 0x0,
1367
14
            NULL, HFILL }},
1368
1369
14
        { &hf_ouch_buy_sell_indicator,
1370
14
          { "Buy/Sell Indicator", "ouch.buy_sell_indicator",
1371
14
            FT_CHAR, BASE_HEX, VALS(ouch_buy_sell_indicator_val), 0x0,
1372
14
            NULL, HFILL }},
1373
1374
14
        { &hf_ouch_cancel_reason,
1375
14
          { "Cancel Reason", "ouch.cancel_reason",
1376
14
            FT_CHAR, BASE_HEX, VALS(ouch_cancel_reason_val), 0x0,
1377
14
            NULL, HFILL }},
1378
1379
14
        { &hf_ouch_capacity,
1380
14
          { "Capacity", "ouch.capacity",
1381
14
            FT_CHAR, BASE_HEX, VALS(ouch_capacity_val), 0x0,
1382
14
            NULL, HFILL }},
1383
1384
14
        { &hf_ouch_cross_type,
1385
14
          { "Cross Type", "ouch.cross_type",
1386
14
            FT_CHAR, BASE_HEX, VALS(ouch_cross_type_val), 0x0,
1387
14
            NULL, HFILL }},
1388
1389
14
        { &hf_ouch_customer_type,
1390
14
          { "Customer Type", "ouch.customer_type",
1391
14
            FT_CHAR, BASE_HEX, VALS(ouch_customer_type_val), 0x0,
1392
14
            NULL, HFILL }},
1393
1394
14
        { &hf_ouch_decrement_shares,
1395
14
          { "Decrement Shares", "ouch.decrement_shares",
1396
14
            FT_UINT32, BASE_DEC, NULL, 0x0,
1397
14
            NULL, HFILL }},
1398
1399
14
        { &hf_ouch_display,
1400
14
          { "Display", "ouch.display",
1401
14
            FT_CHAR, BASE_HEX, VALS(ouch_display_val), 0x0,
1402
14
            NULL, HFILL }},
1403
1404
14
        { &hf_ouch_event_code,
1405
14
          { "Event Code", "ouch.event_code",
1406
14
            FT_CHAR, BASE_HEX, VALS(ouch_event_code_val), 0x0,
1407
14
            NULL, HFILL }},
1408
1409
14
        { &hf_ouch_executed_shares,
1410
14
          { "Executed Shares", "ouch.executed_shares",
1411
14
            FT_UINT32, BASE_DEC, NULL, 0x0,
1412
14
            NULL, HFILL }},
1413
1414
14
        { &hf_ouch_execution_price,
1415
14
          { "Execution Price", "ouch.execution_price",
1416
14
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_price), 0x0,
1417
14
            NULL, HFILL }},
1418
1419
14
        { &hf_ouch_existing_order_token,
1420
14
          { "Existing Order Token", "ouch.existing_order_token",
1421
14
            FT_STRING, BASE_NONE, NULL, 0x0,
1422
14
            NULL, HFILL }},
1423
1424
14
        { &hf_ouch_firm,
1425
14
          { "Firm", "ouch.firm",
1426
14
            FT_STRING, BASE_NONE, NULL, 0x0,
1427
14
            NULL, HFILL }},
1428
1429
14
        { &hf_ouch_iso_eligible,
1430
14
          { "Intermarket Sweep Eligibility", "ouch.iso_eligible",
1431
14
            FT_CHAR, BASE_HEX, VALS(ouch_iso_eligibility_val), 0x0,
1432
14
            NULL, HFILL }},
1433
1434
14
        { &hf_ouch_liquidity_flag,
1435
14
          { "Liquidity Flag", "ouch.liquidity_flag",
1436
14
            FT_CHAR, BASE_HEX, VALS(ouch_liquidity_flag_val), 0x0,
1437
14
            NULL, HFILL }},
1438
1439
14
        { &hf_ouch_match_number,
1440
14
          { "Match Number", "ouch.match_number",
1441
14
            FT_UINT64, BASE_DEC, NULL, 0x0,
1442
14
            NULL, HFILL }},
1443
1444
14
        { &hf_ouch_message,
1445
14
          { "Unknown Message", "ouch.unknown_message",
1446
14
            FT_BYTES, BASE_NONE, NULL, 0x0,
1447
14
            NULL, HFILL }},
1448
1449
14
        { &hf_ouch_min_quantity,
1450
14
          { "Minimum Quantity", "ouch.min_quantity",
1451
14
            FT_UINT32, BASE_DEC, NULL, 0x0,
1452
14
            NULL, HFILL }},
1453
1454
14
        { &hf_ouch_new_execution_price,
1455
14
          { "New Execution Price", "ouch.new_execution_price",
1456
14
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_price), 0x0,
1457
14
            NULL, HFILL }},
1458
1459
14
        { &hf_ouch_order_reference_number,
1460
14
          { "Order Reference Number", "ouch.order_reference_number",
1461
14
            FT_UINT64, BASE_DEC, NULL, 0x0,
1462
14
            NULL, HFILL }},
1463
1464
14
        { &hf_ouch_order_state,
1465
14
          { "Order State", "ouch.order_state",
1466
14
            FT_CHAR, BASE_HEX, VALS(ouch_order_state_val), 0x0,
1467
14
            NULL, HFILL }},
1468
1469
14
        { &hf_ouch_order_token,
1470
14
          { "Order Token", "ouch.order_token",
1471
14
            FT_STRING, BASE_NONE, NULL, 0x0,
1472
14
            NULL, HFILL }},
1473
1474
14
        { &hf_ouch_packet_type,
1475
14
          { "Packet Type", "ouch.packet_type",
1476
14
            FT_CHAR, BASE_HEX, VALS(pkt_type_val), 0x0,
1477
14
            NULL, HFILL }},
1478
1479
14
        { &hf_ouch_previous_order_token,
1480
14
          { "Previous Order Token", "ouch.previous_order_token",
1481
14
            FT_STRING, BASE_NONE, NULL, 0x0,
1482
14
            NULL, HFILL }},
1483
1484
14
        { &hf_ouch_price,
1485
14
          { "Price", "ouch.price",
1486
14
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_price), 0x0,
1487
14
            NULL, HFILL }},
1488
1489
14
        { &hf_ouch_price_correction_reason,
1490
14
          { "Price Correction Reason", "ouch.price_correction_reason",
1491
14
            FT_CHAR, BASE_HEX, VALS(ouch_price_correction_reason_val), 0x0,
1492
14
            NULL, HFILL }},
1493
1494
14
        { &hf_ouch_quantity_prevented_from_trading,
1495
14
          { "Quantity Prevented from Trading",
1496
14
            "ouch.quantity_prevented_from_trading",
1497
14
            FT_UINT32, BASE_DEC, NULL, 0x0,
1498
14
            NULL, HFILL }},
1499
1500
14
        { &hf_ouch_reference_price,
1501
14
          { "Reference Price", "ouch.reference_price",
1502
14
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_price), 0x0,
1503
14
            NULL, HFILL }},
1504
1505
14
        { &hf_ouch_reference_price_type,
1506
14
          { "Reference Price Type", "ouch.reference_price_type",
1507
14
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_reference_price_type), 0x0,
1508
14
            NULL, HFILL }},
1509
1510
14
        { &hf_ouch_reject_reason,
1511
14
          { "Reject Reason", "ouch.reject_reason",
1512
14
            FT_CHAR, BASE_HEX, VALS(ouch_reject_reason_val), 0x0,
1513
14
            NULL, HFILL }},
1514
1515
14
        { &hf_ouch_replacement_order_token,
1516
14
          { "Replacement Order Token", "ouch.replacement_order_token",
1517
14
            FT_STRING, BASE_NONE, NULL, 0x0,
1518
14
            NULL, HFILL }},
1519
1520
14
        { &hf_ouch_shares,
1521
14
          { "Shares", "ouch.shares",
1522
14
            FT_UINT32, BASE_DEC, NULL, 0x0,
1523
14
            NULL, HFILL }},
1524
1525
14
        { &hf_ouch_stock,
1526
14
          { "Stock", "ouch.stock",
1527
14
            FT_STRING, BASE_NONE, NULL, 0x0,
1528
14
            NULL, HFILL }},
1529
1530
14
        { &hf_ouch_tif,
1531
14
          { "Time In Force", "ouch.tif",
1532
14
            FT_UINT32, BASE_CUSTOM, CF_FUNC(format_tif), 0x0,
1533
14
            NULL, HFILL }},
1534
1535
14
        { &hf_ouch_timestamp,
1536
14
          { "Timestamp", "ouch.timestamp",
1537
14
            FT_STRING, BASE_NONE, NULL, 0x0,
1538
14
            NULL, HFILL }},
1539
1540
14
        { &hf_ouch_trade_correction_reason,
1541
14
          { "Trade Correction Reason", "ouch.trade_correction_reason",
1542
14
            FT_CHAR, BASE_HEX, VALS(ouch_trade_correction_reason_val), 0x0,
1543
14
            NULL, HFILL }}
1544
14
    };
1545
1546
    /* Setup protocol subtree array */
1547
14
    static int *ett[] = {
1548
14
        &ett_ouch
1549
14
    };
1550
1551
    /* Register the protocol name and description */
1552
14
    proto_ouch = proto_register_protocol("OUCH", "OUCH", "ouch");
1553
1554
    /* Required function calls to register the header fields and
1555
     * subtrees used */
1556
14
    proto_register_field_array(proto_ouch, hf, array_length(hf));
1557
14
    proto_register_subtree_array(ett, array_length(ett));
1558
1559
    /* Register the dissector */
1560
14
    ouch_handle = register_dissector("ouch", dissect_ouch, proto_ouch);
1561
14
}
1562
1563
1564
/* If this dissector uses sub-dissector registration add a
1565
 * registration routine.  This format is required because a script is
1566
 * used to find these routines and create the code that calls these
1567
 * routines. */
1568
void
1569
proto_reg_handoff_ouch(void)
1570
14
{
1571
14
    heur_dissector_add("soupbintcp", dissect_ouch_heur, "OUCH over SoupBinTCP", "ouch_soupbintcp", proto_ouch, HEURISTIC_ENABLE);
1572
14
    dissector_add_uint_range_with_preference("tcp.port", "", ouch_handle);
1573
14
}
1574
1575
1576
1577
/*
1578
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
1579
 *
1580
 * Local variables:
1581
 * c-basic-offset: 4
1582
 * tab-width: 8
1583
 * indent-tabs-mode: nil
1584
 * End:
1585
 *
1586
 * vi: set shiftwidth=4 tabstop=8 expandtab:
1587
 * :indentSize=4:tabSize=8:noTabs=true:
1588
 */