rip_input
Julian Elischer
julian at elischer.org
Thu Oct 22 18:03:51 UTC 2009
Arun Anirudhan wrote:
> 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.
what IS 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);
>
>
More information about the freebsd-net
mailing list