Date: Thu, 22 Oct 2009 22:49:39 +0530 From: Arun Anirudhan <arun.anirudhan@gmail.com> To: freebsd-net@freebsd.org Subject: rip_input Message-ID: <c668d9dd0910221019n3156db19j8b597d2d4ae728ec@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hello I have just started programming in Kernel Level in FreeBSD. I'm trying to hook rip_input and extract the fields in IP header. I just tried to print the ip_len. This is the code, but its not getting printed. Please help me... --------------------------------- #include <sys/param.h> #include <sys/proc.h> #include <sys/module.h> #include <sys/kernel.h> #include <sys/systm.h> #include <sys/mbuf.h> #include <sys/protosw.h> #include <netinet/in.h> #include <netinet/in_systm.h> #include <netinet/ip.h> #include <netinet/ip_icmp.h> #include <netinet/ip_var.h> extern struct protosw inetsw[]; pr_input_t rip_input_hook; void rip_input_hook(struct mbuf *m, int off) { struct ip *icp; int hlen=off; int l; //m->m_len-=hlen; //m->m_data+=hlen; icp=mtod(m, struct ip *); l=icp->ip_len; //m->m_len+=hlen; //m->m_data-=hlen; uprintf("%d.\n",l); } static int load(struct module *module, int cmd, void *arg) { int error = 0; switch (cmd) { case MOD_LOAD: inetsw[ip_protox[IPPROTO_RAW]].pr_input = rip_input_hook; break; case MOD_UNLOAD: inetsw[ip_protox[IPPROTO_RAW]].pr_input = rip_input; break; default: error = EOPNOTSUPP; break; } return (error); } static moduledata_t rip_input_hook_mod = { "rip_input_hook", load, NULL}; DECLARE_MODULE(rip_input_hook,rip_input_hook_mod,SI_SUB_DRIVERS,SI_ORDER_MIDDLE); -- With regards Arun Anirudhan MTech Student, NIT Calicut 9495983679
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?c668d9dd0910221019n3156db19j8b597d2d4ae728ec>