Re: netfilter hooks: How to compare sk_buff->nh.iph->saddr with a predefined IP

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

 



hi,

> I want to compare the source address of an incoming packet with a list
> of IPs such as:
> 
> char *deny[2]={"/x7f/x00/x00/x01", NULL } // 127.0.0.1
> 
> i've tried comparing the 2 addresses with this:
> 
> 	[...]
> 	if(sb->nh.iph->saddr == *(unsigned int *)deny[0]) {
> 		printk("ignoring packet\n");
> 		return NF_DROP;
> 	}
> 	[...]
> 
> but it doesn't work... where i'm mistaking?

i can't understand completely your code, but i think this option will
work as you expect:

	__u32 deny = in_aton("127.0.0.1");

	[...]
	if(sb->nh.iph->saddr == deny) {
		printk("ignoring packet\n");
		return NF_DROP;
	}
	[...]

> 
> Really thanks

regards,

topi

> Marco..
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux