Coverage Report

Created: 2025-04-03 08:46

/src/wireshark/wiretap/atm.c
Line
Count
Source (jump to first uncovered line)
1
/* atm.c
2
 *
3
 * Wiretap Library
4
 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
5
 *
6
 * SPDX-License-Identifier: GPL-2.0-or-later
7
 */
8
9
#include "config.h"
10
#include "atm.h"
11
#include "wtap-int.h"
12
13
/*
14
 * Routines to use with ATM capture file types that don't include information
15
 * about the *type* of ATM traffic (or, at least, where we haven't found
16
 * that information).
17
 *
18
 * We assume the traffic is AAL5, unless it's VPI 0/VCI 5, in which case
19
 * we assume it's the signalling AAL.
20
 */
21
22
void
23
atm_guess_traffic_type(wtap_rec *rec)
24
0
{
25
  /*
26
   * Start out assuming nothing other than that it's AAL5.
27
   */
28
0
  rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_5;
29
0
  rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_UNKNOWN;
30
0
  rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_UNKNOWN;
31
32
0
  if (rec->rec_header.packet_header.pseudo_header.atm.vpi == 0) {
33
    /*
34
     * Traffic on some PVCs with a VPI of 0 and certain
35
     * VCIs is of particular types.
36
     */
37
0
    switch (rec->rec_header.packet_header.pseudo_header.atm.vci) {
38
39
0
    case 5:
40
      /*
41
       * Signalling AAL.
42
       */
43
0
      rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING;
44
0
      return;
45
46
0
    case 16:
47
      /*
48
       * ILMI.
49
       */
50
0
      rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_ILMI;
51
0
      return;
52
0
    }
53
0
  }
54
55
  /*
56
   * OK, we can't tell what it is based on the VPI/VCI; try
57
   * guessing based on the contents, if we have enough data
58
   * to guess.
59
   */
60
61
0
  if (rec->rec_header.packet_header.caplen >= 3) {
62
0
    const uint8_t *pd = ws_buffer_start_ptr(&rec->data);
63
64
0
    if (pd[0] == 0xaa && pd[1] == 0xaa && pd[2] == 0x03) {
65
      /*
66
       * Looks like a SNAP header; assume it's LLC
67
       * multiplexed RFC 1483 traffic.
68
       */
69
0
      rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_LLCMX;
70
0
    } else if ((rec->rec_header.packet_header.pseudo_header.atm.aal5t_len && rec->rec_header.packet_header.pseudo_header.atm.aal5t_len < 16) ||
71
0
        rec->rec_header.packet_header.caplen < 16) {
72
      /*
73
       * As this cannot be a LANE Ethernet frame (less
74
       * than 2 bytes of LANE header + 14 bytes of
75
       * Ethernet header) we can try it as a SSCOP frame.
76
       */
77
0
      rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING;
78
0
    } else if (pd[0] == 0x83 || pd[0] == 0x81) {
79
      /*
80
       * MTP3b headers often encapsulate
81
       * a SCCP or MTN in the 3G network.
82
       * This should cause 0x83 or 0x81
83
       * in the first byte.
84
       */
85
0
      rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING;
86
0
    } else {
87
      /*
88
       * Assume it's LANE.
89
       */
90
0
      rec->rec_header.packet_header.pseudo_header.atm.type = TRAF_LANE;
91
0
      atm_guess_lane_type(rec);
92
0
    }
93
0
  } else {
94
         /*
95
    * Not only VCI 5 is used for signaling. It might be
96
    * one of these VCIs.
97
    */
98
0
         rec->rec_header.packet_header.pseudo_header.atm.aal = AAL_SIGNALLING;
99
0
  }
100
0
}
101
102
void
103
atm_guess_lane_type(wtap_rec *rec)
104
0
{
105
0
  const uint8_t *pd = ws_buffer_start_ptr(&rec->data);
106
107
0
  if (rec->rec_header.packet_header.caplen >= 2) {
108
0
    if (pd[0] == 0xff && pd[1] == 0x00) {
109
      /*
110
       * Looks like LE Control traffic.
111
       */
112
0
      rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_LANE_LE_CTRL;
113
0
    } else {
114
      /*
115
       * XXX - Ethernet, or Token Ring?
116
       * Assume Ethernet for now; if we see earlier
117
       * LANE traffic, we may be able to figure out
118
       * the traffic type from that, but there may
119
       * still be situations where the user has to
120
       * tell us.
121
       */
122
0
      rec->rec_header.packet_header.pseudo_header.atm.subtype = TRAF_ST_LANE_802_3;
123
0
    }
124
0
  }
125
0
}
126
127
/*
128
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
129
 *
130
 * Local variables:
131
 * c-basic-offset: 8
132
 * tab-width: 8
133
 * indent-tabs-mode: t
134
 * End:
135
 *
136
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
137
 * :indentSize=8:tabSize=8:noTabs=false:
138
 */