#include static unsigned int
aaa_account_infos_intercept(unsigned int hooknum,
struct sk_buff ** pskb,
const struct net_device *in,
const struct net_device *out,
int
(*okfn) (struct sk_buff *))
{
struct in6_addr *srcaddr, *dstaddr;
struct sk_buff *skb = *pskb;
if(skb){
struct ipv6hdr *hdr =
skb->nh.ipv6h;
srcaddr = &hdr->saddr;
dstaddr =
&hdr->daddr;
printk("Packet for source address:
%x:%x:%x:%x:%x:%x:%x:%x\n
destination address: %x:%x:%x:%x:%x:%x:%x:%x ",
NIPV6ADDR(srcaddr), NIPV6ADDR(dstaddr)) ;
return NF_ACCEPT;
}
struct nf_hook_ops aaa_account_infos_ops = {
{NULL,NULL},
aaa_account_infos_intercept,
PF_INET6,
NF_IP6_FORWARD,
NF_IP6_PRI_FILTER+2
};
int __init mipv6_aaa_init(void) {
nf_register_hook(&aaa_account_infos_ops);
return 0;
}
module_init(mipv6_aaa_init);
void __init mipv6_aaa_exit(void) {
nf_unregister_hook(&aaa_account_infos_ops);
}
module_exit(mipv6_aaa_exit);
这是我这几个月来做项目的初步总结,许多地方的认识还比较肤浅。希望大家提出批评和改进,谢谢!
主要参考文献:
1. Linux内核源代码;
2.
http://www.netfilter.org/documentation/HOWTO//netfilter-hacking-HOWTO.html;
3.
IPv6 Packet Handling in Linux 2.4;