=== modified file '.bzrignore'
--- .bzrignore	2012-05-27 19:19:03 +0000
+++ .bzrignore	2012-07-09 11:47:01 +0000
@@ -1,5 +1,6 @@
 Makefile
 Makefile.in
+!./kernel/Makefile.in
 .deps
 .libs
 *.lo

=== modified file 'Makefile.am'
--- Makefile.am	2012-05-11 06:03:25 +0000
+++ Makefile.am	2012-07-09 11:46:00 +0000
@@ -28,7 +28,21 @@
 EXAMPLES_DIR =
 endif
 
-SUBDIRS = src $(TESTS_DIR) $(STATS_DIR) app $(DOC_DIR) $(EXAMPLES_DIR) contrib
+if BUILD_KMOD
+KMOD_DIR = kernel
+else
+KMOD_DIR =
+endif
+
+SUBDIRS = \
+	src \
+	$(TESTS_DIR) \
+	$(STATS_DIR) \
+	app \
+	$(DOC_DIR) \
+	$(EXAMPLES_DIR) \
+	contrib \
+	$(KMOD_DIR)
 
 dist_doc_DATA = \
 	README \

=== modified file 'configure.ac'
--- configure.ac	2012-06-19 20:43:11 +0000
+++ configure.ac	2012-07-09 11:46:00 +0000
@@ -318,10 +318,50 @@
 AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$build_examples" = "xyes"])
 
 
