aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-csm-encaps.c
blob: c6af938b4c2bf7154f09d50e6897500bd79e044d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
/* packet-csm-encaps.c
 * Routines for CSM_ENCAPS dissection
 * Copyright 2005, Angelo Bannack <angelo.bannack@siemens.com>
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 2003 Gerald Combs
 *
 * Copied from packet-ans.c
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#include "config.h"

#include <glib.h>

#include <epan/packet.h>
#include <epan/tap.h>
#include <epan/wmem/wmem.h>
#include <epan/etypes.h>


#define OPCODE_NOOP              0x0000
#define OPCODE_CONTROL_PACKET    0x0001
#define OPCODE_RELIABLE_DATA     0x0002


#define CSM_ENCAPS_CTRL_ACK              0x80
#define CSM_ENCAPS_CTRL_ACK_SUPPRESS     0x40
#define CSM_ENCAPS_CTRL_ACK_TO_HOST      0x20
#define CSM_ENCAPS_CTRL_ENDIAN           0x01



#define CSM_ENCAPS_TYPE_CHANGE               0x00
#define CSM_ENCAPS_TYPE_QUERY                0x01
#define CSM_ENCAPS_TYPE_RESPONSE             0x02
#define CSM_ENCAPS_TYPE_INDICATION           0x03
#define CSM_ENCAPS_TYPE_QUERY_RESPONSE       0x04
#define CSM_ENCAPS_TYPE_INDICATION_RESPONSE  0x05

void proto_register_csm_encaps(void);
void proto_reg_handoff_csm_encaps(void);

static const value_string opcode_vals[] = {
    { OPCODE_NOOP,           "No Operation" },
    { OPCODE_CONTROL_PACKET, "Control Packet" },
    { OPCODE_RELIABLE_DATA,  "Reliable Data Transfer" },
    { 0,       NULL }
};

static const value_string function_code_vals[] = {
    {0x0000, " "},
    { 0,       NULL }
};


static const value_string class_type_vals[] = {
    { 0,      NULL }
};



static const value_string exclusive_to_host_vals[] = {
    { 0,      NULL }
};

static const value_string exclusive_to_host_ct_vals[] = {
    { 0,      NULL }
};


static const value_string error_vals[] = {
    { 0,      NULL }
};



/* Initialize the protocol and registered fields */
static int proto_csm_encaps            = -1;

static int hf_csm_encaps_opcode            = -1;
static int hf_csm_encaps_seq               = -1;
static int hf_csm_encaps_ctrl              = -1;
static int hf_csm_encaps_ctrl_endian       = -1;
static int hf_csm_encaps_ctrl_ack          = -1;
static int hf_csm_encaps_ctrl_ack_suppress = -1;
static int hf_csm_encaps_channel           = -1;
static int hf_csm_encaps_index             = -1;
static int hf_csm_encaps_length            = -1;
static int hf_csm_encaps_class             = -1;
static int hf_csm_encaps_type              = -1;
static int hf_csm_encaps_function_code     = -1;
static int hf_csm_encaps_reserved          = -1;
static int hf_csm_encaps_param_error       = -1;
static int hf_csm_encaps_param1            = -1;
static int hf_csm_encaps_param2            = -1;
static int hf_csm_encaps_param3            = -1;
static int hf_csm_encaps_param4            = -1;
static int hf_csm_encaps_param5            = -1;
static int hf_csm_encaps_param6            = -1;
static int hf_csm_encaps_param7            = -1;
static int hf_csm_encaps_param8            = -1;
static int hf_csm_encaps_param9            = -1;
static int hf_csm_encaps_param10           = -1;
static int hf_csm_encaps_param11           = -1;
static int hf_csm_encaps_param12           = -1;
static int hf_csm_encaps_param13           = -1;
static int hf_csm_encaps_param14           = -1;
static int hf_csm_encaps_param15           = -1;
static int hf_csm_encaps_param16           = -1;
static int hf_csm_encaps_param17           = -1;
static int hf_csm_encaps_param18           = -1;
static int hf_csm_encaps_param19           = -1;
static int hf_csm_encaps_param20           = -1;
static int hf_csm_encaps_param21           = -1;
static int hf_csm_encaps_param22           = -1;
static int hf_csm_encaps_param23           = -1;
static int hf_csm_encaps_param24           = -1;
static int hf_csm_encaps_param25           = -1;
static int hf_csm_encaps_param26           = -1;
static int hf_csm_encaps_param27           = -1;
static int hf_csm_encaps_param28           = -1;
static int hf_csm_encaps_param29           = -1;
static int hf_csm_encaps_param30           = -1;
static int hf_csm_encaps_param31           = -1;
static int hf_csm_encaps_param32           = -1;
static int hf_csm_encaps_param33           = -1;
static int hf_csm_encaps_param34           = -1;
static int hf_csm_encaps_param35           = -1;
static int hf_csm_encaps_param36           = -1;
static int hf_csm_encaps_param37           = -1;
static int hf_csm_encaps_param38           = -1;
static int hf_csm_encaps_param39           = -1;
static int hf_csm_encaps_param40           = -1;
static int hf_csm_encaps_param             = -1;


