|
|
| version 1.3, 2003/11/03 19:31:44 | version 1.4, 2004/03/21 22:41:24 |
|---|---|
| Line 95 void tcp_trace(short, short, struct tcpc | Line 95 void tcp_trace(short, short, struct tcpc |
| static void usage(void); | static void usage(void); |
| int | int |
| main(argc, argv) | main(int argc, char **argv) |
| int argc; | |
| char **argv; | |
| { | { |
| int ch, i, jflag, npcbs; | int ch, i, jflag, npcbs; |
| char *system, *core; | char *system, *core; |
| Line 118 main(argc, argv) | Line 116 main(argc, argv) |
| case 'p': | case 'p': |
| if (npcbs >= TCP_NDEBUG) | if (npcbs >= TCP_NDEBUG) |
| errx(1, "too many pcb's specified"); | errx(1, "too many pcb's specified"); |
| (void)sscanf(optarg, "%x", (int *)&tcp_pcbs[npcbs++]); | sscanf(optarg, "%x", (int *)&tcp_pcbs[npcbs++]); |
| break; | break; |
| case 's': | case 's': |
| ++sflag; | ++sflag; |
| Line 157 main(argc, argv) | Line 155 main(argc, argv) |
| err(2, "%s", core); | err(2, "%s", core); |
| if (kflag) | if (kflag) |
| errx(1, "can't do core files yet"); | errx(1, "can't do core files yet"); |
| (void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET); | klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET); |
| if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) != | if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) != |
| sizeof(tcp_debx)) | sizeof(tcp_debx)) |
| err(3, "tcp_debx"); | err(3, "tcp_debx"); |
| (void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET); | klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET); |
| if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) != | if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) != |
| sizeof(tcp_debug)) | sizeof(tcp_debug)) |
| err(3, "tcp_debug"); | err(3, "tcp_debug"); |
| Line 173 main(argc, argv) | Line 171 main(argc, argv) |
| */ | */ |
| if (!npcbs) { | if (!npcbs) { |
| for (i = 0; i < TCP_NDEBUG; i++) { | for (i = 0; i < TCP_NDEBUG; i++) { |
| register struct tcp_debug *td = &tcp_debug[i]; | struct tcp_debug *td = &tcp_debug[i]; |
| register int j; | int j; |
| if (td->td_tcb == 0) | if (td->td_tcb == 0) |
| continue; | continue; |
| Line 205 main(argc, argv) | Line 203 main(argc, argv) |
| } | } |
| static void | static void |
| usage() | usage(void) |
| { | { |
| (void)fprintf(stderr, | fprintf(stderr, |
| "usage: trpt [-afjst] [-p hex-address] [system [core]]\n"); | "usage: trpt [-afjst] [-p hex-address] [system [core]]\n"); |
| exit(1); | exit(1); |
| } | } |
| void | void |
| dotrace(tcpcb) | dotrace(caddr_t tcpcb) |
| register caddr_t tcpcb; | |
| { | { |
| register struct tcp_debug *td; | struct tcp_debug *td; |
| register int i; | int i; |
| int prev_debx = tcp_debx, family; | int prev_debx, family; |
| prev_debx = tcp_debx; | |
| again: if (--tcp_debx < 0) | again: if (--tcp_debx < 0) |
| tcp_debx = TCP_NDEBUG - 1; | tcp_debx = TCP_NDEBUG - 1; |
| for (i = prev_debx % TCP_NDEBUG; i < TCP_NDEBUG; i++) { | for (i = prev_debx % TCP_NDEBUG; i < TCP_NDEBUG; i++) { |
| Line 284 done: if (follow) { | Line 282 done: if (follow) { |
| prev_debx = 0; | prev_debx = 0; |
| do { | do { |
| sleep(1); | sleep(1); |
| (void)klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET); | klseek(memf, (off_t)nl[N_TCP_DEBX].n_value, L_SET); |
| if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) != | if (read(memf, (char *)&tcp_debx, sizeof(tcp_debx)) != |
| sizeof(tcp_debx)) | sizeof(tcp_debx)) |
| err(3, "tcp_debx"); | err(3, "tcp_debx"); |
| } while (tcp_debx == prev_debx); | } while (tcp_debx == prev_debx); |
| (void)klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET); | klseek(memf, (off_t)nl[N_TCP_DEBUG].n_value, L_SET); |
| if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) != | if (read(memf, (char *)tcp_debug, sizeof(tcp_debug)) != |
| sizeof(tcp_debug)) | sizeof(tcp_debug)) |
| err(3, "tcp_debug"); | err(3, "tcp_debug"); |
| Line 302 done: if (follow) { | Line 300 done: if (follow) { |
| */ | */ |
| /*ARGSUSED*/ | /*ARGSUSED*/ |
| void | void |
| tcp_trace(act, ostate, atp, tp, family, ip, th, req) | tcp_trace(short act, short ostate, struct tcpcb *atp, struct tcpcb *tp, |
| short act, ostate; | int family, void *ip, struct tcphdr *th, int req) |
| struct tcpcb *atp, *tp; | |
| int family; | |
| void *ip; | |
| struct tcphdr *th; | |
| int req; | |
| { | { |
| tcp_seq seq, ack; | tcp_seq seq, ack; |
| int flags, len, win, timer; | int flags, len, win, timer; |
| Line 392 tcp_trace(act, ostate, atp, tp, family, | Line 385 tcp_trace(act, ostate, atp, tp, family, |
| printf("(win=%x)", win); | printf("(win=%x)", win); |
| flags = th->th_flags; | flags = th->th_flags; |
| if (flags) { | if (flags) { |
| register char *cp = "<"; | char *cp = "<"; |
| #define pf(flag, string) { \ | |
| if (th->th_flags&flag) { \ | #define pf(flag, string) { \ |
| (void)printf("%s%s", cp, string); \ | if (th->th_flags & flag) { \ |
| cp = ","; \ | printf("%s%s", cp, string); \ |
| } \ | cp = ","; \ |
| } \ | |
| } | } |
| pf(TH_SYN, "SYN"); | pf(TH_SYN, "SYN"); |
| pf(TH_ACK, "ACK"); | pf(TH_ACK, "ACK"); |
| Line 433 tcp_trace(act, ostate, atp, tp, family, | Line 427 tcp_trace(act, ostate, atp, tp, family, |
| * kernel now uses callouts, not integer time values. | * kernel now uses callouts, not integer time values. |
| */ | */ |
| if (tflag) { | if (tflag) { |
| register char *cp = "\t"; | char *cp = "\t"; |
| register int i; | int i; |
| for (i = 0; i < TCPT_NTIMERS; i++) { | for (i = 0; i < TCPT_NTIMERS; i++) { |
| if (tp->t_timer[i] == 0) | if (tp->t_timer[i] == 0) |
| Line 451 tcp_trace(act, ostate, atp, tp, family, | Line 445 tcp_trace(act, ostate, atp, tp, family, |
| } | } |
| int | int |
| numeric(c1, c2) | numeric(caddr_t *c1, caddr_t *c2) |
| caddr_t *c1, *c2; | |
| { | { |
| return(*c1 - *c2); | return(*c1 - *c2); |
| } | } |
| void | void |
| klseek(fd, base, off) | klseek(int fd, off_t base, int off) |
| int fd, off; | |
| off_t base; | |
| { | { |
| (void)lseek(fd, base, off); | lseek(fd, base, off); |
| } | } |