X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/b751376719cfe1924aa07ab8fd364ec1a55c04b3..10ac80fdecfa9b9b7d259d8f50d0b72ef1b18f12:/print-tcp.c diff --git a/print-tcp.c b/print-tcp.c index d420382e..a1aae18a 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -184,12 +184,12 @@ tcp_print(netdissect_options *ndo, if (!ND_TTEST_2(tp->th_dport)) { if (ip6) { ND_PRINT("%s > %s:", - ip6addr_string(ndo, ip6->ip6_src), - ip6addr_string(ndo, ip6->ip6_dst)); + GET_IP6ADDR_STRING(ip6->ip6_src), + GET_IP6ADDR_STRING(ip6->ip6_dst)); } else { ND_PRINT("%s > %s:", - ipaddr_string(ndo, ip->ip_src), - ipaddr_string(ndo, ip->ip_dst)); + GET_IPADDR_STRING(ip->ip_src), + GET_IPADDR_STRING(ip->ip_dst)); } nd_print_trunc(ndo); return; @@ -201,9 +201,9 @@ tcp_print(netdissect_options *ndo, if (ip6) { if (GET_U_1(ip6->ip6_nxt) == IPPROTO_TCP) { ND_PRINT("%s.%s > %s.%s: ", - ip6addr_string(ndo, ip6->ip6_src), + GET_IP6ADDR_STRING(ip6->ip6_src), tcpport_string(ndo, sport), - ip6addr_string(ndo, ip6->ip6_dst), + GET_IP6ADDR_STRING(ip6->ip6_dst), tcpport_string(ndo, dport)); } else { ND_PRINT("%s > %s: ", @@ -212,9 +212,9 @@ tcp_print(netdissect_options *ndo, } else { if (GET_U_1(ip->ip_p) == IPPROTO_TCP) { ND_PRINT("%s.%s > %s.%s: ", - ipaddr_string(ndo, ip->ip_src), + GET_IPADDR_STRING(ip->ip_src), tcpport_string(ndo, sport), - ipaddr_string(ndo, ip->ip_dst), + GET_IPADDR_STRING(ip->ip_dst), tcpport_string(ndo, dport)); } else { ND_PRINT("%s > %s: ", @@ -298,7 +298,7 @@ tcp_print(netdissect_options *ndo, if (th->nxt == NULL) (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, - "tcp_print: calloc"); + "%s: calloc", __func__); } th->addr = tha; if (rev) @@ -356,7 +356,7 @@ tcp_print(netdissect_options *ndo, if (th->nxt == NULL) (*ndo->ndo_error)(ndo, S_ERR_ND_MEM_ALLOC, - "tcp_print: calloc"); + "%s: calloc", __func__); } th->addr = tha; if (rev) @@ -446,13 +446,11 @@ tcp_print(netdissect_options *ndo, while (hlen > 0) { if (ch != '\0') ND_PRINT("%c", ch); - ND_TCHECK_1(cp); opt = GET_U_1(cp); cp++; if (ZEROLENOPT(opt)) len = 1; else { - ND_TCHECK_1(cp); len = GET_U_1(cp); cp++; /* total including type, len */ if (len < 2 || len > hlen) @@ -703,8 +701,8 @@ tcp_print(netdissect_options *ndo, resp_print(ndo, bp, length); break; case PT_DOMAIN: - ND_PRINT(" "); - domain_print(ndo, bp + 2, length - 2, 0); + /* over_tcp: TRUE, is_mdns: FALSE */ + domain_print(ndo, bp, length, TRUE, FALSE); break; } return; @@ -746,28 +744,16 @@ tcp_print(netdissect_options *ndo, } else if (IS_SRC_OR_DST_PORT(RTSP_PORT) || IS_SRC_OR_DST_PORT(RTSP_PORT_ALT)) { ND_PRINT(": "); rtsp_print(ndo, bp, length); - } else if (length > 2 && - (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))) { - /* domain_print() assumes it does not have to prepend a space before its - * own output to separate it from the output of the calling function. This - * works well with udp_print(), but requires a small prop here. - */ - ND_PRINT(" "); - - /* - * TCP DNS query has 2byte length at the head. - * XXX packet could be unaligned, it can go strange - */ - domain_print(ndo, bp + 2, length - 2, 0); + } else if (IS_SRC_OR_DST_PORT(NAMESERVER_PORT)) { + /* over_tcp: TRUE, is_mdns: FALSE */ + domain_print(ndo, bp, length, TRUE, FALSE); } else if (IS_SRC_OR_DST_PORT(MSDP_PORT)) { msdp_print(ndo, bp, length); } else if (IS_SRC_OR_DST_PORT(RPKI_RTR_PORT)) { rpki_rtr_print(ndo, bp, length); - } - else if (length > 0 && (IS_SRC_OR_DST_PORT(LDP_PORT))) { + } else if (IS_SRC_OR_DST_PORT(LDP_PORT)) { ldp_print(ndo, bp, length); - } - else if ((IS_SRC_OR_DST_PORT(NFS_PORT)) && + } else if ((IS_SRC_OR_DST_PORT(NFS_PORT)) && length >= 4 && ND_TTEST_4(bp)) { /* * If data present, header length valid, and NFS port used, @@ -801,12 +787,12 @@ tcp_print(netdissect_options *ndo, } return; - bad: +bad: ND_PRINT("[bad opt]"); if (ch != '\0') ND_PRINT("]"); return; - trunc: +trunc: nd_print_trunc(ndo); if (ch != '\0') ND_PRINT(">");