An error occurred while compiling the firewall on books.
Source: Internet
Author: User
An error occurred while compiling the firewall in the book-Linux general technology-Linux programming and kernel information. The following is a detailed description. // User_firewall.c
# Ifndef _ KERNEL __
# Define _ KERNEL __
# Endif
# Ifndef MODULE
# Define MODULE
# Endif
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
Static unsigned int user_firewall (unsigned int hooknum, struct sk_buff ** skb, const struct net_device * in,
Const struct net_device * out, int (* okfn) (struct sk_buff *))
{
Struct iphdr * iph;
Struct tcphdr * tcph;
Struct udphdr * udph;
If (iph-> ihl! = 5)
{// Check the checksum
Printk ("IP packet with packet from % d. % d. % d. % d to % d. % d. % d. % d \ n ", NIPQUAD (sip), NIPQUAD (dip ));
}
If (iph-> protocol = 6)
{Tcp protocol
Tcph = (struct tcphdr *) (_ u32 *) iph + iph-> ihl );
Sport = tcph-> source;
Dport = tcph-> dest;
Printk ("Source port: % d \ n", ntohs (tcph-> source ));
Printk ("Dest port: % d \ n", ntohs (tcph-> dest ));
If (tcph-> syn) & (sport = dport) & (sip = dip ))
{
Printk ("maybe land attack \ n ");
}
If (ntohs (tcph-> dest) = 139 & tcph-> urg)
{
Printk ("maybe winnuke a from % d. % d. % d. % d to % d. % d. % d. % d \ n ", NIPQUAD (sip), NIPQUAD (dip ));
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.