rip_input

Arun Anirudhan arun.anirudhan at gmail.com
Thu Oct 22 18:01:56 UTC 2009


When I make
void rip_input_hook(struct mbuf *m, int off)
to
void rip_input_hook(struct mbuf *m) its showing error!!
---------------
rip_input_hook.c:20: error: conflicting types for 'rip_input_hook'
rip_input_hook.c:17: error: previous declaration of 'rip_input_hook' was
here
rip_input_hook.c: In function 'rip_input_hook':
rip_input_hook.c:31: error: too few arguments to function 'rip_input'
rip_input_hook.c: In function 'load':
rip_input_hook.c:40: warning: assignment from incompatible pointer type
*** Error code 1
-------------------
Its given in a book that rip_input(m) only...

On Thu, Oct 22, 2009 at 11:23 PM, Julian Elischer <julian at elischer.org>wrote:

> 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);
>>
>>
>>
>


-- 
With regards
Arun Anirudhan
MTech Student, NIT Calicut
9495983679


More information about the freebsd-net mailing list