Deleted Added
full compact
print-token.c (44165) print-token.c (50514)
1/*
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 8 unchanged lines hidden (view full) ---

17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * Hacked version of print-ether.c Larry Lile <lile@stdio.com>
22 */
23#ifndef lint
24static const char rcsid[] =
1/*
2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 8 unchanged lines hidden (view full) ---

17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * Hacked version of print-ether.c Larry Lile <lile@stdio.com>
22 */
23#ifndef lint
24static const char rcsid[] =
25 "@(#) $Header$";
25 "@(#) $Header: /home/ncvs/src/contrib/tcpdump/print-token.c,v 1.1 1999/02/20 11:17:55 julian Exp $";
26#endif
27
28#include <sys/param.h>
29#include <sys/time.h>
30#include <sys/socket.h>
31
32#if __STDC__
33struct mbuf;

--- 28 unchanged lines hidden (view full) ---

62token_print(register const u_char *bp, u_int length)
63{
64 register const struct token_header *tp;
65 register const struct llc *lp;
66 u_short ether_type;
67
68 tp = (const struct token_header *)bp;
69 lp = (struct llc *)(bp + TOKEN_HDR_LEN);
26#endif
27
28#include <sys/param.h>
29#include <sys/time.h>
30#include <sys/socket.h>
31
32#if __STDC__
33struct mbuf;

--- 28 unchanged lines hidden (view full) ---

62token_print(register const u_char *bp, u_int length)
63{
64 register const struct token_header *tp;
65 register const struct llc *lp;
66 u_short ether_type;
67
68 tp = (const struct token_header *)bp;
69 lp = (struct llc *)(bp + TOKEN_HDR_LEN);
70 if (IS_SOURCE_ROUTED)
70
71 if (IS_SOURCE_ROUTED) {
72 tp->ether_shost[0] = tp->ether_shost[0] & 0x7f;
71 lp = (struct llc *)(bp + TOKEN_HDR_LEN + RIF_LENGTH);
73 lp = (struct llc *)(bp + TOKEN_HDR_LEN + RIF_LENGTH);
74 }
72
73 /*
74 * Ethertype on ethernet is a short, but ethertype in an llc-snap has
75 * been defined as 2 u_chars. This is a stupid little hack to fix
76 * this for now but something better should be done using ntohs()
77 * XXX
78 */
79 ether_type = ((u_short)lp->ethertype[1] << 16) | lp->ethertype[0];

--- 20 unchanged lines hidden (view full) ---

100void
101token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
102{
103 u_int caplen = h->caplen;
104 u_int length = h->len;
105 struct token_header *tp;
106 u_short ether_type;
107 extern u_short extracted_ethertype;
75
76 /*
77 * Ethertype on ethernet is a short, but ethertype in an llc-snap has
78 * been defined as 2 u_chars. This is a stupid little hack to fix
79 * this for now but something better should be done using ntohs()
80 * XXX
81 */
82 ether_type = ((u_short)lp->ethertype[1] << 16) | lp->ethertype[0];

--- 20 unchanged lines hidden (view full) ---

103void
104token_if_print(u_char *user, const struct pcap_pkthdr *h, const u_char *p)
105{
106 u_int caplen = h->caplen;
107 u_int length = h->len;
108 struct token_header *tp;
109 u_short ether_type;
110 extern u_short extracted_ethertype;
108 u_int route_len = 0;
111 u_int route_len = 0, seg;
109 struct llc *lp;
110
111 tp = (struct token_header *)p;
112
113 ts_print(&h->ts);
114
115 if (caplen < TOKEN_HDR_LEN) {
116 printf("[|token-ring]");
117 goto out;
118 }
119
112 struct llc *lp;
113
114 tp = (struct token_header *)p;
115
116 ts_print(&h->ts);
117
118 if (caplen < TOKEN_HDR_LEN) {
119 printf("[|token-ring]");
120 goto out;
121 }
122
120 if (eflag)
121 token_print(p, length);
122
123 /*
124 * Some printers want to get back at the ethernet addresses,
125 * and/or check that they're not walking off the end of the packet.
126 * Rather than pass them all the way down, we set these globals.
127 */
128 tp = (struct token_header *)p;
129
130 /* Adjust for source routing information in the MAC header */
131 if (IS_SOURCE_ROUTED) {
123 /*
124 * Some printers want to get back at the ethernet addresses,
125 * and/or check that they're not walking off the end of the packet.
126 * Rather than pass them all the way down, we set these globals.
127 */
128 tp = (struct token_header *)p;
129
130 /* Adjust for source routing information in the MAC header */
131 if (IS_SOURCE_ROUTED) {
132
133 if (eflag)
134 token_print(p, length);
135
132 route_len = RIF_LENGTH;
136 route_len = RIF_LENGTH;
137 if (vflag) {
138 if (vflag > 1)
139 printf("ac %x fc %x ", tp->ac, tp->fc);
140 ether_type = ntohs((int)lp->ethertype);
141
142 printf("%s ", broadcast_indicator[BROADCAST]);
143 printf("%s", direction[DIRECTION]);
144
145 for (seg = 0; seg < SEGMENT_COUNT; seg++)
146 printf(" [%d:%d]", RING_NUMBER(seg), BRIDGE_NUMBER(seg));
147 } else {
148 printf("rt = %x", ntohs(tp->rcf));
149
150 for (seg = 0; seg < SEGMENT_COUNT; seg++)
151 printf(":%x", ntohs(tp->rseg[seg]));
152 }
153 printf(" (%s) ", largest_frame[LARGEST_FRAME]);
154 } else {
155 if (eflag)
156 token_print(p, length);
133 }
134
135 /* Set pointer to llc header, adjusted for routing information */
136 lp = (struct llc *)(p + TOKEN_HDR_LEN + route_len);
137
138 packetp = p;
139 snapend = p + caplen;
140
141 /* Skip over token ring MAC header */
142 length -= TOKEN_HDR_LEN + route_len;
143 caplen -= TOKEN_HDR_LEN + route_len;
144 p += TOKEN_HDR_LEN + route_len;
145
157 }
158
159 /* Set pointer to llc header, adjusted for routing information */
160 lp = (struct llc *)(p + TOKEN_HDR_LEN + route_len);
161
162 packetp = p;
163 snapend = p + caplen;
164
165 /* Skip over token ring MAC header */
166 length -= TOKEN_HDR_LEN + route_len;
167 caplen -= TOKEN_HDR_LEN + route_len;
168 p += TOKEN_HDR_LEN + route_len;
169
146 ether_type = ntohs((int)lp->ethertype);
147
148 extracted_ethertype = 0;
149 /* Try to print the LLC-layer header & higher layers */
150 if (llc_print(p, length, caplen, ESRC(tp), EDST(tp)) == 0) {
151 /* ether_type not known, print raw packet */
152 if (!eflag)
153 token_print((u_char *)tp, length);
154 if (extracted_ethertype) {
155 printf("(LLC %s) ",
156 etherproto_string(htons(extracted_ethertype)));
157 }
158 if (!xflag && !qflag)
159 default_print(p, caplen);
160 }
161 if (xflag)
162 default_print(p, caplen);
163 out:
164 putchar('\n');
165}
170 extracted_ethertype = 0;
171 /* Try to print the LLC-layer header & higher layers */
172 if (llc_print(p, length, caplen, ESRC(tp), EDST(tp)) == 0) {
173 /* ether_type not known, print raw packet */
174 if (!eflag)
175 token_print((u_char *)tp, length);
176 if (extracted_ethertype) {
177 printf("(LLC %s) ",
178 etherproto_string(htons(extracted_ethertype)));
179 }
180 if (!xflag && !qflag)
181 default_print(p, caplen);
182 }
183 if (xflag)
184 default_print(p, caplen);
185 out:
186 putchar('\n');
187}