From owner-freebsd-net@FreeBSD.ORG Thu Oct 22 18:03:51 2009 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ABD80106566B for ; Thu, 22 Oct 2009 18:03:51 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outS.internet-mail-service.net (rly2.mx.aerioconnect.net [216.240.35.226]) by mx1.freebsd.org (Postfix) with ESMTP id 954938FC08 for ; Thu, 22 Oct 2009 18:03:51 +0000 (UTC) Received: from idiom.com (mx0.idiom.com [216.240.32.160]) by out.internet-mail-service.net (Postfix) with ESMTP id 73D6EC9282; Thu, 22 Oct 2009 10:53:08 -0700 (PDT) X-Client-Authorized: MaGic Cook1e X-Client-Authorized: MaGic Cook1e Received: from julian-mac.elischer.org (h-67-100-89-137.snfccasy.static.covad.net [67.100.89.137]) by idiom.com (Postfix) with ESMTP id DEFFE2D6028; Thu, 22 Oct 2009 10:53:07 -0700 (PDT) Message-ID: <4AE09C03.6050201@elischer.org> Date: Thu, 22 Oct 2009 10:53:07 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Arun Anirudhan References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org Subject: Re: rip_input X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2009 18:03:51 -0000 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 > #include > #include > #include > #include > #include > #include > > #include > #include > #include > #include > #include > > > 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); > >