2 * Routines for PPP Over Ethernet (PPPoE) packet disassembly (RFC2516)
3 * Up to date with http://www.iana.org/assignments/pppoe-parameters (2008-04-30)
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
32 #include <epan/strutil.h>
33 #include <epan/etypes.h>
34 #include <epan/prefs.h>
35 #include <epan/expert.h>
36 #include <epan/ppptypes.h>
38 static int proto_pppoed = -1;
40 /* Common to session and discovery protocols */
41 static gint hf_pppoe_version = -1;
42 static gint hf_pppoe_type = -1;
43 static gint hf_pppoe_code = -1;
44 static gint hf_pppoe_session_id = -1;
45 static gint hf_pppoe_payload_length = -1;
47 /* Discovery protocol fields */
48 static gint hf_pppoed_tags = -1;
49 static gint hf_pppoed_tag = -1;
50 static gint hf_pppoed_tag_length = -1;
51 static gint hf_pppoed_tag_length_8 = -1;
52 static gint hf_pppoed_tag_unknown_data = -1;
53 static gint hf_pppoed_tag_service_name = -1;
54 static gint hf_pppoed_tag_ac_name = -1;
55 static gint hf_pppoed_tag_host_uniq = -1;
56 static gint hf_pppoed_tag_ac_cookie = -1;
57 static gint hf_pppoed_tag_vendor_id = -1;
58 static gint hf_pppoed_tag_vendor_unspecified = -1;
59 static gint hf_pppoed_tag_vspec_tags = -1;
60 static gint hf_pppoed_tag_vspec_tag = -1;
61 static gint hf_pppoed_tag_vspec_circuit_id = -1;
62 static gint hf_pppoed_tag_vspec_remote_id = -1;
63 static gint hf_pppoed_tag_vspec_act_data_rate_up = -1;
64 static gint hf_pppoed_tag_vspec_act_data_rate_down = -1;
65 static gint hf_pppoed_tag_vspec_min_data_rate_up = -1;
66 static gint hf_pppoed_tag_vspec_min_data_rate_down = -1;
67 static gint hf_pppoed_tag_vspec_attainable_data_rate_up = -1;
68 static gint hf_pppoed_tag_vspec_attainable_data_rate_down = -1;
69 static gint hf_pppoed_tag_vspec_max_data_rate_up = -1;
70 static gint hf_pppoed_tag_vspec_max_data_rate_down = -1;
71 static gint hf_pppoed_tag_vspec_min_data_rate_up_lp = -1;
72 static gint hf_pppoed_tag_vspec_min_data_rate_down_lp = -1;
73 static gint hf_pppoed_tag_vspec_max_int_delay_up = -1;
74 static gint hf_pppoed_tag_vspec_act_int_delay_up = -1;
75 static gint hf_pppoed_tag_vspec_max_int_delay_down = -1;
76 static gint hf_pppoed_tag_vspec_act_int_delay_down = -1;
77 static gint hf_pppoed_tag_vspec_access_loop_encapsulation = -1;
78 static gint hf_pppoed_tag_vspec_access_loop_encap_data_link = -1;
79 static gint hf_pppoed_tag_vspec_access_loop_encap_encap_1 = -1;
80 static gint hf_pppoed_tag_vspec_access_loop_encap_encap_2 = -1;
81 static gint hf_pppoed_tag_credits = -1;
82 static gint hf_pppoed_tag_credits_fcn = -1;
83 static gint hf_pppoed_tag_credits_bcn = -1;
84 static gint hf_pppoed_tag_metrics = -1;
85 static gint hf_pppoed_tag_metrics_r = -1;
86 static gint hf_pppoed_tag_metrics_rlq = -1;
87 static gint hf_pppoed_tag_metrics_resource = -1;
88 static gint hf_pppoed_tag_metrics_latency = -1;
89 static gint hf_pppoed_tag_metrics_curr_drate = -1;
90 static gint hf_pppoed_tag_metrics_max_drate = -1;
91 static gint hf_pppoed_tag_mdr_units = -1;
92 static gint hf_pppoed_tag_cdr_units = -1;
93 static gint hf_pppoed_tag_seq_num = -1;
94 static gint hf_pppoed_tag_cred_scale = -1;
95 static gint hf_pppoed_tag_relay_session_id = -1;
96 static gint hf_pppoed_tag_hurl = -1;
97 static gint hf_pppoed_tag_motm = -1;
98 static gint hf_pppoed_tag_max_payload = -1;
99 static gint hf_pppoed_tag_ip_route_add = -1;
100 static gint hf_pppoed_tag_service_name_error = -1;
101 static gint hf_pppoed_tag_ac_system_error = -1;
102 static gint hf_pppoed_tag_generic_error = -1;
104 /* Session protocol fields */
105 static gint hf_pppoes_tags = -1;
106 static gint hf_pppoes_tag = -1;
107 static gint hf_pppoes_tag_credits = -1;
108 static gint hf_pppoes_tag_credits_fcn = -1;
109 static gint hf_pppoes_tag_credits_bcn = -1;
111 /* Session protocol fields */
113 static gint ett_pppoed = -1;
114 static gint ett_pppoed_tags = -1;
115 static gint ett_pppoed_tag_vspec_dslf_access_loop_encaps = -1;
117 static int proto_pppoes = -1;
119 static gint ett_pppoes = -1;
120 static gint ett_pppoes_tags = -1;
122 /* PPPoE parent fields */
124 static int proto_pppoe = -1;
125 static gint ett_pppoe = -1;
128 /* Handle for calling for ppp dissector to handle session data */
129 static dissector_handle_t ppp_handle;
132 /* Preference for showing discovery tag values and lengths */
133 static gboolean global_pppoe_show_tags_and_lengths = FALSE;
136 #define PPPOE_CODE_SESSION 0x00
137 #define PPPOE_CODE_PADO 0x07
138 #define PPPOE_CODE_PADI 0x09
139 #define PPPOE_CODE_PADG 0x0a
140 #define PPPOE_CODE_PADC 0x0b
141 #define PPPOE_CODE_PADQ 0x0c
142 #define PPPOE_CODE_PADR 0x19
143 #define PPPOE_CODE_PADS 0x65
144 #define PPPOE_CODE_PADT 0xa7
145 #define PPPOE_CODE_PADM 0xd3
146 #define PPPOE_CODE_PADN 0xd4
148 #define PPPOE_TAG_EOL 0x0000
149 #define PPPOE_TAG_SVC_NAME 0x0101
150 #define PPPOE_TAG_AC_NAME 0x0102
151 #define PPPOE_TAG_HOST_UNIQ 0x0103
152 #define PPPOE_TAG_AC_COOKIE 0x0104
153 #define PPPOE_TAG_VENDOR 0x0105
154 #define PPPOE_TAG_CREDITS 0x0106
155 #define PPPOE_TAG_METRICS 0x0107
156 #define PPPOE_TAG_SEQ_NUM 0x0108
157 #define PPPOE_TAG_CRED_SCALE 0x0109
158 #define PPPOE_TAG_RELAY_ID 0x0110
159 #define PPPOE_TAG_HURL 0x0111
160 #define PPPOE_TAG_MOTM 0x0112
161 #define PPPOE_TAG_MAX_PAYLD 0x0120
162 #define PPPOE_TAG_IP_RT_ADD 0x0121
163 #define PPPOE_TAG_SVC_ERR 0x0201
164 #define PPPOE_TAG_AC_ERR 0x0202
165 #define PPPOE_TAG_GENERIC_ERR 0x0203
167 #define PPPOE_VENDOR_ID_DSLF 3561
169 #define PPPOE_TAG_VSPEC_DSLF_CIRCUIT_ID 0x01
170 #define PPPOE_TAG_VSPEC_DSLF_REMOTE_ID 0x02
171 #define PPPOE_TAG_VSPEC_DSLF_ACT_DATA_RATE_UP 0x81
172 #define PPPOE_TAG_VSPEC_DSLF_ACT_DATA_RATE_DOWN 0x82
173 #define PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_UP 0x83
174 #define PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_DOWN 0x84
175 #define PPPOE_TAG_VSPEC_DSLF_ATTAINABLE_DATA_RATE_UP 0x85
176 #define PPPOE_TAG_VSPEC_DSLF_ATTAINABLE_DATA_RATE_DOWN 0x86
177 #define PPPOE_TAG_VSPEC_DSLF_MAX_DATA_RATE_UP 0x87
178 #define PPPOE_TAG_VSPEC_DSLF_MAX_DATA_RATE_DOWN 0x88
179 #define PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_UP_LP 0x89
180 #define PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_DOWN_LP 0x8a
181 #define PPPOE_TAG_VSPEC_DSLF_MAX_INT_DELAY_UP 0x8b
182 #define PPPOE_TAG_VSPEC_DSLF_ACT_INT_DELAY_UP 0x8c
183 #define PPPOE_TAG_VSPEC_DSLF_MAX_INT_DELAY_DOWN 0x8d
184 #define PPPOE_TAG_VSPEC_DSLF_ACT_INT_DELAY_DOWN 0x8e
185 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAPSULATION 0x90
187 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_DATA_LINK_ATM 0x00
188 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_DATA_LINK_ETH 0x01
190 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_1_NA 0x00
191 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_1_UNTAGGED_ETH 0x01
192 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_1_SINLE_TAGGED_ETH 0x02
194 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_NA 0x00
195 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_PPPOA_LLC 0x01
196 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_PPPOA_NULL 0x02
197 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_IPOA_LLC 0x03
198 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_IPOA_NULL 0x04
199 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_ETH_OVER_AAL5_LLC_WITH_FCS 0x05
200 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_ETH_OVER_AAL5_LLC_WITHOUT_FCS 0x06
201 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_ETH_OVER_AAL5_NULL_WITH_FCS 0x07
202 #define PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_ETH_OVER_AAL5_NULL_WITHOUT_FCS 0x08
204 #define PPPOE_CDR_MASK 0x06
205 #define PPPOE_MDR_MASK 0x18
206 #define PPPOE_RCV_ONLY_MASK 0x01
208 #define PPPOE_SCALE_KBPS 0x00
209 #define PPPOE_SCALE_MBPS 0x01
210 #define PPPOE_SCALE_GBPS 0x02
211 #define PPPOE_SCALE_TBPS 0x03
214 static const value_string code_vals[] = {
215 {PPPOE_CODE_SESSION, "Session Data" },
216 {PPPOE_CODE_PADO, "Active Discovery Offer (PADO)" },
217 {PPPOE_CODE_PADI, "Active Discovery Initiation (PADI)" },
218 {PPPOE_CODE_PADG, "Active Discovery Session-Grant (PADG)" },
219 {PPPOE_CODE_PADC, "Active Discovery Session-Credit Resp.(PADC)" },
220 {PPPOE_CODE_PADQ, "Active Discovery Quality (PADQ)" },
221 {PPPOE_CODE_PADR, "Active Discovery Request (PADR)" },
222 {PPPOE_CODE_PADS, "Active Discovery Session-confirmation (PADS)"},
223 {PPPOE_CODE_PADT, "Active Discovery Terminate (PADT)" },
224 {PPPOE_CODE_PADM, "Active Discovery Message (PADM)" },
225 {PPPOE_CODE_PADN, "Active Discovery Network (PADN)" },
230 static const value_string tag_vals[] = {
231 {PPPOE_TAG_EOL, "End-Of-List" },
232 {PPPOE_TAG_SVC_NAME, "Service-Name" },
233 {PPPOE_TAG_AC_NAME, "AC-Name" },
234 {PPPOE_TAG_HOST_UNIQ, "Host-Uniq" },
235 {PPPOE_TAG_AC_COOKIE, "AC-Cookie" },
236 {PPPOE_TAG_VENDOR, "Vendor-Specific" },
237 {PPPOE_TAG_CREDITS, "Credits" },
238 {PPPOE_TAG_METRICS, "Metrics" },
239 {PPPOE_TAG_SEQ_NUM, "Sequence Number" },
240 {PPPOE_TAG_CRED_SCALE, "Credit Scale Factor"},
241 {PPPOE_TAG_RELAY_ID, "Relay-Session-Id" },
242 {PPPOE_TAG_HURL, "HURL" },
243 {PPPOE_TAG_MOTM, "MOTM" },
244 {PPPOE_TAG_MAX_PAYLD, "PPP-Max-Payload" },
245 {PPPOE_TAG_IP_RT_ADD, "IP Route Add" },
246 {PPPOE_TAG_SVC_ERR, "Service-Name-Error"},
247 {PPPOE_TAG_AC_ERR, "AC-System-Error" },
248 {PPPOE_TAG_GENERIC_ERR,"Generic-Error" },
252 static const value_string vspec_tag_vals[] = {
253 {PPPOE_TAG_VSPEC_DSLF_CIRCUIT_ID, "Circuit-ID" },
254 {PPPOE_TAG_VSPEC_DSLF_REMOTE_ID, "Remote-ID" },
255 {PPPOE_TAG_VSPEC_DSLF_ACT_DATA_RATE_UP, "Actual-Data-Rate-Up" },
256 {PPPOE_TAG_VSPEC_DSLF_ACT_DATA_RATE_DOWN, "Actual-Data-Rate-Down" },
257 {PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_UP, "Min-Data-Rate-Up" },
258 {PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_DOWN, "Min-Data-Rate-Down" },
259 {PPPOE_TAG_VSPEC_DSLF_ATTAINABLE_DATA_RATE_UP, "Attainable-Data-Rate-Up" },
260 {PPPOE_TAG_VSPEC_DSLF_ATTAINABLE_DATA_RATE_DOWN, "Attainable-Data-Rate-Down" },
261 {PPPOE_TAG_VSPEC_DSLF_MAX_DATA_RATE_UP, "Max-Data-Rate-Up" },
262 {PPPOE_TAG_VSPEC_DSLF_MAX_DATA_RATE_DOWN, "Max-Data-Rate-Down" },
263 {PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_UP_LP, "Min-Data-Rate-Up-Low-Power" },
264 {PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_DOWN_LP, "Min-Data-Rate-Down-Low-Power" },
265 {PPPOE_TAG_VSPEC_DSLF_MAX_INT_DELAY_UP, "Max-Interleaving-Delay-Up" },
266 {PPPOE_TAG_VSPEC_DSLF_ACT_INT_DELAY_UP, "Actual-Interleaving-Delay-Up" },
267 {PPPOE_TAG_VSPEC_DSLF_MAX_INT_DELAY_DOWN, "Max-Interleaving-Delay-Down" },
268 {PPPOE_TAG_VSPEC_DSLF_ACT_INT_DELAY_DOWN, "Actual-Interleaving-Delay-Down"},
269 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAPSULATION, "Access-Loop-Encapsulation" },
273 static const value_string vspec_tag_dslf_access_loop_encap_data_link_vals[] = {
274 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_DATA_LINK_ATM, "ATM AAL5"},
275 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_DATA_LINK_ETH, "Ethernet"},
279 static const value_string vspec_tag_dslf_access_loop_encap_encap_1_vals[] = {
280 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_1_NA, "NA" },
281 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_1_UNTAGGED_ETH, "Untagged Ethernet" },
282 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_1_SINLE_TAGGED_ETH, "Single-tagged Ethernet"},
286 static const value_string vspec_tag_dslf_access_loop_encap_encap_2_vals[] = {
287 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_NA, "NA" },
288 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_PPPOA_LLC, "PPPoA LLC" },
289 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_PPPOA_NULL, "PPPoA Null" },
290 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_IPOA_LLC, "IPoA LLC" },
291 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_IPOA_NULL, "IPoA Null" },
292 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_ETH_OVER_AAL5_LLC_WITH_FCS, "Ethernet over AAL5 LLC w FCS" },
293 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_ETH_OVER_AAL5_LLC_WITHOUT_FCS, "Ethernet over AAL5 LLC w/o FCS" },
294 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_ETH_OVER_AAL5_NULL_WITH_FCS, "Ethernet over AAL5 Null w FCS" },
295 {PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAP_ENCAPS_2_ETH_OVER_AAL5_NULL_WITHOUT_FCS,"Ethernet over AAL5 Null w/o FCS"},
299 const value_string datarate_scale_vals[] = {
300 {PPPOE_SCALE_KBPS, "kilobits per second"},
301 {PPPOE_SCALE_MBPS, "megabits per second"},
302 {PPPOE_SCALE_GBPS, "gigabits per second"},
303 {PPPOE_SCALE_TBPS, "terabits per second"},
308 #define CASE_VSPEC_DSLF_TAG(tag_name, relation, length, hf_var) case tag_name: \
309 if (!(poe_tag_length relation length)) { \
310 expert_add_info_format(pinfo, pppoe_tree, PI_MALFORMED, PI_WARN, "%s: Wrong length: %u (expected %s %d)", \
311 val_to_str(poe_tag, vspec_tag_vals, "Unknown"), poe_tag_length, #relation, length); \
313 proto_tree_add_item(pppoe_tree, hf_var, tvb, \
314 tagstart+2, poe_tag_length, FALSE); \
318 /* Dissect Vendor-Specific Tags introduced by the DSLF */
320 dissect_pppoe_subtags_dslf(tvbuff_t *tvb, packet_info *pinfo _U_, int offset, proto_tree *tree,
324 guint8 poe_tag_length;
327 proto_tree *pppoe_tree, *ti, *encaps_tree;
329 /* Start Decoding Here. */
332 /* Create tags subtree */
333 ti = proto_tree_add_item(tree, hf_pppoed_tag_vspec_tags, tvb, offset, payload_length, FALSE);
334 pppoe_tree = proto_item_add_subtree(ti, ett_pppoed_tags);
338 /* Loop until all data seen or End-Of-List tag found */
339 while (tagstart <= offset + payload_length-2)
341 poe_tag = tvb_get_guint8(tvb, tagstart);
342 poe_tag_length = tvb_get_guint8(tvb, tagstart + 1);
344 /* Tag value and data length */
345 if (global_pppoe_show_tags_and_lengths)
347 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_vspec_tag, tvb, tagstart, 1, FALSE);
348 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_length_8, tvb, tagstart+1, 1, FALSE);
354 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_CIRCUIT_ID, <=, 63,
355 hf_pppoed_tag_vspec_circuit_id)
356 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_REMOTE_ID, <=, 63,
357 hf_pppoed_tag_vspec_remote_id)
358 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_ACT_DATA_RATE_UP, ==, 4,
359 hf_pppoed_tag_vspec_act_data_rate_up)
360 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_ACT_DATA_RATE_DOWN, ==, 4,
361 hf_pppoed_tag_vspec_act_data_rate_down)
362 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_UP, ==, 4,
363 hf_pppoed_tag_vspec_min_data_rate_up)
364 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_DOWN, ==, 4,
365 hf_pppoed_tag_vspec_min_data_rate_down)
366 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_ATTAINABLE_DATA_RATE_UP, ==, 4,
367 hf_pppoed_tag_vspec_attainable_data_rate_up)
368 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_ATTAINABLE_DATA_RATE_DOWN, ==, 4,
369 hf_pppoed_tag_vspec_attainable_data_rate_down)
370 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_MAX_DATA_RATE_UP, ==, 4,
371 hf_pppoed_tag_vspec_max_data_rate_up)
372 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_MAX_DATA_RATE_DOWN, ==, 4,
373 hf_pppoed_tag_vspec_max_data_rate_down)
374 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_UP_LP, ==, 4,
375 hf_pppoed_tag_vspec_min_data_rate_up_lp)
376 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_MIN_DATA_RATE_DOWN_LP, ==, 4,
377 hf_pppoed_tag_vspec_min_data_rate_down_lp)
378 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_MAX_INT_DELAY_UP, ==, 4,
379 hf_pppoed_tag_vspec_max_int_delay_up)
380 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_ACT_INT_DELAY_UP, ==, 4,
381 hf_pppoed_tag_vspec_act_int_delay_up)
382 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_MAX_INT_DELAY_DOWN, ==, 4,
383 hf_pppoed_tag_vspec_max_int_delay_down)
384 CASE_VSPEC_DSLF_TAG(PPPOE_TAG_VSPEC_DSLF_ACT_INT_DELAY_DOWN, ==, 4,
385 hf_pppoed_tag_vspec_act_int_delay_down)
386 case PPPOE_TAG_VSPEC_DSLF_ACCESS_LOOP_ENCAPSULATION:
387 ti = proto_tree_add_item(pppoe_tree, hf_pppoed_tag_vspec_access_loop_encapsulation, tvb,
388 tagstart+2, 3, FALSE);
389 if (poe_tag_length != 3) {
390 expert_add_info_format(pinfo, ti, PI_MALFORMED, PI_WARN,
391 "%s: Wrong length: %u (expected 3)",
392 val_to_str(poe_tag, vspec_tag_vals, "Unknown"), poe_tag_length);
394 encaps_tree = proto_item_add_subtree(ti, ett_pppoed_tag_vspec_dslf_access_loop_encaps);
395 proto_tree_add_item(encaps_tree, hf_pppoed_tag_vspec_access_loop_encap_data_link,
396 tvb, tagstart+2, 1, FALSE);
397 proto_tree_add_item(encaps_tree, hf_pppoed_tag_vspec_access_loop_encap_encap_1,
398 tvb, tagstart+3, 1, FALSE);
399 proto_tree_add_item(encaps_tree, hf_pppoed_tag_vspec_access_loop_encap_encap_2,
400 tvb, tagstart+4, 1, FALSE);
404 if (poe_tag_length > 0 )
406 /* Presumably unknown tag;
407 show tag value if we didn't do it above */
408 if (!global_pppoe_show_tags_and_lengths)
410 proto_tree_add_item(pppoe_tree, hf_pppoed_tag, tvb, tagstart, 1, FALSE);
411 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_length_8, tvb, tagstart+1, 1, FALSE);
413 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_unknown_data, tvb,
414 tagstart+1, poe_tag_length, FALSE);
418 tagstart += (2 + poe_tag_length);
424 /* Dissect discovery protocol tags */
426 dissect_pppoe_tags(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree,
430 guint16 poe_tag_length;
434 proto_tree *pppoe_tree;
436 proto_item *pppoe_tree_tag_length_item = NULL;
439 /* Start Decoding Here. */
442 /* Create tags subtree */
443 ti = proto_tree_add_item(tree, hf_pppoed_tags, tvb, offset, payload_length-6, FALSE);
444 pppoe_tree = proto_item_add_subtree(ti, ett_pppoed_tags);
448 /* Loop until all data seen or End-Of-List tag found */
449 while (tagstart <= payload_length-2)
451 poe_tag = tvb_get_ntohs(tvb, tagstart);
452 poe_tag_length = tvb_get_ntohs(tvb, tagstart + 2);
454 /* Tag value and data length */
455 if (global_pppoe_show_tags_and_lengths)
457 proto_tree_add_item(pppoe_tree, hf_pppoed_tag, tvb, tagstart, 2, FALSE);
458 pppoe_tree_tag_length_item =
459 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_length, tvb, tagstart+2, 2, FALSE);
465 case PPPOE_TAG_SVC_NAME:
466 if (poe_tag_length > 0)
468 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_service_name, tvb,
469 tagstart+4, poe_tag_length, FALSE);
472 case PPPOE_TAG_AC_NAME:
473 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_ac_name, tvb,
474 tagstart+4, poe_tag_length, FALSE);
475 /* Show AC-Name in info column */
476 if (check_col(pinfo->cinfo, COL_INFO))
478 col_append_fstr(pinfo->cinfo, COL_INFO, " AC-Name='%s'",
479 tvb_get_ephemeral_string(tvb, tagstart+4, poe_tag_length));
482 case PPPOE_TAG_HOST_UNIQ:
483 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_host_uniq, tvb,
484 tagstart+4, poe_tag_length, FALSE);
486 case PPPOE_TAG_AC_COOKIE:
487 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_ac_cookie, tvb,
488 tagstart+4, poe_tag_length, FALSE);
490 case PPPOE_TAG_VENDOR:
491 if (poe_tag_length >= 4)
493 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_vendor_id, tvb,
494 tagstart+4, 4, FALSE);
496 if (poe_tag_length > 4)
498 guint32 vendor_id = tvb_get_ntohl(tvb, tagstart+4);
501 case PPPOE_VENDOR_ID_DSLF:
502 dissect_pppoe_subtags_dslf(tvb,pinfo,tagstart+4+4,pppoe_tree,poe_tag_length-4);
505 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_vendor_unspecified, tvb,
506 tagstart+4+4, poe_tag_length-4, FALSE);
511 case PPPOE_TAG_CREDITS:
512 if (poe_tag_length == 4)
514 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_credits_fcn, tvb,
515 tagstart+4, 2, FALSE);
516 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_credits_bcn, tvb,
517 tagstart+6, 2, FALSE);
519 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_credits, tvb,
520 tagstart+4, poe_tag_length, FALSE);
523 case PPPOE_TAG_METRICS:
524 if (poe_tag_length == 10)
526 poe_rsv = tvb_get_ntohs(tvb, tagstart+4);
528 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_mdr_units, tvb,
529 tagstart+4, 2, FALSE);
530 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_cdr_units, tvb,
531 tagstart+4, 2, FALSE);
532 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_metrics_r, tvb,
533 tagstart+4, 2, FALSE);
534 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_metrics_rlq, tvb,
535 tagstart+6, 1, FALSE);
536 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_metrics_resource, tvb,
537 tagstart+7, 1, FALSE);
538 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_metrics_latency, tvb,
539 tagstart+8, 2, FALSE);
542 ti = proto_tree_add_item(pppoe_tree, hf_pppoed_tag_metrics_curr_drate, tvb,
543 tagstart+10, 2, FALSE);
545 switch ((poe_rsv & PPPOE_CDR_MASK) >> 1)
547 case (PPPOE_SCALE_KBPS):
548 proto_item_append_text(ti, " kbps");
550 case (PPPOE_SCALE_MBPS):
551 proto_item_append_text(ti, " mbps");
553 case (PPPOE_SCALE_GBPS):
554 proto_item_append_text(ti, " gbps");
556 case (PPPOE_SCALE_TBPS):
557 proto_item_append_text(ti, " tbps");
562 ti = proto_tree_add_item(pppoe_tree, hf_pppoed_tag_metrics_max_drate, tvb,
563 tagstart+12, 2, FALSE);
565 switch ((poe_rsv & PPPOE_MDR_MASK) >> 3)
567 case (PPPOE_SCALE_KBPS):
568 proto_item_append_text(ti, " kbps");
570 case (PPPOE_SCALE_MBPS):
571 proto_item_append_text(ti, " mbps");
573 case (PPPOE_SCALE_GBPS):
574 proto_item_append_text(ti, " gbps");
576 case (PPPOE_SCALE_TBPS):
577 proto_item_append_text(ti, " tbps");
582 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_metrics, tvb,
583 tagstart+4, poe_tag_length, FALSE);
586 case PPPOE_TAG_SEQ_NUM:
587 if (poe_tag_length == 2) {
588 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_seq_num, tvb,
589 tagstart+4, poe_tag_length, FALSE);
591 if (global_pppoe_show_tags_and_lengths) {
592 proto_item_append_text(pppoe_tree_tag_length_item, " [Wrong: should be 2]");
593 item = pppoe_tree_tag_length_item;
595 item = proto_tree_add_text(pppoe_tree, tvb, tagstart+4, poe_tag_length,
596 "%s: Wrong length: %u (expected 2)",
597 proto_registrar_get_name(hf_pppoed_tag_seq_num),
600 expert_add_info_format(pinfo, item, PI_MALFORMED, PI_WARN,
601 "Sequence Number tag: Wrong length: %u (expected 2)",
605 case PPPOE_TAG_CRED_SCALE:
606 if (poe_tag_length == 2) {
607 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_cred_scale, tvb,
608 tagstart+4, poe_tag_length, FALSE);
610 if (global_pppoe_show_tags_and_lengths) {
611 proto_item_append_text(pppoe_tree_tag_length_item, " [Wrong: should be 2]");
612 item = pppoe_tree_tag_length_item;
614 item = proto_tree_add_text(pppoe_tree, tvb, tagstart+4, poe_tag_length,
615 "%s: Wrong length: %u (expected 2)",
616 proto_registrar_get_name(hf_pppoed_tag_cred_scale),
619 expert_add_info_format(pinfo, item, PI_MALFORMED, PI_WARN,
620 "Credit Scale Factor tag: Wrong length: %u (expected 2)",
624 case PPPOE_TAG_RELAY_ID:
625 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_relay_session_id, tvb,
626 tagstart+4, poe_tag_length, FALSE);
629 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_hurl, tvb,
630 tagstart+4, poe_tag_length, FALSE);
633 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_motm, tvb,
634 tagstart+4, poe_tag_length, FALSE);
636 case PPPOE_TAG_MAX_PAYLD:
637 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_max_payload, tvb,
638 tagstart+4, poe_tag_length, FALSE);
640 case PPPOE_TAG_IP_RT_ADD:
641 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_ip_route_add, tvb,
642 tagstart+4, poe_tag_length, FALSE);
645 /* These error tag values should be interpreted as a utf-8 unterminated
647 case PPPOE_TAG_SVC_ERR:
648 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_service_name_error, tvb,
649 tagstart+4, poe_tag_length, FALSE);
651 case PPPOE_TAG_AC_ERR:
652 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_ac_system_error, tvb,
653 tagstart+4, poe_tag_length, FALSE);
655 case PPPOE_TAG_GENERIC_ERR:
656 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_generic_error, tvb,
657 tagstart+4, poe_tag_length, FALSE);
660 /* Get out if see end-of-list tag */
665 if (poe_tag_length > 0 )
667 /* Presumably unknown tag;
668 show tag value if we didn't
670 if (!global_pppoe_show_tags_and_lengths)
672 proto_tree_add_item(pppoe_tree, hf_pppoed_tag, tvb, tagstart, 2, FALSE);
673 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_length, tvb, tagstart+2, 2, FALSE);
675 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_unknown_data, tvb,
676 tagstart+2, poe_tag_length, FALSE);
680 tagstart += (4 + poe_tag_length);
686 /* Discovery protocol, i.e. PPP session not yet established */
687 static void dissect_pppoed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
690 guint16 reported_payload_length;
692 proto_tree *pppoe_tree = NULL;
695 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPPoED");
696 col_clear(pinfo->cinfo, COL_INFO);
698 /* Start Decoding Here. */
699 pppoe_code = tvb_get_guint8(tvb, 1);
701 if (check_col(pinfo->cinfo, COL_INFO))
703 col_append_str(pinfo->cinfo, COL_INFO, val_to_str(pppoe_code, code_vals, "Unknown"));
706 /* Read length of payload */
707 reported_payload_length = tvb_get_ntohs(tvb, 4);
711 ti = proto_tree_add_item(tree, proto_pppoed, tvb, 0, reported_payload_length+6, FALSE);
712 pppoe_tree = proto_item_add_subtree(ti, ett_pppoed);
714 /* Dissect fixed fields */
715 proto_tree_add_item(pppoe_tree, hf_pppoe_version, tvb, 0, 1, FALSE);
716 proto_tree_add_item(pppoe_tree, hf_pppoe_type, tvb, 0, 1, FALSE);
717 proto_tree_add_item(pppoe_tree, hf_pppoe_code, tvb, 1, 1, FALSE);
718 proto_tree_add_item(pppoe_tree, hf_pppoe_session_id, tvb, 2, 2, FALSE);
719 proto_tree_add_item(pppoe_tree, hf_pppoe_payload_length, tvb, 4, 2, FALSE);
722 /* Now dissect any tags */
723 if (reported_payload_length > 0)
725 dissect_pppoe_tags(tvb, pinfo, 6, pppoe_tree, 6+reported_payload_length);
730 void proto_register_pppoed(void)
732 static hf_register_info hf[] =
734 /* Discovery tag fields */
736 { "PPPoE Tags", "pppoed.tags", FT_NONE, BASE_NONE,
737 NULL, 0x0, NULL, HFILL
741 { "Tag", "pppoed.tag", FT_UINT16, BASE_HEX,
742 VALS(tag_vals), 0x0, NULL, HFILL
745 { &hf_pppoed_tag_length,
746 { "Tag Length", "pppoed.tag_length", FT_UINT16, BASE_DEC,
747 NULL, 0x0, NULL, HFILL
750 { &hf_pppoed_tag_length_8,
751 { "Tag Length", "pppoed.tag_length_8", FT_UINT8, BASE_DEC,
752 NULL, 0x0, NULL, HFILL
755 { &hf_pppoed_tag_unknown_data,
756 { "Unknown Data", "pppoed.tag.unknown_data", FT_BYTES, BASE_NONE,
757 NULL, 0x0, NULL, HFILL
760 { &hf_pppoed_tag_service_name,
761 { "Service-Name", "pppoed.tags.service_name", FT_STRING, BASE_NONE,
762 NULL, 0x0, NULL, HFILL
765 { &hf_pppoed_tag_ac_name,
766 { "AC-Name", "pppoed.tags.ac_name", FT_STRING, BASE_NONE,
767 NULL, 0x0, NULL, HFILL
770 { &hf_pppoed_tag_host_uniq,
771 { "Host-Uniq", "pppoed.tags.host_uniq", FT_BYTES, BASE_NONE,
772 NULL, 0x0, NULL, HFILL
775 { &hf_pppoed_tag_ac_cookie,
776 { "AC-Cookie", "pppoed.tags.ac_cookie", FT_BYTES, BASE_NONE,
777 NULL, 0x0, NULL, HFILL
780 { &hf_pppoed_tag_vendor_id,
781 { "Vendor id", "pppoed.tags.vendor_id", FT_UINT32, BASE_DEC,
782 NULL, 0x0, NULL, HFILL
785 { &hf_pppoed_tag_vendor_unspecified,
786 { "Vendor unspecified", "pppoed.tags.vendor_unspecified", FT_BYTES, BASE_NONE,
787 NULL, 0x0, NULL, HFILL
790 { &hf_pppoed_tag_vspec_tags,
791 { "Vendor Specific PPPoE Tags", "pppoed.tags.vendorspecific.tags", FT_NONE, BASE_NONE,
792 NULL, 0x0, NULL, HFILL
795 { &hf_pppoed_tag_vspec_tag,
796 { "Tag", "pppoed.tags.vendorspecific.tag", FT_UINT8, BASE_HEX,
797 VALS(vspec_tag_vals), 0x0, NULL, HFILL
800 { &hf_pppoed_tag_vspec_circuit_id,
801 { "Circuit ID", "pppoed.tags.circuit_id", FT_STRING, BASE_NONE,
802 NULL, 0x0, NULL, HFILL
805 { &hf_pppoed_tag_vspec_remote_id,
806 { "Remote ID", "pppoed.tags.remote_id", FT_STRING, BASE_NONE,
807 NULL, 0x0, NULL, HFILL
810 { &hf_pppoed_tag_vspec_act_data_rate_up,
811 { "Actual Data Rate Upstream", "pppoed.tags.act_data_rate_up", FT_UINT32, BASE_DEC,
812 NULL, 0x0, NULL, HFILL
815 { &hf_pppoed_tag_vspec_act_data_rate_down,
816 { "Actual Data Rate Downstream", "pppoed.tags.act_data_rate_down", FT_UINT32, BASE_DEC,
817 NULL, 0x0, NULL, HFILL
820 { &hf_pppoed_tag_vspec_min_data_rate_up,
821 { "Minimum Data Rate Upstream", "pppoed.tags.min_data_rate_up", FT_UINT32, BASE_DEC,
822 NULL, 0x0, NULL, HFILL
825 { &hf_pppoed_tag_vspec_min_data_rate_down,
826 { "Minimum Data Rate Downstream", "pppoed.tags.min_data_rate_down", FT_UINT32, BASE_DEC,
827 NULL, 0x0, NULL, HFILL
830 { &hf_pppoed_tag_vspec_attainable_data_rate_up,
831 { "Attainable DataRate Upstream", "pppoed.tags.attainable_data_rate_up", FT_UINT32, BASE_DEC,
832 NULL, 0x0, NULL, HFILL
835 { &hf_pppoed_tag_vspec_attainable_data_rate_down,
836 { "Attainable DataRate Downstream", "pppoed.tags.attainable_data_rate_down", FT_UINT32, BASE_DEC,
837 NULL, 0x0, NULL, HFILL
840 { &hf_pppoed_tag_vspec_max_data_rate_up,
841 { "Maximum Data Rate Upstream", "pppoed.tags.max_data_rate_up", FT_UINT32, BASE_DEC,
842 NULL, 0x0, NULL, HFILL
845 { &hf_pppoed_tag_vspec_max_data_rate_down,
846 { "Maximum Data Rate Downstream", "pppoed.tags.max_data_rate_down", FT_UINT32, BASE_DEC,
847 NULL, 0x0, NULL, HFILL
850 { &hf_pppoed_tag_vspec_min_data_rate_up_lp,
851 { "Min DataRate Upstream in low power state", "pppoed.tags.min_data_rate_up_lp", FT_UINT32, BASE_DEC,
852 NULL, 0x0, NULL, HFILL
855 { &hf_pppoed_tag_vspec_min_data_rate_down_lp,
856 { "Minimum Data Rate Downstream in low power state", "pppoed.tags.min_data_rate_down_lp", FT_UINT32, BASE_DEC,
857 NULL, 0x0, NULL, HFILL
860 { &hf_pppoed_tag_vspec_max_int_delay_up,
861 { "Max Interleaving Delay Upstream", "pppoed.tags.max_int_delay_up", FT_UINT32, BASE_DEC,
862 NULL, 0x0, NULL, HFILL
865 { &hf_pppoed_tag_vspec_act_int_delay_up,
866 { "Actual Interleaving Delay Upstream", "pppoed.tags.act_int_delay_up", FT_UINT32, BASE_DEC,
867 NULL, 0x0, NULL, HFILL
870 { &hf_pppoed_tag_vspec_max_int_delay_down,
871 { "Maximum Interleaving Delay Downstream", "pppoed.tags.max_int_delay_down", FT_UINT32, BASE_DEC,
872 NULL, 0x0, NULL, HFILL
875 { &hf_pppoed_tag_vspec_act_int_delay_down,
876 { "Actual Interleaving Delay Downstream", "pppoed.tags.act_int_delay_down", FT_UINT32, BASE_DEC,
877 NULL, 0x0, NULL, HFILL
880 { &hf_pppoed_tag_vspec_access_loop_encapsulation,
881 { "Access-Loop-Encapsulation", "pppoed.tags.access_loop_encap", FT_NONE, BASE_NONE,
882 NULL, 0x0, NULL, HFILL
885 { &hf_pppoed_tag_vspec_access_loop_encap_data_link,
886 { "Data link", "pppoed.tags.access_loop_encap.data_link", FT_UINT8, BASE_HEX,
887 VALS(vspec_tag_dslf_access_loop_encap_data_link_vals), 0x0, NULL, HFILL
890 { &hf_pppoed_tag_vspec_access_loop_encap_encap_1,
891 { "Encaps 1", "pppoed.tags.access_loop_encap.encap_1", FT_UINT8, BASE_HEX,
892 VALS(vspec_tag_dslf_access_loop_encap_encap_1_vals), 0x0, NULL, HFILL
895 { &hf_pppoed_tag_vspec_access_loop_encap_encap_2,
896 { "Encaps 1", "pppoed.tags.access_loop_encap.encap_2", FT_UINT8, BASE_HEX,
897 VALS(vspec_tag_dslf_access_loop_encap_encap_2_vals), 0x0, NULL, HFILL
900 { &hf_pppoed_tag_credits,
901 { "Credits", "pppoed.tags.credits", FT_BYTES, BASE_NONE,
902 NULL, 0x0, NULL, HFILL
905 { &hf_pppoed_tag_credits_fcn,
906 { "FCN", "pppoed.tags.credits.fcn", FT_UINT16, BASE_DEC,
907 NULL, 0x0, NULL, HFILL
910 { &hf_pppoed_tag_credits_bcn,
911 { "BCN", "pppoed.tags.credits.bcn", FT_UINT16, BASE_DEC,
912 NULL, 0x0, NULL, HFILL
915 { &hf_pppoed_tag_metrics,
916 { "Metrics", "pppoed.tags.metrics", FT_BYTES, BASE_NONE,
917 NULL, 0x0, NULL, HFILL
920 { &hf_pppoed_tag_metrics_r,
921 { "Receive Only", "pppoed.tags.metrics.r", FT_BOOLEAN, 16,
922 NULL, PPPOE_RCV_ONLY_MASK, NULL, HFILL
925 { &hf_pppoed_tag_mdr_units,
926 { "MDR Units", "pppoed.tags.metrics.mdr_units", FT_UINT16, BASE_HEX,
927 VALS(datarate_scale_vals), PPPOE_MDR_MASK, NULL, HFILL
930 { &hf_pppoed_tag_cdr_units,
931 { "CDR Units", "pppoed.tags.metrics.cdr_units", FT_UINT16, BASE_HEX,
932 VALS(datarate_scale_vals), PPPOE_CDR_MASK, NULL, HFILL
935 { &hf_pppoed_tag_metrics_rlq,
936 { "Relative Link Quality", "pppoed.tags.metrics.rlq", FT_UINT8, BASE_DEC,
937 NULL, 0x0, NULL, HFILL
940 { &hf_pppoed_tag_metrics_resource,
941 { "Resource", "pppoed.tags.metrics.resource", FT_UINT8, BASE_DEC,
942 NULL, 0x0, NULL, HFILL
945 { &hf_pppoed_tag_metrics_latency,
946 { "Latency", "pppoed.tags.metrics.latency", FT_UINT16, BASE_DEC,
947 NULL, 0x0, NULL, HFILL
950 { &hf_pppoed_tag_metrics_curr_drate,
951 { "Curr. datarate", "pppoed.tags.metrics.curr_drate", FT_UINT16, BASE_DEC,
952 NULL, 0x0, NULL, HFILL
955 { &hf_pppoed_tag_metrics_max_drate,
956 { "Max. datarate", "pppoed.tags.metrics.max_drate", FT_UINT16, BASE_DEC,
957 NULL, 0x0, NULL, HFILL
960 { &hf_pppoed_tag_seq_num,
961 { "Sequence Number", "pppoed.tags.seq_num", FT_UINT16, BASE_HEX,
962 NULL, 0x0, NULL, HFILL
965 { &hf_pppoed_tag_cred_scale,
966 { "Credit Scale Factor", "pppoed.tags.credit_scale", FT_UINT16, BASE_DEC,
967 NULL, 0x0, NULL, HFILL
970 { &hf_pppoed_tag_relay_session_id,
971 { "Relay-Session-Id", "pppoed.tags.relay_session_id", FT_BYTES, BASE_NONE,
972 NULL, 0x0, NULL, HFILL
975 { &hf_pppoed_tag_hurl,
976 { "HURL", "pppoed.tags.hurl", FT_BYTES, BASE_NONE,
977 NULL, 0x0, NULL, HFILL
980 { &hf_pppoed_tag_motm,
981 { "MOTM", "pppoed.tags.motm", FT_BYTES, BASE_NONE,
982 NULL, 0x0, NULL, HFILL
985 { &hf_pppoed_tag_max_payload,
986 { "PPP Max Palyload", "pppoed.tags.max_payload", FT_BYTES, BASE_NONE,
987 NULL, 0x0, NULL, HFILL
990 { &hf_pppoed_tag_ip_route_add,
991 { "IP Route Add", "pppoed.tags.ip_route_add", FT_BYTES, BASE_NONE,
992 NULL, 0x0, NULL, HFILL
995 { &hf_pppoed_tag_service_name_error,
996 { "Service-Name-Error", "pppoed.tags.service_name_error", FT_STRING, BASE_NONE,
997 NULL, 0x0, NULL, HFILL
1000 { &hf_pppoed_tag_ac_system_error,
1001 { "AC-System-Error", "pppoed.tags.ac_system_error", FT_STRING, BASE_NONE,
1002 NULL, 0x0, NULL, HFILL
1005 { &hf_pppoed_tag_generic_error,
1006 { "Generic-Error", "pppoed.tags.generic_error", FT_STRING, BASE_NONE,
1007 NULL, 0x0, NULL, HFILL
1012 static gint *ett[] = {
1015 &ett_pppoed_tag_vspec_dslf_access_loop_encaps
1018 module_t *pppoed_module;
1020 /* Register protocol and fields */
1021 proto_pppoed = proto_register_protocol("PPP-over-Ethernet Discovery",
1022 "PPPoED", "pppoed");
1023 proto_register_subtree_array(ett, array_length(ett));
1024 proto_register_field_array(proto_pppoed, hf, array_length(hf));
1026 /* Preference setting */
1027 pppoed_module = prefs_register_protocol(proto_pppoed, NULL);
1028 prefs_register_bool_preference(pppoed_module, "show_tags_and_lengths",
1029 "Show tag values and lengths",
1030 "Show values of tags and lengths of data fields",
1031 &global_pppoe_show_tags_and_lengths);
1034 void proto_reg_handoff_pppoed(void)
1036 dissector_handle_t pppoed_handle;
1038 pppoed_handle = create_dissector_handle(dissect_pppoed, proto_pppoed);
1039 dissector_add_uint("ethertype", ETHERTYPE_PPPOED, pppoed_handle);
1043 /* Session protocol, i.e. PPP session established */
1044 static void dissect_pppoes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1047 guint16 pppoe_session_id;
1048 guint16 reported_payload_length;
1050 guint16 poe_tag_length;
1051 gint actual_payload_length;
1052 gint length, reported_length;
1053 gint credit_offset = 0, tagstart = 0;
1056 proto_tree *pppoe_tree;
1057 proto_item *ti = NULL;
1060 col_set_str(pinfo->cinfo, COL_PROTOCOL, "PPPoES");
1061 col_clear(pinfo->cinfo, COL_INFO);
1063 /* Start Decoding Here. */
1064 pppoe_code = tvb_get_guint8(tvb, 1);
1066 if (check_col(pinfo->cinfo,COL_INFO))
1068 col_add_str(pinfo->cinfo, COL_INFO,
1069 val_to_str(pppoe_code, code_vals, "Unknown"));
1072 pppoe_session_id = tvb_get_ntohs(tvb, 2);
1073 reported_payload_length = tvb_get_ntohs(tvb, 4);
1074 actual_payload_length = tvb_reported_length_remaining(tvb, 6);
1078 ti = proto_tree_add_item(tree, proto_pppoes, tvb, 0, 6, FALSE);
1079 pppoe_tree = proto_item_add_subtree(ti, ett_pppoe);
1081 proto_tree_add_item(pppoe_tree, hf_pppoe_version, tvb, 0, 1, FALSE);
1082 proto_tree_add_item(pppoe_tree, hf_pppoe_type, tvb, 0, 1, FALSE);
1083 proto_tree_add_item(pppoe_tree, hf_pppoe_code, tvb, 1, 1, FALSE);
1084 proto_tree_add_item(pppoe_tree, hf_pppoe_session_id, tvb, 2, 2, FALSE);
1085 ti = proto_tree_add_item(pppoe_tree, hf_pppoe_payload_length, tvb, 4, 2, FALSE);
1088 if (PPPOE_TAG_CREDITS == tvb_get_ntohs(tvb, 6))
1091 poe_tag = tvb_get_ntohs(tvb, tagstart);
1092 poe_tag_length = tvb_get_ntohs(tvb, tagstart + 2);
1094 /* Create tags subtree */
1095 ti = proto_tree_add_item(pppoe_tree, hf_pppoes_tags, tvb, tagstart, 8, FALSE);
1096 pppoe_tree = proto_item_add_subtree(ti, ett_pppoes_tags);
1099 if (poe_tag_length == 4)
1101 proto_tree_add_item(pppoe_tree, hf_pppoes_tag_credits_fcn, tvb,
1102 tagstart+4, 2, FALSE);
1103 proto_tree_add_item(pppoe_tree, hf_pppoes_tag_credits_bcn, tvb,
1104 tagstart+6, 2, FALSE);
1106 proto_tree_add_item(pppoe_tree, hf_pppoed_tag_credits, tvb,
1107 tagstart+4, poe_tag_length, FALSE);
1115 * The only reason why the payload length from the header
1116 * should differ from the remaining data in the packet
1117 * would be if the total packet length, including Ethernet
1118 * CRC, were < 64 bytes, so that padding was required.
1120 * That means that you have 14 bytes of Ethernet header,
1121 * 4 bytes of FCS, and fewer than 46 bytes of PPPoE packet.
1123 * If that's not the case, we report a difference between
1124 * the payload length in the packet, and the amount of
1125 * data following the PPPoE header, as an error.
1127 if (tvb_reported_length(tvb) > 46) {
1129 * Be forgiving about a possible trailing FCS.
1131 * XXX - this dissector currently doesn't know
1132 * whether any extra data past the end of the PPP
1133 * payload is an FCS or not.
1135 * If we know that we have an FCS, or that we don't
1136 * have an FCS, we should have been handed a tvbuff
1137 * without the FCS, and we should just do the strict
1140 * If we don't know whether we have an FCS, then:
1142 * if this isn't over Ethernet - the "E" in "PPPoE"
1143 * nonwithstanding, it can also run on top of 802.11,
1144 * for example - there's no trailer, so any data
1145 * past the payload length is either an FCS or
1148 * if this is over Ethernet, there shouldn't be
1149 * a trailer, as the packet is long enough not to
1150 * require a trailer, as per the above;
1152 * so perhaps we should assume that if we have exactly
1153 * 4 bytes of extra information, it's an FCS, otherwise
1156 * Perhaps we need to have a routine to call to
1157 * do all the length checking, etc., and call it
1158 * from here and from other dissectors where the
1159 * protocol has a length field, or have a way to
1160 * tell the dissector that called us which field
1161 * has the length field and have *that* dissector
1162 * do the length checking and add the expert info
1163 * to the length field, *after* it does all the
1167 /* retrieve the control protocol code if it's there */
1168 cp_code = tvb_get_ntohs(tvb, 6);
1170 * The session payload length expressly does not include pad bytes
1171 * when LCP or IPCP are present, so avoid the spurious error message
1173 if ((cp_code != PPP_LCP) && (cp_code != PPP_IPCP) &&
1174 (reported_payload_length != actual_payload_length) &&
1175 ((reported_payload_length + 4) != actual_payload_length)) {
1176 proto_item_append_text(ti, " [incorrect, should be %u]",
1177 actual_payload_length);
1178 expert_add_info_format(pinfo, ti, PI_MALFORMED,
1179 PI_WARN, "Possible bad payload length %u != %u",
1180 reported_payload_length, actual_payload_length);
1185 * Construct a tvbuff containing the PPP packet.
1187 length = tvb_length_remaining(tvb, 6);
1188 reported_length = tvb_reported_length_remaining(tvb, 6);
1189 DISSECTOR_ASSERT(length >= 0);
1190 DISSECTOR_ASSERT(reported_length >= 0);
1191 if (length > reported_length)
1192 length = reported_length;
1193 if ((guint)length > reported_payload_length)
1194 length = reported_payload_length;
1195 if ((guint)reported_length > reported_payload_length)
1196 reported_length = reported_payload_length;
1197 next_tvb = tvb_new_subset(tvb,(6 + credit_offset),
1198 (length - credit_offset),
1199 (reported_length - credit_offset));
1200 call_dissector(ppp_handle,next_tvb,pinfo,tree);
1203 void proto_register_pppoes(void)
1206 static hf_register_info hf[] =
1209 { "PPPoE Tags", "pppoes.tags", FT_NONE, BASE_NONE,
1210 NULL, 0x0, NULL, HFILL
1214 { "Tag", "pppoes.tag", FT_UINT16, BASE_HEX,
1215 VALS(tag_vals), 0x0, NULL, HFILL
1218 { &hf_pppoes_tag_credits,
1219 { "Credits", "pppoes.tags.credits", FT_BYTES, BASE_NONE,
1220 NULL, 0x0, NULL, HFILL
1223 { &hf_pppoes_tag_credits_fcn,
1224 { "FCN", "pppoes.tags.credits.fcn", FT_UINT16, BASE_DEC,
1225 NULL, 0x0, NULL, HFILL
1228 { &hf_pppoes_tag_credits_bcn,
1229 { "BCN", "pppoes.tags.credits.bcn", FT_UINT16, BASE_DEC,
1230 NULL, 0x0, NULL, HFILL
1235 static gint *ett[] = {
1240 /* Register protocol */
1241 proto_pppoes = proto_register_protocol("PPP-over-Ethernet Session", "PPPoES", "pppoes");
1243 proto_register_subtree_array(ett, array_length(ett));
1244 proto_register_field_array(proto_pppoes, hf, array_length(hf));
1247 void proto_register_pppoe(void)
1249 static hf_register_info hf[] =
1251 /* These fields common to discovery and session protocols */
1252 { &hf_pppoe_version,
1253 { "Version", "pppoe.version", FT_UINT8, BASE_DEC,
1254 NULL, 0xf0, NULL, HFILL
1258 { "Type", "pppoe.type", FT_UINT8, BASE_DEC,
1259 NULL, 0x0f, NULL, HFILL
1263 { "Code", "pppoe.code", FT_UINT8, BASE_HEX,
1264 VALS(code_vals), 0x0, NULL, HFILL
1267 { &hf_pppoe_session_id,
1268 { "Session ID", "pppoe.session_id", FT_UINT16, BASE_HEX,
1269 NULL, 0x0, NULL, HFILL
1272 { &hf_pppoe_payload_length,
1273 { "Payload Length", "pppoe.payload_length", FT_UINT16, BASE_DEC,
1274 NULL, 0x0, NULL, HFILL
1279 static gint *ett[] = {
1283 /* Register protocol */
1284 proto_pppoe = proto_register_protocol("PPP-over-Ethernet", "PPPoE", "pppoe");
1286 proto_register_subtree_array(ett, array_length(ett));
1287 proto_register_field_array(proto_pppoe, hf, array_length(hf));
1291 void proto_reg_handoff_pppoes(void)
1293 dissector_handle_t pppoes_handle =
1294 create_dissector_handle(dissect_pppoes, proto_pppoes);
1295 dissector_add_uint("ethertype", ETHERTYPE_PPPOES, pppoes_handle);
1297 /* Get a handle for the PPP dissector */
1298 ppp_handle = find_dissector("ppp");