#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.59 1999-11-21 09:37:02 fenner Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-tcp.c,v 1.63 1999-12-22 15:44:10 itojun Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
static struct tcp_seq_hash tcp_seq_hash[TSEQ_HASHSIZE];
+#ifndef TELNET_PORT
+#define TELNET_PORT 23
+#endif
+#ifndef BGP_PORT
+#define BGP_PORT 179
+#endif
+#define NETBIOS_SSN_PORT 139
+
void
tcp_print(register const u_char *bp, register u_int length,
register const u_char *bp2)
ip6 = NULL;
#endif /*INET6*/
ch = '\0';
- TCHECK(*tp);
- if (length < sizeof(*tp)) {
- (void)printf("truncated-tcp %d", length);
+ if (!TTEST(tp->th_dport)) {
+ (void)printf("%s > %s: [|tcp]",
+ ipaddr_string(&ip->ip_src),
+ ipaddr_string(&ip->ip_dst));
return;
}
sport = ntohs(tp->th_sport);
dport = ntohs(tp->th_dport);
- seq = ntohl(tp->th_seq);
- ack = ntohl(tp->th_ack);
- win = ntohs(tp->th_win);
- urp = ntohs(tp->th_urp);
#ifdef INET6
if (ip6) {
}
}
+ TCHECK(*tp);
+
+ seq = ntohl(tp->th_seq);
+ ack = ntohl(tp->th_ack);
+ win = ntohs(tp->th_win);
+ urp = ntohs(tp->th_urp);
+
if (qflag) {
(void)printf("tcp %d", length - tp->th_off * 4);
return;
}
#ifdef TH_ECN
- if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH|TH_ECN)) {
+ if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH|TH_ECN))
#else
- if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH)) {
+ if ((flags = tp->th_flags) & (TH_SYN|TH_FIN|TH_RST|TH_PUSH))
#endif
+ {
if (flags & TH_SYN)
putchar('S');
if (flags & TH_FIN)
return;
}
length -= hlen;
- if (length > 0 || flags & (TH_SYN | TH_FIN | TH_RST))
+ if (vflag > 1 || length > 0 || flags & (TH_SYN | TH_FIN | TH_RST))
(void)printf(" %u:%u(%d)", seq, seq + length, length);
if (flags & TH_ACK)
(void)printf(" ack %u", ack);
* Decode payload if necessary.
*/
bp += (tp->th_off * 4);
- if (sport == 179 || dport == 179)
+ if (!qflag && vflag && length > 0
+ && (sport == TELNET_PORT || dport == TELNET_PORT))
+ telnet_print(bp, length);
+ else if (sport == BGP_PORT || dport == BGP_PORT)
bgp_print(bp, length);
+ else if (sport == NETBIOS_SSN_PORT || dport == NETBIOS_SSN_PORT)
+ nbt_tcp_print(bp, length);
return;
bad:
fputs("[bad opt]", stdout);