Date: Mon, 05 Aug 2002 22:50:47 +0430 From: "soheil h" <soheil_h_y@hotmail.com> To: freebsd-questions@FreeBSD.ORG Cc: hassas@ce.sharif.ac.ir Subject: accessing tcp header in the ip_input.c::ip_forward() !!!!! Message-ID: <F170mpN7JvVAabAQJ6j0000c5ab@hotmail.com>
next in thread | raw e-mail | index | archive | help
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 <netinet/tcpS.h>
...
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?F170mpN7JvVAabAQJ6j0000c5ab>
