renamed openair-cn to openair3
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7886 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
@@ -0,0 +1,169 @@
|
||||
Active_eNBs = ( "eNB_Eurecom_LTEBox");
|
||||
# Asn1_verbosity, choice in: none, info, annoying
|
||||
Asn1_verbosity = "none";
|
||||
|
||||
eNBs =
|
||||
(
|
||||
{
|
||||
////////// Identification parameters:
|
||||
eNB_ID = 0xe00;
|
||||
|
||||
cell_type = "CELL_MACRO_ENB";
|
||||
|
||||
eNB_name = "eNB_Eurecom_LTEBox";
|
||||
|
||||
// Tracking area code, 0x0000 and 0xfffe are reserved values
|
||||
tracking_area_code = "1";
|
||||
|
||||
mobile_country_code = "208";
|
||||
mobile_network_code = "95";
|
||||
|
||||
////////// Physical parameters:
|
||||
|
||||
component_carriers = (
|
||||
{
|
||||
frame_type = "FDD";
|
||||
tdd_config = 3;
|
||||
tdd_config_s = 0;
|
||||
prefix_type = "NORMAL";
|
||||
eutra_band = 7;
|
||||
downlink_frequency = 2660000000L;
|
||||
uplink_frequency_offset = -120000000;
|
||||
Nid_cell = 0;
|
||||
N_RB_DL = 25;
|
||||
Nid_cell_mbsfn = 0;
|
||||
nb_antennas_tx = 1;
|
||||
nb_antennas_rx = 1;
|
||||
tx_gain = 90;
|
||||
rx_gain = 120;
|
||||
prach_root = 0;
|
||||
prach_config_index = 0;
|
||||
prach_high_speed = "DISABLE";
|
||||
prach_zero_correlation = 1;
|
||||
prach_freq_offset = 2;
|
||||
pucch_delta_shift = 1;
|
||||
pucch_nRB_CQI = 1;
|
||||
pucch_nCS_AN = 0;
|
||||
pucch_n1_AN = 32;
|
||||
pdsch_referenceSignalPower = -26;
|
||||
pdsch_p_b = 0;
|
||||
pusch_n_SB = 1;
|
||||
pusch_enable64QAM = "DISABLE";
|
||||
pusch_hoppingMode = "interSubFrame";
|
||||
pusch_hoppingOffset = 0;
|
||||
pusch_groupHoppingEnabled = "ENABLE";
|
||||
pusch_groupAssignment = 0;
|
||||
pusch_sequenceHoppingEnabled = "DISABLE";
|
||||
pusch_nDMRS1 = 1;
|
||||
phich_duration = "NORMAL";
|
||||
phich_resource = "ONESIXTH";
|
||||
srs_enable = "DISABLE";
|
||||
/* srs_BandwidthConfig =;
|
||||
srs_SubframeConfig =;
|
||||
srs_ackNackST =;
|
||||
srs_MaxUpPts =;*/
|
||||
|
||||
pusch_p0_Nominal = -90;
|
||||
pusch_alpha = "AL1";
|
||||
pucch_p0_Nominal = -108;
|
||||
msg3_delta_Preamble = 6;
|
||||
pucch_deltaF_Format1 = "deltaF2";
|
||||
pucch_deltaF_Format1b = "deltaF3";
|
||||
pucch_deltaF_Format2 = "deltaF0";
|
||||
pucch_deltaF_Format2a = "deltaF0";
|
||||
pucch_deltaF_Format2b = "deltaF0";
|
||||
|
||||
rach_numberOfRA_Preambles = 64;
|
||||
rach_preamblesGroupAConfig = "DISABLE";
|
||||
/*
|
||||
rach_sizeOfRA_PreamblesGroupA = ;
|
||||
rach_messageSizeGroupA = ;
|
||||
rach_messagePowerOffsetGroupB = ;
|
||||
*/
|
||||
rach_powerRampingStep = 4;
|
||||
rach_preambleInitialReceivedTargetPower = -108;
|
||||
rach_preambleTransMax = 10;
|
||||
rach_raResponseWindowSize = 10;
|
||||
rach_macContentionResolutionTimer = 48;
|
||||
rach_maxHARQ_Msg3Tx = 4;
|
||||
|
||||
pcch_default_PagingCycle = 128;
|
||||
pcch_nB = "oneT";
|
||||
bcch_modificationPeriodCoeff = 2;
|
||||
ue_TimersAndConstants_t300 = 1000;
|
||||
ue_TimersAndConstants_t301 = 1000;
|
||||
ue_TimersAndConstants_t310 = 1000;
|
||||
ue_TimersAndConstants_t311 = 10000;
|
||||
ue_TimersAndConstants_n310 = 20;
|
||||
ue_TimersAndConstants_n311 = 1;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
srb1_parameters :
|
||||
{
|
||||
# timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
|
||||
timer_poll_retransmit = 80;
|
||||
|
||||
# timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
|
||||
timer_reordering = 35;
|
||||
|
||||
# timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
|
||||
timer_status_prohibit = 0;
|
||||
|
||||
# poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
|
||||
poll_pdu = 4;
|
||||
|
||||
# poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
|
||||
poll_byte = 99999;
|
||||
|
||||
# max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
|
||||
max_retx_threshold = 4;
|
||||
}
|
||||
|
||||
# ------- SCTP definitions
|
||||
SCTP :
|
||||
{
|
||||
# Number of streams to use in input/output
|
||||
SCTP_INSTREAMS = 2;
|
||||
SCTP_OUTSTREAMS = 2;
|
||||
};
|
||||
|
||||
////////// MME parameters:
|
||||
mme_ip_address = ( { ipv4 = "192.168.12.17";
|
||||
ipv6 = "192:168:30::17";
|
||||
active = "yes";
|
||||
preference = "ipv4";
|
||||
}
|
||||
);
|
||||
|
||||
NETWORK_INTERFACES :
|
||||
{
|
||||
ENB_INTERFACE_NAME_FOR_S1_MME = "eth0";
|
||||
ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.213/24";
|
||||
|
||||
ENB_INTERFACE_NAME_FOR_S1U = "eth0";
|
||||
ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.213/24";
|
||||
ENB_PORT_FOR_S1U = 2152; # Spec 2152
|
||||
};
|
||||
|
||||
log_config :
|
||||
{
|
||||
global_log_level ="debug";
|
||||
global_log_verbosity ="medium";
|
||||
hw_log_level ="info";
|
||||
hw_log_verbosity ="medium";
|
||||
phy_log_level ="info";
|
||||
phy_log_verbosity ="medium";
|
||||
mac_log_level ="info";
|
||||
mac_log_verbosity ="high";
|
||||
rlc_log_level ="info";
|
||||
rlc_log_verbosity ="medium";
|
||||
pdcp_log_level ="info";
|
||||
pdcp_log_verbosity ="medium";
|
||||
rrc_log_level ="info";
|
||||
rrc_log_verbosity ="medium";
|
||||
};
|
||||
|
||||
}
|
||||
);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,451 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
generate_scenario.c
|
||||
-------------------
|
||||
AUTHOR : Lionel GAUTHIER
|
||||
COMPANY : EURECOM
|
||||
EMAIL : Lionel.Gauthier@eurecom.fr
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <libconfig.h>
|
||||
#include <inttypes.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "assertions.h"
|
||||
#include "enb_config.h"
|
||||
#include "s1ap_eNB.h"
|
||||
#if defined(ENABLE_ITTI)
|
||||
# include "intertask_interface.h"
|
||||
#endif
|
||||
|
||||
#define EPC_TEST_SCENARIO_MAX_ENB 2
|
||||
|
||||
#define ENB_CONFIG_STRING_ACTIVE_ENBS "Active_eNBs"
|
||||
|
||||
#define ENB_CONFIG_STRING_ENB_LIST "eNBs"
|
||||
#define ENB_CONFIG_STRING_ENB_ID "eNB_ID"
|
||||
#define ENB_CONFIG_STRING_CELL_TYPE "cell_type"
|
||||
#define ENB_CONFIG_STRING_ENB_NAME "eNB_name"
|
||||
|
||||
#define ENB_CONFIG_STRING_TRACKING_AREA_CODE "tracking_area_code"
|
||||
#define ENB_CONFIG_STRING_MOBILE_COUNTRY_CODE "mobile_country_code"
|
||||
#define ENB_CONFIG_STRING_MOBILE_NETWORK_CODE "mobile_network_code"
|
||||
|
||||
|
||||
#define ENB_CONFIG_STRING_MME_IP_ADDRESS "mme_ip_address"
|
||||
#define ENB_CONFIG_STRING_MME_IPV4_ADDRESS "ipv4"
|
||||
#define ENB_CONFIG_STRING_MME_IPV6_ADDRESS "ipv6"
|
||||
#define ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE "active"
|
||||
#define ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE "preference"
|
||||
|
||||
#define ENB_CONFIG_STRING_SCTP_CONFIG "SCTP"
|
||||
#define ENB_CONFIG_STRING_SCTP_INSTREAMS "SCTP_INSTREAMS"
|
||||
#define ENB_CONFIG_STRING_SCTP_OUTSTREAMS "SCTP_OUTSTREAMS"
|
||||
|
||||
#define ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG "NETWORK_INTERFACES"
|
||||
#define ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1_MME "ENB_INTERFACE_NAME_FOR_S1_MME"
|
||||
#define ENB_CONFIG_STRING_ENB_IPV4_ADDRESS_FOR_S1_MME "ENB_IPV4_ADDRESS_FOR_S1_MME"
|
||||
#define ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1U "ENB_INTERFACE_NAME_FOR_S1U"
|
||||
#define ENB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_S1U "ENB_IPV4_ADDRESS_FOR_S1U"
|
||||
#define ENB_CONFIG_STRING_ENB_PORT_FOR_S1U "ENB_PORT_FOR_S1U"
|
||||
|
||||
|
||||
Enb_properties_array_t g_enb_properties;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void enb_config_display(void)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
int i,j;
|
||||
|
||||
printf( "\n----------------------------------------------------------------------\n");
|
||||
printf( " ENB CONFIG FILE CONTENT LOADED (TBC):\n");
|
||||
printf( "----------------------------------------------------------------------\n");
|
||||
for (i = 0; i < g_enb_properties.number; i++) {
|
||||
printf( "ENB CONFIG for instance %u:\n\n", i);
|
||||
printf( "\teNB name: \t%s:\n",g_enb_properties.properties[i]->eNB_name);
|
||||
printf( "\teNB ID: \t%"PRIu32":\n",g_enb_properties.properties[i]->eNB_id);
|
||||
printf( "\tCell type: \t%s:\n",g_enb_properties.properties[i]->cell_type == CELL_MACRO_ENB ? "CELL_MACRO_ENB":"CELL_HOME_ENB");
|
||||
printf( "\tTAC: \t%"PRIu16":\n",g_enb_properties.properties[i]->tac);
|
||||
printf( "\tMCC: \t%"PRIu16":\n",g_enb_properties.properties[i]->mcc);
|
||||
|
||||
if (g_enb_properties.properties[i]->mnc_digit_length == 3) {
|
||||
printf( "\tMNC: \t%03"PRIu16":\n",g_enb_properties.properties[i]->mnc);
|
||||
} else {
|
||||
printf( "\tMNC: \t%02"PRIu16":\n",g_enb_properties.properties[i]->mnc);
|
||||
}
|
||||
printf( "\n--------------------------------------------------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef LIBCONFIG_LONG
|
||||
#define libconfig_int long
|
||||
#else
|
||||
#define libconfig_int int
|
||||
#endif
|
||||
//------------------------------------------------------------------------------
|
||||
const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
config_t cfg;
|
||||
config_setting_t *setting = NULL;
|
||||
config_setting_t *subsetting = NULL;
|
||||
config_setting_t *setting_srb1 = NULL;
|
||||
config_setting_t *setting_mme_addresses = NULL;
|
||||
config_setting_t *setting_mme_address = NULL;
|
||||
config_setting_t *setting_enb = NULL;
|
||||
int num_enb_properties = 0;
|
||||
int enb_properties_index = 0;
|
||||
int num_enbs = 0;
|
||||
int num_mme_address = 0;
|
||||
int num_otg_elements =0;
|
||||
int num_component_carriers =0;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
int parse_errors = 0;
|
||||
libconfig_int enb_id = 0;
|
||||
const char* cell_type = NULL;
|
||||
const char* tac = 0;
|
||||
const char* enb_name = NULL;
|
||||
const char* mcc = 0;
|
||||
const char* mnc = 0;
|
||||
const char* frame_type = NULL;
|
||||
const char* prefix_type = NULL;
|
||||
libconfig_int Nid_cell = 0;
|
||||
|
||||
libconfig_int my_int;
|
||||
|
||||
char* ipv4 = NULL;
|
||||
char* ipv6 = NULL;
|
||||
char* active = NULL;
|
||||
char* preference = NULL;
|
||||
const char* active_enb[EPC_TEST_SCENARIO_MAX_ENB];
|
||||
char* enb_interface_name_for_S1U = NULL;
|
||||
char* enb_ipv4_address_for_S1U = NULL;
|
||||
libconfig_int enb_port_for_S1U = 0;
|
||||
char* enb_interface_name_for_S1_MME = NULL;
|
||||
char* enb_ipv4_address_for_S1_MME = NULL;
|
||||
char *address = NULL;
|
||||
char *cidr = NULL;
|
||||
char *astring = NULL;
|
||||
|
||||
memset((char*)active_enb, 0 , EPC_TEST_SCENARIO_MAX_ENB * sizeof(char*));
|
||||
|
||||
config_init(&cfg);
|
||||
|
||||
if (lib_config_file_name_pP != NULL) {
|
||||
/* Read the file. If there is an error, report it and exit. */
|
||||
if (! config_read_file(&cfg, lib_config_file_name_pP)) {
|
||||
config_destroy(&cfg);
|
||||
AssertFatal (0, "Failed to parse eNB configuration file %s!\n", lib_config_file_name_pP);
|
||||
}
|
||||
} else {
|
||||
config_destroy(&cfg);
|
||||
AssertFatal (0, "No eNB configuration file provided!\n");
|
||||
}
|
||||
|
||||
// Get list of active eNBs, (only these will be configured)
|
||||
setting = config_lookup(&cfg, ENB_CONFIG_STRING_ACTIVE_ENBS);
|
||||
|
||||
if (setting != NULL) {
|
||||
num_enbs = config_setting_length(setting);
|
||||
|
||||
for (i = 0; i < num_enbs; i++) {
|
||||
setting_enb = config_setting_get_elem(setting, i);
|
||||
active_enb[i] = config_setting_get_string (setting_enb);
|
||||
AssertFatal (active_enb[i] != NULL,
|
||||
"Failed to parse config file %s, %uth attribute %s \n",
|
||||
lib_config_file_name_pP, i, ENB_CONFIG_STRING_ACTIVE_ENBS);
|
||||
active_enb[i] = strdup(active_enb[i]);
|
||||
num_enb_properties += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Output a list of all eNBs. */
|
||||
setting = config_lookup(&cfg, ENB_CONFIG_STRING_ENB_LIST);
|
||||
|
||||
if (setting != NULL) {
|
||||
enb_properties_index = 0;
|
||||
parse_errors = 0;
|
||||
num_enbs = config_setting_length(setting);
|
||||
|
||||
for (i = 0; i < num_enbs; i++) {
|
||||
setting_enb = config_setting_get_elem(setting, i);
|
||||
|
||||
if (! config_setting_lookup_int(setting_enb, ENB_CONFIG_STRING_ENB_ID, &enb_id)) {
|
||||
/* Calculate a default eNB ID */
|
||||
# if defined(ENABLE_USE_MME)
|
||||
uint32_t hash;
|
||||
|
||||
hash = s1ap_generate_eNB_id ();
|
||||
enb_id = i + (hash & 0xFFFF8);
|
||||
# else
|
||||
enb_id = i;
|
||||
# endif
|
||||
}
|
||||
|
||||
if ( !( config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_CELL_TYPE, &cell_type)
|
||||
&& config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_ENB_NAME, &enb_name)
|
||||
&& config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_TRACKING_AREA_CODE, &tac)
|
||||
&& config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_MOBILE_COUNTRY_CODE, &mcc)
|
||||
&& config_setting_lookup_string(setting_enb, ENB_CONFIG_STRING_MOBILE_NETWORK_CODE, &mnc)
|
||||
|
||||
|
||||
)
|
||||
) {
|
||||
AssertError (0, parse_errors ++,
|
||||
"Failed to parse eNB configuration file %s, %u th enb\n",
|
||||
lib_config_file_name_pP, i);
|
||||
continue; // FIXME this prevents segfaults below, not sure what happens after function exit
|
||||
}
|
||||
|
||||
// search if in active list
|
||||
for (j=0; j < num_enb_properties; j++) {
|
||||
if (strcmp(active_enb[j], enb_name) == 0) {
|
||||
g_enb_properties.properties[enb_properties_index] = calloc(1, sizeof(Enb_properties_t));
|
||||
|
||||
g_enb_properties.properties[enb_properties_index]->eNB_id = enb_id;
|
||||
|
||||
if (strcmp(cell_type, "CELL_MACRO_ENB") == 0) {
|
||||
g_enb_properties.properties[enb_properties_index]->cell_type = CELL_MACRO_ENB;
|
||||
} else if (strcmp(cell_type, "CELL_HOME_ENB") == 0) {
|
||||
g_enb_properties.properties[enb_properties_index]->cell_type = CELL_HOME_ENB;
|
||||
} else {
|
||||
AssertError (0, parse_errors ++,
|
||||
"Failed to parse eNB configuration file %s, enb %d unknown value \"%s\" for cell_type choice: CELL_MACRO_ENB or CELL_HOME_ENB !\n",
|
||||
lib_config_file_name_pP, i, cell_type);
|
||||
}
|
||||
|
||||
g_enb_properties.properties[enb_properties_index]->eNB_name = strdup(enb_name);
|
||||
g_enb_properties.properties[enb_properties_index]->tac = (uint16_t)atoi(tac);
|
||||
g_enb_properties.properties[enb_properties_index]->mcc = (uint16_t)atoi(mcc);
|
||||
g_enb_properties.properties[enb_properties_index]->mnc = (uint16_t)atoi(mnc);
|
||||
g_enb_properties.properties[enb_properties_index]->mnc_digit_length = strlen(mnc);
|
||||
AssertFatal((g_enb_properties.properties[enb_properties_index]->mnc_digit_length == 2) ||
|
||||
(g_enb_properties.properties[enb_properties_index]->mnc_digit_length == 3),
|
||||
"BAD MNC DIGIT LENGTH %d",
|
||||
g_enb_properties.properties[i]->mnc_digit_length);
|
||||
|
||||
|
||||
setting_mme_addresses = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_MME_IP_ADDRESS);
|
||||
num_mme_address = config_setting_length(setting_mme_addresses);
|
||||
g_enb_properties.properties[enb_properties_index]->nb_mme = 0;
|
||||
|
||||
for (j = 0; j < num_mme_address; j++) {
|
||||
setting_mme_address = config_setting_get_elem(setting_mme_addresses, j);
|
||||
|
||||
if ( !(
|
||||
config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IPV4_ADDRESS, (const char **)&ipv4)
|
||||
&& config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IPV6_ADDRESS, (const char **)&ipv6)
|
||||
&& config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IP_ADDRESS_ACTIVE, (const char **)&active)
|
||||
&& config_setting_lookup_string(setting_mme_address, ENB_CONFIG_STRING_MME_IP_ADDRESS_PREFERENCE, (const char **)&preference)
|
||||
)
|
||||
) {
|
||||
AssertError (0, parse_errors ++,
|
||||
"Failed to parse eNB configuration file %s, %u th enb %u th mme address !\n",
|
||||
lib_config_file_name_pP, i, j);
|
||||
continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
|
||||
}
|
||||
|
||||
g_enb_properties.properties[enb_properties_index]->nb_mme += 1;
|
||||
|
||||
g_enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv4_address = strdup(ipv4);
|
||||
g_enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6_address = strdup(ipv6);
|
||||
|
||||
if (strcmp(active, "yes") == 0) {
|
||||
g_enb_properties.properties[enb_properties_index]->mme_ip_address[j].active = 1;
|
||||
} // else { (calloc)
|
||||
|
||||
if (strcmp(preference, "ipv4") == 0) {
|
||||
g_enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
|
||||
} else if (strcmp(preference, "ipv6") == 0) {
|
||||
g_enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
|
||||
} else if (strcmp(preference, "no") == 0) {
|
||||
g_enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv4 = 1;
|
||||
g_enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// NETWORK_INTERFACES
|
||||
subsetting = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_NETWORK_INTERFACES_CONFIG);
|
||||
|
||||
if (subsetting != NULL) {
|
||||
if ( (
|
||||
config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1_MME,
|
||||
(const char **)&enb_interface_name_for_S1_MME)
|
||||
&& config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_IPV4_ADDRESS_FOR_S1_MME,
|
||||
(const char **)&enb_ipv4_address_for_S1_MME)
|
||||
&& config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_INTERFACE_NAME_FOR_S1U,
|
||||
(const char **)&enb_interface_name_for_S1U)
|
||||
&& config_setting_lookup_string( subsetting, ENB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_S1U,
|
||||
(const char **)&enb_ipv4_address_for_S1U)
|
||||
&& config_setting_lookup_int(subsetting, ENB_CONFIG_STRING_ENB_PORT_FOR_S1U,
|
||||
&enb_port_for_S1U)
|
||||
)
|
||||
) {
|
||||
g_enb_properties.properties[enb_properties_index]->enb_interface_name_for_S1U = strdup(enb_interface_name_for_S1U);
|
||||
cidr = enb_ipv4_address_for_S1U;
|
||||
address = strtok(cidr, "/");
|
||||
|
||||
if (address) {
|
||||
IPV4_STR_ADDR_TO_INT_NWBO ( address, g_enb_properties.properties[enb_properties_index]->enb_ipv4_address_for_S1U, "BAD IP ADDRESS FORMAT FOR eNB S1_U !\n" );
|
||||
}
|
||||
|
||||
g_enb_properties.properties[enb_properties_index]->enb_port_for_S1U = enb_port_for_S1U;
|
||||
|
||||
g_enb_properties.properties[enb_properties_index]->enb_interface_name_for_S1_MME = strdup(enb_interface_name_for_S1_MME);
|
||||
cidr = enb_ipv4_address_for_S1_MME;
|
||||
address = strtok(cidr, "/");
|
||||
|
||||
if (address) {
|
||||
IPV4_STR_ADDR_TO_INT_NWBO ( address, g_enb_properties.properties[enb_properties_index]->enb_ipv4_address_for_S1_MME, "BAD IP ADDRESS FORMAT FOR eNB S1_MME !\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_enb_properties.number = num_enb_properties;
|
||||
|
||||
AssertError (enb_properties_index == num_enb_properties, parse_errors ++,
|
||||
"Failed to parse eNB configuration file %s, mismatch between %u active eNBs and %u corresponding defined eNBs !\n",
|
||||
lib_config_file_name_pP, num_enb_properties, enb_properties_index);
|
||||
|
||||
AssertFatal (parse_errors == 0,
|
||||
"Failed to parse eNB configuration file %s, found %d error%s !\n",
|
||||
lib_config_file_name_pP, parse_errors, parse_errors > 1 ? "s" : "");
|
||||
enb_config_display();
|
||||
return &g_enb_properties;
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
const Enb_properties_array_t *enb_config_get(void)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
return &g_enb_properties;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void usage (
|
||||
int argc,
|
||||
char *argv[])
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
fprintf (stdout, "Please report any bug to: openair4g-devel@lists.eurecom.fr\n\n");
|
||||
fprintf (stdout, "Usage: %s [options]\n\n", argv[0]);
|
||||
fprintf (stdout, "Available options:\n");
|
||||
fprintf (stdout, "\t--help, -h Print this help and return\n");
|
||||
fprintf (stdout, "\t--test-dir <path>\n");
|
||||
fprintf (stdout, " Set the test directory where pdml and original enb(s) config files are located\n");
|
||||
fprintf (stdout, " See README in openair-cn/TEST/EPC_TEST\n");
|
||||
fprintf (stdout, "\t--new-enb-conf-file <file>\n");
|
||||
fprintf (stdout, " Provide an updated eNB config file for generating a copy of the original test\n");
|
||||
fprintf (stdout, " This option is set as many times as there are some eNB in the original test\n");
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int
|
||||
config_parse_opt_line (
|
||||
int argc,
|
||||
char *argv[])
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
int option;
|
||||
char *enb_config_file_name = NULL;
|
||||
char *test_dir = NULL;
|
||||
|
||||
enum long_option_e {
|
||||
LONG_OPTION_START = 0x100, /* Start after regular single char options */
|
||||
LONG_OPTION_TEST_DIR,
|
||||
LONG_OPTION_NEW_ENB_CONF_FILE,
|
||||
LONG_OPTION_HELP,
|
||||
};
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"test-dir", required_argument, 0, LONG_OPTION_TEST_DIR},
|
||||
{"new-enb-conf-file", required_argument, 0, LONG_OPTION_NEW_ENB_CONF_FILE},
|
||||
{"help", required_argument, 0, LONG_OPTION_HELP},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
/*
|
||||
* Parsing command line
|
||||
*/
|
||||
while ((option = getopt_long (argc, argv, "h", long_options, NULL)) != -1) {
|
||||
switch (option) {
|
||||
case LONG_OPTION_TEST_DIR:
|
||||
if (optarg) {
|
||||
test_dir = strdup(optarg);
|
||||
printf("TEST DIRECTORY IS %s\n", test_dir);
|
||||
}
|
||||
break;
|
||||
|
||||
case LONG_OPTION_NEW_ENB_CONF_FILE:
|
||||
if (optarg) {
|
||||
enb_config_file_name = strdup(optarg);
|
||||
printf("eNB config file name is %s\n", enb_config_file_name);
|
||||
enb_config_init(enb_config_file_name);
|
||||
}
|
||||
break;
|
||||
|
||||
if (optarg) {
|
||||
test_dir = strdup(optarg);
|
||||
printf("TEST DIRECTORY IS %s\n", test_dir);
|
||||
}
|
||||
break;
|
||||
|
||||
case LONG_OPTION_HELP:
|
||||
case 'h': /* Fall through */
|
||||
default:
|
||||
usage (argc, argv);
|
||||
exit (0);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int main( int argc, char **argv )
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
memset((char*) &g_enb_properties, 0 , sizeof(g_enb_properties));
|
||||
config_parse_opt_line (argc, argv); //Command-line options
|
||||
|
||||
return 0;
|
||||
}
|
||||
Executable
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import subprocess
|
||||
import re
|
||||
import socket
|
||||
import datetime
|
||||
from datetime import date
|
||||
import os, errno
|
||||
import argparse
|
||||
import tempfile
|
||||
from lxml import etree
|
||||
from xml.dom.minidom import parse, parseString
|
||||
|
||||
#####################
|
||||
# program arguments
|
||||
#####################
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--pcap_file", "-p", type=str,help="input pcap file to be translated")
|
||||
args = parser.parse_args()
|
||||
|
||||
#####################
|
||||
# get xml document from pcap
|
||||
#####################
|
||||
orig_pcap_file_name = args.pcap_file.strip()
|
||||
orig_pdml_string = subprocess.check_output(["tshark", '-T', 'pdml', '-r', orig_pcap_file_name])
|
||||
|
||||
orig_dom = parseString(orig_pdml_string)
|
||||
|
||||
#####################
|
||||
# filtering unwanted packets
|
||||
#####################
|
||||
#cases = orig_etree.findall(".//proto[@name='sctp']")
|
||||
packets = orig_dom.getElementsByTagName("packet")
|
||||
for packet in packets:
|
||||
found_sctp = False
|
||||
found_s1ap = False
|
||||
protos = packet.getElementsByTagName("proto")
|
||||
for proto in protos:
|
||||
attrs = proto.attributes
|
||||
urlnode = attrs['name']
|
||||
if urlnode.nodeValue == 'sctp':
|
||||
found_sctp = True
|
||||
elif urlnode.nodeValue == 's1ap':
|
||||
found_s1ap = True
|
||||
elif urlnode.nodeValue == 'geninfo':
|
||||
packet.removeChild(proto)
|
||||
elif urlnode.nodeValue == 'eth':
|
||||
packet.removeChild(proto)
|
||||
if found_sctp == False:
|
||||
# hopefully it seems to work (remove iterated packet)
|
||||
packet.parentNode.removeChild(packet)
|
||||
|
||||
#####################
|
||||
# dom to xml string
|
||||
#####################
|
||||
filtered_pdml_string = orig_dom.toxml()
|
||||
cleaned_pdml_string = ""
|
||||
#####################
|
||||
# remove blank lines in xml string
|
||||
#####################
|
||||
lines = filtered_pdml_string.splitlines()
|
||||
for line in lines:
|
||||
if line[:-1]:
|
||||
cleaned_pdml_string += line + '\r\n'
|
||||
#print "'%s'" % cleaned_pdml_string
|
||||
#####################
|
||||
# write pdml string to pdml file
|
||||
#####################
|
||||
out_pdml_file_name = os.path.dirname(orig_pcap_file_name) + os.path.splitext(os.path.basename(orig_pcap_file_name))[0] + '.pdml'
|
||||
out_file = open(out_pdml_file_name, "w")
|
||||
out_file.write(cleaned_pdml_string)
|
||||
out_file.close()
|
||||
|
||||
############################################################
|
||||
# DECEIVING HTML BONUS: DO NOT SEEM TO WORK CORRECTLY IN FIREFOX
|
||||
# DID NOT INVESTIGATE
|
||||
#####################
|
||||
# write xml string to html file
|
||||
#####################
|
||||
xsl_root = etree.fromstring(open('/usr/share/wireshark/pdml2html.xsl').read())
|
||||
transform = etree.XSLT(xsl_root)
|
||||
xml_root = etree.fromstring(cleaned_pdml_string)
|
||||
trans_root = transform(xml_root)
|
||||
filtered_html_string = etree.tostring(trans_root)
|
||||
#####################
|
||||
# write html string to html file
|
||||
#####################
|
||||
out_html_file_name = os.path.dirname(orig_pcap_file_name) + os.path.splitext(os.path.basename(orig_pcap_file_name))[0] + '.html'
|
||||
out_file = open(out_html_file_name, "w")
|
||||
out_file.write(filtered_html_string)
|
||||
out_file.close()
|
||||
@@ -0,0 +1,127 @@
|
||||
################################################################################
|
||||
# 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@lists.eurecom.fr
|
||||
#
|
||||
# Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
#
|
||||
################################################################################
|
||||
AM_CFLAGS = @ADD_CFLAGS@ \
|
||||
@CHECK_CFLAGS@ \
|
||||
-I$(top_srcdir)/COMMON \
|
||||
-I$(top_srcdir)/GTPV1-U \
|
||||
-I$(top_srcdir)/GTPV1-U/nw-gtpv1u/include \
|
||||
-I$(top_srcdir)/GTPV1-U/nw-gtpv1u/shared \
|
||||
-I$(top_srcdir)/SCTP \
|
||||
-I$(top_srcdir)/INTERTASK_INTERFACE \
|
||||
-I$(top_srcdir)/IPV4 \
|
||||
-I$(top_builddir)/S1AP/MESSAGES \
|
||||
-I$(top_builddir)/S1AP \
|
||||
-I$(top_srcdir)/S1AP \
|
||||
-I$(top_srcdir)/SECU \
|
||||
-I$(top_srcdir)/S6A \
|
||||
-I$(top_srcdir)/SGW-LITE \
|
||||
-I$(top_srcdir)/UDP \
|
||||
-I$(top_srcdir)/UTILS \
|
||||
-I$(top_srcdir)/UTILS/TIMER \
|
||||
-I$(top_srcdir)/UTILS/HASTABLE
|
||||
|
||||
if HAVE_CHECK
|
||||
TESTS = \
|
||||
test_kdf \
|
||||
test_aes128_cmac_encrypt \
|
||||
test_aes128_ctr_encrypt \
|
||||
test_aes128_ctr_decrypt \
|
||||
test_secu_kenb \
|
||||
test_secu_knas \
|
||||
test_secu_knas_encrypt_eea1 \
|
||||
test_secu_knas_encrypt_eia1 \
|
||||
test_secu_knas_encrypt_eea2 \
|
||||
test_secu_knas_encrypt_eia2
|
||||
else
|
||||
TESTS =
|
||||
endif
|
||||
|
||||
libtest_util_la_SOURCES = \
|
||||
test_util.c test_util.h
|
||||
|
||||
noinst_LTLIBRARIES = libtest_util.la
|
||||
|
||||
common_ldadd = $(top_builddir)/SECU/libsecu.la \
|
||||
libtest_util.la \
|
||||
$(top_builddir)/UTILS/libutils.la \
|
||||
@CHECK_LIBS@
|
||||
|
||||
check_PROGRAMS = \
|
||||
test_kdf \
|
||||
test_aes128_cmac_encrypt \
|
||||
test_aes128_ctr_encrypt \
|
||||
test_aes128_ctr_decrypt \
|
||||
test_secu_kenb \
|
||||
test_secu_knas \
|
||||
test_secu_knas_encrypt_eea1 \
|
||||
test_secu_knas_encrypt_eia1 \
|
||||
test_secu_knas_encrypt_eea2 \
|
||||
test_secu_knas_encrypt_eia2
|
||||
|
||||
test_kdf_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_secu_knas_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_secu_kenb_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_secu_knas_encrypt_eea1_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_secu_knas_encrypt_eia1_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_secu_knas_encrypt_eea2_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_secu_knas_encrypt_eia2_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_aes128_ctr_encrypt_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_aes128_ctr_decrypt_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_aes128_cmac_encrypt_LDADD = \
|
||||
$(common_ldadd)
|
||||
|
||||
test_s1ap_LDADD = libtest_util.la \
|
||||
$(top_builddir)/S1AP/libs1ap.la
|
||||
#
|
||||
test_s1ap_SOURCES = test_s1ap.c \
|
||||
$(top_srcdir)/S1AP/s1ap_eNB_decoder.c \
|
||||
$(top_srcdir)/S1AP/s1ap_eNB_decoder.h \
|
||||
$(top_srcdir)/S1AP/s1ap_eNB_encoder.c \
|
||||
$(top_srcdir)/S1AP/s1ap_eNB_encoder.h
|
||||
|
||||
test_secu_kenb_SOURCES = test_secu_kenb.c
|
||||
test_secu_knas_SOURCES = test_secu_knas.c
|
||||
@@ -0,0 +1,147 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/sctp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "sctp_primitives_client.h"
|
||||
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_eNB.h"
|
||||
#include "s1ap_mme.h"
|
||||
#include "s1ap_ies_defs.h"
|
||||
|
||||
char ip_addr[] = "127.0.0.1";
|
||||
|
||||
int assoc[2];
|
||||
uint8_t id[] = { 0x03, 0x56, 0xf0, 0xd8 };
|
||||
char identity[] = { 0x02, 0x08, 0x34 };
|
||||
char tac[] = { 0x00, 0x01 };
|
||||
char infoNAS[] = { 0x07, 0x42, 0x01, 0xE0, 0x06, 0x00, 0x00, 0xF1, 0x10, 0x00, 0x01, 0x00, 0x2C,
|
||||
0x52, 0x01, 0xC1, 0x01, 0x09, 0x10, 0x03, 0x77, 0x77, 0x77, 0x07, 0x61, 0x6E, 0x72, 0x69, 0x74,
|
||||
0x73, 0x75, 0x03, 0x63, 0x6F, 0x6D, 0x05, 0x01, 0x0A, 0x01, 0x20, 0x37, 0x27, 0x0E, 0x80, 0x80,
|
||||
0x21, 0x0A, 0x03, 0x00, 0x00, 0x0A, 0x81, 0x06, 0x0A, 0x00, 0x00, 0x01, 0x50, 0x0B, 0xF6,
|
||||
0x00, 0xF1, 0x10, 0x80, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
|
||||
uint32_t eNB_UE_S1AP_ID = 0;
|
||||
|
||||
int s1ap_eNB_generate_initial_ue_message(uint8_t **buffer,
|
||||
uint32_t *length);
|
||||
|
||||
int s1ap_eNB_generate_initial_ue_message(uint8_t **buffer,
|
||||
uint32_t *length)
|
||||
{
|
||||
InitialUEMessageIEs initialUEmessageIEs;
|
||||
InitialUEMessageIEs *initialUEmessageIEs_p = &initialUEmessageIEs;
|
||||
|
||||
memset(initialUEmessageIEs_p, 0, sizeof(InitialUEMessageIEs));
|
||||
|
||||
initialUEmessageIEs.eNB_UE_S1AP_ID = eNB_UE_S1AP_ID;
|
||||
initialUEmessageIEs.nas_pdu.buf = infoNAS;
|
||||
initialUEmessageIEs.nas_pdu.size = sizeof(infoNAS);
|
||||
|
||||
initialUEmessageIEs.tai.tAC.buf = tac;
|
||||
initialUEmessageIEs.tai.tAC.size = 2;
|
||||
initialUEmessageIEs.tai.pLMNidentity.buf = identity;
|
||||
initialUEmessageIEs.tai.pLMNidentity.size = 3;
|
||||
initialUEmessageIEs.eutran_cgi.pLMNidentity.buf = identity;
|
||||
initialUEmessageIEs.eutran_cgi.pLMNidentity.size = 3;
|
||||
initialUEmessageIEs.eutran_cgi.cell_ID.buf = id;
|
||||
initialUEmessageIEs.eutran_cgi.cell_ID.size = 4;
|
||||
initialUEmessageIEs.eutran_cgi.cell_ID.bits_unused = 4;
|
||||
|
||||
initialUEmessageIEs.rrC_Establishment_Cause = RRC_Establishment_Cause_mo_Data;
|
||||
|
||||
return s1ap_eNB_encode_initial_ue_message(initialUEmessageIEs_p, buffer, length);
|
||||
}
|
||||
|
||||
void recv_callback(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
uint8_t *bufferS;
|
||||
uint32_t len;
|
||||
s1ap_eNB_generate_initial_ue_message(&bufferS, &len);
|
||||
sctp_send_msg(assoc[0], 1, bufferS, len);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
asn_enc_rval_t retVal;
|
||||
uint8_t *buffer;
|
||||
uint32_t len;
|
||||
|
||||
SupportedTAs_Item_t ta;
|
||||
PLMNidentity_t plmnIdentity;
|
||||
|
||||
asn_debug = 0;
|
||||
asn1_xer_print = 0;
|
||||
|
||||
S1SetupRequestIEs s1SetupRequest;
|
||||
memset(&s1SetupRequest, 0, sizeof(S1SetupRequestIEs));
|
||||
s1SetupRequest.global_ENB_ID.eNB_ID.present = ENB_ID_PR_macroENB_ID;
|
||||
s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.buf = id;
|
||||
s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.size = 3;
|
||||
s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.bits_unused = 4;
|
||||
OCTET_STRING_fromBuf(&s1SetupRequest.global_ENB_ID.pLMNidentity, identity, 3);
|
||||
|
||||
s1SetupRequest.presenceMask |= S1SETUPREQUESTIES_ENBNAME_PRESENT;
|
||||
OCTET_STRING_fromBuf(&s1SetupRequest.eNBname, "ENB 1 eurecom",
|
||||
strlen("ENB 1 eurecom"));
|
||||
|
||||
memset(&ta, 0, sizeof(SupportedTAs_Item_t));
|
||||
memset(&plmnIdentity, 0, sizeof(PLMNidentity_t));
|
||||
OCTET_STRING_fromBuf(&ta.tAC, tac, 2);
|
||||
OCTET_STRING_fromBuf(&plmnIdentity, identity, 3);
|
||||
ASN_SEQUENCE_ADD(&ta.broadcastPLMNs, &plmnIdentity);
|
||||
ASN_SEQUENCE_ADD(&s1SetupRequest.supportedTAs, &ta);
|
||||
|
||||
s1SetupRequest.defaultPagingDRX = PagingDRX_v64;
|
||||
|
||||
s1ap_eNB_encode_s1setuprequest(&s1SetupRequest, &buffer, &len);
|
||||
|
||||
assoc[0] = sctp_connect_to_remote_host(ip_addr, 36412, &recv_callback);
|
||||
sctp_send_msg(0, 0, buffer, len);
|
||||
|
||||
free(buffer);
|
||||
|
||||
// generateUplinkNASTransport(&buffer, &len);
|
||||
// sctp_send_msg(assoc[0], 0, buffer, len);
|
||||
// s1ap_mme_decode_pdu(buffer, len);
|
||||
|
||||
pthread_join(sctp_get_receiver_thread(assoc[0]), NULL);
|
||||
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <sched.h>
|
||||
|
||||
#include "mme_config.h"
|
||||
#include "gtpv1u_sgw_defs.h"
|
||||
|
||||
#include "intertask_interface_init.h"
|
||||
|
||||
#include "sctp_primitives_server.h"
|
||||
#include "udp_primitives_server.h"
|
||||
#include "s1ap_mme.h"
|
||||
#include "log.h"
|
||||
#include "timer.h"
|
||||
#include "sgw_lite_defs.h"
|
||||
#include "ipv4_defs.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i = 0;
|
||||
int prio = 0;
|
||||
mme_config_t mme_config;
|
||||
MessageDef *message_p;
|
||||
struct sched_param param = {
|
||||
.sched_priority = 10,
|
||||
};
|
||||
|
||||
config_parse_opt_line(argc, argv, &mme_config);
|
||||
fprintf(stdout, "Starting %s ITTI test\n", PACKAGE_STRING);
|
||||
|
||||
if (setpriority(PRIO_PROCESS, 0, prio) < 0) {
|
||||
fprintf(stderr, "Cannot assign requested prio: %d\n"
|
||||
"%d:%s\n", prio, errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sched_setscheduler(0, SCHED_RR, ¶m) < 0) {
|
||||
fprintf(stderr, "Cannot assign requested scheduler policy\n"
|
||||
"%d:%s\n", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Calling each layer init function */
|
||||
log_init(&mme_config);
|
||||
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, NULL);
|
||||
sctp_init(&mme_config);
|
||||
udp_init(&mme_config);
|
||||
s1ap_mme_init(&mme_config);
|
||||
gtpv1u_init(&mme_config);
|
||||
ipv4_init(&mme_config);
|
||||
|
||||
sgw_lite_init(&mme_config);
|
||||
|
||||
message_p = itti_alloc_new_message(TASK_S1AP, MESSAGE_TEST);
|
||||
|
||||
while(i < (1 << 15)) {
|
||||
if (send_broadcast_message(message_p) < 0) {
|
||||
fprintf(stderr, "Failed to send broadcast message %d\n", i);
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Successfully sent %lu messages", get_current_message_number());
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,296 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/sctp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "sctp_primitives_client.h"
|
||||
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_eNB.h"
|
||||
#include "s1ap_mme.h"
|
||||
#include "s1ap_ies_defs.h"
|
||||
|
||||
#include "s1ap_eNB_encoder.h"
|
||||
#include "s1ap_eNB_decoder.h"
|
||||
|
||||
#define NB_OF_ENB 10
|
||||
#define NB_OF_UES 100
|
||||
|
||||
static int connected_eNB = 0;
|
||||
static char ip_addr[] = "127.0.0.1";
|
||||
uint32_t ipv4_local = 0x7F000001;
|
||||
static uint8_t id[] = { 0x03, 0x56, 0xf0, 0xd8 };
|
||||
static char identity[] = { 0x02, 0x08, 0x34 };
|
||||
static char tac[] = { 0x00, 0x01 };
|
||||
static char infoNAS[] = { 0x07, 0x42, 0x01, 0xE0, 0x06, 0x00, 0x00, 0xF1, 0x10, 0x00, 0x01, 0x00, 0x2C,
|
||||
0x52, 0x01, 0xC1, 0x01, 0x09, 0x10, 0x03, 0x77, 0x77, 0x77, 0x07, 0x61, 0x6E, 0x72, 0x69, 0x74,
|
||||
0x73, 0x75, 0x03, 0x63, 0x6F, 0x6D, 0x05, 0x01, 0x0A, 0x01, 0x20, 0x37, 0x27, 0x0E, 0x80, 0x80,
|
||||
0x21, 0x0A, 0x03, 0x00, 0x00, 0x0A, 0x81, 0x06, 0x0A, 0x00, 0x00, 0x01, 0x50, 0x0B, 0xF6,
|
||||
0x00, 0xF1, 0x10, 0x80, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01
|
||||
};
|
||||
uint32_t nb_eNB = NB_OF_ENB;
|
||||
uint32_t nb_ue = NB_OF_UES;
|
||||
|
||||
void s1ap_test_generate_s1_setup_request(uint32_t eNB_id, uint8_t **buffer,
|
||||
uint32_t *length);
|
||||
int s1ap_test_generate_initial_ue_message(uint32_t eNB_UE_S1AP_ID,
|
||||
uint8_t **buffer,
|
||||
uint32_t *length);
|
||||
int recv_callback(uint32_t assocId,
|
||||
uint32_t stream,
|
||||
uint8_t *buffer,
|
||||
uint32_t length);
|
||||
int sctp_connected(void *args,
|
||||
uint32_t assocId,
|
||||
uint32_t instreams,
|
||||
uint32_t outstreams);
|
||||
|
||||
void s1ap_test_generate_s1_setup_request(uint32_t eNB_id, uint8_t **buffer,
|
||||
uint32_t *length)
|
||||
{
|
||||
S1SetupRequestIEs_t s1SetupRequest;
|
||||
SupportedTAs_Item_t ta;
|
||||
PLMNidentity_t plmnIdentity;
|
||||
uint8_t *id_p = (uint8_t *)(&eNB_id + 1);
|
||||
|
||||
memset(&s1SetupRequest, 0, sizeof(S1SetupRequestIEs_t));
|
||||
s1SetupRequest.global_ENB_ID.eNB_ID.present = ENB_ID_PR_macroENB_ID;
|
||||
s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.buf = id_p;
|
||||
s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.size = 3;
|
||||
s1SetupRequest.global_ENB_ID.eNB_ID.choice.macroENB_ID.bits_unused = 4;
|
||||
OCTET_STRING_fromBuf(&s1SetupRequest.global_ENB_ID.pLMNidentity, identity, 3);
|
||||
|
||||
s1SetupRequest.presenceMask |= S1SETUPREQUESTIES_ENBNAME_PRESENT;
|
||||
OCTET_STRING_fromBuf(&s1SetupRequest.eNBname, "ENB 1 eurecom",
|
||||
strlen("ENB 1 eurecom"));
|
||||
|
||||
memset(&ta, 0, sizeof(SupportedTAs_Item_t));
|
||||
memset(&plmnIdentity, 0, sizeof(PLMNidentity_t));
|
||||
OCTET_STRING_fromBuf(&ta.tAC, tac, 2);
|
||||
OCTET_STRING_fromBuf(&plmnIdentity, identity, 3);
|
||||
ASN_SEQUENCE_ADD(&ta.broadcastPLMNs, &plmnIdentity);
|
||||
ASN_SEQUENCE_ADD(&s1SetupRequest.supportedTAs, &ta);
|
||||
|
||||
s1SetupRequest.defaultPagingDRX = PagingDRX_v64;
|
||||
|
||||
s1ap_eNB_encode_s1_setup_request(&s1SetupRequest, buffer, length);
|
||||
}
|
||||
|
||||
int s1ap_test_generate_initial_ue_message(uint32_t eNB_UE_S1AP_ID,
|
||||
uint8_t **buffer,
|
||||
uint32_t *length)
|
||||
{
|
||||
InitialUEMessageIEs_t initialUEmessageIEs;
|
||||
InitialUEMessageIEs_t *initialUEmessageIEs_p = &initialUEmessageIEs;
|
||||
|
||||
memset(initialUEmessageIEs_p, 0, sizeof(InitialUEMessageIEs_t));
|
||||
|
||||
initialUEmessageIEs.eNB_UE_S1AP_ID = eNB_UE_S1AP_ID & 0x00ffffff;
|
||||
initialUEmessageIEs.nas_pdu.buf = (uint8_t *)infoNAS;
|
||||
initialUEmessageIEs.nas_pdu.size = sizeof(infoNAS);
|
||||
|
||||
initialUEmessageIEs.tai.tAC.buf = (uint8_t *)tac;
|
||||
initialUEmessageIEs.tai.tAC.size = 2;
|
||||
initialUEmessageIEs.tai.pLMNidentity.buf = (uint8_t *)identity;
|
||||
initialUEmessageIEs.tai.pLMNidentity.size = 3;
|
||||
initialUEmessageIEs.eutran_cgi.pLMNidentity.buf = (uint8_t *)identity;
|
||||
initialUEmessageIEs.eutran_cgi.pLMNidentity.size = 3;
|
||||
initialUEmessageIEs.eutran_cgi.cell_ID.buf = (uint8_t *)id;
|
||||
initialUEmessageIEs.eutran_cgi.cell_ID.size = 4;
|
||||
initialUEmessageIEs.eutran_cgi.cell_ID.bits_unused = 4;
|
||||
|
||||
initialUEmessageIEs.rrC_Establishment_Cause = RRC_Establishment_Cause_mo_Data;
|
||||
|
||||
return s1ap_eNB_encode_initial_ue_message(initialUEmessageIEs_p, buffer, length);
|
||||
}
|
||||
|
||||
int s1ap_test_generate_initial_setup_resp(uint32_t eNB_UE_S1AP_ID,
|
||||
uint32_t mme_UE_S1AP_ID,
|
||||
uint8_t eRAB_id,
|
||||
uint32_t teid,
|
||||
uint8_t **buffer,
|
||||
uint32_t *length)
|
||||
{
|
||||
InitialContextSetupResponseIEs_t initialResponseIEs;
|
||||
InitialContextSetupResponseIEs_t *initialResponseIEs_p = &initialResponseIEs;
|
||||
|
||||
E_RABSetupItemCtxtSURes_t e_RABSetupItemCtxtSURes;
|
||||
|
||||
memset(initialResponseIEs_p, 0, sizeof(InitialContextSetupResponseIEs_t));
|
||||
memset(&e_RABSetupItemCtxtSURes, 0, sizeof(E_RABSetupItemCtxtSURes_t));
|
||||
|
||||
initialResponseIEs_p->mme_ue_s1ap_id = mme_UE_S1AP_ID;
|
||||
initialResponseIEs_p->eNB_UE_S1AP_ID = eNB_UE_S1AP_ID;
|
||||
|
||||
e_RABSetupItemCtxtSURes.e_RAB_ID = eRAB_id;
|
||||
e_RABSetupItemCtxtSURes.transportLayerAddress.buf = (uint8_t *)&ipv4_local;
|
||||
e_RABSetupItemCtxtSURes.transportLayerAddress.size = 4;
|
||||
|
||||
e_RABSetupItemCtxtSURes.gTP_TEID.buf = (uint8_t *)&teid;
|
||||
e_RABSetupItemCtxtSURes.gTP_TEID.size = 4;
|
||||
|
||||
ASN_SEQUENCE_ADD(
|
||||
&initialResponseIEs_p->e_RABSetupListCtxtSURes.e_RABSetupItemCtxtSURes,
|
||||
&e_RABSetupItemCtxtSURes);
|
||||
|
||||
return s1ap_eNB_encode_initial_context_setup_response(initialResponseIEs_p,
|
||||
buffer, length);
|
||||
}
|
||||
|
||||
int recv_callback(uint32_t assocId,
|
||||
uint32_t stream,
|
||||
uint8_t *buffer,
|
||||
uint32_t length)
|
||||
{
|
||||
s1ap_message message;
|
||||
uint8_t *buffer2;
|
||||
uint32_t len;
|
||||
int j;
|
||||
|
||||
if (s1ap_eNB_decode_pdu(&message, buffer, length) < 0) {
|
||||
fprintf(stderr, "s1ap_eNB_decode_pdu returned status < 0\n");
|
||||
free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (message.procedureCode == ProcedureCode_id_S1Setup
|
||||
&& message.direction == S1AP_PDU_PR_successfulOutcome) {
|
||||
for (j = 0; j < nb_ue; j++) {
|
||||
s1ap_test_generate_initial_ue_message(j, &buffer2, &len);
|
||||
|
||||
if (sctp_send_msg(assocId, j % 64 + 1, buffer2, len) < 0) {
|
||||
fprintf(stderr,
|
||||
"sctp_send_msg returned status < 0\nSomething bad happened on SCTP layer\n");
|
||||
free(buffer2);
|
||||
break;
|
||||
}
|
||||
|
||||
free(buffer2);
|
||||
}
|
||||
} else if (message.procedureCode == ProcedureCode_id_InitialContextSetup
|
||||
&& message.direction == S1AP_PDU_PR_initiatingMessage) {
|
||||
fprintf(stdout, "Received InitialContextSetup request\n");
|
||||
s1ap_test_generate_initial_setup_resp(
|
||||
message.msg.initialContextSetupRequestIEs.eNB_UE_S1AP_ID,
|
||||
message.msg.initialContextSetupRequestIEs.mme_ue_s1ap_id,
|
||||
0x5,
|
||||
0x1,
|
||||
&buffer2,
|
||||
&len);
|
||||
|
||||
if (sctp_send_msg(assocId, stream, buffer2, len) < 0) {
|
||||
fprintf(stderr,
|
||||
"sctp_send_msg returned status < 0\nSomething bad happened on SCTP layer\n");
|
||||
free(buffer2);
|
||||
}
|
||||
|
||||
free(buffer2);
|
||||
} else {
|
||||
fprintf(stderr, "Received unexpected message %d %d\n", message.procedureCode,
|
||||
message.direction);
|
||||
free(buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sctp_connected(void *args,
|
||||
uint32_t assocId,
|
||||
uint32_t instreams,
|
||||
uint32_t outstreams)
|
||||
{
|
||||
uint8_t *buffer;
|
||||
uint32_t len;
|
||||
|
||||
fprintf(stdout, "New association %d\n", assocId);
|
||||
|
||||
s1ap_test_generate_s1_setup_request(assocId * nb_eNB, &buffer, &len);
|
||||
|
||||
if (sctp_send_msg(assocId, 0, buffer, len) < 0) {
|
||||
free(buffer);
|
||||
fprintf(stderr,
|
||||
"sctp_send_msg returned status < 0. Something bad happened on SCTP layer\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
|
||||
connected_eNB++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
asn_enc_rval_t retVal;
|
||||
|
||||
int i;
|
||||
|
||||
SupportedTAs_Item_t ta;
|
||||
PLMNidentity_t plmnIdentity;
|
||||
|
||||
asn_debug = 0;
|
||||
asn1_xer_print = 0;
|
||||
|
||||
if (argc > 1) {
|
||||
nb_eNB = atoi(argv[1]);
|
||||
|
||||
if (argc > 2) {
|
||||
nb_ue = atoi(argv[2]);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < nb_eNB; i++) {
|
||||
sctp_connect_to_remote_host(ip_addr, 36412, 18, NULL, sctp_connected,
|
||||
recv_callback);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
|
||||
// generateUplinkNASTransport(&buffer, &len);
|
||||
// sctp_send_msg(assoc[0], 0, buffer, len);
|
||||
// s1ap_mme_decode_pdu(buffer, len);
|
||||
|
||||
sctp_terminate();
|
||||
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_eNB_decoder.h"
|
||||
#include "s1ap_mme_decoder.h"
|
||||
#include "s1ap_eNB_encoder.h"
|
||||
|
||||
#define MAX_BUF_LENGTH (1024)
|
||||
|
||||
typedef struct {
|
||||
char *procedure_name;
|
||||
uint8_t buffer[MAX_BUF_LENGTH];
|
||||
uint32_t buf_len;
|
||||
} s1ap_test_t;
|
||||
|
||||
s1ap_test_t s1ap_test[] = {
|
||||
// {
|
||||
// .procedure_name = "Downlink NAS transport",
|
||||
// .buffer = {
|
||||
// 0x00, 0x0B, 0x40, 0x21, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
// 0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x00, 0x03,
|
||||
// 0x40, 0x01, 0xB3, 0x00, 0x1A, 0x00, 0x0A, 0x09, 0x27, 0xAB,
|
||||
// 0x1F, 0x7C, 0xEC, 0x01, 0x02, 0x01, 0xD9
|
||||
// },
|
||||
// .buf_len = 37,
|
||||
// },
|
||||
{
|
||||
.procedure_name = "Uplink NAS transport",
|
||||
.buffer = {
|
||||
0x00, 0x0D, 0x40, 0x41, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x00, 0x03,
|
||||
0x40, 0x01, 0xB3, 0x00, 0x1A, 0x00, 0x14, 0x13, 0x27, 0xD3,
|
||||
0x77, 0xED, 0x4C, 0x01, 0x02, 0x01, 0xDA, 0x28, 0x08, 0x03,
|
||||
0x69, 0x6D, 0x73, 0x03, 0x70, 0x66, 0x74, 0x00, 0x64, 0x40,
|
||||
0x08, 0x00, 0x02, 0xF8, 0x29, 0x00, 0x00, 0x20, 0x40, 0x00,
|
||||
0x43, 0x40, 0x06, 0x00, 0x02, 0xF8, 0x29, 0x00, 0x04,
|
||||
},
|
||||
.buf_len = 69,
|
||||
},
|
||||
{
|
||||
.procedure_name = "UE capability info indication",
|
||||
.buffer = {
|
||||
0x00, 0x16, 0x40, 0x37, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x00, 0x03,
|
||||
0x40, 0x01, 0xB3, 0x00, 0x4A, 0x40, 0x20, 0x1F, 0x00, 0xE8,
|
||||
0x01, 0x01, 0xA8, 0x13, 0x80, 0x00, 0x20, 0x83, 0x13, 0x05,
|
||||
0x0B, 0x8B, 0xFC, 0x2E, 0x2F, 0xF0, 0xB8, 0xBF, 0xAF, 0x87,
|
||||
0xFE, 0x40, 0x44, 0x04, 0x07, 0x0C, 0xA7, 0x4A, 0x80,
|
||||
},
|
||||
.buf_len = 59,
|
||||
},
|
||||
{
|
||||
.procedure_name = "Initial Context Setup Request",
|
||||
.buffer = {
|
||||
0x00, 0x09, 0x00, 0x80, 0xD4, 0x00, 0x00, 0x06, 0x00, 0x00,
|
||||
0x00, 0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x00,
|
||||
0x03, 0x40, 0x01, 0xB3, 0x00, 0x42, 0x00, 0x0A, 0x18, 0x08,
|
||||
0xF0, 0xD1, 0x80, 0x60, 0x02, 0xFA, 0xF0, 0x80, 0x00, 0x18,
|
||||
0x00, 0x80, 0x81, 0x00, 0x00, 0x34, 0x00, 0x7C, 0x45, 0x00,
|
||||
0x09, 0x3D, 0x0F, 0x80, 0x0A, 0x05, 0x00, 0x02, 0x03, 0x78,
|
||||
0x48, 0x86, 0x6D, 0x27, 0xC7, 0x97, 0x8E, 0xA1, 0x02, 0x07,
|
||||
0x42, 0x01, 0x49, 0x06, 0x00, 0x02, 0xF8, 0x29, 0x00, 0x04,
|
||||
0x00, 0x48, 0x52, 0x01, 0xC1, 0x01, 0x09, 0x1B, 0x03, 0x69,
|
||||
0x6D, 0x73, 0x03, 0x70, 0x66, 0x74, 0x06, 0x6D, 0x6E, 0x63,
|
||||
0x30, 0x39, 0x32, 0x06, 0x6D, 0x63, 0x63, 0x32, 0x30, 0x38,
|
||||
0x04, 0x67, 0x70, 0x72, 0x73, 0x05, 0x01, 0x0A, 0x80, 0x00,
|
||||
0x24, 0x5D, 0x01, 0x00, 0x30, 0x10, 0x23, 0x93, 0x1F, 0x93,
|
||||
0x96, 0xFE, 0xFE, 0x74, 0x4B, 0xFF, 0xFF, 0x00, 0xC5, 0x00,
|
||||
0x6C, 0x00, 0x32, 0x0B, 0x84, 0x34, 0x01, 0x08, 0x5E, 0x04,
|
||||
0xFE, 0xFE, 0xC5, 0x6C, 0x50, 0x0B, 0xF6, 0x02, 0xF8, 0x29,
|
||||
0x80, 0x00, 0x01, 0xF0, 0x00, 0x70, 0x8A, 0x53, 0x12, 0x64,
|
||||
0x01, 0x01, 0x00, 0x6B, 0x00, 0x05, 0x18, 0x00, 0x0C, 0x00,
|
||||
0x00, 0x00, 0x49, 0x00, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
},
|
||||
.buf_len = 217,
|
||||
},
|
||||
{
|
||||
.procedure_name = "Initial context setup response",
|
||||
.buffer = {
|
||||
0x20, 0x09, 0x00, 0x26, 0x00, 0x00, 0x03, 0x00, 0x00, 0x40,
|
||||
0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x40, 0x03,
|
||||
0x40, 0x01, 0xB3, 0x00, 0x33, 0x40, 0x0F, 0x00, 0x00, 0x32,
|
||||
0x40, 0x0A, 0x0A, 0x1F, 0x0A, 0x05, 0x02, 0x05, 0x00, 0x0F,
|
||||
0x7A, 0x03,
|
||||
},
|
||||
.buf_len = 42,
|
||||
}
|
||||
};
|
||||
|
||||
static int compare_buffer(uint8_t *buffer, uint32_t length_buffer,
|
||||
uint8_t *pattern,
|
||||
uint32_t length_pattern)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (length_buffer != length_pattern) {
|
||||
printf("Length mismatch, expecting %d bytes, got %d bytes\n", length_pattern,
|
||||
length_buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < length_buffer; i++) {
|
||||
if (pattern[i] != buffer[i]) {
|
||||
printf("Mismatch fount in bytes %d\nExpecting 0x%02x, got 0x%02x\n",
|
||||
i, pattern[i], buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
asn1_xer_print = 2;
|
||||
|
||||
if (argc > 1) {
|
||||
asn_debug = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(s1ap_test) / sizeof(s1ap_test_t); i++) {
|
||||
struct s1ap_message_s message;
|
||||
uint8_t *buffer;
|
||||
uint32_t length;
|
||||
memset(&message, 0, sizeof(struct s1ap_message_s));
|
||||
printf("Trying to decode %s procedure with asn1c decoder\n",
|
||||
s1ap_test[i].procedure_name);
|
||||
|
||||
if (s1ap_mme_decode_pdu(&message, s1ap_test[i].buffer,
|
||||
s1ap_test[i].buf_len) < 0) {
|
||||
if (s1ap_eNB_decode_pdu(&message, s1ap_test[i].buffer,
|
||||
s1ap_test[i].buf_len) < 0) {
|
||||
printf("Failed to decode this message\n");
|
||||
} else {
|
||||
printf("Succesfully decoded %s with eNB decoder\n", s1ap_test[i].procedure_name);
|
||||
}
|
||||
} else {
|
||||
printf("Succesfully decoded %s with MME decoder\n", s1ap_test[i].procedure_name);
|
||||
}
|
||||
|
||||
printf("Trying to encode %s procedure with asn1c encoder\n",
|
||||
s1ap_test[i].procedure_name);
|
||||
|
||||
if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
|
||||
printf("Failed to encode this message on MME side, trying eNB side\n");
|
||||
} else {
|
||||
compare_buffer(buffer, length, s1ap_test[i].buffer, s1ap_test[i].buf_len);
|
||||
free(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/sctp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "sctp_primitives_client.h"
|
||||
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_eNB.h"
|
||||
#include "s1ap_mme.h"
|
||||
#include "s1ap_ies_defs.h"
|
||||
|
||||
#include "s1ap_eNB_encoder.h"
|
||||
#include "s1ap_eNB_decoder.h"
|
||||
|
||||
int recv_callback(uint32_t assocId,
|
||||
uint32_t stream,
|
||||
uint8_t *buffer,
|
||||
uint32_t length)
|
||||
{
|
||||
|
||||
free(buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sctp_connected(void *args,
|
||||
uint32_t assocId,
|
||||
uint32_t instreams,
|
||||
uint32_t outstreams)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
asn_enc_rval_t retVal;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nb_eNB; i++) {
|
||||
sctp_connect_to_remote_host(ip_addr, 36412, NULL, sctp_connected, recv_callback);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
sctp_terminate();
|
||||
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
#include <linux/sched.h>
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
#include <getopt.h>
|
||||
#include <syscall.h>
|
||||
|
||||
|
||||
#include "UTIL/LOG/log_extern.h"
|
||||
#include "assertions.h"
|
||||
#include "intertask_interface_init.h"
|
||||
#include "intertask_interface.h"
|
||||
#include "timer.h"
|
||||
#include "sctp_eNB_task.h"
|
||||
#include "s1ap_eNB.h"
|
||||
#include "enb_config.h"
|
||||
|
||||
#include "oaisim_mme_test_s1c.h"
|
||||
|
||||
# define ENB_REGISTER_RETRY_DELAY 5
|
||||
//------------------------------------------------------------------------------
|
||||
static void get_options (int argc, char **argv);
|
||||
static uint32_t eNB_app_register(const uint32_t enb_id_start, const uint32_t enb_id_end, const Enb_properties_array_t *enb_properties);
|
||||
static void *eNB_app_task (void *args_p);
|
||||
void mme_test_s1_start_test(instance_t instance);
|
||||
//------------------------------------------------------------------------------
|
||||
static char *conf_config_file_name = NULL;
|
||||
static char *itti_dump_file = NULL;
|
||||
const Enb_properties_array_t *enb_properties = NULL;
|
||||
int16_t glog_level = LOG_INFO;
|
||||
int16_t glog_verbosity = LOG_MED;
|
||||
s1c_test_t s1c_test = {
|
||||
0, // scenario_index
|
||||
0, // tx_next_message_index
|
||||
0, // rx_next_message_index
|
||||
0 // assoc_id
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void get_options (int argc, char **argv)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
int c;
|
||||
|
||||
|
||||
while ((c = getopt_long (argc, argv, "K:g:G:O:",NULL,NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'K':
|
||||
itti_dump_file = strdup(optarg);
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
conf_config_file_name = optarg;
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
glog_level=atoi(optarg); // value between 1 - 9
|
||||
break;
|
||||
|
||||
case 'G':
|
||||
glog_verbosity=atoi(optarg);// value from 0, 0x5, 0x15, 0x35, 0x75
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AssertFatal(conf_config_file_name != NULL,"Please provide a configuration file\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static uint32_t eNB_app_register(const uint32_t enb_id_start, const uint32_t enb_id_end, const Enb_properties_array_t *enb_properties)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
uint32_t enb_id;
|
||||
uint32_t mme_id;
|
||||
MessageDef *msg_p;
|
||||
uint32_t register_enb_pending = 0;
|
||||
char *str = NULL;
|
||||
struct in_addr addr;
|
||||
|
||||
// 1 eNB should be max.
|
||||
// 1 eNB should be max.
|
||||
for (enb_id = enb_id_start; (enb_id < enb_id_end) ; enb_id++) {
|
||||
{
|
||||
s1ap_register_enb_req_t *s1ap_register_eNB;
|
||||
|
||||
/* note: there is an implicit relationship between the data structure and the message name */
|
||||
msg_p = itti_alloc_new_message (TASK_ENB_APP, S1AP_REGISTER_ENB_REQ);
|
||||
|
||||
s1ap_register_eNB = &S1AP_REGISTER_ENB_REQ(msg_p);
|
||||
|
||||
/* Some default/random parameters */
|
||||
s1ap_register_eNB->eNB_id = enb_properties->properties[enb_id]->eNB_id;
|
||||
s1ap_register_eNB->cell_type = enb_properties->properties[enb_id]->cell_type;
|
||||
s1ap_register_eNB->eNB_name = enb_properties->properties[enb_id]->eNB_name;
|
||||
s1ap_register_eNB->tac = enb_properties->properties[enb_id]->tac;
|
||||
s1ap_register_eNB->mcc = enb_properties->properties[enb_id]->mcc;
|
||||
s1ap_register_eNB->mnc = enb_properties->properties[enb_id]->mnc;
|
||||
s1ap_register_eNB->mnc_digit_length = enb_properties->properties[enb_id]->mnc_digit_length;
|
||||
s1ap_register_eNB->default_drx = enb_properties->properties[enb_id]->pcch_defaultPagingCycle[0];
|
||||
|
||||
s1ap_register_eNB->nb_mme = enb_properties->properties[enb_id]->nb_mme;
|
||||
AssertFatal (s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS, "Too many MME for eNB %d (%d/%d)!", enb_id, s1ap_register_eNB->nb_mme,
|
||||
S1AP_MAX_NB_MME_IP_ADDRESS);
|
||||
|
||||
for (mme_id = 0; mme_id < s1ap_register_eNB->nb_mme; mme_id++) {
|
||||
s1ap_register_eNB->mme_ip_address[mme_id].ipv4 = enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv4;
|
||||
s1ap_register_eNB->mme_ip_address[mme_id].ipv6 = enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv6;
|
||||
strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv4_address,
|
||||
enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv4_address,
|
||||
sizeof(s1ap_register_eNB->mme_ip_address[0].ipv4_address));
|
||||
strncpy (s1ap_register_eNB->mme_ip_address[mme_id].ipv6_address,
|
||||
enb_properties->properties[enb_id]->mme_ip_address[mme_id].ipv6_address,
|
||||
sizeof(s1ap_register_eNB->mme_ip_address[0].ipv6_address));
|
||||
}
|
||||
|
||||
s1ap_register_eNB->enb_ip_address.ipv6 = 0;
|
||||
s1ap_register_eNB->enb_ip_address.ipv4 = 1;
|
||||
addr.s_addr = enb_properties->properties[enb_id]->enb_ipv4_address_for_S1_MME;
|
||||
str = inet_ntoa(addr);
|
||||
strcpy(s1ap_register_eNB->enb_ip_address.ipv4_address, str);
|
||||
|
||||
itti_send_msg_to_task (TASK_S1AP, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
|
||||
|
||||
register_enb_pending++;
|
||||
}
|
||||
}
|
||||
|
||||
return register_enb_pending;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void *eNB_app_task(void *args_p)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
const Enb_properties_array_t *enb_properties_p = NULL;
|
||||
uint32_t enb_nb = 1; /* Default number of eNB is 1 */
|
||||
uint32_t enb_id_start = 0;
|
||||
uint32_t enb_id_end = enb_id_start + enb_nb;
|
||||
uint32_t register_enb_pending;
|
||||
uint32_t registered_enb;
|
||||
long enb_register_retry_timer_id;
|
||||
MessageDef *msg_p = NULL;
|
||||
const char *msg_name = NULL;
|
||||
instance_t instance;
|
||||
int result;
|
||||
|
||||
itti_mark_task_ready (TASK_ENB_APP);
|
||||
|
||||
enb_properties_p = enb_config_get();
|
||||
|
||||
AssertFatal (enb_nb <= enb_properties_p->number,
|
||||
"Number of eNB is greater than eNB defined in configuration file (%d/%d)!",
|
||||
enb_nb, enb_properties_p->number);
|
||||
|
||||
|
||||
/* Try to register each eNB */
|
||||
registered_enb = 0;
|
||||
register_enb_pending = eNB_app_register (enb_id_start, enb_id_end, enb_properties_p);
|
||||
|
||||
do {
|
||||
// Wait for a message
|
||||
itti_receive_msg (TASK_ENB_APP, &msg_p);
|
||||
|
||||
msg_name = ITTI_MSG_NAME (msg_p);
|
||||
instance = ITTI_MSG_INSTANCE (msg_p);
|
||||
|
||||
switch (ITTI_MSG_ID(msg_p)) {
|
||||
case TERMINATE_MESSAGE:
|
||||
itti_exit_task ();
|
||||
break;
|
||||
|
||||
case MESSAGE_TEST:
|
||||
LOG_I(ENB_APP, "Received %s\n", ITTI_MSG_NAME(msg_p));
|
||||
break;
|
||||
|
||||
|
||||
case S1AP_REGISTER_ENB_CNF:
|
||||
LOG_I(ENB_APP, "[eNB %d] Received %s: associated MME %d\n", instance, msg_name,
|
||||
S1AP_REGISTER_ENB_CNF(msg_p).nb_mme);
|
||||
|
||||
DevAssert(register_enb_pending > 0);
|
||||
register_enb_pending--;
|
||||
|
||||
/* Check if at least eNB is registered with one MME */
|
||||
if (S1AP_REGISTER_ENB_CNF(msg_p).nb_mme > 0) {
|
||||
registered_enb++;
|
||||
}
|
||||
|
||||
/* Check if all register eNB requests have been processed */
|
||||
if (register_enb_pending == 0) {
|
||||
if (registered_enb == enb_nb) {
|
||||
mme_test_s1_start_test(instance);
|
||||
|
||||
|
||||
} else {
|
||||
uint32_t not_associated = enb_nb - registered_enb;
|
||||
|
||||
LOG_W(ENB_APP, " %d eNB %s not associated with a MME, retrying registration in %d seconds ...\n",
|
||||
not_associated, not_associated > 1 ? "are" : "is", ENB_REGISTER_RETRY_DELAY);
|
||||
|
||||
/* Restart the eNB registration process in ENB_REGISTER_RETRY_DELAY seconds */
|
||||
if (timer_setup (ENB_REGISTER_RETRY_DELAY, 0, TASK_ENB_APP, INSTANCE_DEFAULT, TIMER_ONE_SHOT,
|
||||
NULL, &enb_register_retry_timer_id) < 0) {
|
||||
LOG_E(ENB_APP, " Can not start eNB register retry timer, use \"sleep\" instead!\n");
|
||||
|
||||
sleep(ENB_REGISTER_RETRY_DELAY);
|
||||
/* Restart the registration process */
|
||||
registered_enb = 0;
|
||||
register_enb_pending = eNB_app_register (enb_id_start, enb_id_end, enb_properties_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case S1AP_DEREGISTERED_ENB_IND:
|
||||
LOG_W(ENB_APP, "[eNB %d] Received %s: associated MME %d\n", instance, msg_name,
|
||||
S1AP_DEREGISTERED_ENB_IND(msg_p).nb_mme);
|
||||
|
||||
/* TODO handle recovering of registration */
|
||||
break;
|
||||
|
||||
case TIMER_HAS_EXPIRED:
|
||||
LOG_I(ENB_APP, " Received %s: timer_id %d\n", msg_name, TIMER_HAS_EXPIRED(msg_p).timer_id);
|
||||
|
||||
if (TIMER_HAS_EXPIRED (msg_p).timer_id == enb_register_retry_timer_id) {
|
||||
/* Restart the registration process */
|
||||
registered_enb = 0;
|
||||
register_enb_pending = eNB_app_register (enb_id_start, enb_id_end, enb_properties_p);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_E(ENB_APP, "Received unexpected message %s\n", msg_name);
|
||||
break;
|
||||
}
|
||||
|
||||
result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
|
||||
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
|
||||
} while (1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void mme_test_s1_start_test(instance_t instance)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
s1ap_eNB_itti_send_sctp_data_req(instance,
|
||||
s1c_test.assoc_id,
|
||||
s1ap_scenarios[s1c_test.scenario_index][s1c_test.tx_next_message_index].buffer,
|
||||
s1ap_scenarios[s1c_test.scenario_index][s1c_test.tx_next_message_index].buf_len,
|
||||
s1ap_scenarios[s1c_test.scenario_index][s1c_test.tx_next_message_index].sctp_stream_id);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void mme_test_s1_notify_sctp_data_ind(uint32_t assoc_id, int32_t stream, const uint8_t * const data, const uint32_t data_length)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int main( int argc, char **argv )
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
// initialize the log (see log.h for details)
|
||||
logInit();
|
||||
|
||||
get_options (argc, argv); //Command-line options
|
||||
set_glog(glog_level, glog_verbosity);
|
||||
log_set_instance_type (LOG_INSTANCE_ENB);
|
||||
|
||||
/* Read eNB configuration file */
|
||||
enb_properties = enb_config_init(conf_config_file_name);
|
||||
|
||||
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, itti_dump_file);
|
||||
|
||||
itti_wait_ready(1);
|
||||
|
||||
if (itti_create_task (TASK_SCTP, sctp_eNB_task, NULL) < 0) {
|
||||
LOG_E(SCTP, "Create task for SCTP failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (itti_create_task (TASK_S1AP, s1ap_eNB_task, NULL) < 0) {
|
||||
LOG_E(S1AP, "Create task for S1AP failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (itti_create_task (TASK_ENB_APP, eNB_app_task, NULL) < 0) {
|
||||
LOG_E(S1AP, "Create task for S1AP failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
itti_wait_ready(0);
|
||||
|
||||
|
||||
|
||||
sleep(30);
|
||||
|
||||
logClean();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
|
||||
typedef struct s1c_test_s {
|
||||
int scenario_index;
|
||||
int tx_next_message_index;
|
||||
int rx_next_message_index;
|
||||
int32_t assoc_id;
|
||||
}s1c_test_t;
|
||||
|
||||
void mme_test_s1_start_test(instance_t instance);
|
||||
void mme_test_s1_notify_sctp_data_ind(uint32_t assoc_id, int32_t stream, const uint8_t * const data, const uint32_t data_length);
|
||||
Executable
+337
@@ -0,0 +1,337 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
#include <linux/sched.h>
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
#include <getopt.h>
|
||||
#include <syscall.h>
|
||||
|
||||
|
||||
#include "tree.h"
|
||||
#include "queue.h"
|
||||
#include "intertask_interface.h"
|
||||
#include "s1ap_eNB_default_values.h"
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_ies_defs.h"
|
||||
#include "s1ap_eNB_defs.h"
|
||||
#include "s1ap_eNB_management_procedures.h"
|
||||
#include "assertions.h"
|
||||
|
||||
#include "platform_types.h"
|
||||
#include "oaisim_mme_test_s1c.h"
|
||||
|
||||
|
||||
void s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *sctp_data_ind)
|
||||
{
|
||||
int result;
|
||||
|
||||
DevAssert(sctp_data_ind != NULL);
|
||||
mme_test_s1_notify_sctp_data_ind(sctp_data_ind->assoc_id, sctp_data_ind->stream,
|
||||
sctp_data_ind->buffer, sctp_data_ind->buffer_length);
|
||||
|
||||
result = itti_free(TASK_UNKNOWN, sctp_data_ind->buffer);
|
||||
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
|
||||
}
|
||||
|
||||
|
||||
void s1ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,
|
||||
uint32_t buffer_length, uint16_t stream)
|
||||
{
|
||||
MessageDef *message_p;
|
||||
sctp_data_req_t *sctp_data_req;
|
||||
|
||||
message_p = itti_alloc_new_message(TASK_S1AP, SCTP_DATA_REQ);
|
||||
|
||||
sctp_data_req = &message_p->ittiMsg.sctp_data_req;
|
||||
|
||||
sctp_data_req->assoc_id = assoc_id;
|
||||
sctp_data_req->buffer = buffer;
|
||||
sctp_data_req->buffer_length = buffer_length;
|
||||
sctp_data_req->stream = stream;
|
||||
|
||||
itti_send_msg_to_task(TASK_SCTP, instance, message_p);
|
||||
}
|
||||
|
||||
void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shutdown)
|
||||
{
|
||||
if (sctp_shutdown) {
|
||||
/* A previously connected MME has been shutdown */
|
||||
|
||||
/* TODO check if it was used by some eNB and send a message to inform these eNB if there is no more associated MME */
|
||||
if (mme_desc_p->state == S1AP_ENB_STATE_CONNECTED) {
|
||||
mme_desc_p->state = S1AP_ENB_STATE_DISCONNECTED;
|
||||
|
||||
if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb > 0) {
|
||||
/* Decrease associated MME number */
|
||||
mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb --;
|
||||
}
|
||||
|
||||
/* If there are no more associated MME, inform eNB app */
|
||||
if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb == 0) {
|
||||
MessageDef *message_p;
|
||||
|
||||
message_p = itti_alloc_new_message(TASK_S1AP, S1AP_DEREGISTERED_ENB_IND);
|
||||
S1AP_DEREGISTERED_ENB_IND(message_p).nb_mme = 0;
|
||||
itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Check that at least one setup message is pending */
|
||||
DevCheck(mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb > 0, mme_desc_p->s1ap_eNB_instance->instance,
|
||||
mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb, 0);
|
||||
|
||||
if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb > 0) {
|
||||
/* Decrease pending messages number */
|
||||
mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb --;
|
||||
}
|
||||
|
||||
/* If there are no more pending messages, inform eNB app */
|
||||
if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb == 0) {
|
||||
MessageDef *message_p;
|
||||
|
||||
message_p = itti_alloc_new_message(TASK_S1AP, S1AP_REGISTER_ENB_CNF);
|
||||
S1AP_REGISTER_ENB_CNF(message_p).nb_mme = mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb;
|
||||
itti_send_msg_to_task(TASK_ENB_APP, mme_desc_p->s1ap_eNB_instance->instance, message_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp)
|
||||
{
|
||||
s1ap_eNB_instance_t *instance_p;
|
||||
s1ap_eNB_mme_data_t *s1ap_mme_data_p;
|
||||
|
||||
DevAssert(sctp_new_association_resp != NULL);
|
||||
|
||||
instance_p = s1ap_eNB_get_instance(instance);
|
||||
DevAssert(instance_p != NULL);
|
||||
|
||||
s1ap_mme_data_p = s1ap_eNB_get_MME(instance_p, -1,
|
||||
sctp_new_association_resp->ulp_cnx_id);
|
||||
DevAssert(s1ap_mme_data_p != NULL);
|
||||
|
||||
if (sctp_new_association_resp->sctp_state != SCTP_STATE_ESTABLISHED) {
|
||||
S1AP_WARN("Received unsuccessful result for SCTP association (%u), instance %d, cnx_id %u\n",
|
||||
sctp_new_association_resp->sctp_state,
|
||||
instance,
|
||||
sctp_new_association_resp->ulp_cnx_id);
|
||||
|
||||
s1ap_handle_s1_setup_message(s1ap_mme_data_p, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update parameters */
|
||||
s1ap_mme_data_p->assoc_id = sctp_new_association_resp->assoc_id;
|
||||
s1ap_mme_data_p->in_streams = sctp_new_association_resp->in_streams;
|
||||
s1ap_mme_data_p->out_streams = sctp_new_association_resp->out_streams;
|
||||
|
||||
/* Prepare new S1 Setup Request */
|
||||
mme_test_s1_start_test(instance_p, s1ap_mme_data_p);
|
||||
}
|
||||
|
||||
void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
|
||||
net_ip_address_t *mme_ip_address,
|
||||
net_ip_address_t *local_ip_addr)
|
||||
{
|
||||
MessageDef *message_p = NULL;
|
||||
sctp_new_association_req_t *sctp_new_association_req_p = NULL;
|
||||
s1ap_eNB_mme_data_t *s1ap_mme_data_p = NULL;
|
||||
|
||||
DevAssert(instance_p != NULL);
|
||||
DevAssert(mme_ip_address != NULL);
|
||||
|
||||
message_p = itti_alloc_new_message(TASK_S1AP, SCTP_NEW_ASSOCIATION_REQ);
|
||||
|
||||
sctp_new_association_req_p = &message_p->ittiMsg.sctp_new_association_req;
|
||||
|
||||
sctp_new_association_req_p->port = S1AP_PORT_NUMBER;
|
||||
sctp_new_association_req_p->ppid = S1AP_SCTP_PPID;
|
||||
|
||||
memcpy(&sctp_new_association_req_p->remote_address,
|
||||
mme_ip_address,
|
||||
sizeof(*mme_ip_address));
|
||||
|
||||
memcpy(&sctp_new_association_req_p->local_address,
|
||||
local_ip_addr,
|
||||
sizeof(*local_ip_addr));
|
||||
|
||||
/* Create new MME descriptor */
|
||||
s1ap_mme_data_p = calloc(1, sizeof(*s1ap_mme_data_p));
|
||||
DevAssert(s1ap_mme_data_p != NULL);
|
||||
|
||||
s1ap_mme_data_p->cnx_id = s1ap_eNB_fetch_add_global_cnx_id();
|
||||
sctp_new_association_req_p->ulp_cnx_id = s1ap_mme_data_p->cnx_id;
|
||||
|
||||
s1ap_mme_data_p->assoc_id = -1;
|
||||
s1ap_mme_data_p->s1ap_eNB_instance = instance_p;
|
||||
|
||||
STAILQ_INIT(&s1ap_mme_data_p->served_gummei);
|
||||
|
||||
/* Insert the new descriptor in list of known MME
|
||||
* but not yet associated.
|
||||
*/
|
||||
RB_INSERT(s1ap_mme_map, &instance_p->s1ap_mme_head, s1ap_mme_data_p);
|
||||
s1ap_mme_data_p->state = S1AP_ENB_STATE_WAITING;
|
||||
instance_p->s1ap_mme_nb ++;
|
||||
instance_p->s1ap_mme_pending_nb ++;
|
||||
|
||||
itti_send_msg_to_task(TASK_SCTP, instance_p->instance, message_p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *s1ap_register_eNB)
|
||||
{
|
||||
s1ap_eNB_instance_t *new_instance;
|
||||
uint8_t index;
|
||||
|
||||
DevAssert(s1ap_register_eNB != NULL);
|
||||
|
||||
/* Look if the provided instance already exists */
|
||||
new_instance = s1ap_eNB_get_instance(instance);
|
||||
|
||||
if (new_instance != NULL) {
|
||||
/* Checks if it is a retry on the same eNB */
|
||||
DevCheck(new_instance->eNB_id == s1ap_register_eNB->eNB_id, new_instance->eNB_id, s1ap_register_eNB->eNB_id, 0);
|
||||
DevCheck(new_instance->cell_type == s1ap_register_eNB->cell_type, new_instance->cell_type, s1ap_register_eNB->cell_type, 0);
|
||||
DevCheck(new_instance->tac == s1ap_register_eNB->tac, new_instance->tac, s1ap_register_eNB->tac, 0);
|
||||
DevCheck(new_instance->mcc == s1ap_register_eNB->mcc, new_instance->mcc, s1ap_register_eNB->mcc, 0);
|
||||
DevCheck(new_instance->mnc == s1ap_register_eNB->mnc, new_instance->mnc, s1ap_register_eNB->mnc, 0);
|
||||
DevCheck(new_instance->mnc_digit_length == s1ap_register_eNB->mnc_digit_length, new_instance->mnc_digit_length, s1ap_register_eNB->mnc_digit_length, 0);
|
||||
DevCheck(new_instance->default_drx == s1ap_register_eNB->default_drx, new_instance->default_drx, s1ap_register_eNB->default_drx, 0);
|
||||
} else {
|
||||
new_instance = calloc(1, sizeof(s1ap_eNB_instance_t));
|
||||
DevAssert(new_instance != NULL);
|
||||
|
||||
RB_INIT(&new_instance->s1ap_ue_head);
|
||||
RB_INIT(&new_instance->s1ap_mme_head);
|
||||
|
||||
/* Copy usefull parameters */
|
||||
new_instance->instance = instance;
|
||||
new_instance->eNB_name = s1ap_register_eNB->eNB_name;
|
||||
new_instance->eNB_id = s1ap_register_eNB->eNB_id;
|
||||
new_instance->cell_type = s1ap_register_eNB->cell_type;
|
||||
new_instance->tac = s1ap_register_eNB->tac;
|
||||
new_instance->mcc = s1ap_register_eNB->mcc;
|
||||
new_instance->mnc = s1ap_register_eNB->mnc;
|
||||
new_instance->mnc_digit_length = s1ap_register_eNB->mnc_digit_length;
|
||||
new_instance->default_drx = s1ap_register_eNB->default_drx;
|
||||
|
||||
/* Add the new instance to the list of eNB (meaningfull in virtual mode) */
|
||||
s1ap_eNB_insert_new_instance(new_instance);
|
||||
|
||||
S1AP_DEBUG("Registered new eNB[%d] and %s eNB id %u\n",
|
||||
instance,
|
||||
s1ap_register_eNB->cell_type == CELL_MACRO_ENB ? "macro" : "home",
|
||||
s1ap_register_eNB->eNB_id);
|
||||
}
|
||||
|
||||
DevCheck(s1ap_register_eNB->nb_mme <= S1AP_MAX_NB_MME_IP_ADDRESS,
|
||||
S1AP_MAX_NB_MME_IP_ADDRESS, s1ap_register_eNB->nb_mme, 0);
|
||||
|
||||
/* Trying to connect to provided list of MME ip address */
|
||||
for (index = 0; index < s1ap_register_eNB->nb_mme; index++) {
|
||||
s1ap_eNB_register_mme(new_instance, &s1ap_register_eNB->mme_ip_address[index],
|
||||
&s1ap_register_eNB->enb_ip_address);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void *s1ap_eNB_task(void *arg)
|
||||
{
|
||||
MessageDef *received_msg = NULL;
|
||||
int result;
|
||||
|
||||
S1AP_DEBUG("Starting S1AP layer\n");
|
||||
|
||||
s1ap_eNB_prepare_internal_data();
|
||||
|
||||
itti_mark_task_ready(TASK_S1AP);
|
||||
|
||||
while (1) {
|
||||
itti_receive_msg(TASK_S1AP, &received_msg);
|
||||
|
||||
switch (ITTI_MSG_ID(received_msg)) {
|
||||
case TERMINATE_MESSAGE:
|
||||
itti_exit_task();
|
||||
break;
|
||||
|
||||
case S1AP_REGISTER_ENB_REQ: {
|
||||
/* Register a new eNB.
|
||||
* in Virtual mode eNBs will be distinguished using the mod_id/
|
||||
* Each eNB has to send an S1AP_REGISTER_ENB message with its
|
||||
* own parameters.
|
||||
*/
|
||||
s1ap_eNB_handle_register_eNB(ITTI_MESSAGE_GET_INSTANCE(received_msg),
|
||||
&S1AP_REGISTER_ENB_REQ(received_msg));
|
||||
}
|
||||
break;
|
||||
|
||||
case SCTP_NEW_ASSOCIATION_RESP: {
|
||||
s1ap_eNB_handle_sctp_association_resp(ITTI_MESSAGE_GET_INSTANCE(received_msg),
|
||||
&received_msg->ittiMsg.sctp_new_association_resp);
|
||||
}
|
||||
break;
|
||||
|
||||
case SCTP_DATA_IND: {
|
||||
s1ap_eNB_handle_sctp_data_ind(&received_msg->ittiMsg.sctp_data_ind);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
default:
|
||||
S1AP_ERROR("Received unhandled message: %d:%s\n",
|
||||
ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
|
||||
break;
|
||||
}
|
||||
|
||||
result = itti_free (ITTI_MSG_ORIGIN_ID(received_msg), received_msg);
|
||||
AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result);
|
||||
|
||||
received_msg = NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sched.h>
|
||||
#include <linux/sched.h>
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
#include <getopt.h>
|
||||
#include <syscall.h>
|
||||
|
||||
void s1ap_eNB_handle_sctp_data_ind(sctp_data_ind_t *sctp_data_ind);
|
||||
|
||||
void s1ap_eNB_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,
|
||||
uint32_t buffer_length, uint16_t stream);
|
||||
|
||||
void s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_shutdown);
|
||||
|
||||
void s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_association_resp_t *sctp_new_association_resp);
|
||||
|
||||
void s1ap_eNB_register_mme(s1ap_eNB_instance_t *instance_p,
|
||||
net_ip_address_t *mme_ip_address,
|
||||
net_ip_address_t *local_ip_addr,
|
||||
uint16_t in_streams,
|
||||
uint16_t out_streams);
|
||||
void s1ap_eNB_handle_register_eNB(instance_t instance, s1ap_register_enb_req_t *s1ap_register_eNB);
|
||||
void *s1ap_eNB_task(void *arg);
|
||||
Executable
+286
@@ -0,0 +1,286 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "oaisim_mme_test_s1c_scenario.h"
|
||||
|
||||
int scenario_index = 0;
|
||||
int scenario_message_index = 0;
|
||||
int debug = 0;
|
||||
int error_count = 0;
|
||||
int break_on_error = 0;
|
||||
|
||||
|
||||
extern s1ap_message_test_t s1ap_scenario1[];
|
||||
|
||||
s1ap_message_test_t s1ap_scenarios[][] = {s1ap_scenario1};
|
||||
|
||||
/* -1 means invalid */
|
||||
static const signed char hex_digits[0x100] = {
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
|
||||
-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
fail (const char *format, ...)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
char str[1024];
|
||||
va_list arg_ptr;
|
||||
|
||||
va_start (arg_ptr, format);
|
||||
vsnprintf ( str, sizeof(str), format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
fputs(str, stderr);
|
||||
error_count++;
|
||||
|
||||
if (break_on_error)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
success (const char *format, ...)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
char str[1024];
|
||||
va_list arg_ptr;
|
||||
|
||||
va_start (arg_ptr, format);
|
||||
vsnprintf ( str, sizeof(str), format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
fputs(str, stderr);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
escapeprint (const char *str, size_t len)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
size_t i;
|
||||
|
||||
printf (" (length %d bytes):\n\t", (int) len);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (((str[i] & 0xFF) >= 'A' && (str[i] & 0xFF) <= 'Z') ||
|
||||
((str[i] & 0xFF) >= 'a' && (str[i] & 0xFF) <= 'z') ||
|
||||
((str[i] & 0xFF) >= '0' && (str[i] & 0xFF) <= '9')
|
||||
|| (str[i] & 0xFF) == ' ' || (str[i] & 0xFF) == '.')
|
||||
printf ("%c", (str[i] & 0xFF));
|
||||
else
|
||||
printf ("\\x%02X", (str[i] & 0xFF));
|
||||
|
||||
if ((i + 1) % 16 == 0 && (i + 1) < len)
|
||||
printf ("'\n\t'");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
hexprint (const void *_str, size_t len)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
size_t i;
|
||||
const char* str = _str;
|
||||
|
||||
printf ("\t;; ");
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
printf ("%02x ", (str[i] & 0xFF));
|
||||
|
||||
if ((i + 1) % 8 == 0)
|
||||
printf (" ");
|
||||
|
||||
if ((i + 1) % 16 == 0 && i + 1 < len)
|
||||
printf ("\n\t;; ");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
binprint (const void *_str, size_t len)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
size_t i;
|
||||
const char* str = _str;
|
||||
|
||||
printf ("\t;; ");
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
printf ("%d%d%d%d%d%d%d%d ",
|
||||
(str[i] & 0xFF) & 0x80 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x40 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x20 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x10 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x08 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x04 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x02 ? 1 : 0, (str[i] & 0xFF) & 0x01 ? 1 : 0);
|
||||
|
||||
if ((i + 1) % 3 == 0)
|
||||
printf (" ");
|
||||
|
||||
if ((i + 1) % 6 == 0 && i + 1 < len)
|
||||
printf ("\n\t;; ");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int
|
||||
compare_buffer(const uint8_t *buffer, const uint32_t length_buffer,
|
||||
const uint8_t *pattern, const uint32_t length_pattern)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
int i;
|
||||
|
||||
if (length_buffer != length_pattern) {
|
||||
printf("Length mismatch, expecting %d bytes, got %d bytes\n", length_pattern,
|
||||
length_buffer);
|
||||
hexprint(buffer, length_buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < length_buffer; i++) {
|
||||
if (pattern[i] != buffer[i]) {
|
||||
printf("Expecting:\n");
|
||||
hexprint(pattern, length_pattern);
|
||||
printf("Received:\n");
|
||||
hexprint(buffer, length_buffer);
|
||||
printf("Mismatch fount in byte %d\nExpecting 0x%02x, got 0x%02x\n",
|
||||
i, pattern[i], buffer[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
unsigned
|
||||
decode_hex_length(const char *h)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
const unsigned char *hex = (const unsigned char *) h;
|
||||
unsigned count;
|
||||
unsigned i;
|
||||
|
||||
for (count = i = 0; hex[i]; i++) {
|
||||
if (isspace(hex[i]))
|
||||
continue;
|
||||
|
||||
if (hex_digits[hex[i]] < 0)
|
||||
abort();
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count % 2)
|
||||
abort();
|
||||
|
||||
return count / 2;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int
|
||||
decode_hex(uint8_t *dst, const char *h)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
const unsigned char *hex = (const unsigned char *) h;
|
||||
unsigned i = 0;
|
||||
|
||||
for (;;) {
|
||||
int high, low;
|
||||
|
||||
while (*hex && isspace(*hex))
|
||||
hex++;
|
||||
|
||||
if (!*hex)
|
||||
return 1;
|
||||
|
||||
high = hex_digits[*hex++];
|
||||
|
||||
if (high < 0)
|
||||
return 0;
|
||||
|
||||
while (*hex && isspace(*hex))
|
||||
hex++;
|
||||
|
||||
if (!*hex)
|
||||
return 0;
|
||||
|
||||
low = hex_digits[*hex++];
|
||||
|
||||
if (low < 0)
|
||||
return 0;
|
||||
|
||||
dst[i++] = (high << 4) | low;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
uint8_t *
|
||||
decode_hex_dup(const char *hex)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
uint8_t *p;
|
||||
unsigned length = decode_hex_length(hex);
|
||||
|
||||
p = malloc(length * sizeof(uint8_t));
|
||||
|
||||
if (decode_hex(p, hex))
|
||||
return p;
|
||||
else {
|
||||
free(p);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MME_TEST_S1_MAX_BUF_LENGTH (1024)
|
||||
#define MME_TEST_S1_MAX_BYTES_TEST (32)
|
||||
|
||||
typedef enum entity_s{
|
||||
MME,
|
||||
ENB
|
||||
} entity_t;
|
||||
|
||||
typedef struct s1ap_message_test_s{
|
||||
char *procedure_name;
|
||||
uint8_t buffer[MME_TEST_S1_MAX_BUF_LENGTH];
|
||||
uint16_t dont_check[MME_TEST_S1_MAX_BYTES_TEST]; // bytes index test that can be omitted
|
||||
uint32_t buf_len;
|
||||
entity_t originating;
|
||||
uint16_t sctp_stream_id;
|
||||
uint32_t assoc_id;
|
||||
} s1ap_message_test_t;
|
||||
|
||||
void fail (const char *format, ...);
|
||||
void success (const char *format, ...);
|
||||
void escapeprint (const char *str, size_t len);
|
||||
void hexprint (const void *_str, size_t len);
|
||||
void binprint (const void *_str, size_t len);
|
||||
int compare_buffer(const uint8_t *buffer, const uint32_t length_buffer, const uint8_t *pattern, const uint32_t length_pattern);
|
||||
unsigned decode_hex_length(const char *h);
|
||||
int decode_hex(uint8_t *dst, const char *h);
|
||||
uint8_t *decode_hex_dup(const char *hex);
|
||||
@@ -0,0 +1,188 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include "oaisim_mme_test_s1c_scenario.h"
|
||||
|
||||
|
||||
// Description succesfull attach of UE, release UE.
|
||||
|
||||
s1ap_message_test_t s1ap_scenario1[] = {
|
||||
{
|
||||
.procedure_name = "id-initialUEMessage",
|
||||
.buffer = {
|
||||
0x00, 0x0C,
|
||||
0x00, 0x5C, 0x00, 0x00, 0x05, 0x00, 0x08, 0x00, 0x04, 0x80, 0x06, 0x69, 0x2D, 0x00, 0x1A, 0x00,
|
||||
0x32, 0x31, 0x07, 0x41, 0x71, 0x08, 0x29, 0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0xE0,
|
||||
0xE0, 0x00, 0x20, 0x02, 0x01, 0xD0, 0x11, 0x27, 0x1A, 0x80, 0x80, 0x21, 0x10, 0x01, 0x00, 0x00,
|
||||
0x10, 0x81, 0x06, 0x00, 0x00, 0x00, 0x00, 0x83, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x00,
|
||||
0x00, 0x0A, 0x00, 0x00, 0x43, 0x00, 0x06, 0x00, 0x02, 0xF8, 0x39, 0x00, 0x01, 0x00, 0x64, 0x40,
|
||||
0x08, 0x00, 0x02, 0xF8, 0x39, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x86, 0x40, 0x01, 0x30
|
||||
},
|
||||
.dont_check = {
|
||||
-1
|
||||
},
|
||||
.buf_len = 96,
|
||||
.sctp_stream_id = 1,
|
||||
.originating = ENB,
|
||||
},
|
||||
{
|
||||
.procedure_name = "id-downlinkNASTransport, Authentication request",
|
||||
.buffer = {
|
||||
0x00, 0x0B,
|
||||
0x00, 0x3D, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xC0, 0x80, 0x00, 0x15, 0x20, 0x00, 0x08,
|
||||
0x00, 0x04, 0x80, 0x06, 0x69, 0x2D, 0x00, 0x1A, 0x00, 0x25, 0x24, 0x07, 0x52, 0x00, 0xD3, 0xB5,
|
||||
0xF0, 0x89, 0x68, 0x02, 0x66, 0x5A, 0x08, 0xE6, 0x51, 0xC7, 0x29, 0x6B, 0x4D, 0xA0, 0x10, 0xDD,
|
||||
0x04, 0x53, 0xC8, 0x3F, 0x94, 0x80, 0x00, 0x03, 0xAF, 0x2F, 0x49, 0xF3, 0xC8, 0x38, 0x90, 0x00,
|
||||
0x00, 0x00
|
||||
},
|
||||
.dont_check = {
|
||||
-1
|
||||
},
|
||||
.buf_len = 65,
|
||||
.sctp_stream_id = 1,
|
||||
.originating = MME,
|
||||
},
|
||||
{
|
||||
.procedure_name = "id-uplinkNASTransport, 0xAuthentication response",
|
||||
.buffer = {
|
||||
0x00, 0x0d,
|
||||
0x40, 0x3a, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0xc0, 0x80, 0x00, 0x15, 0x20, 0x00, 0x08,
|
||||
0x00, 0x04, 0x80, 0x06, 0x69, 0x2d, 0x00, 0x1a, 0x00, 0x0C, 0x0b, 0x07, 0x53, 0x08, 0x11, 0x82,
|
||||
0x98, 0x98, 0x3b, 0xca, 0xF2, 0x97, 0x00, 0x64, 0x40, 0x08, 0x00, 0x02, 0xF8, 0x39, 0x00, 0x00,
|
||||
0xe0, 0x00, 0x00, 0x43, 0x40, 0x06, 0x00, 0x02, 0xF8, 0x39, 0x00, 0x01, 0x00, 0x00
|
||||
},
|
||||
.dont_check = {
|
||||
-1
|
||||
},
|
||||
.buf_len = 62,
|
||||
.sctp_stream_id = 1,
|
||||
.originating = ENB,
|
||||
},
|
||||
{
|
||||
.procedure_name = "id-downlinkNASTransport, Security mode command",
|
||||
.buffer = {
|
||||
0x00, 0x0b,
|
||||
0x00, 0x26, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xc0, 0x80, 0x00, 0x15, 0x20, 0x00, 0x08,
|
||||
0x00, 0x04, 0x80, 0x06, 0x69, 0x2d, 0x00, 0x1a, 0x00, 0x0e, 0x0d, 0x37, 0xFC, 0xc1, 0xda, 0xd9,
|
||||
0x00, 0x07, 0x5d, 0x02, 0x00, 0x02, 0xe0, 0xe0, 0x00, 0x00
|
||||
},
|
||||
.dont_check = {
|
||||
-1
|
||||
},
|
||||
.buf_len = 42,
|
||||
.sctp_stream_id = 1,
|
||||
.originating = MME,
|
||||
},
|
||||
{
|
||||
.procedure_name = "id-uplinkNASTransport, Security mode complete",
|
||||
.buffer = {
|
||||
0x00, 0x0d,
|
||||
0x40, 0x37, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0xc0, 0x80, 0x00, 0x15, 0x20, 0x00, 0x08,
|
||||
0x00, 0x04, 0x80, 0x06, 0x69, 0x2d, 0x00, 0x1a, 0x00, 0x09, 0x08, 0x47, 0x1d, 0xd0, 0xbb, 0xad,
|
||||
0x00, 0x07, 0x5e, 0x00, 0x64, 0x40, 0x08, 0x00, 0x02, 0xF8, 0x39, 0x00, 0x00, 0xe0, 0x00, 0x00,
|
||||
0x43, 0x40, 0x06, 0x00, 0x02, 0xF8, 0x39, 0x00, 0x01, 0x00
|
||||
},
|
||||
.dont_check = {
|
||||
-1
|
||||
},
|
||||
.buf_len = 59,
|
||||
.sctp_stream_id = 1,
|
||||
.originating = ENB,
|
||||
},
|
||||
{
|
||||
.procedure_name = "id-InitialContextSetup, InitialContextSetupRequest , Attach accept, Activate default EPS bearer context request",
|
||||
.buffer = {
|
||||
0x00, 0x09,
|
||||
0x00, 0x80, 0xba, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x05, 0xc0, 0x80, 0x00, 0x15, 0x20, 0x00,
|
||||
0x08, 0x00, 0x04, 0x80, 0x06, 0x69, 0x2d, 0x00, 0x42, 0x00, 0x0a, 0x18, 0x05, 0xF5, 0xe1, 0x00,
|
||||
0x60, 0x02, 0xFa, 0xF0, 0x80, 0x00, 0x18, 0x00, 0x67, 0x00, 0x00, 0x34, 0x00, 0x62, 0x45, 0x00,
|
||||
0x09, 0x04, 0x0f, 0x80, 0x7f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x53, 0x27, 0x8b, 0xe6,
|
||||
0x60, 0xb5, 0x01, 0x07, 0x42, 0x01, 0x4a, 0x06, 0x20, 0x02, 0xF8, 0x39, 0x00, 0x01, 0x00, 0x31,
|
||||
0x52, 0x01, 0xc1, 0x01, 0x09, 0x09, 0x03, 0x6f, 0x61, 0x69, 0x04, 0x69, 0x70, 0x76, 0x34, 0x05,
|
||||
0x01, 0xc0, 0xbb, 0x00, 0x02, 0x5e, 0x04, 0xFe, 0xFe, 0xde, 0x9e, 0x27, 0x14, 0x80, 0x80, 0x21,
|
||||
0x10, 0x03, 0x00, 0x00, 0x10, 0x81, 0x06, 0xc0, 0xa8, 0x0C, 0x64, 0x83, 0x06, 0xc0, 0xa8, 0x6a,
|
||||
0x0C, 0x50, 0x0b, 0xF6, 0x02, 0xF8, 0x39, 0x80, 0x00, 0x01, 0x78, 0x00, 0x0C, 0x20, 0x17, 0x2C,
|
||||
0x00, 0x6b, 0x00, 0x05, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x49, 0x00, 0x20, 0xFa, 0x59, 0x15,
|
||||
0x4e, 0x32, 0x95, 0x04, 0x2d, 0x35, 0xa4, 0x47, 0xc3, 0x80, 0xab, 0x63, 0xd8, 0xe6, 0x91, 0x83,
|
||||
0x6C, 0x9a, 0xF0, 0xed, 0x85, 0x38, 0xa8, 0x27, 0x41, 0x6b, 0x2b, 0x64, 0x86, 0x00
|
||||
},
|
||||
.dont_check = {
|
||||
-1
|
||||
},
|
||||
.buf_len = 191,
|
||||
.sctp_stream_id = 1,
|
||||
.originating = MME,
|
||||
},
|
||||
{
|
||||
.procedure_name = "id-UECapabilityInfoIndication",
|
||||
.buffer = {
|
||||
0x00, 0x16,
|
||||
0x40, 0x2C, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xc0, 0x80, 0x00, 0x15, 0x20, 0x00, 0x08,
|
||||
0x00, 0x04, 0x80, 0x06, 0x69, 0x2d, 0x00, 0x4a, 0x40, 0x14, 0x13, 0x81, 0x20, 0x00, 0x03, 0x00,
|
||||
0x10, 0x60, 0xe0, 0xc1, 0xF8, 0x3f, 0x07, 0xe0 ,0xfd, 0x78, 0x37, 0x62, 0x00, 0x00
|
||||
},
|
||||
.dont_check = {
|
||||
-1
|
||||
},
|
||||
.buf_len = 48,
|
||||
.originating = ENB,
|
||||
},
|
||||
{
|
||||
.procedure_name = "id-InitialContextSetup, InitialContextSetupResponse ",
|
||||
.buffer = {
|
||||
0x20, 0x09,
|
||||
0x00, 0x27, 0x00, 0x00, 0x03, 0x00, 0x00, 0x40, 0x05, 0xc0, 0x80, 0x00, 0x15, 0x20, 0x00, 0x08,
|
||||
0x40, 0x04, 0x80, 0x06, 0x69, 0x2d, 0x00, 0x33, 0x40, 0x0f, 0x00, 0x00, 0x32, 0x40, 0x0a, 0x0a,
|
||||
0x1f, 0x7f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01
|
||||
},
|
||||
.dont_check = {
|
||||
-1
|
||||
},
|
||||
.buf_len = 64,
|
||||
.sctp_stream_id = 1,
|
||||
.originating = ENB,
|
||||
},
|
||||
{
|
||||
.procedure_name = "id-uplinkNASTransport, Attach complete, Activate default EPS bearer context accept",
|
||||
.buffer = {
|
||||
|
||||
0x00, 0x0d,
|
||||
0x05, 0x00, 0x00, 0x00, 0x05, 0xc0, 0x80, 0x00, 0x15, 0x20, 0x00, 0x08, 0x00, 0x04, 0x80, 0x06,
|
||||
0x69, 0x2d, 0x00, 0x1a, 0x00, 0x0e, 0x0d, 0x27, 0xc7, 0x8f, 0x5a, 0xd2, 0x01, 0x07, 0x43, 0x00,
|
||||
0x03, 0x52, 0x00, 0xc2, 0x00, 0x64, 0x40, 0x08, 0x00, 0x02, 0xF8, 0x39, 0x00, 0x00, 0xe0, 0x00,
|
||||
0x00, 0x43, 0x40, 0x06, 0x00, 0x02, 0xF8, 0x39, 0x00, 0x01
|
||||
},
|
||||
.dont_check = {
|
||||
-1
|
||||
},
|
||||
.buf_len = 64,
|
||||
.sctp_stream_id = 1,
|
||||
.originating = ENB,
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,93 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/cmac.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
static CMAC_CTX *ctx;
|
||||
|
||||
static
|
||||
void test_cmac(const uint8_t *key, unsigned key_length, const uint8_t *message,
|
||||
unsigned length, const uint8_t *expect, unsigned expected_length)
|
||||
{
|
||||
size_t size;
|
||||
uint8_t result[16];
|
||||
|
||||
ctx = CMAC_CTX_new();
|
||||
|
||||
CMAC_Init(ctx, key, key_length, EVP_aes_128_cbc(), NULL);
|
||||
CMAC_Update(ctx, message, length);
|
||||
CMAC_Final(ctx, result, &size);
|
||||
|
||||
CMAC_CTX_free(ctx);
|
||||
|
||||
if (compare_buffer(result, size, expect, expected_length) != 0) {
|
||||
fail("test_cmac");
|
||||
}
|
||||
}
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
/* SP300-38B #D.1 */
|
||||
|
||||
/* Example 1 */
|
||||
test_cmac(
|
||||
HL("2b7e151628aed2a6abf7158809cf4f3c"),
|
||||
HL(""),
|
||||
HL("bb1d6929e95937287fa37d129b756746"));
|
||||
/* Example 2 */
|
||||
test_cmac(
|
||||
HL("2b7e151628aed2a6abf7158809cf4f3c"),
|
||||
HL("6bc1bee22e409f96e93d7e117393172a"),
|
||||
HL("070a16b46b4d4144f79bdd9dd04a287c"));
|
||||
/* Example 3 */
|
||||
test_cmac(
|
||||
HL("2b7e151628aed2a6abf7158809cf4f3c"),
|
||||
HL("6bc1bee22e409f96e93d7e117393172a"
|
||||
"ae2d8a571e03ac9c9eb76fac45af8e51"
|
||||
"30c81c46a35ce411"),
|
||||
HL("dfa66747de9ae63030ca32611497c827"));
|
||||
/* Example 4 */
|
||||
test_cmac(
|
||||
HL("2b7e151628aed2a6abf7158809cf4f3c"),
|
||||
HL("6bc1bee22e409f96e93d7e117393172a"
|
||||
"ae2d8a571e03ac9c9eb76fac45af8e51"
|
||||
"30c81c46a35ce411e5fbc1191a0a52ef"
|
||||
"f69f2445df4f9b17ad2b417be66c3710"),
|
||||
HL("51f0bebf7e3b9d92fc49741779363cfe"));
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
#include <nettle/nettle-meta.h>
|
||||
#include <nettle/aes.h>
|
||||
#include <nettle/ctr.h>
|
||||
|
||||
static
|
||||
void test_uncipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key,
|
||||
unsigned key_length, const uint8_t *cipheredtext,
|
||||
unsigned length, const uint8_t *cleartext, const uint8_t *ictr)
|
||||
{
|
||||
void *ctx = malloc(cipher->context_size);
|
||||
uint8_t *data = malloc(length);
|
||||
uint8_t *ctr = malloc(cipher->block_size);
|
||||
|
||||
cipher->set_encrypt_key(ctx, key_length, key);
|
||||
memcpy(ctr, ictr, cipher->block_size);
|
||||
|
||||
ctr_crypt(ctx, cipher->encrypt,
|
||||
cipher->block_size, ctr,
|
||||
length, data, cipheredtext);
|
||||
|
||||
if (compare_buffer(data, length, cleartext, length) != 0) {
|
||||
fail("Fail: test_uncipher_ctr\n");
|
||||
}
|
||||
|
||||
free(ctx);
|
||||
free(data);
|
||||
free(ctr);
|
||||
}
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
/* From NIST spec 800-38a on AES modes,
|
||||
*
|
||||
* http://csrc.nist.gov/CryptoToolkit/modes/800-38_Series_Publications/SP800-38A.pdf
|
||||
*
|
||||
* F.5 CTR Example Vectors
|
||||
*/
|
||||
/* F.5.1 CTR-AES128.Encrypt */
|
||||
test_uncipher_ctr(&nettle_aes128,
|
||||
HL("2b7e151628aed2a6abf7158809cf4f3c"),
|
||||
HL("6bc1bee22e409f96e93d7e117393172a"
|
||||
"ae2d8a571e03ac9c9eb76fac45af8e51"
|
||||
"30c81c46a35ce411e5fbc1191a0a52ef"
|
||||
"f69f2445df4f9b17ad2b417be66c3710"),
|
||||
H("874d6191b620e3261bef6864990db6ce"
|
||||
"9806f66b7970fdff8617187bb9fffdff"
|
||||
"5ae4df3edbd5d35e5b4f09020db03eab"
|
||||
"1e031dda2fbe03d1792170a0f3009cee"),
|
||||
H("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"));
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
#include <nettle/nettle-meta.h>
|
||||
#include <nettle/aes.h>
|
||||
#include <nettle/ctr.h>
|
||||
|
||||
static void test_cipher_ctr(const struct nettle_cipher *cipher, const uint8_t *key,
|
||||
unsigned key_length, const uint8_t *cleartext, unsigned length,
|
||||
const uint8_t *ciphertext, const uint8_t *ictr)
|
||||
{
|
||||
void *ctx = malloc(cipher->context_size);
|
||||
uint8_t *data = malloc(length);
|
||||
uint8_t *ctr = malloc(cipher->block_size);
|
||||
|
||||
cipher->set_encrypt_key(ctx, key_length, key);
|
||||
memcpy(ctr, ictr, cipher->block_size);
|
||||
|
||||
ctr_crypt(ctx, cipher->encrypt,
|
||||
cipher->block_size, ctr,
|
||||
length, data, cleartext);
|
||||
|
||||
if (compare_buffer(data, length, ciphertext, length) != 0) {
|
||||
fail("Fail: test_cipher_ctr");
|
||||
}
|
||||
|
||||
free(ctx);
|
||||
free(data);
|
||||
free(ctr);
|
||||
}
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
/* From NIST spec 800-38a on AES modes,
|
||||
*
|
||||
* http://csrc.nist.gov/CryptoToolkit/modes/800-38_Series_Publications/SP800-38A.pdf
|
||||
*
|
||||
* F.5 CTR Example Vectors
|
||||
*/
|
||||
/* F.5.1 CTR-AES128.Encrypt */
|
||||
test_cipher_ctr(&nettle_aes128,
|
||||
HL("2b7e151628aed2a6abf7158809cf4f3c"),
|
||||
HL("6bc1bee22e409f96e93d7e117393172a"
|
||||
"ae2d8a571e03ac9c9eb76fac45af8e51"
|
||||
"30c81c46a35ce411e5fbc1191a0a52ef"
|
||||
"f69f2445df4f9b17ad2b417be66c3710"),
|
||||
H("874d6191b620e3261bef6864990db6ce"
|
||||
"9806f66b7970fdff8617187bb9fffdff"
|
||||
"5ae4df3edbd5d35e5b4f09020db03eab"
|
||||
"1e031dda2fbe03d1792170a0f3009cee"),
|
||||
H("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff"));
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "test_util.h"
|
||||
#include "secu_defs.h"
|
||||
|
||||
static
|
||||
void do_kdf(uint8_t *key, unsigned key_length, uint8_t *data, unsigned data_length,
|
||||
uint8_t *exp, unsigned exp_length)
|
||||
{
|
||||
uint8_t *result;
|
||||
|
||||
kdf(key, key_length, data, data_length, &result, 32);
|
||||
|
||||
if (compare_buffer(result, exp_length, exp, exp_length) != 0) {
|
||||
fail("Fail: kdf\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
doit (void)
|
||||
{
|
||||
/* RFC 4231 */
|
||||
|
||||
/* Test case 1 #4.2 */
|
||||
do_kdf(HL("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
|
||||
"0b0b0b0b"),
|
||||
HL("4869205468657265"),
|
||||
HL("b0344c61d8db38535ca8afceaf0bf12b"
|
||||
"881dc200c9833da726e9376c2e32cff7"));
|
||||
/* Test case 2 #4.3 */
|
||||
do_kdf(HL("4a656665"),
|
||||
HL("7768617420646f2079612077616e7420"
|
||||
"666f72206e6f7468696e673f"),
|
||||
HL("5bdcc146bf60754e6a042426089575c7"
|
||||
"5a003f089d2739839dec58b964ec3843"));
|
||||
/* Test case 3 #4.4 */
|
||||
do_kdf(HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaa"),
|
||||
HL("dddddddddddddddddddddddddddddddd"
|
||||
"dddddddddddddddddddddddddddddddd"
|
||||
"dddddddddddddddddddddddddddddddd"
|
||||
"dddd"),
|
||||
HL("773ea91e36800e46854db8ebd09181a7"
|
||||
"2959098b3ef8c122d9635514ced565fe"));
|
||||
/* Test case 4 #4.5 */
|
||||
do_kdf(HL("0102030405060708090a0b0c0d0e0f10"
|
||||
"111213141516171819"),
|
||||
HL("cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
|
||||
"cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
|
||||
"cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
|
||||
"cdcd"),
|
||||
HL("82558a389a443c0ea4cc819899f2083a"
|
||||
"85f0faa3e578f8077a2e3ff46729665b"));
|
||||
/* Test case 5 #4.6 */
|
||||
do_kdf(HL("0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c"
|
||||
"0c0c0c0c"),
|
||||
HL("546573742057697468205472756e6361"
|
||||
"74696f6e"),
|
||||
HL("a3b6167473100ee06e0c796c2955552b"));
|
||||
/* Test case 6 #4.7 */
|
||||
do_kdf(HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaa"),
|
||||
HL("54657374205573696e67204c61726765"
|
||||
"72205468616e20426c6f636b2d53697a"
|
||||
"65204b6579202d2048617368204b6579"
|
||||
"204669727374"),
|
||||
HL("60e431591ee0b67f0d8a26aacbf5b77f"
|
||||
"8e0bc6213728c5140546040f0ee37f54"));
|
||||
/* Test case 6 #4.7 */
|
||||
do_kdf(HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
"aaaaaa"),
|
||||
HL("54686973206973206120746573742075"
|
||||
"73696e672061206c6172676572207468"
|
||||
"616e20626c6f636b2d73697a65206b65"
|
||||
"7920616e642061206c61726765722074"
|
||||
"68616e20626c6f636b2d73697a652064"
|
||||
"6174612e20546865206b6579206e6565"
|
||||
"647320746f2062652068617368656420"
|
||||
"6265666f7265206265696e6720757365"
|
||||
"642062792074686520484d414320616c"
|
||||
"676f726974686d2e"),
|
||||
HL("9b09ffa71b942fcb27635fbcd5b0e944"
|
||||
"bfdc63644f0713938a7f51535c3a35e2"));
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "s1ap_common.h"
|
||||
#include "s1ap_eNB_decoder.h"
|
||||
#include "s1ap_mme_decoder.h"
|
||||
#include "s1ap_eNB_encoder.h"
|
||||
#include "s1ap_mme_encoder.h"
|
||||
|
||||
#define MAX_BUF_LENGTH (1024)
|
||||
|
||||
typedef enum {
|
||||
MME,
|
||||
ENB
|
||||
} entity_t;
|
||||
|
||||
typedef struct {
|
||||
char *procedure_name;
|
||||
uint8_t buffer[MAX_BUF_LENGTH];
|
||||
uint32_t buf_len;
|
||||
entity_t originating;
|
||||
} s1ap_test_t;
|
||||
|
||||
s1ap_test_t s1ap_test[] = {
|
||||
{
|
||||
.procedure_name = "Downlink NAS transport",
|
||||
.buffer = {
|
||||
0x00, 0x0B, 0x40, 0x21, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x00, 0x03,
|
||||
0x40, 0x01, 0xB3, 0x00, 0x1A, 0x00, 0x0A, 0x09, 0x27, 0xAB,
|
||||
0x1F, 0x7C, 0xEC, 0x01, 0x02, 0x01, 0xD9
|
||||
},
|
||||
.buf_len = 37,
|
||||
.originating = MME,
|
||||
},
|
||||
{
|
||||
.procedure_name = "Uplink NAS transport",
|
||||
.buffer = {
|
||||
0x00, 0x0D, 0x40, 0x41, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||
0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x00, 0x03,
|
||||
0x40, 0x01, 0xB3, 0x00, 0x1A, 0x00, 0x14, 0x13, 0x27, 0xD3,
|
||||
0x77, 0xED, 0x4C, 0x01, 0x02, 0x01, 0xDA, 0x28, 0x08, 0x03,
|
||||
0x69, 0x6D, 0x73, 0x03, 0x70, 0x66, 0x74, 0x00, 0x64, 0x40,
|
||||
0x08, 0x00, 0x02, 0xF8, 0x29, 0x00, 0x00, 0x20, 0x40, 0x00,
|
||||
0x43, 0x40, 0x06, 0x00, 0x02, 0xF8, 0x29, 0x00, 0x04,
|
||||
},
|
||||
.buf_len = 69,
|
||||
.originating = ENB,
|
||||
},
|
||||
{
|
||||
.procedure_name = "UE capability info indication",
|
||||
.buffer = {
|
||||
0x00, 0x16, 0x40, 0x37, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x00, 0x03,
|
||||
0x40, 0x01, 0xB3, 0x00, 0x4A, 0x40, 0x20, 0x1F, 0x00, 0xE8,
|
||||
0x01, 0x01, 0xA8, 0x13, 0x80, 0x00, 0x20, 0x83, 0x13, 0x05,
|
||||
0x0B, 0x8B, 0xFC, 0x2E, 0x2F, 0xF0, 0xB8, 0xBF, 0xAF, 0x87,
|
||||
0xFE, 0x40, 0x44, 0x04, 0x07, 0x0C, 0xA7, 0x4A, 0x80,
|
||||
},
|
||||
.buf_len = 59,
|
||||
.originating = ENB,
|
||||
},
|
||||
{
|
||||
.procedure_name = "Initial Context Setup Request",
|
||||
.buffer = {
|
||||
0x00, 0x09, 0x00, 0x80, 0xD4, 0x00, 0x00, 0x06, 0x00, 0x00,
|
||||
0x00, 0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x00,
|
||||
0x03, 0x40, 0x01, 0xB3, 0x00, 0x42, 0x00, 0x0A, 0x18, 0x08,
|
||||
0xF0, 0xD1, 0x80, 0x60, 0x02, 0xFA, 0xF0, 0x80, 0x00, 0x18,
|
||||
0x00, 0x80, 0x81, 0x00, 0x00, 0x34, 0x00, 0x7C, 0x45, 0x00,
|
||||
0x09, 0x3D, 0x0F, 0x80, 0x0A, 0x05, 0x00, 0x02, 0x03, 0x78,
|
||||
0x48, 0x86, 0x6D, 0x27, 0xC7, 0x97, 0x8E, 0xA1, 0x02, 0x07,
|
||||
0x42, 0x01, 0x49, 0x06, 0x00, 0x02, 0xF8, 0x29, 0x00, 0x04,
|
||||
0x00, 0x48, 0x52, 0x01, 0xC1, 0x01, 0x09, 0x1B, 0x03, 0x69,
|
||||
0x6D, 0x73, 0x03, 0x70, 0x66, 0x74, 0x06, 0x6D, 0x6E, 0x63,
|
||||
0x30, 0x39, 0x32, 0x06, 0x6D, 0x63, 0x63, 0x32, 0x30, 0x38,
|
||||
0x04, 0x67, 0x70, 0x72, 0x73, 0x05, 0x01, 0x0A, 0x80, 0x00,
|
||||
0x24, 0x5D, 0x01, 0x00, 0x30, 0x10, 0x23, 0x93, 0x1F, 0x93,
|
||||
0x96, 0xFE, 0xFE, 0x74, 0x4B, 0xFF, 0xFF, 0x00, 0xC5, 0x00,
|
||||
0x6C, 0x00, 0x32, 0x0B, 0x84, 0x34, 0x01, 0x08, 0x5E, 0x04,
|
||||
0xFE, 0xFE, 0xC5, 0x6C, 0x50, 0x0B, 0xF6, 0x02, 0xF8, 0x29,
|
||||
0x80, 0x00, 0x01, 0xF0, 0x00, 0x70, 0x8A, 0x53, 0x12, 0x64,
|
||||
0x01, 0x01, 0x00, 0x6B, 0x00, 0x05, 0x18, 0x00, 0x0C, 0x00,
|
||||
0x00, 0x00, 0x49, 0x00, 0x20, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
},
|
||||
.buf_len = 217,
|
||||
.originating = MME,
|
||||
},
|
||||
{
|
||||
.procedure_name = "Initial Context Setup Response",
|
||||
.buffer = {
|
||||
0x20, 0x09, 0x00, 0x26, 0x00, 0x00, 0x03, 0x00, 0x00, 0x40,
|
||||
0x05, 0xC0, 0x01, 0x10, 0xCE, 0xCC, 0x00, 0x08, 0x40, 0x03,
|
||||
0x40, 0x01, 0xB3, 0x00, 0x33, 0x40, 0x0F, 0x00, 0x00, 0x32,
|
||||
0x40, 0x0A, 0x0A, 0x1F, 0x0A, 0x05, 0x02, 0x05, 0x00, 0x0F,
|
||||
0x7A, 0x03,
|
||||
},
|
||||
.buf_len = 42,
|
||||
.originating = ENB,
|
||||
}
|
||||
};
|
||||
|
||||
static int compare_buffer(uint8_t *buffer, uint32_t length_buffer,
|
||||
uint8_t *pattern, uint32_t length_pattern)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (length_buffer != length_pattern) {
|
||||
printf("Length mismatch, expecting %d bytes, got %d bytes\n", length_pattern,
|
||||
length_buffer);
|
||||
hexprint(buffer, length_buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < length_buffer; i++) {
|
||||
if (pattern[i] != buffer[i]) {
|
||||
hexprint(buffer, length_buffer);
|
||||
printf("Mismatch fount in byte %d\nExpecting 0x%02x, got 0x%02x\n",
|
||||
i, pattern[i], buffer[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
break_on_error = 1;
|
||||
|
||||
// asn1_xer_print = 1;
|
||||
// asn_debug = 1;
|
||||
|
||||
for (i = 0; i < sizeof(s1ap_test) / sizeof(s1ap_test_t); i++) {
|
||||
struct s1ap_message_s message;
|
||||
uint8_t *buffer;
|
||||
uint32_t length;
|
||||
|
||||
memset(&message, 0, sizeof(struct s1ap_message_s));
|
||||
|
||||
if (s1ap_test[i].originating == ENB) {
|
||||
/* eNB originated procedure -> USE MME decoder */
|
||||
if (s1ap_mme_decode_pdu(&message, s1ap_test[i].buffer,
|
||||
s1ap_test[i].buf_len) < 0) {
|
||||
fail("Failed to decode %s\n", s1ap_test[i].procedure_name);
|
||||
} else {
|
||||
success("Decoded %s correctly\n", s1ap_test[i].procedure_name);
|
||||
}
|
||||
} else {
|
||||
/* MME originated procedure -> USE eNB decoder */
|
||||
if (s1ap_eNB_decode_pdu(&message, s1ap_test[i].buffer,
|
||||
s1ap_test[i].buf_len) < 0) {
|
||||
fail("Failed to decode %s\n", s1ap_test[i].procedure_name);
|
||||
} else {
|
||||
success("Decoded %s correctly\n", s1ap_test[i].procedure_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (s1ap_test[i].originating == ENB) {
|
||||
/* eNB originated procedure -> USE eNB encoder */
|
||||
if (s1ap_eNB_encode_pdu(&message, &buffer, &length) < 0) {
|
||||
fail("Failed to decode %s\n", s1ap_test[i].procedure_name);
|
||||
} else {
|
||||
success("Encoded %s correctly\n", s1ap_test[i].procedure_name);
|
||||
}
|
||||
} else {
|
||||
/* MME originated procedure -> USE mme encoder */
|
||||
if (s1ap_mme_encode_pdu(&message, &buffer, &length) < 0) {
|
||||
fail("Failed to encode %s\n", s1ap_test[i].procedure_name);
|
||||
} else {
|
||||
success("Encoded %s correctly\n", s1ap_test[i].procedure_name);
|
||||
}
|
||||
}
|
||||
|
||||
if (compare_buffer(buffer, length, s1ap_test[i].buffer, s1ap_test[i].buf_len) < 0) {
|
||||
fail("Mismatch in buffers\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t kasme[32];
|
||||
uint8_t kenb_exp[16];
|
||||
uint32_t nas_count;
|
||||
} test_secu_t;
|
||||
|
||||
const test_secu_t kenb_test_vector[] = {
|
||||
{
|
||||
.kasme = {
|
||||
|
||||
},
|
||||
.kenb_exp = {
|
||||
|
||||
},
|
||||
.nas_count = 0x001FB39C;
|
||||
}
|
||||
};
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(kenb_test_vector) / sizeof(test_secu_t); i++) {
|
||||
uint8_t kenb[32];
|
||||
|
||||
derive_keNB(kenb_test_vector[i].kasme, kenb_test_vector[i].nas_count, kenb);
|
||||
|
||||
if (compare_buffer(kenb_test_vector[i].kenb, 32, kenb, 32) == 0) {
|
||||
success("kenb derivation");
|
||||
} else {
|
||||
fail("kenb derivation");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
static
|
||||
void do_derive_kenb(uint32_t nas_count, const uint8_t *kasme, const unsigned length,
|
||||
const uint8_t *kenb_exp)
|
||||
{
|
||||
uint8_t *kenb;
|
||||
|
||||
derive_keNB(kasme, nas_count, &kenb);
|
||||
|
||||
if (compare_buffer(kenb_exp, length, kenb, length) != 0) {
|
||||
fail("Fail: kenb derivation\n");
|
||||
}
|
||||
|
||||
free(kenb);
|
||||
}
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
do_derive_kenb(0xDB1A3569,
|
||||
HL("238E457E0F758BADBCA8D34BB2612C10428D426757CB5553B2B184FA64BFC549"),
|
||||
H("8EB1BF0083BD79281EF7034BF677E9EC529F196E15287514A2D122ACF713B8E8"));
|
||||
do_derive_kenb(0x001FB39C,
|
||||
HL("564CB4D2007E4F293B67D9B29392A64ADD4C776B133D895AF6499AA6882AAB62"),
|
||||
H("009010688F85855E218339DE6C5BD7B6394958DA12DDFBF7559E978CE43408F1"));
|
||||
do_derive_kenb(0x00000012,
|
||||
HL("FA77E41F693C2A6E71455CB8687E6E6058EF91E2F5ABD1BD3C496179481F308C"),
|
||||
H("0AFE81266DE52B8C8F1C3F4FE799BE883F364B018E7368C41F14DD6D050E13E1"));
|
||||
do_derive_kenb(0xFE56A1D3,
|
||||
HL("FA77E41F693C2A6E71455CB8687E6E6058EF91E2F5ABD1BD3C496179481F308C"),
|
||||
H("3622874B06C683586A009DEC81DBE28BDD8E3E6E67A2C22C31630EC97641828E"));
|
||||
do_derive_kenb(0xFE56A1D3,
|
||||
HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"),
|
||||
H("E59BE6F0FBEFA1207DA3FF05D0F82014100E7A63A11EEBFE4F8AA92E7CF8B847"));
|
||||
do_derive_kenb(0xAABBCCDD,
|
||||
HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"),
|
||||
H("158781A2FDF2CE53ABFA186D22EB751DECB8273471DC792B5016C9016947D1AE"));
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
static
|
||||
void derive_knas_keys(algorithm_type_dist_t atd, uint8_t *kasme, unsigned length,
|
||||
uint8_t *knas_enc_exp, uint8_t *knas_int_exp)
|
||||
{
|
||||
uint8_t *knas_enc;
|
||||
uint8_t *knas_int;
|
||||
|
||||
derive_key_nas_enc(atd, kasme, &knas_enc);
|
||||
derive_key_nas_int(atd, kasme, &knas_int);
|
||||
|
||||
/* Compare both keys with expected */
|
||||
if (compare_buffer(knas_enc, 32, knas_enc_exp, 32) != 0) {
|
||||
fail("Fail: knas_enc derivation\n");
|
||||
}
|
||||
|
||||
if (compare_buffer(knas_int, 32, knas_int_exp, 32) != 0) {
|
||||
fail("Fail: knas_int derivation\n");
|
||||
}
|
||||
|
||||
free(knas_enc);
|
||||
free(knas_int);
|
||||
}
|
||||
|
||||
void doit(void)
|
||||
{
|
||||
derive_knas_keys(EIA0_ALG_ID,
|
||||
HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"),
|
||||
H("64BA839B29C451085C552F4DE9D278B263CB5BDD7FC21A38120637B2A9E5CD39"),
|
||||
H("A66A2D198AF2A8D6A5FF2FAA51676037DF204187C61EDD3AAA70F3B7D8B59E8B"));
|
||||
derive_knas_keys(EIA1_128_ALG_ID,
|
||||
HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"),
|
||||
H("DF8FEBA477891617C42FB16F750E572C9E59ED7564879150F6BB0DAEF5932E89"),
|
||||
H("EA1158BA3F387BC96C967BC32FB43F65AE172A3267343479CAA826034A90A250"));
|
||||
derive_knas_keys(EIA2_128_ALG_ID,
|
||||
HL("70D7071AA016A087F9D888AD51F3A83E2C83443AB27843B35BD1B4923615091C"),
|
||||
H("99D63BD2D43AF81EBB7599F7E8F8B3E81CF7897F31D6270C19C4836070FE11F0"),
|
||||
H("FC7A3850D19AE29EC7000B9DF98787F11A4329FD23FD3A93C9D2D92D853EC9DB"));
|
||||
derive_knas_keys(EIA0_ALG_ID,
|
||||
HL("9EA141DA4B24CDEBC8F5FB3F61A0511216681F121199B23EBCFACC75B358BE43"),
|
||||
H("1E48E1B5EDF98DEDF339DE686544AA1088C8E5616EDB706201837AA106D37691"),
|
||||
H("C83DC420F97AA42D1B8488FA5D8F74865D833416D5851556100B41FEC8E38139"));
|
||||
derive_knas_keys(EIA1_128_ALG_ID,
|
||||
HL("9EA141DA4B24CDEBC8F5FB3F61A0511216681F121199B23EBCFACC75B358BE43"),
|
||||
H("207700CD92B4635B439E40176F92F7ADA824B9D699ABE15F86F3346C25343A33"),
|
||||
H("FAA39E382611CDFED52042E72AF8CECDF92CCD799141857B77B6901741E486B2"));
|
||||
derive_knas_keys(EIA2_128_ALG_ID,
|
||||
HL("9EA141DA4B24CDEBC8F5FB3F61A0511216681F121199B23EBCFACC75B358BE43"),
|
||||
H("2A6854D25282FFD738FA8BBCFDCE853C0C4DFB9F559DCBB71D5120DB2CAC66A6"),
|
||||
H("5EDCAE62A35BC42399C55F64ECAE7B17524BED1ED1601218D2772E55DDFAD959"));
|
||||
derive_knas_keys(EIA0_ALG_ID,
|
||||
HL("546A79BC6D1613A72A4D631EE0351D66036B2A0C44A3831BE6D365E24F023013"),
|
||||
H("7F684F909A5910DED6E4B4CE02AC92DF4690EB3788068600E9CB2C3EF8F0956E"),
|
||||
H("51F3B142D357371726873FAC5E853CE0EEEFC52A695DE45FA6F4A23D20C13155"));
|
||||
derive_knas_keys(EIA1_128_ALG_ID,
|
||||
HL("546A79BC6D1613A72A4D631EE0351D66036B2A0C44A3831BE6D365E24F023013"),
|
||||
H("B6B222E9C07C56D15176C8E95EC1805561492682E4B9CD7228237A6C78702347"),
|
||||
H("4DC5ABF6896DA460473288D16DE83C480388C6FD9E803C7EA88090F311354A15"));
|
||||
derive_knas_keys(EIA2_128_ALG_ID,
|
||||
HL("546A79BC6D1613A72A4D631EE0351D66036B2A0C44A3831BE6D365E24F023013"),
|
||||
H("7BD2A0864452D3D9EDE3B2E38A9958777F231AC4F4B9AF3FC8CE0E1EAAB425A7"),
|
||||
H("89E8049EBE9374F238B0F3278EEA47D9BF8877111D99D6378FFF66FEBB06F3F8"));
|
||||
}
|
||||
Executable
+114
@@ -0,0 +1,114 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
static
|
||||
void eea1_encrypt(uint8_t direction, uint32_t count,
|
||||
uint8_t bearer, uint8_t *key, uint32_t key_length, uint8_t *message,
|
||||
uint32_t length, uint8_t *expected)
|
||||
{
|
||||
nas_stream_cipher_t *nas_cipher;
|
||||
uint8_t *result;
|
||||
uint32_t zero_bits = length & 7;
|
||||
uint32_t byte_length = length >> 3;
|
||||
|
||||
if (zero_bits > 0)
|
||||
byte_length += 1;
|
||||
|
||||
nas_cipher = calloc(1, sizeof(nas_stream_cipher_t));
|
||||
|
||||
nas_cipher->direction = direction;
|
||||
nas_cipher->count = count;
|
||||
nas_cipher->key = key;
|
||||
nas_cipher->key_length = key_length;
|
||||
nas_cipher->bearer = bearer;
|
||||
nas_cipher->blength = length;
|
||||
nas_cipher->message = message;
|
||||
|
||||
if (nas_stream_encrypt_eea1(nas_cipher, &result) != 0)
|
||||
fail("Fail: nas_stream_encrypt_eea1\n");
|
||||
|
||||
if (compare_buffer(result, byte_length, expected, byte_length) != 0) {
|
||||
fail("Fail: eea1_encrypt\n");
|
||||
} else {
|
||||
success("Success: eea1_encrypt\n");
|
||||
}
|
||||
|
||||
free(nas_cipher);
|
||||
free(result);
|
||||
}
|
||||
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
/* Test suite from Specification of the 3GPP Confidentiality and Integrity Algorithms UEA2 & UIA2,
|
||||
* Document 3: Implementors’ Test Data */
|
||||
|
||||
/* Test set 1 #4.3 */
|
||||
eea1_encrypt(
|
||||
1, 0x72A4F20F, 0x0C, HL("2BD6459F82C5B300952C49104881FF48"),
|
||||
H("7EC61272743BF1614726446A6C38CED166F6CA76EB5430044286346CEF130F92922B03450D3A9975E5BD2EA0EB55AD8E1B199E3EC4316020E9A1B285E762795359B7BDFD39BEF4B2484583D5AFE082AEE638BF5FD5A606193901A08F4AB41AAB9B134880"),
|
||||
798,
|
||||
H("8CEBA62943DCED3A0990B06EA1B0A2C4FB3CEDC71B369F42BA64C1EB6665E72AA1C9BB0DEAA20FE86058B8BAEE2C2E7F0BECCE48B52932A53C9D5F931A3A7C532259AF4325E2A65E3084AD5F6A513B7BDDC1B65F0AA0D97A053DB55A88C4C4F9605E4140")
|
||||
);
|
||||
/* Test set 2 #4.4 */
|
||||
eea1_encrypt(
|
||||
0, 0xE28BCF7B, 0x18, HL("EFA8B2229E720C2A7C36EA55E9605695"),
|
||||
H("10111231E060253A43FD3F57E37607AB2827B599B6B1BBDA37A8ABCC5A8C550D1BFB2F494624FB50367FA36CE3BC68F11CF93B1510376B02130F812A9FA169D8"),
|
||||
510,
|
||||
H("E0DA15CA8E2554F5E56C9468DC6C7C129C568AA5032317E04E0729646CABEFA689864C410F24F919E61E3DFDFAD77E560DB0A9CD36C34AE4181490B29F5FA2FC"));
|
||||
/* Test set 3 #4.5 */
|
||||
eea1_encrypt(
|
||||
1, 0xFA556B26, 0x03, HL("5ACB1D644C0D51204EA5F1451010D852"),
|
||||
H("AD9C441F890B38C457A49D421407E8"),
|
||||
120,
|
||||
H("BA0F31300334C56B52A7497CBAC046")
|
||||
);
|
||||
/* Test set 4 #4.6 */
|
||||
eea1_encrypt(
|
||||
1, 0x398A59B4, 0x05, HL("D3C5D592327FB11C4035C6680AF8C6D1"),
|
||||
H("981BA6824C1BFB1AB485472029B71D808CE33E2CC3C0B5FC1F3DE8A6DC66B1F0"),
|
||||
253,
|
||||
H("989B719CDC33CEB7CF276A52827CEF94A56C40C0AB9D81F7A2A9BAC60E11C4B0")
|
||||
);
|
||||
/* Test set 5 #4.7 */
|
||||
eea1_encrypt(
|
||||
0, 0x72A4F20F, 0x09, HL("6090EAE04C83706EECBF652BE8E36566"),
|
||||
H("40981BA6824C1BFB4286B299783DAF442C099F7AB0F58D5C8E46B104F08F01B41AB485472029B71D36BD1A3D90DC3A41B46D51672AC4C9663A2BE063DA4BC8D2808CE33E2CCCBFC634E1B259060876A0FBB5A437EBCC8D31C19E4454318745E3987645987A986F2CB0"),
|
||||
837,
|
||||
H("5892BBA88BBBCAAEAE769AA06B683D3A17CC04A369881697435E44FED5FF9AF57B9E890D4D5C64709885D48AE40690EC043BAAE9705796E4A9FF5A4B8D8B36D7F3FE57CC6CFD6CD005CD3852A85E94CE6BCD90D0D07839CE09733544CA8E350843248550922AC12818")
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
static
|
||||
void eea2_encrypt(uint8_t direction, uint32_t count,
|
||||
uint8_t bearer, uint8_t *key, uint32_t key_length, uint8_t *message,
|
||||
uint32_t length, uint8_t *expected)
|
||||
{
|
||||
nas_stream_cipher_t *nas_cipher;
|
||||
uint8_t *result;
|
||||
uint32_t zero_bits = length & 7;
|
||||
uint32_t byte_length = length >> 3;
|
||||
|
||||
if (zero_bits > 0)
|
||||
byte_length += 1;
|
||||
|
||||
nas_cipher = calloc(1, sizeof(nas_stream_cipher_t));
|
||||
|
||||
nas_cipher->direction = direction;
|
||||
nas_cipher->count = count;
|
||||
nas_cipher->key = key;
|
||||
nas_cipher->key_length = key_length;
|
||||
nas_cipher->bearer = bearer;
|
||||
nas_cipher->blength = length;
|
||||
nas_cipher->message = message;
|
||||
|
||||
if (nas_stream_encrypt_eea2(nas_cipher, &result) != 0)
|
||||
fail("Fail: nas_stream_encrypt_eea2\n");
|
||||
|
||||
if (compare_buffer(result, byte_length, expected, byte_length) != 0) {
|
||||
fail("Fail: eea2_encrypt\n");
|
||||
}
|
||||
|
||||
free(nas_cipher);
|
||||
free(result);
|
||||
}
|
||||
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
/* Test suite from 3GPP TS33.401 #Appendix C.1 */
|
||||
|
||||
/* Test set 1 #C.1.1 */
|
||||
eea2_encrypt(
|
||||
1, 0x398a59b4, 0x15, HL("d3c5d592327fb11c4035c6680af8c6d1"),
|
||||
H("981ba6824c1bfb1ab485472029b71d808ce33e2cc3c0b5fc1f3de8a6dc66b1f0"),
|
||||
253,
|
||||
H("e9fed8a63d155304d71df20bf3e82214b20ed7dad2f233dc3c22d7bdeeed8e78")
|
||||
);
|
||||
/* Test set 2 #C.1.2 */
|
||||
eea2_encrypt(
|
||||
1, 0xc675a64b, 0x0c, HL("2bd6459f82c440e0952c49104805ff48"),
|
||||
H("7ec61272743bf1614726446a6c38ced166f6ca76eb5430044286346cef130f92"
|
||||
"922b03450d3a9975e5bd2ea0eb55ad8e1b199e3ec4316020e9a1b285e7627953"
|
||||
"59b7bdfd39bef4b2484583d5afe082aee638bf5fd5a606193901a08f4ab41aab"
|
||||
"9b134880"),
|
||||
798,
|
||||
H("5961605353c64bdca15b195e288553a910632506d6200aa790c4c806c99904cf"
|
||||
"2445cc50bb1cf168a49673734e081b57e324ce5259c0e78d4cd97b870976503c"
|
||||
"0943f2cb5ae8f052c7b7d392239587b8956086bcab18836042e2e6ce42432a17"
|
||||
"105c53d0")
|
||||
);
|
||||
/* Test set 3 #C.1.3 */
|
||||
eea2_encrypt(
|
||||
0, 0x544d49cd, 0x04, HL("0a8b6bd8d9b08b08d64e32d1817777fb"),
|
||||
H("fd40a41d370a1f65745095687d47ba1d36d2349e23f644392c8ea9c49d40c132"
|
||||
"71aff264d0f24800"),
|
||||
310,
|
||||
H("75750d37b4bba2a4dedb34235bd68c6645acdaaca48138a3b0c471e2a7041a57"
|
||||
"6423d2927287f000")
|
||||
);
|
||||
/* Test set 4 #C.1.4 */
|
||||
eea2_encrypt(
|
||||
1, 0x72d8c671, 0x10, HL("aa1f95aea533bcb32eb63bf52d8f831a"),
|
||||
H("fb1b96c5c8badfb2e8e8edfde78e57f2ad81e74103fc430a534dcc37afcec70e"
|
||||
"1517bb06f27219dae49022ddc47a068de4c9496a951a6b09edbdc864c7adbd74"
|
||||
"0ac50c022f3082bafd22d78197c5d508b977bca13f32e652e74ba728576077ce"
|
||||
"628c535e87dc6077ba07d29068590c8cb5f1088e082cfa0ec961302d69cf3d44"),
|
||||
1022,
|
||||
H("dfb440acb3773549efc04628aeb8d8156275230bdc690d94b00d8d95f28c4b56"
|
||||
"307f60f4ca55eba661ebba72ac808fa8c49e26788ed04a5d606cb418de74878b"
|
||||
"9a22f8ef29590bc4eb57c9faf7c41524a885b8979c423f2f8f8e0592a9879201"
|
||||
"be7ff9777a162ab810feb324ba74c4c156e04d39097209653ac33e5a5f2d8864")
|
||||
);
|
||||
/* Test set 5 #C.1.5 */
|
||||
eea2_encrypt(
|
||||
1, 0xc675a64b, 0x0c, HL("9618ae46891f86578eebe90ef7a1202e"),
|
||||
H("8daa17b1ae050529c6827f28c0ef6a1242e93f8b314fb18a77f790ae049fedd6"
|
||||
"12267fecaefc450174d76d9f9aa7755a30cd90a9a5874bf48eaf70eea3a62a25"
|
||||
"0a8b6bd8d9b08b08d64e32d1817777fb544d49cd49720e219dbf8bbed33904e1"
|
||||
"fd40a41d370a1f65745095687d47ba1d36d2349e23f644392c8ea9c49d40c132"
|
||||
"71aff264d0f24841d6465f0996ff84e65fc517c53efc3363c38492a8"),
|
||||
1245,
|
||||
H("919c8c33d66789703d05a0d7ce82a2aeac4ee76c0f4da050335e8a84e7897ba5"
|
||||
"df2f36bd513e3d0c8578c7a0fcf043e03aa3a39fbaad7d15be074faa5d9029f7"
|
||||
"1fb457b647834714b0e18f117fca10677945096c8c5f326ba8d6095eb29c3e36"
|
||||
"cf245d1622aafe921f7566c4f5d644f2f1fc0ec684ddb21349747622e209295d"
|
||||
"27ff3f95623371d49b147c0af486171f22cd04b1cbeb2658223e6938")
|
||||
);
|
||||
/* Test set 6 #C.1.6 */
|
||||
eea2_encrypt(
|
||||
0, 0xaca4f50f, 0x0b, HL("54f4e2e04c83786eec8fb5abe8e36566"),
|
||||
H("40981ba6824c1bfb4286b299783daf442c099f7ab0f58d5c8e46b104f08f01b4"
|
||||
"1ab485472029b71d36bd1a3d90dc3a41b46d51672ac4c9663a2be063da4bc8d2"
|
||||
"808ce33e2cccbfc634e1b259060876a0fbb5a437ebcc8d31c19e4454318745e3"
|
||||
"fa16bb11adae248879fe52db2543e53cf445d3d828ce0bf5c560593d97278a59"
|
||||
"762dd0c2c9cd68d4496a792508614014b13b6aa51128c18cd6a90b87978c2ff1"
|
||||
"cabe7d9f898a411bfdb84f68f6727b1499cdd30df0443ab4a66653330bcba110"
|
||||
"5e4cec034c73e605b4310eaaadcfd5b0ca27ffd89d144df4792759427c9cc1f8"
|
||||
"cd8c87202364b8a687954cb05a8d4e2d99e73db160deb180ad0841e96741a5d5"
|
||||
"9fe4189f15420026fe4cd12104932fb38f735340438aaf7eca6fd5cfd3a195ce"
|
||||
"5abe65272af607ada1be65a6b4c9c0693234092c4d018f1756c6db9dc8a6d80b"
|
||||
"888138616b681262f954d0e7711748780d92291d86299972db741cfa4f37b8b5"
|
||||
"6cdb18a7ca8218e86e4b4b716a4d04371fbec262fc5ad0b3819b187b97e55b1a"
|
||||
"4d7c19ee24c8b4d7723cfedf045b8acae4869517d80e50615d9035d5d9c5a40a"
|
||||
"f602280b542597b0cb18619eeb35925759d195e100e8e4aa0c38a3c2abe0f3d8"
|
||||
"ff04f3c33c295069c23694b5bbeacdd542e28e8a94edb9119f412d054be1fa72"
|
||||
"00b09000"),
|
||||
3861,
|
||||
H("5cb72c6edc878f1566e10253afc364c9fa540d914db94cbee275d0917ca6af0d"
|
||||
"77acb4ef3bbe1a722b2ef5bd1d4b8e2aa5024ec1388a201e7bce7920aec61589"
|
||||
"5f763a5564dcc4c482a2ee1d8bfecc4498eca83fbb75f9ab530e0dafbede2fa5"
|
||||
"895b82991b6277c529e0f2529d7f79606be96706296dedfa9d7412b616958cb5"
|
||||
"63c678c02825c30d0aee77c4c146d2765412421a808d13cec819694c75ad572e"
|
||||
"9b973d948b81a9337c3b2a17192e22c2069f7ed1162af44cdea817603665e807"
|
||||
"ce40c8e0dd9d6394dc6e31153fe1955c47afb51f2617ee0c5e3b8ef1ad7574ed"
|
||||
"343edc2743cc94c990e1f1fd264253c178dea739c0befeebcd9f9b76d49c1015"
|
||||
"c9fecf50e53b8b5204dbcd3eed863855dabcdcc94b31e318021568855c8b9e52"
|
||||
"a981957a112827f978ba960f1447911b317b5511fbcc7fb13ac153db74251117"
|
||||
"e4861eb9e83bffffc4eb7755579038e57924b1f78b3e1ad90bab2a07871b72db"
|
||||
"5eef96c334044966db0c37cafd1a89e5646a3580eb6465f121dce9cb88d85b96"
|
||||
"cf23ccccd4280767bee8eeb23d8652461db6493103003baf89f5e18261ea43c8"
|
||||
"4a92ebffffe4909dc46c5192f825f770600b9602c557b5f8b431a79d45977dd9"
|
||||
"c41b863da9e142e90020cfd074d6927b7ab3b6725d1a6f3f98b9c9daa8982aff"
|
||||
"06782800")
|
||||
);
|
||||
}
|
||||
Executable
+126
@@ -0,0 +1,126 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "conversions.h"
|
||||
#include "secu_defs.h"
|
||||
|
||||
static
|
||||
void eia1_encrypt(char* test_nameP, uint8_t direction, uint32_t count,
|
||||
uint8_t bearer, uint8_t *key, uint32_t key_length, uint8_t *message,
|
||||
uint32_t length, uint8_t *expected, uint32_t length_expected)
|
||||
{
|
||||
nas_stream_cipher_t nas_cipher;
|
||||
uint8_t result[4];
|
||||
|
||||
nas_cipher.direction = direction;
|
||||
nas_cipher.count = count;
|
||||
nas_cipher.key = key;
|
||||
nas_cipher.key_length = key_length;
|
||||
nas_cipher.bearer = bearer;
|
||||
nas_cipher.blength = length;
|
||||
nas_cipher.message = message;
|
||||
|
||||
if (nas_stream_encrypt_eia1(&nas_cipher, result) != 0) {
|
||||
fail("%s Fail: nas_stream_encrypt_eia1\n", test_nameP);
|
||||
}
|
||||
|
||||
if (compare_buffer(result, 4, expected, length_expected) != 0) {
|
||||
fail("%s Fail: eia1_encrypt\n",test_nameP);
|
||||
} else {
|
||||
success("%s Success: eia1_encrypt\n",test_nameP);
|
||||
}
|
||||
}
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
/* Test suite from Specification 3GPP TS 33.401 V12.10.0 #C.4 128-EIA1 */
|
||||
|
||||
/* Test set 1 #C.4.1 */
|
||||
eia1_encrypt(
|
||||
"Test set 1 #C.4.1",
|
||||
0, 0x38a6f056, 0x1f, HL("2bd6459f82c5b300952c49104881ff48"),
|
||||
H("33323462633938613734790000000000"),
|
||||
88,
|
||||
HL("731f1165")
|
||||
);
|
||||
/* Test set 2 #C.4.2 */
|
||||
eia1_encrypt(
|
||||
"Test set 2 #C.4.2",
|
||||
1, 0x36af6144, 0x18, HL("7e5e94431e11d73828d739cc6ced4573"),
|
||||
H("b3d3c9170a4e1632f60f861013d22d84b726b6a278d802d1eeaf1321ba5929dc "),
|
||||
254,
|
||||
HL("e3259f6f")
|
||||
);
|
||||
/* Test set 3 #C.4.3 */
|
||||
eia1_encrypt(
|
||||
"Test set 3 #C.4.3",
|
||||
0, 0xc7590ea9, 0x17, HL("d3419be821087acd02123a9248033359"),
|
||||
H("bbb057038809496bcff86d6fbc8ce5b135a06b166054f2d565be8ace75dc851e0bcdd8f07141c495872fb5d8c0c66a8b6da556663e4e461205d84580bee5bc7e"),
|
||||
511,
|
||||
HL("9a16c77d")
|
||||
);
|
||||
/* Test set 4 #C.4.4 */
|
||||
eia1_encrypt(
|
||||
"Test set 4 #C.4.4",
|
||||
1, 0x36af6144, 0x0f, HL("83fd23a244a74cf358da3019f1722635"),
|
||||
H("35c68716633c66fb750c266865d53c11ea05b1e9fa49c8398d48e1efa5909d3947902837f5ae96d5a05bc8d61ca8dbef1b13a4b4abfe4fb1006045b674bb5472 9304c382be53a5af05556176f6eaa2ef1d05e4b083181ee674cda5a485f74d7a"),
|
||||
768,
|
||||
HL("bba74492")
|
||||
);
|
||||
/* Test set 5 #C.4.5 */
|
||||
eia1_encrypt(
|
||||
"Test set 5 #C.4.5",
|
||||
0, 0x36af6144, 0x18, HL("6832a65cff4473621ebdd4ba26a921fe"),
|
||||
H("d3c53839626820717765667620323837636240981ba6824c1bfb1ab485472029b71d808ce33e2cc3c0b5fc1f3de8a6dc"),
|
||||
383,
|
||||
HL("4145e4b0")
|
||||
);
|
||||
/* Test set 6 #C.4.6 */
|
||||
eia1_encrypt(
|
||||
"Test set 6 #C.4.6",
|
||||
1, 0x7827fab2, 0x05, HL("5d0a80d8134ae19677824b671e838af4 "),
|
||||
H("70dedf2dc42c5cbd3a96f8a0b11418b3608d5733604a2cd36aabc70ce3193bb5153be2d3c06dfdb2d16e9c357158be6a41d6b861e491db3fbfeb518efcf048d7d58953730ff30c9ec470ffcd663dc34201c36addc0111c35b38afee7cfdb582e3731f8b4baa8d1a89c06e81199a9716227be344efcb436ddd0f096c064c3b5e2c399993fc77394f9e09720a811850ef23b2ee05d9e6173609d86e1c0c18ea51a012a00bb413b9cb8188a703cd6bae31cc67b34b1b00019e6a2b2a690f02671fe7c9ef8dec0094e533763478d58d2c5f5b827a0148c5948a96931acf84f465a64e62ce74007e991e37ea823fa0fb21923b79905b733b631e6c7d6860a3831ac351a9c730c52ff72d9d308eedbab21fde143a0ea17e23edc1f74cbb3638a2033aaa15464eaa733385dbbeb6fd73509b857e6a419dca1d8907af977fbac4dfa35ec"),
|
||||
2558,
|
||||
HL("0fa2b1ee")
|
||||
);
|
||||
/* Test set 7 #C.4.7 */
|
||||
eia1_encrypt(
|
||||
"Test set 7 #C.4.7",
|
||||
1, 0x296f393c, 0x0b, HL("b3120ffdb2cf6af4e73eaf2ef4ebec69"),
|
||||
H("00000000000000000101010101010101e0958045f3a0bba4e3968346f0a3b8a7c02a018ae640765226b987c913e6cbf083570016cf83efbc61c082513e21561a427c009d28c298eface78ed6d56c2d4505ad032e9c04dc60e73a81696da665c6c48603a57b45ab33221585e68ee3169187fb0239528632dd656c807ea3248b7b46d002b2b5c7458eb85b9ce95879e0340859055e3b0abbc3eace8719caa80265c97205d5dc4bcc902fe1839629ed71328a0f0449f588557e6898860e042aecd84b2404c212c9222da5bf8a89ef6797870cf50771a60f66a2ee62853657addf04cdde07fa414e11f12b4d81b9b4e8ac538ea30666688d881f6c348421992f31b94f8806ed8fccff4c9123b89642527ad613b109bf75167485f1268bf884b4cd23d29a0934925703d634098f7767f1be7491e708a8bb949a3873708aef4a36239e50cc08235cd5ed6bbe578668a17b58c1171d0b90e813a9e4f58a89d719b11042d6360b1b0f52deb730a58d58faf46315954b0a872691475977dc88c0d733feff54600a0cc1d0300aaaeb94572c6e95b01ae90de04f1dce47f87e8fa7bebf77e1dbc20d6ba85cb9143d518b285dfa04b698bf0cf7819f20fa7a288eb0703d995c59940c7c66de57a9b70f82379b70e2031e450fcfd2181326fcd28d8823baaa80df6e0f443559647539fd8907c0ffd9d79c130ed81c9afd9b7e848c9fed38443d5d380e53fbdb8ac8c3d3f06876054f122461107de92fea09c6f6923a188d53afe54a10f60e6e9d5a03d996b5fbc820f8a637116a27ad04b444a0932dd60fbd12671c11e1c0ec73e789879faa3d42c64d20cd1252742a3768c25a901585888ecee1e612d9936b403b0775949a66cdfd99a29b1345baa8d9d5400c91024b0a607363b013ce5de9ae869d3b8d95b0570b3c2d391422d32450cbcfae96652286e96dec1214a9346527980a8192eac1c39a3aaf6f15351da6be764df89772ec0407d06e4415befae7c92580df9bf507497c8f2995160d4e218daacb02944abf83340ce8be1686a960faf90e2d90c55cc6475babc3171a80a363174954955d7101dab16ae8179167e21444b443a9eaaa7c91de36d118c39d389f8dd4469a846c9a262bf7fa18487a79e8de11699e0b8fdf557cb48719d453ba713056109b93a218c89675ac195fb4fb06639b3797144955b3c9327d1aec003d42ecd0ea98abf19ffb4af3561a67e77c35bf15c59c2412da881db02b1bfbcebfac5152bc99bc3f1d15f771001b7029fedb028f8b852bc4407eb83f891c9ca733254fdd1e9edb56919ce9fea21c174072521c18319a54b5d4efbebddf1d8b69b1cbf25f489fcc981372547cf41d008ef0bca1926f934b735e090b3b251eb33a36f82ed9b29cf4cb944188fa0e1e38dd778f7d1c9d987b28d132dfb9731fa4f4b416935be49de30516af3578581f2f13f561c0663361941eab249a4bc123f8d15cd711a956a1bf20fe6eb78aea2373361da0426c79a530c3bb1de0c99722ef1fde39ac2b00a0a8ee7c800a08bc2264f89f4effe627ac2f0531fb554f6d21d74c590a70adfaa390bdfbb3d68e46215cab187d2368d5a71f5ebec081cd3b20c082dbe4cd2faca28773795d6b0c10204b659a939ef29bbe1088243624429927a7eb576dd3a00ea5e01af5d47583b2272c0c161a806521a16ff9b0a722c0cf26b025d5836e2258a4f7d4773ac801e4263bc294f43def7fa8703f3a4197463525887652b0b2a4a2a7cf87f00914871e25039113c7e1618da34064b57a43c463249fb8d05e0f26f4a6d84972e7a9054824145f91295cdbe39a6f920facc659712b46a54ba295bbe6a90154e91b33985a2bcd420ad5c67ec9ad8eb7ac6864db272a516bc94c2839b0a8169a6bf58e1a0c2ada8c883b7bf497a49171268ed15ddd2969384e7ff4bf4aab2ec9ecc6529cf629e2df0f08a77a65afa12aa9b505df8b287ef6cc91493d1caa39076e28ef1ea028f5118de61ae02bb6aefc3343a050292f199f401857b2bead5e6ee2a1f191022f9278016f047791a9d18da7d2a6d27f2e0e51c2f6ea30e8ac49a0604f4c13542e85b68381b9fdcfa0ce4b2d341354852d360245c536b612af71f3e77c9095ae2dbde504b265733dabfe10a20fc7d6d32c21ccc72b8b3444ae663d65922d17f82caa2b865cd88913d291a65899026ea1328439723c198c36b0c3c8d085bfaf8a320fde334b4a4919b44c2b95f6e8ecf73393f7f0d2a40e60b1d406526b022ddc331810b1a5f7c347bd53ed1f105d6a0d30aba477e178889ab2ec55d558deab2630204336962b4db5b663b6902b89e85b31bc6af50fc50accb3fb9b57b663297031378db47896d7fbaf6c600add2c67f936db037986db856eb49cf2db3f7da6d23650e438f1884041b013119e4c2ae5af37cccdfb68660738b58b3c59d1c0248437472aba1f35ca1fb90cd714aa9f635534f49e7c5bba81c2b6b36fdee21ca27e347f793d2ce944edb23c8c9b914be10335e350feb5070394b7a4a15c0ca120283568b7bfc254fe838b137a2147ce7c113a3a4d65499d9e86b87dbcc7f03bbd3a3ab1aa243ece5ba9bcf25f82836cfe473b2d83e7a7201cd0b96a72451e863f6c3ba664a6d073d1f7b5ed990865d978bd3815d06094fc9a2aba5221c22d5ab996389e3721e3af5f05beddc2875e0dfaeb39021ee27a41187cbb45ef40c3e73bc03989f9a30d12c54ba7d2141da8a875493e65776ef35f97debc2286cc4af9b4623eee902f840c52f1b8ad658939aef71f3f72b9ec1de21588bd35484ea44436343ff95ead6ab1d8afb1b2a303df1b71e53c4aea6b2e3e9372be0d1bc99798b0ce3cc10d2a596d565dba82f88ce4cff3b33d5d24e9c0831124bf1ad54b792532983dd6c3a8b7d0"),
|
||||
16448,
|
||||
HL("abf3e651")
|
||||
);
|
||||
}
|
||||
@@ -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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
static
|
||||
void eia2_encrypt(uint8_t direction, uint32_t count,
|
||||
uint8_t bearer, uint8_t *key, uint32_t key_length, uint8_t *message,
|
||||
uint32_t length, uint8_t *expected, uint32_t length_expected)
|
||||
{
|
||||
nas_stream_cipher_t nas_cipher;
|
||||
uint8_t result[4];
|
||||
|
||||
nas_cipher.direction = direction;
|
||||
nas_cipher.count = count;
|
||||
nas_cipher.key = key;
|
||||
nas_cipher.key_length = key_length;
|
||||
nas_cipher.bearer = bearer;
|
||||
nas_cipher.blength = length;
|
||||
nas_cipher.message = message;
|
||||
|
||||
if (nas_stream_encrypt_eia2(&nas_cipher, result) != 0) {
|
||||
fail("Fail: nas_stream_encrypt_eia2\n");
|
||||
}
|
||||
|
||||
if (compare_buffer(result, 4, expected, length_expected) != 0) {
|
||||
fail("Fail: eia2_encrypt\n");
|
||||
}
|
||||
}
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
/* Test suite from 3GPP TS33.401 #Appendix C.2
|
||||
* For EPS implementation verification, byte alignment test data sets
|
||||
* (2, 5 and 8) can be used, as EPS RRC and EPS NAS messages are byte aligned.
|
||||
* The non byte aligned test data sets may be used to verify implementations
|
||||
* that support non byte aligned messages.
|
||||
*/
|
||||
|
||||
/* Test set 2 #C.2.2 */
|
||||
eia2_encrypt(
|
||||
1, 0x398a59b4, 0x1a, HL("d3c5d592327fb11c4035c6680af8c6d1"),
|
||||
H("484583d5afe082ae"),
|
||||
64,
|
||||
HL("b93787e6")
|
||||
);
|
||||
/* Test set 5 #C.2.5 */
|
||||
eia2_encrypt(
|
||||
1, 0x36af6144, 0x0f, HL("83fd23a244a74cf358da3019f1722635"),
|
||||
H("35c68716633c66fb750c266865d53c11ea05b1e9fa49c8398d48e1efa5909d39"
|
||||
"47902837f5ae96d5a05bc8d61ca8dbef1b13a4b4abfe4fb1006045b674bb5472"
|
||||
"9304c382be53a5af05556176f6eaa2ef1d05e4b083181ee674cda5a485f74d7a"),
|
||||
768,
|
||||
HL("e657e182")
|
||||
);
|
||||
/* Test set 8 #C.2.8 */
|
||||
eia2_encrypt(
|
||||
1, 0x296f393c, 0x0b, HL("b3120ffdb2cf6af4e73eaf2ef4ebec69"),
|
||||
H("00000000000000000101010101010101e0958045f3a0bba4e3968346f0a3b8a7"
|
||||
"c02a018ae640765226b987c913e6cbf083570016cf83efbc61c082513e21561a"
|
||||
"427c009d28c298eface78ed6d56c2d4505ad032e9c04dc60e73a81696da665c6"
|
||||
"c48603a57b45ab33221585e68ee3169187fb0239528632dd656c807ea3248b7b"
|
||||
"46d002b2b5c7458eb85b9ce95879e0340859055e3b0abbc3eace8719caa80265"
|
||||
"c97205d5dc4bcc902fe1839629ed71328a0f0449f588557e6898860e042aecd8"
|
||||
"4b2404c212c9222da5bf8a89ef6797870cf50771a60f66a2ee62853657addf04"
|
||||
"cdde07fa414e11f12b4d81b9b4e8ac538ea30666688d881f6c348421992f31b9"
|
||||
"4f8806ed8fccff4c9123b89642527ad613b109bf75167485f1268bf884b4cd23"
|
||||
"d29a0934925703d634098f7767f1be7491e708a8bb949a3873708aef4a36239e"
|
||||
"50cc08235cd5ed6bbe578668a17b58c1171d0b90e813a9e4f58a89d719b11042"
|
||||
"d6360b1b0f52deb730a58d58faf46315954b0a872691475977dc88c0d733feff"
|
||||
"54600a0cc1d0300aaaeb94572c6e95b01ae90de04f1dce47f87e8fa7bebf77e1"
|
||||
"dbc20d6ba85cb9143d518b285dfa04b698bf0cf7819f20fa7a288eb0703d995c"
|
||||
"59940c7c66de57a9b70f82379b70e2031e450fcfd2181326fcd28d8823baaa80"
|
||||
"df6e0f443559647539fd8907c0ffd9d79c130ed81c9afd9b7e848c9fed38443d"
|
||||
"5d380e53fbdb8ac8c3d3f06876054f122461107de92fea09c6f6923a188d53af"
|
||||
"e54a10f60e6e9d5a03d996b5fbc820f8a637116a27ad04b444a0932dd60fbd12"
|
||||
"671c11e1c0ec73e789879faa3d42c64d20cd1252742a3768c25a901585888ece"
|
||||
"e1e612d9936b403b0775949a66cdfd99a29b1345baa8d9d5400c91024b0a6073"
|
||||
"63b013ce5de9ae869d3b8d95b0570b3c2d391422d32450cbcfae96652286e96d"
|
||||
"ec1214a9346527980a8192eac1c39a3aaf6f15351da6be764df89772ec0407d0"
|
||||
"6e4415befae7c92580df9bf507497c8f2995160d4e218daacb02944abf83340c"
|
||||
"e8be1686a960faf90e2d90c55cc6475babc3171a80a363174954955d7101dab1"
|
||||
"6ae8179167e21444b443a9eaaa7c91de36d118c39d389f8dd4469a846c9a262b"
|
||||
"f7fa18487a79e8de11699e0b8fdf557cb48719d453ba713056109b93a218c896"
|
||||
"75ac195fb4fb06639b3797144955b3c9327d1aec003d42ecd0ea98abf19ffb4a"
|
||||
"f3561a67e77c35bf15c59c2412da881db02b1bfbcebfac5152bc99bc3f1d15f7"
|
||||
"71001b7029fedb028f8b852bc4407eb83f891c9ca733254fdd1e9edb56919ce9"
|
||||
"fea21c174072521c18319a54b5d4efbebddf1d8b69b1cbf25f489fcc98137254"
|
||||
"7cf41d008ef0bca1926f934b735e090b3b251eb33a36f82ed9b29cf4cb944188"
|
||||
"fa0e1e38dd778f7d1c9d987b28d132dfb9731fa4f4b416935be49de30516af35"
|
||||
"78581f2f13f561c0663361941eab249a4bc123f8d15cd711a956a1bf20fe6eb7"
|
||||
"8aea2373361da0426c79a530c3bb1de0c99722ef1fde39ac2b00a0a8ee7c800a"
|
||||
"08bc2264f89f4effe627ac2f0531fb554f6d21d74c590a70adfaa390bdfbb3d6"
|
||||
"8e46215cab187d2368d5a71f5ebec081cd3b20c082dbe4cd2faca28773795d6b"
|
||||
"0c10204b659a939ef29bbe1088243624429927a7eb576dd3a00ea5e01af5d475"
|
||||
"83b2272c0c161a806521a16ff9b0a722c0cf26b025d5836e2258a4f7d4773ac8"
|
||||
"01e4263bc294f43def7fa8703f3a4197463525887652b0b2a4a2a7cf87f00914"
|
||||
"871e25039113c7e1618da34064b57a43c463249fb8d05e0f26f4a6d84972e7a9"
|
||||
"054824145f91295cdbe39a6f920facc659712b46a54ba295bbe6a90154e91b33"
|
||||
"985a2bcd420ad5c67ec9ad8eb7ac6864db272a516bc94c2839b0a8169a6bf58e"
|
||||
"1a0c2ada8c883b7bf497a49171268ed15ddd2969384e7ff4bf4aab2ec9ecc652"
|
||||
"9cf629e2df0f08a77a65afa12aa9b505df8b287ef6cc91493d1caa39076e28ef"
|
||||
"1ea028f5118de61ae02bb6aefc3343a050292f199f401857b2bead5e6ee2a1f1"
|
||||
"91022f9278016f047791a9d18da7d2a6d27f2e0e51c2f6ea30e8ac49a0604f4c"
|
||||
"13542e85b68381b9fdcfa0ce4b2d341354852d360245c536b612af71f3e77c90"
|
||||
"95ae2dbde504b265733dabfe10a20fc7d6d32c21ccc72b8b3444ae663d65922d"
|
||||
"17f82caa2b865cd88913d291a65899026ea1328439723c198c36b0c3c8d085bf"
|
||||
"af8a320fde334b4a4919b44c2b95f6e8ecf73393f7f0d2a40e60b1d406526b02"
|
||||
"2ddc331810b1a5f7c347bd53ed1f105d6a0d30aba477e178889ab2ec55d558de"
|
||||
"ab2630204336962b4db5b663b6902b89e85b31bc6af50fc50accb3fb9b57b663"
|
||||
"297031378db47896d7fbaf6c600add2c67f936db037986db856eb49cf2db3f7d"
|
||||
"a6d23650e438f1884041b013119e4c2ae5af37cccdfb68660738b58b3c59d1c0"
|
||||
"248437472aba1f35ca1fb90cd714aa9f635534f49e7c5bba81c2b6b36fdee21c"
|
||||
"a27e347f793d2ce944edb23c8c9b914be10335e350feb5070394b7a4a15c0ca1"
|
||||
"20283568b7bfc254fe838b137a2147ce7c113a3a4d65499d9e86b87dbcc7f03b"
|
||||
"bd3a3ab1aa243ece5ba9bcf25f82836cfe473b2d83e7a7201cd0b96a72451e86"
|
||||
"3f6c3ba664a6d073d1f7b5ed990865d978bd3815d06094fc9a2aba5221c22d5a"
|
||||
"b996389e3721e3af5f05beddc2875e0dfaeb39021ee27a41187cbb45ef40c3e7"
|
||||
"3bc03989f9a30d12c54ba7d2141da8a875493e65776ef35f97debc2286cc4af9"
|
||||
"b4623eee902f840c52f1b8ad658939aef71f3f72b9ec1de21588bd35484ea444"
|
||||
"36343ff95ead6ab1d8afb1b2a303df1b71e53c4aea6b2e3e9372be0d1bc99798"
|
||||
"b0ce3cc10d2a596d565dba82f88ce4cff3b33d5d24e9c0831124bf1ad54b7925"
|
||||
"32983dd6c3a8b7d0"),
|
||||
16448,
|
||||
HL("ebd5ccb0")
|
||||
);
|
||||
/* Test set 1 #C.2.1 */
|
||||
#if defined(EIA2_NON_BYTE_ALIGNED_SUPPORTED)
|
||||
eia2_encrypt(
|
||||
0, 0x38a6f056, 0x18, HL("2bd6459f82c5b300952c49104881ff48"),
|
||||
H("3332346263393840"),
|
||||
58,
|
||||
HL("118c6eb8")
|
||||
);
|
||||
/* Test set 3 #C.2.3 */
|
||||
eia2_encrypt(
|
||||
1, 0x36af6144, 0x18, HL("7e5e94431e11d73828d739cc6ced4573"),
|
||||
H("b3d3c9170a4e1632f60f861013d22d84b726b6a278d802d1eeaf1321ba5929dc"),
|
||||
254,
|
||||
HL("1f60b01d")
|
||||
);
|
||||
/* Test set 4 #C.2.4 */
|
||||
eia2_encrypt(
|
||||
0, 0xc7590ea9, 0x17, HL("d3419be821087acd02123a9248033359"),
|
||||
H("bbb057038809496bcff86d6fbc8ce5b135a06b166054f2d565be8ace75dc851e"
|
||||
"0bcdd8f07141c495872fb5d8c0c66a8b6da556663e4e461205d84580bee5bc7e"),
|
||||
511,
|
||||
HL("6846a2f0")
|
||||
);
|
||||
/* Test set 6 #C.2.6 */
|
||||
eia2_encrypt(
|
||||
0, 0x36af6144, 0x18, HL("6832a65cff4473621ebdd4ba26a921fe"),
|
||||
H("d3c53839626820717765667620323837636240981ba6824c1bfb1ab485472029"
|
||||
"b71d808ce33e2cc3c0b5fc1f3de8a6dc"),
|
||||
768,
|
||||
HL("f0668c1e")
|
||||
);
|
||||
/* Test set 7 #C.2.7 */
|
||||
eia2_encrypt(
|
||||
1, 0x7827fab2, 0x05, HL("5d0a80d8134ae19677824b671e838af4"),
|
||||
H("70dedf2dc42c5cbd3a96f8a0b11418b3608d5733604a2cd36aabc70ce3193bb5"
|
||||
"153be2d3c06dfdb2d16e9c357158be6a41d6b861e491db3fbfeb518efcf048d7"
|
||||
"d58953730ff30c9ec470ffcd663dc34201c36addc0111c35b38afee7cfdb582e"
|
||||
"3731f8b4baa8d1a89c06e81199a9716227be344efcb436ddd0f096c064c3b5e2"
|
||||
"c399993fc77394f9e09720a811850ef23b2ee05d9e6173609d86e1c0c18ea51a"
|
||||
"012a00bb413b9cb8188a703cd6bae31cc67b34b1b00019e6a2b2a690f02671fe"
|
||||
"7c9ef8dec0094e533763478d58d2c5f5b827a0148c5948a96931acf84f465a64"
|
||||
"e62ce74007e991e37ea823fa0fb21923b79905b733b631e6c7d6860a3831ac35"
|
||||
"1a9c730c52ff72d9d308eedbab21fde143a0ea17e23edc1f74cbb3638a2033aa"
|
||||
"a15464eaa733385dbbeb6fd73509b857e6a419dca1d8907af977fbac4dfa35ec"),
|
||||
2558,
|
||||
HL("f4cc8fa3")
|
||||
);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*******************************************************************************
|
||||
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@lists.eurecom.fr
|
||||
|
||||
Address : Eurecom, Compus SophiaTech 450, route des chappes, 06451 Biot, France.
|
||||
|
||||
*******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
#include "secu_defs.h"
|
||||
|
||||
#define H(x) decode_hex_dup(x)
|
||||
#define HL(x) decode_hex_dup(x), decode_hex_length(x)
|
||||
|
||||
static void eea2_encrypt(uint8_t direction, uint32_t count,
|
||||
uint8_t bearer, uint8_t *key, uint32_t key_length, uint8_t *message,
|
||||
uint32_t length, uint8_t *expected)
|
||||
{
|
||||
nas_stream_cipher_t *nas_cipher;
|
||||
uint8_t *result;
|
||||
uint32_t zero_bits = length & 7;
|
||||
uint32_t byte_length = length >> 3;
|
||||
|
||||
if (zero_bits > 0)
|
||||
byte_length += 1;
|
||||
|
||||
nas_cipher = calloc(1, sizeof(nas_stream_cipher_t));
|
||||
|
||||
nas_cipher->direction = direction;
|
||||
nas_cipher->count = count;
|
||||
nas_cipher->key = key;
|
||||
nas_cipher->key_length = key_length;
|
||||
nas_cipher->bearer = bearer;
|
||||
nas_cipher->blength = length;
|
||||
nas_cipher->message = message;
|
||||
|
||||
if (nas_stream_cipher_eea2(nas_cipher, &result) != 0)
|
||||
fail("Fail: nas_stream_cipher_eea2\n");
|
||||
|
||||
if (compare_buffer(result, byte_length, expected, byte_length) != 0) {
|
||||
fail("Fail: eea2_encrypt\n");
|
||||
}
|
||||
|
||||
free(nas_cipher);
|
||||
free(result);
|
||||
}
|
||||
|
||||
|
||||
void doit (void)
|
||||
{
|
||||
/* Test suite from 3GPP TS33.401 #Appendix C.1 */
|
||||
|
||||
/* Test set 1 #C.1.1 */
|
||||
eea2_encrypt(
|
||||
1, 0x398a59b4, 0x15, HL("d3c5d592327fb11c4035c6680af8c6d1"),
|
||||
H("981ba6824c1bfb1ab485472029b71d808ce33e2cc3c0b5fc1f3de8a6dc66b1f0"),
|
||||
253,
|
||||
H("e9fed8a63d155304d71df20bf3e82214b20ed7dad2f233dc3c22d7bdeeed8e78")
|
||||
);
|
||||
/* Test set 2 #C.1.2 */
|
||||
eea2_encrypt(
|
||||
1, 0xc675a64b, 0x0c, HL("2bd6459f82c440e0952c49104805ff48"),
|
||||
H("7ec61272743bf1614726446a6c38ced166f6ca76eb5430044286346cef130f92"
|
||||
"922b03450d3a9975e5bd2ea0eb55ad8e1b199e3ec4316020e9a1b285e7627953"
|
||||
"59b7bdfd39bef4b2484583d5afe082aee638bf5fd5a606193901a08f4ab41aab"
|
||||
"9b134880"),
|
||||
798,
|
||||
H("5961605353c64bdca15b195e288553a910632506d6200aa790c4c806c99904cf"
|
||||
"2445cc50bb1cf168a49673734e081b57e324ce5259c0e78d4cd97b870976503c"
|
||||
"0943f2cb5ae8f052c7b7d392239587b8956086bcab18836042e2e6ce42432a17"
|
||||
"105c53d0")
|
||||
);
|
||||
/* Test set 3 #C.1.3 */
|
||||
eea2_encrypt(
|
||||
0, 0x544d49cd, 0x04, HL("0a8b6bd8d9b08b08d64e32d1817777fb"),
|
||||
H("fd40a41d370a1f65745095687d47ba1d36d2349e23f644392c8ea9c49d40c132"
|
||||
"71aff264d0f24800"),
|
||||
310,
|
||||
H("75750d37b4bba2a4dedb34235bd68c6645acdaaca48138a3b0c471e2a7041a57"
|
||||
"6423d2927287f000")
|
||||
);
|
||||
/* Test set 4 #C.1.4 */
|
||||
eea2_encrypt(
|
||||
1, 0x72d8c671, 0x10, HL("aa1f95aea533bcb32eb63bf52d8f831a"),
|
||||
H("fb1b96c5c8badfb2e8e8edfde78e57f2ad81e74103fc430a534dcc37afcec70e"
|
||||
"1517bb06f27219dae49022ddc47a068de4c9496a951a6b09edbdc864c7adbd74"
|
||||
"0ac50c022f3082bafd22d78197c5d508b977bca13f32e652e74ba728576077ce"
|
||||
"628c535e87dc6077ba07d29068590c8cb5f1088e082cfa0ec961302d69cf3d44"),
|
||||
1022,
|
||||
H("dfb440acb3773549efc04628aeb8d8156275230bdc690d94b00d8d95f28c4b56"
|
||||
"307f60f4ca55eba661ebba72ac808fa8c49e26788ed04a5d606cb418de74878b"
|
||||
"9a22f8ef29590bc4eb57c9faf7c41524a885b8979c423f2f8f8e0592a9879201"
|
||||
"be7ff9777a162ab810feb324ba74c4c156e04d39097209653ac33e5a5f2d8864")
|
||||
);
|
||||
/* Test set 5 #C.1.5 */
|
||||
eea2_encrypt(
|
||||
1, 0xc675a64b, 0x0c, HL("9618ae46891f86578eebe90ef7a1202e"),
|
||||
H("8daa17b1ae050529c6827f28c0ef6a1242e93f8b314fb18a77f790ae049fedd6"
|
||||
"12267fecaefc450174d76d9f9aa7755a30cd90a9a5874bf48eaf70eea3a62a25"
|
||||
"0a8b6bd8d9b08b08d64e32d1817777fb544d49cd49720e219dbf8bbed33904e1"
|
||||
"fd40a41d370a1f65745095687d47ba1d36d2349e23f644392c8ea9c49d40c132"
|
||||
"71aff264d0f24841d6465f0996ff84e65fc517c53efc3363c38492a8"),
|
||||
1245,
|
||||
H("919c8c33d66789703d05a0d7ce82a2aeac4ee76c0f4da050335e8a84e7897ba5"
|
||||
"df2f36bd513e3d0c8578c7a0fcf043e03aa3a39fbaad7d15be074faa5d9029f7"
|
||||
"1fb457b647834714b0e18f117fca10677945096c8c5f326ba8d6095eb29c3e36"
|
||||
"cf245d1622aafe921f7566c4f5d644f2f1fc0ec684ddb21349747622e209295d"
|
||||
"27ff3f95623371d49b147c0af486171f22cd04b1cbeb2658223e6938")
|
||||
);
|
||||
/* Test set 6 #C.1.6 */
|
||||
eea2_encrypt(
|
||||
0, 0xaca4f50f, 0x0b, HL("54f4e2e04c83786eec8fb5abe8e36566"),
|
||||
H("40981ba6824c1bfb4286b299783daf442c099f7ab0f58d5c8e46b104f08f01b4"
|
||||
"1ab485472029b71d36bd1a3d90dc3a41b46d51672ac4c9663a2be063da4bc8d2"
|
||||
"808ce33e2cccbfc634e1b259060876a0fbb5a437ebcc8d31c19e4454318745e3"
|
||||
"fa16bb11adae248879fe52db2543e53cf445d3d828ce0bf5c560593d97278a59"
|
||||
"762dd0c2c9cd68d4496a792508614014b13b6aa51128c18cd6a90b87978c2ff1"
|
||||
"cabe7d9f898a411bfdb84f68f6727b1499cdd30df0443ab4a66653330bcba110"
|
||||
"5e4cec034c73e605b4310eaaadcfd5b0ca27ffd89d144df4792759427c9cc1f8"
|
||||
"cd8c87202364b8a687954cb05a8d4e2d99e73db160deb180ad0841e96741a5d5"
|
||||
"9fe4189f15420026fe4cd12104932fb38f735340438aaf7eca6fd5cfd3a195ce"
|
||||
"5abe65272af607ada1be65a6b4c9c0693234092c4d018f1756c6db9dc8a6d80b"
|
||||
"888138616b681262f954d0e7711748780d92291d86299972db741cfa4f37b8b5"
|
||||
"6cdb18a7ca8218e86e4b4b716a4d04371fbec262fc5ad0b3819b187b97e55b1a"
|
||||
"4d7c19ee24c8b4d7723cfedf045b8acae4869517d80e50615d9035d5d9c5a40a"
|
||||
"f602280b542597b0cb18619eeb35925759d195e100e8e4aa0c38a3c2abe0f3d8"
|
||||
"ff04f3c33c295069c23694b5bbeacdd542e28e8a94edb9119f412d054be1fa72"
|
||||
"00b09000"),
|
||||
3861,
|
||||
H("5cb72c6edc878f1566e10253afc364c9fa540d914db94cbee275d0917ca6af0d"
|
||||
"77acb4ef3bbe1a722b2ef5bd1d4b8e2aa5024ec1388a201e7bce7920aec61589"
|
||||
"5f763a5564dcc4c482a2ee1d8bfecc4498eca83fbb75f9ab530e0dafbede2fa5"
|
||||
"895b82991b6277c529e0f2529d7f79606be96706296dedfa9d7412b616958cb5"
|
||||
"63c678c02825c30d0aee77c4c146d2765412421a808d13cec819694c75ad572e"
|
||||
"9b973d948b81a9337c3b2a17192e22c2069f7ed1162af44cdea817603665e807"
|
||||
"ce40c8e0dd9d6394dc6e31153fe1955c47afb51f2617ee0c5e3b8ef1ad7574ed"
|
||||
"343edc2743cc94c990e1f1fd264253c178dea739c0befeebcd9f9b76d49c1015"
|
||||
"c9fecf50e53b8b5204dbcd3eed863855dabcdcc94b31e318021568855c8b9e52"
|
||||
"a981957a112827f978ba960f1447911b317b5511fbcc7fb13ac153db74251117"
|
||||
"e4861eb9e83bffffc4eb7755579038e57924b1f78b3e1ad90bab2a07871b72db"
|
||||
"5eef96c334044966db0c37cafd1a89e5646a3580eb6465f121dce9cb88d85b96"
|
||||
"cf23ccccd4280767bee8eeb23d8652461db6493103003baf89f5e18261ea43c8"
|
||||
"4a92ebffffe4909dc46c5192f825f770600b9602c557b5f8b431a79d45977dd9"
|
||||
"c41b863da9e142e90020cfd074d6927b7ab3b6725d1a6f3f98b9c9daa8982aff"
|
||||
"06782800")
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2012 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Simon Josefsson
|
||||
*
|
||||
* This file is part of GnuTLS.
|
||||
*
|
||||
* GnuTLS 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.
|
||||
*
|
||||
* GnuTLS 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 GnuTLS; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "test_util.h"
|
||||
|
||||
int debug = 0;
|
||||
int error_count = 0;
|
||||
int break_on_error = 0;
|
||||
|
||||
/* -1 means invalid */
|
||||
static const signed char hex_digits[0x100] = {
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1,
|
||||
-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,10,11,12,13,14,15,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
|
||||
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
||||
};
|
||||
|
||||
void
|
||||
fail (const char *format, ...)
|
||||
{
|
||||
char str[1024];
|
||||
va_list arg_ptr;
|
||||
|
||||
va_start (arg_ptr, format);
|
||||
vsnprintf ( str, sizeof(str), format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
fputs(str, stderr);
|
||||
error_count++;
|
||||
|
||||
if (break_on_error)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
void
|
||||
success (const char *format, ...)
|
||||
{
|
||||
char str[1024];
|
||||
va_list arg_ptr;
|
||||
|
||||
va_start (arg_ptr, format);
|
||||
vsnprintf ( str, sizeof(str), format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
fputs(str, stderr);
|
||||
}
|
||||
|
||||
void
|
||||
escapeprint (const char *str, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
printf (" (length %d bytes):\n\t", (int) len);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (((str[i] & 0xFF) >= 'A' && (str[i] & 0xFF) <= 'Z') ||
|
||||
((str[i] & 0xFF) >= 'a' && (str[i] & 0xFF) <= 'z') ||
|
||||
((str[i] & 0xFF) >= '0' && (str[i] & 0xFF) <= '9')
|
||||
|| (str[i] & 0xFF) == ' ' || (str[i] & 0xFF) == '.')
|
||||
printf ("%c", (str[i] & 0xFF));
|
||||
else
|
||||
printf ("\\x%02X", (str[i] & 0xFF));
|
||||
|
||||
if ((i + 1) % 16 == 0 && (i + 1) < len)
|
||||
printf ("'\n\t'");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
void
|
||||
hexprint (const void *_str, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
const char* str = _str;
|
||||
|
||||
printf ("\t;; ");
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
printf ("%02x ", (str[i] & 0xFF));
|
||||
|
||||
if ((i + 1) % 8 == 0)
|
||||
printf (" ");
|
||||
|
||||
if ((i + 1) % 16 == 0 && i + 1 < len)
|
||||
printf ("\n\t;; ");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
void
|
||||
binprint (const void *_str, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
const char* str = _str;
|
||||
|
||||
printf ("\t;; ");
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
printf ("%d%d%d%d%d%d%d%d ",
|
||||
(str[i] & 0xFF) & 0x80 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x40 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x20 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x10 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x08 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x04 ? 1 : 0,
|
||||
(str[i] & 0xFF) & 0x02 ? 1 : 0, (str[i] & 0xFF) & 0x01 ? 1 : 0);
|
||||
|
||||
if ((i + 1) % 3 == 0)
|
||||
printf (" ");
|
||||
|
||||
if ((i + 1) % 6 == 0 && i + 1 < len)
|
||||
printf ("\n\t;; ");
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
int
|
||||
compare_buffer(const uint8_t *buffer, const uint32_t length_buffer,
|
||||
const uint8_t *pattern, const uint32_t length_pattern)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (length_buffer != length_pattern) {
|
||||
printf("Length mismatch, expecting %d bytes, got %d bytes\n", length_pattern,
|
||||
length_buffer);
|
||||
hexprint(buffer, length_buffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < length_buffer; i++) {
|
||||
if (pattern[i] != buffer[i]) {
|
||||
printf("Expecting:\n");
|
||||
hexprint(pattern, length_pattern);
|
||||
printf("Received:\n");
|
||||
hexprint(buffer, length_buffer);
|
||||
printf("Mismatch fount in byte %d\nExpecting 0x%02x, got 0x%02x\n",
|
||||
i, pattern[i], buffer[i]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned
|
||||
decode_hex_length(const char *h)
|
||||
{
|
||||
const unsigned char *hex = (const unsigned char *) h;
|
||||
unsigned count;
|
||||
unsigned i;
|
||||
|
||||
for (count = i = 0; hex[i]; i++) {
|
||||
if (isspace(hex[i]))
|
||||
continue;
|
||||
|
||||
if (hex_digits[hex[i]] < 0)
|
||||
abort();
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count % 2)
|
||||
abort();
|
||||
|
||||
return count / 2;
|
||||
}
|
||||
|
||||
int
|
||||
decode_hex(uint8_t *dst, const char *h)
|
||||
{
|
||||
const unsigned char *hex = (const unsigned char *) h;
|
||||
unsigned i = 0;
|
||||
|
||||
for (;;) {
|
||||
int high, low;
|
||||
|
||||
while (*hex && isspace(*hex))
|
||||
hex++;
|
||||
|
||||
if (!*hex)
|
||||
return 1;
|
||||
|
||||
high = hex_digits[*hex++];
|
||||
|
||||
if (high < 0)
|
||||
return 0;
|
||||
|
||||
while (*hex && isspace(*hex))
|
||||
hex++;
|
||||
|
||||
if (!*hex)
|
||||
return 0;
|
||||
|
||||
low = hex_digits[*hex++];
|
||||
|
||||
if (low < 0)
|
||||
return 0;
|
||||
|
||||
dst[i++] = (high << 4) | low;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *
|
||||
decode_hex_dup(const char *hex)
|
||||
{
|
||||
uint8_t *p;
|
||||
unsigned length = decode_hex_length(hex);
|
||||
|
||||
p = malloc(length * sizeof(uint8_t));
|
||||
|
||||
if (decode_hex(p, hex))
|
||||
return p;
|
||||
else {
|
||||
free(p);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
do
|
||||
if (strcmp (argv[argc - 1], "-v") == 0 ||
|
||||
strcmp (argv[argc - 1], "--verbose") == 0)
|
||||
debug = 1;
|
||||
else if (strcmp (argv[argc - 1], "-b") == 0 ||
|
||||
strcmp (argv[argc - 1], "--break-on-error") == 0)
|
||||
break_on_error = 1;
|
||||
else if (strcmp (argv[argc - 1], "-h") == 0 ||
|
||||
strcmp (argv[argc - 1], "-?") == 0 ||
|
||||
strcmp (argv[argc - 1], "--help") == 0) {
|
||||
printf ("Usage: %s [-vbh?] [--verbose] [--break-on-error] [--help]\n",
|
||||
argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (argc-- > 1);
|
||||
|
||||
doit ();
|
||||
|
||||
if (debug || error_count > 0)
|
||||
printf ("Self test `%s' finished with %d errors\n", argv[0], error_count);
|
||||
|
||||
return error_count ? 1 : 0;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2012 Free Software Foundation, Inc.
|
||||
*
|
||||
* Author: Simon Josefsson
|
||||
*
|
||||
* This file is part of GnuTLS.
|
||||
*
|
||||
* GnuTLS 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.
|
||||
*
|
||||
* GnuTLS 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 GnuTLS; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef TEST_UTIL_H
|
||||
#define TEST_UTIL_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifndef __attribute__
|
||||
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
|
||||
#define __attribute__(Spec) /* empty */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern int debug;
|
||||
extern int error_count;
|
||||
extern int break_on_error;
|
||||
|
||||
extern void fail (const char *format, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
extern void success (const char *format, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
extern void escapeprint (const char *str, size_t len);
|
||||
extern void hexprint (const void *str, size_t len);
|
||||
extern void binprint (const void *str, size_t len);
|
||||
|
||||
extern uint8_t * decode_hex_dup(const char *hex);
|
||||
extern int decode_hex(uint8_t *dst, const char *h);
|
||||
extern unsigned decode_hex_length(const char *h);
|
||||
|
||||
#define H(x) decode_hex_dup(x)
|
||||
#define HL(x) decode_hex_dup(x), decode_hex_length(x)
|
||||
|
||||
extern int
|
||||
compare_buffer(const uint8_t *buffer, const uint32_t length_buffer,
|
||||
const uint8_t *pattern, const uint32_t length_pattern);
|
||||
|
||||
/* This must be implemented elsewhere. */
|
||||
extern void doit (void);
|
||||
|
||||
#endif /* TEST_UTIL_H_ */
|
||||
Reference in New Issue
Block a user