Move {LITE,MESH} NETWORK DRIVERS FROM openair2/NAS/DRIVER to openair2/NETWORK_DRIVER
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7150 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. 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
|
||||
them 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 prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. 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.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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 that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
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
|
||||
state 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program 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, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU 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 Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
# NASMESH Driver makefile
|
||||
#
|
||||
include $(OPENAIR_DIR)/common/utils/Makefile.inc
|
||||
NAS_UPDIR := $(shell /bin/pwd)
|
||||
|
||||
####################################################
|
||||
# NASMESH compilation flags
|
||||
####################################################
|
||||
#RTAI=1
|
||||
|
||||
####################################################
|
||||
# D E B U G F L A G S
|
||||
####################################################
|
||||
|
||||
####################################################
|
||||
# EXTRA COMPILER FLAGS
|
||||
####################################################
|
||||
#EXTRA_CFLAGS = -fno-common -fno-stack-protector -mpreferred-stack-boundary=4 $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,)
|
||||
EXTRA_CFLAGS += -I$(OPENAIR2_DIR)
|
||||
ifdef PDCP_USE_NETLINK
|
||||
EXTRA_CFLAGS += -DPDCP_USE_NETLINK
|
||||
else
|
||||
EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall
|
||||
endif
|
||||
|
||||
ifdef LOOPBACK
|
||||
EXTRA_CFLAGS += -DLOOPBACK_TEST
|
||||
endif
|
||||
|
||||
ifdef ADDRESS_FIX
|
||||
EXTRA_CFLAGS += -DNAS_ADDRESS_FIX
|
||||
endif
|
||||
ifdef NAS_DEBUG_RECEIVE
|
||||
EXTRA_CFLAGS += -DNAS_DEBUG_RECEIVE
|
||||
endif
|
||||
|
||||
ifdef NAS_DEBUG_SEND
|
||||
EXTRA_CFLAGS += -DNAS_DEBUG_SEND
|
||||
endif
|
||||
|
||||
ccflags-y := $(CFLAGS) $(EXTRA_CFLAGS)
|
||||
CFLAGS=
|
||||
|
||||
####################################################
|
||||
# LOADABLE MODULE GOALS
|
||||
####################################################
|
||||
obj-m += nasmesh.o
|
||||
nasmesh-objs += device.o
|
||||
nasmesh-objs += common.o
|
||||
nasmesh-objs += ioctl.o
|
||||
nasmesh-objs += classifier.o
|
||||
nasmesh-objs += tool.o
|
||||
nasmesh-objs += mesh.o
|
||||
ifdef PDCP_USE_NETLINK
|
||||
nasmesh-objs += netlink.o
|
||||
endif
|
||||
|
||||
####################################################
|
||||
# REVOIR LE CLEAN
|
||||
####################################################
|
||||
|
||||
#netlink.ko:
|
||||
# make PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules
|
||||
|
||||
#nasmesh.ko:
|
||||
# make V=1 -C $(KERNEL_DIR) M=`pwd` modules
|
||||
|
||||
clean:
|
||||
rm -f $(nasmesh-objs) $(obj-m)
|
||||
# make -C $(KERNEL_DIR) modules
|
||||
@@ -0,0 +1,12 @@
|
||||
CC = gcc
|
||||
|
||||
NAS_DIR = ..
|
||||
|
||||
|
||||
rb_tool: rb_tool.c
|
||||
$(CC) rb_tool.c -o rb_tool -I../../../mac/openair_wireless3g4free/openair_rrc/include -I../ -g -ggdb
|
||||
|
||||
all: rb_tool
|
||||
|
||||
clean:
|
||||
rm -f rb_tool
|
||||
@@ -0,0 +1,452 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
/***************************************************************************
|
||||
rb_tool.c - User-space utility for driving NASMESH IOCTL interface
|
||||
-------------------
|
||||
copyright : (C) 2008 by Eurecom
|
||||
email : raymond.knopp@eurecom.fr and navid.nikaein@eurecom.fr
|
||||
***************************************************************************
|
||||
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
//
|
||||
|
||||
//#include "ral_cdma_variables.h"
|
||||
//#include "ral_cdma_proto.h"
|
||||
|
||||
#include "rrc_nas_primitives.h"
|
||||
#include "ioctl.h"
|
||||
#include "constant.h"
|
||||
|
||||
//#include "nasmt_constant.h"
|
||||
//#include "nasmt_iocontrol.h"
|
||||
|
||||
|
||||
|
||||
// Global variables
|
||||
//int sd_graal;
|
||||
int fd;
|
||||
//char myIPAddr[16]; // local IP Address
|
||||
//int meas_counter;
|
||||
//struct ralu_priv ru_priv;
|
||||
//struct ralu_priv *ralupriv;
|
||||
//ioctl
|
||||
char dummy_buffer[1024];
|
||||
struct nas_ioctl gifr;
|
||||
//int wait_start_nas;
|
||||
|
||||
/*
|
||||
//---------------------------------------------------------------------------
|
||||
int NAS_RALconnect(void)
|
||||
//---------------------------------------------------------------------------
|
||||
{
|
||||
struct sockaddr_un remote;
|
||||
int len,s;
|
||||
|
||||
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
|
||||
perror("NAS_RALconnect - socket");
|
||||
exit(1);
|
||||
}
|
||||
//
|
||||
printf("Trying to connect to NAS ...\n");
|
||||
remote.sun_family = AF_UNIX;
|
||||
strcpy(remote.sun_path, SOCKET_RAL_TD_CDMA_NAME);
|
||||
len = strlen(remote.sun_path) + sizeof(remote.sun_family);
|
||||
|
||||
while (wait_start_graal){
|
||||
if (connect(s, (struct sockaddr *)&remote, len) == -1) {
|
||||
perror("NAS_RALconnect - waiting for connection - ");
|
||||
// exit(1);
|
||||
wait_start_graal = 1;
|
||||
sleep(5);
|
||||
} else {
|
||||
wait_start_graal =0;
|
||||
printf("RAL connected to NAS.\n");
|
||||
}
|
||||
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void IAL_NAS_ioctl_init(int inst)
|
||||
//---------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
struct nas_msg_statistic_reply *msgrep;
|
||||
int err,rc;
|
||||
|
||||
sprintf(gifr.name, "oai%d",inst);
|
||||
|
||||
// Get an UDP IPv6 socket ??
|
||||
fd=socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
|
||||
if (fd<0) {
|
||||
printf("Error opening socket\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sprintf(gifr.name, "oai%d",inst);
|
||||
|
||||
gifr.type = NAS_MSG_STATISTIC_REQUEST;
|
||||
memset ((void *)dummy_buffer,0,800);
|
||||
gifr.msg= &(dummy_buffer[0]);
|
||||
msgrep=(struct nas_msg_statistic_reply *)(gifr.msg);
|
||||
printf("ioctl :Statistics requested\n");
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
if (err<0) {
|
||||
printf("IOCTL error, err=%d\n",err);
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
printf("tx_packets = %u, rx_packets = %u\n", msgrep->tx_packets, msgrep->rx_packets);
|
||||
printf("tx_bytes = %u, rx_bytes = %u\n", msgrep->tx_bytes, msgrep->rx_bytes);
|
||||
printf("tx_errors = %u, rx_errors = %u\n", msgrep->tx_errors, msgrep->rx_errors);
|
||||
printf("tx_dropped = %u, rx_dropped = %u\n", msgrep->tx_dropped, msgrep->rx_dropped);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#define ADD_RB 0
|
||||
#define DEL_RB 1
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int main(int argc,char **argv)
|
||||
//---------------------------------------------------------------------------
|
||||
{
|
||||
int done, rc, meas_polling_counter;
|
||||
fd_set readfds;
|
||||
struct timeval tv;
|
||||
int i;
|
||||
int err;
|
||||
char * buffer;
|
||||
int c;
|
||||
int action,rbset=0,cxset=0,instset=0,saddr_ipv4set=0,saddr_ipv6set=0,daddr_ipv4set=0,daddr_ipv6set=0,dscpset=0,mpls_outlabelset=0,mpls_inlabelset;
|
||||
char rb[100],cx[100],dscp[100],inst[100],mpls_outgoinglabel[100],mpls_incominglabel[100];
|
||||
int index;
|
||||
struct nas_msg_rb_establishment_request *msgreq;
|
||||
struct nas_msg_class_add_request *msgreq_class;
|
||||
in_addr_t saddr_ipv4,daddr_ipv4;
|
||||
struct in6_addr saddr_ipv6,daddr_ipv6;
|
||||
unsigned int mpls_outlabel,mpls_inlabel;
|
||||
|
||||
char addr_str[46];
|
||||
|
||||
|
||||
|
||||
// scan options
|
||||
rb[0] = '\0';
|
||||
cx[0] = '\0';
|
||||
dscp[0] = '\0';
|
||||
mpls_incominglabel[0] = '\0';
|
||||
mpls_outgoinglabel[0] = '\0';
|
||||
|
||||
while ((c = getopt (argc, argv, "adr:i:c:l:m:s:t:x:y:z:")) != -1)
|
||||
switch (c) {
|
||||
case 'a':
|
||||
action = ADD_RB;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
action = DEL_RB;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
strcpy(rb,optarg);
|
||||
rbset = 1;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
strcpy(inst,optarg);
|
||||
instset = 1;
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
strcpy(cx,optarg);
|
||||
cxset = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
strcpy(mpls_outgoinglabel,optarg);
|
||||
mpls_outlabelset=1;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
strcpy(mpls_incominglabel,optarg);
|
||||
mpls_inlabelset=1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
inet_aton(optarg,&saddr_ipv4);
|
||||
saddr_ipv4set = 1;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
inet_aton(optarg,&daddr_ipv4);
|
||||
daddr_ipv4set = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
printf("IPv6: %s\n",optarg);
|
||||
inet_pton(AF_INET6,optarg,(void *)&saddr_ipv6);
|
||||
saddr_ipv6set = 1;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
inet_pton(AF_INET6,optarg,(void *)&daddr_ipv6);
|
||||
daddr_ipv6set = 1;
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
dscpset=1;
|
||||
strcpy(dscp,optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
if (isprint (optopt))
|
||||
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
|
||||
else
|
||||
fprintf (stderr,
|
||||
"Unknown option character `\\x%x'.\n",
|
||||
optopt);
|
||||
|
||||
return 1;
|
||||
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
|
||||
|
||||
printf ("action = %d, rb = %s,cx = %s\n", action, rb, cx);
|
||||
|
||||
|
||||
if (rbset==0) {
|
||||
printf("ERROR: Specify a RAB id!!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (cxset==0) {
|
||||
printf("ERROR: Specify an LCR !!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (instset==0) {
|
||||
printf("ERROR: Specify an interface !!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ((mpls_outlabelset == 0) && (saddr_ipv4set==0) && (saddr_ipv6set==0)) {
|
||||
printf("ERROR: Specify a source IP address\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ((mpls_outlabelset == 0) && (daddr_ipv4set==0) && (daddr_ipv6set==0)) {
|
||||
printf("ERROR: Specify a destination IP address\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ((mpls_outlabelset == 1) && (mpls_inlabelset == 0)) {
|
||||
printf("ERROR: Specify an incoming MPLS label\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ((mpls_inlabelset == 1) && (mpls_outlabelset == 0)) {
|
||||
printf("ERROR: Specify an outgoing MPLS label\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
IAL_NAS_ioctl_init(atoi(inst));
|
||||
|
||||
msgreq = (struct nas_msg_rb_establishment_request *)(gifr.msg);
|
||||
msgreq->rab_id = atoi(rb);
|
||||
msgreq->lcr = atoi(cx);
|
||||
msgreq->qos = 0;
|
||||
|
||||
|
||||
if (action == ADD_RB) {
|
||||
gifr.type = NAS_MSG_RB_ESTABLISHMENT_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
|
||||
|
||||
if (saddr_ipv4set == 1) {
|
||||
msgreq_class = (struct nas_msg_class_add_request *)(gifr.msg);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->version = 4;
|
||||
|
||||
msgreq_class->classref = 0 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir = NAS_DIRECTION_SEND;
|
||||
msgreq_class->fct = NAS_FCT_QOS_SEND;
|
||||
msgreq_class->saddr.ipv4 = saddr_ipv4;
|
||||
msgreq_class->daddr.ipv4 = daddr_ipv4;
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = NAS_PROTOCOL_DEFAULT;
|
||||
|
||||
if (dscpset==0)
|
||||
msgreq_class->dscp=0;
|
||||
else
|
||||
msgreq_class->dscp=atoi(dscp);
|
||||
|
||||
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
|
||||
msgreq_class->classref = 1+(msgreq_class->lcr<<3);
|
||||
msgreq_class->dir = NAS_DIRECTION_RECEIVE;
|
||||
|
||||
|
||||
msgreq_class->daddr.ipv4 = saddr_ipv4;
|
||||
msgreq_class->saddr.ipv4 = daddr_ipv4;
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
}
|
||||
|
||||
if (saddr_ipv6set == 1) {
|
||||
msgreq_class = (struct nas_msg_class_add_request *)(gifr.msg);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->version = 6;
|
||||
|
||||
if (dscpset==0)
|
||||
msgreq_class->dscp=0;
|
||||
else
|
||||
msgreq_class->dscp=atoi(dscp);
|
||||
|
||||
msgreq_class->classref = 2+(msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=NAS_DIRECTION_SEND;
|
||||
msgreq_class->fct=NAS_FCT_QOS_SEND;
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = NAS_PROTOCOL_DEFAULT;
|
||||
|
||||
memcpy(&msgreq_class->saddr.ipv6,&saddr_ipv6,16);
|
||||
memcpy(&msgreq_class->daddr.ipv6,&daddr_ipv6,16);
|
||||
|
||||
inet_ntop(AF_INET6,(void *)&saddr_ipv6,addr_str,46);
|
||||
printf("IPV6: Source %s\n",addr_str);
|
||||
inet_ntop(AF_INET6,(void *)&daddr_ipv6,addr_str,46);
|
||||
printf("IPV6: Dest %s\n",addr_str);
|
||||
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
|
||||
msgreq_class->classref = 3+(msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=NAS_DIRECTION_RECEIVE;
|
||||
memcpy(&msgreq_class->daddr.ipv6,&saddr_ipv6,16);
|
||||
memcpy(&msgreq_class->saddr.ipv6,&daddr_ipv6,16);
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (mpls_inlabelset == 1) {
|
||||
|
||||
msgreq_class = (struct nas_msg_class_add_request *)(gifr.msg);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->version = NAS_MPLS_VERSION_CODE;
|
||||
|
||||
if (dscpset==0)
|
||||
msgreq_class->dscp=0;
|
||||
else
|
||||
msgreq_class->dscp=atoi(dscp);
|
||||
|
||||
msgreq_class->classref = 4 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=NAS_DIRECTION_SEND;
|
||||
msgreq_class->fct=NAS_FCT_QOS_SEND;
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = NAS_PROTOCOL_DEFAULT;
|
||||
|
||||
mpls_outlabel = atoi(mpls_outgoinglabel);
|
||||
|
||||
printf("Setting MPLS outlabel %d with exp %d\n",mpls_outlabel,msgreq_class->dscp);
|
||||
|
||||
msgreq_class->daddr.mpls_label = mpls_outlabel;
|
||||
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
|
||||
msgreq_class->classref = 5 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=NAS_DIRECTION_RECEIVE;
|
||||
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = NAS_PROTOCOL_DEFAULT;
|
||||
|
||||
mpls_inlabel = atoi(mpls_incominglabel);
|
||||
|
||||
printf("Setting MPLS inlabel %d with exp %d\n",mpls_inlabel,msgreq_class->dscp);
|
||||
|
||||
msgreq_class->daddr.mpls_label = mpls_inlabel;
|
||||
|
||||
gifr.type = NAS_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
|
||||
|
||||
}
|
||||
} else if (action == DEL_RB) {
|
||||
gifr.type = NAS_MSG_RB_RELEASE_REQUEST;
|
||||
err=ioctl(fd, NAS_IOCTL_RRM, &gifr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
typedef unsigned int sdu_size_t;
|
||||
typedef unsigned int rb_id_t;
|
||||
|
||||
typedef struct pdcp_data_req_header_t {
|
||||
rb_id_t rb_id;
|
||||
sdu_size_t data_size;
|
||||
int inst;
|
||||
} pdcp_data_req_header_t;
|
||||
|
||||
typedef struct pdcp_data_ind_header_t {
|
||||
rb_id_t rb_id;
|
||||
sdu_size_t data_size;
|
||||
int inst;
|
||||
} pdcp_data_ind_header_t;
|
||||
|
||||
#define MAX_PAYLOAD 1024 /* maximum payload size*/
|
||||
struct sockaddr_nl src_addr, dest_addr;
|
||||
struct nlmsghdr *nlh = NULL;
|
||||
struct iovec iov;
|
||||
int sock_fd;
|
||||
struct msghdr msg;
|
||||
|
||||
|
||||
void foo( int sig )
|
||||
{
|
||||
|
||||
printf("I got cntl-C, closing socket\n");
|
||||
|
||||
|
||||
close(sock_fd);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
#define OAI_IP_DRIVER_NETLINK_ID 31
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
|
||||
struct sigaction newaction;
|
||||
int i=0;
|
||||
int ret;
|
||||
int len;
|
||||
|
||||
newaction.sa_handler = foo;
|
||||
|
||||
if ( sigaction( SIGINT, &newaction, NULL ) == -1)
|
||||
perror("Could not install the new signal handler");
|
||||
|
||||
sock_fd = socket(PF_NETLINK, SOCK_RAW,OAI_IP_DRIVER_NETLINK_ID);
|
||||
|
||||
printf("Opened socket with fd %d\n",sock_fd);
|
||||
|
||||
ret = fcntl(sock_fd,F_SETFL,O_NONBLOCK);
|
||||
printf("fcntl returns %d\n",ret);
|
||||
|
||||
memset(&src_addr, 0, sizeof(src_addr));
|
||||
src_addr.nl_family = AF_NETLINK;
|
||||
src_addr.nl_pid = 1;//getpid(); /* self pid */
|
||||
src_addr.nl_groups = 0; /* not in mcast groups */
|
||||
ret = bind(sock_fd, (struct sockaddr*)&src_addr,
|
||||
sizeof(src_addr));
|
||||
printf("bind returns %d\n",ret);
|
||||
|
||||
memset(&dest_addr, 0, sizeof(dest_addr));
|
||||
dest_addr.nl_family = AF_NETLINK;
|
||||
dest_addr.nl_pid = 0; /* For Linux Kernel */
|
||||
dest_addr.nl_groups = 0; /* unicast */
|
||||
|
||||
nlh=(struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD));
|
||||
/* Fill the netlink message header */
|
||||
nlh->nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD);
|
||||
nlh->nlmsg_pid = 1;//getpid(); /* self pid */
|
||||
nlh->nlmsg_flags = 0;
|
||||
|
||||
iov.iov_base = (void *)nlh;
|
||||
iov.iov_len = nlh->nlmsg_len;
|
||||
memset(&msg,0,sizeof(msg));
|
||||
msg.msg_name = (void *)&dest_addr;
|
||||
msg.msg_namelen = sizeof(dest_addr);
|
||||
msg.msg_iov = &iov;
|
||||
msg.msg_iovlen = 1;
|
||||
|
||||
|
||||
/* Read message from kernel */
|
||||
memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));
|
||||
|
||||
while (1) {
|
||||
len = recvmsg(sock_fd, &msg, 0);
|
||||
|
||||
|
||||
if (len<0) {
|
||||
|
||||
// exit(-1);
|
||||
} else {
|
||||
printf("Received socket with length %d (nlmsg_len = %d)\n",len,nlh->nlmsg_len);
|
||||
}
|
||||
|
||||
usleep(1000);
|
||||
i=i+1;
|
||||
|
||||
if ((i % 100) == 0)
|
||||
printf("%d\n",i);
|
||||
|
||||
/*
|
||||
for (i=0;i<nlh->nlmsg_len - sizeof(struct nlmsghdr);i++) {
|
||||
printf("%x ",
|
||||
((unsigned char *)NLMSG_DATA(nlh))[i]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* Close Netlink Socket */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+828
@@ -0,0 +1,828 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
/*! \file classifier.c
|
||||
* \brief Classify IP packets
|
||||
* \author Navid Nikaein, Lionel GAUTHIER, Raymond knopp
|
||||
* \company Eurecom
|
||||
* \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr, knopp@eurecom.fr
|
||||
*/
|
||||
|
||||
|
||||
#include "local.h"
|
||||
#include "proto_extern.h"
|
||||
|
||||
#include <net/ip6_fib.h>
|
||||
#include <net/route.h>
|
||||
|
||||
|
||||
//#define MPLS
|
||||
|
||||
#ifdef MPLS
|
||||
#include <net/mpls.h>
|
||||
#endif
|
||||
|
||||
|
||||
//#define NAS_DEBUG_CLASS 1
|
||||
//#define NAS_DEBUG_SEND 1
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Add a new classifier rule (send direction)
|
||||
struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc;
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_SCLASSIFIER: begin for dscp %d, classref %d\n", dscp,classref);
|
||||
#endif
|
||||
|
||||
if (cx==NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_SCLASSIFIER - input parameter cx is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (gc=cx->sclassifier[dscp]; gc!=NULL; gc=gc->next) {
|
||||
if (gc->classref==classref) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_SCLASSIFIER: classifier already exist for dscp %d, classref %d\n",dscp,classref);
|
||||
#endif
|
||||
return gc;
|
||||
}
|
||||
}
|
||||
|
||||
gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_KERNEL);
|
||||
|
||||
if (gc==NULL)
|
||||
return NULL;
|
||||
|
||||
gc->next=cx->sclassifier[dscp];
|
||||
gc->classref=classref;
|
||||
cx->sclassifier[dscp]=gc;
|
||||
++cx->nsclassifier;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_SCLASSIFIER: classifier created for dscp %d, classref %d\n",dscp,classref);
|
||||
#endif
|
||||
return gc;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Add a new classifier rule (receive direction)
|
||||
struct classifier_entity *nas_CLASS_add_rclassifier(uint8_t dscp,
|
||||
uint16_t classref,
|
||||
struct nas_priv *gpriv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_RCLASSIFIER: begin\n");
|
||||
#endif
|
||||
|
||||
for (gc=gpriv->rclassifier[dscp]; gc!=NULL; gc=gc->next) {
|
||||
if (gc->classref==classref) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_RCLASSIFIER: classifier already exist for dscp %d, classref %d\n",dscp,classref);
|
||||
#endif
|
||||
return gc;
|
||||
}
|
||||
}
|
||||
|
||||
gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_KERNEL);
|
||||
|
||||
if (gc==NULL)
|
||||
return NULL;
|
||||
|
||||
gc->next=gpriv->rclassifier[dscp];
|
||||
gc->classref=classref;
|
||||
gpriv->rclassifier[dscp]=gc;
|
||||
++gpriv->nrclassifier;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_RCLASSIFIER: classifier created for dscp %d, classref %d\n",dscp,classref);
|
||||
#endif
|
||||
return gc;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Add a new classifier rule (forwarding)
|
||||
struct classifier_entity *nas_CLASS_add_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_FCLASSIFIER: begin for dscp %d, classref %d\n", dscp,classref);
|
||||
#endif
|
||||
|
||||
if (cx==NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_FCLASSIFIER - input parameter cx is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (gc=cx->fclassifier[dscp]; gc!=NULL; gc=gc->next) {
|
||||
if (gc->classref==classref) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_SCLASSIFIER: classifier already exist for dscp %d, classref %d\n",dscp,classref);
|
||||
#endif
|
||||
return gc;
|
||||
}
|
||||
}
|
||||
|
||||
gc=(struct classifier_entity *)kmalloc(sizeof(struct classifier_entity), GFP_KERNEL);
|
||||
|
||||
if (gc==NULL)
|
||||
return NULL;
|
||||
|
||||
gc->next=cx->fclassifier[dscp];
|
||||
gc->classref=classref;
|
||||
cx->fclassifier[dscp]=gc;
|
||||
++cx->nfclassifier;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_ADD_FCLASSIFIER: classifier created for dscp %d, classref %d\n",dscp,classref);
|
||||
#endif
|
||||
return gc;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CLASS_flush_sclassifier(struct cx_entity *cx)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t dscpi;
|
||||
struct classifier_entity *gc;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_FLUSH_SCLASSIFIER: begin\n");
|
||||
#endif
|
||||
|
||||
if (cx==NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_FLUSH_SCLASSIFIER - input parameter cx is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) {
|
||||
for (gc=cx->sclassifier[dscpi]; gc!=NULL; gc=cx->sclassifier[dscpi]) {
|
||||
cx->sclassifier[dscpi]=gc->next;
|
||||
kfree(gc);
|
||||
}
|
||||
}
|
||||
|
||||
cx->nsclassifier=0;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_FLUSH_SCLASSIFIER: end\n");
|
||||
#endif
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CLASS_flush_fclassifier(struct cx_entity *cx)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t dscpi;
|
||||
struct classifier_entity *gc;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_FLUSH_FCLASSIFIER: begin\n");
|
||||
#endif
|
||||
|
||||
if (cx==NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_FLUSH_FCLASSIFIER - input parameter cx is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) {
|
||||
for (gc=cx->fclassifier[dscpi]; gc!=NULL; gc=cx->fclassifier[dscpi]) {
|
||||
cx->fclassifier[dscpi]=gc->next;
|
||||
kfree(gc);
|
||||
}
|
||||
}
|
||||
|
||||
cx->nfclassifier=0;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_FLUSH_FCLASSIFIER: end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t dscpi;
|
||||
struct classifier_entity *gc;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_FLUSH_RCLASSIFIER: begin\n");
|
||||
#endif
|
||||
|
||||
for (dscpi=0; dscpi<NAS_DSCP_MAX; ++dscpi) {
|
||||
for (gc=gpriv->rclassifier[dscpi]; gc!=NULL; gc=gpriv->rclassifier[dscpi]) {
|
||||
gpriv->rclassifier[dscpi]=gc->next;
|
||||
kfree(gc);
|
||||
}
|
||||
}
|
||||
|
||||
gpriv->nrclassifier=0;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_FLUSH_RCLASSIFIER: end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete a classifier rule (send direction)
|
||||
void nas_CLASS_del_sclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p,*np;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_DEL_SCLASSIFIER: begin\n");
|
||||
#endif
|
||||
|
||||
if (cx==NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_DEL_SCLASSIFIER - input parameter cx is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
p=cx->sclassifier[dscp];
|
||||
|
||||
if (p==NULL)
|
||||
return;
|
||||
|
||||
if (p->classref==classref) {
|
||||
cx->sclassifier[dscp]=p->next;
|
||||
kfree(p);
|
||||
--cx->nsclassifier;
|
||||
return;
|
||||
}
|
||||
|
||||
for (np=p->next; np!=NULL; p=np) {
|
||||
if (np->classref==classref) {
|
||||
p->next=np->next;
|
||||
kfree(np);
|
||||
--cx->nsclassifier;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_DEL_SCLASSIFIER: end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete a classifier rule (send direction)
|
||||
void nas_CLASS_del_fclassifier(struct cx_entity *cx, uint8_t dscp, uint16_t classref)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p,*np;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_DEL_FCLASSIFIER: begin\n");
|
||||
#endif
|
||||
|
||||
if (cx==NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_DEL_FCLASSIFIER - input parameter cx is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
p=cx->fclassifier[dscp];
|
||||
|
||||
if (p==NULL)
|
||||
return;
|
||||
|
||||
if (p->classref==classref) {
|
||||
cx->fclassifier[dscp]=p->next;
|
||||
kfree(p);
|
||||
--cx->nfclassifier;
|
||||
return;
|
||||
}
|
||||
|
||||
for (np=p->next; np!=NULL; p=np) {
|
||||
if (np->classref==classref) {
|
||||
p->next=np->next;
|
||||
kfree(np);
|
||||
--cx->nfclassifier;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_DEL_FCLASSIFIER: end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete a classifier rule (receive direction)
|
||||
void nas_CLASS_del_rclassifier(uint8_t dscp, uint16_t classref,struct nas_priv *gpriv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p,*np;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_DEL_RCLASSIFIER: begin\n");
|
||||
#endif
|
||||
p=gpriv->rclassifier[dscp];
|
||||
|
||||
if (p==NULL)
|
||||
return;
|
||||
|
||||
if (p->classref==classref) {
|
||||
gpriv->rclassifier[dscp]=p->next;
|
||||
kfree(p);
|
||||
--gpriv->nrclassifier;
|
||||
return;
|
||||
}
|
||||
|
||||
for (np=p->next; np!=NULL; p=np) {
|
||||
if (np->classref==classref) {
|
||||
p->next=np->next;
|
||||
kfree(np);
|
||||
--gpriv->nrclassifier;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_DEL_RCLASSIFIER: end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Search the entity with the IPv6 address 'addr'
|
||||
// Navid: the ipv6 classifier is not fully tested
|
||||
struct cx_entity *nas_CLASS_cx6(struct sk_buff *skb,
|
||||
unsigned char dscp,
|
||||
struct nas_priv *gpriv,
|
||||
int inst,
|
||||
unsigned char *cx_searcher)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned char cxi;
|
||||
unsigned int *addr,*dst=NULL;
|
||||
struct cx_entity *default_ip=NULL;
|
||||
struct classifier_entity *p=NULL;
|
||||
|
||||
if (skb!=NULL) {
|
||||
|
||||
for (cxi=*cx_searcher; cxi<NAS_CX_MAX; cxi++) {
|
||||
|
||||
(*cx_searcher)++;
|
||||
|
||||
p = gpriv->cx[cxi].sclassifier[dscp];
|
||||
|
||||
while (p!=NULL) {
|
||||
if (p->version == 6) { // verify that this is an IPv4 rule
|
||||
|
||||
|
||||
if ((addr = (unsigned int *)(&(p->daddr.ipv6)))== NULL) {
|
||||
printk("nas_CLASS_cx6: addr is null \n");
|
||||
p = p->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("cx %d : %X,%X.%X,%X\n",cxi,addr[0],addr[1],addr[2],addr[3]);
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
|
||||
//if ((dst = (unsigned int*)&(((struct rt6_info *)skbdst)->rt6i_gateway)) == 0){
|
||||
if ((dst = ((struct iphdr*)(skb_network_header(skb)))->daddr) == 0) {
|
||||
|
||||
printk("nas_CLASS_cx6: dst addr is null \n");
|
||||
p = p->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((addr[0] == dst[0]) &&
|
||||
(addr[1] == dst[1]) &&
|
||||
(addr[2] == dst[2]) &&
|
||||
(addr[3] == dst[3])) {
|
||||
//#ifdef NAS_DEBUG_CLASS
|
||||
printk("nas_CLASS_cx6: found cx %d: %X.%X.%X.%X\n",cxi,
|
||||
dst[0],
|
||||
dst[1],
|
||||
dst[2],
|
||||
dst[3]);
|
||||
//#endif //NAS_DEBUG_CLASS
|
||||
return gpriv->cx+cxi;
|
||||
}
|
||||
|
||||
/*
|
||||
else if ((addr[0]==NAS_DEFAULT_IPV6_ADDR0) &&
|
||||
(addr[1]==NAS_DEFAULT_IPV6_ADDR1) &&
|
||||
(addr[2]==NAS_DEFAULT_IPV6_ADDR2) &&
|
||||
(addr[3]==NAS_DEFAULT_IPV6_ADDR3))
|
||||
default_ip = gpriv->cx+cxi;
|
||||
*/
|
||||
}
|
||||
|
||||
// Go to next classifier entry for connection
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printk("nas_CLASS_cx6 NOT FOUND: %X.%X.%X.%X\n",
|
||||
dst[0],
|
||||
dst[1],
|
||||
dst[2],
|
||||
dst[3]);
|
||||
return default_ip;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Search the entity with the IPv4 address 'addr'
|
||||
struct cx_entity *nas_CLASS_cx4(struct sk_buff *skb,
|
||||
unsigned char dscp,
|
||||
struct nas_priv *gpriv,
|
||||
int inst,
|
||||
unsigned char *cx_searcher)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned char cxi;
|
||||
unsigned char *addr;
|
||||
uint32_t daddr;
|
||||
struct cx_entity *default_ip=NULL;
|
||||
struct classifier_entity *p=NULL;
|
||||
|
||||
// if (inst >0)
|
||||
// return(gpriv->cx); //dump to clusterhead
|
||||
|
||||
if (skb!=NULL) {
|
||||
daddr = ((struct iphdr*)(skb_network_header(skb)))->daddr;
|
||||
|
||||
if (daddr!=NULL) {
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("[NAS][CLASS][IPv4] Searching for %d.%d.%d.%d\n",
|
||||
((unsigned char *)&daddr)[0],
|
||||
((unsigned char *)&daddr)[1],
|
||||
((unsigned char *)&daddr)[2],
|
||||
((unsigned char *)&daddr)[3]);
|
||||
#endif
|
||||
|
||||
for (cxi=*cx_searcher; cxi<NAS_CX_MAX; ++cxi) {
|
||||
(*cx_searcher)++;
|
||||
p = gpriv->cx[cxi].sclassifier[dscp];
|
||||
|
||||
while (p!=NULL) {
|
||||
if (p->version == 4) { // verify that this is an IPv4 rule
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
addr = (char *)(&(p->daddr.ipv4));
|
||||
printk("found classifier cx %d for destination: %d.%d.%d.%d\n",cxi,addr[0],addr[1],addr[2],addr[3]);
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
|
||||
if ((p->daddr.ipv4)== daddr) {
|
||||
addr = (char *)(&(p->daddr.ipv4));
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("found cx %d: %d.%d.%d.%d\n",cxi,
|
||||
addr[0],
|
||||
addr[1],
|
||||
addr[2],
|
||||
addr[3]);
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
return gpriv->cx+cxi;
|
||||
}
|
||||
|
||||
/*
|
||||
else if (gpriv->cx[cxi].sclassifier[dscp]->daddr.ipv4==NAS_DEFAULT_IPV4_ADDR) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("found default_ip rule\n");
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
default_ip = gpriv->cx+cxi;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// goto to next classification rule for the connection
|
||||
p = p->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return default_ip;
|
||||
}
|
||||
|
||||
#ifdef MPLS
|
||||
//---------------------------------------------------------------------------
|
||||
// Search the entity with the mpls label and given exp
|
||||
struct cx_entity *nas_CLASS_MPLS(struct sk_buff *skb,
|
||||
unsigned char exp,
|
||||
struct nas_priv *gpriv,
|
||||
int inst,
|
||||
unsigned char *cx_searcher)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned char cxi;
|
||||
|
||||
struct cx_entity *default_label=NULL;
|
||||
struct classifier_entity *p=NULL;
|
||||
|
||||
// if (inst >0)
|
||||
// return(gpriv->cx); //dump to clusterhead
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
|
||||
|
||||
printk("[NAS][CLASS][MPLS] Searching for label %d\n",MPLSCB(skb)->label);
|
||||
#endif
|
||||
|
||||
for (cxi=*cx_searcher; cxi<NAS_CX_MAX; ++cxi) {
|
||||
|
||||
(*cx_searcher)++;
|
||||
p = gpriv->cx[cxi].sclassifier[exp];
|
||||
|
||||
while (p!=NULL) {
|
||||
if (p->version == NAS_MPLS_VERSION_CODE) { // verify that this is an MPLS rule
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("cx %d : label %d\n",cxi,p->daddr.mpls_label);
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
|
||||
if (p->daddr.mpls_label==MPLSCB(skb)->label) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("found cx %d: label %d, RB %d\n",cxi,
|
||||
MPLSCB(skb)->label,
|
||||
p->rab_id);
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
return gpriv->cx+cxi;
|
||||
}
|
||||
|
||||
/*
|
||||
else if (gpriv->cx[cxi].sclassifier[dscp]->daddr.ipv4==NAS_DEFAULT_IPV4_ADDR) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("found default_ip rule\n");
|
||||
#endif //NAS_DEBUG_CLASS
|
||||
default_ip = gpriv->cx+cxi;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// goto to next classification rule for the connection
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return default_label;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Search the sending function
|
||||
void nas_CLASS_send(struct sk_buff *skb,int inst)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *p, *sp;
|
||||
uint8_t *protocolh,version;
|
||||
uint8_t protocol, dscp, exp,label;
|
||||
uint16_t classref;
|
||||
struct cx_entity *cx;
|
||||
unsigned int i;
|
||||
|
||||
unsigned int router_adv = 0;
|
||||
struct net_device *dev=nasdev[inst];
|
||||
|
||||
struct nas_priv *gpriv=netdev_priv(dev);
|
||||
|
||||
unsigned char cx_searcher,no_connection=1;
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: begin - inst %d\n",inst);
|
||||
#endif
|
||||
|
||||
if (skb==NULL) {
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
printk("NAS_CLASS_SEND - input parameter skb is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
|
||||
printk("[NAS][CLASS][SEND] Got packet from kernel:\n");
|
||||
|
||||
for (i=0; i<256; i++)
|
||||
printk("%2x ",((unsigned char *)skb->data)[i]);
|
||||
|
||||
printk("\n");
|
||||
#endif
|
||||
// find all connections related to socket
|
||||
cx_searcher = 0;
|
||||
|
||||
no_connection = 1;
|
||||
|
||||
//while (cx_searcher<NAS_CX_MAX) {
|
||||
|
||||
cx = NULL;
|
||||
|
||||
// Address classification
|
||||
switch (ntohs(skb->protocol)) {
|
||||
case ETH_P_IPV6:
|
||||
version = 6;
|
||||
|
||||
protocolh=nas_TOOL_get_protocol6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
dscp=nas_TOOL_get_dscp6(
|
||||
(struct ipv6hdr *)(skb_network_header(skb))
|
||||
);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: %p %d %p %d %p \n",skb, dscp, gpriv, inst, &cx_searcher);
|
||||
#endif
|
||||
cx=nas_CLASS_cx6(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got IPv6 packet, dscp = %d\n",dscp);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ETH_P_IP:
|
||||
|
||||
|
||||
dscp=nas_TOOL_get_dscp4((struct iphdr *)(skb_network_header(skb)));
|
||||
cx=nas_CLASS_cx4(skb,dscp,gpriv,inst,&cx_searcher);
|
||||
protocolh=nas_TOOL_get_protocol4(
|
||||
(struct iphdr *)(skb_network_header(skb)),
|
||||
&protocol);
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got IPv4 packet (%x), dscp = %d, cx = %x\n",ntohs(skb->protocol),dscp,cx);
|
||||
#endif
|
||||
version = 4;
|
||||
|
||||
break;
|
||||
#ifdef MPLS
|
||||
|
||||
case ETH_P_MPLS_UC:
|
||||
cx=nas_CLASS_MPLS(skb,MPLSCB(skb)->exp,gpriv,inst,&cx_searcher);
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: Got MPLS unicast packet, exp = %d, label = %d, cx = %x\n",MPLSCB(skb)->exp,MPLSCB(skb)->label,cx);
|
||||
#endif
|
||||
|
||||
dscp = MPLSCB(skb)->exp;
|
||||
version = NAS_MPLS_VERSION_CODE;
|
||||
protocol = version;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
printk("NAS_CLASS_SEND: Unknown protocol\n");
|
||||
version = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// If a valid connection for the DSCP/EXP with destination address
|
||||
// is found scan all protocol-based classification rules
|
||||
|
||||
if (cx) {
|
||||
|
||||
classref=0;
|
||||
sp=NULL;
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("[NAS][CLASSIFIER] DSCP/EXP %d : looking for classifier entry\n",dscp);
|
||||
#endif
|
||||
|
||||
for (p=cx->sclassifier[dscp]; p!=NULL; p=p->next) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("[NAS][CLASSIFIER] DSCP %d p->classref=%d,p->protocol=%d,p->version=%d\n",dscp,p->classref,p->protocol,p->version);
|
||||
#endif
|
||||
// Check if transport protocol/message match
|
||||
/*
|
||||
if ((p->protocol == protocol))
|
||||
if ((protocol == NAS_PROTOCOL_ICMP6) && (version == 6))
|
||||
if (p->protocol_message_type == (p->protocol_message_type )) {
|
||||
printk("[GRAAL][CLASSIFIER] Router advertisement\n");
|
||||
}
|
||||
*/
|
||||
// normal rule checks that network protocol version matches
|
||||
|
||||
if (p->version == version) {
|
||||
sp=p;
|
||||
classref=sp->classref;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sp!=NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
|
||||
char sfct[10], sprotocol[10];
|
||||
|
||||
if (sp->fct==nas_COMMON_QOS_send)
|
||||
strcpy(sfct, "qos");
|
||||
|
||||
if (sp->fct==nas_CTL_send)
|
||||
strcpy(sfct, "ctl");
|
||||
|
||||
if (sp->fct==nas_COMMON_del_send)
|
||||
strcpy(sfct, "del");
|
||||
|
||||
if (sp->fct==nas_mesh_DC_send_sig_data_request)
|
||||
strcpy(sfct, "dc");
|
||||
|
||||
switch(protocol) {
|
||||
case NAS_PROTOCOL_UDP:
|
||||
strcpy(sprotocol, "udp");
|
||||
printk("udp packet\n");
|
||||
break;
|
||||
|
||||
case NAS_PROTOCOL_TCP:
|
||||
strcpy(sprotocol, "tcp");
|
||||
printk("tcp packet\n");
|
||||
break;
|
||||
|
||||
case NAS_PROTOCOL_ICMP4:
|
||||
strcpy(sprotocol, "icmp4");
|
||||
printk("icmp4 packet\n");
|
||||
break;
|
||||
|
||||
case NAS_PROTOCOL_ICMP6:
|
||||
strcpy(sprotocol, "icmp6");
|
||||
print_TOOL_pk_icmp6((struct icmp6hdr*)protocolh);
|
||||
break;
|
||||
#ifdef MPLS
|
||||
|
||||
case NAS_MPLS_VERSION_CODE:
|
||||
strcpy(sprotocol,"mpls");
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
printk("NAS_CLASS_SEND: (dscp %u, %s) received, (classref %u, fct %s, rab_id %u) classifier rule\n",
|
||||
dscp, sprotocol, sp->classref, sfct, sp->rab_id);
|
||||
#endif
|
||||
|
||||
sp->fct(skb, cx, sp,inst);
|
||||
|
||||
} // if classifier entry match found
|
||||
|
||||
else {
|
||||
printk("NAS_CLASS_SEND: no corresponding item in the classifier, so the message is dropped\n");
|
||||
// nas_COMMON_del_send(skb, cx, NULL,inst);
|
||||
}
|
||||
|
||||
no_connection = 0;
|
||||
} // if connection found
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
|
||||
if (no_connection == 1)
|
||||
printk("NAS_CLASS_SEND: no corresponding connection, so the message is dropped\n");
|
||||
|
||||
#endif NAS_DEBUG_CLASS
|
||||
|
||||
|
||||
// } // while loop over connections
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_CLASS_SEND: end\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
Executable
+713
@@ -0,0 +1,713 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
/*! \file common.c
|
||||
* \brief implementation of emultor tx and rx
|
||||
* \author Navid Nikaein, Lionel GAUTHIER, and Raymomd Knopp
|
||||
* \date 2011
|
||||
* \version 1.0
|
||||
* \company Eurecom
|
||||
* \email: navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr
|
||||
*/
|
||||
|
||||
//#include "nas_common.h"
|
||||
#include "local.h"
|
||||
#include "proto_extern.h"
|
||||
#ifdef RTAI
|
||||
#include "rtai_fifos.h"
|
||||
#endif
|
||||
|
||||
//#define NAS_DEBUG_RECEIVE 1
|
||||
//#define NAS_DEBUG_SEND 1
|
||||
//#define NAS_DEBUG_CLASS 1
|
||||
//#define NAS_ADDRESS_FIX 1
|
||||
|
||||
#include <linux/inetdevice.h>
|
||||
|
||||
#include <net/tcp.h>
|
||||
#include <net/udp.h>
|
||||
|
||||
|
||||
void nas_COMMON_receive(uint16_t dlen,
|
||||
void *pdcp_sdu,
|
||||
int inst,
|
||||
struct classifier_entity *rclass,
|
||||
nasRadioBearerId_t rb_id)
|
||||
{
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
struct sk_buff *skb;
|
||||
struct ipversion *ipv;
|
||||
struct nas_priv *gpriv=netdev_priv(nasdev[inst]);
|
||||
uint32_t odaddr,osaddr;
|
||||
|
||||
int i;
|
||||
|
||||
unsigned char protocol;
|
||||
|
||||
unsigned char *addr,*daddr,*saddr,*ifaddr,sn;
|
||||
|
||||
struct udphdr *uh;
|
||||
struct tcphdr *th;
|
||||
uint16_t *cksum,check;
|
||||
|
||||
struct iphdr *network_header;
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
|
||||
printk("NAS_COMMON_RECEIVE: begin RB %d Inst %d Length %d bytes\n",rb_id,inst,dlen);
|
||||
#endif
|
||||
skb = dev_alloc_skb( dlen + 2 );
|
||||
|
||||
if(!skb) {
|
||||
printk("NAS_COMMON_RECEIVE: low on memory\n");
|
||||
++gpriv->stats.rx_dropped;
|
||||
return;
|
||||
}
|
||||
|
||||
skb_reserve(skb,2);
|
||||
memcpy(skb_put(skb, dlen), pdcp_sdu,dlen);
|
||||
|
||||
skb->dev = nasdev[inst];
|
||||
|
||||
skb_reset_mac_header(skb);
|
||||
//printk("[NAC_COMMIN_RECEIVE]: Packet Type %d (%d,%d)",skb->pkt_type,PACKET_HOST,PACKET_BROADCAST);
|
||||
skb->pkt_type = PACKET_HOST;
|
||||
|
||||
if (rclass->version != NAS_MPLS_VERSION_CODE) { // This is an IP packet
|
||||
|
||||
skb->ip_summed = CHECKSUM_NONE;
|
||||
|
||||
|
||||
ipv = (struct ipversion *)skb->data;
|
||||
|
||||
switch (ipv->version) {
|
||||
case 6:
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("NAS_COMMON_RECEIVE: receive IPv6 message\n");
|
||||
#endif
|
||||
|
||||
|
||||
skb_reset_network_header(skb);
|
||||
|
||||
skb->protocol = htons(ETH_P_IPV6);
|
||||
// printk("Writing packet with protocol %x\n",ntohs(skb->protocol));
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
#ifdef NAS_ADDRESS_FIX
|
||||
// Make the third byte of both the source and destination equal to the fourth of the destination
|
||||
|
||||
|
||||
|
||||
daddr = (unsigned char *)&((struct iphdr *)skb->data)->daddr;
|
||||
odaddr = ((struct iphdr *)skb->data)->daddr;
|
||||
// sn = addr[3];
|
||||
saddr = (unsigned char *)&((struct iphdr *)skb->data)->saddr;
|
||||
osaddr = ((struct iphdr *)skb->data)->saddr;
|
||||
|
||||
if (daddr[0] == saddr[0]) {// same network
|
||||
daddr[2] = daddr[3]; // set third byte of destination to that of local machine so that local IP stack accepts the packet
|
||||
saddr[2] = daddr[3]; // set third byte of source to that of local machine so that local IP stack accepts the packet
|
||||
} else { // get the 3rd byte from device address in net_device structure
|
||||
ifaddr = (unsigned char *)(&(((struct in_device *)((nasdev[inst])->ip_ptr))->ifa_list->ifa_local));
|
||||
|
||||
if (saddr[0] == ifaddr[0]) { // source is in same network as local machine
|
||||
daddr[0] += saddr[3]; // fix address of remote destination to undo change at source
|
||||
saddr[2] = ifaddr[2]; // set third byte to that of local machine so that local IP stack accepts the packet
|
||||
} else { // source is remote machine from outside network
|
||||
saddr[0] -= daddr[3]; // fix address of remote source to be understood by destination
|
||||
daddr[2] = daddr[3]; // fix 3rd byte of local address to be understood by IP stack of
|
||||
// destination
|
||||
}
|
||||
}
|
||||
|
||||
#endif //NAS_ADDRESS_FIX
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
// printk("NAS_TOOL_RECEIVE: receive IPv4 message\n");
|
||||
addr = (unsigned char *)&((struct iphdr *)skb->data)->saddr;
|
||||
|
||||
if (addr) {
|
||||
// addr[2]^=0x01;
|
||||
printk("[NAS][COMMON][RECEIVE] Source %d.%d.%d.%d\n",addr[0],addr[1],addr[2],addr[3]);
|
||||
}
|
||||
|
||||
addr = (unsigned char *)&((struct iphdr *)skb->data)->daddr;
|
||||
|
||||
if (addr) {
|
||||
// addr[2]^=0x01;
|
||||
printk("[NAS][COMMON][RECEIVE] Dest %d.%d.%d.%d\n",addr[0],addr[1],addr[2],addr[3]);
|
||||
}
|
||||
|
||||
printk("[NAS][COMMON][RECEIVE] protocol %d\n",((struct iphdr *)skb->data)->protocol);
|
||||
|
||||
#endif
|
||||
|
||||
skb_reset_network_header(skb);
|
||||
network_header = (struct iphdr *)skb_network_header(skb);
|
||||
protocol = network_header->protocol;
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
|
||||
switch (protocol) {
|
||||
case IPPROTO_IP:
|
||||
printk("[NAS][COMMON][RECEIVE] Received Raw IPv4 packet\n");
|
||||
break;
|
||||
|
||||
case IPPROTO_IPV6:
|
||||
printk("[NAS][COMMON][RECEIVE] Received Raw IPv6 packet\n");
|
||||
break;
|
||||
|
||||
case IPPROTO_ICMP:
|
||||
printk("[NAS][COMMON][RECEIVE] Received Raw ICMP packet\n");
|
||||
break;
|
||||
|
||||
case IPPROTO_TCP:
|
||||
printk("[NAS][COMMON][RECEIVE] Received TCP packet\n");
|
||||
break;
|
||||
|
||||
case IPPROTO_UDP:
|
||||
printk("[NAS][COMMON][RECEIVE] Received UDP packet\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef NAS_ADDRESS_FIX
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("NAS_COMMON_RECEIVE: dumping the packet before the csum recalculation\n",skb->len);
|
||||
|
||||
for (i=0; i<skb->len; i++)
|
||||
printk("%2x ",((unsigned char *)(skb->data))[i]);
|
||||
|
||||
printk("\n");
|
||||
#endif //NAS_DEBUG_RECEIVE
|
||||
|
||||
|
||||
network_header->check = 0;
|
||||
network_header->check = ip_fast_csum((unsigned char *) network_header,
|
||||
network_header->ihl);
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON][RECEIVE] IP Fast Checksum %x \n", network_header->check);
|
||||
#endif
|
||||
|
||||
// if (!(skb->nh.iph->frag_off & htons(IP_OFFSET))) {
|
||||
|
||||
|
||||
|
||||
|
||||
switch(protocol) {
|
||||
|
||||
case IPPROTO_TCP:
|
||||
|
||||
cksum = (uint16_t*)&(((struct tcphdr*)((network_header + (network_header->ihl<<2))))->check);
|
||||
//check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, tcp_hdrlen(skb), IPPROTO_TCP, ~(*cksum));
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON] Inst %d TCP packet calculated CS %x, CS = %x (before), SA (%x)%x, DA (%x)%x\n",
|
||||
inst,
|
||||
network_header->check,
|
||||
*cksum,
|
||||
osaddr,
|
||||
((struct iphdr *)skb->data)->saddr,
|
||||
odaddr,
|
||||
((struct iphdr *)skb->data)->daddr);
|
||||
#endif
|
||||
check = csum_tcpudp_magic(((struct iphdr *)skb->data)->saddr, ((struct iphdr *)skb->data)->daddr,0,0, ~(*cksum));
|
||||
*cksum = csum_tcpudp_magic(~osaddr, ~odaddr, 0, 0, ~check);
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON] Inst %d TCP packet NEW CS %x\n",
|
||||
inst,
|
||||
*cksum);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case IPPROTO_UDP:
|
||||
|
||||
cksum = (uint16_t*)&(((struct udphdr*)((network_header + (network_header->ihl<<2))))->check);
|
||||
// check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, udp_hdr(skb)->len, IPPROTO_UDP, ~(*cksum));
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON] Inst %d UDP packet CS = %x (before), SA (%x)%x, DA (%x)%x\n",
|
||||
inst,
|
||||
*cksum,
|
||||
osaddr,
|
||||
((struct iphdr *)skb->data)->saddr,
|
||||
odaddr,
|
||||
((struct iphdr *)skb->data)->daddr);
|
||||
#endif
|
||||
check = csum_tcpudp_magic(((struct iphdr *)skb->data)->saddr, ((struct iphdr *)skb->data)->daddr, 0,0, ~(*cksum));
|
||||
*cksum= csum_tcpudp_magic(~osaddr, ~odaddr,0,0, ~check);
|
||||
//*cksum= csum_tcpudp_magic(~osaddr, ~odaddr,udp_hdr(skb)->len, IPPROTO_UDP, ~check);
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON] Inst %d UDP packet NEW CS %x\n",
|
||||
inst,
|
||||
*cksum);
|
||||
#endif
|
||||
// if ((check = *cksum) != 0) {
|
||||
// src, dst, len, proto, sum
|
||||
|
||||
|
||||
// }
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
#endif //NAS_ADDRESS_FIX
|
||||
|
||||
skb->protocol = htons(ETH_P_IP);
|
||||
// printk("[NAS][COMMON] Writing packet with protocol %x\n",ntohs(skb->protocol));
|
||||
break;
|
||||
|
||||
default:
|
||||
printk("NAS_COMMON_RECEIVE: begin RB %d Inst %d Length %d bytes\n",rb_id,inst,dlen);
|
||||
|
||||
printk("[NAS][COMMON] Inst %d: receive unknown message (version=%d)\n",inst,ipv->version);
|
||||
|
||||
}
|
||||
} else { // This is an MPLS packet
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("NAS_COMMON_RECEIVE: Received an MPLS packet on RB %d\n",rb_id);
|
||||
#endif
|
||||
skb->protocol = htons(ETH_P_MPLS_UC);
|
||||
|
||||
}
|
||||
|
||||
++gpriv->stats.rx_packets;
|
||||
gpriv->stats.rx_bytes += dlen;
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("NAS_COMMON_RECEIVE: sending packet of size %d to kernel\n",skb->len);
|
||||
|
||||
for (i=0; i<skb->len; i++)
|
||||
printk("%2x ",((unsigned char *)(skb->data))[i]);
|
||||
|
||||
printk("\n");
|
||||
#endif //NAS_DEBUG_RECEIVE
|
||||
netif_rx(skb);
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("NAS_COMMON_RECEIVE: end\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete the data
|
||||
void nas_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *sp,int inst)
|
||||
{
|
||||
struct nas_priv *priv=netdev_priv(nasdev[inst]);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
++priv->stats.tx_dropped;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Request the transfer of data (QoS SAP)
|
||||
|
||||
void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct pdcp_data_req_header_s pdcph;
|
||||
struct nas_priv *priv=netdev_priv(nasdev[inst]);
|
||||
#ifdef LOOPBACK_TEST
|
||||
int i;
|
||||
#endif
|
||||
unsigned int bytes_wrote;
|
||||
unsigned char j;
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
printk("NAS_COMMON_QOS_SEND - inst %d begin \n",inst);
|
||||
#endif
|
||||
|
||||
// if (cx->state!=NAS_STATE_CONNECTED) // <--- A REVOIR
|
||||
// {
|
||||
// priv->stats.tx_dropped ++;
|
||||
// printk("NAS_QOS_SEND: No connected, so message are dropped \n");
|
||||
// return;
|
||||
// }
|
||||
if (skb==NULL) {
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
printk("NAS_COMMON_QOS_SEND - input parameter skb is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (gc==NULL) {
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
printk("NAS_COMMON_QOS_SEND - input parameter gc is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (cx==NULL) {
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
printk("NAS_COMMON_QOS_SEND - input parameter cx is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
if (gc->rb==NULL) {
|
||||
gc->rb=nas_COMMON_search_rb(cx, gc->rab_id);
|
||||
|
||||
if (gc->rb==NULL) {
|
||||
++priv->stats.tx_dropped;
|
||||
printk("NAS_COMMON_QOS_SEND: No corresponding Radio Bearer, so message are dropped, rab_id=%u \n", gc->rab_id);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
printk("NAS_COMMON_QOS_SEND #1 :");
|
||||
printk("lcr %u, rab_id %u, rab_id %u, skb_len %d\n", cx->lcr, (gc->rb)->rab_id, gc->rab_id,skb->len);
|
||||
nas_print_classifier(gc);
|
||||
#endif
|
||||
pdcph.data_size = skb->len;
|
||||
pdcph.rb_id = (gc->rb)->rab_id;
|
||||
pdcph.inst = inst;
|
||||
|
||||
|
||||
#ifdef PDCP_USE_NETLINK
|
||||
bytes_wrote = nas_netlink_send((char *)&pdcph,NAS_PDCPH_SIZE);
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
printk("[NAS] Wrote %d bytes (header for %d byte skb) to PDCP via netlink\n",
|
||||
bytes_wrote,skb->len);
|
||||
#endif
|
||||
#else
|
||||
bytes_wrote = rtf_put(NAS2PDCP_FIFO, &pdcph, NAS_PDCPH_SIZE);
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
printk("[NAS] Wrote %d bytes (header for %d byte skb) to PDCP fifo\n",
|
||||
bytes_wrote,skb->len);
|
||||
#endif
|
||||
#endif //PDCP_USE_NETLINK
|
||||
|
||||
if (bytes_wrote != NAS_PDCPH_SIZE) {
|
||||
printk("NAS_COMMON_QOS_SEND: problem while writing PDCP's header (bytes wrote = %d )\n",bytes_wrote);
|
||||
printk("rb_id %d, Wrote %d, Header Size %lu\n", pdcph.rb_id , bytes_wrote, NAS_PDCPH_SIZE);
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
rtf_reset(NAS2PDCP_FIFO);
|
||||
#endif //PDCP_USE_NETLINK
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PDCP_USE_NETLINK
|
||||
bytes_wrote += nas_netlink_send((char *)skb->data,skb->len);
|
||||
#else
|
||||
bytes_wrote += rtf_put(NAS2PDCP_FIFO, skb->data, skb->len);
|
||||
#endif //PDCP_USE_NETLINK
|
||||
|
||||
if (bytes_wrote != skb->len+NAS_PDCPH_SIZE) {
|
||||
printk("NAS_COMMON_QOS_SEND: Inst %d, RB_ID %d: problem while writing PDCP's data, bytes_wrote = %d, Data_len %d, PDCPH_SIZE %lu\n",
|
||||
inst,
|
||||
pdcph.rb_id,
|
||||
bytes_wrote,
|
||||
skb->len,
|
||||
NAS_PDCPH_SIZE); // congestion
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
rtf_reset(NAS2PDCP_FIFO);
|
||||
#endif //PDCP_USE_NETLINK
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NAS_DEBUG_SEND
|
||||
printk("NAS_SEND: Sending packet of size %d to PDCP \n",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 NAS_DEBUG_SEND
|
||||
printk("NAS_COMMON_QOS_SEND - end \n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_COMMON_QOS_receive()
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t sapi;
|
||||
struct pdcp_data_ind_header_s pdcph;
|
||||
unsigned char data_buffer[2048];
|
||||
struct classifier_entity *rclass;
|
||||
struct nas_priv *priv;
|
||||
int bytes_read;
|
||||
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("NAS_COMMON_QOS_RECEIVE - begin \n");
|
||||
#endif
|
||||
|
||||
// End debug information
|
||||
|
||||
bytes_read = rtf_get(PDCP2PDCP_USE_RT_FIFO,&pdcph, NAS_PDCPH_SIZE);
|
||||
|
||||
while (bytes_read>0) {
|
||||
if (bytes_read != NAS_PDCPH_SIZE) {
|
||||
printk("NAS_COMMON_QOS_RECEIVE: problem while reading PDCP header\n");
|
||||
return;
|
||||
}
|
||||
|
||||
priv=netdev_priv(nasdev[pdcph.inst]);
|
||||
rclass = nas_COMMON_search_class_for_rb(pdcph.rb_id,priv);
|
||||
|
||||
bytes_read+= rtf_get(PDCP2PDCP_USE_RT_FIFO,
|
||||
data_buffer,
|
||||
pdcph.data_size);
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("NAS_COMMON_QOS_RECEIVE - Got header for RB %d, Inst %d \n",
|
||||
pdcph.rb_id,
|
||||
pdcph.inst);
|
||||
#endif
|
||||
|
||||
if (rclass) {
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON] Found corresponding connection in classifier for RAB\n");
|
||||
#endif //NAS_DEBUG_RECEIVE
|
||||
|
||||
nas_COMMON_receive(pdcph.data_size,
|
||||
(void *)data_buffer,
|
||||
pdcph.inst,
|
||||
rclass,
|
||||
pdcph.rb_id);
|
||||
}
|
||||
|
||||
bytes_read = rtf_get(PDCP2PDCP_USE_RT_FIFO, &pdcph, NAS_PDCPH_SIZE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("NAS_COMMON_QOS_RECEIVE - end \n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#else
|
||||
void nas_COMMON_QOS_receive(struct nlmsghdr *nlh)
|
||||
{
|
||||
|
||||
struct pdcp_data_ind_header_s *pdcph = (struct pdcp_data_ind_header_s *)NLMSG_DATA(nlh);
|
||||
struct classifier_entity *rclass;
|
||||
struct nas_priv *priv;
|
||||
|
||||
priv = netdev_priv(nasdev[pdcph->inst]);
|
||||
|
||||
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON][NETLINK] QOS receive from PDCP, size %d, rab %d, inst %d\n",
|
||||
pdcph->data_size,pdcph->rb_id,pdcph->inst);
|
||||
#endif //NAS_DEBUG_RECEIVE
|
||||
|
||||
rclass = nas_COMMON_search_class_for_rb(pdcph->rb_id,priv);
|
||||
|
||||
if (rclass) {
|
||||
#ifdef NAS_DEBUG_RECEIVE
|
||||
printk("[NAS][COMMON][NETLINK] Found corresponding connection in classifier for RAB\n");
|
||||
#endif //NAS_DEBUG_RECEIVE
|
||||
|
||||
nas_COMMON_receive(pdcph->data_size,
|
||||
(unsigned char *)NLMSG_DATA(nlh) + NAS_PDCPH_SIZE,
|
||||
pdcph->inst,
|
||||
rclass,
|
||||
pdcph->rb_id);
|
||||
}
|
||||
|
||||
}
|
||||
#endif //PDCP_USE_NETLINK
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
struct cx_entity *nas_COMMON_search_cx(nasLocalConnectionRef_t lcr,struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_COMMON_SEARCH_CX - lcr %d\n",lcr);
|
||||
#endif
|
||||
|
||||
if (lcr<NAS_CX_MAX)
|
||||
return priv->cx+lcr;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Search a Radio Bearer
|
||||
struct rb_entity *nas_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct rb_entity *rb;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_COMMON_SEARCH_RB - rab_id %d\n", rab_id);
|
||||
#endif
|
||||
|
||||
for (rb=cx->rb; rb!=NULL; rb=rb->next) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\n");
|
||||
printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.rab_id %u \n", rb->rab_id);
|
||||
printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.sapi %u \n", rb->sapi;
|
||||
printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.qos %u \n", rb->qos;
|
||||
printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.state %u \n", rb->state;
|
||||
printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.retry %u \n", rb->retry;
|
||||
printk("NAS_COMMON_SEARCH_RB - rab_id %d Comparing rb_entity.countimer %u \n\n", rb->countimer;);
|
||||
#endif
|
||||
|
||||
if (rb->rab_id==rab_id)
|
||||
return rb;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Search for a classifier with corresponding radio bearer
|
||||
|
||||
struct classifier_entity *nas_COMMON_search_class_for_rb(nasRadioBearerId_t rab_id,struct nas_priv *priv)
|
||||
{
|
||||
|
||||
struct rb_entity *rb;
|
||||
int dscp;
|
||||
struct classifier_entity *rclass;
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("[NAS][COMMON] NAS_COMMON_SEARCH_CLASS_FOR_RB - rab_id %d\n", rab_id);
|
||||
#endif
|
||||
|
||||
for (dscp=0; dscp<NAS_DSCP_MAX; dscp++) {
|
||||
|
||||
// printk("[NAS][COMMON] priv->rclassifier[%d] = %p\n",dscp,priv->rclassifier[dscp]);
|
||||
for (rclass=priv->rclassifier[dscp]; rclass!=NULL; rclass=rclass->next) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("[NAS][COMMON] NAS_COMMON_SEARCH_CLASS_FOR_RB - dscp %d, rb %d\n", dscp,rclass->rab_id);
|
||||
#endif
|
||||
|
||||
if (rclass->rab_id==rab_id)
|
||||
return rclass;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
struct rb_entity *nas_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rab_id, nasQoSTrafficClass_t qos)
|
||||
{
|
||||
//--------------------------------------------------------------------------
|
||||
struct rb_entity *rb;
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_COMMON_ADD_RB - begin for rab_id %d , qos %d\n", rab_id, qos );
|
||||
#endif
|
||||
|
||||
if (cx==NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_COMMON_ADD_RB - input parameter cx is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rb=nas_COMMON_search_rb(cx, rab_id);
|
||||
|
||||
if (rb==NULL) {
|
||||
rb=(struct rb_entity *)kmalloc(sizeof(struct rb_entity), GFP_KERNEL);
|
||||
|
||||
if (rb!=NULL) {
|
||||
rb->retry=0;
|
||||
rb->countimer=NAS_TIMER_IDLE;
|
||||
rb->rab_id=rab_id;
|
||||
// rb->rab_id=rab_id+(32*cx->lcr);
|
||||
#ifdef NAS_DEBUG_DC
|
||||
printk("NAS_COMMON_ADD_RB: rab_id=%u, mt_id=%u\n",rb->rab_id, cx->lcr);
|
||||
#endif
|
||||
rb->qos=qos;
|
||||
rb->sapi=NAS_RAB_INPUT_SAPI;
|
||||
rb->state=NAS_IDLE;
|
||||
rb->next=cx->rb;
|
||||
cx->rb=rb;
|
||||
++cx->num_rb;
|
||||
} else
|
||||
printk("NAS_ADD_CTL_RB: no memory\n");
|
||||
}
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_COMMON_ADD_RB - end \n" );
|
||||
#endif
|
||||
return rb;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_COMMON_flush_rb(struct cx_entity *cx)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct rb_entity *rb;
|
||||
struct classifier_entity *gc;
|
||||
uint8_t dscp;
|
||||
// End debug information
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_COMMON_FLUSH_RB - begin\n");
|
||||
#endif
|
||||
|
||||
if (cx==NULL) {
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_COMMON_FLUSH_RB - input parameter cx is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
for (rb=cx->rb; rb!=NULL; rb=cx->rb) {
|
||||
printk("NAS_COMMON_FLUSH_RB: del rab_id %u\n", rb->rab_id);
|
||||
cx->rb=rb->next;
|
||||
kfree(rb);
|
||||
}
|
||||
|
||||
cx->num_rb=0;
|
||||
cx->rb=NULL;
|
||||
|
||||
for(dscp=0; dscp<NAS_DSCP_MAX; ++dscp) {
|
||||
for (gc=cx->sclassifier[dscp]; gc!=NULL; gc=gc->next)
|
||||
gc->rb=NULL;
|
||||
}
|
||||
|
||||
#ifdef NAS_DEBUG_CLASS
|
||||
printk("NAS_COMMON_FLUSH_RB - end\n");
|
||||
#endif
|
||||
}
|
||||
Executable
+182
@@ -0,0 +1,182 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef _NAS_CST
|
||||
#define _NAS_CST
|
||||
|
||||
#define MAX_MEASURE_NB 5
|
||||
#define NAS_MAX_LENGTH 180
|
||||
|
||||
//Debug flags
|
||||
//#define NAS_DEBUG_DC
|
||||
//#define NAS_DEBUG_SEND
|
||||
//#define NAS_DEBUG_RECEIVE
|
||||
//#define NAS_DEBUG_CLASS
|
||||
//#define NAS_DEBUG_GC
|
||||
//#define NAS_DEBUG_DC_MEASURE
|
||||
//#define NAS_DEBUG_TIMER
|
||||
//#define NAS_DEBUG_DEVICE
|
||||
//#define NAS_DEBUG_INTERRUPT
|
||||
//#define NAS_DEBUG_TOOL
|
||||
|
||||
// Other flags
|
||||
#define DEMO_3GSM
|
||||
|
||||
// General Constants
|
||||
#define NAS_MTU 1500
|
||||
#define NAS_TX_QUEUE_LEN 100
|
||||
#define NAS_ADDR_LEN 8
|
||||
#define NAS_INET6_ADDRSTRLEN 46
|
||||
#define NAS_INET_ADDRSTRLEN 16
|
||||
|
||||
#define NAS_CX_MAX 128 // 32 //Identical to RRC constant
|
||||
//#define NAS_CX_MULTICAST_ALLNODE 2
|
||||
|
||||
#define NAS_RETRY_LIMIT_DEFAULT 5
|
||||
|
||||
#define NAS_MESSAGE_MAXLEN 5004
|
||||
|
||||
#define NAS_SIG_SRB3 3
|
||||
#define NAS_SIG_SRB4 3 // not used yet
|
||||
|
||||
//peer-to-peer messages between NAS entities
|
||||
#define NAS_CMD_OPEN_RB 1
|
||||
|
||||
//#define NAS_IID1_CONTROL 0x0
|
||||
//#define NAS_IID2_CONTROL __constant_htonl(0xffffffff)
|
||||
|
||||
//#define NAS_STATE_IDLE 0
|
||||
//#define NAS_STATE_CONNECTED 1
|
||||
//#define NAS_STATE_ESTABLISHMENT_REQUEST 2
|
||||
//#define NAS_STATE_ESTABLISHMENT_FAILURE 3
|
||||
//#define NAS_STATE_RELEASE_FAILURE 4
|
||||
#define NAS_CX_RELEASE_UNDEF_CAUSE 1
|
||||
|
||||
// MT+RG NAS States
|
||||
#define NAS_IDLE 0x01
|
||||
// Connection
|
||||
#define NAS_CX_FACH 0x06
|
||||
#define NAS_CX_DCH 0x0A
|
||||
#define NAS_CX_RECEIVED 0x10
|
||||
#define NAS_CX_CONNECTING 0x04
|
||||
#define NAS_CX_RELEASING 0x08
|
||||
#define NAS_CX_CONNECTING_FAILURE 0x14
|
||||
#define NAS_CX_RELEASING_FAILURE 0x18
|
||||
// Radio Bearers
|
||||
#define NAS_RB_ESTABLISHING 0x24
|
||||
#define NAS_RB_RELEASING 0x28
|
||||
#define NAS_RB_DCH 0x2A
|
||||
|
||||
|
||||
#define NAS_TIMER_ESTABLISHMENT_DEFAULT 12
|
||||
#define NAS_TIMER_RELEASE_DEFAULT 2
|
||||
#define NAS_TIMER_IDLE UINT_MAX
|
||||
#define NAS_TIMER_TICK HZ
|
||||
|
||||
#define NAS_PDCPH_SIZE sizeof(struct pdcp_data_req_header_s)
|
||||
#define NAS_IPV4_SIZE 20
|
||||
#define NAS_IPV6_SIZE 40
|
||||
|
||||
#define NAS_DIRECTION_SEND 0
|
||||
#define NAS_DIRECTION_RECEIVE 1
|
||||
#define NAS_DIRECTION_FORWARD 2
|
||||
|
||||
// function number
|
||||
#define NAS_FCT_DEL_SEND 1
|
||||
#define NAS_FCT_QOS_SEND 2
|
||||
#define NAS_FCT_DC_SEND 3
|
||||
#define NAS_FCT_CTL_SEND 4
|
||||
|
||||
// type of IOCTL command
|
||||
#define NAS_IOCTL_RRM 0x89F0
|
||||
|
||||
// Error cause
|
||||
#define NAS_ERROR_ALREADYEXIST 1
|
||||
#define NAS_ERROR_NOMEMORY 3
|
||||
#define NAS_ERROR_NOTMT 9
|
||||
#define NAS_ERROR_NOTRG 10
|
||||
#define NAS_ERROR_NOTIDLE 11
|
||||
#define NAS_ERROR_NOTCONNECTED 12
|
||||
#define NAS_ERROR_NORB 14
|
||||
#define NAS_ERROR_NOTCORRECTVALUE 32
|
||||
#define NAS_ERROR_NOTCORRECTLCR 33
|
||||
#define NAS_ERROR_NOTCORRECTDIR 34
|
||||
#define NAS_ERROR_NOTCORRECTDSCP 35
|
||||
#define NAS_ERROR_NOTCORRECTVERSION 36
|
||||
#define NAS_ERROR_NOTCORRECTRABI 37
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/* Constants related with IP protocols */
|
||||
/**********************************************************/
|
||||
|
||||
//#define NAS_PORT_CONTROL __constant_htons(0xc45)
|
||||
//#define NAS_PORT_AUTHENTICATION __constant_htons(1811)
|
||||
|
||||
#define NAS_TRAFFICCLASS_MASK __constant_htonl(0x0fc00000)
|
||||
|
||||
// Network control codepoint 111000 + IP version 6
|
||||
#define NAS_FLOWINFO_NCONTROL __constant_htonl(0x6e000000)
|
||||
// network control codepoint 111000
|
||||
#define NAS_DSCP_NCONTROL 56 //0x38
|
||||
// default codepoint 1000000
|
||||
#define NAS_DSCP_DEFAULT 64
|
||||
#define NAS_DSCP_MAX 193
|
||||
|
||||
#define NAS_PROTOCOL_DEFAULT 0
|
||||
#define NAS_PROTOCOL_TCP IPPROTO_TCP
|
||||
#define NAS_PROTOCOL_UDP IPPROTO_UDP
|
||||
#define NAS_PROTOCOL_ICMP4 IPPROTO_ICMP
|
||||
#define NAS_PROTOCOL_ICMP6 IPPROTO_ICMPV6
|
||||
|
||||
#define NAS_PORT_DEFAULT __constant_htons(65535)
|
||||
#define NAS_PORT_HTTP __constant_htons(80)
|
||||
|
||||
#define NAS_VERSION_DEFAULT 0
|
||||
#define NAS_VERSION_4 4
|
||||
#define NAS_VERSION_6 0 //?MW
|
||||
|
||||
#define NAS_DEFAULT_IPV4_ADDR 0
|
||||
#define NAS_DEFAULT_IPV6_ADDR0 0
|
||||
#define NAS_DEFAULT_IPV6_ADDR1 0
|
||||
#define NAS_DEFAULT_IPV6_ADDR2 0
|
||||
#define NAS_DEFAULT_IPV6_ADDR3 0
|
||||
|
||||
|
||||
#define NAS_MPLS_VERSION_CODE 99
|
||||
|
||||
#define NB_INSTANCES_MAX 64 //16
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Executable
+599
@@ -0,0 +1,599 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
/*! \file device.c
|
||||
* \brief Networking Device Driver for OpenAirInterface MESH
|
||||
* \author navid.nikaein, yan.moret(no longer valid), michelle.wetterwald, raymond.knopp
|
||||
* \company Eurecom
|
||||
* \email: raymond.knopp@eurecom.fr, navid.nikaein@eurecom.fr, michelle.wetterwald@eurecom.fr,
|
||||
|
||||
*/
|
||||
/*******************************************************************************/
|
||||
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
#ifdef RTAI
|
||||
#include "rtai_posix.h"
|
||||
#define RTAI_IRQ 30 //try to get this irq with RTAI
|
||||
#endif // RTAI
|
||||
#endif // PDCP_USE_NETLINK
|
||||
|
||||
#include "constant.h"
|
||||
#include "local.h"
|
||||
#include "proto_extern.h"
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/version.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>
|
||||
|
||||
|
||||
//#define DEBUG_DEVICE 1
|
||||
//#define DEBUG_INTERRUPT 1
|
||||
|
||||
struct net_device *nasdev[NB_INSTANCES_MAX];
|
||||
|
||||
#ifdef PDCP_USE_NETLINK
|
||||
extern void nas_netlink_release(void);
|
||||
extern int nas_netlink_init(void);
|
||||
#endif
|
||||
|
||||
//int bytes_wrote;
|
||||
//int bytes_read;
|
||||
uint8_t NULL_IMEI[14]= {0x05, 0x04, 0x03, 0x01, 0x02 ,0x00, 0x00, 0x00, 0x05, 0x04, 0x03 ,0x00, 0x01, 0x08};
|
||||
|
||||
|
||||
static unsigned int nas_IMEI[6]= {0x03, 0x01, 0x02 ,0x00, 0x00, 0x00}; // may change to char
|
||||
static int m_arg=0;
|
||||
static unsigned int nas_is_clusterhead=0;
|
||||
|
||||
|
||||
int find_inst(struct net_device *dev)
|
||||
{
|
||||
|
||||
int i;
|
||||
|
||||
for (i=0; i<NB_INSTANCES_MAX; i++)
|
||||
if (nasdev[i] == dev)
|
||||
return(i);
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
//void interrupt(void){
|
||||
void *nas_interrupt(void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t cxi;
|
||||
|
||||
// struct nas_priv *priv=netdev_priv(dev_id);
|
||||
// unsigned int flags;
|
||||
|
||||
// priv->lock = SPIN_LOCK_UNLOCKED;
|
||||
|
||||
#ifdef 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 PDCP_USE_NETLINK
|
||||
nas_COMMON_QOS_receive();
|
||||
#endif
|
||||
// spin_unlock_irqrestore(&priv->lock,flags);
|
||||
#ifdef DEBUG_INTERRUPT
|
||||
printk("INTERRUPT: end\n");
|
||||
#endif
|
||||
// return 0;
|
||||
}
|
||||
#endif //NETLINK
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Called by ifconfig when the device is activated by ifconfig
|
||||
int nas_open(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_priv *priv=netdev_priv(dev);
|
||||
|
||||
printk("OPEN: begin\n");
|
||||
// MOD_INC_USE_COUNT;
|
||||
|
||||
// Address has already been set at init
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
|
||||
if (pdcp_2_nas_irq==-EBUSY) {
|
||||
printk("OPEN: irq failure\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
#endif //PDCP_USE_NETLINK
|
||||
|
||||
/*
|
||||
netif_start_queue(dev);
|
||||
//
|
||||
init_timer(&priv->timer);
|
||||
(priv->timer).expires=jiffies+NAS_TIMER_TICK;
|
||||
(priv->timer).data=0L;
|
||||
(priv->timer).function=nas_mesh_timer;
|
||||
// add_timer(&priv->timer);
|
||||
//
|
||||
*/
|
||||
printk("OPEN: name = %s, end\n", dev->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Called by ifconfig when the device is desactivated
|
||||
int nas_stop(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_priv *priv = netdev_priv(dev);
|
||||
printk("STOP: begin\n");
|
||||
del_timer(&(priv->timer));
|
||||
netif_stop_queue(dev);
|
||||
// MOD_DEC_USE_COUNT;
|
||||
printk("STOP: name = %s, end\n", dev->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_teardown(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
int cxi;
|
||||
|
||||
struct nas_priv *priv;
|
||||
int inst;
|
||||
|
||||
if (dev) {
|
||||
priv = netdev_priv(dev);
|
||||
inst = find_inst(dev);
|
||||
|
||||
if (inst<0) {
|
||||
printk("nas_teardown: ERROR, couldn't find instance\n");
|
||||
}
|
||||
|
||||
printk("nas_teardown instance %d: begin\n",inst);
|
||||
|
||||
|
||||
|
||||
nas_CLASS_flush_rclassifier(priv);
|
||||
|
||||
for (cxi=0; cxi<NAS_CX_MAX; cxi++) {
|
||||
nas_COMMON_flush_rb(priv->cx+cxi);
|
||||
nas_CLASS_flush_sclassifier(priv->cx+cxi);
|
||||
}
|
||||
|
||||
printk("nas_teardown: end\n");
|
||||
} // check dev
|
||||
else {
|
||||
printk("nas_teardown: Device is null\n");
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_set_config(struct net_device *dev, struct ifmap *map)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
printk("SET_CONFIG: begin\n");
|
||||
|
||||
if (dev->flags & IFF_UP)
|
||||
return -EBUSY;
|
||||
|
||||
if (map->base_addr != dev->base_addr) {
|
||||
printk(KERN_WARNING "SET_CONFIG: Can't change I/O address\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
if (map->irq != dev->irq)
|
||||
dev->irq = map->irq;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
int nas_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
|
||||
int inst;
|
||||
|
||||
if (dev)
|
||||
inst = find_inst(dev);
|
||||
else {
|
||||
printk("nas_hard_start_xmit: ERROR, device is null\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (inst>=0) {
|
||||
#ifdef DEBUG_DEVICE
|
||||
printk("HARD_START_XMIT: inst %d, begin\n",inst);
|
||||
#endif
|
||||
|
||||
if (!skb) {
|
||||
printk("HARD_START_XMIT - input parameter skb is NULL \n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
netif_stop_queue(dev);
|
||||
dev->trans_start = jiffies;
|
||||
#ifdef DEBUG_DEVICE
|
||||
printk("HARD_START_XMIT: step 1\n");
|
||||
#endif
|
||||
nas_CLASS_send(skb,inst);
|
||||
#ifdef DEBUG_DEVICE
|
||||
printk("HARD_START_XMIT: step 2\n");
|
||||
#endif
|
||||
// if (skb==NULL){
|
||||
// printk("HARD_START_XMIT - parameter skb is NULL \n");
|
||||
// return -1;
|
||||
// }else
|
||||
dev_kfree_skb(skb);
|
||||
#ifdef DEBUG_DEVICE
|
||||
printk("HARD_START_XMIT: step 3\n");
|
||||
#endif
|
||||
netif_wake_queue(dev);
|
||||
#ifdef DEBUG_DEVICE
|
||||
printk("HARD_START_XMIT: end\n");
|
||||
#endif
|
||||
} else {
|
||||
printk("nas_hard_start_xmit: ERROR, couldn't find instnace\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
struct net_device_stats *nas_get_stats(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// return &((struct nas_priv *)dev->priv)->stats;
|
||||
struct nas_priv *priv = netdev_priv(dev);
|
||||
return &priv->stats;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_change_mtu(struct net_device *dev, int mtu)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
printk("CHANGE_MTU: begin\n");
|
||||
|
||||
if ((mtu<50) || (mtu>1500))
|
||||
return -EINVAL;
|
||||
|
||||
dev->mtu = mtu;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_tx_timeout(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Transmitter timeout, serious problems.
|
||||
struct nas_priv *priv = netdev_priv(dev);
|
||||
|
||||
printk("TX_TIMEOUT: begin\n");
|
||||
// (struct nas_priv *)(dev->priv)->stats.tx_errors++;
|
||||
(priv->stats).tx_errors++;
|
||||
dev->trans_start = jiffies;
|
||||
netif_wake_queue(dev);
|
||||
printk("TX_TIMEOUT: transmit timed out %s\n",dev->name);
|
||||
}
|
||||
|
||||
static const struct net_device_ops nasmesh_netdev_ops = {
|
||||
|
||||
.ndo_open = nas_open,
|
||||
.ndo_stop = nas_stop,
|
||||
.ndo_start_xmit = nas_hard_start_xmit,
|
||||
.ndo_validate_addr = NULL,
|
||||
.ndo_set_mac_address = NULL,
|
||||
.ndo_set_config = nas_set_config,
|
||||
.ndo_do_ioctl = nas_CTL_ioctl,
|
||||
.ndo_change_mtu = nas_change_mtu,
|
||||
.ndo_tx_timeout = nas_tx_timeout,
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Initialisation of the network device
|
||||
void nas_init(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t cxi, dscpi;
|
||||
struct nas_priv *priv;
|
||||
// int inst;
|
||||
|
||||
if (dev) {
|
||||
priv = netdev_priv(dev);
|
||||
//memset(dev->priv, 0, sizeof(struct nas_priv));
|
||||
memset(priv, 0, sizeof(struct nas_priv));
|
||||
// priv=(struct nas_priv *)(dev->priv);
|
||||
priv=netdev_priv(dev);
|
||||
//
|
||||
dev->netdev_ops = &nasmesh_netdev_ops;
|
||||
// dev->type = ARPHRD_EUROPENAIRMESH;
|
||||
//dev->type = ARPHRD_ETHER;
|
||||
// dev->features = NETIF_F_NO_CSUM;
|
||||
dev->hard_header_len = 0;
|
||||
dev->addr_len = NAS_ADDR_LEN;
|
||||
dev->flags = IFF_BROADCAST|IFF_MULTICAST|IFF_NOARP;
|
||||
dev->tx_queue_len = NAS_TX_QUEUE_LEN;
|
||||
dev->mtu = NAS_MTU;
|
||||
//
|
||||
// Initialize private structure
|
||||
// priv->sap[NAS_GC_SAPI] = RRC_DEVICE_GC;
|
||||
// priv->sap[NAS_NT_SAPI] = RRC_DEVICE_NT;
|
||||
priv->sap[NAS_RAB_INPUT_SAPI] = PDCP2PDCP_USE_RT_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT;
|
||||
priv->sap[NAS_RAB_OUTPUT_SAPI] = NAS2PDCP_FIFO;//QOS_DEVICE_STREAMING_INPUT;
|
||||
|
||||
// priv->retry_limit=RETRY_LIMIT_DEFAULT;
|
||||
// priv->timer_establishment=TIMER_ESTABLISHMENT_DEFAULT;
|
||||
// priv->timer_release=TIMER_RELEASE_DEFAULT;
|
||||
|
||||
for (dscpi=0; dscpi<65; ++dscpi)
|
||||
priv->rclassifier[dscpi]=NULL;
|
||||
|
||||
priv->nrclassifier=0;
|
||||
|
||||
//
|
||||
for (cxi=0; cxi<NAS_CX_MAX; cxi++) {
|
||||
#ifdef DEBUG_DEVICE
|
||||
printk("INIT: init classifiers, state and timer for MT %u\n", cxi);
|
||||
#endif
|
||||
|
||||
// priv->cx[cxi].sap[NAS_DC_INPUT_SAPI] = RRC_DEVICE_DC_INPUT0;
|
||||
// priv->cx[cxi].sap[NAS_DC_OUTPUT_SAPI] = RRC_DEVICE_DC_OUTPUT0;
|
||||
priv->cx[cxi].state=NAS_IDLE;
|
||||
priv->cx[cxi].countimer=NAS_TIMER_IDLE;
|
||||
priv->cx[cxi].retry=0;
|
||||
priv->cx[cxi].lcr=cxi;
|
||||
priv->cx[cxi].rb=NULL;
|
||||
priv->cx[cxi].num_rb=0;
|
||||
|
||||
// initialisation of the classifier
|
||||
for (dscpi=0; dscpi<65; ++dscpi) {
|
||||
priv->cx[cxi].sclassifier[dscpi]=NULL;
|
||||
priv->cx[cxi].fclassifier[dscpi]=NULL;
|
||||
}
|
||||
|
||||
priv->cx[cxi].nsclassifier=0;
|
||||
priv->cx[cxi].nfclassifier=0;
|
||||
// initialisation of the IP address
|
||||
// TOOL_imei2iid(IMEI, (uint8_t *)priv->cx[cxi].iid6);
|
||||
priv->cx[cxi].iid4=0;
|
||||
//
|
||||
}
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
//this requires kernel patch for OAI driver: typically for RF/hard realtime emu experimentation
|
||||
#ifdef ADDRCONF
|
||||
#ifdef NETLINK
|
||||
nas_TOOL_imei2iid(IMEI, dev->dev_addr);// IMEI to device address (for stateless autoconfiguration address)
|
||||
nas_TOOL_imei2iid(IMEI, (uint8_t *)priv->cx[0].iid6);
|
||||
#else
|
||||
nas_TOOL_imei2iid(nas_IMEI, dev->dev_addr);// IMEI to device address (for stateless autoconfiguration address)
|
||||
nas_TOOL_imei2iid(nas_IMEI, (uint8_t *)priv->cx[0].iid6);
|
||||
#endif
|
||||
// this is more appropriate for user space soft realtime emulation
|
||||
#else
|
||||
memcpy(dev->dev_addr,&nas_IMEI[0],8);
|
||||
printk("Setting HW addr to : %X%X\n",*((unsigned int *)&dev->dev_addr[0]),*((unsigned int *)&dev->dev_addr[4]));
|
||||
|
||||
((unsigned char*)dev->dev_addr)[7] = (unsigned char)find_inst(dev);
|
||||
|
||||
memcpy((uint8_t *)priv->cx[0].iid6,&nas_IMEI[0],8);
|
||||
|
||||
printk("INIT: init IMEI to IID\n");
|
||||
#endif
|
||||
|
||||
printk("INIT: end\n");
|
||||
return;
|
||||
} // instance value check
|
||||
else {
|
||||
printk("nas_init(): ERROR, Device is NULL!!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int init_module (void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
int err,inst;
|
||||
struct nas_priv *priv;
|
||||
char devicename[100];
|
||||
|
||||
|
||||
// Initialize parameters shared with RRC
|
||||
|
||||
printk("Starting NASMESH, number of IMEI paramters %d, IMEI %X%X\n",m_arg,nas_IMEI[0],nas_IMEI[1]);
|
||||
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
|
||||
#ifdef RTAI //with RTAI you have to indicate which irq# you want
|
||||
|
||||
pdcp_2_nas_irq=rt_request_srq(0, nas_interrupt, NULL);
|
||||
|
||||
#endif
|
||||
|
||||
if (pdcp_2_nas_irq == -EBUSY || pdcp_2_nas_irq == -EINVAL) {
|
||||
printk("[NAS][INIT] No interrupt resource available\n");
|
||||
return -EBUSY;
|
||||
} else
|
||||
printk("[NAS][INIT]: Interrupt %d\n", pdcp_2_nas_irq);
|
||||
|
||||
//rt_startup_irq(RTAI_IRQ);
|
||||
|
||||
//rt_enable_irq(RTAI_IRQ);
|
||||
|
||||
|
||||
#endif //NETLINK
|
||||
|
||||
for (inst=0; inst<NB_INSTANCES_MAX; inst++) {
|
||||
printk("[NAS][INIT] nasmesh_init_module: begin init instance %d\n",inst);
|
||||
|
||||
|
||||
sprintf(devicename,"oai%d",inst);
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
|
||||
nasdev[inst] = alloc_netdev(sizeof(struct nas_priv),devicename, nas_init);
|
||||
#else
|
||||
nasdev[inst] = alloc_netdev(sizeof(struct nas_priv),devicename, NET_NAME_PREDICTABLE, nas_init);
|
||||
#endif
|
||||
priv = netdev_priv(nasdev[inst]);
|
||||
|
||||
if (nasdev[inst]) {
|
||||
nas_mesh_init(inst);
|
||||
//memcpy(nasdev[inst]->dev_addr,&nas_IMEI[0],8);
|
||||
nas_TOOL_imei2iid(nas_IMEI, nasdev[inst]->dev_addr);// IMEI to device address (for stateless autoconfiguration address)
|
||||
nas_TOOL_imei2iid(nas_IMEI, (uint8_t *)priv->cx[0].iid6);
|
||||
// TO HAVE DIFFERENT HW @
|
||||
((unsigned char*)nasdev[inst]->dev_addr)[7] = ((unsigned char*)nasdev[inst]->dev_addr)[7] + (unsigned char)inst + 1;
|
||||
printk("Setting HW addr for INST %d to : %X%X\n",inst,*((unsigned int *)&nasdev[inst]->dev_addr[0]),*((unsigned int *)&nasdev[inst]->dev_addr[4]));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
err= register_netdev(nasdev[inst]);
|
||||
|
||||
if (err) {
|
||||
printk("[NAS][INIT] nasmesh_init_module (inst %d): error %i registering device %s\n", inst,err, nasdev[inst]->name);
|
||||
} else {
|
||||
printk("nasmesh_init_module: registering device %s, ifindex = %d\n\n",nasdev[inst]->name, nasdev[inst]->ifindex);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PDCP_USE_NETLINK
|
||||
|
||||
if ((err=nas_netlink_init()) == -1)
|
||||
printk("[NAS][INIT] NETLINK failed\n");
|
||||
|
||||
printk("[NAS][INIT] NETLINK INIT\n");
|
||||
|
||||
#endif //NETLINK
|
||||
|
||||
return err;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void cleanup_module(void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int inst;
|
||||
|
||||
|
||||
printk("[NAS][CLEANUP]nasmesh_cleanup_module: begin\n");
|
||||
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
|
||||
if (pdcp_2_nas_irq!=-EBUSY) {
|
||||
pdcp_2_nas_irq=0;
|
||||
#ifdef RTAI
|
||||
// V1
|
||||
// rt_free_linux_irq(priv->irq, NULL);
|
||||
// END V1
|
||||
rt_free_srq(pdcp_2_nas_irq);
|
||||
#endif
|
||||
// Start IRQ linux
|
||||
// free_irq(priv->irq, NULL);
|
||||
// End IRQ linux
|
||||
|
||||
}
|
||||
|
||||
#else // NETLINK
|
||||
|
||||
|
||||
|
||||
#endif //NETLINK
|
||||
|
||||
for (inst=0; inst<NB_INSTANCES_MAX; inst++) {
|
||||
#ifdef DEBUG_DEVICE
|
||||
printk("nasmesh_cleanup_module: unregister and free net device instance %d\n",inst);
|
||||
#endif
|
||||
unregister_netdev(nasdev[inst]);
|
||||
nas_teardown(nasdev[inst]);
|
||||
free_netdev(nasdev[inst]);
|
||||
}
|
||||
|
||||
#ifdef PDCP_USE_NETLINK
|
||||
nas_netlink_release();
|
||||
#endif //PDCP_USE_NETLINK
|
||||
printk("nasmesh_cleanup_module: end\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
|
||||
|
||||
#define DRV_NAME "NASMESH"
|
||||
#define DRV_VERSION "3.0.2"DRV_NAME
|
||||
#define DRV_DESCRIPTION "OPENAIR MESH Device Driver"
|
||||
#define DRV_COPYRIGHT "-Copyright(c) GNU GPL Eurecom 2009"
|
||||
#define DRV_AUTHOR "Raymond Knopp, and Navid Nikaein: <firstname.name@eurecom.fr>"DRV_COPYRIGHT
|
||||
|
||||
module_param_array(nas_IMEI,uint,&m_arg,0444);
|
||||
MODULE_PARM_DESC(nas_IMEI,"The IMEI Hardware address (64-bit, decimal nibbles)");
|
||||
|
||||
module_param(nas_is_clusterhead,uint,0444);
|
||||
MODULE_PARM_DESC(nas_is_clusterhead,"The Clusterhead Indicator");
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,1)
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION(DRV_DESCRIPTION);
|
||||
MODULE_AUTHOR(DRV_AUTHOR);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//---------------------------------------------------------------------------
|
||||
//module_init(init_nasmesh);
|
||||
//module_exit(exit_nasmesh);
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
*/
|
||||
Executable
+870
@@ -0,0 +1,870 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
#include "local.h"
|
||||
#include "ioctl.h"
|
||||
#include "proto_extern.h"
|
||||
|
||||
//#include <linux/in.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/checksum.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
|
||||
// Statistic
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_statistic_reply(struct nas_msg_statistic_reply *msgrep,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
msgrep->rx_packets=priv->stats.rx_packets;
|
||||
msgrep->tx_packets=priv->stats.tx_packets;
|
||||
msgrep->rx_bytes=priv->stats.rx_bytes;
|
||||
msgrep->tx_bytes=priv->stats.tx_bytes;
|
||||
msgrep->rx_errors=priv->stats.rx_errors;
|
||||
msgrep->tx_errors=priv->stats.tx_errors;
|
||||
msgrep->rx_dropped=priv->stats.rx_dropped;
|
||||
msgrep->tx_dropped=priv->stats.tx_dropped;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_statistic_request(struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_msg_statistic_reply msgrep;
|
||||
printk("NAS_IOCTL_STATISTIC: stat requested\n");
|
||||
nas_set_msg_statistic_reply(&msgrep,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) {
|
||||
printk("NAS_IOCTL_STATISTIC: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Connections List
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_cx_list_reply(uint8_t *msgrep,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct cx_entity *cx;
|
||||
nasLocalConnectionRef_t lcr;
|
||||
struct nas_msg_cx_list_reply *list;
|
||||
msgrep[0]=NAS_CX_MAX;
|
||||
list=(struct nas_msg_cx_list_reply *)(msgrep+1);
|
||||
|
||||
for(lcr=0; lcr<NAS_CX_MAX; ++lcr) {
|
||||
cx=nas_COMMON_search_cx(lcr,priv);
|
||||
list[lcr].lcr=lcr;
|
||||
list[lcr].state=cx->state;
|
||||
list[lcr].cellid=cx->cellid;
|
||||
list[lcr].iid4=cx->iid4;
|
||||
list[lcr].iid6[0]=cx->iid6[0];
|
||||
list[lcr].iid6[1]=cx->iid6[1];
|
||||
list[lcr].num_rb=cx->num_rb;
|
||||
list[lcr].nsclassifier=cx->nsclassifier;
|
||||
printk("NAS_SET_MSG_CX_LIST_REPLY: nsc=%u\n",cx->nsclassifier);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_cx_list_request(struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t msgrep[NAS_CX_MAX*sizeof(struct nas_msg_cx_list_reply)+1];
|
||||
printk("NAS_IOCTL_CX_LIST: connection list requested\n");
|
||||
nas_set_msg_cx_list_reply(msgrep,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, msgrep, NAS_CX_MAX*sizeof(struct nas_msg_cx_list_reply)+1)) {
|
||||
printk("NAS_IOCTL_CX_LIST: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
printk("NAS_IOCTL_CX_LIST: end\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Connection Establishment
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_cx_establishment_reply(struct nas_msg_cx_establishment_reply *msgrep,
|
||||
struct nas_msg_cx_establishment_request *msgreq,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
struct cx_entity *cx;
|
||||
cx=nas_COMMON_search_cx(msgreq->lcr,priv);
|
||||
|
||||
if (cx!=NULL) {
|
||||
cx->cellid=msgreq->cellid;
|
||||
msgrep->status=nas_mesh_DC_send_cx_establish_request(cx,priv);
|
||||
} else
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTLCR;
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_cx_establishment_request(struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_msg_cx_establishment_request msgreq;
|
||||
struct nas_msg_cx_establishment_reply msgrep;
|
||||
printk("NAS_IOCTL_ESTABLISHMENT: connection establishment requested\n");
|
||||
|
||||
if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) {
|
||||
printk("NAS_IOCTL_CX_ESTABLISHMENT: copy_from_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
nas_set_msg_cx_establishment_reply(&msgrep, &msgreq,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) {
|
||||
printk("NAS_IOCTL_CX_ESTABLISHMENT: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Connection Release
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_cx_release_reply(struct nas_msg_cx_release_reply *msgrep,
|
||||
struct nas_msg_cx_release_request *msgreq,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct cx_entity *cx;
|
||||
cx=nas_COMMON_search_cx(msgreq->lcr,priv);
|
||||
|
||||
if (cx!=NULL)
|
||||
msgrep->status=nas_mesh_DC_send_cx_release_request(cx,priv);
|
||||
else
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTLCR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Request the release of a connection
|
||||
int nas_ioCTL_cx_release_request(struct nas_ioctl *gifr,struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_msg_cx_release_request msgreq;
|
||||
struct nas_msg_cx_release_reply msgrep;
|
||||
|
||||
printk("NAS_IOCTL_CX_RELEASE: connection release requested\n");
|
||||
|
||||
if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) {
|
||||
printk("NAS_IOCTL_CX_RELEASE: copy_from_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
nas_set_msg_cx_release_reply(&msgrep, &msgreq,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) {
|
||||
printk("NAS_IOCTL_CX_RELEASE: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
printk("NAS_IOCTL_CX_RELEASE: end\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Radio Bearer List
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_rb_list_reply(uint8_t *msgrep,
|
||||
struct nas_msg_rb_list_request *msgreq,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct cx_entity *cx;
|
||||
cx=nas_COMMON_search_cx(msgreq->lcr,priv);
|
||||
|
||||
if (cx!=NULL) {
|
||||
uint8_t rbi;
|
||||
struct rb_entity *rb;
|
||||
struct nas_msg_rb_list_reply *list;
|
||||
|
||||
if (cx->num_rb > NAS_LIST_RB_MAX)
|
||||
msgrep[0] = NAS_LIST_RB_MAX;
|
||||
else
|
||||
msgrep[0] = cx->num_rb;
|
||||
|
||||
list=(struct nas_msg_rb_list_reply *)(msgrep+1);
|
||||
|
||||
for (rb=cx->rb, rbi=0; (rb!=NULL)&&(rbi<msgrep[0]); rb=rb->next, ++rbi) {
|
||||
list[rbi].state=rb->state;
|
||||
list[rbi].rab_id=rb->rab_id;
|
||||
list[rbi].sapi=rb->sapi;
|
||||
list[rbi].qos=rb->qos;
|
||||
}
|
||||
} else
|
||||
msgrep[0]=0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_rb_list_request(struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t msgrep[NAS_LIST_RB_MAX*sizeof(struct nas_msg_rb_list_reply)+1];
|
||||
struct nas_msg_rb_list_request msgreq;
|
||||
printk("NAS_IOCTL_RB_LIST: Radio Bearer list requested\n");
|
||||
|
||||
if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) {
|
||||
printk("NAS_IOCTL_RB_LIST: copy_from_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
nas_set_msg_rb_list_reply(msgrep, &msgreq,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, msgrep, NAS_LIST_RB_MAX*sizeof(struct nas_msg_rb_list_reply)+1)) {
|
||||
printk("NAS_IOCTL_RB_LIST: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
printk("NAS_IOCTL_CX_LIST: end\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Radio Bearer Establishment
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_rb_establishment_reply(struct nas_msg_rb_establishment_reply *msgrep,
|
||||
struct nas_msg_rb_establishment_request *msgreq,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// if ((msgreq->rab_id<3)||(msgreq->rab_id>127))
|
||||
if ((msgreq->rab_id<1)||(msgreq->rab_id>MAX_RABS)) // navid : increase the number
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTRABI;
|
||||
else {
|
||||
struct cx_entity *cx;
|
||||
cx=nas_COMMON_search_cx(msgreq->lcr,priv);
|
||||
|
||||
if (cx==NULL)
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTLCR;
|
||||
else {
|
||||
struct rb_entity *rb;
|
||||
rb=nas_COMMON_add_rb(cx, msgreq->rab_id, msgreq->qos);
|
||||
|
||||
if (rb!=NULL) {
|
||||
// rb->cnxid = msgreq->cnxid;
|
||||
// msgrep->status=nas_rg_DC_send_rb_establish_request(cx, rb);
|
||||
} else
|
||||
msgrep->status=-NAS_ERROR_NOMEMORY;
|
||||
|
||||
// msgrep->cnxid = msgreq->cnxid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_rb_establishment_request(struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_msg_rb_establishment_request msgreq;
|
||||
struct nas_msg_rb_establishment_reply msgrep;
|
||||
printk("NAS_IOCTL_RB_ESTABLISHMENT: Radio bearer establishment requested\n");
|
||||
|
||||
if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) {
|
||||
printk("NAS_IOCTL_RB_ESTABLISHMENT: copy_from_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
nas_set_msg_rb_establishment_reply(&msgrep, &msgreq,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) {
|
||||
printk("NAS_IOCTL_RB_ESTABLISHMENT: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Radio Bearer Release
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_rb_release_reply(struct nas_msg_rb_release_reply *msgrep,
|
||||
struct nas_msg_rb_release_request *msgreq,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
if (msgreq->lcr<NAS_CX_MAX) {
|
||||
struct rb_entity *rb;
|
||||
struct cx_entity *cx;
|
||||
cx=nas_COMMON_search_cx(msgreq->lcr,priv);
|
||||
rb=nas_COMMON_search_rb(cx, msgreq->rab_id);
|
||||
|
||||
if (rb!=NULL) {
|
||||
//msgrep->status=nas_rg_DC_send_rb_release_request(cx, rb);
|
||||
} else
|
||||
msgrep->status=-NAS_ERROR_NOTCONNECTED;
|
||||
|
||||
// msgrep->cnxid = msgreq->cnxid;
|
||||
} else
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTLCR;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_rb_release_request(
|
||||
struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_msg_rb_release_request msgreq;
|
||||
struct nas_msg_rb_release_reply msgrep;
|
||||
printk("NAS_IOCTL_RB_RELEASE: Radio bearer release requested\n");
|
||||
|
||||
if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) {
|
||||
printk("NAS_IOCTL_RB_RELEASE: copy_from_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
nas_set_msg_rb_release_reply(&msgrep, &msgreq, priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) {
|
||||
printk("NAS_IOCTL_RB_RELEASE: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Classifier List
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_class_list_reply(
|
||||
uint8_t *msgrep,
|
||||
struct nas_msg_class_list_request *msgreq,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct cx_entity *cx;
|
||||
struct classifier_entity *gc;
|
||||
struct nas_msg_class_list_reply *list;
|
||||
uint8_t cli;
|
||||
list=(struct nas_msg_class_list_reply *)(msgrep+1);
|
||||
|
||||
switch(msgreq->dir) {
|
||||
case NAS_DIRECTION_SEND:
|
||||
cx=nas_COMMON_search_cx(msgreq->lcr,priv);
|
||||
|
||||
if (cx==NULL) {
|
||||
msgrep[0]=0;
|
||||
return;
|
||||
}
|
||||
|
||||
gc=cx->sclassifier[msgreq->dscp];
|
||||
break;
|
||||
|
||||
case NAS_DIRECTION_RECEIVE:
|
||||
cx=NULL;
|
||||
gc=priv->rclassifier[msgreq->dscp];
|
||||
break;
|
||||
|
||||
default:
|
||||
cx=NULL;
|
||||
msgrep[0]=0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (cli=0; (gc!=NULL)&&(cli<NAS_LIST_CLASS_MAX); gc=gc->next, ++cli) {
|
||||
list[cli].classref=gc->classref;
|
||||
list[cli].lcr=msgreq->lcr;
|
||||
list[cli].dir=msgreq->dir;
|
||||
list[cli].dscp=msgreq->dscp;
|
||||
list[cli].rab_id=gc->rab_id;
|
||||
list[cli].version=gc->version;
|
||||
|
||||
switch(gc->version) {
|
||||
case 4:
|
||||
list[cli].saddr.ipv4 = gc->saddr.ipv4;
|
||||
list[cli].daddr.ipv4 = gc->daddr.ipv4;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
list[cli].saddr.ipv6 = gc->saddr.ipv6;
|
||||
list[cli].daddr.ipv6 = gc->daddr.ipv6;
|
||||
break;
|
||||
}
|
||||
|
||||
list[cli].protocol=gc->protocol;
|
||||
list[cli].sport=ntohs(gc->sport);
|
||||
list[cli].dport=ntohs(gc->dport);
|
||||
list[cli].splen=gc->splen;
|
||||
list[cli].dplen=gc->dplen;
|
||||
list[cli].fct=nas_TOOL_invfct(gc);
|
||||
}
|
||||
|
||||
msgrep[0]=cli;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_class_list_request(
|
||||
struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t msgrep[NAS_LIST_CLASS_MAX*sizeof(struct nas_msg_class_list_reply)+1];
|
||||
struct nas_msg_class_list_request msgreq;
|
||||
printk("NAS_IOCTL_CLASS_LIST: classifier list requested\n");
|
||||
|
||||
if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) {
|
||||
printk("NAS_IOCTL_CLASS_LIST: copy_from_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
nas_set_msg_class_list_reply(msgrep, &msgreq,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, msgrep, NAS_LIST_CLASS_MAX*sizeof(struct nas_msg_class_list_reply)+1)) {
|
||||
printk("NAS_IOCTL_CLASS_LIST: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Request the addition of a classifier rule
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_class_add_reply(
|
||||
struct nas_msg_class_add_reply *msgrep,
|
||||
struct nas_msg_class_add_request *msgreq,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct classifier_entity *gc,*gc2;
|
||||
unsigned char *saddr,*daddr;
|
||||
unsigned int *saddr32,*daddr32;
|
||||
|
||||
printk("[NAS][CLASS] nas_set_msg_class_add_reply\n");
|
||||
|
||||
|
||||
if (msgreq->dscp>NAS_DSCP_MAX) {
|
||||
printk("NAS_SET_MSG_CLASS_ADD_REPLY: Incoherent parameter value\n");
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTDSCP;
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgreq->dir==NAS_DIRECTION_SEND) {
|
||||
|
||||
|
||||
struct cx_entity *cx;
|
||||
cx=nas_COMMON_search_cx(msgreq->lcr,priv);
|
||||
|
||||
if (cx!=NULL) {
|
||||
printk("NAS_SET_MSG_CLASS_ADD_REPLY: DSCP/EXP %d, Classref %d, RB %u\n", msgreq->dscp, msgreq->classref,msgreq->rab_id );
|
||||
gc=nas_CLASS_add_sclassifier(cx, msgreq->dscp, msgreq->classref);
|
||||
|
||||
printk("NAS_SET_MSG_CLASS_ADD_REPLY: %p %p\n" , msgreq, gc);
|
||||
|
||||
if (gc==NULL) {
|
||||
msgrep->status=-NAS_ERROR_NOMEMORY;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTLCR;
|
||||
return;
|
||||
}
|
||||
|
||||
gc->rab_id=msgreq->rab_id;
|
||||
|
||||
gc->rb=nas_COMMON_search_rb(cx, gc->rab_id);
|
||||
printk("NAS_SET_MSG_CLASS_ADD_REPLY: gc_rb %p %u \n", gc->rb, gc->rab_id);
|
||||
} else {
|
||||
if (msgreq->dir==NAS_DIRECTION_RECEIVE) {
|
||||
gc=nas_CLASS_add_rclassifier(msgreq->dscp,
|
||||
msgreq->classref,
|
||||
priv);
|
||||
|
||||
if (gc==NULL) {
|
||||
msgrep->status=-NAS_ERROR_NOMEMORY;
|
||||
return;
|
||||
}
|
||||
|
||||
gc->rab_id=msgreq->rab_id;
|
||||
|
||||
} else {
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTDIR;
|
||||
return;
|
||||
}
|
||||
|
||||
for (gc2 = priv->rclassifier[msgreq->dscp]; gc2!=NULL ; gc2 = gc2->next)
|
||||
printk("[NAS][CLASS] Add Receive Classifier dscp %d: rab_id %d (%p,next %p)\n",msgreq->dscp,gc2->rab_id,gc2,gc2->next);
|
||||
}
|
||||
|
||||
printk("[NAS][CLASS] Getting addresses ...\n");
|
||||
|
||||
nas_TOOL_fct(gc, msgreq->fct);
|
||||
gc->version=msgreq->version;
|
||||
|
||||
switch(gc->version) {
|
||||
case 4:
|
||||
gc->saddr.ipv4=msgreq->saddr.ipv4;
|
||||
gc->daddr.ipv4=msgreq->daddr.ipv4;
|
||||
|
||||
|
||||
|
||||
// #ifdef NAS_CLASS_DEBUG
|
||||
saddr = (unsigned char *)&gc->saddr.ipv4;
|
||||
daddr = (unsigned char *)&gc->daddr.ipv4;
|
||||
|
||||
printk("[NAS][CLASS] Adding IPv4 %d.%d.%d.%d -> %d.%d.%d.%d\n",
|
||||
saddr[0],saddr[1],saddr[2],saddr[3],
|
||||
daddr[0],daddr[1],daddr[2],daddr[3]);
|
||||
|
||||
|
||||
|
||||
//#endif
|
||||
gc->splen=msgreq->splen;
|
||||
gc->dplen=msgreq->dplen;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
memcpy(&gc->saddr.ipv6,&msgreq->saddr.ipv6,16);
|
||||
memcpy(&gc->daddr.ipv6,&msgreq->daddr.ipv6,16);
|
||||
|
||||
saddr32 = (unsigned int *)&gc->saddr.ipv6;
|
||||
daddr32 = (unsigned int *)&gc->daddr.ipv6;
|
||||
|
||||
printk("[NAS][CLASS] Adding IPv6 %X:%X:%X:%X -> %X.%X.%X.%X\n",
|
||||
saddr32[0],saddr32[1],saddr32[2],saddr32[3],
|
||||
daddr32[0],daddr32[1],daddr32[2],daddr32[3]);
|
||||
gc->splen=msgreq->splen;
|
||||
gc->dplen=msgreq->dplen;
|
||||
break;
|
||||
|
||||
case NAS_MPLS_VERSION_CODE:
|
||||
|
||||
printk("[NAS][CLASS] Adding MPLS label %d with exp %d\n",
|
||||
msgreq->daddr.mpls_label,msgreq->dscp);
|
||||
gc->daddr.mpls_label = msgreq->daddr.mpls_label;
|
||||
|
||||
break;
|
||||
|
||||
case 0:
|
||||
gc->saddr.ipv6.s6_addr32[0]=0;
|
||||
gc->daddr.ipv6.s6_addr32[1]=0;
|
||||
gc->saddr.ipv6.s6_addr32[2]=0;
|
||||
gc->daddr.ipv6.s6_addr32[3]=0;
|
||||
gc->splen=0;
|
||||
gc->dplen=0;
|
||||
break;
|
||||
|
||||
default:
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTVERSION;
|
||||
kfree(gc);
|
||||
return;
|
||||
}
|
||||
|
||||
gc->protocol=msgreq->protocol;
|
||||
gc->protocol_message_type=msgreq->protocol_message_type;
|
||||
gc->sport=htons(msgreq->sport);
|
||||
gc->dport=htons(msgreq->dport);
|
||||
msgrep->status=0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_class_add_request(struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_msg_class_add_request msgreq;
|
||||
struct nas_msg_class_add_reply msgrep;
|
||||
|
||||
|
||||
printk("NAS_IOCTL_CLASS_ADD: Add classifier components requested\n");
|
||||
printk("NAS_IOCTL_CLASS_ADD: size of gifr msg %zd\n", sizeof(gifr->msg));
|
||||
|
||||
|
||||
if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) {
|
||||
printk("NAS_IOCTL_CLASS_ADD: copy_from_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
nas_set_msg_class_add_reply(&msgrep, &msgreq,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) {
|
||||
printk("NAS_IOCTL_CLASS_ADD: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Request the deletion of a classifier rule
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_class_del_reply(struct nas_msg_class_del_reply *msgrep,
|
||||
struct nas_msg_class_del_request *msgreq,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
if (msgreq->dscp>NAS_DSCP_DEFAULT) {
|
||||
printk("NAS_SET_MSG_CLASS_DEL_REPLY: Incoherent parameter value\n");
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTDSCP;
|
||||
return;
|
||||
}
|
||||
|
||||
if (msgreq->dir==NAS_DIRECTION_SEND) {
|
||||
struct cx_entity *cx;
|
||||
cx=nas_COMMON_search_cx(msgreq->lcr,priv);
|
||||
|
||||
if (cx!=NULL)
|
||||
nas_CLASS_del_sclassifier(cx, msgreq->dscp, msgreq->classref);
|
||||
else {
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTLCR;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (msgreq->dir==NAS_DIRECTION_RECEIVE)
|
||||
nas_CLASS_del_rclassifier(msgreq->dscp, msgreq->classref,priv);
|
||||
else {
|
||||
msgrep->status=-NAS_ERROR_NOTCORRECTDIR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
msgrep->status=0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_class_del_request(struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_msg_class_del_request msgreq;
|
||||
struct nas_msg_class_del_reply msgrep;
|
||||
printk("NAS_IOCTL_CLASS_DEL: Del classifier components requested\n");
|
||||
|
||||
if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) {
|
||||
printk("NAS_IOCTL_CLASS_DEL: copy_from_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
nas_set_msg_class_del_reply(&msgrep, &msgreq,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) {
|
||||
printk("NAS_IOCTL_CLASS_DEL: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Measurement
|
||||
// Messages for Measurement transfer
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_measure_reply(struct nas_msg_measure_reply *msgrep, struct nas_msg_measure_request *msgreq,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct cx_entity *cx;
|
||||
int lcr=0; // Temp lcr->mt =0
|
||||
int i;
|
||||
|
||||
cx=nas_COMMON_search_cx(lcr,priv);
|
||||
|
||||
if (cx!=NULL) {
|
||||
msgrep->num_cells = cx->num_measures;
|
||||
|
||||
for (i=0; i<cx->num_measures; i++) {
|
||||
msgrep-> measures[i].cell_id = cx->meas_cell_id[i];
|
||||
msgrep-> measures[i].level = cx->meas_level[i];
|
||||
msgrep-> measures[i].provider_id = cx->provider_id[i];
|
||||
}
|
||||
|
||||
msgrep->signal_lost_flag = 0;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_measure_request(struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_msg_measure_request msgreq;
|
||||
struct nas_msg_measure_reply msgrep;
|
||||
printk("NAS_IOCTL_MEASURE: Measurement requested\n");
|
||||
|
||||
if (copy_from_user(&msgreq, gifr->msg, sizeof(msgreq))) {
|
||||
printk("NAS_IOCTL_MEASURE: copy_from_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
nas_set_msg_measure_reply(&msgrep, &msgreq,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) {
|
||||
printk("NAS_IOCTL_MEASURE: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// IMEI
|
||||
// Messages for IMEI transfer
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_set_msg_imei_reply(struct nas_msg_l2id_reply *msgrep,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct cx_entity *cx;
|
||||
int lcr=0; // Temp lcr->mt =0
|
||||
int i;
|
||||
|
||||
cx=nas_COMMON_search_cx(lcr,priv);
|
||||
|
||||
if (cx!=NULL) {
|
||||
msgrep->l2id[0] = cx->iid6[0];
|
||||
msgrep->l2id[1] = cx->iid6[1];
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_ioCTL_imei_request(struct nas_ioctl *gifr,
|
||||
struct nas_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_msg_l2id_reply msgrep;
|
||||
printk("NAS_IOCTL_IMEI: IMEI requested\n");
|
||||
nas_set_msg_imei_reply(&msgrep,priv);
|
||||
|
||||
if (copy_to_user(gifr->msg, &msgrep, sizeof(msgrep))) {
|
||||
printk("NAS_IOCTL_IMEI: copy_to_user failure\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IOCTL command
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_CTL_ioctl(struct net_device *dev,
|
||||
struct ifreq *ifr,
|
||||
int cmd)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct nas_ioctl *gifr;
|
||||
struct nas_priv *priv=netdev_priv(dev);
|
||||
|
||||
int r;
|
||||
|
||||
// printk("NAS_CTL_IOCTL: begin ioctl for instance %d\n",find_inst(dev));
|
||||
|
||||
switch(cmd) {
|
||||
case NAS_IOCTL_RRM:
|
||||
gifr=(struct nas_ioctl *)ifr;
|
||||
|
||||
switch(gifr->type) {
|
||||
case NAS_MSG_STATISTIC_REQUEST:
|
||||
r=nas_ioCTL_statistic_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_CX_ESTABLISHMENT_REQUEST:
|
||||
r=nas_ioCTL_cx_establishment_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_CX_RELEASE_REQUEST:
|
||||
r=nas_ioCTL_cx_release_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_CX_LIST_REQUEST:
|
||||
r=nas_ioCTL_cx_list_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_RB_ESTABLISHMENT_REQUEST:
|
||||
r=nas_ioCTL_rb_establishment_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_RB_RELEASE_REQUEST:
|
||||
r= nas_ioCTL_rb_release_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_RB_LIST_REQUEST:
|
||||
r=nas_ioCTL_rb_list_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_CLASS_ADD_REQUEST:
|
||||
r=nas_ioCTL_class_add_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_CLASS_LIST_REQUEST:
|
||||
r=nas_ioCTL_class_list_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_CLASS_DEL_REQUEST:
|
||||
r=nas_ioCTL_class_del_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_MEAS_REQUEST:
|
||||
r=nas_ioCTL_measure_request(gifr,priv);
|
||||
break;
|
||||
|
||||
case NAS_MSG_IMEI_REQUEST:
|
||||
r=nas_ioCTL_imei_request(gifr,priv);
|
||||
break;
|
||||
|
||||
default:
|
||||
// printk("NAS_IOCTL_RRM: unkwon request type, type=%x\n", gifr->type);
|
||||
r=-EFAULT;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
// printk("NAS_CTL_IOCTL: Unknown ioctl command, cmd=%x\n", cmd);
|
||||
r=-EFAULT;
|
||||
}
|
||||
|
||||
// printk("NAS_CTL_IOCTL: end\n");
|
||||
return r;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void nas_CTL_send(struct sk_buff *skb,
|
||||
struct cx_entity *cx,
|
||||
struct classifier_entity *gc)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
printk("NAS_CTL_SEND - void \n");
|
||||
}
|
||||
|
||||
Executable
+233
@@ -0,0 +1,233 @@
|
||||
/***************************************************************************
|
||||
nas_iocontrol.h - description
|
||||
-------------------
|
||||
copyright : (C) 2002 by Eurecom
|
||||
email : michelle.wetterwald@eurecom.fr
|
||||
yan.moret@eurecom.fr
|
||||
knopp@eurecom.fr
|
||||
***************************************************************************
|
||||
|
||||
***************************************************************************/
|
||||
#ifndef NAS_CTL_H
|
||||
#define NAS_CTL_H
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <asm/types.h>
|
||||
#include <linux/udp.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
|
||||
//#include <linux/ipv6.h>
|
||||
|
||||
#define NAS_MSG_MAXLEN 1100/// change???
|
||||
|
||||
// type of CTL message
|
||||
#define NAS_MSG_STATISTIC_REQUEST 1
|
||||
#define NAS_MSG_STATISTIC_REPLY 2
|
||||
#define NAS_MSG_ECHO_REQUEST 3
|
||||
#define NAS_MSG_ECHO_REPLY 4
|
||||
#define NAS_MSG_CX_ESTABLISHMENT_REQUEST 5
|
||||
#define NAS_MSG_CX_ESTABLISHMENT_REPLY 6
|
||||
#define NAS_MSG_CX_RELEASE_REQUEST 7
|
||||
#define NAS_MSG_CX_RELEASE_REPLY 8
|
||||
#define NAS_MSG_CX_LIST_REQUEST 9
|
||||
#define NAS_MSG_CX_LIST_REPLY 10
|
||||
#define NAS_MSG_RB_ESTABLISHMENT_REQUEST 11
|
||||
#define NAS_MSG_RB_ESTABLISHMENT_REPLY 12
|
||||
#define NAS_MSG_RB_RELEASE_REQUEST 13
|
||||
#define NAS_MSG_RB_RELEASE_REPLY 14
|
||||
#define NAS_MSG_RB_LIST_REQUEST 15
|
||||
#define NAS_MSG_RB_LIST_REPLY 16
|
||||
#define NAS_MSG_CLASS_ADD_REQUEST 17
|
||||
#define NAS_MSG_CLASS_ADD_REPLY 18
|
||||
#define NAS_MSG_CLASS_DEL_REQUEST 19
|
||||
#define NAS_MSG_CLASS_DEL_REPLY 20
|
||||
#define NAS_MSG_CLASS_LIST_REQUEST 21
|
||||
#define NAS_MSG_CLASS_LIST_REPLY 22
|
||||
#define NAS_MSG_MEAS_REQUEST 23
|
||||
#define NAS_MSG_MEAS_REPLY 24
|
||||
#define NAS_MSG_IMEI_REQUEST 25
|
||||
#define NAS_MSG_IMEI_REPLY 26
|
||||
|
||||
// Max number of entry of a message list
|
||||
#define NAS_LIST_CX_MAX 32
|
||||
#define NAS_LIST_RB_MAX 32
|
||||
#define NAS_LIST_CLASS_MAX 32
|
||||
|
||||
typedef unsigned short nasMsgType_t;
|
||||
|
||||
struct nas_ioctl {
|
||||
char name[IFNAMSIZ];
|
||||
nasMsgType_t type;
|
||||
char *msg;
|
||||
};
|
||||
|
||||
struct nas_msg_statistic_reply {
|
||||
unsigned int rx_packets;
|
||||
unsigned int tx_packets;
|
||||
unsigned int rx_bytes;
|
||||
unsigned int tx_bytes;
|
||||
unsigned int rx_errors;
|
||||
unsigned int tx_errors;
|
||||
unsigned int rx_dropped;
|
||||
unsigned int tx_dropped;
|
||||
};
|
||||
|
||||
struct nas_msg_cx_list_reply {
|
||||
nasLocalConnectionRef_t lcr; // Local Connection reference
|
||||
unsigned char state;
|
||||
nasCellID_t cellid; // cell identification
|
||||
unsigned int iid6[2]; // IPv6 interface identification
|
||||
unsigned char iid4; // IPv4 interface identification
|
||||
unsigned short num_rb;
|
||||
unsigned short nsclassifier;
|
||||
};
|
||||
struct nas_msg_cx_establishment_reply {
|
||||
int status;
|
||||
};
|
||||
struct nas_msg_cx_establishment_request {
|
||||
nasLocalConnectionRef_t lcr; // Local Connection reference
|
||||
nasCellID_t cellid; // Cell identification
|
||||
};
|
||||
struct nas_msg_cx_release_reply {
|
||||
int status;
|
||||
};
|
||||
struct nas_msg_cx_release_request {
|
||||
nasLocalConnectionRef_t lcr; // Local Connection reference
|
||||
};
|
||||
|
||||
struct nas_msg_rb_list_reply {
|
||||
nasRadioBearerId_t rab_id;
|
||||
nasSapId_t sapi;
|
||||
nasQoSTrafficClass_t qos;
|
||||
unsigned char state;
|
||||
};
|
||||
struct nas_msg_rb_list_request {
|
||||
nasLocalConnectionRef_t lcr; // Local Connection reference
|
||||
};
|
||||
struct nas_msg_rb_establishment_reply {
|
||||
int status;
|
||||
};
|
||||
struct nas_msg_rb_establishment_request {
|
||||
nasLocalConnectionRef_t lcr; // Local Connection reference
|
||||
nasRadioBearerId_t rab_id;
|
||||
nasQoSTrafficClass_t qos;
|
||||
};
|
||||
|
||||
struct nas_msg_rb_release_reply {
|
||||
int status;
|
||||
};
|
||||
struct nas_msg_rb_release_request {
|
||||
nasLocalConnectionRef_t lcr; // Local Connection reference
|
||||
nasRadioBearerId_t rab_id;
|
||||
};
|
||||
/*
|
||||
struct saddr {
|
||||
|
||||
struct in6_addr ipv6;
|
||||
unsigned int ipv4;
|
||||
};
|
||||
|
||||
struct daddr {
|
||||
|
||||
struct in6_addr ipv6;
|
||||
unsigned int ipv4;
|
||||
unsigned int mpls_label;
|
||||
};
|
||||
*/
|
||||
struct nas_msg_class_add_request {
|
||||
nasLocalConnectionRef_t lcr; // Local Connection reference
|
||||
nasRadioBearerId_t rab_id;
|
||||
nasRadioBearerId_t rab_id_rx;
|
||||
unsigned char dir; // direction (send or receive, forward)
|
||||
unsigned char dscp; // codepoint
|
||||
unsigned char fct;
|
||||
unsigned short classref;
|
||||
unsigned char version;
|
||||
|
||||
//struct daddr daddr;
|
||||
//struct saddr saddr;
|
||||
|
||||
unsigned char splen; // prefix length
|
||||
|
||||
union {
|
||||
struct in6_addr ipv6;
|
||||
|
||||
// begin navid
|
||||
//in_addr_t ipv4;
|
||||
unsigned int ipv4;
|
||||
//end navid
|
||||
|
||||
unsigned int mpls_label;
|
||||
} daddr; // IP destination address
|
||||
|
||||
union {
|
||||
struct in6_addr ipv6;
|
||||
|
||||
// begin navid
|
||||
//in_addr_t ipv4;
|
||||
unsigned int ipv4;
|
||||
//end navid
|
||||
|
||||
} saddr; // IP source address
|
||||
|
||||
|
||||
unsigned char dplen; // prefix length
|
||||
|
||||
unsigned char protocol; //!< transport layer protocol type (ANY,TCP,UDP,ICMPv4,ICMPv6)
|
||||
unsigned char protocol_message_type; //!< transport layer protocol message (ROUTER_ADV, ROUTER_SOLL, etc.)
|
||||
unsigned short sport; //!< source port
|
||||
unsigned short dport; //!< destination port
|
||||
};
|
||||
|
||||
struct nas_msg_class_add_reply {
|
||||
int status;
|
||||
};
|
||||
struct nas_msg_class_del_request {
|
||||
nasLocalConnectionRef_t lcr; // Local Connection reference
|
||||
unsigned char dir; // direction (send or receive)
|
||||
unsigned char dscp; // codepoint
|
||||
unsigned short classref;
|
||||
};
|
||||
struct nas_msg_class_del_reply {
|
||||
int status;
|
||||
};
|
||||
#define nas_msg_class_list_reply nas_msg_class_add_request
|
||||
struct nas_msg_class_list_request {
|
||||
nasLocalConnectionRef_t lcr; // Local Connection reference
|
||||
unsigned char dir;
|
||||
unsigned char dscp;
|
||||
};
|
||||
|
||||
|
||||
// Messages for Measurement transfer - MW 01/04/2005
|
||||
typedef unsigned int nioctlProviderId_t;
|
||||
typedef unsigned short nioctlSignalLoss_t;
|
||||
typedef struct nioctlMeasures {
|
||||
nasCellID_t cell_id;
|
||||
nasSigLevel_t level;
|
||||
nioctlProviderId_t provider_id;
|
||||
} nioctlMeasures_t;
|
||||
|
||||
struct nas_msg_measure_request {
|
||||
nasNumRGsMeas_t num_cells;
|
||||
nasCellID_t cellid[MAX_MEASURE_NB]; // Cell identification
|
||||
unsigned short num_providers;
|
||||
nioctlProviderId_t provider_id[MAX_MEASURE_NB]; // Provider identification
|
||||
};
|
||||
struct nas_msg_measure_reply {
|
||||
nasNumRGsMeas_t num_cells;
|
||||
nioctlMeasures_t measures[MAX_MEASURE_NB];
|
||||
nioctlSignalLoss_t signal_lost_flag;
|
||||
};
|
||||
|
||||
// Messages for Measurement transfer - MW 01/04/2005
|
||||
typedef unsigned int nioctlL2Id_t[2];
|
||||
|
||||
struct nas_msg_l2id_reply {
|
||||
nioctlL2Id_t l2id;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Executable
+193
@@ -0,0 +1,193 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
/***************************************************************************
|
||||
local.h - description
|
||||
-------------------
|
||||
copyright : (C) 2002 by Eurecom
|
||||
email : navid.nikaein@eurecom.fr
|
||||
lionel.gauthier@eurecom.fr
|
||||
knopp@eurecom.fr
|
||||
***************************************************************************
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef LOCAL_H
|
||||
#define 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 "rrc_nas_primitives.h"
|
||||
//#include "rrc_sap.h"
|
||||
|
||||
#define PDCP2PDCP_USE_RT_FIFO 21
|
||||
#define NAS2PDCP_FIFO 22
|
||||
|
||||
#include "constant.h"
|
||||
#include "sap.h"
|
||||
#include "rrc_nas_primitives.h"
|
||||
#include "COMMON/platform_types.h"
|
||||
|
||||
struct rb_entity {
|
||||
nasRadioBearerId_t rab_id;
|
||||
nasSapId_t sapi;
|
||||
nasQoSTrafficClass_t qos;
|
||||
uint8_t state;
|
||||
uint8_t retry;
|
||||
uint32_t countimer;
|
||||
struct rb_entity *next;
|
||||
};
|
||||
|
||||
struct cx_entity {
|
||||
int sap[NAS_SAPI_CX_MAX];
|
||||
uint8_t state; // state of the connection
|
||||
nasLocalConnectionRef_t lcr; // Local connection reference
|
||||
nasCellID_t cellid; // cell identification
|
||||
uint32_t countimer; // timeout's counter
|
||||
uint8_t retry; // number of retransmission
|
||||
struct classifier_entity *sclassifier[NAS_DSCP_MAX]; // send classifier;
|
||||
struct classifier_entity *fclassifier[NAS_DSCP_MAX]; // send classifier;
|
||||
uint16_t nsclassifier;
|
||||
uint16_t nfclassifier;
|
||||
uint32_t iid6[2]; // IPv6 interface identification
|
||||
uint8_t iid4; // IPv4 interface identification
|
||||
struct rb_entity *rb;
|
||||
uint16_t num_rb;
|
||||
int lastRRCprimitive;
|
||||
//measures
|
||||
int req_prov_id[MAX_MEASURE_NB];
|
||||
int num_measures;
|
||||
int meas_cell_id[MAX_MEASURE_NB];
|
||||
int meas_level[MAX_MEASURE_NB];
|
||||
int provider_id[MAX_MEASURE_NB];
|
||||
|
||||
};
|
||||
|
||||
struct classifier_entity {
|
||||
uint32_t classref;
|
||||
struct classifier_entity *next;
|
||||
uint8_t version;
|
||||
union {
|
||||
struct in6_addr ipv6;
|
||||
uint32_t ipv4;
|
||||
} saddr; // IP source address
|
||||
uint8_t splen; // prefix length
|
||||
union {
|
||||
struct in6_addr ipv6;
|
||||
uint32_t ipv4;
|
||||
unsigned int mpls_label;
|
||||
} daddr; // IP destination address
|
||||
uint8_t dplen; // prefix length
|
||||
uint8_t protocol; // high layer protocol type
|
||||
unsigned char protocol_message_type;
|
||||
uint16_t sport; // source port
|
||||
uint16_t dport; // destination port
|
||||
struct rb_entity *rb; //pointer to rb_entity for sending function or receiving in case of forwarding rule
|
||||
struct rb_entity *rb_rx; //pointer to rb_entity for receiving (in case of forwarding rule)
|
||||
nasRadioBearerId_t rab_id; // RAB identification for sending
|
||||
nasRadioBearerId_t rab_id_rx; // RAB identification for receiving (in case of forwarding rule)
|
||||
void (*fct)(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst);
|
||||
};
|
||||
|
||||
|
||||
|
||||
//#define NAS_RETRY_LIMIT_DEFAULT 5
|
||||
|
||||
struct nas_priv {
|
||||
int irq;
|
||||
struct timer_list timer;
|
||||
spinlock_t lock;
|
||||
struct net_device_stats stats;
|
||||
uint8_t retry_limit;
|
||||
uint32_t timer_establishment;
|
||||
uint32_t timer_release;
|
||||
struct cx_entity cx[NAS_CX_MAX];
|
||||
struct classifier_entity *rclassifier[NAS_DSCP_MAX]; // receive classifier
|
||||
uint16_t nrclassifier;
|
||||
int sap[NAS_SAPI_MAX];
|
||||
struct sock *nl_sk;
|
||||
uint8_t nlmsg[NAS_MAX_LENGTH+sizeof(struct nlmsghdr)];
|
||||
uint8_t xbuffer[NAS_MAX_LENGTH]; // transmition buffer
|
||||
uint8_t rbuffer[NAS_MAX_LENGTH]; // reception buffer
|
||||
};
|
||||
|
||||
struct ipversion {
|
||||
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
||||
uint8_t reserved:4,
|
||||
version:4;
|
||||
#else
|
||||
uint8_t version:4,
|
||||
reserved:4;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct pdcp_data_req_header_s {
|
||||
rb_id_t rb_id;
|
||||
sdu_size_t data_size;
|
||||
signed int inst;
|
||||
ip_traffic_type_t traffic_type;
|
||||
} pdcp_data_req_header_t;
|
||||
|
||||
typedef struct pdcp_data_ind_header_s {
|
||||
rb_id_t rb_id;
|
||||
sdu_size_t data_size;
|
||||
signed int inst;
|
||||
ip_traffic_type_t dummy_traffic_type;
|
||||
} pdcp_data_ind_header_t;
|
||||
|
||||
extern struct net_device *nasdev[NB_INSTANCES_MAX];
|
||||
//extern int bytes_wrote;
|
||||
//extern int bytes_read;
|
||||
|
||||
extern uint8_t NAS_NULL_IMEI[14];
|
||||
|
||||
//global variables shared with RRC
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
extern int pdcp_2_nas_irq;
|
||||
#endif
|
||||
//extern uint8_t nas_IMEI[14];
|
||||
|
||||
#endif
|
||||
Executable
+1025
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,220 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
/*! \file netlink.c
|
||||
* \brief establish a netlink
|
||||
* \author Navid Nikaein, Lionel Gauthier, and Raymond knopp
|
||||
* \company Eurecom
|
||||
* \email:navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr, knopp@eurecom.fr
|
||||
*/
|
||||
|
||||
//#include <linux/config.h>
|
||||
#include <linux/version.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"
|
||||
//#include "platform_constants.h"
|
||||
|
||||
//#define NETLINK_DEBUG 1
|
||||
|
||||
|
||||
#define OAI_IP_DRIVER_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 *);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
|
||||
struct netlink_kernel_cfg oai_netlink_cfg;
|
||||
#endif
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// 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;
|
||||
int j;
|
||||
|
||||
if (skb) {
|
||||
|
||||
#ifdef NETLINK_DEBUG
|
||||
printk("[NAS][NETLINK] Received socket from PDCP\n");
|
||||
#endif //NETLINK_DEBUG
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
|
||||
nas_COMMON_QOS_receive(nlh);
|
||||
|
||||
//kfree_skb(skb); // not required,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int nas_netlink_init()
|
||||
{
|
||||
|
||||
printk("[NAS][NETLINK] Running init ...\n");
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
|
||||
oai_netlink_cfg.groups = 0;
|
||||
oai_netlink_cfg.input = nas_nl_data_ready;
|
||||
oai_netlink_cfg.cb_mutex = &nasmesh_mutex;
|
||||
oai_netlink_cfg.bind = NULL;
|
||||
|
||||
nas_nl_sk = netlink_kernel_create(
|
||||
&init_net,
|
||||
OAI_IP_DRIVER_NETLINK_ID,
|
||||
# if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
|
||||
THIS_MODULE,
|
||||
# endif
|
||||
&oai_netlink_cfg);
|
||||
#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
|
||||
nas_nl_sk = netlink_kernel_create(
|
||||
&init_net,
|
||||
OAI_IP_DRIVER_NETLINK_ID,
|
||||
0,
|
||||
nas_nl_data_ready,
|
||||
&nasmesh_mutex, // NULL
|
||||
THIS_MODULE);
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
|
||||
|
||||
if (nas_nl_sk == NULL) {
|
||||
|
||||
printk("[NAS][NETLINK] netlink_kernel_create failed \n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void nas_netlink_release(void)
|
||||
{
|
||||
|
||||
exit_netlink_thread=1;
|
||||
printk("[NAS][NETLINK] Releasing netlink socket\n");
|
||||
|
||||
if(nas_nl_sk) {
|
||||
netlink_kernel_release(nas_nl_sk); //or skb->sk
|
||||
|
||||
}
|
||||
|
||||
// printk("[NAS][NETLINK] Removing netlink_rx_thread\n");
|
||||
//kthread_stop(netlink_rx_thread);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int nas_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("[NAS][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 */
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
|
||||
NETLINK_CB(nl_skb).portid = 0;
|
||||
#else
|
||||
NETLINK_CB(nl_skb).pid = 0;
|
||||
#endif
|
||||
|
||||
#ifdef NETLINK_DEBUG
|
||||
printk("[NAS][NETLINK] In nas_netlink_send, nl_skb %p, nl_sk %x, nlh %p, nlh->nlmsg_len %d (OAI_IP_DRIVER_NETLINK_ID %d)\n",
|
||||
nl_skb,nas_nl_sk,nlh,nlh->nlmsg_len,
|
||||
OAI_IP_DRIVER_NETLINK_ID);
|
||||
#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("[NAS][NETLINK] SEND status is %d\n",status);
|
||||
return(0);
|
||||
} else {
|
||||
#ifdef NETLINK_DEBUG
|
||||
printk("[NAS][NETLINK] SEND status is %d\n",status);
|
||||
#endif
|
||||
return len;
|
||||
}
|
||||
} else {
|
||||
printk("[NAS][SEND] socket is NULL\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
nlmsg_failure: // Used by NLMSG_PUT
|
||||
if (nl_skb)
|
||||
kfree_skb(nl_skb);
|
||||
*/
|
||||
|
||||
}
|
||||
Executable
+326
@@ -0,0 +1,326 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
/***************************************************************************
|
||||
nas_proto_extern.h - description
|
||||
-------------------
|
||||
copyright : (C) 2002 by Eurecom
|
||||
email : navid.nikaein@eurecom.fr
|
||||
lionel.gauthier@eurecom.fr
|
||||
knopp@eurecom.fr
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _NAS_PROTO_H
|
||||
#define _NAS_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 "rrc_nas_primitives.h"
|
||||
//#include "protocol_vars_extern.h"
|
||||
//#include "as_sap.h"
|
||||
//#include "rrc_qos.h"
|
||||
//#include "rrc_sap.h"
|
||||
|
||||
#include "local.h"
|
||||
|
||||
// device.c
|
||||
|
||||
|
||||
/** @defgroup _nas_mesh_impl_ NAS Mesh Network Device
|
||||
* @ingroup _ref_implementation_
|
||||
* @{
|
||||
\fn int 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 find_inst(struct net_device *dev);
|
||||
|
||||
// nas_common.c
|
||||
/**
|
||||
\fn void nas_COMMON_receive(unsigned short dlen, void* pdcp_sdu,int inst,struct classifier_entity *rclass,nasRadioBearerId_t rb_id)
|
||||
\brief Receive data from FIFO (QOS)
|
||||
@param dlen Length of SDU in bytes
|
||||
@param pdcp_sdu Pointer to received SDU
|
||||
@param inst Instance number
|
||||
@param rclass RX Classifier entity
|
||||
@param rb_id Radio Bearer Id
|
||||
*/
|
||||
void nas_COMMON_receive(unsigned short dlen,
|
||||
void *pdcp_sdu,
|
||||
int inst,
|
||||
struct classifier_entity *rclass,
|
||||
nasRadioBearerId_t rb_id);
|
||||
|
||||
/**
|
||||
\fn void nas_COMMON_QOS_send(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 cx pointer to connection entity for SDU
|
||||
@param gc pointer to classifier entity for SDU
|
||||
@param inst device instance
|
||||
*/
|
||||
void nas_COMMON_QOS_send(struct sk_buff *skb,
|
||||
struct cx_entity *cx,
|
||||
struct classifier_entity *gc,int inst);
|
||||
|
||||
/**
|
||||
\fn void nas_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst)
|
||||
\brief Delete the data
|
||||
@param skb pointer to socket buffer
|
||||
@param cx pointer to connection entity for SDU
|
||||
@param gc pointer to classifier entity for SDU
|
||||
@param inst device instance
|
||||
*/
|
||||
void nas_COMMON_del_send(struct sk_buff *skb,
|
||||
struct cx_entity *cx,
|
||||
struct classifier_entity *gc,int inst);
|
||||
|
||||
#ifndef PDCP_USE_NETLINK
|
||||
/**
|
||||
\fn void nas_COMMON_QOS_receive()
|
||||
\brief Retrieve PDU from PDCP for connection
|
||||
*/
|
||||
void nas_COMMON_QOS_receive(void);
|
||||
#endif //PDCP_USE_NETLINK
|
||||
|
||||
/**
|
||||
\fn struct rb_entity *nas_COMMON_add_rb(struct cx_entity *cx, nasRadioBearerId_t rabi, nasQoSTrafficClass_t qos)
|
||||
\brief Add a radio-bearer descriptor
|
||||
@param cx pointer to connection entity
|
||||
@param rabi radio-bearer index
|
||||
@param qos NAS QOS traffic class
|
||||
*/
|
||||
struct rb_entity *nas_COMMON_add_rb(
|
||||
struct cx_entity *cx, nasRadioBearerId_t rabi,
|
||||
nasQoSTrafficClass_t qos);
|
||||
|
||||
/**
|
||||
\fn struct rb_entity *nas_COMMON_search_rb(struct cx_entity *cx, nasRadioBearerId_t rabi)
|
||||
\brief Search for a radio-bearer entity for a particular connection and radio-bearer index
|
||||
@param cx pointer to connection entity
|
||||
@param rabi radio-bearer index
|
||||
@returns A pointer to the radio-bearer entity
|
||||
*/
|
||||
struct rb_entity *nas_COMMON_search_rb(
|
||||
struct cx_entity *cx, nasRadioBearerId_t rabi);
|
||||
|
||||
/**
|
||||
\fn struct cx_entity *nas_COMMON_search_cx(nasLocalConnectionRef_t lcr,struct nas_priv *gpriv)
|
||||
\brief Search for a connection entity based on its index and pointer to nas_priv
|
||||
@param lcr index of local connection
|
||||
@param gpriv pointer to nas_priv for device
|
||||
@returns A pointer to the connection entity
|
||||
*/
|
||||
struct cx_entity *nas_COMMON_search_cx(
|
||||
nasLocalConnectionRef_t lcr,
|
||||
struct nas_priv *gpriv);
|
||||
|
||||
/**
|
||||
\fn struct classifier_entity *nas_COMMON_search_class_for_rb(nasRadioBearerId_t rab_id,struct nas_priv *priv)
|
||||
\brief Search for an RX classifier entity based on a RB id and pointer to nas_priv
|
||||
@param rab_id Index of RAB for search
|
||||
@param priv pointer to nas_priv for device
|
||||
@returns A pointer to the corresponding RX classifier entity
|
||||
*/
|
||||
struct classifier_entity
|
||||
*nas_COMMON_search_class_for_rb(nasRadioBearerId_t
|
||||
rab_id,struct nas_priv *priv);
|
||||
|
||||
/**
|
||||
\fn void nas_COMMON_flush_rb(struct cx_entity *cx)
|
||||
\brief Clear all RB's for a particular connection
|
||||
@param cx pointer to connection entity
|
||||
*/
|
||||
void nas_COMMON_flush_rb(struct cx_entity *cx);
|
||||
|
||||
#ifdef PDCP_USE_NETLINK
|
||||
/**
|
||||
\fn int nas_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 nas_netlink_send(unsigned char *data,unsigned int len);
|
||||
|
||||
/**
|
||||
\fn void nas_COMMON_QOS_receive(struct nlmsghdr *nlh)
|
||||
\brief Request a PDU from PDCP
|
||||
@param nlh pointer to netlink message header
|
||||
*/
|
||||
void nas_COMMON_QOS_receive(struct nlmsghdr *nlh);
|
||||
|
||||
#endif //PDCP_USE_NETLINK
|
||||
//nasmesh.c
|
||||
|
||||
/**
|
||||
\brief Initialize an interface for a particular instance ID.
|
||||
*/
|
||||
void nas_mesh_init(int inst //!< Instance ID
|
||||
|
||||
);
|
||||
|
||||
void nas_mesh_timer(unsigned long data,
|
||||
struct nas_priv *gpriv);
|
||||
|
||||
int nas_mesh_DC_receive(struct cx_entity *cx,struct nas_priv *gpriv);
|
||||
int nas_mesh_GC_receive(struct nas_priv *gpriv);
|
||||
int nas_mesh_DC_send_cx_establish_request(struct cx_entity *cx,struct nas_priv *gpriv);
|
||||
int nas_mesh_DC_send_cx_release_request(struct cx_entity *cx,struct nas_priv *gpriv);
|
||||
void nas_mesh_DC_send_sig_data_request(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,struct nas_priv *gpriv);
|
||||
|
||||
// iocontrol.c
|
||||
void nas_CTL_send(struct sk_buff *skb,
|
||||
struct cx_entity *cx,
|
||||
struct classifier_entity *gc);
|
||||
//int nas_CTL_receive_authentication(struct ipv6hdr *iph, struct cx-entity *cx, unsigned char sapi);
|
||||
int nas_CTL_ioctl(struct net_device *dev,
|
||||
struct ifreq *ifr, int cmd);
|
||||
|
||||
// classifier.c
|
||||
|
||||
/**
|
||||
\brief Send a socket received from IP to classifier for a particular instance ID.
|
||||
*/
|
||||
void nas_CLASS_send(struct sk_buff *skb, //!< Pointer to socket buffer
|
||||
int inst //!< Instance ID
|
||||
);
|
||||
/**
|
||||
\brief
|
||||
*/
|
||||
struct classifier_entity *nas_CLASS_add_sclassifier(struct cx_entity *cx, unsigned char dscp, unsigned short classref);
|
||||
|
||||
/**
|
||||
\brief Send a socket received from IP to classifier for a particular instance ID.
|
||||
*/
|
||||
struct classifier_entity
|
||||
*nas_CLASS_add_fclassifier(struct cx_entity *cx,
|
||||
unsigned char dscp,
|
||||
unsigned short classref
|
||||
);
|
||||
|
||||
/**
|
||||
\brief Send a socket received from IP to classifier for a particular instance ID.
|
||||
*/
|
||||
struct classifier_entity
|
||||
*nas_CLASS_add_rclassifier(unsigned char dscp,
|
||||
unsigned short classref,
|
||||
struct nas_priv*
|
||||
);
|
||||
|
||||
/**
|
||||
\brief
|
||||
*/
|
||||
void nas_CLASS_del_sclassifier(struct cx_entity *cx,
|
||||
unsigned char dscp,
|
||||
unsigned short classref
|
||||
);
|
||||
|
||||
/**
|
||||
\brief
|
||||
*/
|
||||
void nas_CLASS_del_fclassifier(struct cx_entity *cx,
|
||||
unsigned char dscp,
|
||||
unsigned short classref
|
||||
);
|
||||
|
||||
/**
|
||||
\brief
|
||||
*/
|
||||
void nas_CLASS_del_rclassifier(unsigned char dscp,
|
||||
unsigned short classref,
|
||||
struct nas_priv*
|
||||
);
|
||||
|
||||
/**
|
||||
\brief
|
||||
*/
|
||||
void nas_CLASS_flush_sclassifier(struct cx_entity *cx
|
||||
);
|
||||
|
||||
/**
|
||||
\brief
|
||||
*/
|
||||
void nas_CLASS_flush_fclassifier(struct cx_entity *cx
|
||||
);
|
||||
|
||||
/**
|
||||
\brief
|
||||
*/
|
||||
void nas_CLASS_flush_rclassifier(struct nas_priv *gpriv
|
||||
);
|
||||
|
||||
|
||||
// nas_tool.c
|
||||
unsigned char nas_TOOL_invfct(struct classifier_entity *gc);
|
||||
void nas_TOOL_fct(struct classifier_entity *gc, unsigned char fct);
|
||||
void nas_TOOL_imei2iid(unsigned char *imei, unsigned char *iid);
|
||||
unsigned char nas_TOOL_get_dscp6(struct ipv6hdr *iph);
|
||||
unsigned char nas_TOOL_get_dscp4(struct iphdr *iph);
|
||||
unsigned char *nas_TOOL_get_protocol6(struct ipv6hdr *iph, unsigned char *protocol);
|
||||
unsigned char *nas_TOOL_get_protocol4(struct iphdr *iph, unsigned char *protocol);
|
||||
char *nas_TOOL_get_udpmsg(struct udphdr *udph);
|
||||
unsigned short nas_TOOL_udpcksum(struct in6_addr *saddr, struct in6_addr *daddr, unsigned char proto, unsigned int udplen, void *data);
|
||||
int nas_TOOL_network6(struct in6_addr *addr, struct in6_addr *prefix, unsigned char plen);
|
||||
int nas_TOOL_network4(unsigned int *addr, unsigned int *prefix, unsigned char plen);
|
||||
void print_TOOL_pk_icmp6(struct icmp6hdr *icmph);
|
||||
|
||||
void print_TOOL_pk_all(struct sk_buff *skb);
|
||||
void print_TOOL_pk_ipv6(struct ipv6hdr *iph);
|
||||
void print_TOOL_state(unsigned char state);
|
||||
void nas_tool_print_buffer(char * buffer,int length);
|
||||
void nas_print_rb_entity(struct rb_entity *rb);
|
||||
void nas_print_classifier(struct classifier_entity *gc);
|
||||
|
||||
#ifdef PDCP_USE_NETLINK
|
||||
// nas_netlink.c
|
||||
|
||||
void nas_netlink_release(void);
|
||||
int nas_netlink_init(void);
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
+287
@@ -0,0 +1,287 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
/*********************************************************************
|
||||
rrc_nas_primitives.h - description
|
||||
-------------------
|
||||
begin : Jan 11, 2002
|
||||
copyright : (C) 2001 by Eurecom
|
||||
email : navid.nikaein@eurecom.fr
|
||||
lionel.gauthier@eurecom.fr
|
||||
knopp@eurecom.fr
|
||||
*********************************************************************
|
||||
Define RRC external interface primitives
|
||||
********************************************************************/
|
||||
#ifndef __RRC_NASPRIM_H__
|
||||
# define __RRC_NASPRIM_H__
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Primitives
|
||||
//----------------------------------------------------------
|
||||
# define INFO_BROADCAST_REQ 1
|
||||
# define INFO_BROADCAST_IND 2
|
||||
# define CONN_ESTABLISH_REQ 3
|
||||
# define CONN_ESTABLISH_IND 4
|
||||
# define CONN_ESTABLISH_RESP 5
|
||||
# define CONN_ESTABLISH_CNF 6
|
||||
# define CONN_RELEASE_REQ 7
|
||||
# define CONN_RELEASE_IND 8
|
||||
# define DATA_TRANSFER_REQ 9
|
||||
# define DATA_TRANSFER_IND 10
|
||||
# define RB_ESTABLISH_REQ 11
|
||||
# define RB_ESTABLISH_IND 12
|
||||
# define RB_ESTABLISH_CNF 14
|
||||
# define RB_RELEASE_REQ 15
|
||||
# define RB_RELEASE_IND 16
|
||||
# define MEASUREMENT_IND 17
|
||||
# define CONN_LOSS_IND 18
|
||||
# define PAGING_REQ 19
|
||||
# define NOTIFICATION_IND 20
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Constants
|
||||
//----------------------------------------------------------
|
||||
// Define max length authorized (to be updated later)
|
||||
# define NAS_MAX_LENGTH 180 // maximum length of a NAS primitive
|
||||
# define NAS_TL_SIZE 4 // size of the Type+Length fields of the primitive
|
||||
# define NAS_DATA_MAX_LENGTH NAS_MAX_LENGTH - NAS_TL_SIZE //remaining bytes for the message
|
||||
# define MAX_RABS 8 * 64 //NB_RAB_MAX * MAX_MOBILES_PER_RG //27 // = MAXURAB
|
||||
# define MAX_MEASURE_NB 5
|
||||
|
||||
//Connection Establishment status
|
||||
// UE
|
||||
# define TERMINATED 0
|
||||
# define ABORTED 1
|
||||
# define ALREADY_CONNECTED 2
|
||||
// RG + RB Establishment Confirm
|
||||
# define ACCEPTED 0
|
||||
# define FAILURE 1
|
||||
//----------------------------------------------------------
|
||||
|
||||
// Parameter types
|
||||
//----------------------------------------------------------
|
||||
typedef unsigned int nasPeriod_t; // Broadcast repetition period
|
||||
typedef unsigned short nasBroadcastCategory_t; // identifies the type of data to broadcast (IP signalling/ List of neighbors)
|
||||
typedef unsigned char nasIMEI_t[14]; // 14 digits of IMEI
|
||||
typedef unsigned short nasDataLength_t; // Length of the data in the primitive
|
||||
typedef unsigned short nasCellID_t; // ID of the cell for connection
|
||||
typedef unsigned int nasLocalConnectionRef_t; // local identifier
|
||||
typedef unsigned short nasConnectionStatus_t; // connection establishment status
|
||||
typedef unsigned short nasReleaseCause_t; // connection release cause
|
||||
typedef unsigned short nasSignalingPriority_t; // priority to use srb3 or srb4
|
||||
typedef unsigned short nasRadioBearerId_t;
|
||||
typedef unsigned short nasQoSTrafficClass_t; //QoS traffic class requested
|
||||
typedef unsigned short nasIPdscp_t; // DSCP code transported to service NAS
|
||||
typedef struct nasRBDef {
|
||||
nasRadioBearerId_t rbId;
|
||||
nasQoSTrafficClass_t QoSclass;
|
||||
nasIPdscp_t dscp;
|
||||
} nasrbParms_t;
|
||||
typedef unsigned int nasSapId_t; // Id of the QoS SAP to use
|
||||
typedef unsigned short nasRBEstablishStatus_t; // radio bearer establishment status
|
||||
typedef unsigned short nasNumRBsInList_t; // number of RBs defined in the list
|
||||
typedef nasrbParms_t nasRBList_t[MAX_RABS]; // List of Rbs for handover
|
||||
typedef unsigned short nasNumRGsMeas_t; // number of RGs that could be measured
|
||||
typedef unsigned int nasPagingUEId_t; // Cell_Id of the mobile, = Local Conn Ref
|
||||
typedef unsigned int nasSigLevel_t; // Signal level measured
|
||||
typedef struct nasMeasures {
|
||||
nasCellID_t cell_id;
|
||||
nasSigLevel_t level;
|
||||
} nasMeasures_t;
|
||||
|
||||
//----------------------------------------------------------
|
||||
// Primitive definitions
|
||||
//----------------------------------------------------------
|
||||
// -- SAP-GC
|
||||
struct NASInfoBroadcastReq {
|
||||
nasPeriod_t period; // 0 = one-shot, otherwise in x 10 ms
|
||||
nasBroadcastCategory_t category;
|
||||
nasDataLength_t nasDataLength;
|
||||
};
|
||||
struct NASInfoBroadcastInd {
|
||||
nasDataLength_t nasDataLength;
|
||||
};
|
||||
struct nas_ue_gc_element {
|
||||
unsigned short type;
|
||||
unsigned short length;
|
||||
union {
|
||||
struct NASInfoBroadcastInd broadcast_ind;
|
||||
} nasUEGCPrimitive;
|
||||
};
|
||||
struct nas_rg_gc_element {
|
||||
unsigned short type;
|
||||
unsigned short length;
|
||||
union {
|
||||
struct NASInfoBroadcastReq broadcast_req;
|
||||
} nasRGGCPrimitive;
|
||||
};
|
||||
|
||||
// -- SAP-DC
|
||||
struct NASConnEstablishReq {
|
||||
nasLocalConnectionRef_t localConnectionRef; //provided by NAS
|
||||
nasCellID_t cellId;
|
||||
};
|
||||
struct NASConnEstablishInd {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasIMEI_t InterfaceIMEI;
|
||||
};
|
||||
struct NASConnEstablishConf {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasConnectionStatus_t status; // can be : Accepted, Failure
|
||||
nasNumRBsInList_t num_RBs; // actual number of RBs in the list
|
||||
nasRBList_t RB_List;
|
||||
};
|
||||
struct NASConnEstablishResp {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasIMEI_t InterfaceIMEI;
|
||||
nasConnectionStatus_t status; // can be : Terminated, Aborted , Already_Connected
|
||||
};
|
||||
struct NASConnReleaseReq {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasReleaseCause_t releaseCause;
|
||||
};
|
||||
struct NASConnReleaseInd {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasReleaseCause_t releaseCause;
|
||||
};
|
||||
struct NASConnLossInd {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
};
|
||||
struct NASDataReq {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasSignalingPriority_t priority;
|
||||
nasDataLength_t nasDataLength;
|
||||
};
|
||||
struct NASDataInd {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasSignalingPriority_t priority;
|
||||
nasDataLength_t nasDataLength;
|
||||
};
|
||||
struct NASrbEstablishReq {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasRadioBearerId_t rbId;
|
||||
nasQoSTrafficClass_t QoSclass;
|
||||
nasIPdscp_t dscp;
|
||||
};
|
||||
struct NASrbEstablishInd {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasRadioBearerId_t rbId;
|
||||
nasQoSTrafficClass_t QoSclass;
|
||||
nasIPdscp_t dscp;
|
||||
nasSapId_t sapId;
|
||||
};
|
||||
struct NASrbEstablishConf {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasRadioBearerId_t rbId;
|
||||
nasSapId_t sapId;
|
||||
nasRBEstablishStatus_t status; // can be : Accepted, Failure
|
||||
};
|
||||
struct NASrbReleaseReq {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasRadioBearerId_t rbId;
|
||||
};
|
||||
struct NASrbReleaseInd {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasRadioBearerId_t rbId;
|
||||
};
|
||||
struct NASMeasureReq {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
};
|
||||
struct NASMeasureInd {
|
||||
nasLocalConnectionRef_t localConnectionRef;
|
||||
nasNumRGsMeas_t nb_rg;
|
||||
nasMeasures_t measures[MAX_MEASURE_NB];
|
||||
};
|
||||
|
||||
/*****
|
||||
* UE Primitives
|
||||
*****/
|
||||
struct nas_ue_dc_element {
|
||||
unsigned short type;
|
||||
unsigned short length;
|
||||
union {
|
||||
struct NASConnEstablishReq conn_establish_req;
|
||||
struct NASConnEstablishResp conn_establish_resp;
|
||||
|
||||
// struct NASConnReleaseInd conn_release_ind;
|
||||
struct NASConnReleaseReq conn_release_req;
|
||||
struct NASConnLossInd conn_loss_ind;
|
||||
struct NASDataReq data_transfer_req;
|
||||
struct NASDataInd data_transfer_ind;
|
||||
struct NASrbEstablishInd rb_establish_ind;
|
||||
struct NASrbReleaseInd rb_release_ind;
|
||||
struct NASMeasureInd measurement_ind;
|
||||
struct NASMeasureReq measurement_req;
|
||||
} nasUEDCPrimitive;
|
||||
};
|
||||
|
||||
/*****
|
||||
* RG Primitives
|
||||
*****/
|
||||
struct nas_rg_dc_element {
|
||||
unsigned short type;
|
||||
unsigned short length;
|
||||
union {
|
||||
struct NASConnEstablishInd conn_establish_ind;
|
||||
struct NASConnEstablishConf conn_establish_conf;
|
||||
struct NASConnReleaseInd conn_release_ind;
|
||||
|
||||
// struct NASConnReleaseReq conn_release_req;
|
||||
struct NASConnLossInd conn_loss_ind;
|
||||
struct NASDataReq data_transfer_req;
|
||||
struct NASDataInd data_transfer_ind;
|
||||
struct NASrbEstablishReq rb_establish_req;
|
||||
struct NASrbEstablishConf rb_establish_conf;
|
||||
struct NASrbReleaseReq rb_release_req;
|
||||
} nasRGDCPrimitive;
|
||||
};
|
||||
|
||||
// -- SAP-NT
|
||||
struct NASPagingReq {
|
||||
nasPagingUEId_t UeId;
|
||||
nasDataLength_t nasDataLength;
|
||||
};
|
||||
struct NASNotificationInd {
|
||||
nasDataLength_t nasDataLength;
|
||||
};
|
||||
struct nas_ue_nt_element {
|
||||
unsigned short type;
|
||||
unsigned short length;
|
||||
union {
|
||||
struct NASNotificationInd notification_ind;
|
||||
} nasUENTPrimitive;
|
||||
};
|
||||
struct nas_rg_nt_element {
|
||||
unsigned short type;
|
||||
unsigned short length;
|
||||
union {
|
||||
struct NASPagingReq paging_req;
|
||||
} nasRGNTPrimitive;
|
||||
};
|
||||
|
||||
#endif
|
||||
Executable
+72
@@ -0,0 +1,72 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
/***************************************************************************
|
||||
graal_sap.h - description
|
||||
-------------------
|
||||
copyright : (C) 2002 by Eurecom
|
||||
email : michelle.wetterwald@eurecom.fr
|
||||
yan.moret@eurecom.fr
|
||||
***************************************************************************
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _NAS_SAP_H
|
||||
#define _NAS_SAP_H
|
||||
|
||||
|
||||
// RT-FIFO identifiers ** must be identical to Access Stratum as_sap.h and rrc_sap.h
|
||||
|
||||
#define RRC_DEVICE_GC RRC_SAPI_GCSAP
|
||||
#define RRC_DEVICE_NT RRC_SAPI_NTSAP
|
||||
#define RRC_DEVICE_DC_INPUT0 RRC_SAPI_DCSAP_IN
|
||||
#define RRC_DEVICE_DC_OUTPUT0 RRC_SAPI_DCSAP_OUT
|
||||
|
||||
|
||||
//FIFO indexes in control blocks
|
||||
|
||||
#define NAS_DC_INPUT_SAPI 0
|
||||
#define NAS_DC_OUTPUT_SAPI 1
|
||||
#define NAS_SAPI_CX_MAX 2
|
||||
|
||||
#define NAS_GC_SAPI 0
|
||||
#define NAS_NT_SAPI 1
|
||||
|
||||
#define NAS_RAB_INPUT_SAPI 2
|
||||
#define NAS_RAB_OUTPUT_SAPI 3
|
||||
|
||||
|
||||
#define NAS_SAPI_MAX 4
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Executable
+896
@@ -0,0 +1,896 @@
|
||||
/*******************************************************************************
|
||||
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 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#include "local.h"
|
||||
#include "proto_extern.h"
|
||||
|
||||
//#include <linux/in.h>
|
||||
//#include <net/ndisc.h>
|
||||
//#include <linux/icmpv6.h>
|
||||
//#include <linux/icmp.h>
|
||||
//#include <linux/udp.h>
|
||||
//#include <linux/tcp.h>
|
||||
|
||||
//#define NAS_DEBUG_TOOL 1
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
void nas_TOOL_fct(struct classifier_entity *gc, uint8_t fct)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_FCT - begin \n");
|
||||
#endif
|
||||
|
||||
if (gc==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_FCT - input parameter gc is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
switch(fct) {
|
||||
case NAS_FCT_QOS_SEND:
|
||||
gc->fct=nas_COMMON_QOS_send;
|
||||
break;
|
||||
|
||||
case NAS_FCT_CTL_SEND:
|
||||
gc->fct=nas_CTL_send;
|
||||
break;
|
||||
|
||||
case NAS_FCT_DC_SEND:
|
||||
gc->fct=nas_mesh_DC_send_sig_data_request;
|
||||
break;
|
||||
|
||||
case NAS_FCT_DEL_SEND:
|
||||
gc->fct=nas_COMMON_del_send;
|
||||
break;
|
||||
|
||||
default:
|
||||
gc->fct=nas_COMMON_del_send;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t nas_TOOL_invfct(struct classifier_entity *gc)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_INVFCT - begin \n");
|
||||
#endif
|
||||
|
||||
if (gc==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_INVFCT - input parameter gc is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
if (gc->fct==nas_COMMON_QOS_send)
|
||||
return NAS_FCT_QOS_SEND;
|
||||
|
||||
if (gc->fct==nas_CTL_send)
|
||||
return NAS_FCT_CTL_SEND;
|
||||
|
||||
if (gc->fct==nas_COMMON_del_send)
|
||||
return NAS_FCT_DEL_SEND;
|
||||
|
||||
if (gc->fct==nas_mesh_DC_send_sig_data_request)
|
||||
|
||||
return NAS_FCT_DC_SEND;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t nas_TOOL_get_dscp6(struct ipv6hdr *iph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_DSCP6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_DSCP6 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
return (ntohl(((*(__u32 *)iph)&NAS_TRAFFICCLASS_MASK)))>>22;
|
||||
//return ntohs(*(const __be16 *)iph) >> 4; // see linux/dsfield.h
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t nas_TOOL_get_dscp4(struct iphdr *iph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_DSCP4 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_DSCP4 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
return (iph->tos);
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_TOOL_network6(struct in6_addr *addr, struct in6_addr *prefix, uint8_t plen)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_NETWORK6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (addr==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_NETWORK6 - input parameter addr is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (prefix==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_NETWORK6 - input parameter prefix is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
switch(plen/32) {
|
||||
case 0:
|
||||
return (((addr->s6_addr32[0]>>(32-plen))<<(32-plen))==prefix->s6_addr[0]);
|
||||
|
||||
case 1:
|
||||
return ((addr->s6_addr32[0]==prefix->s6_addr[0])&&
|
||||
(((addr->s6_addr32[1]>>(64-plen))<<(64-plen))==prefix->s6_addr[1]));
|
||||
|
||||
case 2:
|
||||
return ((addr->s6_addr32[0]==prefix->s6_addr[0])&&
|
||||
(addr->s6_addr32[1]==prefix->s6_addr[1])&&
|
||||
(((addr->s6_addr32[2]>>(96-plen))<<(96-plen))==prefix->s6_addr[2]));
|
||||
|
||||
case 3:
|
||||
return ((addr->s6_addr32[0]==prefix->s6_addr[0])&&
|
||||
(addr->s6_addr32[1]==prefix->s6_addr[1])&&
|
||||
(addr->s6_addr32[2]==prefix->s6_addr[2])&&
|
||||
(((addr->s6_addr32[3]>>(128-plen))<<(128-plen))==prefix->s6_addr[3]));
|
||||
|
||||
default:
|
||||
return ((addr->s6_addr32[0]==prefix->s6_addr[0])&&
|
||||
(addr->s6_addr32[1]==prefix->s6_addr[1])&&
|
||||
(addr->s6_addr32[2]==prefix->s6_addr[2])&&
|
||||
(addr->s6_addr32[3]==prefix->s6_addr[3]));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int nas_TOOL_network4(uint32_t *addr, uint32_t *prefix, uint8_t plen)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_NETWORK4 - begin \n");
|
||||
#endif
|
||||
|
||||
if (addr==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_NETWORK4 - input parameter addr is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (prefix==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_NETWORK4 - input parameter prefix is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
if (plen>=32)
|
||||
return (*addr==*prefix);
|
||||
else
|
||||
return (((*addr>>(32-plen))<<(32-plen))==*prefix);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//struct udphdr *nas_TOOL_get_udp6(struct ipv6hdr *iph){
|
||||
//---------------------------------------------------------------------------
|
||||
// return (struct udphdr *)((char *)iph+NAS_IPV6_SIZE); // to modify
|
||||
//}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t *nas_TOOL_get_protocol6(struct ipv6hdr *iph, uint8_t *protocol)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint16_t size;
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_PROTOCOL6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_PROTOCOL6 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (protocol==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_PROTOCOL6 - input parameter protocol is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
*protocol=iph->nexthdr;
|
||||
size=NAS_IPV6_SIZE;
|
||||
|
||||
while (1) {
|
||||
switch(*protocol) {
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_TCP:
|
||||
case IPPROTO_ICMPV6:
|
||||
return (uint8_t *)((uint8_t *)iph+size);
|
||||
|
||||
case IPPROTO_HOPOPTS:
|
||||
case IPPROTO_ROUTING:
|
||||
case IPPROTO_DSTOPTS:
|
||||
*protocol=((uint8_t *)iph+size)[0];
|
||||
size+=((uint8_t *)iph+size)[1]*8+8;
|
||||
break;
|
||||
|
||||
case IPPROTO_FRAGMENT:
|
||||
*protocol=((uint8_t *)iph+size)[0];
|
||||
size+=((uint8_t *)iph+size)[1]+8;
|
||||
break;
|
||||
|
||||
case IPPROTO_NONE:
|
||||
case IPPROTO_AH:
|
||||
case IPPROTO_ESP:
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t *nas_TOOL_get_protocol4(struct iphdr *iph, uint8_t *protocol)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_PROTOCOL4 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_PROTOCOL4 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (protocol==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_PROTOCOL4 - input parameter protocol is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
*protocol=iph->protocol;
|
||||
|
||||
switch(*protocol) {
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_TCP:
|
||||
case IPPROTO_ICMP:
|
||||
return (uint8_t *)((uint8_t *)iph+iph->tot_len);
|
||||
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Convert the IMEI to iid
|
||||
void nas_TOOL_imei2iid(uint8_t *imei, uint8_t *iid)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_IMEI2IID - begin \n");
|
||||
#endif
|
||||
|
||||
if (imei==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_IMEI2IID - input parameter imei is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (iid==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_IMEI2IID - input parameter iid is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
memset(iid, 0, NAS_ADDR_LEN);
|
||||
iid[0] = 0x03;
|
||||
iid[1] = 16*imei[0]+imei[1];
|
||||
iid[2] = 16*imei[2]+imei[3];
|
||||
iid[3] = 16*imei[4]+imei[5];
|
||||
iid[4] = 16*imei[6]+imei[7];
|
||||
iid[5] = 16*imei[8]+imei[9];
|
||||
iid[6] = 16*imei[10]+imei[11];
|
||||
iid[7] = 16*imei[12]+imei[13];
|
||||
}
|
||||
|
||||
//struct udphdr *nas_TOOL_get_udp4(struct iphdr *iph)
|
||||
//{
|
||||
// return (struct udphdr *)((char *)iph+NAS_IPV4_SIZE); // to modify
|
||||
//}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
char *nas_TOOL_get_udpmsg(struct udphdr *udph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_UDPMSG - begin \n");
|
||||
#endif
|
||||
|
||||
if (udph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_GET_UDPMSG - input parameter udph is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
return ((char *)udph+sizeof(struct udphdr));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Compute the UDP checksum (the data size must be odd)
|
||||
uint16_t nas_TOOL_udpcksum(struct in6_addr *saddr, struct in6_addr *daddr, uint8_t proto, uint32_t udplen, void *data)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint32_t i;
|
||||
uint16_t *data16;
|
||||
uint32_t csum=0;
|
||||
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_UDPCKSUM - begin \n");
|
||||
#endif
|
||||
|
||||
if (saddr==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_UDPCKSUM - input parameter saddr is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (daddr==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_UDPCKSUM - input parameter daddr is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (data==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_UDPCKSUM - input parameter data is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
data16=data;
|
||||
|
||||
for (i=0; i<8; ++i) {
|
||||
csum+=ntohs(saddr->s6_addr16[i]);
|
||||
|
||||
if (csum>0xffff)
|
||||
csum-=0xffff;
|
||||
}
|
||||
|
||||
for (i=0; i<8; ++i) {
|
||||
csum+=ntohs(daddr->s6_addr16[i]);
|
||||
|
||||
if (csum>0xffff)
|
||||
csum-=0xffff;
|
||||
}
|
||||
|
||||
csum+=(udplen>>16); // udplen checksum
|
||||
|
||||
if (csum>0xffff)
|
||||
csum -= 0xffff;
|
||||
|
||||
csum+=udplen & 0xffff;
|
||||
|
||||
if (csum>0xffff)
|
||||
csum -= 0xffff;
|
||||
|
||||
csum+=proto; // protocol checksum
|
||||
|
||||
if (csum>0xffff)
|
||||
csum-=0xffff;
|
||||
|
||||
for (i = 0; 2*i < udplen; i++) {
|
||||
csum+=ntohs(data16[i]);
|
||||
|
||||
if (csum>0xffff)
|
||||
csum-=0xffff;
|
||||
}
|
||||
|
||||
return htons((uint16_t)(~csum)&0xffff);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void print_TOOL_pk_udp(struct udphdr *udph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_UDP - begin \n");
|
||||
#endif
|
||||
|
||||
if (udph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_PK_UDP - input parameter udph is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
if (udph!=NULL) {
|
||||
printk("UDP:\t source = %u, dest = %u, len = %u, check = %x\n", ntohs(udph->source), ntohs(udph->dest), ntohs(udph->len), udph->check);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void print_TOOL_pk_tcp(struct tcphdr *tcph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_TDP - begin \n");
|
||||
#endif
|
||||
|
||||
if (tcph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_PK_TDP - input parameter tcph is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
if (tcph!=NULL) {
|
||||
printk("TCP:\t source = %u, dest = %u\n", tcph->source, tcph->dest);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void print_TOOL_pk_icmp6(struct icmp6hdr *icmph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_ICMP6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (icmph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_PK_ICMP6 - input parameter icmph is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
if (icmph!=NULL) {
|
||||
printk("ICMPv6:\t type= %d, code = %d\n", icmph->icmp6_type, icmph->icmp6_code);
|
||||
|
||||
switch(icmph->icmp6_type) {
|
||||
case ICMPV6_DEST_UNREACH:
|
||||
printk("Destination unreachable\n");
|
||||
break;
|
||||
|
||||
case ICMPV6_PKT_TOOBIG:
|
||||
printk("Packet too big\n");
|
||||
break;
|
||||
|
||||
case ICMPV6_TIME_EXCEED:
|
||||
printk("Time exceeded\n");
|
||||
break;
|
||||
|
||||
case ICMPV6_PARAMPROB:
|
||||
printk("Parameter problem\n");
|
||||
break;
|
||||
|
||||
case ICMPV6_ECHO_REQUEST:
|
||||
printk("Echo request\n");
|
||||
break;
|
||||
|
||||
case ICMPV6_ECHO_REPLY:
|
||||
printk("Echo reply\n");
|
||||
break;
|
||||
|
||||
case ICMPV6_MGM_QUERY:
|
||||
printk("Multicast listener query\n");
|
||||
break;
|
||||
|
||||
case ICMPV6_MGM_REPORT:
|
||||
printk("Multicast listener report\n");
|
||||
break;
|
||||
|
||||
case ICMPV6_MGM_REDUCTION:
|
||||
printk("Multicast listener done\n");
|
||||
break;
|
||||
|
||||
case NDISC_ROUTER_SOLICITATION:
|
||||
printk("Router solicitation\n");
|
||||
break;
|
||||
|
||||
case NDISC_ROUTER_ADVERTISEMENT:
|
||||
printk("Router advertisment\n");
|
||||
break;
|
||||
|
||||
case NDISC_NEIGHBOUR_SOLICITATION:
|
||||
printk("Neighbour solicitation\n");
|
||||
break;
|
||||
|
||||
case NDISC_NEIGHBOUR_ADVERTISEMENT:
|
||||
printk("Neighbour advertisment\n");
|
||||
break;
|
||||
|
||||
case NDISC_REDIRECT:
|
||||
printk("redirect message\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void print_TOOL_pk_ipv6(struct ipv6hdr *iph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_IPv6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_PK_IPv6 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
|
||||
if (iph!=NULL) {
|
||||
// char addr[NAS_INET6_ADDRSTRLEN];
|
||||
printk("IP:\t version = %u, priority = %u, payload_len = %u\n", iph->version, iph->priority, ntohs(iph->payload_len));
|
||||
printk("\t fl0 = %u, fl1 = %u, fl2 = %u\n",iph->flow_lbl[0],iph->flow_lbl[1],iph->flow_lbl[2]);
|
||||
printk("\t next header = %u, hop_limit = %u\n", iph->nexthdr, iph->hop_limit);
|
||||
|
||||
// inet_ntop(AF_INET6, (void *)(&iph->saddr), addr, NAS_INET6_ADDRSTRLEN);
|
||||
// printk("\t saddr = %s",addr);
|
||||
// inet_ntop(AF_INET6, (void *)(&iph->daddr), addr, NAS_INET6_ADDRSTRLEN);
|
||||
// printk(", daddr = %s\n",addr);
|
||||
switch(iph->nexthdr) {
|
||||
case IPPROTO_UDP:
|
||||
print_TOOL_pk_udp((struct udphdr *)((char *)iph+sizeof(struct ipv6hdr)));
|
||||
break;
|
||||
|
||||
case IPPROTO_TCP:
|
||||
print_TOOL_pk_tcp((struct tcphdr *)((char *)iph+sizeof(struct ipv6hdr)));
|
||||
break;
|
||||
|
||||
case IPPROTO_ICMPV6:
|
||||
print_TOOL_pk_icmp6((struct icmp6hdr *)((char *)iph+sizeof(struct ipv6hdr)));
|
||||
break;
|
||||
|
||||
case IPPROTO_IPV6:
|
||||
print_TOOL_pk_ipv6((struct ipv6hdr *)((char *)iph+sizeof(struct ipv6hdr)));
|
||||
break;
|
||||
|
||||
default:
|
||||
printk("Unknown upper layer\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void print_TOOL_pk_ipv4(struct iphdr *iph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_IPv4 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_PK_IPv4 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
|
||||
if (iph!=NULL) {
|
||||
// char addr[NAS_INET_ADDRSTRLEN];
|
||||
printk("IP:\t version = %u, IP length = %u\n", iph->version, iph->ihl);
|
||||
// inet_ntop(AF_INET, (void *)(&iph->saddr), addr, NAS_INET_ADDRSTRLEN);
|
||||
// printk("\t saddr = %s", addr);
|
||||
// inet_ntop(AF_INET, (void *)(&iph->saddr), addr, NAS_INET_ADDRSTRLEN);
|
||||
// printk("\t saddr = %s", addr);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void print_TOOL_pk_all(struct sk_buff *skb)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
printk("Skb:\t %p, len = %u\n", skb, skb->len);
|
||||
//navid: need to calculate the current used space: fixme?
|
||||
printk("Skb:\t available buf space = %u \n", skb->truesize);
|
||||
|
||||
switch (ntohs(skb->protocol)) {
|
||||
case ETH_P_IPV6:
|
||||
print_TOOL_pk_ipv6((struct ipv6hdr *)skb->network_header);
|
||||
break;
|
||||
|
||||
case ETH_P_IP:
|
||||
print_TOOL_pk_ipv4((struct iphdr *)skb->network_header);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/*int isdigit(char c)
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*int nas_TOOL_inet_pton4(char *src, uint32_t *dst)
|
||||
{
|
||||
uint32_t val;
|
||||
int n;
|
||||
uint8_t c;
|
||||
uint32_t parts[4];
|
||||
|
||||
c = *src;
|
||||
val=0;
|
||||
n=0
|
||||
for (;;)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
if (isdigit(c))
|
||||
{
|
||||
val = (val * 10) + c - '0';
|
||||
c = *++src;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (c == '.')
|
||||
{
|
||||
if (n>4)
|
||||
return -1;
|
||||
parts[n]=val;
|
||||
c = *++src;
|
||||
++n;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if ((c != '\0')||(n!=3))
|
||||
return (0);
|
||||
if ((parts[0] | parts[1] | parts[2] | val) > 256)
|
||||
return (0);
|
||||
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
||||
if (dst)
|
||||
dst = htonl(val);
|
||||
return (1);
|
||||
}*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void print_TOOL_state(uint8_t state)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// case NAS_STATE_IDLE:printk(" State NAS_STATE_IDLE\n");return;
|
||||
// case NAS_STATE_CONNECTED:printk(" State NAS_STATE_CONNECTED\n");return;
|
||||
// case NAS_STATE_ESTABLISHMENT_REQUEST:printk(" State NAS_STATE_ESTABLISHMENT_REQUEST\n");return;
|
||||
// case NAS_STATE_ESTABLISHMENT_FAILURE:printk(" State NAS_STATE_ESTABLISHMENT_FAILURE\n");return;
|
||||
// case NAS_STATE_RELEASE_FAILURE:printk(" State NAS_STATE_RELEASE_FAILURE\n");return;
|
||||
|
||||
switch(state) {
|
||||
case NAS_IDLE:
|
||||
printk("NAS_IDLE\n");
|
||||
return;
|
||||
|
||||
case NAS_CX_FACH:
|
||||
printk("NAS_CX_FACH\n");
|
||||
return;
|
||||
|
||||
case NAS_CX_DCH:
|
||||
printk("NAS_CX_DCH\n");
|
||||
return;
|
||||
|
||||
case NAS_CX_RECEIVED:
|
||||
printk("NAS_CX_RECEIVED\n");
|
||||
return;
|
||||
|
||||
case NAS_CX_CONNECTING:
|
||||
printk("NAS_CX_CONNECTING\n");
|
||||
return;
|
||||
|
||||
case NAS_CX_RELEASING:
|
||||
printk("NAS_CX_RELEASING\n");
|
||||
return;
|
||||
|
||||
case NAS_CX_CONNECTING_FAILURE:
|
||||
printk("NAS_CX_CONNECTING_FAILURE\n");
|
||||
return;
|
||||
|
||||
case NAS_CX_RELEASING_FAILURE:
|
||||
printk("NAS_CX_RELEASING_FAILURE\n");
|
||||
return;
|
||||
|
||||
case NAS_RB_ESTABLISHING:
|
||||
printk("NAS_RB_ESTABLISHING\n");
|
||||
return;
|
||||
|
||||
case NAS_RB_RELEASING:
|
||||
printk("NAS_RB_RELEASING\n");
|
||||
return;
|
||||
|
||||
case NAS_RB_DCH:
|
||||
printk("NAS_RB_DCH\n");
|
||||
return;
|
||||
|
||||
default:
|
||||
printk(" Unknown state\n");
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Print the content of a buffer in hexadecimal
|
||||
void nas_tool_print_buffer(char * buffer,int length)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
int i;
|
||||
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_PRINT_BUFFER - begin \n");
|
||||
#endif
|
||||
|
||||
if (buffer==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_TOOL_PRINT_BUFFER - input parameter buffer is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
printk("\nBuffer content: ");
|
||||
|
||||
for (i=0; i<length; i++)
|
||||
printk("-%hx-",buffer[i]);
|
||||
|
||||
printk(",\t length %d\n", length);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void nas_print_rb_entity(struct rb_entity *rb)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_PRINT_RB_ENTITY - begin \n");
|
||||
#endif
|
||||
|
||||
if (rb==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_PRINT_RB_ENTITY - input parameter rb is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
printk("\nrb_entity content: rab_id %d, sapi %d, qos %d, \n", rb->rab_id, rb->sapi, rb->qos);
|
||||
printk("state %d, retry %d, countimer %d\n",rb->state, rb->retry, rb->countimer);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void nas_print_classifier(struct classifier_entity *gc)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_PRINT_GC_ENTITY - begin \n");
|
||||
#endif
|
||||
|
||||
if (gc==NULL) {
|
||||
#ifdef NAS_DEBUG_TOOL
|
||||
printk("NAS_PRINT_GC_ENTITY - input parameter gc is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
printk("\nClassifier content: classref %d, version %d, splen %d, dplen %d,\n", gc->classref, gc->version, gc->splen, gc->dplen);
|
||||
printk("protocol %d, sport %d, dport %d, rab_id %d\n", gc->protocol, gc->sport, gc->dport, gc->rab_id);
|
||||
|
||||
if (gc->rb != NULL) {
|
||||
nas_print_rb_entity(gc->rb);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user