LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-13-2008, 12:30 AM   #1
wangqi0021
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Rep: Reputation: 0
how to use the nfnetlink or ipq?


How can I transmit the packet into the userspace and verdict?


Quote:
unsigned int watch_out(unsigned int hooknum, struct sk_buff **skb, const struct net_device *in, const struct net_device *out, int (*okfn) (struct sk_buff *)){
struct sk_buff *sb;
struct tcphdr *tcph;

sb=*skb;


if(sb->nh.iph->protocol!=IPPROTO_TCP){
return NF_ACCEPT;
}


if(sb->nh.iph->saddr!=inet_addr(ker_conf.ip)&&sb->nh.iph->daddr!=inet_addr(ker_conf.ip)){
return NF_ACCEPT;
}


tcph=(struct tcphdr *)((sb->data)+(sb->nh.iph->ihl * 4));


if(tcph->source!=htons(ker_conf.port) && tcph->dest != htons(ker_conf.port)){
return NF_ACCEPT;
}

printk("enqueue the packet\n");
return NF_QUEUE;
}

int webwall_queue_fun(struct sk_buff *skb, struct nf_info *info,unsigned int queuenum, void *data){
printk(KERN_INFO "I`m webwall_queue_fun\n");

/********************************
TO DO!!!!!!!!!!!!!!!!!!
********************************/

return 1;
}

int register_webwall_ker_mod(void){
int ret=0;

DEBUG("Now registing the Webwall kernel mod.\n");


webwall_queue_handle.outfn=webwall_queue_fun;

webwall_queue_handle.data=NULL;

webwall_queue_handle.name="webwall_queue";


post_hook.hook = watch_out;
post_hook.pf = PF_INET;
post_hook.priority = NF_IP_PRI_FIRST;
post_hook.hooknum = NF_IP_POST_ROUTING;


ret=read_config(&ker_conf);
if(ret==ERR){
printk("webwall:Something are not ok in the function \"read_config\"\n\n");
return -1;
}
//register the hook function
nf_register_hook(&post_hook);
//register the webwall queue
nf_register_queue_handler(PF_INET, &webwall_queue_handle);

return 1;
}

void unregister_webwall_ker_mod(void){
DEBUG("Now unregisting the Webwall kernel mod.\n");

//unregister the hook function
nf_unregister_hook(&post_hook);
//unregister the webwall queue
nf_unregister_queue_handler(PF_INET);
}

module_init(register_webwall_ker_mod);
module_exit(unregister_webwall_ker_mod);

Last edited by wangqi0021; 11-13-2008 at 07:48 PM.
 
Old 11-13-2008, 03:10 AM   #2
wangqi0021
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Original Poster
Rep: Reputation: 0
anyone here?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ipq problems johnlee27 Programming 1 06-27-2005 08:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration