Porting the RTSP module to 2.6.22
Hello,
I am trying to forward port the RTSP module from 2.6.21 to 2.6.22 and I am nearly done. All there is missing is a helper function. I had a look at the skbuff struct but I could not find out what needed to be changed.
Here is the short original helper function.
static voidget_skb_tcpdata(struct sk_buff* skb, char** pptcpdata, uint* ptcpdatalen)
{
struct iphdr* iph = (struct iphdr*)skb->nh.iph;
struct tcphdr* tcph = (struct tcphdr*)((char*)iph + iph->ihl*4);
*pptcpdata = (char*)tcph + tcph->doff*4;
*ptcpdatalen = ((char*)skb->h.raw + skb->len) - *pptcpdata;
}I changed this to
static voidget_skb_tcpdata(struct sk_buff** skb, char** pptcpdata, uint* ptcpdatalen)
{
struct iphdr* iph = ip_hdr(*skb);
struct tcphdr* tcph = (void *)iph + iph->ihl*4;
*pptcpdata = (char*)tcph + tcph->doff*4;
*ptcpdatalen = ((char*)skb->h.raw + skb->len) - *pptcpdata;
}I am pretty sure, that the first three lines are ok. But the last one is giving me some problems, since "h" is no longer in the skb struct. Maybe someone with a little bit more knowledge about the changes can help me here.
Kind regards,
Michael
Quoted 8 lines · Michael Guntsche
I changed this to
static void
get_skb_tcpdata(struct sk_buff** skb, char** pptcpdata, uint* ptcpdatalen){
struct iphdr* iph =ip_hdr(*skb);
struct tcphdr* tcph = (void *)iph + iph->ihl*4;
Use (void *)iph + ip_hdrlen(*skb)
Quoted 3 lines
*pptcpdata = (char*)tcph + tcph->doff*4; *ptcpdatalen = ((char*)skb->h.raw +
skb->len) - *pptcpdata;
}
h.raw is now skb_transport_header(skb);
Also, skb-> should be (*skb)->, since it is a double pointer (which you can also get rid of)
Quoted 4 lines
I am pretty sure, that the first three lines are ok. But the last one is giving me some problems, since "h" is no longer in the skb struct.
Maybe someone with a little bit more knowledge about the changes can help me here.
Jan
Quoted 4 lines · Jan Engelhardt
Use (void *)iph +
ip_hdrlen(*skb)
Quoted 8 lines
Quoted 3 lines
*pptcpdata = (char*)tcph + tcph->doff*4; *ptcpdatalen = ((char*)skb->h.raw +
skb->len) - *pptcpdata;
}h.raw is now
skb_transport_header(skb);
Also, skb-> should be (*skb)->, since it is a double pointer (which you can also get rid of)
Thank you very very much Jan. With your tips and some poking in the other modules I was able to get a compiling and more suprisingly running version of the RTSP module.
The new and working function looks like this.
static voidget_skb_tcpdata(struct sk_buff* skb, char** pptcpdata, uint* ptcpdatalen)
{
struct iphdr* iph = ip_hdr(skb);
struct tcphdr* tcph = (void *)iph + ip_hdrlen(skb);
*pptcpdata = (char*)tcph + tcph->doff*4;
*ptcpdatalen = ((char*)skb_transport_header(skb) + skb->len) - *pptcpdata;
}
I am in the process of creating and updated patch against 2.6.22.1 and will put it up on my site this evening.
http://mike.it-loops.com/rtsp/
It is working for me right now, but maybe someone can give it a quick check and tell me if there are any problems or bugs.
Kind regards,
Michael
Answering my own post.
I already fixed the obvious mistake I made. On Jul 29, 2007, at 22:12, Michael Guntsche wrote:
<snip>
Quoted 4 lines
I changed this to
static void
get_skb_tcpdata(struct sk_buff** skb, char** pptcpdata, uint* ptcpdatalen)
Quoted 8 lines
{
struct iphdr* iph = ip_hdr(*skb);
struct tcphdr* tcph = (void *)iph + iph->ihl*4;
*pptcpdata = (char*)tcph + tcph->doff*4;
*ptcpdatalen = ((char*)skb->h.raw + skb->len) - *pptcpdata;
}Of course there is no need to change skb.
Sorry for not checking this before sending the first E-Mail.
static voidget_skb_tcpdata(struct sk_buff* skb, char** pptcpdata, uint* ptcpdatalen)
{
struct iphdr* iph = ip_hdr(skb);
struct tcphdr* tcph = (void *)iph + iph->ihl*4;
*pptcpdata = (char*)tcph + tcph->doff*4;
*ptcpdatalen = ((char*)skb->h.raw + skb->len) - *pptcpdata;
}The problem remains though that the "h" member is no longer existing.
Kind regards,
Michael
Quoted 32 lines · Michael Guntsche
Answering my own post.
I already fixed the obvious mistake I made. On Jul 29, 2007, at 22:12, Michael Guntsche wrote:
<snip>Quoted 5 lines
I changed this to
static void
get_skb_tcpdata(struct sk_buff** skb, char** pptcpdata, uint* ptcpdatalen)Quoted 8 lines
{ struct iphdr* iph = ip_hdr(*skb); struct tcphdr* tcph = (void *)iph + iph->ihl*4; *pptcpdata = (char*)tcph + tcph->doff*4; *ptcpdatalen = ((char*)skb->h.raw + skb->len) - *pptcpdata; }Of course there is no need to change skb.
Sorry for not checking this before sending the first E-Mail.static void
get_skb_tcpdata(struct sk_buff* skb, char** pptcpdata, uint* ptcpdatalen){ struct iphdr* iph = ip_hdr(skb); struct tcphdr* tcph = (void *)iph + iph->ihl*4; *pptcpdata = (char*)tcph + tcph->doff*4; *ptcpdatalen = ((char*)skb->h.raw + skb->len) - *pptcpdata; }
Quoted 1 line
The problem remains though that the "h" member is no longer existing.
That shouldn't be a problem since netfilter modules should basically never use it anyway since its only valid for locally generated packets. Use Jan's suggestion (or look at other modules) and skb_header_pointer.