Coverage Report

Created: 2025-08-04 07:15

/src/wireshark/epan/dissectors/packet-reload-framing.c
Line
Count
Source (jump to first uncovered line)
1
/* packet-reload-framing.c
2
 * Routines for REsource LOcation And Discovery (RELOAD) Framing
3
 * Author: Stephane Bryant <sbryant@glycon.org>
4
 * Copyright 2010 Stonyfish Inc.
5
 *
6
 * Wireshark - Network traffic analyzer
7
 * By Gerald Combs <gerald@wireshark.org>
8
 * Copyright 1998 Gerald Combs
9
 *
10
 * SPDX-License-Identifier: GPL-2.0-or-later
11
 *
12
 * Please refer to the following specs for protocol detail:
13
 * - draft-ietf-p2psip-base-15
14
 * - RFC 6940 (does this incorporate all changes between
15
 *   draft-ietf-p2psip-base-15 and RFC 6940, if any?)
16
 */
17
18
#include "config.h"
19
20
#include <epan/packet.h>
21
#include <epan/expert.h>
22
#include <epan/tap.h>
23
#include <epan/exported_pdu.h>
24
#include "packet-tcp.h"
25
26
void proto_register_reload_framing(void);
27
void proto_reg_handoff_reload_framing(void);
28
29
/* Initialize the protocol and registered fields */
30
static int proto_reload_framing;
31
32
static int hf_reload_framing_type;
33
static int hf_reload_framing_sequence;
34
static int hf_reload_framing_ack_sequence;
35
static int hf_reload_framing_message;
36
static int hf_reload_framing_message_length;
37
static int hf_reload_framing_message_data;
38
static int hf_reload_framing_received;
39
static int hf_reload_framing_parsed_received;
40
static int hf_reload_framing_duplicate;
41
static int hf_reload_framing_response_in;
42
static int hf_reload_framing_response_to;
43
static int hf_reload_framing_time;
44
45
static dissector_handle_t reload_handle;
46
static dissector_handle_t reload_framing_tcp_handle;
47
static dissector_handle_t reload_framing_udp_handle;
48
49
static int exported_pdu_tap = -1;
50
51
/* Structure containing transaction specific information */
52
typedef struct _reload_frame_t {
53
  uint32_t data_frame;
54
  uint32_t ack_frame;
55
  nstime_t req_time;
56
} reload_frame_t;
57
58
/* Structure containing conversation specific information */
59
typedef struct _reload_frame_conv_info_t {
60
  wmem_tree_t *transaction_pdus;
61
} reload_conv_info_t;
62
63
64
/* RELOAD Message classes = (message_code & 0x1) (response = request +1) */
65
455
#define DATA            128
66
20
#define ACK             129
67
68
69
/* Initialize the subtree pointers */
70
static int ett_reload_framing;
71
static int ett_reload_framing_message;
72
static int ett_reload_framing_received;
73
74
static expert_field ei_reload_no_dissector;
75
76
14
#define UDP_PORT_RELOAD                 6084
77
14
#define TCP_PORT_RELOAD                 6084
78
79
4.68k
#define MIN_HDR_LENGTH                             9
80
0
#define MIN_RELOADDATA_HDR_LENGTH                  38
81
82
50
#define RELOAD_TOKEN                    0xd2454c4f
83
84
static const value_string types[] = {
85
  {DATA, "DATA"},
86
  {ACK,  "ACK"},
87
  {0x00, NULL}
88
};
89
90
static unsigned
91
get_reload_framing_message_length(packet_info *pinfo _U_, tvbuff_t *tvb,
92
                                  int offset, void *data _U_)
93
398
{
94
  /* Get the type */
95
398
  uint32_t length = 9;
96
97
98
398
  if (tvb_get_uint8(tvb, offset) == DATA) {
99
19
    length = 1 + 4 + 3 + tvb_get_ntoh24(tvb, 1 + 4);
100
19
  }
101
102
398
  return length;
103
398
}
104
105
106
static int
107
dissect_reload_framing_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bool from_dtls)
108
4.66k
{
109
4.66k
  proto_item         *ti;
110
4.66k
  proto_tree         *reload_framing_tree;
111
4.66k
  uint32_t            relo_token;
112
4.66k
  uint32_t            message_length = 0;
113
4.66k
  wmem_tree_key_t     transaction_id_key[4];
114
4.66k
  uint32_t           *key_save, len_save;
115
4.66k
  uint32_t            sequence;
116
4.66k
  unsigned            effective_length;
117
4.66k
  uint16_t            offset;
118
4.66k
  conversation_t     *conversation;
119
4.66k
  reload_conv_info_t *reload_framing_info = NULL;
120
4.66k
  reload_frame_t *    reload_frame;
121
4.66k
  uint8_t             type;
122
123
4.66k
  offset = 0;
124
4.66k
  effective_length = tvb_captured_length(tvb);
125
126
  /* First, make sure we have enough data to do the check. */
127
4.66k
  if (effective_length < MIN_HDR_LENGTH) {
128
782
    return 0;
129
782
  }
130
131
  /* Next, make sure we can create transaction ID keys. */
132
3.88k
  if (!(pinfo->src.data && pinfo->dst.data)) {
133
923
    return 0;
134
923
  }
135
136
2.95k
  conversation = find_conversation_pinfo(pinfo, 0);
137
2.95k
  if (conversation)
138
2.95k
    reload_framing_info = (reload_conv_info_t *)conversation_get_proto_data(conversation, proto_reload_framing);
139
140
  /* Get the type
141
   * https://tools.ietf.org/html/draft-ietf-p2psip-base-12
142
   * 5.6.2.  Framing Header
143
   */
144
2.95k
  type = tvb_get_uint8(tvb, 0);
145
146
2.95k
  switch(type) {
147
57
  case DATA:
148
    /* in the data type, check the reload token to be sure this
149
    *  is a reLoad packet
150
    */
151
57
    if (effective_length < 12)  /* [type + seq + length + token] */
152
7
      return 0;
153
154
50
    relo_token = tvb_get_ntohl(tvb,1 + 4 + 3);
155
50
    if (relo_token != RELOAD_TOKEN) {
156
50
      return 0;
157
50
    }
158
0
    message_length = tvb_get_ntoh24(tvb, 1 + 4);
159
0
    if (message_length < MIN_RELOADDATA_HDR_LENGTH) {
160
0
      return 0;
161
0
    }
162
0
    break;
163
20
  case ACK:
164
    /* Require previous ACK (i.e., reload_framing_info attached to conversation). */
165
20
    if (effective_length < 9 || ! reload_framing_info) {
166
20
      return 0;
167
20
    }
168
0
    break;
169
2.88k
  default:
170
2.88k
    return 0;
171
2.95k
  }
172
173
0
  if (from_dtls && have_tap_listener(exported_pdu_tap)) {
174
0
    exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "reload-framing", EXP_PDU_TAG_DISSECTOR_NAME);
175
176
0
    exp_pdu_data->tvb_captured_length = effective_length;
177
0
    exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
178
0
    exp_pdu_data->pdu_tvb = tvb;
179
180
0
    tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data);
181
0
  }
182
183
  /* The message seems to be a valid RELOAD framing message! */
184
185
0
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "RELOAD Frame");
186
0
  col_clear(pinfo->cinfo, COL_INFO);
187
188
  /* Create the transaction key which may be used to track the conversation */
189
190
0
  sequence = tvb_get_ntohl(tvb, 1);
191
0
  transaction_id_key[0].length = 1;
192
0
  transaction_id_key[0].key = &sequence; /* sequence number */
193
194
  /* When the wmem_tree_* functions iterate through the keys, they
195
   * perform pointer arithmetic with uint32_t (which requires copying
196
   * the address, at least on some platforms, as there's no guarantee
197
   * that the address structure data field is 4-byte aligned), so we
198
   * have to divide our length fields by that to make things work, but
199
   * we still want to wmem_alloc and memcpy the entire amounts, since
200
   * those both operate in raw bytes. */