/* Initialize the subtree pointers */
static gint ett_csm_encaps         = -1;
static gint ett_csm_encaps_control = -1;


/* returns the command name */
static const gchar *
csm_fc(guint16 fc, guint16 ct)
{
    if (fc == 0x0000) {
        return wmem_strdup(wmem_packet_scope(),
                           val_to_str(ct, class_type_vals, "0x%04x"));
    } else {
        return wmem_strdup(wmem_packet_scope(),
                           val_to_str(fc, function_code_vals, "0x%04x"));
    }
}



/* check to see if the message is an exclusive message send to host */
static gboolean
csm_to_host(guint16 fc, guint16 ct)
{
    if (fc == 0x0000)
    {
        return (try_val_to_str(ct, exclusive_to_host_ct_vals) != NULL);
    }
    else
    {
        return (try_val_to_str(fc, exclusive_to_host_vals) != NULL);
    }
}



/* Code to actually dissect the packets */
static void
dissect_csm_encaps(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
    proto_item  *ti;
    proto_tree  *csm_encaps_tree = NULL;
    guint16      function_code, channel, class_type;
    guint        control, type, sequence, length;
    guint        i;
    gboolean     show_error_param= FALSE;
    const gchar *str_function_name;


    function_code = tvb_get_letohs(tvb, 10);
    control = tvb_get_guint8(tvb, 3);

    class_type = tvb_get_guint8(tvb, 9);
    class_type = class_type<<8;
    class_type|= tvb_get_guint8(tvb, 8);

    type     = tvb_get_guint8(tvb, 8);
    sequence = tvb_get_guint8(tvb, 2);
    length   = tvb_get_guint8(tvb, 6);
    channel  = tvb_get_ntohs(tvb, 4);


    if (CSM_ENCAPS_CTRL_ACK&control)
        show_error_param= FALSE;
    else
    {
        if (csm_to_host(function_code, class_type)) /* exclusive messages to host */
            show_error_param= FALSE;
        else
        {
            if (type == CSM_ENCAPS_TYPE_RESPONSE)
                show_error_param= TRUE;
            else
                show_error_param= FALSE;
        }
    }


    col_set_str(pinfo->cinfo, COL_PROTOCOL, "CSM_ENCAPS");

    col_clear(pinfo->cinfo, COL_INFO);


    if (CSM_ENCAPS_CTRL_ACK&control)
    {
        if (CSM_ENCAPS_CTRL_ACK_TO_HOST&control)
            col_append_fstr(pinfo->cinfo, COL_INFO,
                            "<-- ACK                                 Ch: 0x%04X, Seq: %2d (To Host)",
                            channel, sequence);
        else
            col_append_fstr(pinfo->cinfo, COL_INFO,
                            "--> ACK                                 Ch: 0x%04X, Seq: %2d (From Host)",
                            channel, sequence);
    }
    else
    {
        str_function_name= csm_fc(function_code, class_type);
        if ((type == CSM_ENCAPS_TYPE_RESPONSE) || (csm_to_host(function_code, class_type)))
            col_append_fstr(pinfo->cinfo, COL_INFO,
                            "<-- %-35s Ch: 0x%04X, Seq: %2d (To Host)",
                            str_function_name, channel, sequence);
        else
            col_append_fstr(pinfo->cinfo, COL_INFO,
                            "--> %-35s Ch: 0x%04X, Seq: %2d (From Host)",
                            str_function_name, channel, sequence);
    }


    if (tree) {
        static const int * control_flags[] = {
            &hf_csm_encaps_ctrl_ack,
            &hf_csm_encaps_ctrl_ack_suppress,
            &hf_csm_encaps_ctrl_endian,
            NULL
        };

        ti = proto_tree_add_item(tree, proto_csm_encaps, tvb, 0, -1, ENC_NA);
        csm_encaps_tree = proto_item_add_subtree(ti, ett_csm_encaps);

        proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_opcode, tvb, 0, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_seq, tvb, 2, 1, ENC_BIG_ENDIAN);

        proto_tree_add_bitmask(tree, tvb, 3, hf_csm_encaps_ctrl, ett_csm_encaps_control, control_flags, ENC_NA);

        proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_channel, tvb, 4, 2, ENC_BIG_ENDIAN);
        proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_length, tvb, 6, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_index, tvb, 7, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_class, tvb, 9, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_type, tvb, 8, 1, ENC_BIG_ENDIAN);
        proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_function_code, tvb, 10, 2, ENC_LITTLE_ENDIAN);

        i=6;

        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_reserved, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length)
        {
            if (show_error_param)
                proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param_error, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN);
            else
                proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param1, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN);
            i+=2;
        }
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param2, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param3, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param4, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param5, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param6, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param7, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param8, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param9, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param10, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param11, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param12, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param13, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param14, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param15, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param16, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param17, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param18, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param19, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param20, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param21, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param22, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param23, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param24, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param25, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param26, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param27, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param28, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param29, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param30, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param31, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param32, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param33, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param34, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param35, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param36, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param37, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param38, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param39, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;
        if (i<length) proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param40, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN); i+=2;

        for (; i<length; i+=2)
            proto_tree_add_item(csm_encaps_tree, hf_csm_encaps_param, tvb, 12 + i-6, 2, ENC_LITTLE_ENDIAN);
    }
}


