trpt.c revision 1.8 1 1.8 mrg /* $NetBSD: trpt.c,v 1.8 1998/07/06 07:50:20 mrg Exp $ */
2 1.5 thorpej
3 1.5 thorpej /*-
4 1.5 thorpej * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 1.5 thorpej * All rights reserved.
6 1.5 thorpej *
7 1.5 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.5 thorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.5 thorpej * NASA Ames Research Center.
10 1.5 thorpej *
11 1.5 thorpej * Redistribution and use in source and binary forms, with or without
12 1.5 thorpej * modification, are permitted provided that the following conditions
13 1.5 thorpej * are met:
14 1.5 thorpej * 1. Redistributions of source code must retain the above copyright
15 1.5 thorpej * notice, this list of conditions and the following disclaimer.
16 1.5 thorpej * 2. Redistributions in binary form must reproduce the above copyright
17 1.5 thorpej * notice, this list of conditions and the following disclaimer in the
18 1.5 thorpej * documentation and/or other materials provided with the distribution.
19 1.5 thorpej * 3. All advertising materials mentioning features or use of this software
20 1.5 thorpej * must display the following acknowledgement:
21 1.5 thorpej * This product includes software developed by the NetBSD
22 1.5 thorpej * Foundation, Inc. and its contributors.
23 1.5 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.5 thorpej * contributors may be used to endorse or promote products derived
25 1.5 thorpej * from this software without specific prior written permission.
26 1.5 thorpej *
27 1.5 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.5 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.5 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.5 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.5 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.5 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.5 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.5 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.5 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.5 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.5 thorpej * POSSIBILITY OF SUCH DAMAGE.
38 1.5 thorpej */
39 1.4 mikel
40 1.1 cgd /*
41 1.4 mikel * Copyright (c) 1983, 1988, 1993
42 1.4 mikel * The Regents of the University of California. All rights reserved.
43 1.1 cgd *
44 1.1 cgd * Redistribution and use in source and binary forms, with or without
45 1.1 cgd * modification, are permitted provided that the following conditions
46 1.1 cgd * are met:
47 1.1 cgd * 1. Redistributions of source code must retain the above copyright
48 1.1 cgd * notice, this list of conditions and the following disclaimer.
49 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
50 1.1 cgd * notice, this list of conditions and the following disclaimer in the
51 1.1 cgd * documentation and/or other materials provided with the distribution.
52 1.1 cgd * 3. All advertising materials mentioning features or use of this software
53 1.1 cgd * must display the following acknowledgement:
54 1.1 cgd * This product includes software developed by the University of
55 1.1 cgd * California, Berkeley and its contributors.
56 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
57 1.1 cgd * may be used to endorse or promote products derived from this software
58 1.1 cgd * without specific prior written permission.
59 1.1 cgd *
60 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70 1.1 cgd * SUCH DAMAGE.
71 1.1 cgd */
72 1.1 cgd
73 1.5 thorpej #include <sys/cdefs.h>
74 1.1 cgd #ifndef lint
75 1.5 thorpej __COPYRIGHT(
76 1.4 mikel "@(#) Copyright (c) 1983, 1988, 1993\n\
77 1.5 thorpej The Regents of the University of California. All rights reserved.\n");
78 1.1 cgd #endif /* not lint */
79 1.1 cgd
80 1.1 cgd #ifndef lint
81 1.4 mikel #if 0
82 1.4 mikel static char sccsid[] = "@(#)trpt.c 8.1 (Berkeley) 6/6/93";
83 1.4 mikel #else
84 1.8 mrg __RCSID("$NetBSD: trpt.c,v 1.8 1998/07/06 07:50:20 mrg Exp $");
85 1.4 mikel #endif
86 1.1 cgd #endif /* not lint */
87 1.1 cgd
88 1.1 cgd #include <sys/param.h>
89 1.3 cgd #include <sys/queue.h>
90 1.1 cgd #include <sys/socket.h>
91 1.1 cgd #include <sys/socketvar.h>
92 1.1 cgd #define PRUREQUESTS
93 1.1 cgd #include <sys/protosw.h>
94 1.1 cgd #include <sys/file.h>
95 1.1 cgd
96 1.1 cgd #include <net/route.h>
97 1.1 cgd #include <net/if.h>
98 1.1 cgd
99 1.1 cgd #include <netinet/in.h>
100 1.1 cgd #include <netinet/in_systm.h>
101 1.1 cgd #include <netinet/ip.h>
102 1.1 cgd #include <netinet/in_pcb.h>
103 1.1 cgd #include <netinet/ip_var.h>
104 1.1 cgd #include <netinet/tcp.h>
105 1.1 cgd #define TCPSTATES
106 1.1 cgd #include <netinet/tcp_fsm.h>
107 1.1 cgd #include <netinet/tcp_seq.h>
108 1.1 cgd #define TCPTIMERS
109 1.1 cgd #include <netinet/tcp_timer.h>
110 1.1 cgd #include <netinet/tcp_var.h>
111 1.1 cgd #include <netinet/tcpip.h>
112 1.1 cgd #define TANAMES
113 1.1 cgd #include <netinet/tcp_debug.h>
114 1.1 cgd
115 1.1 cgd #include <arpa/inet.h>
116 1.1 cgd
117 1.5 thorpej #include <err.h>
118 1.1 cgd #include <stdio.h>
119 1.1 cgd #include <errno.h>
120 1.5 thorpej #include <kvm.h>
121 1.1 cgd #include <nlist.h>
122 1.1 cgd #include <paths.h>
123 1.5 thorpej #include <limits.h>
124 1.5 thorpej #include <stdlib.h>
125 1.5 thorpej #include <unistd.h>
126 1.1 cgd
127 1.1 cgd struct nlist nl[] = {
128 1.1 cgd #define N_TCP_DEBUG 0
129 1.1 cgd { "_tcp_debug" },
130 1.1 cgd #define N_TCP_DEBX 1
131 1.1 cgd { "_tcp_debx" },
132 1.5 thorpej { NULL },
133 1.1 cgd };
134 1.1 cgd
135 1.1 cgd static caddr_t tcp_pcbs[TCP_NDEBUG];
136 1.1 cgd static n_time ntime;
137 1.5 thorpej static int aflag, follow, sflag, tflag;
138 1.5 thorpej
139 1.5 thorpej extern char *__progname;
140 1.5 thorpej
141 1.5 thorpej int main __P((int, char *[]));
142 1.5 thorpej void dotrace __P((caddr_t));
143 1.5 thorpej void tcp_trace __P((short, short, struct tcpcb *, struct tcpcb *,
144 1.5 thorpej struct tcpiphdr *, int));
145 1.5 thorpej int numeric __P((const void *, const void *));
146 1.5 thorpej void usage __P((void));
147 1.1 cgd
148 1.5 thorpej kvm_t *kd;
149 1.5 thorpej
150 1.5 thorpej int
151 1.1 cgd main(argc, argv)
152 1.1 cgd int argc;
153 1.5 thorpej char *argv[];
154 1.1 cgd {
155 1.5 thorpej int ch, i, jflag, npcbs;
156 1.5 thorpej char *system, *core, *cp, errbuf[_POSIX2_LINE_MAX];
157 1.8 mrg gid_t egid = getegid();
158 1.5 thorpej
159 1.8 mrg (void)setegid(getgid());
160 1.5 thorpej system = core = NULL;
161 1.1 cgd
162 1.1 cgd jflag = npcbs = 0;
163 1.5 thorpej while ((ch = getopt(argc, argv, "afjp:st")) != -1) {
164 1.1 cgd switch (ch) {
165 1.1 cgd case 'a':
166 1.1 cgd ++aflag;
167 1.1 cgd break;
168 1.1 cgd case 'f':
169 1.1 cgd ++follow;
170 1.1 cgd setlinebuf(stdout);
171 1.1 cgd break;
172 1.1 cgd case 'j':
173 1.1 cgd ++jflag;
174 1.1 cgd break;
175 1.1 cgd case 'p':
176 1.5 thorpej if (npcbs >= TCP_NDEBUG)
177 1.5 thorpej errx(1, "too many pcbs specified");
178 1.5 thorpej errno = 0;
179 1.5 thorpej tcp_pcbs[npcbs++] = (caddr_t)strtoul(optarg, &cp, 16);
180 1.5 thorpej if (*cp != '\0' || errno == ERANGE)
181 1.5 thorpej errx(1, "invalid address: %s", optarg);
182 1.1 cgd break;
183 1.1 cgd case 's':
184 1.1 cgd ++sflag;
185 1.1 cgd break;
186 1.1 cgd case 't':
187 1.1 cgd ++tflag;
188 1.1 cgd break;
189 1.5 thorpej case 'N':
190 1.5 thorpej system = optarg;
191 1.5 thorpej break;
192 1.5 thorpej case 'M':
193 1.5 thorpej core = optarg;
194 1.5 thorpej break;
195 1.1 cgd case '?':
196 1.1 cgd default:
197 1.5 thorpej usage();
198 1.5 thorpej /* NOTREACHED */
199 1.1 cgd }
200 1.5 thorpej }
201 1.1 cgd argc -= optind;
202 1.1 cgd argv += optind;
203 1.1 cgd
204 1.5 thorpej if (argc)
205 1.5 thorpej usage();
206 1.5 thorpej
207 1.5 thorpej /*
208 1.8 mrg * Discard setgid privileges. If not the running kernel, we toss
209 1.8 mrg * them away totally so that bad guys can't print interesting stuff
210 1.8 mrg * from kernel memory, otherwise switch back to kmem for the
211 1.8 mrg * duration of the kvm_openfiles() call.
212 1.5 thorpej */
213 1.5 thorpej if (core != NULL || system != NULL)
214 1.4 mikel setgid(getgid());
215 1.8 mrg else
216 1.8 mrg setegid(egid);
217 1.1 cgd
218 1.5 thorpej kd = kvm_openfiles(system, core, NULL, O_RDONLY, errbuf);
219 1.5 thorpej if (kd == NULL)
220 1.5 thorpej errx(1, "can't open kmem: %s", errbuf);
221 1.8 mrg
222 1.8 mrg /* get rid of it now anyway */
223 1.8 mrg if (core == NULL && system == NULL)
224 1.8 mrg setgid(getgid());
225 1.5 thorpej
226 1.5 thorpej if (kvm_nlist(kd, nl))
227 1.5 thorpej errx(2, "%s: no namelist", system ? system : _PATH_UNIX);
228 1.5 thorpej
229 1.5 thorpej if (kvm_read(kd, nl[N_TCP_DEBX].n_value, (char *)&tcp_debx,
230 1.5 thorpej sizeof(tcp_debx)) != sizeof(tcp_debx))
231 1.5 thorpej errx(3, "tcp_debx: %s", kvm_geterr(kd));
232 1.5 thorpej
233 1.5 thorpej if (kvm_read(kd, nl[N_TCP_DEBUG].n_value, (char *)tcp_debug,
234 1.5 thorpej sizeof(tcp_debug)) != sizeof(tcp_debug))
235 1.5 thorpej errx(3, "tcp_debug: %s", kvm_geterr(kd));
236 1.1 cgd
237 1.1 cgd /*
238 1.1 cgd * If no control blocks have been specified, figure
239 1.1 cgd * out how many distinct one we have and summarize
240 1.1 cgd * them in tcp_pcbs for sorting the trace records
241 1.1 cgd * below.
242 1.1 cgd */
243 1.5 thorpej if (npcbs == 0) {
244 1.1 cgd for (i = 0; i < TCP_NDEBUG; i++) {
245 1.5 thorpej struct tcp_debug *td = &tcp_debug[i];
246 1.5 thorpej int j;
247 1.1 cgd
248 1.1 cgd if (td->td_tcb == 0)
249 1.1 cgd continue;
250 1.1 cgd for (j = 0; j < npcbs; j++)
251 1.1 cgd if (tcp_pcbs[j] == td->td_tcb)
252 1.1 cgd break;
253 1.1 cgd if (j >= npcbs)
254 1.1 cgd tcp_pcbs[npcbs++] = td->td_tcb;
255 1.1 cgd }
256 1.5 thorpej if (npcbs == 0)
257 1.1 cgd exit(0);
258 1.1 cgd }
259 1.1 cgd qsort(tcp_pcbs, npcbs, sizeof(caddr_t), numeric);
260 1.1 cgd if (jflag) {
261 1.1 cgd for (i = 0;;) {
262 1.3 cgd printf("%lx", (long)tcp_pcbs[i]);
263 1.1 cgd if (++i == npcbs)
264 1.1 cgd break;
265 1.1 cgd fputs(", ", stdout);
266 1.1 cgd }
267 1.1 cgd putchar('\n');
268 1.5 thorpej } else {
269 1.5 thorpej for (i = 0; i < npcbs; i++) {
270 1.5 thorpej printf("\n%lx:\n", (long)tcp_pcbs[i]);
271 1.5 thorpej dotrace(tcp_pcbs[i]);
272 1.5 thorpej }
273 1.1 cgd }
274 1.1 cgd exit(0);
275 1.1 cgd }
276 1.1 cgd
277 1.5 thorpej void
278 1.1 cgd dotrace(tcpcb)
279 1.5 thorpej caddr_t tcpcb;
280 1.1 cgd {
281 1.5 thorpej struct tcp_debug *td;
282 1.1 cgd int prev_debx = tcp_debx;
283 1.5 thorpej int i;
284 1.1 cgd
285 1.5 thorpej again:
286 1.5 thorpej if (--tcp_debx < 0)
287 1.1 cgd tcp_debx = TCP_NDEBUG - 1;
288 1.1 cgd for (i = prev_debx % TCP_NDEBUG; i < TCP_NDEBUG; i++) {
289 1.1 cgd td = &tcp_debug[i];
290 1.1 cgd if (tcpcb && td->td_tcb != tcpcb)
291 1.1 cgd continue;
292 1.1 cgd ntime = ntohl(td->td_time);
293 1.5 thorpej tcp_trace(td->td_act, td->td_ostate,
294 1.5 thorpej (struct tcpcb *)td->td_tcb, &td->td_cb, &td->td_ti,
295 1.5 thorpej td->td_req);
296 1.1 cgd if (i == tcp_debx)
297 1.1 cgd goto done;
298 1.1 cgd }
299 1.1 cgd for (i = 0; i <= tcp_debx % TCP_NDEBUG; i++) {
300 1.1 cgd td = &tcp_debug[i];
301 1.1 cgd if (tcpcb && td->td_tcb != tcpcb)
302 1.1 cgd continue;
303 1.1 cgd ntime = ntohl(td->td_time);
304 1.5 thorpej tcp_trace(td->td_act, td->td_ostate,
305 1.5 thorpej (struct tcpcb *)td->td_tcb, &td->td_cb, &td->td_ti,
306 1.5 thorpej td->td_req);
307 1.1 cgd }
308 1.5 thorpej done:
309 1.5 thorpej if (follow) {
310 1.1 cgd prev_debx = tcp_debx + 1;
311 1.1 cgd if (prev_debx >= TCP_NDEBUG)
312 1.1 cgd prev_debx = 0;
313 1.1 cgd do {
314 1.1 cgd sleep(1);
315 1.5 thorpej if (kvm_read(kd, nl[N_TCP_DEBX].n_value,
316 1.5 thorpej (char *)&tcp_debx, sizeof(tcp_debx)) !=
317 1.5 thorpej sizeof(tcp_debx))
318 1.5 thorpej errx(3, "tcp_debx: %s", kvm_geterr(kd));
319 1.1 cgd } while (tcp_debx == prev_debx);
320 1.5 thorpej
321 1.5 thorpej if (kvm_read(kd, nl[N_TCP_DEBUG].n_value, (char *)tcp_debug,
322 1.5 thorpej sizeof(tcp_debug)) != sizeof(tcp_debug))
323 1.5 thorpej errx(3, "tcp_debug: %s", kvm_geterr(kd));
324 1.5 thorpej
325 1.1 cgd goto again;
326 1.1 cgd }
327 1.1 cgd }
328 1.1 cgd
329 1.1 cgd /*
330 1.1 cgd * Tcp debug routines
331 1.1 cgd */
332 1.1 cgd /*ARGSUSED*/
333 1.5 thorpej void
334 1.1 cgd tcp_trace(act, ostate, atp, tp, ti, req)
335 1.1 cgd short act, ostate;
336 1.1 cgd struct tcpcb *atp, *tp;
337 1.1 cgd struct tcpiphdr *ti;
338 1.1 cgd int req;
339 1.1 cgd {
340 1.1 cgd tcp_seq seq, ack;
341 1.1 cgd int flags, len, win, timer;
342 1.1 cgd
343 1.5 thorpej printf("%03d %s:%s ", (ntime/10) % 1000, tcpstates[ostate],
344 1.1 cgd tanames[act]);
345 1.1 cgd switch (act) {
346 1.1 cgd case TA_INPUT:
347 1.1 cgd case TA_OUTPUT:
348 1.1 cgd case TA_DROP:
349 1.1 cgd if (aflag) {
350 1.1 cgd printf("(src=%s,%u, ",
351 1.1 cgd inet_ntoa(ti->ti_src), ntohs(ti->ti_sport));
352 1.1 cgd printf("dst=%s,%u)",
353 1.1 cgd inet_ntoa(ti->ti_dst), ntohs(ti->ti_dport));
354 1.1 cgd }
355 1.1 cgd seq = ti->ti_seq;
356 1.1 cgd ack = ti->ti_ack;
357 1.1 cgd len = ti->ti_len;
358 1.1 cgd win = ti->ti_win;
359 1.1 cgd if (act == TA_OUTPUT) {
360 1.5 thorpej NTOHL(seq);
361 1.5 thorpej NTOHL(ack);
362 1.5 thorpej NTOHS(len);
363 1.5 thorpej NTOHS(win);
364 1.1 cgd }
365 1.1 cgd if (act == TA_OUTPUT)
366 1.1 cgd len -= sizeof(struct tcphdr);
367 1.1 cgd if (len)
368 1.5 thorpej printf("[%x..%x)", seq, seq + len);
369 1.1 cgd else
370 1.5 thorpej printf("%x", seq);
371 1.5 thorpej printf("@%x", ack);
372 1.1 cgd if (win)
373 1.1 cgd printf("(win=%x)", win);
374 1.1 cgd flags = ti->ti_flags;
375 1.1 cgd if (flags) {
376 1.1 cgd register char *cp = "<";
377 1.1 cgd #define pf(flag, string) { \
378 1.1 cgd if (ti->ti_flags&flag) { \
379 1.1 cgd (void)printf("%s%s", cp, string); \
380 1.1 cgd cp = ","; \
381 1.1 cgd } \
382 1.1 cgd }
383 1.1 cgd pf(TH_SYN, "SYN");
384 1.1 cgd pf(TH_ACK, "ACK");
385 1.1 cgd pf(TH_FIN, "FIN");
386 1.1 cgd pf(TH_RST, "RST");
387 1.1 cgd pf(TH_PUSH, "PUSH");
388 1.1 cgd pf(TH_URG, "URG");
389 1.1 cgd printf(">");
390 1.1 cgd }
391 1.1 cgd break;
392 1.1 cgd case TA_USER:
393 1.1 cgd timer = req >> 8;
394 1.1 cgd req &= 0xff;
395 1.1 cgd printf("%s", prurequests[req]);
396 1.1 cgd if (req == PRU_SLOWTIMO || req == PRU_FASTTIMO)
397 1.1 cgd printf("<%s>", tcptimers[timer]);
398 1.1 cgd break;
399 1.1 cgd }
400 1.1 cgd printf(" -> %s", tcpstates[tp->t_state]);
401 1.1 cgd /* print out internal state of tp !?! */
402 1.1 cgd printf("\n");
403 1.1 cgd if (sflag) {
404 1.5 thorpej printf("\trcv_nxt %x rcv_wnd %lx snd_una %x snd_nxt %x snd_max %x\n",
405 1.1 cgd tp->rcv_nxt, tp->rcv_wnd, tp->snd_una, tp->snd_nxt,
406 1.1 cgd tp->snd_max);
407 1.5 thorpej printf("\tsnd_wl1 %x snd_wl2 %x snd_wnd %lx\n", tp->snd_wl1,
408 1.1 cgd tp->snd_wl2, tp->snd_wnd);
409 1.1 cgd }
410 1.1 cgd /* print out timers? */
411 1.1 cgd if (tflag) {
412 1.1 cgd register char *cp = "\t";
413 1.1 cgd register int i;
414 1.1 cgd
415 1.1 cgd for (i = 0; i < TCPT_NTIMERS; i++) {
416 1.1 cgd if (tp->t_timer[i] == 0)
417 1.1 cgd continue;
418 1.1 cgd printf("%s%s=%d", cp, tcptimers[i], tp->t_timer[i]);
419 1.1 cgd if (i == TCPT_REXMT)
420 1.1 cgd printf(" (t_rxtshft=%d)", tp->t_rxtshift);
421 1.1 cgd cp = ", ";
422 1.1 cgd }
423 1.1 cgd if (*cp != '\t')
424 1.1 cgd putchar('\n');
425 1.1 cgd }
426 1.1 cgd }
427 1.1 cgd
428 1.5 thorpej int
429 1.5 thorpej numeric(v1, v2)
430 1.5 thorpej const void *v1, *v2;
431 1.1 cgd {
432 1.6 thorpej const caddr_t *c1 = v1;
433 1.6 thorpej const caddr_t *c2 = v2;
434 1.7 thorpej int rv;
435 1.5 thorpej
436 1.7 thorpej if (*c1 < *c2)
437 1.7 thorpej rv = -1;
438 1.7 thorpej else if (*c1 > *c2)
439 1.7 thorpej rv = 1;
440 1.7 thorpej else
441 1.7 thorpej rv = 0;
442 1.7 thorpej
443 1.7 thorpej return (rv);
444 1.1 cgd }
445 1.1 cgd
446 1.5 thorpej void
447 1.5 thorpej usage()
448 1.1 cgd {
449 1.1 cgd
450 1.5 thorpej (void) fprintf(stderr, "usage: %s [-afjst] [-p hex-address]"
451 1.5 thorpej " [-N system] [-M core]\n", __progname);
452 1.5 thorpej exit(1);
453 1.1 cgd }
454