Insmod Problems << Unresolved symbol ntohl >>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello .
  I am trying to compile the below code to make a lkm. but when i do an insmod
i get a bunch of errors

appreciate all help.

truely
dheeraj
=====
/*
  $Id: hellomod.c,v 1.2 2002/11/18 18:41:46 dheeraj Exp dheeraj $
*/

#define __KERNEL__         /* We're part of the kernel */
#define MODULE             /* Not a permanent part, though. */
/* #define _LOOSE_KERNEL_NAMES */

/* Standard headers for LKMs */
#include <linux/modversions.h> 
#include <linux/module.h>
#include <linux/byteorder/generic.h>
#include <linux/ip.h>
#include <linux/udp.h>
#include <linux/tcp.h>
#include <linux/netfilter_ipv4.h>

#include <linux/tty.h>      /* console_print() interface */



enum {
  IPPROTO_IP = 0,
  IPPROTO_TCP = 6
};

/*
  NF_IP_PRI_FILTER specifies relative priority
  -1 is before netfiltering
  +1 is aimmediately after netfiltering
 */

static unsigned int dhee_hook (unsigned int hook,
			       struct sk_buff **skb,
			       const struct net_device *in,
			       const struct net_device *out,
			       int (*okfn)(struct sk_buff *)
			       )
{

  /*   unsigned char* ipv4_data = */
  /*     (void*) (*skb)->nh.iph + (*skb)->nh.iph->ihl*4; */

  const struct iphdr *ip = (*skb)->nh.iph;
  struct tcphdr *mytcphdr;
  /* if the protocol is tcp */
  if(ip->protocol == IPPROTO_TCP)
    {
      printk("TCP::"
	     "%d.%d.%d%d:%hu --> %d.%d.%d%d:%hu \n",
	     (ntohl(ip->saddr)>>24) & 0xff,
	     (ntohl(ip->saddr)>>16) & 0xff,
	     (ntohl(ip->saddr)>>8) & 0xff,
	     (ntohl(ip->saddr)>>0) & 0xff,
	     ntohs(mytcphdr->source),
	     (ntohl(ip->daddr)>>24) & 0xff,
	     (ntohl(ip->daddr)>>16) & 0xff,
	     (ntohl(ip->daddr)>>8) & 0xff,
	     (ntohl(ip->daddr)>>0) & 0xff,
	     ntohs(mytcphdr->dest)
	     );

    }
  return NF_ACCEPT;
}  

static struct nf_hook_ops dhee_hook_ops =
  {
    {NULL, NULL},
    dhee_hook,
    PF_INET,
    NF_IP_LOCAL_IN,
    NF_IP_PRI_FILTER+1
  };


void dhee_ksym()
{
  return;
}

/* Initialize */
int init_module()
{
  dhee_ksym();
  printk("Hello, world - this is the kernel speaking\n");
  return nf_register_hook(&dhee_hook_ops);
}


/* Cleanup */
void cleanup_module ()
{
  nf_unregister_hook(&dhee_hook_ops);
  printk("Short is the life of an LKM\n");
}

============
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux