From owner-freebsd-net@FreeBSD.ORG Thu Oct 22 17:42:49 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 2C71C106566B for ; Thu, 22 Oct 2009 17:42:49 +0000 (UTC) (envelope-from arun.anirudhan@gmail.com) Received: from mail-px0-f186.google.com (mail-px0-f186.google.com [209.85.216.186]) by mx1.freebsd.org (Postfix) with ESMTP id 065B08FC08 for ; Thu, 22 Oct 2009 17:42:48 +0000 (UTC) Received: by pxi16 with SMTP id 16so5451124pxi.3 for ; Thu, 22 Oct 2009 10:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=wDT+cmvtWKyi+58vdYyJ6A9MCtR/TB3m9B4e4luROTk=; b=HOSrBJfdDpc0VjQzwSrLqbnRHj0WRUM01FNlqEBIfuS8ay4w5jMhG3iGfFsP7NLgIT GFjx3LKvvR8w9ydBzljvTg8GKtNJwQstWh4yq0mQteRVbV/G/m39GJmkWmYVIAcZnzN0 M2pBniQJob6pucKK794Bv3IFhrMfHb4vs9PFs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Uk2Y+2Jgpz0D4LFtgmXYevUL6PQmvpgtia4mNvVqS+SdGQIHLT+ppAmQzwC7BCTGpo VZ00XcUUp6jLMK+/eAgKW2LhQ3aGbnmAzEV4kh1VjF+0djhtdvzPI23JBZdONhCZ8Qvl NoiNe2BmIfLbV0phdJCPhWzGv/Lqd0UqyzMk8= MIME-Version: 1.0 Received: by 10.115.67.10 with SMTP id u10mr14784968wak.203.1256231979677; Thu, 22 Oct 2009 10:19:39 -0700 (PDT) Date: Thu, 22 Oct 2009 22:49:39 +0530 Message-ID: From: Arun Anirudhan To: freebsd-net@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: 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 17:42:49 -0000 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. 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); -- With regards Arun Anirudhan MTech Student, NIT Calicut 9495983679