--- cvc_linux-rh-gcc3-3.5/src/linux_wrapper.c	2007-02-07 19:10:41.000000000 +0000
+++ cvc_linux-rh-gcc3-3.5/src/linux_wrapper.c	2007-09-10 14:16:04.000000000 +0000
@@ -48,7 +48,7 @@
 #include <linux/utsrelease.h>
 #endif
 /* Version 2.2.x */
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
 
 #include <linux/autoconf.h>
 
@@ -77,7 +77,7 @@
 #include <net/ip.h>
 #include <linux/udp.h>
 
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
   #include <linux/firewall.h>
   #include <asm/spinlock.h>
   #include <net/route.h>
@@ -88,12 +88,12 @@
   int nl_nf_register_hook(struct nf_hook_ops *reg);
   int mishim_init();
   int mishim_uninit();
-#if (LINUX_VERSION_CODE >= 0x020500)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
 
 #include <asm/checksum.h>
 
   #include <net/flow.h>
-#if (LINUX_VERSION_CODE > 0x02060c)
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,c))
   #include <net/route.h>
 #else
   struct rtable;
@@ -134,13 +134,18 @@ int nl_open(struct inode *inode, struct 
 
 
 /* some necessary globals... */
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
 typedef struct device net_device_t;
 #else
 typedef struct net_device net_device_t;
 #endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+typedef struct list_head net_device_p;
+#else
+typedef net_device_t net_device_p;
+#endif
 
-net_device_t *nl_dev_base;
+net_device_p *nl_dev_base;
 int kmalloc_pri = GFP_ATOMIC;
 
 /* assert macro definition */
@@ -168,12 +173,12 @@ typedef unsigned long DWORD;
 unsigned long volatile *nljiffies = &jiffies;
 char kernel_version [] = UTS_RELEASE;
 
-#if (LINUX_VERSION_CODE > 0x020400)
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0))
   static struct nf_hook_ops input_filter;
   static struct nf_hook_ops output_filter;
 #endif
 
