/*******************************************************************************
    OpenAirInterface 
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface 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 3 of the License, or
    (at your option) any later version.


    OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is 
   included in this distribution in the file called "COPYING". If not, 
   see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr
  
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06410 Biot Sophia Antipolis cedex, FRANCE

 *******************************************************************************/
/*________________________OPENAIR/OPENAIR3/________________________

 File    : INSTALL.kernel
 Authors : OpenAir3
 Company : EURECOM
 Emails  : openair3@eurecom.fr
________________________________________________________________*/

-------------------------
Table of contents
-------------------------

The content of this file is the following:

        0) PMIP6D
        1) HOW TO BUILD THE PROPER KERNEL
		1.1) Enable the required features in the kernel
	        1.2) Kernel recompilation


0) PMIP6D
================================
Proxy Mobile IPv6 (PMIPv6) is a network-based mobility management protocol for localized domains, which has been actively standardized by the IETF NETLMM Working Group. PMIPv6 is starting to attract much attention among telecommunication and internet communities due to its salient features and it is expected to expedite the real deployment of IP-based mobility management.

Notice also that this release is for use with:
- i386,

WARNING: The PMIP6D has been developped and validated under Linux UBUNTU 10.04 LTS distribution. 
	 We can not confirm it will work with other systems however it might work with other UBUNTU systems. 

1) HOW TO BUILD THE PROPER KERNEL
=================================

1.1) Enable the required features in the kernel
-----------------------------------------------

Your current kernel DOES NOT require any patches in order to run PMIP6D, however you need to enable some already existing features in your kernel and recompile it.

If you don't already have your kernel source installed on your machine, follow what is next.
Be sure to be connected to Internet, open a new shell and type :
	$ apt-get update 
	$ apt-get install linux-source
	$ cd /usr/src/
	$ tar xjf linux-source-XX.XX.XX (with XX.XX.XX depends on your system version)
	$ ln -s /usr/src/linux-source-XX.XX.XX /usr/src/linux

Now that you have your kernel source, we will configure them.
In your shell, execute :
	$ apt-get install qt3-apps-dev g++
	$ cd /usr/src/linux-source-XX.XX.XX

Run either :
	$ make xconfig # (Qt-based) (recommended)
	$ make gconfig # (GTK-based)
	$ make menuconfig # (You need to install libncurses4-dev first) 

And set the features this way :
N.B: When you execute "make xconfig" all the features are set in a tree. For some features, you'll find in brackets the path in the kernel tree to reach the feature you want to enable.  

 Required for every nodes :
  CONFIG_EXPERIMENTAL=y		(GENERAL SETUP -> PROMPT FOR DEV AND OR INCOMPLETE DRIVERS)
  CONFIG_SYSVIPC=y			(GENERAL SETUP -> SYSTEM V IPC)
  CONFIG_PROC_FS=y			
  CONFIG_NET=y				(NETWORKING SUPPORT -> NETWORKING OPTIONS -> TCP/IP NETWORKING)
  CONFIG_INET=y				(NETWORKING SUPPORT -> NETWORKING OPTIONS -> TCP/IP NETWORKING)
  CONFIG_IPV6=y				(NETWORKING SUPPORT -> NETWORKING OPTIONS -> TCP/IP NETWORKING)
  CONFIG_IPV6_MIP6=y		(NETWORKING SUPPORT -> NETWORKING OPTIONS -> IPV6 PROTOCOL)
  CONFIG_XFRM=y
  CONFIG_XFRM_USER=y		(NETWORKING SUPPORT -> NETWORKING OPTIONS -> TRANSFORMATION USER CONFIGURATION INTERFACE)
  CONFIG_XFRM_SUB_POLICY=y	(NETWORKING SUPPORT -> NETWORKING OPTIONS -> TRANSFORMATION SUB POLICY SUPPORT)
  CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=y	(NETWORKING SUPPORT -> NETWORKING OPTIONS -> IPV6 PROTOCOL -> IPV6: MIPV6 ROUTE OPTIMISATION MODE)
  
 The Home Agent and Mobile Node also need:
  CONFIG_IPV6_TUNNEL=y				(NETWORKING SUPPORT -> NETWORKING OPTIONS -> IPV6 PROTOCOL -> IPV6: IPV6 IN IPV6 TUNNEL)
  CONFIG_IP_ADVANCED_ROUTER=y		(NETWORKING SUPPORT -> NETWORKING OPTIONS -> IP: ADVANCED ROUTER)
  CONFIG_IPV6_MULTIPLE_TABLES=y
  
 The Mobile Node also needs:
  CONFIG_IPV6_SUBTREES=y
  
 For some additional movement indicators on the Mobile Node you may set:
  CONFIG_ARPD=y				(NETWORKING SUPPORT -> NETWORKING OPTIONS -> IP: ARP DAEMON SUPPORT)
  
 For IPsec support you need at least:
  CONFIG_INET6_ESP=y		(NETWORKING SUPPORT -> NETWORKING OPTIONS -> IPV6 PROTOCOL -> IPV6 ESP TRANSFORMATION)
  
 If you plan to use IPsec tunnel mode you need:
  CONFIG_NET_KEY=y			(NETWORKING SUPPORT -> NETWORKING OPTIONS -> PF_KEY SOCKETS)
  CONFIG_NET_KEY_MIGRATE=y	(NETWORKING SUPPORT -> NETWORKING OPTIONS -> PF_KEY SOCKETS -> PF_KEY MIGRATE)
 Do not turn CONFIG_IPV6_MIP6_DEBUG on

In order to be sure, you did it in a proper way, there is a script in the PMIP6D directory which is capable of checking if the kernel settings are set correctly.
To check your kernel, open a new shell, go to your PMIP6D directory and type :
	$ ./chkconf_kernel.sh /usr/src/linux-source-XX.XX.XX

1.2) Kernel recompilation
-----------------------------------------------

Now that you gave the good options to your kernel, we need to recompile it.
	$ cd /usr/src/linux-source-XX.XX.XX
	$ make && make modules_install && make install
	N.B: If you have many cores in your CPU and wand to use all of them in order to make the compilation faster, you might add "-jX" option to your "make" command with X=nb of core. For example for a dual-core CPU, type "make -j2". For a quad-core CPU, type "make -j4"

	$ mkinitramfs -o  /boot/initrd.img-XX.XX.XX   XX.XX.XX
	$ update-grub
	N.B: If your computer does not reboot on the good kernel, edit and update the "default" line inside the following file -> /boot/grub/grub.cfg 

	You should now reboot your system in order to take into account modifications you made on your kernel
	$ reboot
