Skip to contentSkip to conversation

Port number problem

LARTC Pham Viet Ha 2 participants 2 messages Nov 6, 2002

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 8 lines · Pham Viet Ha

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).

Quoted 5 lines

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) = ....
}
Signature · 8 lines
Vincent EGAL
Email : [email protected]



_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/