201
0
  if (type==DATA) {
202
0
    transaction_id_key[1].length = 1;
203
0
    transaction_id_key[1].key    = &pinfo->srcport;
204
0
    transaction_id_key[2].length = (pinfo->src.len) / (unsigned)sizeof(uint32_t);
205
0
    transaction_id_key[2].key    = (uint32_t *)wmem_alloc(pinfo->pool, pinfo->src.len);
206
0
    memcpy(transaction_id_key[2].key, pinfo->src.data, pinfo->src.len);
207
0
  }
208
0
  else {
209
0
    transaction_id_key[1].length = 1;
210
0
    transaction_id_key[1].key    = &pinfo->destport;
211
0
    transaction_id_key[2].length = (pinfo->dst.len) / (unsigned)sizeof(uint32_t);
212
0
    transaction_id_key[2].key    = (uint32_t *)wmem_alloc(pinfo->pool, pinfo->dst.len);
213
0
    memcpy(transaction_id_key[2].key, pinfo->dst.data, pinfo->dst.len);
214
0
  }
215
0
  transaction_id_key[3].length=0;
216
0
  transaction_id_key[3].key=NULL;
217
  /* The tree functions are destructive to this part of the key, so save the
218
   * proper values here and restore them after each call. */
219
0
  key_save = transaction_id_key[2].key;
220
0
  len_save = transaction_id_key[2].length;
221
222
0
  if (!conversation) {
223
0
    conversation = conversation_new(pinfo->num, &pinfo->src, &pinfo->dst,
224
0
                                    conversation_pt_to_conversation_type(pinfo->ptype), pinfo->srcport, pinfo->destport, 0);
225
0
  }
226
227
  /*
228
   * Do we already have a state structure for this conv
229
   */
230
0
  if (!reload_framing_info) {
231
    /* No.  Attach that information to the conversation, and add
232
     * it to the list of information structures.
233
     */
234
0
    reload_framing_info = wmem_new(wmem_file_scope(), reload_conv_info_t);
235
0
    reload_framing_info->transaction_pdus = wmem_tree_new(wmem_file_scope());
236
0
    conversation_add_proto_data(conversation, proto_reload_framing, reload_framing_info);
237
0
  }
238
239
0
  if (!pinfo->fd->visited) {
240
0
    if ((reload_frame = (reload_frame_t *)
241
0
           wmem_tree_lookup32_array(reload_framing_info->transaction_pdus, transaction_id_key)) == NULL) {
242
0
      transaction_id_key[2].key    = key_save;
243
0
      transaction_id_key[2].length = len_save;
244
0
      reload_frame = wmem_new(wmem_file_scope(), reload_frame_t);
245
0
      reload_frame->data_frame = 0;
246
0
      reload_frame->ack_frame  = 0;
247
0
      reload_frame->req_time   = pinfo->abs_ts;
248
0
      wmem_tree_insert32_array(reload_framing_info->transaction_pdus, transaction_id_key, (void *)reload_frame);
249
0
    }
250
0
    transaction_id_key[2].key    = key_save;
251
0
    transaction_id_key[2].length = len_save;
252
253
    /* check whether the message is a request or a response */
254
255
0
    if (type == DATA) {
256
      /* This is a data */
257
0
      if (reload_frame->data_frame == 0) {
258
0
        reload_frame->data_frame = pinfo->num;
259
0
      }
260
0
    }
261
0
    else {
262
      /* This is a catch-all for all non-request messages */
263
0
      if (reload_frame->ack_frame == 0) {
264
0
        reload_frame->ack_frame = pinfo->num;
265
0
      }
266
0
    }
267
0
  }
268
0
  else {
269
0
    reload_frame=(reload_frame_t *)wmem_tree_lookup32_array(reload_framing_info->transaction_pdus, transaction_id_key);
270
0
    transaction_id_key[2].key    = key_save;
271
0
    transaction_id_key[2].length = len_save;
272
0
  }
273
274
0
  if (!reload_frame) {
275
    /* create a "fake" pana_trans structure */
276
0
    reload_frame = wmem_new(pinfo->pool, reload_frame_t);
277
0
    reload_frame->data_frame = (type==DATA) ? pinfo->num : 0;
278
0
    reload_frame->ack_frame  = (type!=DATA) ? pinfo->num : 0;
279
0
    reload_frame->req_time   = pinfo->abs_ts;
280
0
  }
281
282
0
  ti = proto_tree_add_item(tree, proto_reload_framing, tvb, 0, -1, ENC_NA);
283
284
0
  reload_framing_tree = proto_item_add_subtree(ti, ett_reload_framing);
285
286
0
  col_set_str(pinfo->cinfo, COL_INFO, val_to_str_const(type, types, "Unknown"));
287
0
  proto_item_append_text(ti, ": %s", val_to_str_const(type, types, "Unknown"));
288
289
  /* Retransmission control */
290
0
  if (type == DATA) {
291
0
    if (reload_frame->data_frame != pinfo->num) {
292
0
      proto_item *it;
293
0
      it = proto_tree_add_uint(reload_framing_tree, hf_reload_framing_duplicate, tvb, 0, 0, reload_frame->data_frame);
294
0
      proto_item_set_generated(it);
295
0
    }
296
0
    if (reload_frame->ack_frame) {
297
0
      proto_item *it;
298
0
      it = proto_tree_add_uint(reload_framing_tree, hf_reload_framing_response_in, tvb, 0, 0, reload_frame->ack_frame);
299
0
      proto_item_set_generated(it);
300
0
    }
301
0
  }
302
0
  else {
303
    /* This is a response */
304
0
    if (reload_frame->ack_frame != pinfo->num) {
305
0
      proto_item *it;
306
0
      it = proto_tree_add_uint(reload_framing_tree, hf_reload_framing_duplicate, tvb, 0, 0, reload_frame->ack_frame);
307
0
      proto_item_set_generated(it);
308
0
    }
309
310
0
    if (reload_frame->data_frame) {
311
0
      proto_item *it;
312
0
      nstime_t    ns;
313
314
0
      it = proto_tree_add_uint(reload_framing_tree, hf_reload_framing_response_to, tvb, 0, 0, reload_frame->data_frame);
315
0
      proto_item_set_generated(it);
316
317
0
      nstime_delta(&ns, &pinfo->abs_ts, &reload_frame->req_time);
318
0
      it = proto_tree_add_time(reload_framing_tree, hf_reload_framing_time, tvb, 0, 0, &ns);
319
0
      proto_item_set_generated(it);
320
0
    }
321
0
  }
322
323
  /*
324
   * Message dissection
325
   */
326
0
  proto_tree_add_item(reload_framing_tree, hf_reload_framing_type, tvb, offset , 1, ENC_BIG_ENDIAN);
327
0
  offset += 1;
328
0
  switch (type) {
329
330
0
  case DATA:
331
0
  {
332
0
    tvbuff_t   *next_tvb;
333
0
    proto_item *ti_message;
334
0
    proto_tree *message_tree;
335
336
0
    proto_tree_add_item(reload_framing_tree, hf_reload_framing_sequence, tvb, offset , 4, ENC_BIG_ENDIAN);
337
0
    offset += 4;
338
0
    ti_message = proto_tree_add_item(reload_framing_tree, hf_reload_framing_message, tvb, offset, 3+message_length, ENC_NA);
339
0
    proto_item_append_text(ti_message, " (opaque<%d>)", message_length);
340
0
    message_tree =  proto_item_add_subtree(ti_message, ett_reload_framing_message);
341
0
    proto_tree_add_item(message_tree, hf_reload_framing_message_length, tvb, offset, 3, ENC_BIG_ENDIAN);
342
0
    offset += 3;
343
0
    proto_tree_add_item(message_tree, hf_reload_framing_message_data, tvb, offset, message_length, ENC_NA);
344
0
    next_tvb = tvb_new_subset_length_caplen(tvb, offset, effective_length - offset, message_length);
345
0
    if (reload_handle == NULL) {
346
0
      expert_add_info(pinfo, ti, &ei_reload_no_dissector);
347
0
      return tvb_captured_length(tvb);
348
0
    }
349
0
    call_dissector_only(reload_handle, next_tvb, pinfo, tree, NULL);
350
0
  }
351
0
  break;
352
353
0
  case ACK:
354
0
  {
355
0
    proto_item *ti_received;
356
357
0
    proto_tree_add_uint(reload_framing_tree, hf_reload_framing_ack_sequence, tvb, offset , 4, sequence);
358
0
    offset += 4;
359
360
0
    ti_received = proto_tree_add_item(reload_framing_tree, hf_reload_framing_received, tvb, offset , 4, ENC_BIG_ENDIAN);
361
0
    {
362
0
      uint32_t    received;
363
0
      int         last_received      = -1;
364
0
      unsigned int         indx      = 0;
365
0
      proto_tree *received_tree;
366
0
      proto_item *ti_parsed_received = NULL;
367
368
0
      received = tvb_get_ntohl(tvb, offset);
369
0
      while ((indx<32) && (received<<indx) != 0) {
370
0
        if (received &(1U<<(31-indx))) {
371
0
          if (indx==0) {
372
0
            received_tree = proto_item_add_subtree(ti_received, ett_reload_framing_received);
373
0
            ti_parsed_received = proto_tree_add_item(received_tree, hf_reload_framing_parsed_received, tvb, offset, 4, ENC_NA);
374
0
            proto_item_append_text(ti_parsed_received, "[%u", (sequence -32+indx));
375
0
            last_received = indx;
376
0
          }
377
0
          else {
378
0
            if (received &(1U<<(31-indx+1))) {
379
0
              indx++;
380
              /* the previous one is also acked: in the middle of a range: skip */
381
0
              continue;
382
0
            }
383
0
            else {
384
              /* 1st acked in a series */
385
0
              if (last_received<0) {
386
                /* 1st acked ever */
387
0
                received_tree = proto_item_add_subtree(ti_received, ett_reload_framing_received);
388
0
                ti_parsed_received = proto_tree_add_item(received_tree, hf_reload_framing_parsed_received, tvb, offset, 4, ENC_NA);
389
0
                proto_item_append_text(ti_parsed_received, "[%u",(sequence-32+indx));
390
0
              }
391
0
              else {
392
0
                proto_item_append_text(ti_parsed_received, ",%u",(sequence-32+indx));
393
0
              }
394
0
              last_received = indx;
395
396
0
            }
397
0
          }
398
0
        }
399
0
        else if (indx>0) {
400
0
          if ((indx>1) && (received &(1U<<(31-indx+1))) && (received &(1U<<(31-indx+2)))) {
401
            /* end of a series */
402
0
            if ((indx>2) && (received &(1U<<(31-indx+3)))) {
403
0
              proto_item_append_text(ti_parsed_received,"-%u",(sequence-32+indx-1));
404
0
            }
405
0
            else {
406
              /* just a pair */
407
0
              proto_item_append_text(ti_received, ",%u", (sequence-32+indx-1));
408
0
            }
409
0
          }
410
0
          else {
411
0
            indx++;
412
0
            continue;
413
0
          }
414
0
        }
415
0
        indx++;
416
0
      }
417
0
      if (last_received>=0) {
418
0
        if ((indx>1) && (received &(1U<<(31-indx+1)))  && (received &(1U<<(31-indx+2)))) {
419
          /* end of a series */
420
0
          if ((indx>2) && (received &(1U<<(31-indx+3)))) {
421
0
            proto_item_append_text(ti_parsed_received,"-%u",(sequence-32+indx-1));
422
0
          }
423
0
          else {
424
            /* just a pair */
425
0
            proto_item_append_text(ti_parsed_received, ",%u", (sequence-32+indx-1));
426
0
          }
427
0
        }
428
0
        proto_item_append_text(ti_parsed_received, "]");
429
0
        proto_item_set_generated(ti_parsed_received);
430
0
      }
431
0
    }
432
0
  }
433
0
  break;
434
435
0
  default:
436
0
    DISSECTOR_ASSERT_NOT_REACHED();
437
0
  }