+# check if linux kernel module build enabled
+AC_ARG_ENABLE(kernel-module,
+              AS_HELP_STRING([--enable-kernel-module],
+                             [build linux kernel module [default=no]]),
+              [build_kmod=$enableval],
+              [build_kmod=no])
+AM_CONDITIONAL([BUILD_KMOD], [test "x$build_kmod" = "xyes"])
+
+# allow users to specify kernel soure directory
+AC_ARG_WITH(kernel-src,
+            AS_HELP_STRING([--with-kernel-src=DIR],
+                           [linux kernel source directory]),
+            [kernel_src="$withval"],
+            [kernel_src="no"])
+if test "$build_kmod" = "yes"; then
+	AC_MSG_CHECKING([kernel source directory])
+	if test "$kernel_src" = "no"; then
+		runver=`uname -r`
+		sourcelink=/lib/modules/${runver}/source
+		buildlink=/lib/modules/${runver}/build
+
+		if test -e $buildlink; then
+			kernel_src=`(cd $buildlink; /bin/pwd)`
+		fi
+		if test -e $sourcelink; then
+			kernel_src=`(cd $sourcelink; /bin/pwd)`
+		fi
+		if test -z "$kernel_src"; then
+			AC_MSG_RESULT([Not found])
+			AC_MSG_ERROR([
+				ERROR: linux kernel source not found
+				specify the location of the kernel source with
+				the '--with-kerne-src=DIR' option])
+		fi
+	fi
+	AC_MSG_RESULT([$kernel_src])
+	AC_SUBST(kernel_src)
+fi
+
 AM_DEP_TRACK
 
 AC_CONFIG_FILES([ \
 	Makefile \
+	kernel/Makefile \
 	src/Makefile \
 	src/common/Makefile \
 	src/common/test/Makefile \

=== added directory 'kernel'
=== added file 'kernel/Makefile.in'
--- kernel/Makefile.in	1970-01-01 00:00:00 +0000
+++ kernel/Makefile.in	2012-07-09 11:46:00 +0000
@@ -0,0 +1,142 @@
+# @configure_input@
+
+srcdir = @abs_srcdir@
+builddir = @abs_builddir@
+INSTALL = @INSTALL@
+KDIR = @kernel_src@
+
+DISTFILES = \
+	$(srcdir)/Makefile.in \
+	$(srcdir)/kmod.c\
+	$(srcdir)/include
+
+rohc_sources = \
+	common/rohc.c \
+	common/rohc_packets.c \
+	common/rohc_traces.c \
+	common/crc.c \
+	common/decode.c \
+	common/ip_id.c \
+	common/interval.c \
+	common/lsb_decode.c \
+	common/sdvl.c \
+	common/wlsb.c \
+	common/ip.c \
+	common/ts_sc_comp.c \
+	common/ts_sc_decomp.c \
+	common/comp_list.c \
+	common/cid.c \
+	comp/rohc_comp.c \
+	comp/c_uncompressed.c \
+	comp/c_generic.c \
+	comp/c_ip.c \
+	comp/c_udp.c \
+	comp/c_udp_lite.c \
+	comp/c_rtp.c \
+	decomp/rohc_decomp.c \
+	decomp/feedback.c \
+	decomp/d_uncompressed.c \
+	decomp/d_generic.c \
+	decomp/d_ip.c \
+	decomp/d_udp.c \
+	decomp/d_udp_lite.c \
+	decomp/d_rtp.c
+
+rohc_links = $(notdir $(rohc_sources)) kmod.c
+rohc_fixed_links = $(subst rohc.c,rohc_common.c,$(rohc_links))
+rohc_objs = $(patsubst %.c,%.o,$(rohc_fixed_links))
+rohc_modname = rohc
+rohc_mod = $(rohc_modname).ko
+rohc_moddir = /lib/modules/`uname -r`/extra
+
+ifneq ($(KERNELRELEASE),)
+
+rohc_ccflags = \
+	-Wall \
+	-I$(builddir)/.. \
+	-I$(srcdir)/include \
+	-I$(srcdir)/../src/common \
+	-I$(srcdir)/../src/comp \
+	-I$(srcdir)/../src/decomp
+
+EXTRA_CFLAGS = $(rohc_ccflags)
+
+obj-m  = $(rohc_modname).o
+$(rohc_modname)-y = $(rohc_objs)
+
+else
+
+all: fix_rohc_links
+	$(MAKE) V=0 -C $(KDIR) M=`pwd` modules
+
+$(foreach s,$(sort $(rohc_sources)), \
+  $(eval $(notdir $(s)): ; ln -s $(srcdir)/../src/$(s) $@))
+
+kmod.c:
+	ln -s $(srcdir)/$@
+
+fix_rohc_links: $(rohc_links)
+	mv rohc.c rohc_common.c
+
+clean:
+	rm -rf \
+		*.o  \
+		*.ko \
+		.*.cmd \
+		*.mod.c \
+		.tmp_versions \
+		Module.symvers \
+		modules.order
+
+distclean: clean
+	for d in $(rohc_links); do if test -h $$d; then rm $$d; fi; done
+	if test -h kmod.c; then rm kmod.c; fi
+	rm -f rohc_common.c
+	rm -f Makefile
+
+install:
+	$(INSTALL) -d $(DESTDIR)$(rohc_moddir)
+	$(INSTALL) -m 644 $(rohc_mod) $(DESTDIR)$(rohc_moddir)/$(rohc_mod)
+	-/sbin/depmod -a
+
+uninstall:
+	rm -f $(DESTDIR)$(rohc_moddir)/$(rohc_mod)
+	-/sbin/depmod -a
+
+
+distdir: $(DISTFILES)
+	cp -rpn $(DISTFILES) $(distdir)
+
+EMPTY_AUTOMAKE_TARGETS = \
+	install-data \
+	install-exec \
+	install-dvi \
+	install-html \
+	install-info \
+	install-ps \
+	install-pdf \
+	installdirs \
+	check \
+	installcheck \
+	mostlyclean \
+	maintainer-clean \
+	dvi \
+	pdf \
+	ps \
+	info \
+	html \
+	tags \
+	ctags 
+
+$(EMPTY_AUTOMAKE_TARGETS):
+
+.PHONY: \
+	fix_rohc_links \
+	all \
+	clean \
+	distclean \
+	install \
+	uninstall \
+	distdir \
+	$(EMPTY_AUTOMAKE_TARGETS)
+endif

=== added directory 'kernel/include'
=== added file 'kernel/include/assert.h'
--- kernel/include/assert.h	1970-01-01 00:00:00 +0000
+++ kernel/include/assert.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,24 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef ASSERT_H_
+#define ASSERT_H_
+
+#include <linux/kernel.h>
+
+#define assert(x)
+
+#endif /* ASSERT_H_ */

=== added file 'kernel/include/endian.h'
--- kernel/include/endian.h	1970-01-01 00:00:00 +0000
+++ kernel/include/endian.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,22 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef ENDIAN_H_
+#define ENDIAN_H_
+
+#include <linux/kernel.h>
+
+#endif /* ENDIAN_H_ */

=== added directory 'kernel/include/netinet'
=== added file 'kernel/include/netinet/in.h'
--- kernel/include/netinet/in.h	1970-01-01 00:00:00 +0000
+++ kernel/include/netinet/in.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,23 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef IN_H_
+#define IN_H_
+
+#include <linux/in.h>
+#include <linux/in6.h>
+
+#endif /* IN_H_ */

=== added file 'kernel/include/netinet/ip.h'
--- kernel/include/netinet/ip.h	1970-01-01 00:00:00 +0000
+++ kernel/include/netinet/ip.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,22 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef IP_H_
+#define IP_H_
+
+#include <net/ip.h>
+
+#endif /* IP_H_ */

=== added file 'kernel/include/netinet/ip6.h'
--- kernel/include/netinet/ip6.h	1970-01-01 00:00:00 +0000
+++ kernel/include/netinet/ip6.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,48 @@
+/* Copyright (C) 1991-1997, 2001, 2003, 2006 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _NETINET_IP6_H
+#define _NETINET_IP6_H 1
+
+#include <netinet/in.h>
+
+struct ip6_hdr
+  {
+    union
+      {
+	struct ip6_hdrctl
+	  {
+	    uint32_t ip6_un1_flow;   /* 4 bits version, 8 bits TC,
+					20 bits flow-ID */
+	    uint16_t ip6_un1_plen;   /* payload length */
+	    uint8_t  ip6_un1_nxt;    /* next header */
+	    uint8_t  ip6_un1_hlim;   /* hop limit */
+	  } ip6_un1;
+	uint8_t ip6_un2_vfc;       /* 4 bits version, top 4 bits tclass */
+      } ip6_ctlun;
+    struct in6_addr ip6_src;      /* source address */
+    struct in6_addr ip6_dst;      /* destination address */
+  };
+#define ip6_vfc   ip6_ctlun.ip6_un2_vfc
+#define ip6_flow  ip6_ctlun.ip6_un1.ip6_un1_flow
+#define ip6_plen  ip6_ctlun.ip6_un1.ip6_un1_plen
+#define ip6_nxt   ip6_ctlun.ip6_un1.ip6_un1_nxt
+#define ip6_hlim  ip6_ctlun.ip6_un1.ip6_un1_hlim
+#define ip6_hops  ip6_ctlun.ip6_un1.ip6_un1_hlim
+
+#endif /* netinet/ip6.h */

