Skip to contentSkip to conversation

About the variable of "network_header" in the struct sk_buff

DISCUSSION supercodeing35271 supercodeing35271 2 participants 2 messages Feb 25, 2010 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,I really do not know that is it correctly of  asking such a foolish question in this high-level mailing list,but i could not find the answer by google it.
As a recruit,i'm now studying netfilter,i want to write a simply test kernel module by the function of dropping the packet which the protocol is TCP.For that i have read the "Using Netfilter hooks"(http://www.topsight.net/article.php/2003050621055083/print),in the page there is a piece of code below:

      static int check_tcp_packet(struct sk_buff *skb)
          {
              /*........................*/
              if (skb->nh.iph->protocol != IPPROTO_TCP) {
                  return NF_ACCEPT;
              }

              /*................*/
          }

But when i look up the source code of the kernel of 2.6.32,the sk_buff has changed.It is not a nh,the name is "network_header",as the others are "transport_header" and "mac_header".Then i found that the "network_header" is just a sk_buff_data_t(the true is a "unsigned int" or "unsigned char *") type variable.
So, my question is how to get a IP packet with it protocol or tcp flags or someother things by the "network_header" variable in the struct sk_buff.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw
Quoted 8 lines · On Thursday 2010-02-25 19:17, supercodeing35271 supercodeing35271 wrote:

Hi,I really do not know that is it correctly of  asking such a foolish question in this high-level mailing list,but i could not find the answer by google it.
As a recruit,i'm now studying netfilter,i want to write a simply test kernel module by the function of dropping the packet which the protocol is TCP.For that i have read the "Using Netfilter hooks"(http://www.topsight.net/article.php/2003050621055083/print),in the page there is a piece of code below:

You need to look at a recent documentation, such as "Writing Netfilter Modules" PDF/e-book.

Quoted 9 lines
     static int check_tcp_packet(struct sk_buff *skb)
         {
             /*........................*/
             if (skb->nh.iph->protocol != IPPROTO_TCP) {
                 return NF_ACCEPT;
             }

             /*................*/
         }

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html