-#if (LINUX_VERSION_CODE > 0x020400)
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0))
 unsigned int mishim_packet_in (unsigned int hooknum,
                              struct sk_buff **skbp,
                              const net_device_t *in,
@@ -229,9 +234,21 @@ void unregister_netfilter()
 }
 #endif
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22))
+struct iphdr ip_hdr(struct sk_buff *skb)
+{
+  return skb->nh.iph;
+}
+
+net_device_t* net_device_entry(net_device_p *dev)
+{
+  return dev;
+}
+#endif
+
 void mod_inc_use_count()
 {
-#if (LINUX_VERSION_CODE >= 0x020500)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
   try_module_get(THIS_MODULE);
 #else
   MOD_INC_USE_COUNT;
@@ -239,12 +256,11 @@ void mod_inc_use_count()
 }
 void mod_dec_use_count()
 {
-#if (LINUX_VERSION_CODE >= 0x020500)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
   module_put(THIS_MODULE);
 #else
   MOD_DEC_USE_COUNT;
 #endif
-
 }
 void nldo_gettimeofday(struct timeval *tvdataptr)
 {
@@ -280,7 +296,7 @@ unsigned long ticks_to_ms (unsigned long
 
 struct sk_buff *nl_frag_list (struct sk_buff *skb)
 {
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
     return NULL;
 #else
     return skb_shinfo(skb)->frag_list;
@@ -306,11 +322,14 @@ nl_copy_to_user(void *to, const void *fr
 
 void init_misc(void)
 {
-
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+        nl_dev_base = &dev_base_head;
+#else
         nl_dev_base = dev_base;
+#endif
 }
 
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
 
 int nl_register_firewall(int pf, struct firewall_ops *fw)
 {
@@ -402,7 +421,7 @@ void nl_spin_lock_init(spinlock_t *lockp
 }
 void nl_spin_lock_irqsave(spinlock_t *lockptr, DWORD *flagptr)
 {
-#if (LINUX_VERSION_CODE < 0x020607) 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) 
 	assert(lockptr); 
 	assert(flagptr); 
 	spin_lock_irqsave((spinlock_t *)lockptr, (*flagptr));
@@ -413,7 +432,7 @@ void nl_spin_lock_irqsave(spinlock_t *lo
 
 void nl_spin_unlock_irqrestore(spinlock_t *lockptr, DWORD *flagptr)
 {
-#if (LINUX_VERSION_CODE < 0x020607) 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) 
 	assert(lockptr);
 	assert(flagptr);
 	spin_unlock_irqrestore((spinlock_t *)lockptr, (*flagptr));
@@ -429,9 +448,9 @@ void nl_skb_put(struct sk_buff *skb, int
 
 int nl_ip_rcv(struct sk_buff *skb, struct packet_type *pt)
 {
-#if (LINUX_VERSION_CODE > 0x02060c)
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,12))
     struct net_device *dev = skb->dev;
-    struct iphdr *iph = skb->nh.iph;
+    struct iphdr *iph = ip_hdr(skb);
 
     if (skb->dst == NULL)
         {
@@ -467,32 +486,32 @@ int nl_unregister_netdevice_notifier(str
     return unregister_netdevice_notifier (nb);
 }
 
-char *dev_name (net_device_t *dev)
+char *dev_name (net_device_p *dev)
 {
-  return (dev->name);
+  return (net_device_entry(dev)->name);
 }
 
-int dev_name_len (net_device_t *dev)
+int dev_name_len (net_device_p *dev)
 {
-  return (strlen(dev->name));
+  return (strlen(net_device_entry(dev)->name));
 }
-unsigned *dev_mtu_ptr (net_device_t *dev)
+unsigned *dev_mtu_ptr (net_device_p *dev)
 {
-  return (&dev->mtu);
+  return &(net_device_entry(dev)->mtu);
 }
-unsigned dev_mtu (net_device_t *dev)
+unsigned dev_mtu (net_device_p *dev)
 {
-  return (dev->mtu);
+  return (net_device_entry(dev)->mtu);
 }
-int dev_ifindex (net_device_t *dev)
+int dev_ifindex (net_device_p *dev)
 {
-  return (dev->ifindex);
+  return (net_device_entry(dev)->ifindex);
 }
-void *dev_ip_ptr (net_device_t *dev)
+void *dev_ip_ptr (net_device_p *dev)
 {
-  return (dev->ip_ptr);
+  return (net_device_entry(dev)->ip_ptr);
 }
-net_device_t *dev_next (net_device_t *dev)
+net_device_t *dev_next (net_device_p *dev)
 {
   return (dev->next);
 }
@@ -546,20 +565,26 @@ void nl_skb_dup (struct sk_buff *new_skb
     head_offset = new_skb->head - skb->head;
     new_skb->dev = skb->dev;
     new_skb->dst = dst_clone(skb->dst);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+    new_skb->transport_header = skb->transport_header+head_offset;
+    new_skb->network_header = skb->network_header+head_offset;
+    new_skb->mac_header = skb->mac_header+head_offset;
+#else
     new_skb->h.raw = skb->h.raw+head_offset;
     new_skb->nh.raw = skb->nh.raw+head_offset;
     new_skb->mac.raw = skb->mac.raw+head_offset;
+#endif
     memcpy(new_skb->cb, skb->cb, sizeof(skb->cb));
     new_skb->priority = skb->priority;
     new_skb->protocol = skb->protocol;
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
     new_skb->security = skb->security;
     new_skb->stamp = skb->stamp;
     new_skb->used = skb->used;
 #endif
     }
                                                                                 
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
   new_skb->is_clone = 0;
 #else
 	new_skb->ip_summed = skb->ip_summed;
@@ -573,13 +598,19 @@ void nl_skb_hdr_copy (struct sk_buff *sk
 {
   skb_to->dev = skb_from->dev;
   skb_to->dst = skb_from->dst;
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+  skb_to->transport_header = skb_from->transport_header;
+  skb_to->network_header = skb_from->network_header;
+  skb_to->mac_header = skb_from->mac_header;
+#else
   skb_to->h.raw = skb_from->h.raw;
   skb_to->nh.raw = skb_from->nh.raw;
   skb_to->mac.raw = skb_from->mac.raw;
+#endif
   memcpy(skb_to->cb, skb_from->cb, sizeof(skb_from->cb));
   skb_to->priority = skb_from->priority;
   skb_to->protocol = skb_from->protocol;
-#if ((LINUX_VERSION_CODE >= 0x020200) && (LINUX_VERSION_CODE < 0x020300))
+#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0)))
   skb_to->stamp = skb_from->stamp;
   skb_to->used = skb_from->used;
 #else
@@ -592,7 +623,7 @@ void nl_skb_hdr_copy (struct sk_buff *sk
 
 struct iphdr * nl_skb_iph (struct sk_buff *skb)
 {
-  return skb->nh.iph;
+  return ip_hdr(skb);
 }
 
 net_device_t * nl_skb_dev (struct sk_buff *skb)
@@ -613,13 +644,17 @@ void nl_send_skb (struct sk_buff *skb, n
 
   if (skb)
     {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22))
+    skb_reset_network_header(skb);
+#else
     skb->nh.iph = (struct iphdr *) skb->data;
+#endif
     skb->dev = dev;
-                                                                                
-    iph = skb->nh.iph;
-                                              
+    
+    iph = ip_hdr(skb);
+    
     rval = ip_route_output (&rt, iph->daddr, 0, RT_TOS(iph->tos), 0);
-                                                                                
+    
     if (rval < 0)
       {
       printk("NL_SEND_SKB: ip_route_output failed.");
@@ -633,7 +668,7 @@ void nl_send_skb (struct sk_buff *skb, n
                                                                                 
     if (skb->dst)
       {
-#if ((LINUX_VERSION_CODE < 0x020607) || (LINUX_VERSION_CODE > 0x020609))
+#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7)) || (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)))
       skb->dst->output(skb);
 #else
       skb->dst->output(&skb);
@@ -664,7 +699,7 @@ void update_inner_route (struct sk_buff 
   dst_release(skb->dst);
   skb->dst = NULL;
 }
-#if (LINUX_VERSION_CODE < 0x020500)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
 
 extern char kernel_version [];
 
@@ -741,7 +776,7 @@ void do_checksum_offload( struct sk_buff
   struct sk_buff *frag_ptr;
   struct iphdr *iph;
 
-#if (LINUX_VERSION_CODE < 0x020500)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
   ip_send_check (skb->nh.iph);
   return;
 #else
@@ -749,7 +784,7 @@ void do_checksum_offload( struct sk_buff
     {
     goto done_exit;
     }
-  iph = skb->nh.iph;
+  iph = ip_hdr(skb);
   header_length = iph->ihl << 2;                /* get the ip header length */
   h_ptr = (char*)iph + header_length;           /* get pointer to proto header */
   frag_ptr = skb_shinfo( skb )->frag_list;      /* at most, one frag */
@@ -765,11 +800,11 @@ void do_checksum_offload( struct sk_buff
     csum = csum_partial( h_ptr, ntohs(iph->tot_len) - header_length, 0 );
     check = csum_fold( csum_partial( frag_ptr->data, nl_data_len( frag_ptr ), csum ) );
     }
-  if ( skb->nh.iph->protocol == 17 )            /* if UDP, */
+  if ( iph->protocol == IPPROTO_UDP )
     {
     ((struct udphdr*)h_ptr)->check = check;
     }
-  if ( skb->nh.iph->protocol == 6 )             /* if TCP, */
+  if ( iph->protocol == IPPROTO_TCP )
     {
     ((struct tcphdr*)h_ptr)->check = check;
     }