=== added file 'kernel/include/netinet/udp.h'
--- kernel/include/netinet/udp.h	1970-01-01 00:00:00 +0000
+++ kernel/include/netinet/udp.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,22 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef UDP_H_
+#define UDP_H_
+
+#include <net/udp.h>
+
+#endif /* UDP_H_ */

=== added file 'kernel/include/stdbool.h'
--- kernel/include/stdbool.h	1970-01-01 00:00:00 +0000
+++ kernel/include/stdbool.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,28 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef STDBOOL_H_
+#define STDBOOL_H_
+
+#include <linux/kernel.h>
+
+#ifndef bool
+#define bool int
+#define true 1
+#define false 0
+#endif
+
+#endif /* STDBOOL_H_ */

=== added file 'kernel/include/stdint.h'
--- kernel/include/stdint.h	1970-01-01 00:00:00 +0000
+++ kernel/include/stdint.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,22 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef STDINT_H_
+#define STDINT_H_
+
+#include <linux/kernel.h>
+
+#endif /* STDINT_H_ */

=== added file 'kernel/include/stdio.h'
--- kernel/include/stdio.h	1970-01-01 00:00:00 +0000
+++ kernel/include/stdio.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,24 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef STDIO_H_
+#define STDIO_H_
+
+#include <linux/kernel.h>
+
+int printf(const char *format, ...);
+
+#endif /* STDIO_H_ */

=== added file 'kernel/include/stdlib.h'
--- kernel/include/stdlib.h	1970-01-01 00:00:00 +0000
+++ kernel/include/stdlib.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,26 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef STDLIB_H_
+#define STDLIB_H_
+
+#include <linux/kernel.h>
+
+void *malloc(size_t size);
+void free(void *ptr);
+void *calloc(size_t nmemb, size_t size);
+
+#endif /* STDLIB_H_ */

=== added file 'kernel/include/string.h'
--- kernel/include/string.h	1970-01-01 00:00:00 +0000
+++ kernel/include/string.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,25 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef STRING_H_
+#define STRING_H_
+
+#include <linux/kernel.h>
+#include <linux/string.h>
+
+#define bzero(s, n)		memset(s, 0, n)
+
+#endif /* STRING_H_ */

=== added directory 'kernel/include/sys'
=== added file 'kernel/include/sys/time.h'
--- kernel/include/sys/time.h	1970-01-01 00:00:00 +0000
+++ kernel/include/sys/time.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,25 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef TIME_H_
+#define TIME_H_
+
+#include <linux/kernel.h>
+#include <linux/time.h>
+
+#define gettimeofday(a, b)	do_gettimeofday(a)
+
+#endif /* TIME_H_ */

=== added file 'kernel/include/sys/types.h'
--- kernel/include/sys/types.h	1970-01-01 00:00:00 +0000
+++ kernel/include/sys/types.h	2012-07-09 11:46:00 +0000
@@ -0,0 +1,22 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef TYPES_H_
+#define TYPES_H_
+
+#include <linux/kernel.h>
+
+#endif /* TYPES_H_ */

=== added file 'kernel/kmod.c'
--- kernel/kmod.c	1970-01-01 00:00:00 +0000
+++ kernel/kmod.c	2012-07-09 11:46:00 +0000
@@ -0,0 +1,67 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <config.h>
+#include <rohc.h>
+#include <rohc_comp.h>
+#include <rohc_decomp.h>
+#include <stdlib.h>
+#include <string.h>
+
+MODULE_DESCRIPTION(PACKAGE_STRING " (" PACKAGE_URL ")");
+MODULE_LICENSE("GPL");
+
+void *malloc(size_t size)
+{
+	return kmalloc(size, GFP_ATOMIC);
+}
+
+void *calloc(size_t n, size_t size)
+{
+	return kcalloc(n, size, GFP_ATOMIC);
+}
+
+void free(void *ptr)
+{
+	kfree(ptr);
+}
+
+int printf(const char *fmt, ...)
+{
+	char printf_buf[1024] = KERN_DEBUG " ";
+	va_list args;
+
+	va_start(args, fmt);
+	vsprintf(printf_buf + 4, fmt, args);
+	va_end(args);
+
+	return printk(printf_buf);
+}
+
+EXPORT_SYMBOL(rohc_version);
+EXPORT_SYMBOL(rohc_alloc_compressor);
+EXPORT_SYMBOL(rohc_free_compressor);
+EXPORT_SYMBOL(rohc_compress);
+EXPORT_SYMBOL(rohc_activate_profile);
+EXPORT_SYMBOL(rohc_c_set_large_cid);
+EXPORT_SYMBOL(rohc_c_set_max_cid);
+EXPORT_SYMBOL(rohc_feedback_flush);
+EXPORT_SYMBOL(rohc_alloc_decompressor);
+EXPORT_SYMBOL(rohc_free_decompressor);
+EXPORT_SYMBOL(rohc_decompress);
+EXPORT_SYMBOL(rohc_decompress_both);

=== modified file 'src/common/ip.h'
--- src/common/ip.h	2012-05-31 20:31:46 +0000
+++ src/common/ip.h	2012-07-09 11:46:00 +0000
@@ -207,6 +207,7 @@
  * Inline functions
  */
 
+#ifndef __KERNEL__
 /**
  * @brief In-place change the byte order in a two-byte value.
  *
@@ -360,6 +361,7 @@
 
 
 #endif
+#endif
 
 
 /*

=== modified file 'src/common/rohc_bit_ops.h'
--- src/common/rohc_bit_ops.h	2012-05-10 18:48:30 +0000
+++ src/common/rohc_bit_ops.h	2012-07-09 11:46:00 +0000
@@ -84,10 +84,10 @@
  * @brief Get the next 16 bits at the given memory location
  *        in Network Byte Order
  */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if (defined(__KERNEL__) && defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN))
 	#define GET_NEXT_16_BITS(x) \
 		((((*((x) + 1)) << 8) & 0xff00) | ((*(x)) & 0x00ff))
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif (defined(__KERNEL__) && defined(__BIG_ENDIAN)) || (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN))
 	#define GET_NEXT_16_BITS(x) \
 		((((*(x)) << 8) & 0xff00) | ((*((x) + 1)) & 0x00ff))
 #else

=== modified file 'src/common/rtp.h'
--- src/common/rtp.h	2011-11-12 14:31:32 +0000
+++ src/common/rtp.h	2012-07-09 11:46:00 +0000
@@ -35,14 +35,14 @@
  */
 struct rtphdr
 {
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if (defined(__KERNEL__) && defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN))
 	u_int16_t cc:4;          ///< CSRC Count
 	u_int16_t extension:1;   ///< Extension bit
 	u_int16_t padding:1;     ///< Padding bit
 	u_int16_t version:2;     ///< RTP version
 	u_int16_t pt:7;          ///< Payload Type
 	u_int16_t m:1;           ///< Marker
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#elif (defined(__KERNEL__) && defined(__BIG_ENDIAN)) || (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN))
 	u_int16_t version:2;
 	u_int16_t padding:1;
 	u_int16_t extension:1;

