minor: tcpdump: fixed source code layout

This commit is contained in:
Simon Goldschmidt 2014-09-17 22:14:08 +02:00
parent 2386284b04
commit c6c94d27fc
1 changed files with 34 additions and 39 deletions

View File

@ -85,11 +85,11 @@ tcpdump(struct pbuf *p)
(ip_addr_t *)&(iphdr->src), (ip_addr_t *)&(iphdr->src),
(ip_addr_t *)&(iphdr->dest)) != 0) { (ip_addr_t *)&(iphdr->dest)) != 0) {
LWIP_DEBUGF(TCPDUMP_DEBUG, ("tcpdump: IP checksum failed!\n")); LWIP_DEBUGF(TCPDUMP_DEBUG, ("tcpdump: IP checksum failed!\n"));
/* fprintf(file, "chksum 0x%lx ", tcphdr->chksum); /*
tcphdr->chksum = 0; fprintf(file, "chksum 0x%lx ", tcphdr->chksum);
fprintf(file, "should be 0x%lx ", inet_chksum_pseudo(p, (ip_addr_t *)&(iphdr->src), tcphdr->chksum = 0;
(ip_addr_t *)&(iphdr->dest), fprintf(file, "should be 0x%lx ", inet_chksum_pseudo(p, (ip_addr_t *)&(iphdr->src),
IP_PROTO_TCP, p->tot_len));*/ (ip_addr_t *)&(iphdr->dest), IP_PROTO_TCP, p->tot_len));*/
fprintf(file, "!chksum "); fprintf(file, "!chksum ");
} }
@ -114,32 +114,27 @@ tcpdump(struct pbuf *p)
fprintf(file, "%d.%d.%d.%d.%u > %d.%d.%d.%d.%u: ", fprintf(file, "%d.%d.%d.%d.%u > %d.%d.%d.%d.%u: ",
(int)(ntohl(iphdr->src.addr) >> 24) & 0xff, (int)(ntohl(iphdr->src.addr) >> 24) & 0xff,
(int)(ntohl(iphdr->src.addr) >> 16) & 0xff, (int)(ntohl(iphdr->src.addr) >> 16) & 0xff,
(int)(ntohl(iphdr->src.addr) >> 8) & 0xff, (int)(ntohl(iphdr->src.addr) >> 8) & 0xff,
(int)(ntohl(iphdr->src.addr) >> 0) & 0xff, (int)(ntohl(iphdr->src.addr) >> 0) & 0xff,
ntohs(tcphdr->src), ntohs(tcphdr->src),
(int)(ntohl(iphdr->dest.addr) >> 24) & 0xff, (int)(ntohl(iphdr->dest.addr) >> 24) & 0xff,
(int)(ntohl(iphdr->dest.addr) >> 16) & 0xff, (int)(ntohl(iphdr->dest.addr) >> 16) & 0xff,
(int)(ntohl(iphdr->dest.addr) >> 8) & 0xff, (int)(ntohl(iphdr->dest.addr) >> 8) & 0xff,
(int)(ntohl(iphdr->dest.addr) >> 0) & 0xff, (int)(ntohl(iphdr->dest.addr) >> 0) & 0xff,
ntohs(tcphdr->dest)); ntohs(tcphdr->dest));
offset = TCPH_HDRLEN(tcphdr); offset = TCPH_HDRLEN(tcphdr);
len = ntohs(IPH_LEN(iphdr)) - offset * 4 - IP_HLEN; len = ntohs(IPH_LEN(iphdr)) - offset * 4 - IP_HLEN;
if (len != 0 || flags[0] != '.') { if (len != 0 || flags[0] != '.') {
fprintf(file, "%s %u:%u(%u) ", fprintf(file, "%s %u:%u(%u) ", flags, ntohl(tcphdr->seqno),
flags, ntohl(tcphdr->seqno) + len, len);
ntohl(tcphdr->seqno),
ntohl(tcphdr->seqno) + len,
len);
} }
if (TCPH_FLAGS(tcphdr) & TCP_ACK) { if (TCPH_FLAGS(tcphdr) & TCP_ACK) {
fprintf(file, "ack %u ", fprintf(file, "ack %u ", ntohl(tcphdr->ackno));
ntohl(tcphdr->ackno));
} }
fprintf(file, "wnd %u\n", fprintf(file, "wnd %u\n", ntohs(tcphdr->wnd));
ntohs(tcphdr->wnd));
fflush(file); fflush(file);
@ -156,25 +151,25 @@ tcpdump(struct pbuf *p)
(ip_addr_t *)&(iphdr->src), (ip_addr_t *)&(iphdr->src),
(ip_addr_t *)&(iphdr->dest)) != 0) { (ip_addr_t *)&(iphdr->dest)) != 0) {
LWIP_DEBUGF(TCPDUMP_DEBUG, ("tcpdump: IP checksum failed!\n")); LWIP_DEBUGF(TCPDUMP_DEBUG, ("tcpdump: IP checksum failed!\n"));
/* fprintf(file, "chksum 0x%lx ", tcphdr->chksum); /*
tcphdr->chksum = 0; fprintf(file, "chksum 0x%lx ", tcphdr->chksum);
fprintf(file, "should be 0x%lx ", inet_chksum_pseudo(p, (ip_addr_t *)&(iphdr->src), tcphdr->chksum = 0;
(ip_addr_t *)&(iphdr->dest), fprintf(file, "should be 0x%lx ", inet_chksum_pseudo(p, (ip_addr_t *)&(iphdr->src),
IP_PROTO_TCP, p->tot_len));*/ (ip_addr_t *)&(iphdr->dest), IP_PROTO_TCP, p->tot_len));*/
fprintf(file, "!chksum "); fprintf(file, "!chksum ");
} }
fprintf(file, "%d.%d.%d.%d.%u > %d.%d.%d.%d.%u: ", fprintf(file, "%d.%d.%d.%d.%u > %d.%d.%d.%d.%u: ",
(int)(ntohl(iphdr->src.addr) >> 24) & 0xff, (int)(ntohl(iphdr->src.addr) >> 24) & 0xff,
(int)(ntohl(iphdr->src.addr) >> 16) & 0xff, (int)(ntohl(iphdr->src.addr) >> 16) & 0xff,
(int)(ntohl(iphdr->src.addr) >> 8) & 0xff, (int)(ntohl(iphdr->src.addr) >> 8) & 0xff,
(int)(ntohl(iphdr->src.addr) >> 0) & 0xff, (int)(ntohl(iphdr->src.addr) >> 0) & 0xff,
ntohs(udphdr->src), ntohs(udphdr->src),
(int)(ntohl(iphdr->dest.addr) >> 24) & 0xff, (int)(ntohl(iphdr->dest.addr) >> 24) & 0xff,
(int)(ntohl(iphdr->dest.addr) >> 16) & 0xff, (int)(ntohl(iphdr->dest.addr) >> 16) & 0xff,
(int)(ntohl(iphdr->dest.addr) >> 8) & 0xff, (int)(ntohl(iphdr->dest.addr) >> 8) & 0xff,
(int)(ntohl(iphdr->dest.addr) >> 0) & 0xff, (int)(ntohl(iphdr->dest.addr) >> 0) & 0xff,
ntohs(udphdr->dest)); ntohs(udphdr->dest));
fprintf(file, "U "); fprintf(file, "U ");
len = ntohs(IPH_LEN(iphdr)) - sizeof(struct udp_hdr) - IP_HLEN; len = ntohs(IPH_LEN(iphdr)) - sizeof(struct udp_hdr) - IP_HLEN;
fprintf(file, " %d\n", len); fprintf(file, " %d\n", len);