Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Oct 2009 10:53:07 -0700
From:      Julian Elischer <julian@elischer.org>
To:        Arun Anirudhan <arun.anirudhan@gmail.com>
Cc:        freebsd-net@freebsd.org
Subject:   Re: rip_input
Message-ID:  <4AE09C03.6050201@elischer.org>
In-Reply-To: <c668d9dd0910221019n3156db19j8b597d2d4ae728ec@mail.gmail.com>
References:  <c668d9dd0910221019n3156db19j8b597d2d4ae728ec@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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);
> 
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4AE09C03.6050201>