438
439
0
  return tvb_captured_length(tvb);
440
0
}
441
442
static int
443
dissect_reload_framing(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
444
400
{
445
400
  return dissect_reload_framing_message(tvb, pinfo, tree, false);
446
400
}
447
448
static int
449
dissect_reload_framing_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
450
23
{
451
  /* XXX: Check if we have a valid RELOAD Frame Type ? */
452
23
  tcp_dissect_pdus(tvb, pinfo, tree, true, MIN_HDR_LENGTH,
453
23
                   get_reload_framing_message_length, dissect_reload_framing, data);
454
23
  return tvb_captured_length(tvb);
455
23
}
456
457
/* ToDo: If a TCP connection is identified heuristically as reload-framing, then
458
 *        the code should be such that reload-framing PDUs can be re-assembled (as is
459
 *        done for a TCP connection identified as reload-framing because of
460
 *        the TCP port used).
461
 */
462
static bool
463
dissect_reload_framing_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
464
4.26k
{
465
4.26k
  if (dissect_reload_framing_message(tvb, pinfo, tree, false) == 0) {
466
    /*
467
     * It wasn't a valid RELOAD message, and wasn't
468
     * dissected as such.
469
     */
470
4.26k
    return false;
471
4.26k
  }
472
0
  return true;
473
4.26k
}
474
475
static bool
476
dissect_reload_framing_heur_dtls(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
477
0
{
478
0
  if (dissect_reload_framing_message(tvb, pinfo, tree, true) == 0) {
479
    /*
480
     * It wasn't a valid RELOAD message, and wasn't
481
     * dissected as such.
482
     */
483
0
    return false;
484
0
  }
485
0
  return true;
486
0
}
487
488
void
489
proto_register_reload_framing(void)
490
14
{
491
492
14
  static hf_register_info hf[] = {
493
14
    { &hf_reload_framing_type,
494
14
      { "type (FramedMessageType)", "reload_framing.type", FT_UINT8,
495
14
        BASE_DEC, VALS(types),  0x0,  NULL, HFILL
496
14
      }
497
14
    },
498
14
    { &hf_reload_framing_sequence,
499
14
      { "sequence (uint32)", "reload_framing.sequence", FT_UINT32,
500
14
        BASE_DEC, NULL, 0x0,  NULL, HFILL
501
14
      }
502
14
    },
503
14
    { &hf_reload_framing_ack_sequence,
504
14
      { "ack_sequence (uint32)", "reload_framing.ack_sequence", FT_UINT32,
505
14
        BASE_DEC, NULL, 0x0,  NULL, HFILL
506
14
      }
507
14
    },
508
14
    { &hf_reload_framing_message,
509
14
      { "message", "reload_framing.message", FT_NONE,
510
14
        BASE_NONE, NULL, 0x0,  NULL, HFILL
511
14
      }
512
14
    },
513
14
    { &hf_reload_framing_message_length,
514
14
      { "length (uint24)", "reload_framing.message.length", FT_UINT32,
515
14
        BASE_DEC, NULL, 0x0,  NULL, HFILL
516
14
      }
517
14
    },
518
14
    { &hf_reload_framing_message_data,
519
14
      { "data", "reload_framing.message.data", FT_BYTES,
520
14
        BASE_NONE, NULL, 0x0,  NULL, HFILL
521
14
      }
522
14
    },
523
14
    { &hf_reload_framing_received,
524
14
      { "received (uint32)", "reload_framing.received", FT_UINT32,
525
14
        BASE_HEX, NULL, 0x0,  NULL, HFILL
526
14
      }
527
14
    },
528
14
    { &hf_reload_framing_parsed_received,
529
14
      { "Acked Frames:",  "reload_framing.parsed_received", FT_NONE,
530
14
        BASE_NONE, NULL, 0x0, NULL, HFILL
531
14
      }
532
14
    },
533
14
    { &hf_reload_framing_response_in,
534
14
      { "Response In",  "reload_framing.response-in", FT_FRAMENUM,
535
14
        BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0, "The response to this RELOAD Request is in this frame", HFILL
536
14
      }
537
14
    },
538
14
    { &hf_reload_framing_response_to,
539
14
      { "Request In", "reload_framing.response-to", FT_FRAMENUM,
540
14
        BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0, "This is a response to the RELOAD Request in this frame", HFILL
541
14
      }
542
14
    },
543
14
    { &hf_reload_framing_time,
544
14
      { "Time", "reload_framing.time", FT_RELATIVE_TIME,
545
14
        BASE_NONE, NULL, 0x0, "The time between the Request and the Response", HFILL
546
14
      }
547
14
    },
548
14
    { &hf_reload_framing_duplicate,
549
14
      { "Duplicated original message in", "reload_framing.duplicate", FT_FRAMENUM,
550
14
        BASE_NONE, NULL, 0x0, "This is a duplicate of RELOAD message in this frame", HFILL
551
14
      }
552
14
    },
553
14
  };
554
555
  /* Setup protocol subtree array */
556
14
  static int *ett[] = {
557
14
    &ett_reload_framing,
558
14
    &ett_reload_framing_message,
559
14
    &ett_reload_framing_received,
560
14
  };
561
562
14
  static ei_register_info ei[] = {
563
14
     { &ei_reload_no_dissector, { "reload_framing.no_dissector", PI_PROTOCOL, PI_WARN, "Can not find reload dissector", EXPFILL }},
564
14
  };
565
566
14
  expert_module_t* expert_reload_framing;
567
568
  /* Register the protocol name and description */
569
14
  proto_reload_framing = proto_register_protocol("REsource LOcation And Discovery Framing", "RELOAD FRAMING", "reload-framing");
570
571
  /* Required function calls to register the header fields and subtrees used */
572
14
  proto_register_field_array(proto_reload_framing, hf, array_length(hf));
573
14
  proto_register_subtree_array(ett, array_length(ett));
574
14
  expert_reload_framing = expert_register_protocol(proto_reload_framing);
575
14
  expert_register_field_array(expert_reload_framing, ei, array_length(ei));
576
577
14
  reload_framing_udp_handle = register_dissector("reload-framing", dissect_reload_framing, proto_reload_framing);
578
14
  reload_framing_tcp_handle = register_dissector("reload-framing.tcp", dissect_reload_framing_tcp, proto_reload_framing);
579
580
14
}
581
582
void
583
proto_reg_handoff_reload_framing(void)
584
14
{
585
14
  reload_handle = find_dissector_add_dependency("reload", proto_reload_framing);
586
587
14
  dissector_add_uint_with_preference("tcp.port", TCP_PORT_RELOAD, reload_framing_tcp_handle);
588
14
  dissector_add_uint_with_preference("udp.port", UDP_PORT_RELOAD, reload_framing_udp_handle);
589
590
14
  heur_dissector_add("udp",  dissect_reload_framing_heur, "RELOAD Framing over UDP", "reload_framing_udp", proto_reload_framing, HEURISTIC_ENABLE);
591
14
  heur_dissector_add("tcp",  dissect_reload_framing_heur, "RELOAD Framing over TCP", "reload_framing_tcp", proto_reload_framing, HEURISTIC_ENABLE);
592
14
  heur_dissector_add("dtls", dissect_reload_framing_heur_dtls, "RELOAD Framing over DTLS", "reload_framing_dtls", proto_reload_framing, HEURISTIC_ENABLE);
593
594
14
  exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7);
595
14
}
596
597
/*
598
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
599
 *
600
 * Local variables:
601
 * c-basic-offset: 2
602
 * tab-width: 8
603
 * indent-tabs-mode: nil
604
 * End:
605
 *
606
 * vi: set shiftwidth=2 tabstop=8 expandtab:
607
 * :indentSize=2:tabSize=8:noTabs=true:
608
 */