IP Driver for UE using LTE-EPC
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4913 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
Executable
+340
@@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
Executable
+100
@@ -0,0 +1,100 @@
|
||||
# UE IP Driver makefile
|
||||
#
|
||||
NAS_UPDIR := $(shell /bin/pwd)
|
||||
|
||||
KERNEL_NAME=$(shell echo `uname -r`)
|
||||
|
||||
KERNEL_MAIN_TYPE=$(shell echo `uname -r | cut -d. -f-2 | tr "." "_"`)
|
||||
export KERNEL_MAIN_TYPE
|
||||
|
||||
KERNEL_MAIN_VERSION=$(shell echo `uname -r | cut -d. -f-1`)
|
||||
|
||||
ifeq ($(IS_LINUX), 1)
|
||||
SUBVERSION=$(shell echo `grep '^SUBLEVEL =' /usr/src/linux/Makefile | sed -e 's, ,,g' | sed -e 's/SUBLEVEL=//'`)
|
||||
else
|
||||
ifeq ($(IS_KERNEL_OPENAIRINTERFACE), 1)
|
||||
SUBVERSION=$(shell echo `grep '^SUBLEVEL =' /usr/src/linux-$(KERNEL_NAME)/Makefile | sed -e 's, ,,g' | sed -e 's/SUBLEVEL=//'`)
|
||||
else
|
||||
SUBVERSION=$(shell echo `grep '^SUBLEVEL =' /usr/src/linux-headers-$(KERNEL_NAME)/Makefile | sed -e 's, ,,g' | sed -e 's/SUBLEVEL=//'`)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_20=$(shell if [ $(SUBVERSION) -ge 20 ] ; then echo true ; fi)
|
||||
KERNEL_ARCH=$(shell echo `uname -m`)
|
||||
#SET_REGPARM=$(shell if [ $(KERNEL_ARCH) = 'i686' -a $(SUBVERSION) -ge 20 ]; then echo true ; fi)
|
||||
SET_X64=$(shell if [ $(KERNEL_ARCH) = 'x86_64' -a $(SUBVERSION) -ge 20 ]; then echo true ; fi)
|
||||
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_22=$(shell if [ $(SUBVERSION) -ge 22 ] ; then echo true ; fi)
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_29=$(shell if [ $(SUBVERSION) -ge 29 ] ; then echo true ; fi)
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_30=$(shell if [ $(SUBVERSION) -ge 30 ] ; then echo true ; fi)
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_32=$(shell if [ $(SUBVERSION) -ge 32 ] ; then echo true ; fi)
|
||||
|
||||
# Add global rule for V3 kernels
|
||||
ifeq ($(KERNEL_MAIN_VERSION),3)
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_22 = "true"
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_29 = "true"
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_30 = "true"
|
||||
IS_KERNEL_SUBVERSION_GREATER_THAN_32 = "true"
|
||||
IS_KERNEL_MAIN_VERSION_IS_3 = "true"
|
||||
endif
|
||||
|
||||
GT2622= $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_22),-DKERNEL_VERSION_GREATER_THAN_2622=1)
|
||||
GT2629= $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_29),-DKERNEL_VERSION_GREATER_THAN_2629=1)
|
||||
GT32= $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_32),-DKERNEL_VERSION_GREATER_THAN_32=1)
|
||||
V3= $(if $(IS_KERNEL_MAIN_VERSION_IS_3),-DKERNEL_MAIN_VERSION_IS_3=1)
|
||||
####################################################
|
||||
# D E B U G F L A G S
|
||||
####################################################
|
||||
|
||||
|
||||
|
||||
####################################################
|
||||
# EXTRA COMPILER FLAGS
|
||||
####################################################
|
||||
EXTRA_CFLAGS = -fno-common $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_20),-mregparm=3 -fno-stack-protector -mpreferred-stack-boundary=4) $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,) $(GT2622) $(GT2629) $(V3) $(GT32)
|
||||
|
||||
|
||||
|
||||
ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
EXTRA_CFLAGS += -DOAI_NW_DRIVER_USE_NETLINK
|
||||
else
|
||||
EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall
|
||||
endif
|
||||
|
||||
|
||||
####################################################
|
||||
# LOADABLE MODULE GOALS
|
||||
####################################################
|
||||
obj-m += ue_ip.o
|
||||
ue_ip-objs += device.o
|
||||
ue_ip-objs += common.o
|
||||
ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
ue_ip-objs += netlink.o
|
||||
endif
|
||||
|
||||
####################################################
|
||||
# REVOIR LE CLEAN
|
||||
####################################################
|
||||
|
||||
|
||||
print:
|
||||
@echo linux kernel ge 22: $(IS_KERNEL_SUBVERSION_GREATER_THAN_22)
|
||||
@echo kernel name : $(KERNEL_NAME)
|
||||
@echo subversion : $(SUBVERSION)
|
||||
@echo flag gt2622: $(GT2622)
|
||||
@echo linux kernel ge 29: $(IS_KERNEL_SUBVERSION_GREATER_THAN_29)
|
||||
@echo flag gt2629: $(GT2629)
|
||||
@echo linux kernel ge 30: $(IS_KERNEL_SUBVERSION_GREATER_THAN_30)
|
||||
@echo flag KERNEL_MAIN_VERSION $(KERNEL_MAIN_VERSION)
|
||||
clean:
|
||||
rm -f *.ko
|
||||
rm -f .*.ko.cmd
|
||||
rm -f .*.o.cmd
|
||||
rm -f *.o
|
||||
rm -f *.mod.c
|
||||
find . -name *.ko -delete
|
||||
find . -name .*.o -delete
|
||||
find . -name *.o -delete
|
||||
find . -name *.mod.c -delete
|
||||
Executable
+326
@@ -0,0 +1,326 @@
|
||||
/*******************************************************************************
|
||||
|
||||
Eurecom OpenAirInterface 2
|
||||
Copyright(c) 1999 - 2010 Eurecom
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms and conditions of the GNU General Public License,
|
||||
version 2, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope 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.,
|
||||
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in
|
||||
the file called "COPYING".
|
||||
|
||||
Contact Information
|
||||
Openair Admin: openair_admin@eurecom.fr
|
||||
Openair Tech : openair_tech@eurecom.fr
|
||||
Forums : http://forums.eurecom.fsr/openairinterface
|
||||
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
/*! \file common.c
|
||||
* \brief
|
||||
* \author Navid Nikaein and Raymond Knopp, Lionel GAUTHIER
|
||||
* \date 2013
|
||||
* \version 1.0
|
||||
* \company Eurecom
|
||||
* \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr
|
||||
*/
|
||||
|
||||
#include "local.h"
|
||||
#include "proto_extern.h"
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
#include "rtai_fifos.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <linux/inetdevice.h>
|
||||
|
||||
#include <net/tcp.h>
|
||||
#include <net/udp.h>
|
||||
|
||||
#define NIPADDR(addr) \
|
||||
(uint8_t)(addr & 0x000000FF), \
|
||||
(uint8_t)((addr & 0x0000FF00) >> 8), \
|
||||
(uint8_t)((addr & 0x00FF0000) >> 16), \
|
||||
(uint8_t)((addr & 0xFF000000) >> 24)
|
||||
|
||||
#define NIP6ADDR(addr) \
|
||||
ntohs((addr)->s6_addr16[0]), \
|
||||
ntohs((addr)->s6_addr16[1]), \
|
||||
ntohs((addr)->s6_addr16[2]), \
|
||||
ntohs((addr)->s6_addr16[3]), \
|
||||
ntohs((addr)->s6_addr16[4]), \
|
||||
ntohs((addr)->s6_addr16[5]), \
|
||||
ntohs((addr)->s6_addr16[6]), \
|
||||
ntohs((addr)->s6_addr16[7])
|
||||
|
||||
|
||||
//#define OAI_DRV_DEBUG_SEND
|
||||
//#define OAI_DRV_DEBUG_RECEIVE
|
||||
void ue_ip_common_class_wireless2ip(u16 dlen,
|
||||
void *pdcp_sdu,
|
||||
int inst,
|
||||
OaiNwDrvRadioBearerId_t rb_id) {
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
struct sk_buff *skb;
|
||||
struct ipversion *ipv;
|
||||
struct ue_ip_priv *gpriv=netdev_priv(ue_ip_dev[inst]);
|
||||
unsigned int hard_header_len;
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
int i;
|
||||
unsigned char *addr;
|
||||
#endif
|
||||
unsigned char protocol;
|
||||
struct iphdr *network_header;
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[UE_IP_DRV][%s] begin RB %d Inst %d Length %d bytes\n",__FUNCTION__, rb_id,inst,dlen);
|
||||
#endif
|
||||
|
||||
skb = dev_alloc_skb( dlen + 2 );
|
||||
|
||||
if(!skb) {
|
||||
printk("[UE_IP_DRV][%s] low on memory\n",__FUNCTION__);
|
||||
++gpriv->stats.rx_dropped;
|
||||
return;
|
||||
}
|
||||
skb_reserve(skb,2);
|
||||
memcpy(skb_put(skb, dlen), pdcp_sdu,dlen);
|
||||
|
||||
skb->dev = ue_ip_dev[inst];
|
||||
hard_header_len = ue_ip_dev[inst]->hard_header_len;
|
||||
|
||||
skb_set_mac_header(skb, 0);
|
||||
//skb->mac_header = skb->data;
|
||||
|
||||
//printk("[NAC_COMMIN_RECEIVE]: Packet Type %d (%d,%d)",skb->pkt_type,PACKET_HOST,PACKET_BROADCAST);
|
||||
skb->pkt_type = PACKET_HOST;
|
||||
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[UE_IP_DRV][%s] Receiving packet of size %d from PDCP \n",__FUNCTION__, skb->len);
|
||||
|
||||
for (i=0;i<skb->len;i++)
|
||||
printk("%2x ",((unsigned char *)(skb->data))[i]);
|
||||
printk("\n");
|
||||
#endif
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[UE_IP_DRV][%s] skb->data @ %p\n",__FUNCTION__, skb->data);
|
||||
printk("[UE_IP_DRV][%s] skb->mac_header @ %p\n",__FUNCTION__, skb->mac_header);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// LG TEST skb->ip_summed = CHECKSUM_NONE;
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
|
||||
|
||||
ipv = (struct ipversion *)&(skb->data[hard_header_len]);
|
||||
switch (ipv->version) {
|
||||
|
||||
case 6:
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[UE_IP_DRV][%s] receive IPv6 message\n",__FUNCTION__);
|
||||
#endif
|
||||
skb_set_network_header(skb, hard_header_len);
|
||||
//skb->network_header = &skb->data[hard_header_len];
|
||||
|
||||
if (hard_header_len == 0) {
|
||||
skb->protocol = htons(ETH_P_IPV6);
|
||||
} else {
|
||||
#ifdef OAI_NW_DRIVER_TYPE_ETHERNET
|
||||
skb->protocol = eth_type_trans(skb, ue_ip_dev[inst]);
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
//printk("Writing packet with protocol %x\n",ntohs(skb->protocol));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
//printk("NAS_TOOL_RECEIVE: receive IPv4 message\n");
|
||||
addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->saddr;
|
||||
if (addr) {
|
||||
printk("[UE_IP_DRV][%s] Source %d.%d.%d.%d\n",__FUNCTION__, addr[0],addr[1],addr[2],addr[3]);
|
||||
}
|
||||
addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->daddr;
|
||||
if (addr){
|
||||
printk("[UE_IP_DRV][%s] Dest %d.%d.%d.%d\n",__FUNCTION__, addr[0],addr[1],addr[2],addr[3]);
|
||||
}
|
||||
printk("[UE_IP_DRV][%s] protocol %d\n",__FUNCTION__, ((struct iphdr *)&skb->data[hard_header_len])->protocol);
|
||||
#endif
|
||||
|
||||
skb->network_header = &skb->data[hard_header_len];
|
||||
//network_header = (struct iphdr *)skb_network_header(skb);
|
||||
network_header = (struct iphdr *)skb_network_header(skb);
|
||||
protocol = network_header->protocol;
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
switch (protocol) {
|
||||
case IPPROTO_IP:
|
||||
printk("[UE_IP_DRV][%s] Received Raw IPv4 packet\n",__FUNCTION__);
|
||||
break;
|
||||
case IPPROTO_IPV6:
|
||||
printk("[UE_IP_DRV][%s] Received Raw IPv6 packet\n",__FUNCTION__);
|
||||
break;
|
||||
case IPPROTO_ICMP:
|
||||
printk("[UE_IP_DRV][%s] Received Raw ICMP packet\n",__FUNCTION__);
|
||||
break;
|
||||
case IPPROTO_TCP:
|
||||
printk("[UE_IP_DRV][%s] Received TCP packet\n",__FUNCTION__);
|
||||
break;
|
||||
case IPPROTO_UDP:
|
||||
printk("[UE_IP_DRV][%s] Received UDP packet\n",__FUNCTION__);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (hard_header_len == 0) {
|
||||
skb->protocol = htons(ETH_P_IP);
|
||||
}
|
||||
//printk("[UE_IP_DRV][COMMON] Writing packet with protocol %x\n",ntohs(skb->protocol));
|
||||
break;
|
||||
|
||||
default:
|
||||
printk("[UE_IP_DRV][%s] begin RB %d Inst %d Length %d bytes\n",__FUNCTION__,rb_id,inst,dlen);
|
||||
printk("[UE_IP_DRV][%s] Inst %d: receive unknown message (version=%d)\n",__FUNCTION__,inst,ipv->version);
|
||||
}
|
||||
|
||||
++gpriv->stats.rx_packets;
|
||||
gpriv->stats.rx_bytes += dlen;
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[UE_IP_DRV][%s] sending packet of size %d to kernel\n",__FUNCTION__,skb->len);
|
||||
for (i=0;i<skb->len;i++)
|
||||
printk("%2x ",((unsigned char *)(skb->data))[i]);
|
||||
printk("\n");
|
||||
#endif //OAI_DRV_DEBUG_RECEIVE
|
||||
netif_rx(skb);
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[UE_IP_DRV][%s] end\n",__FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete the data
|
||||
void ue_ip_common_ip2wireless_drop(struct sk_buff *skb, int inst){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv=netdev_priv(ue_ip_dev[inst]);
|
||||
++priv->stats.tx_dropped;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Request the transfer of data (QoS SAP)
|
||||
void ue_ip_common_ip2wireless(struct sk_buff *skb, int inst){
|
||||
//---------------------------------------------------------------------------
|
||||
struct pdcp_data_req_header_t pdcph;
|
||||
struct ue_ip_priv *priv=netdev_priv(ue_ip_dev[inst]);
|
||||
#ifdef LOOPBACK_TEST
|
||||
int i;
|
||||
#endif
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
int j;
|
||||
#endif
|
||||
unsigned int bytes_wrote;
|
||||
// Start debug information
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[UE_IP_DRV][%s] inst %d begin \n",__FUNCTION__,inst);
|
||||
#endif
|
||||
|
||||
if (skb==NULL){
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[UE_IP_DRV][%s] input parameter skb is NULL \n",__FUNCTION__);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pdcph.data_size = skb->len;
|
||||
if (skb->mark) {
|
||||
pdcph.rb_id = skb->mark;
|
||||
} else {
|
||||
pdcph.rb_id = UE_IP_DEFAULT_RAB_ID;
|
||||
}
|
||||
pdcph.inst = inst;
|
||||
|
||||
|
||||
bytes_wrote = ue_ip_netlink_send((char *)&pdcph,UE_IP_PDCPH_SIZE);
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[UE_IP_DRV][%s] Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n",__FUNCTION__,
|
||||
bytes_wrote,skb->len);
|
||||
#endif
|
||||
|
||||
if (bytes_wrote != UE_IP_PDCPH_SIZE)
|
||||
{
|
||||
printk("[UE_IP_DRV][%s] problem while writing PDCP's header (bytes wrote = %d)\n",__FUNCTION__,bytes_wrote);
|
||||
printk("rb_id %d, Wrote %d, Header Size %d \n", pdcph.rb_id , bytes_wrote, UE_IP_PDCPH_SIZE);
|
||||
priv->stats.tx_dropped ++;
|
||||
return;
|
||||
}
|
||||
|
||||
bytes_wrote += ue_ip_netlink_send((char *)skb->data,skb->len);
|
||||
|
||||
|
||||
if (bytes_wrote != skb->len+UE_IP_PDCPH_SIZE)
|
||||
{
|
||||
printk("[UE_IP_DRV][%s] Inst %d, RB_ID %d: problem while writing PDCP's data, bytes_wrote = %d, Data_len %d, PDCPH_SIZE %d\n",
|
||||
__FUNCTION__,
|
||||
inst,
|
||||
pdcph.rb_id,
|
||||
bytes_wrote,
|
||||
skb->len,
|
||||
UE_IP_PDCPH_SIZE); // congestion
|
||||
|
||||
priv->stats.tx_dropped ++;
|
||||
return;
|
||||
}
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[UE_IP_DRV][%s] Sending packet of size %d to PDCP \n",__FUNCTION__,skb->len);
|
||||
|
||||
for (j=0;j<skb->len;j++)
|
||||
printk("%2x ",((unsigned char *)(skb->data))[j]);
|
||||
printk("\n");
|
||||
#endif
|
||||
|
||||
priv->stats.tx_bytes += skb->len;
|
||||
priv->stats.tx_packets ++;
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[UE_IP_DRV][%s] end \n",__FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void ue_ip_common_wireless2ip(struct nlmsghdr *nlh) {
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
struct pdcp_data_ind_header_t *pdcph = (struct pdcp_data_ind_header_t *)NLMSG_DATA(nlh);
|
||||
struct ue_ip_priv *priv;
|
||||
|
||||
priv = netdev_priv(ue_ip_dev[pdcph->inst]);
|
||||
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[UE_IP_DRV][%s] QOS receive from PDCP, size %d, rab %d, inst %d\n",__FUNCTION__,
|
||||
pdcph->data_size,pdcph->rb_id,pdcph->inst);
|
||||
#endif
|
||||
|
||||
ue_ip_common_class_wireless2ip(pdcph->data_size,
|
||||
(unsigned char *)NLMSG_DATA(nlh) + UE_IP_PDCPH_SIZE,
|
||||
pdcph->inst,
|
||||
pdcph->rb_id);
|
||||
|
||||
}
|
||||
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
/*******************************************************************************
|
||||
|
||||
Eurecom OpenAirInterface 2
|
||||
Copyright(c) 1999 - 2010 Eurecom
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms and conditions of the GNU General Public License,
|
||||
version 2, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope 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.,
|
||||
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in
|
||||
the file called "COPYING".
|
||||
|
||||
Contact Information
|
||||
Openair Admin: openair_admin@eurecom.fr
|
||||
Openair Tech : openair_tech@eurecom.fr
|
||||
Forums : http://forums.eurecom.fsr/openairinterface
|
||||
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#ifndef _UE_IP_CST
|
||||
#define _UE_IP_CST
|
||||
|
||||
#define UE_IP_MAX_LENGTH 180
|
||||
|
||||
// General Constants
|
||||
#define UE_IP_MTU 1500
|
||||
#define UE_IP_TX_QUEUE_LEN 100
|
||||
#define UE_IP_ADDR_LEN 8
|
||||
#define UE_IP_INET6_ADDRSTRLEN 46
|
||||
#define UE_IP_INET_ADDRSTRLEN 16
|
||||
#define UE_IP_DEFAULT_RAB_ID 5
|
||||
|
||||
#define UE_IP_RESET_RX_FLAGS 0
|
||||
|
||||
|
||||
#define UE_IP_RETRY_LIMIT_DEFAULT 5
|
||||
|
||||
#define UE_IP_MESSAGE_MAXLEN 5004
|
||||
|
||||
#define UE_IP_TIMER_ESTABLISHMENT_DEFAULT 12
|
||||
#define UE_IP_TIMER_RELEASE_DEFAULT 2
|
||||
#define UE_IP_TIMER_IDLE UINT_MAX
|
||||
#define UE_IP_TIMER_TICK HZ
|
||||
|
||||
#define UE_IP_PDCPH_SIZE sizeof(struct pdcp_data_req_header_t)
|
||||
#define UE_IP_IPV4_SIZE 20
|
||||
#define UE_IP_IPV6_SIZE 40
|
||||
|
||||
|
||||
|
||||
|
||||
#define UE_IP_NB_INSTANCES_MAX 8
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+403
@@ -0,0 +1,403 @@
|
||||
/*******************************************************************************
|
||||
|
||||
Eurecom OpenAirInterface 2
|
||||
Copyright(c) 1999 - 2010 Eurecom
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms and conditions of the GNU General Public License,
|
||||
version 2, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope 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.,
|
||||
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in
|
||||
the file called "COPYING".
|
||||
|
||||
Contact Information
|
||||
Openair Admin: openair_admin@eurecom.fr
|
||||
Openair Tech : openair_tech@eurecom.fr
|
||||
Forums : http://forums.eurecom.fsr/openairinterface
|
||||
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
/*! \file device.c
|
||||
* \brief Networking Device Driver for OpenAirInterface
|
||||
* \author navid.nikaein, yan.moret(no longer valid), michelle.wetterwald(no longer valid), raymond.knopp, Lionel Gauthier
|
||||
* \company Eurecom
|
||||
* \email: raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr
|
||||
|
||||
*/
|
||||
/*******************************************************************************/
|
||||
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
#ifdef RTAI
|
||||
#include "rtai_posix.h"
|
||||
#define RTAI_IRQ 30 //try to get this irq with RTAI
|
||||
#endif // RTAI
|
||||
#endif // OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
#include "constant.h"
|
||||
#include "local.h"
|
||||
#include "proto_extern.h"
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/bitops.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/segment.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/delay.h>
|
||||
#include <asm/unistd.h>
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
|
||||
|
||||
struct net_device *ue_ip_dev[UE_IP_NB_INSTANCES_MAX];
|
||||
|
||||
#ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
extern void ue_ip_netlink_release(void);
|
||||
extern int ue_ip_netlink_init(void);
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int ue_ip_find_inst(struct net_device *dev) {
|
||||
//---------------------------------------------------------------------------
|
||||
int i;
|
||||
|
||||
for (i=0;i<UE_IP_NB_INSTANCES_MAX;i++)
|
||||
if (ue_ip_dev[i] == dev)
|
||||
return(i);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
void *ue_ip_interrupt(void){
|
||||
//---------------------------------------------------------------------------
|
||||
u8 cxi;
|
||||
|
||||
// struct ue_ip_priv *priv=netdev_priv(dev_id);
|
||||
// unsigned int flags;
|
||||
// priv->lock = SPIN_LOCK_UNLOCKED;
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_INTERRUPT
|
||||
printk("INTERRUPT - begin\n");
|
||||
#endif
|
||||
// spin_lock_irqsave(&priv->lock,flags);
|
||||
cxi=0;
|
||||
// mesh_GC_receive();
|
||||
// mesh_DC_receive(naspriv->cx+cxi);
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
ue_ip_common_wireless2ip();
|
||||
#endif
|
||||
// spin_unlock_irqrestore(&priv->lock,flags);
|
||||
#ifdef OAI_DRV_DEBUG_INTERRUPT
|
||||
printk("INTERRUPT: end\n");
|
||||
#endif
|
||||
// return 0;
|
||||
}
|
||||
#endif //NETLINK
|
||||
//---------------------------------------------------------------------------
|
||||
void ue_ip_timer(unsigned long data){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv=(struct ue_ip_priv *)data;
|
||||
spin_lock(&priv->lock);
|
||||
(priv->timer).function=ue_ip_timer;
|
||||
(priv->timer).expires=jiffies+UE_IP_TIMER_TICK;
|
||||
(priv->timer).data=data;
|
||||
add_timer(&priv->timer);
|
||||
spin_unlock(&priv->lock);
|
||||
return;
|
||||
// add_timer(&gpriv->timer);
|
||||
// spin_unlock(&gpriv->lock);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Called by ifconfig when the device is activated by ifconfig
|
||||
int ue_ip_open(struct net_device *dev){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv=netdev_priv(dev);
|
||||
|
||||
// Address has already been set at init
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
if (pdcp_2_ue_ip_irq==-EBUSY){
|
||||
printk("[UE_IP_DRV][%s] : irq failure\n", __FUNCTION__);
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif //OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
if(!netif_queue_stopped(dev))
|
||||
netif_start_queue(dev);
|
||||
else
|
||||
netif_wake_queue(dev);
|
||||
|
||||
init_timer(&priv->timer);
|
||||
(priv->timer).expires = jiffies+UE_IP_TIMER_TICK;
|
||||
(priv->timer).data = (unsigned long)priv;
|
||||
(priv->timer).function = ue_ip_timer;
|
||||
//add_timer(&priv->timer);
|
||||
|
||||
printk("[UE_IP_DRV][%s] name = %s\n", __FUNCTION__, dev->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Called by ifconfig when the device is desactivated
|
||||
int ue_ip_stop(struct net_device *dev){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv = netdev_priv(dev);
|
||||
|
||||
printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
|
||||
del_timer(&(priv->timer));
|
||||
netif_stop_queue(dev);
|
||||
// MOD_DEC_USE_COUNT;
|
||||
printk("[UE_IP_DRV][%s] End\n", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void ue_ip_teardown(struct net_device *dev){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv;
|
||||
int inst;
|
||||
|
||||
printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
|
||||
if (dev) {
|
||||
priv = netdev_priv(dev);
|
||||
inst = ue_ip_find_inst(dev);
|
||||
if ((inst<0) || (inst>=UE_IP_NB_INSTANCES_MAX)) {
|
||||
printk("[UE_IP_DRV][%s] ERROR, couldn't find instance\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
printk("[UE_IP_DRV][%s] End\n", __FUNCTION__);
|
||||
} // check dev
|
||||
else {
|
||||
printk("[UE_IP_DRV][%s] Device is null\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int ue_ip_set_config(struct net_device *dev, struct ifmap *map){
|
||||
//---------------------------------------------------------------------------
|
||||
printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
|
||||
if (dev->flags & IFF_UP)
|
||||
return -EBUSY;
|
||||
if (map->base_addr != dev->base_addr) {
|
||||
printk(KERN_WARNING "[UE_IP_DRV][%s] Can't change I/O address\n", __FUNCTION__);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
if (map->irq != dev->irq)
|
||||
dev->irq = map->irq;
|
||||
printk("[UE_IP_DRV][%s] End\n", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
int ue_ip_hard_start_xmit(struct sk_buff *skb, struct net_device *dev){
|
||||
//---------------------------------------------------------------------------
|
||||
int inst;
|
||||
|
||||
if (dev) {
|
||||
inst = ue_ip_find_inst(dev);
|
||||
} else {
|
||||
printk("[UE_IP_DRV][%s] ERROR, device is null\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((inst>=0) && (inst<UE_IP_NB_INSTANCES_MAX)) {
|
||||
#ifdef OAI_DRV_OAI_DRV_DEBUG_DEVICE
|
||||
printk("[UE_IP_DRV][%s] inst %d, begin\n", __FUNCTION__,inst);
|
||||
#endif
|
||||
|
||||
if (!skb){
|
||||
printk("[UE_IP_DRV][%s] input parameter skb is NULL\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
// End debug information
|
||||
netif_stop_queue(dev);
|
||||
dev->trans_start = jiffies;
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[UE_IP_DRV][%s] step 1\n", __FUNCTION__);
|
||||
#endif
|
||||
ue_ip_common_ip2wireless(skb,inst);
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[UE_IP_DRV][%s] step 2\n", __FUNCTION__);
|
||||
#endif
|
||||
dev_kfree_skb(skb);
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[UE_IP_DRV][%s] step 3\n", __FUNCTION__);
|
||||
#endif
|
||||
netif_wake_queue(dev);
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[UE_IP_DRV][%s] end\n", __FUNCTION__);
|
||||
#endif
|
||||
} else {
|
||||
printk("[UE_IP_DRV][%s] ERROR, couldn't find instance\n", __FUNCTION__);
|
||||
return(-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
struct net_device_stats *ue_ip_get_stats(struct net_device *dev){
|
||||
//---------------------------------------------------------------------------
|
||||
// return &((struct ue_ip_priv *)dev->priv)->stats;
|
||||
struct ue_ip_priv *priv = netdev_priv(dev);
|
||||
//printk("[UE_IP_DRV][%s]\n", __FUNCTION__);
|
||||
return &priv->stats;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int ue_ip_set_mac_address(struct net_device *dev, void *mac) {
|
||||
//---------------------------------------------------------------------------
|
||||
//struct sockaddr *addr = mac;
|
||||
printk("[UE_IP_DRV][%s] CHANGE MAC ADDRESS UNSUPPORTED\n", __FUNCTION__);
|
||||
//memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
|
||||
return 0;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int ue_ip_change_mtu(struct net_device *dev, int mtu){
|
||||
//---------------------------------------------------------------------------
|
||||
printk("[UE_IP_DRV][%s] CHANGE MTU %d bytes\n", __FUNCTION__, mtu);
|
||||
if ((mtu<50) || (mtu>1500))
|
||||
return -EINVAL;
|
||||
dev->mtu = mtu;
|
||||
return 0;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void ue_ip_change_rx_flags(struct net_device *dev, int flags){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv = netdev_priv(dev);
|
||||
printk("[UE_IP_DRV][%s] CHANGE RX FLAGS %08X\n", __FUNCTION__, flags);
|
||||
priv->rx_flags ^= flags;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void ue_ip_tx_timeout(struct net_device *dev){
|
||||
//---------------------------------------------------------------------------
|
||||
// Transmitter timeout, serious problems.
|
||||
struct ue_ip_priv *priv = netdev_priv(dev);
|
||||
|
||||
printk("[UE_IP_DRV][%s] begin\n", __FUNCTION__);
|
||||
// (struct ue_ip_priv *)(dev->priv)->stats.tx_errors++;
|
||||
(priv->stats).tx_errors++;
|
||||
dev->trans_start = jiffies;
|
||||
netif_wake_queue(dev);
|
||||
printk("[UE_IP_DRV][%s] transmit timed out %s\n", __FUNCTION__,dev->name);
|
||||
}
|
||||
|
||||
static const struct net_device_ops ue_ip_netdev_ops = {
|
||||
.ndo_open = ue_ip_open,
|
||||
.ndo_stop = ue_ip_stop,
|
||||
.ndo_start_xmit = ue_ip_hard_start_xmit,
|
||||
.ndo_validate_addr = NULL,
|
||||
.ndo_get_stats = ue_ip_get_stats,
|
||||
.ndo_set_mac_address = ue_ip_set_mac_address,
|
||||
.ndo_set_config = ue_ip_set_config,
|
||||
.ndo_do_ioctl = NULL,
|
||||
.ndo_change_mtu = ue_ip_change_mtu,
|
||||
.ndo_tx_timeout = ue_ip_tx_timeout,
|
||||
.ndo_change_rx_flags = ue_ip_change_rx_flags,
|
||||
};
|
||||
/*.ndo_set_multicast_list = NULL,*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Initialisation of the network device
|
||||
void ue_ip_init(struct net_device *dev){
|
||||
//---------------------------------------------------------------------------
|
||||
struct ue_ip_priv *priv;
|
||||
if (dev) {
|
||||
priv = netdev_priv(dev);
|
||||
memset(priv, 0, sizeof(struct ue_ip_priv));
|
||||
spin_lock_init(&priv->lock);
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2629
|
||||
dev->netdev_ops = &ue_ip_netdev_ops;
|
||||
#else
|
||||
#error "KERNEL VERSION MUST BE NEWER THAN 2.6.29"
|
||||
#endif
|
||||
dev->hard_header_len = 0;
|
||||
dev->addr_len = UE_IP_ADDR_LEN;
|
||||
dev->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP;
|
||||
dev->tx_queue_len = UE_IP_TX_QUEUE_LEN;
|
||||
dev->mtu = UE_IP_MTU;
|
||||
} else {
|
||||
printk("[UE_IP_DRV][%s] ERROR, Device is NULL!!\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int init_module (void) {
|
||||
//---------------------------------------------------------------------------
|
||||
int err,inst;
|
||||
char devicename[100];
|
||||
|
||||
|
||||
// Initialize parameters shared with RRC
|
||||
printk("[UE_IP_DRV][%s] Starting OAI IP driver", __FUNCTION__);
|
||||
|
||||
for (inst=0;inst<UE_IP_NB_INSTANCES_MAX;inst++) {
|
||||
printk("[UE_IP_DRV][%s] begin init instance %d\n", __FUNCTION__,inst);
|
||||
sprintf(devicename,"oip%d",inst);
|
||||
ue_ip_dev[inst] = alloc_netdev(sizeof(struct ue_ip_priv),devicename, ue_ip_init);
|
||||
//netif_stop_queue(ue_ip_dev[inst]);
|
||||
if (ue_ip_dev[inst] == NULL) {
|
||||
printk("[UE_IP_DRV][%s][INST %02d] alloc_netdev FAILED\n", __FUNCTION__,inst);
|
||||
} else {
|
||||
// linux/net/core/dev.c line 4767
|
||||
err= register_netdev(ue_ip_dev[inst]);
|
||||
if (err){
|
||||
printk("[UE_IP_DRV][%s] (inst %d): error %i registering device %s\n", __FUNCTION__, inst,err, ue_ip_dev[inst]->name);
|
||||
}else{
|
||||
printk("[UE_IP_DRV][%s] registering device %s, ifindex = %d\n\n", __FUNCTION__,ue_ip_dev[inst]->name, ue_ip_dev[inst]->ifindex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printk("[UE_IP_DRV][%s] NETLINK INIT\n", __FUNCTION__);
|
||||
if ((err=ue_ip_netlink_init()) == -1)
|
||||
printk("[UE_IP_DRV][%s] NETLINK failed\n", __FUNCTION__);
|
||||
|
||||
return err;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void cleanup_module(void){
|
||||
//---------------------------------------------------------------------------
|
||||
int inst;
|
||||
|
||||
printk("[UE_IP_DRV][CLEANUP]nasmesh_cleanup_module: begin\n");
|
||||
|
||||
for (inst=0;inst<UE_IP_NB_INSTANCES_MAX;inst++) {
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("nasmesh_cleanup_module: unregister and free net device instance %d\n",inst);
|
||||
#endif
|
||||
if (ue_ip_dev[inst]) {
|
||||
unregister_netdev(ue_ip_dev[inst]);
|
||||
ue_ip_teardown(ue_ip_dev[inst]);
|
||||
free_netdev(ue_ip_dev[inst]);
|
||||
}
|
||||
}
|
||||
ue_ip_netlink_release();
|
||||
printk("nasmesh_cleanup_module: end\n");
|
||||
}
|
||||
|
||||
#define DRV_NAME "ue_ip"
|
||||
#define DRV_VERSION "1.0"DRV_NAME
|
||||
#define DRV_DESCRIPTION "OPENAIR UE IP Device Driver"
|
||||
#define DRV_COPYRIGHT "-Copyright(c) GNU GPL Eurecom 2013"
|
||||
#define DRV_AUTHOR "Lionel GAUTHIER: <firstname.name@eurecom.fr>"DRV_COPYRIGHT
|
||||
|
||||
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
/*******************************************************************************
|
||||
|
||||
Eurecom OpenAirInterface 2
|
||||
Copyright(c) 1999 - 2010 Eurecom
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms and conditions of the GNU General Public License,
|
||||
version 2, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope 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.,
|
||||
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in
|
||||
the file called "COPYING".
|
||||
|
||||
Contact Information
|
||||
Openair Admin: openair_admin@eurecom.fr
|
||||
Openair Tech : openair_tech@eurecom.fr
|
||||
Forums : http://forums.eurecom.fsr/openairinterface
|
||||
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
|
||||
|
||||
*******************************************************************************/
|
||||
/***************************************************************************
|
||||
local.h - description
|
||||
-------------------
|
||||
copyright : (C) 2002 by Eurecom
|
||||
email : michelle.wetterwald@eurecom.fr(no longer valid)
|
||||
yan.moret@eurecom.fr(no longer valid)
|
||||
knopp@eurecom.fr
|
||||
gauthier@eurecom.fr
|
||||
***************************************************************************
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef UE_IP_LOCAL_H
|
||||
#define UE_IP_LOCAL_H
|
||||
|
||||
#include <linux/if_arp.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/sysctl.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/unistd.h>
|
||||
#include <asm/param.h>
|
||||
//#include <sys/sysctl.h>
|
||||
#include <linux/udp.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/icmp.h>
|
||||
#include <linux/icmpv6.h>
|
||||
#include <linux/in.h>
|
||||
#include <net/ndisc.h>
|
||||
|
||||
|
||||
|
||||
#include "constant.h"
|
||||
#include "sap.h"
|
||||
|
||||
|
||||
struct ue_ip_priv {
|
||||
int irq;
|
||||
int rx_flags;
|
||||
struct timer_list timer;
|
||||
spinlock_t lock;
|
||||
struct net_device_stats stats;
|
||||
u8 retry_limit;
|
||||
u32 timer_establishment;
|
||||
u32 timer_release;
|
||||
struct sock *nl_sk;
|
||||
u8 nlmsg[UE_IP_PRIMITIVE_MAX_LENGTH+sizeof(struct nlmsghdr)];
|
||||
u8 xbuffer[UE_IP_PRIMITIVE_MAX_LENGTH]; // transmition buffer
|
||||
u8 rbuffer[UE_IP_PRIMITIVE_MAX_LENGTH]; // reception buffer
|
||||
};
|
||||
|
||||
struct ipversion {
|
||||
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
||||
u8 reserved:4,
|
||||
version:4;
|
||||
#else
|
||||
u8 version:4,
|
||||
reserved:4;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct pdcp_data_req_header_t {
|
||||
unsigned int rb_id;
|
||||
unsigned int data_size;
|
||||
int inst;
|
||||
} pdcp_data_req_header_t;
|
||||
|
||||
typedef struct pdcp_data_ind_header_t {
|
||||
unsigned int rb_id;
|
||||
unsigned int data_size;
|
||||
int inst;
|
||||
} pdcp_data_ind_header_t;
|
||||
|
||||
|
||||
|
||||
extern struct net_device *ue_ip_dev[UE_IP_NB_INSTANCES_MAX];
|
||||
|
||||
|
||||
#endif
|
||||
Executable
+248
@@ -0,0 +1,248 @@
|
||||
/*******************************************************************************
|
||||
|
||||
Eurecom OpenAirInterface 2
|
||||
Copyright(c) 1999 - 2010 Eurecom
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms and conditions of the GNU General Public License,
|
||||
version 2, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope 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.,
|
||||
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in
|
||||
the file called "COPYING".
|
||||
|
||||
Contact Information
|
||||
Openair Admin: openair_admin@eurecom.fr
|
||||
Openair Tech : openair_tech@eurecom.fr
|
||||
Forums : http://forums.eurecom.fsr/openairinterface
|
||||
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
|
||||
|
||||
*******************************************************************************/
|
||||
/*! \file netlink.c
|
||||
* \brief establish a netlink
|
||||
* \author Raymond knopp, and Navid Nikaein, Lionel Gauthier
|
||||
* \company Eurecom
|
||||
* \email: knopp@eurecom.fr, and navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr
|
||||
*/
|
||||
|
||||
//#include <linux/config.h>
|
||||
#include <linux/socket.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <net/sock.h>
|
||||
#include <linux/kthread.h>
|
||||
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#include "local.h"
|
||||
#include "proto_extern.h"
|
||||
|
||||
//#define NETLINK_DEBUG 1
|
||||
|
||||
|
||||
#define NAS_NETLINK_ID 31
|
||||
#define NL_DEST_PID 1
|
||||
|
||||
|
||||
static struct sock *nas_nl_sk = NULL;
|
||||
static int exit_netlink_thread=0;
|
||||
static int nas_netlink_rx_thread(void *);
|
||||
|
||||
|
||||
static DEFINE_MUTEX(nasmesh_mutex);
|
||||
|
||||
static inline void nasmesh_lock(void)
|
||||
{
|
||||
mutex_lock(&nasmesh_mutex);
|
||||
}
|
||||
|
||||
static inline void nasmesh_unlock(void)
|
||||
{
|
||||
mutex_unlock(&nasmesh_mutex);
|
||||
}
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2629
|
||||
// This can also be implemented using thread to get the data from PDCP without blocking.
|
||||
static void nas_nl_data_ready (struct sk_buff *skb)
|
||||
{
|
||||
// wake_up_interruptible(skb->sk->sk_sleep);
|
||||
//nasmesh_lock();
|
||||
//netlink_rcv_skb(skb, &my_rcv_msg);// my_rcv_msg is the call back func>
|
||||
//nasmesh_unlock();
|
||||
|
||||
struct nlmsghdr *nlh = NULL;
|
||||
if (skb) {
|
||||
#ifdef NETLINK_DEBUG
|
||||
printk("[UE_IP_DRV][NETLINK] Received socket from PDCP\n");
|
||||
#endif //NETLINK_DEBUG
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
ue_ip_common_wireless2ip(nlh);
|
||||
//kfree_skb(skb); // not required,
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
static struct task_struct *netlink_rx_thread;
|
||||
|
||||
// this thread is used to avoid blocking other system calls from entering the kernel
|
||||
static int nas_netlink_rx_thread(void *data) {
|
||||
|
||||
int err;
|
||||
struct sk_buff *skb = NULL;
|
||||
struct nlmsghdr *nlh = NULL;
|
||||
|
||||
printk("[UE_IP_DRV][NETLINK] Starting RX Thread \n");
|
||||
|
||||
while (!kthread_should_stop()) {
|
||||
|
||||
if (nas_nl_sk) {
|
||||
skb = skb_recv_datagram(nas_nl_sk, 0, 0, &err);
|
||||
|
||||
if (skb) {
|
||||
|
||||
#ifdef NETLINK_DEBUG
|
||||
printk("[UE_IP_DRV][NETLINK] Received socket from PDCP\n");
|
||||
#endif //NETLINK_DEBUG
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
|
||||
nas_COMMON_QOS_receive(nlh);
|
||||
|
||||
skb_free_datagram(nas_nl_sk,skb);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
if (exit_netlink_thread == 1) {
|
||||
printk("[UE_IP_DRV][NETLINK] exit_netlink_thread\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // while
|
||||
|
||||
printk("[UE_IP_DRV][NETLINK] Exiting RX thread\n");
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
static void nas_nl_data_ready (struct sock *sk, int len)
|
||||
|
||||
{
|
||||
wake_up_interruptible(sk->sk_sleep);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int ue_ip_netlink_init(void)
|
||||
{
|
||||
|
||||
printk("[UE_IP_DRV][NETLINK] Running init ...\n");
|
||||
|
||||
|
||||
nas_nl_sk = netlink_kernel_create(
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
&init_net,
|
||||
#endif
|
||||
NAS_NETLINK_ID,
|
||||
0,
|
||||
nas_nl_data_ready,
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2622
|
||||
&nasmesh_mutex, // NULL
|
||||
#endif
|
||||
THIS_MODULE);
|
||||
|
||||
|
||||
if (nas_nl_sk == NULL) {
|
||||
|
||||
printk("[UE_IP_DRV][NETLINK] netlink_kernel_create failed \n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2629
|
||||
|
||||
#else
|
||||
// Create receive thread
|
||||
netlink_rx_thread = kthread_run(nas_netlink_rx_thread, NULL, "NAS_NETLINK_RX_THREAD");
|
||||
#endif
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ue_ip_netlink_release(void) {
|
||||
|
||||
exit_netlink_thread=1;
|
||||
printk("[UE_IP_DRV][NETLINK] Releasing netlink socket\n");
|
||||
|
||||
if(nas_nl_sk){
|
||||
#ifdef KERNEL_VERSION_GREATER_THAN_2629
|
||||
netlink_kernel_release(nas_nl_sk); //or skb->sk
|
||||
#else
|
||||
sock_release(nas_nl_sk->sk_socket);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// printk("[UE_IP_DRV][NETLINK] Removing netlink_rx_thread\n");
|
||||
//kthread_stop(netlink_rx_thread);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ue_ip_netlink_send(unsigned char *data,unsigned int len) {
|
||||
|
||||
|
||||
struct sk_buff *nl_skb = alloc_skb(NLMSG_SPACE(len),GFP_ATOMIC);
|
||||
struct nlmsghdr *nlh = (struct nlmsghdr *)nl_skb->data;
|
||||
int status;
|
||||
|
||||
|
||||
// printk("[UE_IP_DRV][NETLINK] Sending %d bytes (%d)\n",len,NLMSG_SPACE(len));
|
||||
skb_put(nl_skb, NLMSG_SPACE(len));
|
||||
memcpy(NLMSG_DATA(nlh),data,len);
|
||||
|
||||
nlh->nlmsg_len = NLMSG_SPACE(len);
|
||||
|
||||
|
||||
nlh->nlmsg_pid = 0; /* from kernel */
|
||||
|
||||
NETLINK_CB(nl_skb).pid = 0;
|
||||
|
||||
#ifdef NETLINK_DEBUG
|
||||
printk("[UE_IP_DRV][NETLINK] In nas_netlink_send, nl_skb %p, nl_sk %x, nlh %p, nlh->nlmsg_len %d\n",nl_skb,nas_nl_sk,nlh,nlh->nlmsg_len);
|
||||
#endif //DEBUG_NETLINK
|
||||
|
||||
if (nas_nl_sk) {
|
||||
|
||||
// nasmesh_lock();
|
||||
status = netlink_unicast(nas_nl_sk, nl_skb, NL_DEST_PID, MSG_DONTWAIT);
|
||||
// mutex_unlock(&nasmesh_mutex);
|
||||
|
||||
if (status < 0) {
|
||||
printk("[UE_IP_DRV][NETLINK] SEND status is %d\n",status);
|
||||
return(0);
|
||||
}
|
||||
else {
|
||||
#ifdef NETLINK_DEBUG
|
||||
printk("[UE_IP_DRV][NETLINK] SEND status is %d\n",status);
|
||||
#endif
|
||||
return len;
|
||||
}
|
||||
}
|
||||
else {
|
||||
printk("[UE_IP_DRV][SEND] socket is NULL\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
Executable
+148
@@ -0,0 +1,148 @@
|
||||
/*******************************************************************************
|
||||
|
||||
Eurecom OpenAirInterface 2
|
||||
Copyright(c) 1999 - 2010 Eurecom
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms and conditions of the GNU General Public License,
|
||||
version 2, as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope 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.,
|
||||
51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in
|
||||
the file called "COPYING".
|
||||
|
||||
Contact Information
|
||||
Openair Admin: openair_admin@eurecom.fr
|
||||
Openair Tech : openair_tech@eurecom.fr
|
||||
Forums : http://forums.eurecom.fsr/openairinterface
|
||||
Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France
|
||||
|
||||
*******************************************************************************/
|
||||
/***************************************************************************
|
||||
proto_extern.h - description
|
||||
-------------------
|
||||
copyright : (C) 2002 by Eurecom
|
||||
email : michelle.wetterwald@eurecom.fr(no longer valid)
|
||||
yan.moret@eurecom.fr(no longer valid)
|
||||
knopp@eurecom.fr
|
||||
gauthier@eurecom.fr
|
||||
***************************************************************************
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _UE_IP_PROTO_H
|
||||
#define _UE_IP_PROTO_H
|
||||
|
||||
#include <linux/if_arp.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/ipv6.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/sysctl.h>
|
||||
#include <linux/timer.h>
|
||||
#include <asm/param.h>
|
||||
//#include <sys/sysctl.h>
|
||||
#include <linux/udp.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/icmp.h>
|
||||
#include <linux/icmpv6.h>
|
||||
#include <linux/in.h>
|
||||
#include <net/ndisc.h>
|
||||
|
||||
#include "local.h"
|
||||
|
||||
// device.c
|
||||
|
||||
|
||||
/** @defgroup _ue_ip_impl_ OAI Network Device for RRC Lite
|
||||
* @ingroup _ref_implementation_
|
||||
* @{
|
||||
\fn int ue_ip_find_inst(struct net_device *dev)
|
||||
\brief This function determines the instance id for a particular device pointer.
|
||||
@param dev Pointer to net_device structure
|
||||
*/
|
||||
int ue_ip_find_inst(struct net_device *dev);
|
||||
|
||||
// common.c
|
||||
/**
|
||||
\fn void ue_ip_common_class_wireless2ip(unsigned short dlen, void* pdcp_sdu,int inst,struct classifier_entity *rclass,OaiNwDrvRadioBearerId_t rb_id)
|
||||
\brief Receive classified LTE packet, build skbuff struct with it and deliver it to the OS network layer.
|
||||
@param dlen Length of SDU in bytes
|
||||
@param pdcp_sdu Pointer to received SDU
|
||||
@param inst Instance number
|
||||
@param rb_id Radio Bearer Id
|
||||
*/
|
||||
void ue_ip_common_class_wireless2ip(unsigned short dlen,
|
||||
void *pdcp_sdu,
|
||||
int inst,
|
||||
OaiNwDrvRadioBearerId_t rb_id);
|
||||
|
||||
/**
|
||||
\fn void ue_ip_common_ip2wireless(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst)
|
||||
\brief Request the transfer of data (QoS SAP)
|
||||
@param skb pointer to socket buffer
|
||||
@param inst device instance
|
||||
*/
|
||||
void ue_ip_common_ip2wireless(struct sk_buff *skb, int inst);
|
||||
|
||||
/**
|
||||
\fn void ue_ip_common_ip2wireless_drop(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst)
|
||||
\brief Drop the IP packet comming from the OS network layer.
|
||||
@param skb pointer to socket buffer
|
||||
@param inst device instance
|
||||
*/
|
||||
void ue_ip_common_ip2wireless_drop(struct sk_buff *skb, int inst);
|
||||
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
/**
|
||||
\fn void ue_ip_common_wireless2ip()
|
||||
\brief Retrieve PDU from PDCP through RT-fifos for delivery to the IP stack.
|
||||
*/
|
||||
void ue_ip_common_wireless2ip(void);
|
||||
#else
|
||||
/**
|
||||
\fn void ue_ip_common_wireless2ip(struct nlmsghdr *nlh)
|
||||
\brief Retrieve PDU from PDCP through netlink sockets for delivery to the IP stack.
|
||||
*/
|
||||
void ue_ip_common_wireless2ip(struct nlmsghdr *nlh);
|
||||
#endif //OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
|
||||
#ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
/**
|
||||
\fn int ue_ip_netlink_send(unsigned char *data,unsigned int len)
|
||||
\brief Request the transfer of data by PDCP via netlink socket
|
||||
@param data pointer to SDU
|
||||
@param len length of SDU in bytes
|
||||
@returns Numeber of bytes transfered by netlink socket
|
||||
*/
|
||||
int ue_ip_netlink_send(unsigned char *data,unsigned int len);
|
||||
|
||||
/**
|
||||
\fn void ue_ip_COMMON_QOS_receive(struct nlmsghdr *nlh)
|
||||
\brief Request a PDU from PDCP
|
||||
@param nlh pointer to netlink message header
|
||||
*/
|
||||
void ue_ip_COMMON_QOS_receive(struct nlmsghdr *nlh);
|
||||
|
||||
#endif //OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
|
||||
// netlink.c
|
||||
|
||||
void ue_ip_netlink_release(void);
|
||||
int ue_ip_netlink_init(void);
|
||||
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#ifndef UE_IP_SAP_H
|
||||
#define UE_IP_SAP_H
|
||||
typedef unsigned short OaiNwDrvRadioBearerId_t;
|
||||
|
||||
#define UE_IP_PRIMITIVE_MAX_LENGTH 180 // maximum length of a NAS primitive
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user