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

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



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