@@ -23,6 +23,7 @@ static const char rcsid[] _U_ =
2323 "@(#) $Header: /tcpdump/master/tcpdump/print-ether.c,v 1.106 2008-02-06 10:47:53 guy Exp $ (LBL)" ;
2424#endif
2525
26+ #define NETDISSECT_REWORKED
2627#ifdef HAVE_CONFIG_H
2728#include "config.h"
2829#endif
@@ -84,7 +85,8 @@ const struct tok ethertype_values[] = {
8485};
8586
8687static inline void
87- ether_hdr_print (register const u_char * bp , u_int length )
88+ ether_hdr_print (netdissect_options * ndo ,
89+ const u_char * bp , u_int length )
8890{
8991 register const struct ether_header * ep ;
9092 u_int16_t ether_type ;
@@ -96,7 +98,7 @@ ether_hdr_print(register const u_char *bp, u_int length)
9698 etheraddr_string (EDST (ep )));
9799
98100 ether_type = EXTRACT_16BITS (& ep -> ether_type );
99- if (!qflag ) {
101+ if (!ndo -> ndo_qflag ) {
100102 if (ether_type <= ETHERMTU )
101103 (void )printf (", 802.3" );
102104 else
@@ -120,8 +122,9 @@ ether_hdr_print(register const u_char *bp, u_int length)
120122 * frame's protocol, and an argument to pass to that function.
121123 */
122124void
123- ether_print (const u_char * p , u_int length , u_int caplen ,
124- void (* print_encap_header )(const u_char * ), const u_char * encap_header_arg )
125+ ether_print (netdissect_options * ndo ,
126+ const u_char * p , u_int length , u_int caplen ,
127+ void (* print_encap_header )(netdissect_options * ndo , const u_char * ), const u_char * encap_header_arg )
125128{
126129 struct ether_header * ep ;
127130 u_int orig_length ;
@@ -133,10 +136,10 @@ ether_print(const u_char *p, u_int length, u_int caplen,
133136 return ;
134137 }
135138
136- if (eflag ) {
139+ if (ndo -> ndo_eflag ) {
137140 if (print_encap_header != NULL )
138- (* print_encap_header )(encap_header_arg );
139- ether_hdr_print (p , length );
141+ (* print_encap_header )(ndo , encap_header_arg );
142+ ether_hdr_print (ndo , p , length );
140143 }
141144 orig_length = length ;
142145
@@ -156,14 +159,14 @@ ether_print(const u_char *p, u_int length, u_int caplen,
156159 if (llc_print (p , length , caplen , ESRC (ep ), EDST (ep ),
157160 & extracted_ether_type ) == 0 ) {
158161 /* ether_type not known, print raw packet */
159- if (!eflag ) {
162+ if (!ndo -> ndo_eflag ) {
160163 if (print_encap_header != NULL )
161- (* print_encap_header )(encap_header_arg );
162- ether_hdr_print ((u_char * )ep , orig_length );
164+ (* print_encap_header )(ndo , encap_header_arg );
165+ ether_hdr_print (ndo , (u_char * )ep , orig_length );
163166 }
164167
165- if (!suppress_default_print )
166- default_print ( p , caplen );
168+ if (!ndo -> ndo_suppress_default_print )
169+ ndo -> ndo_default_print ( ndo , p , caplen );
167170 }
168171 } else if (ether_type == ETHERTYPE_8021Q ) {
169172 /*
@@ -174,7 +177,7 @@ ether_print(const u_char *p, u_int length, u_int caplen,
174177 printf ("[|vlan]" );
175178 return ;
176179 }
177- if (eflag ) {
180+ if (ndo -> ndo_eflag ) {
178181 u_int16_t tag = EXTRACT_16BITS (p );
179182
180183 printf ("vlan %u, p %u%s, " ,
@@ -184,7 +187,7 @@ ether_print(const u_char *p, u_int length, u_int caplen,
184187 }
185188
186189 ether_type = EXTRACT_16BITS (p + 2 );
187- if (eflag && ether_type > ETHERMTU )
190+ if (ndo -> ndo_eflag && ether_type > ETHERMTU )
188191 printf ("ethertype %s, " , tok2str (ethertype_values ,"0x%04x" , ether_type ));
189192 p += 4 ;
190193 length -= 4 ;
@@ -204,26 +207,26 @@ ether_print(const u_char *p, u_int length, u_int caplen,
204207 if (llc_print (p , length , caplen , ESRC (ep ), EDST (ep ),
205208 & extracted_ether_type ) == 0 ) {
206209 /* ether_type not known, print raw packet */
207- if (!eflag ) {
210+ if (!ndo -> ndo_eflag ) {
208211 if (print_encap_header != NULL )
209- (* print_encap_header )(encap_header_arg );
210- ether_hdr_print ((u_char * )ep , orig_length );
212+ (* print_encap_header )(ndo , encap_header_arg );
213+ ether_hdr_print (ndo , (u_char * )ep , orig_length );
211214 }
212215
213- if (!suppress_default_print )
214- default_print ( p , caplen );
216+ if (!ndo -> ndo_suppress_default_print )
217+ ndo -> ndo_default_print ( ndo , p , caplen );
215218 }
216219 } else {
217- if (ethertype_print (ether_type , p , length , caplen ) == 0 ) {
220+ if (ethertype_print (ndo , ether_type , p , length , caplen ) == 0 ) {
218221 /* ether_type not known, print raw packet */
219- if (!eflag ) {
222+ if (!ndo -> ndo_eflag ) {
220223 if (print_encap_header != NULL )
221- (* print_encap_header )(encap_header_arg );
222- ether_hdr_print ((u_char * )ep , orig_length );
224+ (* print_encap_header )(ndo , encap_header_arg );
225+ ether_hdr_print (ndo , (u_char * )ep , orig_length );
223226 }
224227
225- if (!suppress_default_print )
226- default_print ( p , caplen );
228+ if (!ndo -> ndo_suppress_default_print )
229+ ndo -> ndo_default_print ( ndo , p , caplen );
227230 }
228231 }
229232}
@@ -235,9 +238,10 @@ ether_print(const u_char *p, u_int length, u_int caplen,
235238 * is the number of bytes actually captured.
236239 */
237240u_int
238- ether_if_print (const struct pcap_pkthdr * h , const u_char * p )
241+ ether_if_print (netdissect_options * ndo , const struct pcap_pkthdr * h ,
242+ const u_char * p )
239243{
240- ether_print (p , h -> len , h -> caplen , NULL , NULL );
244+ ether_print (ndo , p , h -> len , h -> caplen , NULL , NULL );
241245
242246 return (ETHER_HDRLEN );
243247}
@@ -250,93 +254,95 @@ ether_if_print(const struct pcap_pkthdr *h, const u_char *p)
250254 */
251255
252256int
253- ethertype_print (u_short ether_type , const u_char * p , u_int length , u_int caplen )
257+ ethertype_print (netdissect_options * ndo ,
258+ u_short ether_type , const u_char * p ,
259+ u_int length , u_int caplen )
254260{
255261 switch (ether_type ) {
256262
257263 case ETHERTYPE_IP :
258- ip_print (gndo , p , length );
264+ ip_print (ndo , p , length );
259265 return (1 );
260266
261267#ifdef INET6
262268 case ETHERTYPE_IPV6 :
263- ip6_print (p , length );
269+ ip6_print (/*ndo,*/ p , length );
264270 return (1 );
265271#endif /*INET6*/
266272
267273 case ETHERTYPE_ARP :
268274 case ETHERTYPE_REVARP :
269- arp_print (gndo , p , length , caplen );
275+ arp_print (ndo , p , length , caplen );
270276 return (1 );
271277
272278 case ETHERTYPE_DN :
273- decnet_print (p , length , caplen );
279+ decnet_print (/*ndo,*/ p , length , caplen );
274280 return (1 );
275281
276282 case ETHERTYPE_ATALK :
277- if (vflag )
283+ if (ndo -> ndo_vflag )
278284 fputs ("et1 " , stdout );
279- atalk_print (p , length );
285+ atalk_print (/*ndo,*/ p , length );
280286 return (1 );
281287
282288 case ETHERTYPE_AARP :
283- aarp_print (p , length );
289+ aarp_print (/*ndo,*/ p , length );
284290 return (1 );
285291
286292 case ETHERTYPE_IPX :
287293 printf ("(NOV-ETHII) " );
288- ipx_print (p , length );
294+ ipx_print (/*ndo,*/ p , length );
289295 return (1 );
290296
291297 case ETHERTYPE_ISO :
292- isoclns_print (p + 1 , length - 1 , length - 1 );
298+ isoclns_print (/*ndo,*/ p + 1 , length - 1 , length - 1 );
293299 return (1 );
294300
295301 case ETHERTYPE_PPPOED :
296302 case ETHERTYPE_PPPOES :
297303 case ETHERTYPE_PPPOED2 :
298304 case ETHERTYPE_PPPOES2 :
299- pppoe_print (p , length );
305+ pppoe_print (/*ndo,*/ p , length );
300306 return (1 );
301307
302308 case ETHERTYPE_EAPOL :
303- eap_print (gndo , p , length );
309+ eap_print (ndo , p , length );
304310 return (1 );
305311
306312 case ETHERTYPE_RRCP :
307- rrcp_print (gndo , p - 14 , length + 14 );
313+ rrcp_print (ndo , p - 14 , length + 14 );
308314 return (1 );
309315
310316 case ETHERTYPE_PPP :
311317 if (length ) {
312318 printf (": " );
313- ppp_print (p , length );
319+ ppp_print (/*ndo,*/ p , length );
314320 }
315321 return (1 );
316322
317323 case ETHERTYPE_MPCP :
318- mpcp_print (p , length );
324+ mpcp_print (/*ndo,*/ p , length );
319325 return (1 );
320326
321327 case ETHERTYPE_SLOW :
322- slow_print (p , length );
328+ slow_print (/*ndo,*/ p , length );
323329 return (1 );
324330
325331 case ETHERTYPE_CFM :
326332 case ETHERTYPE_CFM_OLD :
327- cfm_print (p , length );
333+ cfm_print (/*ndo,*/ p , length );
328334 return (1 );
329335
330336 case ETHERTYPE_LLDP :
331- lldp_print (p , length );
337+ lldp_print (/*ndo,*/ p , length );
332338 return (1 );
333339
334340 case ETHERTYPE_LOOPBACK :
335341 return (1 );
336342
337343 case ETHERTYPE_MPLS :
338344 case ETHERTYPE_MPLS_MULTI :
339- mpls_print (p , length );
345+ mpls_print (/*ndo,*/ p , length );
340346 return (1 );
341347
342348 case ETHERTYPE_LAT :
0 commit comments