Remove function in favor of well-tested one

This commit is contained in:
dmiller 2026-08-18 16:06:50 +00:00
parent 5650f35c6d
commit 27b7951833
4 changed files with 4 additions and 92 deletions

View file

@ -278,7 +278,7 @@ static int ipid_proxy_probe(struct idle_proxy_info *proxy, int *probes_sent,
} else if (o.debugging > 1) {
error("Received unexpected response packet from %s during IP ID zombie probing:",
inet_socktop(&hdr.src));
readtcppacket(pkt, 0);
error("%s", ippackethdrinfo(pkt, bytes, HIGH_DETAIL));
}
continue;
}

View file

@ -2622,7 +2622,6 @@ bool HostOsScan::processTSeqResp(HostOsScanStats *hss, const struct ip *ip, cons
if ((tcp->th_flags & (TH_SYN|TH_ACK)) == (TH_SYN|TH_ACK)) {
/* error("DEBUG: response is SYN|ACK to port %hu\n", ntohs(tcp->th_dport)); */
/*readtcppacket((char *)ip, 0);*/
/* We use the ACK value to match up our sent with rcv'd packets */
seq_response_num = ntohl(tcp->th_ack) - tcpSeqBase - 1;
/* printf("seq_response_num = %d\treplyNo = %d\n", seq_response_num, replyNo); */
@ -2632,10 +2631,10 @@ bool HostOsScan::processTSeqResp(HostOsScanStats *hss, const struct ip *ip, cons
if (o.debugging) {
error("Unable to associate os scan response with sent packet for %s.",
hss->target->targetipstr());
error("Received ack: %lX; sequence sent: %lX. Packet:",
error("Received ack: %lX; sequence sent: %lX. Packet:\n%s",
(unsigned long) ntohl(tcp->th_ack),
(unsigned long) tcpSeqBase);
readtcppacket(pkt, 0);
(unsigned long) tcpSeqBase,
ippackethdrinfo(pkt, tcplen + sizeof(*ip), HIGH_DETAIL));
}
seq_response_num = replyNo;
}

View file

@ -1098,86 +1098,6 @@ u8 *build_igmp_raw(const struct in_addr *source,
ipopt, ipoptlen, pkt, igmplen, packetlen);
}
/* A simple function I wrote to help in debugging, shows the important fields
of a TCP packet*/
int readtcppacket(const u8 *packet, int readdata) {
const struct ip *ip = (struct ip *) packet;
const struct tcp_hdr *tcp = (struct tcp_hdr *) (packet + sizeof(struct ip));
const unsigned char *data = packet + sizeof(struct ip) + sizeof(struct tcp_hdr);
int tot_len;
struct in_addr bullshit, bullshit2;
char sourcehost[16];
int i = 0;
int realfrag = 0;
if (!packet) {
error("%s: packet is NULL!", __func__);
return -1;
}
bullshit.s_addr = ip->ip_src.s_addr;
bullshit2.s_addr = ip->ip_dst.s_addr;
realfrag = htons(ntohs(ip->ip_off) & IP_OFFMASK);
tot_len = htons(ip->ip_len);
Strncpy(sourcehost, inet_ntoa(bullshit), sizeof(sourcehost));
if (ip->ip_hl >= 5 && tcp->th_off >= 5) {
i = 4 * (ip->ip_hl + tcp->th_off);
}
if (ip->ip_p == IPPROTO_TCP) {
if (realfrag)
log_write(LOG_PLAIN, "Packet is fragmented, offset field: %u\n",
realfrag);
else {
log_write(LOG_PLAIN,
"TCP packet: %s:%d -> %s:%d (total: %d bytes)\n",
sourcehost, ntohs(tcp->th_sport), inet_ntoa(bullshit2),
ntohs(tcp->th_dport), tot_len);
log_write(LOG_PLAIN, "Flags: ");
if (!tcp->th_flags)
log_write(LOG_PLAIN, "(none)");
if (tcp->th_flags & TH_RST)
log_write(LOG_PLAIN, "RST ");
if (tcp->th_flags & TH_SYN)
log_write(LOG_PLAIN, "SYN ");
if (tcp->th_flags & TH_ACK)
log_write(LOG_PLAIN, "ACK ");
if (tcp->th_flags & TH_PUSH)
log_write(LOG_PLAIN, "PSH ");
if (tcp->th_flags & TH_FIN)
log_write(LOG_PLAIN, "FIN ");
if (tcp->th_flags & TH_URG)
log_write(LOG_PLAIN, "URG ");
log_write(LOG_PLAIN, "\n");
log_write(LOG_PLAIN, "ipid: %hu ttl: %hhu ", ntohs(ip->ip_id),
ip->ip_ttl);
if (tcp->th_flags & (TH_SYN | TH_ACK))
log_write(LOG_PLAIN, "Seq: %u\tAck: %u\n",
(unsigned int) ntohl(tcp->th_seq),
(unsigned int) ntohl(tcp->th_ack));
else if (tcp->th_flags & TH_SYN)
log_write(LOG_PLAIN, "Seq: %u\n",
(unsigned int) ntohl(tcp->th_seq));
else if (tcp->th_flags & TH_ACK)
log_write(LOG_PLAIN, "Ack: %u\n",
(unsigned int) ntohl(tcp->th_ack));
}
}
if (readdata && i > 0 && i < tot_len) {
log_write(LOG_PLAIN, "Data portion:\n");
while (i < tot_len) {
log_write(LOG_PLAIN, "%2X%c", data[i], ((i + 1) % 16) ? ' ' : '\n');
i++;
}
log_write(LOG_PLAIN, "\n");
}
return 0;
}
/* Used by validatepkt() to validate the TCP header (including option lengths).
The options checked are MSS, WScale, SackOK, Sack, and Timestamp. */
static bool validateTCPhdr(const u8 *tcpc, unsigned len) {

View file

@ -302,13 +302,6 @@ bool pcap_recv_timeval_valid();
packets). */
void pcap_print_stats(int logt, pcap_t *pd);
/* A simple function I wrote to help in debugging, shows the important fields
of a TCP packet*/
int readtcppacket(const u8 *packet, int readdata);
int readudppacket(const u8 *packet, int readdata);
/* Fill buf (up to buflen -- truncate if necessary but always
terminate) with a short representation of the packet stats.
Returns buf. Aborts if there is a problem. */