Re: Port number problem

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pham Viet Ha wrote:

> Hello there,
>  
> I am just a newbie. I got a bug when modifying CBQ scheduler in Linux 
> Kernel 2.4. I just want to get the soure and destination port number 
> of the packet (TCP/UDP). I used ntohs(skb->h.th->dest) for the 
> destination port number of a TCP packet. It doesn't work. The printed 
> value is not correct (we used FTP, port 21 to test).
>  
> Did anyone meet the same issue? Please give me a hand.
>  
> Thanks so much in advance.
>  
> VietHa

hi,
should try something like this :

struct iphdr *iph = skb->nh.iph;
struct tcphdr *th;
if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
(iph->protocol == IPPROTO_TCP))
{
       th = (struct tcphdr*)(((u32*)iph) + iph->ihl);         
                    if (ntohs(th->dest) == ....
}


-- 
Vincent EGAL
Email : egal@ipanematech.com



_______________________________________________
LARTC mailing list / LARTC@mailman.ds9a.nl
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux