From owner-freebsd-questions Mon Aug 5 11:20:51 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8F0CB37B400 for ; Mon, 5 Aug 2002 11:20:48 -0700 (PDT) Received: from hotmail.com (f170.law9.hotmail.com [64.4.9.170]) by mx1.FreeBSD.org (Postfix) with ESMTP id 49F8A43E81 for ; Mon, 5 Aug 2002 11:20:48 -0700 (PDT) (envelope-from soheil_h_y@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Mon, 5 Aug 2002 11:20:48 -0700 Received: from 80.75.14.195 by lw9fd.law9.hotmail.msn.com with HTTP; Mon, 05 Aug 2002 18:20:47 GMT X-Originating-IP: [80.75.14.195] From: "soheil h" To: freebsd-questions@FreeBSD.ORG Cc: hassas@ce.sharif.ac.ir Subject: accessing tcp header in the ip_input.c::ip_forward() !!!!! Date: Mon, 05 Aug 2002 22:50:47 +0430 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 05 Aug 2002 18:20:48.0267 (UTC) FILETIME=[D2743DB0:01C23CAC] Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG hi list i made a change in ip_forward() in ip_input.c to print the window sizes passes through my gateway. but it doesn't work properly and doesn't show the true th_win (window size) and the th_dport they doesn't mach the tcpdump output but shows the true ip->ip_p for TCP it means that i make a wrong cast in ip packet means not at the place of the tcphdr some byte more or less i don't know please verify me if my code is true and if not please help me !!!!! i make a struct named tcpShdr in tcpS.h file(my file ;) ): (the tcphdr with a litte change on field definition) struct tcpShdr { u_short th_sport; /* source port */ u_short th_dport; /* destination port */ tcpS_seq th_seq; /* sequence number */ tcpS_seq th_ack; /* acknowledgement number */ u_short th_soheil;/* the flags and ... fields that i don't care */ u_short th_win; /* window */ u_short th_sum; /* checksum */ u_short th_urp; /* urgent pointer */ }; in ip_input.c ... #include ... static void ip_forward(m, srcrt) struct mbuf *m; int srcrt; { register struct ip *ip = mtod(m, struct ip *); register struct sockaddr_in *sin; register struct rtentry *rt; int error, type = 0, code = 0; struct mbuf *mcopy; n_long dest; /*caddr_t s_c;/* pointer to tcp first bye */ */ int s_len;/*the ip length*/ struct tcpShdr * s_hdr; /* the header of my tcp/ip packet*/ struct ifnet *destifp; #ifdef IPSEC struct ifnet dummyifp; #endif dest = 0; #ifdef DIAGNOSTIC if (ipprintfs) printf("forward: src %lx dst %lx ttl %x\n", (u_long)ip->ip_src.s_addr, (u_long)ip->ip_dst.s_addr, ip->ip_ttl); #endif s_len = IP_VHL_HL(ip->ip_vhl) << 2; if(ip->ip_p == IPPROTO_TCP) { s_hdr = (struct tcpShdr *)( (caddr_t) ip + s_len); if( (s_hdr->th_win) >= 4096 && (s_hdr->th_win) <= 16000 ){ printf("win %d prot %d port %d" , s_hdr->th_win, ip->ip_p, s_hdr->th_dport); } } .../* it continues on noramlly */ } _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message