void
proto_register_csm_encaps(void)
{
    static struct true_false_string control_endian_bit       = {"Little Endian","Big Endian"};
    static struct true_false_string control_ack_bit          = {"ACK Packet", "Message Packet"};
    static struct true_false_string control_ack_suppress_bit = {"ACK Suppressed", "ACK Required"};


    static hf_register_info hf[] = {
        { &hf_csm_encaps_opcode,
            { "Opcode", "csm_encaps.opcode",
                FT_UINT16, BASE_HEX, VALS(opcode_vals), 0,
                "CSM_ENCAPS Opcode", HFILL }
        },
        { &hf_csm_encaps_seq,
            { "Sequence Number", "csm_encaps.seq_num",
                FT_UINT8, BASE_DEC, NULL, 0,
                "CSM_ENCAPS Sequence Number", HFILL }
        },

        { &hf_csm_encaps_ctrl,
            { "Control", "csm_encaps.ctrl",
                FT_UINT8, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Control", HFILL }
        },

        { &hf_csm_encaps_ctrl_ack,
           { "Packet Bit",  "csm_encaps.ctrl.ack",
                FT_BOOLEAN, 8, TFS(&control_ack_bit), CSM_ENCAPS_CTRL_ACK,
                "Message Packet/ACK Packet", HFILL }
        },
        { &hf_csm_encaps_ctrl_ack_suppress,
           { "ACK Suppress Bit",    "csm_encaps.ctrl.ack_suppress",
                FT_BOOLEAN, 8, TFS(&control_ack_suppress_bit), CSM_ENCAPS_CTRL_ACK_SUPPRESS,
                "ACK Required/ACK Suppressed", HFILL }
        },
        { &hf_csm_encaps_ctrl_endian,
           { "Endian Bit",  "csm_encaps.ctrl.endian",
                FT_BOOLEAN, 8, TFS(&control_endian_bit), CSM_ENCAPS_CTRL_ENDIAN,
                "Little Endian/Big Endian", HFILL }
        },


        { &hf_csm_encaps_channel,
            { "Channel Number", "csm_encaps.channel",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Channel Number", HFILL }
        },
        { &hf_csm_encaps_index,
            { "Index", "csm_encaps.index",
                FT_UINT8, BASE_DEC, NULL, 0,
                "CSM_ENCAPS Index", HFILL }
        },
        { &hf_csm_encaps_length,
            { "Length", "csm_encaps.length",
                FT_UINT8, BASE_DEC, NULL, 0,
                "CSM_ENCAPS Length", HFILL }
        },
        { &hf_csm_encaps_class,
            { "Class", "csm_encaps.class",
                FT_UINT8, BASE_DEC, NULL, 0,
                "CSM_ENCAPS Class", HFILL }
        },
        { &hf_csm_encaps_type,
            { "Type", "csm_encaps.type",
                FT_UINT8, BASE_DEC, NULL, 0,
                "CSM_ENCAPS Type", HFILL }
        },
        { &hf_csm_encaps_function_code,
            { "Function Code", "csm_encaps.function_code",
                FT_UINT16, BASE_HEX, VALS(function_code_vals), 0,
                "CSM_ENCAPS Function Code", HFILL }
        },
        { &hf_csm_encaps_reserved,
            { "Reserved", "csm_encaps.reserved",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Reserved", HFILL }
        },
        { &hf_csm_encaps_param_error,
            { "Parameter 1", "csm_encaps.param1",
                FT_UINT16, BASE_HEX, VALS(error_vals), 0,
                "CSM_ENCAPS Parameter 1", HFILL }
        },
        { &hf_csm_encaps_param1,
            { "Parameter 1", "csm_encaps.param1",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 1", HFILL }
        },
        { &hf_csm_encaps_param2,
            { "Parameter 2", "csm_encaps.param2",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 2", HFILL }
        },
        { &hf_csm_encaps_param3,
            { "Parameter 3", "csm_encaps.param3",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 3", HFILL }
        },
        { &hf_csm_encaps_param4,
            { "Parameter 4", "csm_encaps.param4",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 4", HFILL }
        },
        { &hf_csm_encaps_param5,
            { "Parameter 5", "csm_encaps.param5",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 5", HFILL }
        },
        { &hf_csm_encaps_param6,
            { "Parameter 6", "csm_encaps.param6",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 6", HFILL }
        },
        { &hf_csm_encaps_param7,
            { "Parameter 7", "csm_encaps.param7",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 7", HFILL }
        },
        { &hf_csm_encaps_param8,
            { "Parameter 8", "csm_encaps.param8",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 8", HFILL }
        },
        { &hf_csm_encaps_param9,
            { "Parameter 9", "csm_encaps.param9",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 9", HFILL }
        },
        { &hf_csm_encaps_param10,
            { "Parameter 10", "csm_encaps.param10",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 10", HFILL }
        },
        { &hf_csm_encaps_param11,
            { "Parameter 11", "csm_encaps.param11",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 11", HFILL }
        },
        { &hf_csm_encaps_param12,
            { "Parameter 12", "csm_encaps.param12",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 12", HFILL }
        },
        { &hf_csm_encaps_param13,
            { "Parameter 13", "csm_encaps.param13",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 13", HFILL }
        },
        { &hf_csm_encaps_param14,
            { "Parameter 14", "csm_encaps.param14",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 14", HFILL }
        },
        { &hf_csm_encaps_param15,
            { "Parameter 15", "csm_encaps.param15",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 15", HFILL }
        },
        { &hf_csm_encaps_param16,
            { "Parameter 16", "csm_encaps.param16",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 16", HFILL }
        },
        { &hf_csm_encaps_param17,
            { "Parameter 17", "csm_encaps.param17",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 17", HFILL }
        },
        { &hf_csm_encaps_param18,
            { "Parameter 18", "csm_encaps.param18",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 18", HFILL }
        },
        { &hf_csm_encaps_param19,
            { "Parameter 19", "csm_encaps.param19",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 19", HFILL }
        },
        { &hf_csm_encaps_param20,
            { "Parameter 20", "csm_encaps.param20",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 20", HFILL }
        },
        { &hf_csm_encaps_param21,
            { "Parameter 21", "csm_encaps.param21",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 21", HFILL }
        },
        { &hf_csm_encaps_param22,
            { "Parameter 22", "csm_encaps.param22",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 22", HFILL }
        },
        { &hf_csm_encaps_param23,
            { "Parameter 23", "csm_encaps.param23",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 23", HFILL }
        },
        { &hf_csm_encaps_param24,
            { "Parameter 24", "csm_encaps.param24",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 24", HFILL }
        },
        { &hf_csm_encaps_param25,
            { "Parameter 25", "csm_encaps.param25",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 25", HFILL }
        },
        { &hf_csm_encaps_param26,
            { "Parameter 26", "csm_encaps.param26",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 26", HFILL }
        },
        { &hf_csm_encaps_param27,
            { "Parameter 27", "csm_encaps.param27",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 27", HFILL }
        },
        { &hf_csm_encaps_param28,
            { "Parameter 28", "csm_encaps.param28",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 28", HFILL }
        },
        { &hf_csm_encaps_param29,
            { "Parameter 29", "csm_encaps.param29",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 29", HFILL }
        },
        { &hf_csm_encaps_param30,
            { "Parameter 30", "csm_encaps.param30",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 30", HFILL }
        },
        { &hf_csm_encaps_param31,
            { "Parameter 31", "csm_encaps.param31",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 31", HFILL }
        },
        { &hf_csm_encaps_param32,
            { "Parameter 32", "csm_encaps.param32",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 32", HFILL }
        },
        { &hf_csm_encaps_param33,
            { "Parameter 33", "csm_encaps.param33",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 33", HFILL }
        },
        { &hf_csm_encaps_param34,
            { "Parameter 34", "csm_encaps.param34",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 34", HFILL }
        },
        { &hf_csm_encaps_param35,
            { "Parameter 35", "csm_encaps.param35",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 35", HFILL }
        },
        { &hf_csm_encaps_param36,
            { "Parameter 36", "csm_encaps.param36",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 36", HFILL }
        },
        { &hf_csm_encaps_param37,
            { "Parameter 37", "csm_encaps.param37",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 37", HFILL }
        },
        { &hf_csm_encaps_param38,
            { "Parameter 38", "csm_encaps.param38",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 38", HFILL }
        },
        { &hf_csm_encaps_param39,
            { "Parameter 39", "csm_encaps.param39",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 39", HFILL }
        },
        { &hf_csm_encaps_param40,
            { "Parameter 40", "csm_encaps.param40",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter 40", HFILL }
        },
        { &hf_csm_encaps_param,
            { "Parameter", "csm_encaps.param",
                FT_UINT16, BASE_HEX, NULL, 0,
                "CSM_ENCAPS Parameter", HFILL }
        },
    };

    static gint *ett[] = {
        &ett_csm_encaps,
        &ett_csm_encaps_control
    };

    proto_csm_encaps = proto_register_protocol("CSM_ENCAPS", "CSM_ENCAPS", "csm_encaps");
    proto_register_field_array(proto_csm_encaps, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));

}


void
proto_reg_handoff_csm_encaps(void)
{
    dissector_handle_t csm_encaps_handle;

    csm_encaps_handle = create_dissector_handle(dissect_csm_encaps, proto_csm_encaps);
    dissector_add_uint("ethertype", ETHERTYPE_CSM_ENCAPS, csm_encaps_handle);
}

/*
 * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * vi: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */