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:
Executable
+674
@@ -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
+72
@@ -0,0 +1,72 @@
|
||||
# NASMESH Driver makefile
|
||||
#
|
||||
include $(OPENAIR_DIR)/common/utils/Makefile.inc
|
||||
NAS_UPDIR := $(shell /bin/pwd)
|
||||
|
||||
KERNEL_ARCH:=$(shell echo `uname -m`)
|
||||
SET_X64:=$(shell if [ $(KERNEL_ARCH) = 'x86_64' ]; then echo true ; fi)
|
||||
|
||||
####################################################
|
||||
# EXTRA COMPILER FLAGS
|
||||
####################################################
|
||||
EXTRA_CFLAGS = -I$(OPENAIR2_DIR)/COMMON -fno-common -fno-stack-protector -mpreferred-stack-boundary=4 $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,)
|
||||
|
||||
ifdef ADDRCONF
|
||||
EXTRA_CFLAGS += -DADDRCONF
|
||||
endif
|
||||
|
||||
ifdef OAI_NW_DRIVER_TYPE_ETHERNET
|
||||
EXTRA_CFLAGS += -DOAI_NW_DRIVER_TYPE_ETHERNET
|
||||
endif
|
||||
|
||||
ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
EXTRA_CFLAGS += -DOAI_NW_DRIVER_USE_NETLINK
|
||||
else
|
||||
EXTRA_CFLAGS += $(shell rtai-config --module-cflags) -DRTAI -D__IN_RTAI__ -Wall
|
||||
endif
|
||||
|
||||
ccflags-y= $(CFLAGS) $(EXTRA_CFLAGS)
|
||||
CFLAGS=
|
||||
|
||||
ifdef LOOPBACK
|
||||
EXTRA_CFLAGS += -DLOOPBACK_TEST
|
||||
endif
|
||||
|
||||
ifdef ADDRESS_FIX
|
||||
EXTRA_CFLAGS += -DNAS_ADDRESS_FIX
|
||||
endif
|
||||
|
||||
####################################################
|
||||
# LOADABLE MODULE GOALS
|
||||
####################################################
|
||||
obj-m += oai_nw_drv.o
|
||||
oai_nw_drv-objs += device.o
|
||||
oai_nw_drv-objs += common.o
|
||||
oai_nw_drv-objs += ioctl.o
|
||||
oai_nw_drv-objs += classifier.o
|
||||
oai_nw_drv-objs += tool.o
|
||||
ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
oai_nw_drv-objs += netlink.o
|
||||
endif
|
||||
|
||||
####################################################
|
||||
# REVOIR LE CLEAN
|
||||
####################################################
|
||||
|
||||
#netlink.ko:
|
||||
#make $(x)$(y) PDCP_USE_NETLINK=1 V=1 -C $(KERNEL_DIR) M=`pwd` modules
|
||||
|
||||
#oai_nw_drv.ko:
|
||||
# make V=1 -C $(KERNEL_DIR) M=`pwd` modules
|
||||
print:
|
||||
@echo subversion : $(SUBVERSION)
|
||||
clean:
|
||||
rm -f *.ko
|
||||
rm -f .*.ko.cmd
|
||||
rm -f .*.o.cmd
|
||||
rm -f *.o
|
||||
rm -f *.mod.c
|
||||
find . -name *.ko -delete
|
||||
find . -name .*.o -delete
|
||||
find . -name *.o -delete
|
||||
find . -name *.mod.c -delete
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
CC = gcc
|
||||
|
||||
NAS_DIR = ..
|
||||
|
||||
rb_tool: rb_tool.c
|
||||
$(CC) rb_tool.c -o rb_tool -I../ -g -ggdb
|
||||
|
||||
all: rb_tool
|
||||
|
||||
clean:
|
||||
rm rb_tool
|
||||
+532
@@ -0,0 +1,532 @@
|
||||
/*******************************************************************************
|
||||
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 "rrc_nas_primitives.h"
|
||||
#include "ioctl.h"
|
||||
#include "constant.h"
|
||||
|
||||
|
||||
#define NIPADDR(addr) \
|
||||
(uint8_t)(addr & 0x000000FF), \
|
||||
(uint8_t)((addr & 0x0000FF00) >> 8), \
|
||||
(uint8_t)((addr & 0x00FF0000) >> 16), \
|
||||
(uint8_t)((addr & 0xFF000000) >> 24)
|
||||
|
||||
|
||||
|
||||
#define NIP6ADDR(addr) \
|
||||
ntohs((addr)->s6_addr16[0]), \
|
||||
ntohs((addr)->s6_addr16[1]), \
|
||||
ntohs((addr)->s6_addr16[2]), \
|
||||
ntohs((addr)->s6_addr16[3]), \
|
||||
ntohs((addr)->s6_addr16[4]), \
|
||||
ntohs((addr)->s6_addr16[5]), \
|
||||
ntohs((addr)->s6_addr16[6]), \
|
||||
ntohs((addr)->s6_addr16[7])
|
||||
|
||||
|
||||
// Global variables
|
||||
|
||||
int fd;
|
||||
//ioctl
|
||||
char dummy_buffer[1024];
|
||||
struct oai_nw_drv_ioctl gifr;
|
||||
//int wait_start_nas;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void IAL_NAS_ioctl_init(int inst)
|
||||
//---------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
struct oai_nw_drv_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 = OAI_NW_DRV_MSG_STATISTIC_REQUEST;
|
||||
memset ((void *)dummy_buffer,0,800);
|
||||
gifr.msg= &(dummy_buffer[0]);
|
||||
msgrep=(struct oai_nw_drv_msg_statistic_reply *)(gifr.msg);
|
||||
printf("ioctl :Statistics requested\n");
|
||||
err=ioctl(fd, OAI_NW_DRV_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 NO_ACTION_RB 0
|
||||
#define ADD_RB 1
|
||||
#define DEL_RB 2
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int main(int argc,char **argv)
|
||||
//---------------------------------------------------------------------------
|
||||
{
|
||||
int done;
|
||||
int rc;
|
||||
int meas_polling_counter;
|
||||
fd_set readfds;
|
||||
struct timeval tv;
|
||||
int i;
|
||||
int err;
|
||||
char *buffer;
|
||||
int c;
|
||||
int action;
|
||||
int rbset = 0;
|
||||
int cxset = 0;
|
||||
int classrefset = 0;
|
||||
int instset = 0;
|
||||
int saddr_ipv4set = 0;
|
||||
int saddr_ipv6set = 0;
|
||||
int daddr_ipv4set = 0;
|
||||
int daddr_ipv6set = 0;
|
||||
int dscpset = 0;
|
||||
int dplen = 0;
|
||||
int splen = 0;
|
||||
int mpls_outlabelset = 0;
|
||||
int mpls_inlabelset;
|
||||
char rb[20];
|
||||
char cx[20];
|
||||
char classref[20];
|
||||
char dscp[20];
|
||||
char inst[20];
|
||||
char mpls_outgoinglabel[100];
|
||||
char mpls_incominglabel[100];
|
||||
int index;
|
||||
struct oai_nw_drv_msg_rb_establishment_request *msgreq;
|
||||
struct oai_nw_drv_msg_class_add_request *msgreq_class;
|
||||
in_addr_t saddr_ipv4;
|
||||
in_addr_t daddr_ipv4;
|
||||
struct in6_addr saddr_ipv6;
|
||||
struct in6_addr daddr_ipv6;
|
||||
unsigned int mpls_outlabel;
|
||||
unsigned int mpls_inlabel;
|
||||
char addr_str[46];
|
||||
char mask_len_delims[] = "/";
|
||||
char *result;
|
||||
|
||||
// scan options
|
||||
rb[0] = '\0';
|
||||
cx[0] = '\0';
|
||||
dscp[0] = '\0';
|
||||
mpls_incominglabel[0] = '\0';
|
||||
mpls_outgoinglabel[0] = '\0';
|
||||
action = NO_ACTION_RB;
|
||||
|
||||
while ((c = getopt (argc, argv, "adr:i:c:f: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 'f':
|
||||
strcpy(classref,optarg);
|
||||
classrefset = 1;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
strcpy(mpls_outgoinglabel,optarg);
|
||||
mpls_outlabelset=1;
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
strcpy(mpls_incominglabel,optarg);
|
||||
mpls_inlabelset=1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
inet_aton(result,&saddr_ipv4);
|
||||
printf("Arg Source Addr IPv4 string: %s\n",result);
|
||||
saddr_ipv4set = 1;
|
||||
} else {
|
||||
printf("Arg Source Addr IPv4 string: ERROR\n");
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
splen = atoi(result);
|
||||
} else {
|
||||
splen = 32;
|
||||
}
|
||||
|
||||
printf("Arg Source Addr IPv4 mask len: %d\n",splen);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
inet_aton(result,&daddr_ipv4);
|
||||
printf("Arg Dest Addr IPv4 string: %s\n",result);
|
||||
daddr_ipv4set = 1;
|
||||
} else {
|
||||
printf("Arg Dest Addr IPv4 string: ERROR\n");
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
dplen = atoi(result);
|
||||
} else {
|
||||
dplen = 32;
|
||||
}
|
||||
|
||||
printf("Arg Dest Addr IPv4 mask len: %d\n",dplen);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
printf("Arg Source Addr IPv6 string: %s\n",result);
|
||||
inet_pton(AF_INET6,result,(void *)&saddr_ipv6);
|
||||
saddr_ipv6set = 1;
|
||||
} else {
|
||||
printf("Arg Source Addr IPv6 string: ERROR\n");
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
splen = atoi(result);
|
||||
} else {
|
||||
splen = 128;
|
||||
}
|
||||
|
||||
printf("Arg Source Addr IPv6 mask len: %d\n",splen);
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
result = strtok( optarg, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
printf("Arg Dest Addr IPv6 string: %s\n",result);
|
||||
inet_pton(AF_INET6,result,(void *)&daddr_ipv6);
|
||||
daddr_ipv6set = 1;
|
||||
} else {
|
||||
printf("Arg Dest Addr IPv6 string: ERROR\n");
|
||||
break;
|
||||
}
|
||||
|
||||
result = strtok( NULL, mask_len_delims );
|
||||
|
||||
if ( result != NULL ) {
|
||||
dplen = atoi(result);
|
||||
} else {
|
||||
dplen = 128;
|
||||
}
|
||||
|
||||
printf("Arg Dest Addr IPv6 mask len: %d\n",dplen);
|
||||
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 (classrefset==0) {
|
||||
printf("ERROR: Specify an Class reference !!\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 oai_nw_drv_msg_rb_establishment_request *)(gifr.msg);
|
||||
msgreq->rab_id = atoi(rb);
|
||||
msgreq->lcr = atoi(cx);
|
||||
msgreq->qos = 0;
|
||||
|
||||
|
||||
if (action == ADD_RB) {
|
||||
gifr.type = OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REQUEST;
|
||||
printf("OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REQUEST: RB %d LCR %d QOS %d\n ", msgreq->rab_id, msgreq->lcr, msgreq->qos);
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
}
|
||||
|
||||
// only add classification rule
|
||||
if ((action == ADD_RB ) || (action == NO_ACTION_RB)) {
|
||||
if (saddr_ipv4set == 1) {
|
||||
msgreq_class = (struct oai_nw_drv_msg_class_add_request *)(gifr.msg);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->version = 4;
|
||||
msgreq_class->classref = atoi(classref) + (msgreq_class->lcr<<8);
|
||||
msgreq_class->dir = OAI_NW_DRV_DIRECTION_SEND;
|
||||
msgreq_class->fct = OAI_NW_DRV_FCT_QOS_SEND;
|
||||
msgreq_class->saddr.ipv4 = saddr_ipv4;
|
||||
msgreq_class->daddr.ipv4 = daddr_ipv4;
|
||||
msgreq_class->dplen = dplen;
|
||||
msgreq_class->splen = splen;
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = OAI_NW_DRV_PROTOCOL_DEFAULT;
|
||||
|
||||
if (dscpset==0) {
|
||||
msgreq_class->dscp=0;
|
||||
} else {
|
||||
msgreq_class->dscp=atoi(dscp);
|
||||
}
|
||||
|
||||
printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_SEND RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref);
|
||||
printf("IPV4: Source = %d.%d.%d.%d/%d ", NIPADDR(msgreq_class->saddr.ipv4), msgreq_class->splen);
|
||||
printf(" IPV4: Dest = %d.%d.%d.%d/%d\n", NIPADDR(msgreq_class->daddr.ipv4), msgreq_class->dplen);
|
||||
gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->version = 4;
|
||||
msgreq_class->classref = atoi(classref) + 1 + (msgreq_class->lcr<<8);
|
||||
msgreq_class->dir = OAI_NW_DRV_DIRECTION_RECEIVE;
|
||||
msgreq_class->fct = OAI_NW_DRV_FCT_QOS_SEND;
|
||||
msgreq_class->daddr.ipv4 = saddr_ipv4;
|
||||
msgreq_class->saddr.ipv4 = daddr_ipv4;
|
||||
msgreq_class->dplen = splen;
|
||||
msgreq_class->splen = dplen;
|
||||
printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_RECEIVE RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref);
|
||||
printf("IPV4: Source = %d.%d.%d.%d/%d ", NIPADDR(msgreq_class->saddr.ipv4), msgreq_class->splen);
|
||||
printf("IPV4: Dest = %d.%d.%d.%d/%d\n", NIPADDR(msgreq_class->daddr.ipv4), msgreq_class->dplen);
|
||||
|
||||
gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
}
|
||||
|
||||
if (saddr_ipv6set == 1) {
|
||||
msgreq_class = (struct oai_nw_drv_msg_class_add_request *)(gifr.msg);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->version = 6;
|
||||
msgreq_class->dplen = dplen;
|
||||
msgreq_class->splen = splen;
|
||||
|
||||
if (dscpset==0)
|
||||
msgreq_class->dscp = 0;
|
||||
else
|
||||
msgreq_class->dscp = atoi(dscp);
|
||||
|
||||
msgreq_class->classref = atoi(classref) + (msgreq_class->lcr<<8);
|
||||
msgreq_class->dir = OAI_NW_DRV_DIRECTION_SEND;
|
||||
msgreq_class->fct = OAI_NW_DRV_FCT_QOS_SEND;
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = OAI_NW_DRV_PROTOCOL_DEFAULT;
|
||||
|
||||
memcpy(&msgreq_class->saddr.ipv6,&saddr_ipv6,16);
|
||||
memcpy(&msgreq_class->daddr.ipv6,&daddr_ipv6,16);
|
||||
printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_SEND RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref);
|
||||
printf("IPV6: Source = %x:%x:%x:%x:%x:%x:%x:%x/%d ", NIP6ADDR(&msgreq_class->saddr.ipv6), msgreq_class->splen);
|
||||
printf("IPV6: Dest = %x:%x:%x:%x:%x:%x:%x:%x/%d\n", NIP6ADDR(&msgreq_class->daddr.ipv6), msgreq_class->dplen);
|
||||
gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->dplen = splen;
|
||||
msgreq_class->splen = dplen;
|
||||
msgreq_class->classref = atoi(classref) + 1 + (msgreq_class->lcr<<8);
|
||||
msgreq_class->dir = OAI_NW_DRV_DIRECTION_RECEIVE;
|
||||
memcpy(&msgreq_class->daddr.ipv6,&saddr_ipv6,16);
|
||||
memcpy(&msgreq_class->saddr.ipv6,&daddr_ipv6,16);
|
||||
printf("OAI_NW_DRV_MSG_CLASS_ADD_REQUEST: OAI_NW_DRV_DIRECTION_RECEIVE RB %d LCR %d ClassRef %d ", msgreq_class->rab_id, msgreq_class->lcr, msgreq_class->classref);
|
||||
printf("IPV6: Source = %x:%x:%x:%x:%x:%x:%x:%x/%d ", NIP6ADDR(&msgreq_class->saddr.ipv6), msgreq_class->splen);
|
||||
printf("IPV6: Dest = %x:%x:%x:%x:%x:%x:%x:%x/%d\n", NIP6ADDR(&msgreq_class->daddr.ipv6), msgreq_class->dplen);
|
||||
gifr.type = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
}
|
||||
|
||||
if (mpls_inlabelset == 1) {
|
||||
|
||||
msgreq_class = (struct oai_nw_drv_msg_class_add_request *)(gifr.msg);
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
msgreq_class->version = OAI_NW_DRV_MPLS_VERSION_CODE;
|
||||
|
||||
if (dscpset==0)
|
||||
msgreq_class->dscp=0;
|
||||
else
|
||||
msgreq_class->dscp=atoi(dscp);
|
||||
|
||||
msgreq_class->classref = atoi(classref) + (msgreq_class->lcr<<8);
|
||||
//msgreq_class->classref = 4 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=OAI_NW_DRV_DIRECTION_SEND;
|
||||
msgreq_class->fct=OAI_NW_DRV_FCT_QOS_SEND;
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = OAI_NW_DRV_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 = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
|
||||
msgreq_class->rab_id = atoi(rb);
|
||||
msgreq_class->lcr = atoi(cx);
|
||||
|
||||
msgreq_class->classref = atoi(classref) + 1 + (msgreq_class->lcr<<8);
|
||||
//msgreq_class->classref = 5 + (msgreq_class->lcr<<3);
|
||||
msgreq_class->dir=OAI_NW_DRV_DIRECTION_RECEIVE;
|
||||
|
||||
|
||||
// TO BE FIXED WHEN WE CAN SPECIFY A PROTOCOL-based rule
|
||||
msgreq_class->protocol = OAI_NW_DRV_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 = OAI_NW_DRV_MSG_CLASS_ADD_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
}
|
||||
|
||||
} else if (action == DEL_RB) {
|
||||
gifr.type = OAI_NW_DRV_MSG_RB_RELEASE_REQUEST;
|
||||
err=ioctl(fd, OAI_NW_DRV_IOCTL_RRM, &gifr);
|
||||
}
|
||||
}
|
||||
Executable
+202
@@ -0,0 +1,202 @@
|
||||
/*******************************************************************************
|
||||
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>
|
||||
#ifdef MPLS
|
||||
#include <net/mpls.h>
|
||||
#endif
|
||||
|
||||
|
||||
#define IN_CLASSA(a) ((((long int) (a)) & 0x80000000) == 0)
|
||||
#define IN_CLASSB(a) ((((long int) (a)) & 0xc0000000) == 0x80000000)
|
||||
#define IN_CLASSC(a) ((((long int) (a)) & 0xe0000000) == 0xc0000000)
|
||||
#define IN_CLASSD(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
|
||||
#define IN_MULTICAST(a) IN_CLASSD(a)
|
||||
#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xf0000000) == 0xf0000000)
|
||||
#define IN_BADCLASS(a) IN_EXPERIMENTAL((a))
|
||||
/* Address to accept any incoming messages. */
|
||||
#define INADDR_ANY ((unsigned long int) 0x00000000)
|
||||
/* Address to send to all hosts. */
|
||||
#define INADDR_BROADCAST ((unsigned long int) 0xffffffff)
|
||||
/* Address indicating an error return. */
|
||||
#define INADDR_NONE ((unsigned long int) 0xffffffff)
|
||||
|
||||
|
||||
#define NIPADDR(addr) \
|
||||
(uint8_t)(addr & 0x000000FF), \
|
||||
(uint8_t)((addr & 0x0000FF00) >> 8), \
|
||||
(uint8_t)((addr & 0x00FF0000) >> 16), \
|
||||
(uint8_t)((addr & 0xFF000000) >> 24)
|
||||
|
||||
#define NIP6ADDR(addr) \
|
||||
ntohs((addr)->s6_addr16[0]), \
|
||||
ntohs((addr)->s6_addr16[1]), \
|
||||
ntohs((addr)->s6_addr16[2]), \
|
||||
ntohs((addr)->s6_addr16[3]), \
|
||||
ntohs((addr)->s6_addr16[4]), \
|
||||
ntohs((addr)->s6_addr16[5]), \
|
||||
ntohs((addr)->s6_addr16[6]), \
|
||||
ntohs((addr)->s6_addr16[7])
|
||||
|
||||
|
||||
#define IN6_IS_ADDR_UNSPECIFIED(a) \
|
||||
(((__const uint32_t *) (a))[0] == 0 \
|
||||
&& ((__const uint32_t *) (a))[1] == 0 \
|
||||
&& ((__const uint32_t *) (a))[2] == 0 \
|
||||
&& ((__const uint32_t *) (a))[3] == 0)
|
||||
|
||||
#define IN6_IS_ADDR_LOOPBACK(a) \
|
||||
(((__const uint32_t *) (a))[0] == 0 \
|
||||
&& ((__const uint32_t *) (a))[1] == 0 \
|
||||
&& ((__const uint32_t *) (a))[2] == 0 \
|
||||
&& ((__const uint32_t *) (a))[3] == htonl (1))
|
||||
|
||||
#define IN6_IS_ADDR_MULTICAST(a) (((__const uint8_t *) (a))[0] == 0xff)
|
||||
|
||||
#define IN6_IS_ADDR_LINKLOCAL(a) \
|
||||
((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \
|
||||
== htonl (0xfe800000))
|
||||
|
||||
#define IN6_IS_ADDR_SITELOCAL(a) \
|
||||
((((__const uint32_t *) (a))[0] & htonl (0xffc00000)) \
|
||||
== htonl (0xfec00000))
|
||||
|
||||
#define IN6_IS_ADDR_V4MAPPED(a) \
|
||||
((((__const uint32_t *) (a))[0] == 0) \
|
||||
&& (((__const uint32_t *) (a))[1] == 0) \
|
||||
&& (((__const uint32_t *) (a))[2] == htonl (0xffff)))
|
||||
|
||||
#define IN6_IS_ADDR_V4COMPAT(a) \
|
||||
((((__const uint32_t *) (a))[0] == 0) \
|
||||
&& (((__const uint32_t *) (a))[1] == 0) \
|
||||
&& (((__const uint32_t *) (a))[2] == 0) \
|
||||
&& (ntohl (((__const uint32_t *) (a))[3]) > 1))
|
||||
|
||||
#define IN6_ARE_ADDR_EQUAL(a,b) \
|
||||
((((__const uint32_t *) (a))[0] == ((__const uint32_t *) (b))[0]) \
|
||||
&& (((__const uint32_t *) (a))[1] == ((__const uint32_t *) (b))[1]) \
|
||||
&& (((__const uint32_t *) (a))[2] == ((__const uint32_t *) (b))[2]) \
|
||||
&& (((__const uint32_t *) (a))[3] == ((__const uint32_t *) (b))[3]))
|
||||
|
||||
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
|
||||
(IN6_IS_ADDR_MULTICAST(a) \
|
||||
&& ((((__const uint8_t *) (a))[1] & 0xf) == 0x1))
|
||||
|
||||
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
|
||||
(IN6_IS_ADDR_MULTICAST(a) \
|
||||
&& ((((__const uint8_t *) (a))[1] & 0xf) == 0x2))
|
||||
|
||||
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
|
||||
(IN6_IS_ADDR_MULTICAST(a) \
|
||||
&& ((((__const uint8_t *) (a))[1] & 0xf) == 0x5))
|
||||
|
||||
#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
|
||||
(IN6_IS_ADDR_MULTICAST(a) \
|
||||
&& ((((__const uint8_t *) (a))[1] & 0xf) == 0x8))
|
||||
|
||||
#define IN6_IS_ADDR_MC_GLOBAL(a) \
|
||||
(IN6_IS_ADDR_MULTICAST(a) \
|
||||
&& ((((__const uint8_t *) (a))[1] & 0xf) == 0xe))
|
||||
|
||||
#define IN6_ARE_ADDR_MASKED_EQUAL(a,b,m) \
|
||||
(((((__const uint32_t *) (a))[0] & (((__const uint32_t *) (m))[0])) == (((__const uint32_t *) (b))[0] & (((__const uint32_t *) (m))[0]))) \
|
||||
&& ((((__const uint32_t *) (a))[1] & (((__const uint32_t *) (m))[1])) == (((__const uint32_t *) (b))[1] & (((__const uint32_t *) (m))[1]))) \
|
||||
&& ((((__const uint32_t *) (a))[2] & (((__const uint32_t *) (m))[2])) == (((__const uint32_t *) (b))[2] & (((__const uint32_t *) (m))[2]))) \
|
||||
&& ((((__const uint32_t *) (a))[3] & (((__const uint32_t *) (m))[3])) == (((__const uint32_t *) (b))[3] & (((__const uint32_t *) (m))[3]))))
|
||||
|
||||
#define IN_ARE_ADDR_MASKED_EQUAL(a,b,m) \
|
||||
(((((__const uint8_t *) (a))[0] & (((__const uint8_t *) (m))[0])) == (((__const uint8_t *) (b))[0] & (((__const uint8_t *) (m))[0]))) \
|
||||
&& ((((__const uint8_t *) (a))[1] & (((__const uint8_t *) (m))[1])) == (((__const uint8_t *) (b))[1] & (((__const uint8_t *) (m))[1]))) \
|
||||
&& ((((__const uint8_t *) (a))[2] & (((__const uint8_t *) (m))[2])) == (((__const uint8_t *) (b))[2] & (((__const uint8_t *) (m))[2]))) \
|
||||
&& ((((__const uint8_t *) (a))[3] & (((__const uint8_t *) (m))[3])) == (((__const uint8_t *) (b))[3] & (((__const uint8_t *) (m))[3]))))
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Find the IP traffic type (UNICAST, MULTICAST, BROADCAST)
|
||||
ip_traffic_type_t oai_nw_drv_find_traffic_type(struct sk_buff *skb)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
ip_traffic_type_t traffic_type = TRAFFIC_IPVX_TYPE_UNKNOWN;
|
||||
|
||||
if (skb!=NULL) {
|
||||
switch (ntohs(skb->protocol)) {
|
||||
case ETH_P_IPV6:
|
||||
traffic_type = TRAFFIC_IPV6_TYPE_UNKNOWN;
|
||||
#ifdef OAI_DRV_DEBUG_CLASS
|
||||
printk("SOURCE ADDR %X:%X:%X:%X:%X:%X:%X:%X",NIP6ADDR(&(ipv6_hdr(skb)->saddr)));
|
||||
printk(" DEST ADDR %X:%X:%X:%X:%X:%X:%X:%X\n",NIP6ADDR(&(ipv6_hdr(skb)->daddr)));
|
||||
#endif
|
||||
|
||||
if (IN6_IS_ADDR_MULTICAST(&ipv6_hdr(skb)->daddr.in6_u.u6_addr32[0])) {
|
||||
traffic_type = TRAFFIC_IPV6_TYPE_MULTICAST;
|
||||
|
||||
} else {
|
||||
traffic_type = TRAFFIC_IPV6_TYPE_UNICAST;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case ETH_P_IP:
|
||||
traffic_type = TRAFFIC_IPV4_TYPE_UNKNOWN;
|
||||
|
||||
//print_TOOL_pk_ipv4((struct iphdr *)skb->network_header);
|
||||
if (IN_MULTICAST(htonl(ip_hdr(skb)->daddr))) {
|
||||
traffic_type = TRAFFIC_IPV4_TYPE_MULTICAST;
|
||||
} else {
|
||||
traffic_type = TRAFFIC_IPV4_TYPE_UNICAST;
|
||||
}
|
||||
|
||||
// TO DO BROADCAST
|
||||
|
||||
break;
|
||||
|
||||
case ETH_P_ARP:
|
||||
traffic_type = TRAFFIC_IPV4_TYPE_BROADCAST;
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
return traffic_type;
|
||||
}
|
||||
|
||||
Executable
+459
@@ -0,0 +1,459 @@
|
||||
/*******************************************************************************
|
||||
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 "local.h"
|
||||
#include "proto_extern.h"
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
#include "rtai_fifos.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <linux/inetdevice.h>
|
||||
#ifdef OAI_NW_DRIVER_TYPE_ETHERNET
|
||||
#include <linux/etherdevice.h>
|
||||
#endif
|
||||
|
||||
#include <net/tcp.h>
|
||||
#include <net/udp.h>
|
||||
|
||||
#define NIPADDR(addr) \
|
||||
(uint8_t)(addr & 0x000000FF), \
|
||||
(uint8_t)((addr & 0x0000FF00) >> 8), \
|
||||
(uint8_t)((addr & 0x00FF0000) >> 16), \
|
||||
(uint8_t)((addr & 0xFF000000) >> 24)
|
||||
|
||||
#define NIP6ADDR(addr) \
|
||||
ntohs((addr)->s6_addr16[0]), \
|
||||
ntohs((addr)->s6_addr16[1]), \
|
||||
ntohs((addr)->s6_addr16[2]), \
|
||||
ntohs((addr)->s6_addr16[3]), \
|
||||
ntohs((addr)->s6_addr16[4]), \
|
||||
ntohs((addr)->s6_addr16[5]), \
|
||||
ntohs((addr)->s6_addr16[6]), \
|
||||
ntohs((addr)->s6_addr16[7])
|
||||
|
||||
|
||||
//#define OAI_DRV_DEBUG_SEND
|
||||
//#define OAI_DRV_DEBUG_RECEIVE
|
||||
void oai_nw_drv_common_class_wireless2ip(uint16_t dlen,
|
||||
void *pdcp_sdu,
|
||||
int inst,
|
||||
OaiNwDrvRadioBearerId_t rb_id)
|
||||
{
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
struct sk_buff *skb;
|
||||
struct ipversion *ipv;
|
||||
struct oai_nw_drv_priv *gpriv=netdev_priv(oai_nw_drv_dev[inst]);
|
||||
unsigned int hard_header_len = 0;
|
||||
uint16_t *p_ether_type;
|
||||
uint16_t ether_type;
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
int i;
|
||||
unsigned char *addr;
|
||||
#endif
|
||||
unsigned char protocol;
|
||||
struct iphdr *network_header;
|
||||
|
||||
#ifdef NAS_ADDRESS_FIX
|
||||
uint32_t odaddr,osaddr;
|
||||
unsigned char *addr,*daddr,*saddr,*ifaddr;
|
||||
uint16_t *cksum,check;
|
||||
#endif // NAS_ADDRESS_FIX
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[OAI_IP_DRV][%s] begin RB %d Inst %d Length %d bytes\n",__FUNCTION__, rb_id,inst,dlen);
|
||||
#endif
|
||||
|
||||
skb = dev_alloc_skb( dlen + 2 );
|
||||
|
||||
if(!skb) {
|
||||
printk("[OAI_IP_DRV][%s] low on memory\n",__FUNCTION__);
|
||||
++gpriv->stats.rx_dropped;
|
||||
return;
|
||||
}
|
||||
|
||||
skb_reserve(skb,2);
|
||||
memcpy(skb_put(skb, dlen), pdcp_sdu,dlen);
|
||||
|
||||
skb->dev = oai_nw_drv_dev[inst];
|
||||
hard_header_len = oai_nw_drv_dev[inst]->hard_header_len;
|
||||
|
||||
skb_set_mac_header(skb, 0);
|
||||
skb_set_network_header(skb, hard_header_len);
|
||||
skb->mark = rb_id;
|
||||
skb->pkt_type = PACKET_HOST;
|
||||
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[OAI_IP_DRV][%s] Receiving packet @%p of size %d from PDCP \n",__FUNCTION__, skb->data, skb->len);
|
||||
|
||||
for (i=0; i<skb->len; i++)
|
||||
printk("%2x ",((unsigned char *)(skb->data))[i]);
|
||||
|
||||
printk("\n");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// LG TEST skb->ip_summed = CHECKSUM_NONE;
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
|
||||
|
||||
ipv = (struct ipversion *)skb_network_header(skb);
|
||||
|
||||
switch (ipv->version) {
|
||||
|
||||
case 6:
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[OAI_IP_DRV][%s] receive IPv6 message\n",__FUNCTION__);
|
||||
#endif
|
||||
skb_set_network_header(skb, hard_header_len);
|
||||
|
||||
//skb->network_header = &skb->data[hard_header_len];
|
||||
if (hard_header_len == 0) {
|
||||
skb->protocol = htons(ETH_P_IPV6);
|
||||
} else {
|
||||
#ifdef OAI_NW_DRIVER_TYPE_ETHERNET
|
||||
skb->protocol = eth_type_trans(skb, oai_nw_drv_dev[inst]);
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
//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[hard_header_len])->daddr;
|
||||
odaddr = ((struct iphdr *)skb->data)->daddr;
|
||||
//sn = addr[3];
|
||||
saddr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->saddr;
|
||||
osaddr = ((struct iphdr *)&skb->data[hard_header_len])->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 *)((oai_nw_drv_dev[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 OAI_DRV_DEBUG_RECEIVE
|
||||
//printk("NAS_TOOL_RECEIVE: receive IPv4 message\n");
|
||||
addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->saddr;
|
||||
|
||||
if (addr) {
|
||||
//addr[2]^=0x01;
|
||||
printk("[OAI_IP_DRV][%s] Source %d.%d.%d.%d\n",__FUNCTION__, addr[0],addr[1],addr[2],addr[3]);
|
||||
}
|
||||
|
||||
addr = (unsigned char *)&((struct iphdr *)&skb->data[hard_header_len])->daddr;
|
||||
|
||||
if (addr) {
|
||||
//addr[2]^=0x01;
|
||||
printk("[OAI_IP_DRV][%s] Dest %d.%d.%d.%d\n",__FUNCTION__, addr[0],addr[1],addr[2],addr[3]);
|
||||
}
|
||||
|
||||
printk("[OAI_IP_DRV][%s] protocol %d\n",__FUNCTION__, ((struct iphdr *)&skb->data[hard_header_len])->protocol);
|
||||
#endif
|
||||
|
||||
skb_set_network_header(skb, hard_header_len);
|
||||
//skb->network_header = &skb->data[hard_header_len];
|
||||
network_header = (struct iphdr *)skb_network_header(skb);
|
||||
protocol = network_header->protocol;
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
|
||||
switch (protocol) {
|
||||
case IPPROTO_IP:
|
||||
printk("[OAI_IP_DRV][%s] Received Raw IPv4 packet\n",__FUNCTION__);
|
||||
break;
|
||||
|
||||
case IPPROTO_IPV6:
|
||||
printk("[OAI_IP_DRV][%s] Received Raw IPv6 packet\n",__FUNCTION__);
|
||||
break;
|
||||
|
||||
case IPPROTO_ICMP:
|
||||
printk("[OAI_IP_DRV][%s] Received Raw ICMP packet\n",__FUNCTION__);
|
||||
break;
|
||||
|
||||
case IPPROTO_TCP:
|
||||
printk("[OAI_IP_DRV][%s] Received TCP packet\n",__FUNCTION__);
|
||||
break;
|
||||
|
||||
case IPPROTO_UDP:
|
||||
printk("[OAI_IP_DRV][%s] Received UDP packet\n",__FUNCTION__);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef NAS_ADDRESS_FIX
|
||||
network_header->check = 0;
|
||||
network_header->check = ip_fast_csum((unsigned char *) network_header, network_header->ihl);
|
||||
//printk("[OAI_IP_DRV][COMMON][RECEIVE] IP Fast Checksum %x \n", network_header->check);
|
||||
|
||||
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, 0,0, ~(*cksum));
|
||||
//check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, tcp_hdrlen(skb), IPPROTO_TCP, ~(*cksum));
|
||||
//check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, dlen, IPPROTO_TCP, ~(*cksum));
|
||||
|
||||
*cksum = csum_tcpudp_magic(~osaddr, ~odaddr, 0, 0, ~check);
|
||||
//*cksum = csum_tcpudp_magic(~osaddr, ~odaddr, dlen, IPPROTO_TCP, ~check);
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[OAI_IP_DRV][%s] Inst %d TCP packet calculated CS %x, CS = %x (before), SA (%x)%x, DA (%x)%x\n",__FUNCTION__,
|
||||
inst,
|
||||
network_header->check,
|
||||
*cksum,
|
||||
osaddr,
|
||||
((struct iphdr *)skb->data)->saddr,
|
||||
odaddr,
|
||||
((struct iphdr *)skb->data)->daddr);
|
||||
|
||||
printk("[OAI_IP_DRV][%s] Inst %d TCP packet NEW CS %x\n",__FUNCTION__,
|
||||
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, 0,0, ~(*cksum));
|
||||
// check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, udp_hdr(skb)->len, IPPROTO_UDP, ~(*cksum));
|
||||
//check = csum_tcpudp_magic(((struct iphdr *)network_header)->saddr, ((struct iphdr *)network_header)->daddr, dlen, IPPROTO_UDP, ~(*cksum));
|
||||
|
||||
*cksum= csum_tcpudp_magic(~osaddr, ~odaddr,0,0, ~check);
|
||||
//*cksum= csum_tcpudp_magic(~osaddr, ~odaddr,udp_hdr(skb)->len, IPPROTO_UDP, ~check);
|
||||
//*cksum= csum_tcpudp_magic(~osaddr, ~odaddr,dlen, IPPROTO_UDP, ~check);
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[OAI_IP_DRV][%s] Inst %d UDP packet CS = %x (before), SA (%x)%x, DA (%x)%x\n",__FUNCTION__,
|
||||
inst,*cksum,osaddr,((struct iphdr *)&skb->data[hard_header_len])->saddr,odaddr,((struct iphdr *)&skb->data[hard_header_len])->daddr);
|
||||
|
||||
printk("[OAI_IP_DRV][%s] Inst %d UDP packet NEW CS %x\n",__FUNCTION__,inst,*cksum);
|
||||
#endif
|
||||
//if ((check = *cksum) != 0) {
|
||||
// src, dst, len, proto, sum
|
||||
// }
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#endif //NAS_ADDRESS_FIX
|
||||
|
||||
if (hard_header_len == 0) {
|
||||
skb->protocol = htons(ETH_P_IP);
|
||||
} else {
|
||||
#ifdef OAI_NW_DRIVER_TYPE_ETHERNET
|
||||
skb->protocol = eth_type_trans(skb, oai_nw_drv_dev[inst]);
|
||||
#else
|
||||
#endif
|
||||
}
|
||||
|
||||
//printk("[OAI_IP_DRV][COMMON] Writing packet with protocol %x\n",ntohs(skb->protocol));
|
||||
break;
|
||||
|
||||
default:
|
||||
// fill skb->pkt_type, skb->dev
|
||||
|
||||
skb->protocol = eth_type_trans(skb, oai_nw_drv_dev[inst]);
|
||||
// minus 1(short) instead of 2(bytes) because uint16_t*
|
||||
p_ether_type = (uint16_t *)(skb_network_header(skb)-2);
|
||||
ether_type = ntohs(*p_ether_type);
|
||||
|
||||
switch (ether_type) {
|
||||
case ETH_P_ARP:
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[OAI_IP_DRV][%s] ether_type = ETH_P_ARP\n",__FUNCTION__);
|
||||
#endif
|
||||
//skb->pkt_type = PACKET_HOST;
|
||||
skb->protocol = htons(ETH_P_ARP);
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
printk("[OAI_IP_DRV][%s] begin RB %d Inst %d Length %d bytes\n",__FUNCTION__,rb_id,inst,dlen);
|
||||
printk("[OAI_IP_DRV][%s] Inst %d: receive unknown message (version=%d)\n",__FUNCTION__,inst,ipv->version);
|
||||
}
|
||||
|
||||
++gpriv->stats.rx_packets;
|
||||
gpriv->stats.rx_bytes += dlen;
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[OAI_IP_DRV][%s] sending packet of size %d to kernel\n",__FUNCTION__,skb->len);
|
||||
|
||||
for (i=0; i<skb->len; i++)
|
||||
printk("%2x ",((unsigned char *)(skb->data))[i]);
|
||||
|
||||
printk("\n");
|
||||
#endif //OAI_DRV_DEBUG_RECEIVE
|
||||
netif_rx(skb);
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[OAI_IP_DRV][%s] end\n",__FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Delete the data
|
||||
void oai_nw_drv_common_ip2wireless_drop(struct sk_buff *skb, int inst)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct oai_nw_drv_priv *priv=netdev_priv(oai_nw_drv_dev[inst]);
|
||||
++priv->stats.tx_dropped;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Request the transfer of data (QoS SAP)
|
||||
void oai_nw_drv_common_ip2wireless(struct sk_buff *skb, int inst)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct pdcp_data_req_header_s pdcph;
|
||||
struct oai_nw_drv_priv *priv=netdev_priv(oai_nw_drv_dev[inst]);
|
||||
#ifdef LOOPBACK_TEST
|
||||
int i;
|
||||
#endif
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
int j;
|
||||
#endif
|
||||
unsigned int bytes_wrote;
|
||||
// Start debug information
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[OAI_IP_DRV][%s] inst %d begin \n",__FUNCTION__,inst);
|
||||
#endif
|
||||
|
||||
if (skb==NULL) {
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[OAI_IP_DRV][%s] input parameter skb is NULL \n",__FUNCTION__);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
pdcph.data_size = skb->len;
|
||||
pdcph.rb_id = skb->mark;
|
||||
pdcph.inst = inst;
|
||||
pdcph.traffic_type = oai_nw_drv_find_traffic_type(skb);
|
||||
|
||||
|
||||
bytes_wrote = oai_nw_drv_netlink_send((char *)&pdcph,OAI_NW_DRV_PDCPH_SIZE);
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[OAI_IP_DRV][%s] Wrote %d bytes (header for %d byte skb) to PDCP RB %d via netlink\n",__FUNCTION__,
|
||||
bytes_wrote,skb->len, pdcph.rb_id);
|
||||
#endif
|
||||
|
||||
|
||||
if (bytes_wrote != OAI_NW_DRV_PDCPH_SIZE) {
|
||||
printk("[OAI_IP_DRV][%s] problem while writing PDCP's header (bytes wrote = %d to fifo %d)\n",__FUNCTION__,bytes_wrote,IP2PDCP_FIFO);
|
||||
printk("rb_id %u, Wrote %u, Header Size %lu \n", pdcph.rb_id , bytes_wrote, OAI_NW_DRV_PDCPH_SIZE);
|
||||
priv->stats.tx_dropped ++;
|
||||
return;
|
||||
}
|
||||
|
||||
bytes_wrote += oai_nw_drv_netlink_send((char *)skb->data,skb->len);
|
||||
|
||||
|
||||
if (bytes_wrote != skb->len+OAI_NW_DRV_PDCPH_SIZE) {
|
||||
printk("[OAI_IP_DRV][%s] Inst %d, RB_ID %u: problem while writing PDCP's data, bytes_wrote = %u, Data_len %u, PDCPH_SIZE %lu\n",
|
||||
__FUNCTION__,
|
||||
inst,
|
||||
pdcph.rb_id,
|
||||
bytes_wrote,
|
||||
skb->len,
|
||||
OAI_NW_DRV_PDCPH_SIZE); // congestion
|
||||
|
||||
priv->stats.tx_dropped ++;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[OAI_IP_DRV][%s] Sending packet of size %d to PDCP traffic type %d\n",__FUNCTION__,skb->len, pdcph.traffic_type);
|
||||
|
||||
for (j=0; j<skb->len; j++)
|
||||
printk("%2x ",((unsigned char *)(skb->data))[j]);
|
||||
|
||||
printk("\n");
|
||||
#endif
|
||||
|
||||
priv->stats.tx_bytes += skb->len;
|
||||
priv->stats.tx_packets ++;
|
||||
#ifdef OAI_DRV_DEBUG_SEND
|
||||
printk("[OAI_IP_DRV][%s] end \n",__FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void oai_nw_drv_common_wireless2ip(struct nlmsghdr *nlh)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
struct pdcp_data_ind_header_s *pdcph = (struct pdcp_data_ind_header_s *)NLMSG_DATA(nlh);
|
||||
struct oai_nw_drv_priv *priv;
|
||||
|
||||
priv = netdev_priv(oai_nw_drv_dev[pdcph->inst]);
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_RECEIVE
|
||||
printk("[OAI_IP_DRV][%s] QOS receive from PDCP, size %d, rab %d, inst %d\n",__FUNCTION__,
|
||||
pdcph->data_size,pdcph->rb_id,pdcph->inst);
|
||||
#endif //OAI_DRV_DEBUG_RECEIVE
|
||||
|
||||
oai_nw_drv_common_class_wireless2ip(pdcph->data_size,
|
||||
(unsigned char *)NLMSG_DATA(nlh) + OAI_NW_DRV_PDCPH_SIZE,
|
||||
pdcph->inst,
|
||||
pdcph->rb_id);
|
||||
}
|
||||
|
||||
|
||||
Executable
+183
@@ -0,0 +1,183 @@
|
||||
/*******************************************************************************
|
||||
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 _OAI_NW_DRV_CST
|
||||
#define _OAI_NW_DRV_CST
|
||||
|
||||
#define MAX_MEASURE_NB 5
|
||||
#define OAI_NW_DRV_MAX_LENGTH 180
|
||||
|
||||
//Debug flags
|
||||
//#define OAI_NW_DRV_DEBUG_DC
|
||||
#define OAI_NW_DRV_DEBUG_SEND
|
||||
#define OAI_NW_DRV_DEBUG_RECEIVE
|
||||
//#define OAI_NW_DRV_DEBUG_CLASS
|
||||
//#define OAI_NW_DRV_DEBUG_GC
|
||||
//#define OAI_NW_DRV_DEBUG_DC_MEASURE
|
||||
//#define OAI_NW_DRV_DEBUG_TIMER
|
||||
//#define OAI_NW_DRV_DEBUG_DEVICE
|
||||
//#define OAI_NW_DRV_DEBUG_INTERRUPT
|
||||
//#define OAI_NW_DRV_DEBUG_TOOL
|
||||
|
||||
// Other flags
|
||||
#define DEMO_3GSM
|
||||
|
||||
// General Constants
|
||||
#define OAI_NW_DRV_MTU 1500
|
||||
#define OAI_NW_DRV_TX_QUEUE_LEN 100
|
||||
#define OAI_NW_DRV_ADDR_LEN 8
|
||||
#define OAI_NW_DRV_INET6_ADDRSTRLEN 46
|
||||
#define OAI_NW_DRV_INET_ADDRSTRLEN 16
|
||||
|
||||
#define OAI_NW_DRV_RESET_RX_FLAGS 0
|
||||
|
||||
#define OAI_NW_DRV_CX_MAX 32 //Identical to RRC constant
|
||||
//#define OAI_NW_DRV_CX_MULTICAST_ALLNODE 2
|
||||
|
||||
#define OAI_NW_DRV_RETRY_LIMIT_DEFAULT 5
|
||||
|
||||
#define OAI_NW_DRV_MESSAGE_MAXLEN 5004
|
||||
|
||||
#define OAI_NW_DRV_SIG_SRB3 3
|
||||
#define OAI_NW_DRV_SIG_SRB4 3 // not used yet
|
||||
|
||||
//peer-to-peer messages between NAS entities
|
||||
#define OAI_NW_DRV_CMD_OPEN_RB 1
|
||||
|
||||
//#define OAI_NW_DRV_IID1_CONTROL 0x0
|
||||
//#define OAI_NW_DRV_IID2_CONTROL __constant_htonl(0xffffffff)
|
||||
|
||||
//#define OAI_NW_DRV_STATE_IDLE 0
|
||||
//#define OAI_NW_DRV_STATE_CONNECTED 1
|
||||
//#define OAI_NW_DRV_STATE_ESTABLISHMENT_REQUEST 2
|
||||
//#define OAI_NW_DRV_STATE_ESTABLISHMENT_FAILURE 3
|
||||
//#define OAI_NW_DRV_STATE_RELEASE_FAILURE 4
|
||||
#define OAI_NW_DRV_CX_RELEASE_UNDEF_CAUSE 1
|
||||
|
||||
// MT+RG NAS States
|
||||
#define OAI_NW_DRV_IDLE 0x01
|
||||
// Connection
|
||||
#define OAI_NW_DRV_CX_FACH 0x06
|
||||
#define OAI_NW_DRV_CX_DCH 0x0A
|
||||
#define OAI_NW_DRV_CX_RECEIVED 0x10
|
||||
#define OAI_NW_DRV_CX_CONNECTING 0x04
|
||||
#define OAI_NW_DRV_CX_RELEASING 0x08
|
||||
#define OAI_NW_DRV_CX_CONNECTING_FAILURE 0x14
|
||||
#define OAI_NW_DRV_CX_RELEASING_FAILURE 0x18
|
||||
// Radio Bearers
|
||||
#define OAI_NW_DRV_RB_ESTABLISHING 0x24
|
||||
#define OAI_NW_DRV_RB_RELEASING 0x28
|
||||
#define OAI_NW_DRV_RB_DCH 0x2A
|
||||
|
||||
|
||||
#define OAI_NW_DRV_TIMER_ESTABLISHMENT_DEFAULT 12
|
||||
#define OAI_NW_DRV_TIMER_RELEASE_DEFAULT 2
|
||||
#define OAI_NW_DRV_TIMER_IDLE UINT_MAX
|
||||
#define OAI_NW_DRV_TIMER_TICK HZ
|
||||
|
||||
#define OAI_NW_DRV_PDCPH_SIZE sizeof(struct pdcp_data_req_header_s)
|
||||
#define OAI_NW_DRV_IPV4_SIZE 20
|
||||
#define OAI_NW_DRV_IPV6_SIZE 40
|
||||
|
||||
#define OAI_NW_DRV_DIRECTION_SEND 0
|
||||
#define OAI_NW_DRV_DIRECTION_RECEIVE 1
|
||||
#define OAI_NW_DRV_DIRECTION_FORWARD 2
|
||||
|
||||
// function number
|
||||
#define OAI_NW_DRV_FCT_DEL_SEND 1
|
||||
#define OAI_NW_DRV_FCT_QOS_SEND 2
|
||||
#define OAI_NW_DRV_FCT_DC_SEND 3
|
||||
#define OAI_NW_DRV_FCT_CTL_SEND 4
|
||||
|
||||
// type of IOCTL command
|
||||
#define OAI_NW_DRV_IOCTL_RRM 0x89F0
|
||||
|
||||
// Error cause
|
||||
#define OAI_NW_DRV_ERROR_ALREADYEXIST 1
|
||||
#define OAI_NW_DRV_ERROR_NOMEMORY 3
|
||||
#define OAI_NW_DRV_ERROR_NOTMT 9
|
||||
#define OAI_NW_DRV_ERROR_NOTRG 10
|
||||
#define OAI_NW_DRV_ERROR_NOTIDLE 11
|
||||
#define OAI_NW_DRV_ERROR_NOTCONNECTED 12
|
||||
#define OAI_NW_DRV_ERROR_NORB 14
|
||||
#define OAI_NW_DRV_ERROR_NOTCORRECTVALUE 32
|
||||
#define OAI_NW_DRV_ERROR_NOTCORRECTLCR 33
|
||||
#define OAI_NW_DRV_ERROR_NOTCORRECTDIR 34
|
||||
#define OAI_NW_DRV_ERROR_NOTCORRECTDSCP 35
|
||||
#define OAI_NW_DRV_ERROR_NOTCORRECTVERSION 36
|
||||
#define OAI_NW_DRV_ERROR_NOTCORRECTRABI 37
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/* Constants related with IP protocols */
|
||||
/**********************************************************/
|
||||
|
||||
//#define OAI_NW_DRV_PORT_CONTROL __constant_htons(0xc45)
|
||||
//#define OAI_NW_DRV_PORT_AUTHENTICATION __constant_htons(1811)
|
||||
|
||||
#define OAI_NW_DRV_TRAFFICCLASS_MASK __constant_htonl(0x0fc00000)
|
||||
|
||||
// Network control codepoint 111000 + IP version 6
|
||||
#define OAI_NW_DRV_FLOWINFO_NCONTROL __constant_htonl(0x6e000000)
|
||||
// network control codepoint 111000
|
||||
#define OAI_NW_DRV_DSCP_NCONTROL 56 //0x38
|
||||
// default codepoint 1000000
|
||||
#define OAI_NW_DRV_DSCP_DEFAULT 64
|
||||
#define OAI_NW_DRV_DSCP_MAX 193
|
||||
|
||||
#define OAI_NW_DRV_PROTOCOL_DEFAULT 0
|
||||
#define OAI_NW_DRV_PROTOCOL_TCP IPPROTO_TCP
|
||||
#define OAI_NW_DRV_PROTOCOL_UDP IPPROTO_UDP
|
||||
#define OAI_NW_DRV_PROTOCOL_ICMP4 IPPROTO_ICMP
|
||||
#define OAI_NW_DRV_PROTOCOL_ICMP6 IPPROTO_ICMPV6
|
||||
//#warning "OAI_NW_DRV_PROTOCOL_ARP value 200 may collide with new defined values in kernel"
|
||||
#define OAI_NW_DRV_PROTOCOL_ARP 200
|
||||
|
||||
#define OAI_NW_DRV_PORT_DEFAULT __constant_htons(65535)
|
||||
#define OAI_NW_DRV_PORT_HTTP __constant_htons(80)
|
||||
|
||||
#define OAI_NW_DRV_IP_VERSION_ALL 0
|
||||
#define OAI_NW_DRV_IP_VERSION_4 4
|
||||
#define OAI_NW_DRV_IP_VERSION_6 6
|
||||
|
||||
#define OAI_NW_DRV_DEFAULT_IPV4_ADDR 0
|
||||
#define OAI_NW_DRV_DEFAULT_IPV6_ADDR0 0
|
||||
#define OAI_NW_DRV_DEFAULT_IPV6_ADDR1 0
|
||||
#define OAI_NW_DRV_DEFAULT_IPV6_ADDR2 0
|
||||
#define OAI_NW_DRV_DEFAULT_IPV6_ADDR3 0
|
||||
|
||||
|
||||
#define OAI_NW_DRV_MPLS_VERSION_CODE 99
|
||||
|
||||
#define OAI_NW_DRV_NB_INSTANCES_MAX 8
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Executable
+656
@@ -0,0 +1,656 @@
|
||||
/*******************************************************************************
|
||||
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 Ethernet
|
||||
* \author navid.nikaein, Lionel Gauthier, raymond.knopp,
|
||||
* \company Eurecom
|
||||
* \email:navid.nikaein@eurecom.fr, lionel.gauthier@eurecom.fr, raymond.knopp@eurecom.fr
|
||||
|
||||
*/
|
||||
/*******************************************************************************/
|
||||
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
#ifdef RTAI
|
||||
#include "rtai_posix.h"
|
||||
#define RTAI_IRQ 30 //try to get this irq with RTAI
|
||||
#endif // RTAI
|
||||
#endif // OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
#include "constant.h"
|
||||
#include "local.h"
|
||||
#include "proto_extern.h"
|
||||
|
||||
//#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#ifdef OAI_NW_DRIVER_TYPE_ETHERNET
|
||||
#include <linux/if_ether.h>
|
||||
#endif
|
||||
#include <asm/io.h>
|
||||
#include <asm/bitops.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/segment.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/delay.h>
|
||||
#include <asm/unistd.h>
|
||||
#include <linux/netdevice.h>
|
||||
#ifdef OAI_NW_DRIVER_TYPE_ETHERNET
|
||||
#include <linux/etherdevice.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct net_device *oai_nw_drv_dev[OAI_NW_DRV_NB_INSTANCES_MAX];
|
||||
|
||||
#ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
extern void oai_nw_drv_netlink_release(void);
|
||||
extern int oai_nw_drv_netlink_init(void);
|
||||
#endif
|
||||
|
||||
uint8_t NULL_IMEI[14]= {0x05, 0x04, 0x03, 0x01, 0x02 ,0x00, 0x00, 0x00, 0x05, 0x04, 0x03 ,0x00, 0x01, 0x08};
|
||||
|
||||
static unsigned char oai_nw_drv_IMEI[14];
|
||||
static int m_arg=0;
|
||||
static unsigned int oai_nw_drv_is_clusterhead=0;
|
||||
//---------------------------------------------------------------------------
|
||||
int oai_nw_drv_find_inst(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
int i;
|
||||
|
||||
for (i=0; i<OAI_NW_DRV_NB_INSTANCES_MAX; i++)
|
||||
if (oai_nw_drv_dev[i] == dev)
|
||||
return(i);
|
||||
|
||||
return(-1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
void *oai_nw_drv_interrupt(void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t cxi;
|
||||
|
||||
// struct oai_nw_drv_priv *priv=netdev_priv(dev_id);
|
||||
// unsigned int flags;
|
||||
// priv->lock = SPIN_LOCK_UNLOCKED;
|
||||
|
||||
#ifdef OAI_DRV_DEBUG_INTERRUPT
|
||||
printk("INTERRUPT - begin\n");
|
||||
#endif
|
||||
// spin_lock_irqsave(&priv->lock,flags);
|
||||
cxi=0;
|
||||
// mesh_GC_receive();
|
||||
// mesh_DC_receive(naspriv->cx+cxi);
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
oai_nw_drv_common_wireless2ip();
|
||||
#endif
|
||||
// spin_unlock_irqrestore(&priv->lock,flags);
|
||||
#ifdef OAI_DRV_DEBUG_INTERRUPT
|
||||
printk("INTERRUPT: end\n");
|
||||
#endif
|
||||
// return 0;
|
||||
}
|
||||
#endif //NETLINK
|
||||
//---------------------------------------------------------------------------
|
||||
void oai_nw_drv_timer(unsigned long data)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct oai_nw_drv_priv *priv=(struct oai_nw_drv_priv *)data;
|
||||
spin_lock(&priv->lock);
|
||||
(priv->timer).function=oai_nw_drv_timer;
|
||||
(priv->timer).expires=jiffies+OAI_NW_DRV_TIMER_TICK;
|
||||
(priv->timer).data=data;
|
||||
add_timer(&priv->timer);
|
||||
spin_unlock(&priv->lock);
|
||||
return;
|
||||
// add_timer(&gpriv->timer);
|
||||
// spin_unlock(&gpriv->lock);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Called by ifconfig when the device is activated by ifconfig
|
||||
int oai_nw_drv_open(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct oai_nw_drv_priv *priv=netdev_priv(dev);
|
||||
|
||||
// Address has already been set at init
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
if (pdcp_2_oai_nw_drv_irq==-EBUSY) {
|
||||
printk("[OAI_IP_DRV][%s] : irq failure\n", __FUNCTION__);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
#endif //OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
if(!netif_queue_stopped(dev))
|
||||
netif_start_queue(dev);
|
||||
else
|
||||
netif_wake_queue(dev);
|
||||
|
||||
init_timer(&priv->timer);
|
||||
(priv->timer).expires = jiffies+OAI_NW_DRV_TIMER_TICK;
|
||||
(priv->timer).data = (unsigned long)priv;
|
||||
(priv->timer).function = oai_nw_drv_timer;
|
||||
//add_timer(&priv->timer);
|
||||
|
||||
printk("[OAI_IP_DRV][%s] name = %s\n", __FUNCTION__, dev->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Called by ifconfig when the device is desactivated
|
||||
int oai_nw_drv_stop(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct oai_nw_drv_priv *priv = netdev_priv(dev);
|
||||
|
||||
printk("[OAI_IP_DRV][%s] Begin\n", __FUNCTION__);
|
||||
del_timer(&(priv->timer));
|
||||
netif_stop_queue(dev);
|
||||
// MOD_DEC_USE_COUNT;
|
||||
printk("[OAI_IP_DRV][%s] End\n", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void oai_nw_drv_teardown(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct oai_nw_drv_priv *priv;
|
||||
int inst;
|
||||
|
||||
printk("[OAI_IP_DRV][%s] Begin\n", __FUNCTION__);
|
||||
|
||||
if (dev) {
|
||||
priv = netdev_priv(dev);
|
||||
inst = oai_nw_drv_find_inst(dev);
|
||||
|
||||
if ((inst<0) || (inst>=OAI_NW_DRV_NB_INSTANCES_MAX)) {
|
||||
printk("[OAI_IP_DRV][%s] ERROR, couldn't find instance\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
/*oai_nw_drv_class_flush_recv_classifier(priv);
|
||||
|
||||
for (cxi=0;cxi<OAI_NW_DRV_CX_MAX;cxi++) {
|
||||
oai_nw_drv_common_flush_rb(priv->cx+cxi);
|
||||
oai_nw_drv_class_flush_send_classifier(priv->cx+cxi);
|
||||
}*/
|
||||
printk("[OAI_IP_DRV][%s] End\n", __FUNCTION__);
|
||||
} // check dev
|
||||
else {
|
||||
printk("[OAI_IP_DRV][%s] Device is null\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int oai_nw_drv_set_config(struct net_device *dev, struct ifmap *map)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
printk("[OAI_IP_DRV][%s] Begin\n", __FUNCTION__);
|
||||
|
||||
if (dev->flags & IFF_UP)
|
||||
return -EBUSY;
|
||||
|
||||
if (map->base_addr != dev->base_addr) {
|
||||
printk(KERN_WARNING "[OAI_IP_DRV][%s] Can't change I/O address\n", __FUNCTION__);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
if (map->irq != dev->irq)
|
||||
dev->irq = map->irq;
|
||||
|
||||
printk("[OAI_IP_DRV][%s] End\n", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
int oai_nw_drv_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
int inst;
|
||||
|
||||
if (dev) {
|
||||
inst = oai_nw_drv_find_inst(dev);
|
||||
} else {
|
||||
printk("[OAI_IP_DRV][%s] ERROR, device is null\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((inst>=0) && (inst<OAI_NW_DRV_NB_INSTANCES_MAX)) {
|
||||
#ifdef OAI_DRV_OAI_DRV_DEBUG_DEVICE
|
||||
printk("[OAI_IP_DRV][%s] inst %d, begin\n", __FUNCTION__,inst);
|
||||
#endif
|
||||
|
||||
if (!skb) {
|
||||
printk("[OAI_IP_DRV][%s] input parameter skb is NULL\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
netif_stop_queue(dev);
|
||||
dev->trans_start = jiffies;
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[OAI_IP_DRV][%s] step 1\n", __FUNCTION__);
|
||||
#endif
|
||||
oai_nw_drv_common_ip2wireless(skb,inst);
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[OAI_IP_DRV][%s] step 2\n", __FUNCTION__);
|
||||
#endif
|
||||
dev_kfree_skb(skb);
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[OAI_IP_DRV][%s] step 3\n", __FUNCTION__);
|
||||
#endif
|
||||
netif_wake_queue(dev);
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[OAI_IP_DRV][%s] end\n", __FUNCTION__);
|
||||
#endif
|
||||
} else {
|
||||
printk("[OAI_IP_DRV][%s] ERROR, couldn't find instance\n", __FUNCTION__);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
struct net_device_stats *oai_nw_drv_get_stats(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// return &((struct oai_nw_drv_priv *)dev->priv)->stats;
|
||||
struct oai_nw_drv_priv *priv = netdev_priv(dev);
|
||||
//printk("[OAI_IP_DRV][%s]\n", __FUNCTION__);
|
||||
return &priv->stats;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int oai_nw_drv_set_mac_address(struct net_device *dev, void *mac)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct sockaddr *addr = mac;
|
||||
printk("[OAI_IP_DRV][%s] CHANGE MAC ADDRESS\n", __FUNCTION__);
|
||||
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
|
||||
return 0;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int oai_nw_drv_change_mtu(struct net_device *dev, int mtu)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
printk("[OAI_IP_DRV][%s] CHANGE MTU %d bytes\n", __FUNCTION__, mtu);
|
||||
|
||||
if ((mtu<50) || (mtu>1500))
|
||||
return -EINVAL;
|
||||
|
||||
dev->mtu = mtu;
|
||||
return 0;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void oai_nw_drv_change_rx_flags(struct net_device *dev, int flags)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct oai_nw_drv_priv *priv = netdev_priv(dev);
|
||||
printk("[OAI_IP_DRV][%s] CHANGE RX FLAGS %08X\n", __FUNCTION__, flags);
|
||||
priv->rx_flags ^= flags;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void oai_nw_drv_tx_timeout(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Transmitter timeout, serious problems.
|
||||
struct oai_nw_drv_priv *priv = netdev_priv(dev);
|
||||
|
||||
printk("[OAI_IP_DRV][%s] begin\n", __FUNCTION__);
|
||||
// (struct oai_nw_drv_priv *)(dev->priv)->stats.tx_errors++;
|
||||
(priv->stats).tx_errors++;
|
||||
dev->trans_start = jiffies;
|
||||
netif_wake_queue(dev);
|
||||
printk("[OAI_IP_DRV][%s] transmit timed out %s\n", __FUNCTION__,dev->name);
|
||||
}
|
||||
|
||||
static const struct net_device_ops nasmesh_netdev_ops = {
|
||||
.ndo_open = oai_nw_drv_open,
|
||||
.ndo_stop = oai_nw_drv_stop,
|
||||
.ndo_start_xmit = oai_nw_drv_hard_start_xmit,
|
||||
.ndo_validate_addr = NULL,
|
||||
.ndo_get_stats = oai_nw_drv_get_stats,
|
||||
.ndo_set_mac_address = oai_nw_drv_set_mac_address,
|
||||
.ndo_set_config = oai_nw_drv_set_config,
|
||||
.ndo_do_ioctl = oai_nw_drv_CTL_ioctl,
|
||||
.ndo_change_mtu = oai_nw_drv_change_mtu,
|
||||
.ndo_tx_timeout = oai_nw_drv_tx_timeout,
|
||||
.ndo_change_rx_flags = oai_nw_drv_change_rx_flags,
|
||||
};
|
||||
/*.ndo_set_multicast_list = NULL,*/
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// Initialisation of the network device
|
||||
void oai_nw_drv_init(struct net_device *dev)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t cxi;
|
||||
struct oai_nw_drv_priv *priv;
|
||||
int index;
|
||||
|
||||
if (dev) {
|
||||
|
||||
priv = netdev_priv(dev);
|
||||
|
||||
memset(priv, 0, sizeof(struct oai_nw_drv_priv));
|
||||
|
||||
|
||||
#ifndef OAI_NW_DRIVER_TYPE_ETHERNET
|
||||
dev->type = ARPHRD_EURECOM_LTE;
|
||||
dev->features = NETIF_F_NO_CSUM;
|
||||
dev->hard_header_len = 0;
|
||||
dev->addr_len = ETH_ALEN; // 6
|
||||
dev->flags = IFF_BROADCAST | IFF_MULTICAST | IFF_NOARP;
|
||||
dev->tx_queue_len = NAS_TX_QUEUE_LEN;
|
||||
dev->mtu = NAS_MTU;
|
||||
#endif
|
||||
// Can be one of the following enum defined in include/linux/netdevice.h:
|
||||
// enum netdev_state_t {
|
||||
// __LINK_STATE_START,
|
||||
// __LINK_STATE_PRESENT,
|
||||
// __LINK_STATE_NOCARRIER,
|
||||
// __LINK_STATE_LINKWATCH_PENDING,
|
||||
// __LINK_STATE_DORMANT,
|
||||
// };
|
||||
set_bit(__LINK_STATE_PRESENT, &dev->state);
|
||||
|
||||
//
|
||||
dev->netdev_ops = &nasmesh_netdev_ops;
|
||||
#ifdef OAI_NW_DRIVER_TYPE_ETHERNET
|
||||
printk("[OAI_IP_DRV][%s] Driver type ETHERNET\n", __FUNCTION__);
|
||||
// Memo: linux-source-3.2.0/net/ethernet/eth.c:
|
||||
//334 void ether_setup(struct net_device *dev)
|
||||
//335 {
|
||||
//336 dev->header_ops = ð_header_ops;
|
||||
//337 dev->type = ARPHRD_ETHER;
|
||||
//338 dev->hard_header_len = ETH_HLEN;
|
||||
//339 dev->mtu = ETH_DATA_LEN;
|
||||
//340 dev->addr_len = ETH_ALEN;
|
||||
//341 dev->tx_queue_len = 1000; /* Ethernet wants good queues */
|
||||
//342 dev->flags = IFF_BROADCAST|IFF_MULTICAST;
|
||||
//343 dev->priv_flags |= IFF_TX_SKB_SHARING;
|
||||
//344
|
||||
//345 memset(dev->broadcast, 0xFF, ETH_ALEN);
|
||||
//346 }
|
||||
ether_setup(dev);
|
||||
#endif
|
||||
//
|
||||
// Initialize private structure
|
||||
priv->rx_flags = OAI_NW_DRV_RESET_RX_FLAGS;
|
||||
priv->sap[OAI_NW_DRV_RAB_INPUT_SAPI] = PDCP2IP_FIFO;//QOS_DEVICE_CONVERSATIONAL_INPUT;
|
||||
priv->sap[OAI_NW_DRV_RAB_OUTPUT_SAPI] = IP2PDCP_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<OAI_NW_DRV_DSCP_MAX; ++dscpi) {
|
||||
priv->rclassifier[dscpi]=NULL;
|
||||
}
|
||||
priv->nrclassifier=0;*/
|
||||
//
|
||||
for (cxi=0; cxi<OAI_NW_DRV_CX_MAX; cxi++) {
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("[OAI_IP_DRV][%s] init classifiers, state and timer for MT %u\n", __FUNCTION__, 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 = OAI_NW_DRV_IDLE;
|
||||
priv->cx[cxi].countimer = OAI_NW_DRV_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
|
||||
oai_nw_drv_TOOL_eNB_imei2iid(oai_nw_drv_IMEI, (uint8_t *)priv->cx[cxi].iid6, dev->addr_len);
|
||||
priv->cx[cxi].iid4=0;
|
||||
//
|
||||
}
|
||||
|
||||
spin_lock_init(&priv->lock);
|
||||
//this requires kernel patch for OAI driver: typically for RF/hard realtime emu experimentation
|
||||
#define ADDRCONF
|
||||
#ifdef ADDRCONF
|
||||
|
||||
#ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
oai_nw_drv_TOOL_eNB_imei2iid(oai_nw_drv_IMEI, dev->dev_addr, dev->addr_len);// IMEI to device address (for stateless autoconfiguration address)
|
||||
|
||||
oai_nw_drv_TOOL_eNB_imei2iid(oai_nw_drv_IMEI, (uint8_t *)priv->cx[0].iid6, dev->addr_len);
|
||||
#else
|
||||
oai_nw_drv_TOOL_imei2iid(oai_nw_drv_IMEI, dev->dev_addr);// IMEI to device address (for stateless autoconfiguration address)
|
||||
oai_nw_drv_TOOL_imei2iid(oai_nw_drv_IMEI, (uint8_t *)priv->cx[0].iid6);
|
||||
#endif
|
||||
// this is more appropriate for user space soft realtime emulation
|
||||
#else
|
||||
|
||||
// LG: strange
|
||||
for (index = 0; index < dev->addr_len; index++) {
|
||||
dev->dev_addr[index] = 16*oai_nw_drv_IMEI[index]+oai_nw_drv_IMEI[index+1]);
|
||||
}
|
||||
|
||||
memcpy((uint8_t *)priv->cx[0].iid6,&oai_nw_drv_IMEI[0],dev->addr_len);
|
||||
|
||||
printk("INIT: init IMEI to IID\n");
|
||||
#endif
|
||||
printk("[OAI_IP_DRV][%s] Setting HW addr to : ", __FUNCTION__);
|
||||
|
||||
for (index = 0; index < dev->addr_len; index++) {
|
||||
printk("%02X", dev->dev_addr[index]);
|
||||
}
|
||||
|
||||
printk("\n[OAI_IP_DRV][%s] Setting priv->cx to : ", __FUNCTION__);
|
||||
|
||||
for (index = 0; index < 8; index++) {
|
||||
printk("%02X", ((uint8_t *)(priv->cx[0].iid6))[index]);
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
printk("[OAI_IP_DRV][%s] INIT: end\n", __FUNCTION__);
|
||||
return;
|
||||
} else {
|
||||
printk("[OAI_IP_DRV][%s] ERROR, Device is NULL!!\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int init_module (void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
int err,inst, index;
|
||||
struct oai_nw_drv_priv *priv;
|
||||
char devicename[100];
|
||||
|
||||
|
||||
// Initialize parameters shared with RRC
|
||||
printk("[OAI_IP_DRV][%s] Starting NASMESH, number of IMEI parameters %d, IMEI ", __FUNCTION__, m_arg);
|
||||
|
||||
for (index = 0; index < m_arg; index++) {
|
||||
printk("%02X", oai_nw_drv_IMEI[index]);
|
||||
}
|
||||
|
||||
printk("\n");
|
||||
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
#ifdef RTAI //with RTAI you have to indicate which irq# you want
|
||||
|
||||
pdcp_2_oai_nw_drv_irq=rt_request_srq(0, oai_nw_drv_interrupt, NULL);
|
||||
|
||||
#endif
|
||||
|
||||
if (pdcp_2_oai_nw_drv_irq == -EBUSY || pdcp_2_oai_nw_drv_irq == -EINVAL) {
|
||||
printk("[OAI_IP_DRV][%s] No interrupt resource available\n", __FUNCTION__);
|
||||
return -EBUSY;
|
||||
} else
|
||||
printk("[OAI_IP_DRV][%s] Interrupt %d\n", __FUNCTION__, pdcp_2_oai_nw_drv_irq);
|
||||
|
||||
//rt_startup_irq(RTAI_IRQ);
|
||||
|
||||
//rt_enable_irq(RTAI_IRQ);
|
||||
|
||||
|
||||
#endif //NETLINK
|
||||
|
||||
for (inst=0; inst<OAI_NW_DRV_NB_INSTANCES_MAX; inst++) {
|
||||
printk("[OAI_IP_DRV][%s] begin init instance %d\n", __FUNCTION__,inst);
|
||||
|
||||
|
||||
sprintf(devicename,"oai%d",inst);
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
|
||||
oai_nw_drv_dev[inst] = alloc_netdev(sizeof(struct oai_nw_drv_priv),devicename, oai_nw_drv_init);
|
||||
#else
|
||||
oai_nw_drv_dev[inst] = alloc_netdev(sizeof(struct oai_nw_drv_priv),devicename, NET_NAME_PREDICTABLE, oai_nw_drv_init);
|
||||
#endif
|
||||
//netif_stop_queue(oai_nw_drv_dev[inst]);
|
||||
|
||||
if (oai_nw_drv_dev[inst] == NULL) {
|
||||
printk("[OAI_IP_DRV][%s][INST %02d] alloc_netdev FAILED\n", __FUNCTION__,inst);
|
||||
} else {
|
||||
|
||||
priv = netdev_priv(oai_nw_drv_dev[inst]);
|
||||
|
||||
if (oai_nw_drv_dev[inst]) {
|
||||
oai_nw_drv_IMEI[9] += 1;
|
||||
|
||||
if (oai_nw_drv_IMEI[9] > 0x0F) {
|
||||
oai_nw_drv_IMEI[8] = oai_nw_drv_IMEI[9] >> 4;
|
||||
oai_nw_drv_IMEI[9] = oai_nw_drv_IMEI[9] & 0x0F;
|
||||
}
|
||||
}
|
||||
|
||||
// linux/net/core/dev.c line 4767
|
||||
err= register_netdev(oai_nw_drv_dev[inst]);
|
||||
|
||||
if (err) {
|
||||
printk("[OAI_IP_DRV][%s] (inst %d): error %i registering device %s\n", __FUNCTION__, inst,err, oai_nw_drv_dev[inst]->name);
|
||||
} else {
|
||||
printk("[OAI_IP_DRV][%s] registering device %s, ifindex = %d\n\n", __FUNCTION__,oai_nw_drv_dev[inst]->name, oai_nw_drv_dev[inst]->ifindex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
printk("[OAI_IP_DRV][%s] NETLINK INIT\n", __FUNCTION__);
|
||||
|
||||
if ((err=oai_nw_drv_netlink_init()) == -1)
|
||||
printk("[OAI_IP_DRV][%s] NETLINK failed\n", __FUNCTION__);
|
||||
|
||||
#endif //NETLINK
|
||||
|
||||
return err;
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void cleanup_module(void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
int inst;
|
||||
|
||||
printk("[OAI_IP_DRV][CLEANUP]nasmesh_cleanup_module: begin\n");
|
||||
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
if (pdcp_2_oai_nw_drv_irq!=-EBUSY) {
|
||||
pdcp_2_oai_nw_drv_irq=0;
|
||||
#ifdef RTAI
|
||||
// V1
|
||||
// rt_free_linux_irq(priv->irq, NULL);
|
||||
// END V1
|
||||
rt_free_srq(pdcp_2_oai_nw_drv_irq);
|
||||
#endif
|
||||
// Start IRQ linux
|
||||
//free_irq(priv->irq, NULL);
|
||||
// End IRQ linux
|
||||
}
|
||||
|
||||
#else // NETLINK
|
||||
#endif //NETLINK
|
||||
|
||||
for (inst=0; inst<OAI_NW_DRV_NB_INSTANCES_MAX; inst++) {
|
||||
#ifdef OAI_DRV_DEBUG_DEVICE
|
||||
printk("nasmesh_cleanup_module: unregister and free net device instance %d\n",inst);
|
||||
#endif
|
||||
|
||||
if (oai_nw_drv_dev[inst]) {
|
||||
unregister_netdev(oai_nw_drv_dev[inst]);
|
||||
oai_nw_drv_teardown(oai_nw_drv_dev[inst]);
|
||||
free_netdev(oai_nw_drv_dev[inst]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
oai_nw_drv_netlink_release();
|
||||
#endif //OAI_NW_DRIVER_USE_NETLINK
|
||||
printk("nasmesh_cleanup_module: end\n");
|
||||
}
|
||||
|
||||
#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_named(oai_nw_drv_IMEI,oai_nw_drv_IMEI,byte,&m_arg,0);
|
||||
//module_param_array(oai_nw_drv_IMEI,byte,&m_arg,0444);
|
||||
MODULE_PARM_DESC(oai_nw_drv_IMEI,"The IMEI Hardware address (64-bit, decimal nibbles)");
|
||||
|
||||
//module_param(oai_nw_drv_is_clusterhead,uint,0444);
|
||||
module_param_named(oai_nw_drv_is_clusterhead,oai_nw_drv_is_clusterhead,uint,0444);
|
||||
MODULE_PARM_DESC(oai_nw_drv_is_clusterhead,"The Clusterhead Indicator");
|
||||
|
||||
//MODULE_AUTHOR(DRV_AUTHOR);
|
||||
//MODULE_DESCRIPTION(DRV_DESCRIPTION);
|
||||
//MODULE_LICENSE("GPL");
|
||||
//MODULE_VERSION(DRV_VERSION);
|
||||
|
||||
Executable
+137
@@ -0,0 +1,137 @@
|
||||
/*******************************************************************************
|
||||
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 <asm/uaccess.h>
|
||||
#include <asm/checksum.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#define NIP6ADDR(addr) \
|
||||
ntohs((addr)->s6_addr16[0]), \
|
||||
ntohs((addr)->s6_addr16[1]), \
|
||||
ntohs((addr)->s6_addr16[2]), \
|
||||
ntohs((addr)->s6_addr16[3]), \
|
||||
ntohs((addr)->s6_addr16[4]), \
|
||||
ntohs((addr)->s6_addr16[5]), \
|
||||
ntohs((addr)->s6_addr16[6]), \
|
||||
ntohs((addr)->s6_addr16[7])
|
||||
|
||||
uint8_t g_msgrep[OAI_NW_DRV_LIST_CLASS_MAX*sizeof(struct oai_nw_drv_msg_class_list_reply)+1];
|
||||
|
||||
// Statistic
|
||||
//---------------------------------------------------------------------------
|
||||
void oai_nw_drv_set_msg_statistic_reply(struct oai_nw_drv_msg_statistic_reply *msgrep,
|
||||
struct oai_nw_drv_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 oai_nw_drv_ioCTL_statistic_request(struct oai_nw_drv_ioctl *gifr,
|
||||
struct oai_nw_drv_priv *priv)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct oai_nw_drv_msg_statistic_reply msgrep;
|
||||
printk("NAS_IOCTL_STATISTIC: stat requested\n");
|
||||
oai_nw_drv_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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// IMEI
|
||||
// Messages for IMEI transfer
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IOCTL command
|
||||
//---------------------------------------------------------------------------
|
||||
int oai_nw_drv_CTL_ioctl(struct net_device *dev,
|
||||
struct ifreq *ifr,
|
||||
int cmd)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
struct oai_nw_drv_ioctl *gifr;
|
||||
struct oai_nw_drv_priv *priv=netdev_priv(dev);
|
||||
|
||||
int r;
|
||||
|
||||
// printk("NAS_CTL_IOCTL: begin ioctl for instance %d\n",find_inst(dev));
|
||||
|
||||
switch(cmd) {
|
||||
case OAI_NW_DRV_IOCTL_RRM:
|
||||
gifr=(struct oai_nw_drv_ioctl *)ifr;
|
||||
|
||||
switch(gifr->type) {
|
||||
case OAI_NW_DRV_MSG_STATISTIC_REQUEST:
|
||||
r=oai_nw_drv_ioCTL_statistic_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 oai_nw_drv_CTL_send(struct sk_buff *skb, int inst)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
printk("NAS_CTL_SEND - void \n");
|
||||
}
|
||||
Executable
+263
@@ -0,0 +1,263 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
|
||||
*******************************************************************************/
|
||||
/***************************************************************************
|
||||
ioctl.h - description
|
||||
-------------------
|
||||
copyright : (C) 2002 by Eurecom
|
||||
email : michelle.wetterwald@eurecom.fr
|
||||
yan.moret@eurecom.fr
|
||||
knopp@eurecom.fr
|
||||
***************************************************************************
|
||||
|
||||
***************************************************************************/
|
||||
#ifndef OAI_IOCTL_H
|
||||
#define OAI_IOCTL_H
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
#include <asm/types.h>
|
||||
#include <linux/udp.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/if.h>
|
||||
|
||||
#include "sap.h"
|
||||
|
||||
|
||||
//#include <linux/ipv6.h>
|
||||
|
||||
#define OAI_NW_DRV_MSG_MAXLEN 1100/// change???
|
||||
|
||||
// type of CTL message
|
||||
#define OAI_NW_DRV_MSG_STATISTIC_REQUEST 1
|
||||
#define OAI_NW_DRV_MSG_STATISTIC_REPLY 2
|
||||
#define OAI_NW_DRV_MSG_ECHO_REQUEST 3
|
||||
#define OAI_NW_DRV_MSG_ECHO_REPLY 4
|
||||
#define OAI_NW_DRV_MSG_CX_ESTABLISHMENT_REQUEST 5
|
||||
#define OAI_NW_DRV_MSG_CX_ESTABLISHMENT_REPLY 6
|
||||
#define OAI_NW_DRV_MSG_CX_RELEASE_REQUEST 7
|
||||
#define OAI_NW_DRV_MSG_CX_RELEASE_REPLY 8
|
||||
#define OAI_NW_DRV_MSG_CX_LIST_REQUEST 9
|
||||
#define OAI_NW_DRV_MSG_CX_LIST_REPLY 10
|
||||
#define OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REQUEST 11
|
||||
#define OAI_NW_DRV_MSG_RB_ESTABLISHMENT_REPLY 12
|
||||
#define OAI_NW_DRV_MSG_RB_RELEASE_REQUEST 13
|
||||
#define OAI_NW_DRV_MSG_RB_RELEASE_REPLY 14
|
||||
#define OAI_NW_DRV_MSG_RB_LIST_REQUEST 15
|
||||
#define OAI_NW_DRV_MSG_RB_LIST_REPLY 16
|
||||
#define OAI_NW_DRV_MSG_CLASS_ADD_REQUEST 17
|
||||
#define OAI_NW_DRV_MSG_CLASS_ADD_REPLY 18
|
||||
#define OAI_NW_DRV_MSG_CLASS_DEL_REQUEST 19
|
||||
#define OAI_NW_DRV_MSG_CLASS_DEL_REPLY 20
|
||||
#define OAI_NW_DRV_MSG_CLASS_LIST_REQUEST 21
|
||||
#define OAI_NW_DRV_MSG_CLASS_LIST_REPLY 22
|
||||
#define OAI_NW_DRV_MSG_MEAS_REQUEST 23
|
||||
#define OAI_NW_DRV_MSG_MEAS_REPLY 24
|
||||
#define OAI_NW_DRV_MSG_IMEI_REQUEST 25
|
||||
#define OAI_NW_DRV_MSG_IMEI_REPLY 26
|
||||
|
||||
// Max number of entry of a message list
|
||||
#define OAI_NW_DRV_LIST_CX_MAX 32
|
||||
#define OAI_NW_DRV_LIST_RB_MAX 32
|
||||
#define OAI_NW_DRV_LIST_CLASS_MAX 32
|
||||
|
||||
typedef unsigned short oai_nw_drv_MsgType_t;
|
||||
|
||||
struct oai_nw_drv_ioctl {
|
||||
char name[IFNAMSIZ];
|
||||
oai_nw_drv_MsgType_t type;
|
||||
char *msg;
|
||||
};
|
||||
|
||||
struct oai_nw_drv_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 oai_nw_drv_msg_cx_list_reply {
|
||||
OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference
|
||||
unsigned char state;
|
||||
OaiNwDrvCellID_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 oai_nw_drv_msg_cx_establishment_reply {
|
||||
int status;
|
||||
};
|
||||
struct oai_nw_drv_msg_cx_establishment_request {
|
||||
OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference
|
||||
OaiNwDrvCellID_t cellid; // Cell identification
|
||||
};
|
||||
struct oai_nw_drv_msg_cx_release_reply {
|
||||
int status;
|
||||
};
|
||||
struct oai_nw_drv_msg_cx_release_request {
|
||||
OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference
|
||||
};
|
||||
|
||||
struct oai_nw_drv_msg_rb_list_reply {
|
||||
OaiNwDrvRadioBearerId_t rab_id;
|
||||
OaiNwDrvSapId_t sapi;
|
||||
OaiNwDrvQoSTrafficClass_t qos;
|
||||
unsigned char state;
|
||||
};
|
||||
struct oai_nw_drv_msg_rb_list_request {
|
||||
OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference
|
||||
};
|
||||
struct oai_nw_drv_msg_rb_establishment_reply {
|
||||
int status;
|
||||
};
|
||||
struct oai_nw_drv_msg_rb_establishment_request {
|
||||
OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference
|
||||
OaiNwDrvRadioBearerId_t rab_id;
|
||||
OaiNwDrvQoSTrafficClass_t qos;
|
||||
};
|
||||
|
||||
struct oai_nw_drv_msg_rb_release_reply {
|
||||
int status;
|
||||
};
|
||||
struct oai_nw_drv_msg_rb_release_request {
|
||||
OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference
|
||||
OaiNwDrvRadioBearerId_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 oai_nw_drv_msg_class_add_request {
|
||||
OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference
|
||||
OaiNwDrvRadioBearerId_t rab_id;
|
||||
OaiNwDrvRadioBearerId_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 oai_nw_drv_msg_class_add_reply {
|
||||
int status;
|
||||
};
|
||||
struct oai_nw_drv_msg_class_del_request {
|
||||
OaiNwDrvLocalConnectionRef_t lcr; // Local Connection reference
|
||||
unsigned char dir; // direction (send or receive)
|
||||
unsigned char dscp; // codepoint
|
||||
unsigned short classref;
|
||||
};
|
||||
struct oai_nw_drv_msg_class_del_reply {
|
||||
int status;
|
||||
};
|
||||
#define oai_nw_drv_msg_class_list_reply oai_nw_drv_msg_class_add_request
|
||||
struct oai_nw_drv_msg_class_list_request {
|
||||
OaiNwDrvLocalConnectionRef_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 {
|
||||
OaiNwDrvCellID_t cell_id;
|
||||
OaiNwDrvSigLevel_t level;
|
||||
nioctlProviderId_t provider_id;
|
||||
} nioctlMeasures_t;
|
||||
|
||||
struct oai_nw_drv_msg_measure_request {
|
||||
OaiNwDrvNumRGsMeas_t num_cells;
|
||||
OaiNwDrvCellID_t cellid[OAI_NW_DRV_MAX_MEASURE_NB]; // Cell identification
|
||||
unsigned short num_providers;
|
||||
nioctlProviderId_t provider_id[OAI_NW_DRV_MAX_MEASURE_NB]; // Provider identification
|
||||
};
|
||||
struct oai_nw_drv_msg_measure_reply {
|
||||
OaiNwDrvNumRGsMeas_t num_cells;
|
||||
nioctlMeasures_t measures[OAI_NW_DRV_MAX_MEASURE_NB];
|
||||
nioctlSignalLoss_t signal_lost_flag;
|
||||
};
|
||||
|
||||
// Messages for Measurement transfer - MW 01/04/2005
|
||||
typedef unsigned int nioctlL2Id_t[2];
|
||||
|
||||
struct oai_nw_drv_msg_l2id_reply {
|
||||
nioctlL2Id_t l2id;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Executable
+139
@@ -0,0 +1,139 @@
|
||||
/*******************************************************************************
|
||||
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 OAI_LOCAL_H
|
||||
#define OAI_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>
|
||||
|
||||
#define PDCP2IP_FIFO 21
|
||||
#define IP2PDCP_FIFO 22
|
||||
|
||||
#include "constant.h"
|
||||
#include "platform_types.h"
|
||||
#include "sap.h"
|
||||
|
||||
struct cx_entity {
|
||||
int sap[OAI_NW_DRV_SAPI_CX_MAX];
|
||||
uint8_t state; // state of the connection
|
||||
OaiNwDrvLocalConnectionRef_t lcr; // Local connection reference
|
||||
OaiNwDrvCellID_t cellid; // cell identification
|
||||
uint32_t countimer; // timeout's counter
|
||||
uint8_t retry; // number of retransmission
|
||||
|
||||
uint32_t iid6[2]; // IPv6 interface identification
|
||||
uint8_t iid4; // IPv4 interface identification
|
||||
int lastRRCprimitive;
|
||||
//measures
|
||||
int req_prov_id [OAI_NW_DRV_MAX_MEASURE_NB];
|
||||
int num_measures;
|
||||
int meas_cell_id[OAI_NW_DRV_MAX_MEASURE_NB];
|
||||
int meas_level [OAI_NW_DRV_MAX_MEASURE_NB];
|
||||
int provider_id [OAI_NW_DRV_MAX_MEASURE_NB];
|
||||
};
|
||||
|
||||
struct oai_nw_drv_priv {
|
||||
int irq;
|
||||
int rx_flags;
|
||||
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[OAI_NW_DRV_CX_MAX];
|
||||
//struct classifier_entity *rclassifier[OAI_NW_DRV_DSCP_MAX]; // receive classifier
|
||||
uint16_t nrclassifier;
|
||||
int sap[OAI_NW_DRV_SAPI_MAX];
|
||||
struct sock *nl_sk;
|
||||
uint8_t nlmsg[OAI_NW_DRV_PRIMITIVE_MAX_LENGTH+sizeof(struct nlmsghdr)];
|
||||
uint8_t xbuffer[OAI_NW_DRV_PRIMITIVE_MAX_LENGTH]; // transmition buffer
|
||||
uint8_t rbuffer[OAI_NW_DRV_PRIMITIVE_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 *oai_nw_drv_dev[OAI_NW_DRV_NB_INSTANCES_MAX];
|
||||
|
||||
extern uint8_t OAI_NW_DRV_NULL_IMEI[14];
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Executable
+207
@@ -0,0 +1,207 @@
|
||||
/*******************************************************************************
|
||||
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/version.h>
|
||||
|
||||
//#include <linux/config.h>
|
||||
#include <linux/socket.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <net/sock.h>
|
||||
#include <linux/kthread.h>
|
||||
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#include "local.h"
|
||||
#include "proto_extern.h"
|
||||
|
||||
//#define NETLINK_DEBUG 1
|
||||
|
||||
|
||||
#define OAI_IP_DRIVER_NETLINK_ID 31
|
||||
#define NL_DEST_PID 1
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
|
||||
struct netlink_kernel_cfg oai_netlink_cfg;
|
||||
#endif
|
||||
|
||||
static struct sock *nas_nl_sk = NULL;
|
||||
static int exit_netlink_thread=0;
|
||||
static int nas_netlink_rx_thread(void *);
|
||||
|
||||
|
||||
static DEFINE_MUTEX(nasmesh_mutex);
|
||||
|
||||
static inline void nasmesh_lock(void)
|
||||
{
|
||||
mutex_lock(&nasmesh_mutex);
|
||||
}
|
||||
|
||||
static inline void nasmesh_unlock(void)
|
||||
{
|
||||
mutex_unlock(&nasmesh_mutex);
|
||||
}
|
||||
|
||||
// This can also be implemented using thread to get the data from PDCP without blocking.
|
||||
static void nas_nl_data_ready (struct sk_buff *skb)
|
||||
{
|
||||
// wake_up_interruptible(skb->sk->sk_sleep);
|
||||
//nasmesh_lock();
|
||||
//netlink_rcv_skb(skb, &my_rcv_msg);// my_rcv_msg is the call back func>
|
||||
//nasmesh_unlock();
|
||||
|
||||
struct nlmsghdr *nlh = NULL;
|
||||
|
||||
if (skb) {
|
||||
#ifdef NETLINK_DEBUG
|
||||
printk("[OAI_IP_DRV][NETLINK] Received socket from PDCP\n");
|
||||
#endif //NETLINK_DEBUG
|
||||
nlh = (struct nlmsghdr *)skb->data;
|
||||
oai_nw_drv_common_wireless2ip(nlh);
|
||||
//kfree_skb(skb); // not required,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int oai_nw_drv_netlink_init(void)
|
||||
{
|
||||
|
||||
printk("[OAI_IP_DRV][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("[OAI_IP_DRV][NETLINK] netlink_kernel_create failed \n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void oai_nw_drv_netlink_release(void)
|
||||
{
|
||||
|
||||
exit_netlink_thread=1;
|
||||
printk("[OAI_IP_DRV][NETLINK] Releasing netlink socket\n");
|
||||
|
||||
if(nas_nl_sk) {
|
||||
netlink_kernel_release(nas_nl_sk); //or skb->sk
|
||||
|
||||
}
|
||||
|
||||
// printk("[OAI_IP_DRV][NETLINK] Removing netlink_rx_thread\n");
|
||||
//kthread_stop(netlink_rx_thread);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int oai_nw_drv_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("[OAI_IP_DRV][NETLINK] Sending %d bytes (%d)\n",len,NLMSG_SPACE(len));
|
||||
skb_put(nl_skb, NLMSG_SPACE(len));
|
||||
memcpy(NLMSG_DATA(nlh),data,len);
|
||||
|
||||
nlh->nlmsg_len = NLMSG_SPACE(len);
|
||||
|
||||
|
||||
nlh->nlmsg_pid = 0; /* from kernel */
|
||||
|
||||
#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("[OAI_IP_DRV][NETLINK] In nas_netlink_send, nl_skb %p, nl_sk %x, nlh %p, nlh->nlmsg_len %d\n",nl_skb,nas_nl_sk,nlh,nlh->nlmsg_len);
|
||||
#endif //DEBUG_NETLINK
|
||||
|
||||
if (nas_nl_sk) {
|
||||
|
||||
// nasmesh_lock();
|
||||
status = netlink_unicast(nas_nl_sk, nl_skb, NL_DEST_PID, MSG_DONTWAIT);
|
||||
// mutex_unlock(&nasmesh_mutex);
|
||||
|
||||
if (status < 0) {
|
||||
printk("[OAI_IP_DRV][NETLINK] SEND status is %d\n",status);
|
||||
return(0);
|
||||
} else {
|
||||
#ifdef NETLINK_DEBUG
|
||||
printk("[OAI_IP_DRV][NETLINK] SEND status is %d\n",status);
|
||||
#endif
|
||||
return len;
|
||||
}
|
||||
} else {
|
||||
printk("[OAI_IP_DRV][SEND] socket is NULL\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
Executable
+180
@@ -0,0 +1,180 @@
|
||||
/*******************************************************************************
|
||||
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
|
||||
|
||||
*******************************************************************************/
|
||||
/***************************************************************************
|
||||
proto_extern.h - description
|
||||
-------------------
|
||||
copyright : (C) 2002 by Eurecom
|
||||
email : michelle.wetterwald@eurecom.fr
|
||||
yan.moret@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 "local.h"
|
||||
|
||||
// device.c
|
||||
|
||||
|
||||
/** @defgroup _oai_nw_drv_impl_ OAI Network Device for RRC Lite
|
||||
* @ingroup _ref_implementation_
|
||||
* @{
|
||||
\fn int oai_nw_drv_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 oai_nw_drv_find_inst(struct net_device *dev);
|
||||
|
||||
// common.c
|
||||
/**
|
||||
\fn void oai_nw_drv_common_class_wireless2ip(unsigned short dlen, void* pdcp_sdu,int inst,OaiNwDrvRadioBearerId_t rb_id)
|
||||
\brief Receive classified LTE packet, build skbuff struct with it and deliver it to the OS network layer.
|
||||
@param dlen Length of SDU in bytes
|
||||
@param pdcp_sdu Pointer to received SDU
|
||||
@param inst Instance number
|
||||
@param rb_id Radio Bearer Id
|
||||
*/
|
||||
void oai_nw_drv_common_class_wireless2ip(unsigned short dlen,
|
||||
void *pdcp_sdu,
|
||||
int inst,
|
||||
OaiNwDrvRadioBearerId_t rb_id);
|
||||
|
||||
/**
|
||||
\fn void oai_nw_drv_common_ip2wireless(struct sk_buff *skb, int inst)
|
||||
\brief Request the transfer of data (QoS SAP)
|
||||
@param skb pointer to socket buffer
|
||||
@param inst device instance
|
||||
*/
|
||||
void oai_nw_drv_common_ip2wireless(struct sk_buff *skb, int inst);
|
||||
|
||||
/**
|
||||
\fn void oai_nw_drv_common_ip2wireless_drop(struct sk_buff *skb, int inst)
|
||||
\brief Drop the IP packet comming from the OS network layer.
|
||||
@param skb pointer to socket buffer
|
||||
@param inst device instance
|
||||
*/
|
||||
void oai_nw_drv_common_ip2wireless_drop(struct sk_buff *skb, int inst);
|
||||
|
||||
#ifndef OAI_NW_DRIVER_USE_NETLINK
|
||||
/**
|
||||
\fn void oai_nw_drv_common_wireless2ip()
|
||||
\brief Retrieve PDU from PDCP through RT-fifos for delivery to the IP stack.
|
||||
*/
|
||||
void oai_nw_drv_common_wireless2ip(void);
|
||||
#else
|
||||
/**
|
||||
\fn void oai_nw_drv_common_wireless2ip(struct nlmsghdr *nlh)
|
||||
\brief Retrieve PDU from PDCP through netlink sockets for delivery to the IP stack.
|
||||
*/
|
||||
void oai_nw_drv_common_wireless2ip(struct nlmsghdr *nlh);
|
||||
#endif //OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
|
||||
#ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
/**
|
||||
\fn int oai_nw_drv_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 oai_nw_drv_netlink_send(unsigned char *data,unsigned int len);
|
||||
|
||||
/**
|
||||
\fn void oai_nw_drv_COMMON_QOS_receive(struct nlmsghdr *nlh)
|
||||
\brief Request a PDU from PDCP
|
||||
@param nlh pointer to netlink message header
|
||||
*/
|
||||
void oai_nw_drv_COMMON_QOS_receive(struct nlmsghdr *nlh);
|
||||
|
||||
#endif //OAI_NW_DRIVER_USE_NETLINK
|
||||
|
||||
|
||||
|
||||
// iocontrol.c
|
||||
void oai_nw_drv_CTL_send(struct sk_buff *skb, int inst);
|
||||
int oai_nw_drv_CTL_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
|
||||
|
||||
// classifier.c
|
||||
|
||||
/**
|
||||
\brief Find the IP traffic type (UNICAST, MULTICAST, BROADCAST) of the IP packet attached to sk_buff.
|
||||
*/
|
||||
ip_traffic_type_t oai_nw_drv_find_traffic_type(struct sk_buff *skb);
|
||||
|
||||
|
||||
|
||||
// tool.c
|
||||
void oai_nw_drv_TOOL_imei2iid(unsigned char *imei, unsigned char *iid);
|
||||
void oai_nw_drv_TOOL_eNB_imei2iid(unsigned char *imei, unsigned char *iid, unsigned char len);
|
||||
unsigned char oai_nw_drv_TOOL_get_dscp6(struct ipv6hdr *iph);
|
||||
unsigned char oai_nw_drv_TOOL_get_dscp4(struct iphdr *iph);
|
||||
unsigned char *oai_nw_drv_TOOL_get_protocol6(struct ipv6hdr *iph, unsigned char *protocol);
|
||||
unsigned char *oai_nw_drv_TOOL_get_protocol4(struct iphdr *iph, unsigned char *protocol);
|
||||
char *oai_nw_drv_TOOL_get_udpmsg(struct udphdr *udph);
|
||||
unsigned short oai_nw_drv_TOOL_udpcksum(struct in6_addr *saddr, struct in6_addr *daddr, unsigned char proto, unsigned int udplen, void *data);
|
||||
int oai_nw_drv_TOOL_network6(struct in6_addr *addr, struct in6_addr *prefix, unsigned char plen);
|
||||
int oai_nw_drv_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 oai_nw_drv_tool_print_buffer(char * buffer,int length);
|
||||
#ifdef OAI_NW_DRIVER_USE_NETLINK
|
||||
// netlink.c
|
||||
|
||||
void oai_nw_drv_netlink_release(void);
|
||||
int oai_nw_drv_netlink_init(void);
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
#endif
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
/*******************************************************************************
|
||||
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 OAI_SAP_H
|
||||
#define OAI_SAP_H
|
||||
typedef unsigned short OaiNwDrvRadioBearerId_t;
|
||||
typedef unsigned int OaiNwDrvSapId_t; // Id of the QoS SAP to use
|
||||
typedef unsigned short OaiNwDrvQoSTrafficClass_t; // QoS traffic class requested
|
||||
typedef unsigned int OaiNwDrvLocalConnectionRef_t; // local identifier
|
||||
typedef unsigned short OaiNwDrvCellID_t; // ID of the cell for connection
|
||||
typedef unsigned short OaiNwDrvNumRGsMeas_t; // number of RGs that could be measured
|
||||
typedef unsigned int OaiNwDrvSigLevel_t; // Signal level measured
|
||||
|
||||
#define OAI_NW_DRV_SAPI_CX_MAX 2
|
||||
#define OAI_NW_DRV_MAX_MEASURE_NB 5
|
||||
#define OAI_NW_DRV_PRIMITIVE_MAX_LENGTH 180 // maximum length of a NAS primitive
|
||||
#define OAI_NW_DRV_SAPI_MAX 4
|
||||
#define OAI_NW_DRV_RAB_INPUT_SAPI 2
|
||||
#define OAI_NW_DRV_RAB_OUTPUT_SAPI 3
|
||||
#define OAI_NW_DRV_MAX_RABS 8 * 64 //NB_RAB_MAX * MAX_MOBILES_PER_RG //27 // = MAXURAB
|
||||
#define OAI_NW_DRV_LIST_RB_MAX 32
|
||||
#endif
|
||||
Executable
+755
@@ -0,0 +1,755 @@
|
||||
/*******************************************************************************
|
||||
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 OAI_NW_DRV_DEBUG_TOOL 1
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t oai_nw_drv_TOOL_get_dscp6(struct ipv6hdr *iph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_DSCP6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_DSCP6 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
return (ntohl(((*(__u32 *)iph)&OAI_NW_DRV_TRAFFICCLASS_MASK)))>>22;
|
||||
//return ntohs(*(const __be16 *)iph) >> 4; // see linux/dsfield.h
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t oai_nw_drv_TOOL_get_dscp4(struct iphdr *iph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_DSCP4 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_DSCP4 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
return (iph->tos);
|
||||
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
int oai_nw_drv_TOOL_network6(struct in6_addr *addr, struct in6_addr *prefix, uint8_t plen)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_NETWORK6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (addr==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_NETWORK6 - input parameter addr is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (prefix==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_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 oai_nw_drv_TOOL_network4(uint32_t *addr, uint32_t *prefix, uint8_t plen)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_NETWORK4 - begin \n");
|
||||
#endif
|
||||
|
||||
if (addr==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_NETWORK4 - input parameter addr is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (prefix==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_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 *oai_nw_drv_TOOL_get_udp6(struct ipv6hdr *iph){
|
||||
//---------------------------------------------------------------------------
|
||||
// return (struct udphdr *)((char *)iph+OAI_NW_DRV_IPV6_SIZE); // to modify
|
||||
//}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
uint8_t *oai_nw_drv_TOOL_get_protocol6(struct ipv6hdr *iph, uint8_t *protocol)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
uint16_t size;
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_PROTOCOL6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_PROTOCOL6 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (protocol==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_PROTOCOL6 - input parameter protocol is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
*protocol=iph->nexthdr;
|
||||
size=OAI_NW_DRV_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 *oai_nw_drv_TOOL_get_protocol4(struct iphdr *iph, uint8_t *protocol)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_PROTOCOL4 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_PROTOCOL4 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (protocol==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_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 oai_nw_drv_TOOL_imei2iid(uint8_t *imei, uint8_t *iid)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_IMEI2IID - begin \n");
|
||||
#endif
|
||||
|
||||
if (imei==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_IMEI2IID - input parameter imei is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (iid==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_IMEI2IID - input parameter iid is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
memset(iid, 0, OAI_NW_DRV_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];
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
// Convert the IMEI to iid
|
||||
void oai_nw_drv_TOOL_eNB_imei2iid(unsigned char *imei, unsigned char *iid, unsigned char len)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
unsigned int index;
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_eNB_IMEI2IID - begin \n");
|
||||
#endif
|
||||
|
||||
if (imei==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_eNB_IMEI2IID - input parameter imei is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
if (iid==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_eNB_IMEI2IID - input parameter iid is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
memset(iid, 0, len);
|
||||
iid[0] = 0x00; // to be compatible between link local and global
|
||||
|
||||
// len -1 because of insertion of 0 above
|
||||
for (index = 0; index < (len-1); index++) {
|
||||
iid[index+1] = 16*imei[index*2]+imei[index*2+1];
|
||||
}
|
||||
}
|
||||
|
||||
//struct udphdr *oai_nw_drv_TOOL_get_udp4(struct iphdr *iph)
|
||||
//{
|
||||
// return (struct udphdr *)((char *)iph+OAI_NW_DRV_IPV4_SIZE); // to modify
|
||||
//}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
char *oai_nw_drv_TOOL_get_udpmsg(struct udphdr *udph)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_GET_UDPMSG - begin \n");
|
||||
#endif
|
||||
|
||||
if (udph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_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 oai_nw_drv_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 OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_UDPCKSUM - begin \n");
|
||||
#endif
|
||||
|
||||
if (saddr==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_UDPCKSUM - input parameter saddr is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (daddr==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_UDPCKSUM - input parameter daddr is NULL \n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (data==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_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 OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_UDP - begin \n");
|
||||
#endif
|
||||
|
||||
if (udph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_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 OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_TDP - begin \n");
|
||||
#endif
|
||||
|
||||
if (tcph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_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 OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_ICMP6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (icmph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_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 OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_IPv6 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_PK_IPv6 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
|
||||
if (iph!=NULL) {
|
||||
// char addr[OAI_NW_DRV_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, OAI_NW_DRV_INET6_ADDRSTRLEN);
|
||||
// printk("\t saddr = %s",addr);
|
||||
// inet_ntop(AF_INET6, (void *)(&iph->daddr), addr, OAI_NW_DRV_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 OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("PRINT_TOOL_PK_IPv4 - begin \n");
|
||||
#endif
|
||||
|
||||
if (iph==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_PK_IPv4 - input parameter iph is NULL \n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// End debug information
|
||||
|
||||
if (iph!=NULL) {
|
||||
// char addr[OAI_NW_DRV_INET_ADDRSTRLEN];
|
||||
printk("IP:\t version = %u, IP length = %u\n", iph->version, iph->ihl);
|
||||
// inet_ntop(AF_INET, (void *)(&iph->saddr), addr, OAI_NW_DRV_INET_ADDRSTRLEN);
|
||||
// printk("\t saddr = %s", addr);
|
||||
// inet_ntop(AF_INET, (void *)(&iph->saddr), addr, OAI_NW_DRV_INET_ADDRSTRLEN);
|
||||
// printk("\t saddr = %s", addr);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void print_TOOL_pk_all(struct sk_buff *skb)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
printk("Skb:\t %u, len = %u\n", (unsigned int)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 oai_nw_drv_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);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Print the content of a buffer in hexadecimal
|
||||
void oai_nw_drv_tool_print_buffer(char * buffer,int length)
|
||||
{
|
||||
//-----------------------------------------------------------------------------
|
||||
int i;
|
||||
|
||||
// Start debug information
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_TOOL_PRINT_BUFFER - begin \n");
|
||||
#endif
|
||||
|
||||
if (buffer==NULL) {
|
||||
#ifdef OAI_NW_DRV_DEBUG_TOOL
|
||||
printk("OAI_NW_DRV_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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user