HACK: 1. try to match RowsetProperties
[wireshark-wip.git] / wiretap / atm.c
blobb9053e3f1f103e3c869b9c425619c331d222aa13
1 /* atm.c
3 * $Id$
5 * Wiretap Library
6 * Copyright (c) 1998 by Gilbert Ramirez <gram@alumni.rice.edu>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "config.h"
24 #include "wtap-int.h"
25 #include "atm.h"
28 * Routines to use with ATM capture file types that don't include information
29 * about the *type* of ATM traffic (or, at least, where we haven't found
30 * that information).
32 * We assume the traffic is AAL5, unless it's VPI 0/VCI 5, in which case
33 * we assume it's the signalling AAL.
36 void
37 atm_guess_traffic_type(const guint8 *pd, guint32 len,
38 union wtap_pseudo_header *pseudo_header)
41 * Start out assuming nothing other than that it's AAL5.
43 pseudo_header->atm.aal = AAL_5;
44 pseudo_header->atm.type = TRAF_UNKNOWN;
45 pseudo_header->atm.subtype = TRAF_ST_UNKNOWN;
47 if (pseudo_header->atm.vpi == 0) {
49 * Traffic on some PVCs with a VPI of 0 and certain
50 * VCIs is of particular types.
52 switch (pseudo_header->atm.vci) {
54 case 5:
56 * Signalling AAL.
58 pseudo_header->atm.aal = AAL_SIGNALLING;
59 return;
61 case 16:
63 * ILMI.
65 pseudo_header->atm.type = TRAF_ILMI;
66 return;
71 * OK, we can't tell what it is based on the VPI/VCI; try
72 * guessing based on the contents, if we have enough data
73 * to guess.
76 if (len >= 3) {
77 if (pd[0] == 0xaa && pd[1] == 0xaa && pd[2] == 0x03) {
79 * Looks like a SNAP header; assume it's LLC
80 * multiplexed RFC 1483 traffic.
82 pseudo_header->atm.type = TRAF_LLCMX;
83 } else if ((pseudo_header->atm.aal5t_len &&
84 pseudo_header->atm.aal5t_len < 16) || len<16) {
86 * As this cannot be a LANE Ethernet frame (less
87 * than 2 bytes of LANE header + 14 bytes of
88 * Ethernet header) we can try it as a SSCOP frame.
90 pseudo_header->atm.aal = AAL_SIGNALLING;
91 } else if (pd[0] == 0x83 || pd[0] == 0x81) {
93 * MTP3b headers often encapsulate
94 * a SCCP or MTN in the 3G network.
95 * This should cause 0x83 or 0x81
96 * in the first byte.
98 pseudo_header->atm.aal = AAL_SIGNALLING;
99 } else {
101 * Assume it's LANE.
103 pseudo_header->atm.type = TRAF_LANE;
104 atm_guess_lane_type(pd, len, pseudo_header);
106 } else {
108 * Not only VCI 5 is used for signaling. It might be
109 * one of these VCIs.
111 pseudo_header->atm.aal = AAL_SIGNALLING;
115 void
116 atm_guess_lane_type(const guint8 *pd, guint32 len,
117 union wtap_pseudo_header *pseudo_header)
119 if (len >= 2) {
120 if (pd[0] == 0xff && pd[1] == 0x00) {
122 * Looks like LE Control traffic.
124 pseudo_header->atm.subtype = TRAF_ST_LANE_LE_CTRL;
125 } else {
127 * XXX - Ethernet, or Token Ring?
128 * Assume Ethernet for now; if we see earlier
129 * LANE traffic, we may be able to figure out
130 * the traffic type from that, but there may
131 * still be situations where the user has to
132 * tell us.
134 pseudo_header->atm.subtype = TRAF_ST_LANE_802_3;