mirror of
https://github.com/KuskoSoft/FeitCSI.git
synced 2026-08-27 14:18:34 +03:00
initial commit
This commit is contained in:
commit
ce357515a4
12
.gitignore
vendored
Normal file
12
.gitignore
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
# Ignore default output directories
|
||||
/bin/
|
||||
/obj/
|
||||
/data/
|
||||
/tmp/
|
||||
/.vscode/
|
||||
MainWindow.glade~
|
||||
poznamky
|
||||
|
||||
|
||||
# Ignore compiled sources in any directory
|
||||
/**/*.o
|
||||
674
COPYING
Normal file
674
COPYING
Normal file
@ -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>.
|
||||
891
MainWindow.glade
Normal file
891
MainWindow.glade
Normal file
@ -0,0 +1,891 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkMessageDialog" id="errorDialog">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="type-hint">dialog</property>
|
||||
<property name="message-type">error</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="errorDialogOkBtn">
|
||||
<property name="label" translatable="yes">Ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkFileChooserDialog" id="filechooserdialog1">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="type-hint">dialog</property>
|
||||
<property name="do-overwrite-confirmation">True</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox">
|
||||
<property name="can-focus">False</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkButtonBox">
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="frequencySpin">
|
||||
<property name="lower">2412</property>
|
||||
<property name="upper">7125</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="injectDelaySpin">
|
||||
<property name="upper">100000000</property>
|
||||
<property name="value">100000</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="injectRepeatSpin">
|
||||
<property name="upper">100000000</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
<object class="GtkApplicationWindow" id="MainWindow">
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkNotebook">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkViewport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<!-- n-columns=2 n-rows=18 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">8</property>
|
||||
<property name="margin-end">8</property>
|
||||
<property name="margin-top">8</property>
|
||||
<property name="margin-bottom">8</property>
|
||||
<property name="row-spacing">8</property>
|
||||
<property name="column-spacing">8</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Frequency [MHz]:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Channel width [MHz]:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">MCS index:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Save CSI to:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Spatial streams:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="mcs">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item id="0" translatable="yes">0</item>
|
||||
<item id="1" translatable="yes">1</item>
|
||||
<item id="2" translatable="yes">2</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="spatialStreams">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item id="1" translatable="yes">1</item>
|
||||
<item id="2" translatable="yes">2</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">9</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Basic settings</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Inject settings</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">7</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Guard interval [ns]:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="guardInterval">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item id="400" translatable="yes">400</item>
|
||||
<item id="800" translatable="yes">800</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">10</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">TX power [dBm]:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">12</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="txPower">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item id="1" translatable="yes">1</item>
|
||||
<item id="2" translatable="yes">2</item>
|
||||
<item id="3" translatable="yes">3</item>
|
||||
<item id="4" translatable="yes">4</item>
|
||||
<item id="5" translatable="yes">5</item>
|
||||
<item id="6" translatable="yes">6</item>
|
||||
<item id="7" translatable="yes">7</item>
|
||||
<item id="8" translatable="yes">8</item>
|
||||
<item id="9" translatable="yes">9</item>
|
||||
<item id="10" translatable="yes">10</item>
|
||||
<item id="11" translatable="yes">11</item>
|
||||
<item id="12" translatable="yes">12</item>
|
||||
<item id="13" translatable="yes">13</item>
|
||||
<item id="14" translatable="yes">14</item>
|
||||
<item id="15" translatable="yes">15</item>
|
||||
<item id="16" translatable="yes">16</item>
|
||||
<item id="17" translatable="yes">17</item>
|
||||
<item id="18" translatable="yes">18</item>
|
||||
<item id="19" translatable="yes">19</item>
|
||||
<item id="20" translatable="yes">20</item>
|
||||
<item id="21" translatable="yes">21</item>
|
||||
<item id="22" translatable="yes">22</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">12</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Format:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="format">
|
||||
<property name="name">format</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="active">1</property>
|
||||
<items>
|
||||
<item id="NOHT" translatable="yes">NOHT</item>
|
||||
<item id="HT" translatable="yes">HT</item>
|
||||
<item id="VHT" translatable="yes">VHT</item>
|
||||
<item id="HESU" translatable="yes">HESU</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Coding:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">13</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="coding">
|
||||
<property name="name">coding</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item id="BCC" translatable="yes">BCC</item>
|
||||
<item id="LDPC" translatable="yes">LDPC</item>
|
||||
</items>
|
||||
<style>
|
||||
<class name="BCC"/>
|
||||
<class name="LDPC"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">13</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Inject delay [us]:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">14</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Inject repeat:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">15</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="errorMessages">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
<attribute name="foreground" value="#e0e01b1b2424"/>
|
||||
<attribute name="background" value="#f9f9f0f06b6b"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">16</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="filePath">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="wrap-mode">char</property>
|
||||
<property name="max-width-chars">40</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">5</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="channelWidth">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item id="20" translatable="yes">20</item>
|
||||
<item id="40" translatable="yes">40</item>
|
||||
<item id="HT40-" translatable="yes">HT40-</item>
|
||||
<item id="80" translatable="yes">80</item>
|
||||
<item id="160" translatable="yes">160</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="frequency">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="adjustment">frequencySpin</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="injectDelay">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="adjustment">injectDelaySpin</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">14</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="injectRepeat">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="adjustment">injectRepeatSpin</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">15</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="measureButton">
|
||||
<property name="label" translatable="yes">Measure</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">end</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">6</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="injectButton">
|
||||
<property name="label" translatable="yes">Inject</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="halign">end</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">17</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">LTF:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">11</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="ltf">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="active">0</property>
|
||||
<items>
|
||||
<item id="2xLTF+0.8" translatable="yes">2xLTF+0.8</item>
|
||||
<item id="2xLTF+1.6" translatable="yes">2xLTF+1.6</item>
|
||||
<item id="4xLTF+3.2" translatable="yes">4xLTF+3.2</item>
|
||||
<item id="4xLTF+0.8" translatable="yes">4xLTF+0.8</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">11</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="outputFile">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="do-overwrite-confirmation">True</property>
|
||||
<property name="dialog">filechooserdialog1</property>
|
||||
<property name="title" translatable="yes"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Measuring / Injecting</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="tab-fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<property name="propagate-natural-width">True</property>
|
||||
<child>
|
||||
<object class="GtkViewport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<!-- n-columns=2 n-rows=9 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">8</property>
|
||||
<property name="margin-end">8</property>
|
||||
<property name="margin-top">8</property>
|
||||
<property name="margin-bottom">8</property>
|
||||
<property name="row-spacing">8</property>
|
||||
<property name="column-spacing">8</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Raw CSI file:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFileChooserButton" id="inputFile">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="title" translatable="yes"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Current data:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="currentDataCount">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">1/235</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="previousCsiButton">
|
||||
<property name="label" translatable="yes">⬅ previous</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="nextCsiButton">
|
||||
<property name="label" translatable="yes">next ➡</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Data</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Interpolation</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">4</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="interpolationLinearRadioButton">
|
||||
<property name="label" translatable="yes">Linear</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
<property name="group">interpolationNone</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="interpolationCosineButton">
|
||||
<property name="label" translatable="yes">Cosine</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
<property name="group">interpolationNone</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="interpolationCubicRadioButton">
|
||||
<property name="label" translatable="yes">Cubic</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
<property name="group">interpolationNone</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="interpolationNone">
|
||||
<property name="label" translatable="yes">None</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Phase linear transform</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="phaseLinearTransformCheckButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="draw-indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="processingSaveGtkButton">
|
||||
<property name="label" translatable="yes">Save processed CSI</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">8</property>
|
||||
<property name="width">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="tab">
|
||||
<object class="GtkLabel">
|
||||
<property name="sensitive">False</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Processing</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
<property name="tab-fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned" id="socketConsolePaned">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSocket" id="chartSocket">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">False</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="consoleScrollbar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="window-placement">bottom-left</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkTextView" id="console">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="wrap-mode">word</property>
|
||||
<property name="cursor-visible">False</property>
|
||||
<property name="accepts-tab">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="resize">True</property>
|
||||
<property name="shrink">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="mcsValues">
|
||||
<columns>
|
||||
<!-- column-name guchar1 -->
|
||||
<column type="guchar"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0">a</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0">s</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
<object class="GtkListStore" id="spatialStreamsValues">
|
||||
<columns>
|
||||
<!-- column-name guint1 -->
|
||||
<column type="guint"/>
|
||||
</columns>
|
||||
<data>
|
||||
<row>
|
||||
<col id="0">1</col>
|
||||
</row>
|
||||
<row>
|
||||
<col id="0">2</col>
|
||||
</row>
|
||||
</data>
|
||||
</object>
|
||||
</interface>
|
||||
52
Makefile
Normal file
52
Makefile
Normal file
@ -0,0 +1,52 @@
|
||||
# Target
|
||||
BIN_DIR = bin
|
||||
BIN = $(BIN_DIR)/app
|
||||
|
||||
# Match all sources in src direcotry
|
||||
SRCS_DIR = src
|
||||
SRCS = $(wildcard $(SRCS_DIR)/**/*.cpp $(SRCS_DIR)/*.cpp)
|
||||
|
||||
# Builds object list from sources, substitues .cpp for .o
|
||||
OBJS_DIR = obj
|
||||
OBJS = $(patsubst $(SRCS_DIR)/%.cpp,$(OBJS_DIR)/%.o,$(SRCS))
|
||||
|
||||
# Include headers files
|
||||
INCLUDE_DIRS = include include/gui lib/include
|
||||
INCLUDE = $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
|
||||
|
||||
# Search libraries in following directories
|
||||
INCLUDE_LIB_DIRS =
|
||||
INCLUDE_LIB = $(foreach includedir,$(INCLUDE_LIB_DIRS),-L$(includedir))
|
||||
|
||||
# Set compiler, preprocesor and linker flags
|
||||
CXXFLAGS += -g -O3 -Wall -std=c++17 $(INCLUDE)
|
||||
CPPFLAGS += `pkg-config --cflags gtkmm-3.0 libnl-3.0 libnl-genl-3.0 libpcap`
|
||||
LDFLAGS += $(INCLUDE_LIB)
|
||||
LDLIBS += `pkg-config --libs gtkmm-3.0 libnl-3.0 libnl-genl-3.0 libpcap`
|
||||
|
||||
# Set other tools
|
||||
MKDIR = mkdir -p
|
||||
|
||||
# Avoid filename conflicts
|
||||
.PHONY: all clean
|
||||
|
||||
# Rules
|
||||
all: $(BIN)
|
||||
|
||||
$(OBJS_DIR)/%.o: $(SRCS_DIR)/%.cpp
|
||||
@$(MKDIR) $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
$(BIN): $(OBJS)
|
||||
@$(MKDIR) $(dir $@)
|
||||
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
|
||||
|
||||
install:
|
||||
cp $(BIN) /usr/local/bin/feitcsi
|
||||
|
||||
uninstall:
|
||||
rm /usr/local/bin/feitcsi
|
||||
|
||||
clean:
|
||||
@$(RM) $(BIN)
|
||||
@$(RM) $(OBJS)
|
||||
100
include/Csi.h
Normal file
100
include/Csi.h
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef CSI_H
|
||||
#define CSI_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <complex>
|
||||
#include <vector>
|
||||
|
||||
#define CSI_HEADER_LENGTH 272
|
||||
|
||||
struct RawHeaderData
|
||||
{
|
||||
uint32_t csiDataSize;
|
||||
uint32_t space4;
|
||||
uint32_t ftmClock;
|
||||
uint8_t space12[34];
|
||||
uint8_t numRx;
|
||||
uint8_t numTx;
|
||||
uint8_t space48[4];
|
||||
uint32_t numSubCarriers;
|
||||
uint8_t space54[4];
|
||||
uint32_t rssi1;
|
||||
uint32_t rssi2;
|
||||
uint8_t srcMac[6];
|
||||
uint8_t space75[18];
|
||||
uint32_t rateNflag;
|
||||
uint32_t space96[44];
|
||||
};
|
||||
|
||||
class Csi
|
||||
{
|
||||
|
||||
public:
|
||||
Csi();
|
||||
~Csi();
|
||||
// void load(uint8_t *data, uint32_t size);
|
||||
void loadFromFile(std::string fileName);
|
||||
void loadFromMemory(uint8_t *pHeader, uint8_t *rawCsiData);
|
||||
void loadFromMemory(uint8_t *rawData);
|
||||
void save();
|
||||
void backup();
|
||||
void restore();
|
||||
void magnitudePhaseToComplex();
|
||||
void recalcMagnitudePhase();
|
||||
void unwrapPhase();
|
||||
const std::vector<uint32_t> getPilotIndices();
|
||||
|
||||
RawHeaderData rawHeaderData;
|
||||
uint32_t numRx;
|
||||
uint32_t numTx;
|
||||
uint32_t numSubCarriers = 0;
|
||||
uint32_t format = 0;
|
||||
uint32_t channelWidth = 0;
|
||||
std::vector<std::complex<double>> csi;
|
||||
std::vector<std::complex<double>> csiBackup;
|
||||
std::vector<double> magnitude;
|
||||
std::vector<double> phase;
|
||||
|
||||
private:
|
||||
const std::vector<uint32_t> NO_NHT_20_PILOT_INDICES = {5, 19, 32, 46}; // 52 subcarriers
|
||||
const std::vector<uint32_t> HT_VHT_20_PILOT_INDICES = {7, 21, 34, 48}; // 56 subcarriers
|
||||
const std::vector<uint32_t> HT_VHT_40_PILOT_INDICES = {5, 33, 47, 66, 80, 108}; // 114 subcarriers
|
||||
const std::vector<uint32_t> VHT_80_PILOT_INDICES = {19, 47, 83, 111, 130, 158, 194, 222}; // 242 subcarriers
|
||||
const std::vector<uint32_t> VHT_160_PILOT_INDICES = {19, 47, 83, 111, 130, 158, 194, 222, 261, 289, 325, 353, 372, 400, 436, 464}; // 484 subcarriers
|
||||
const std::vector<uint32_t> HE_20_PILOT_INDICES = {6, 32, 74, 100, 141, 167, 209, 235}; // 242 subcarriers
|
||||
const std::vector<uint32_t> HE_40_PILOT_INDICES = {6, 32, 74, 100, 140, 166, 208, 234, 249, 275, 317, 343, 383, 409, 451, 477}; // 484 subcarriers
|
||||
const std::vector<uint32_t> HE_80_PILOT_INDICES = {32, 100, 166, 234, 274, 342, 408, 476, 519, 587, 653, 721, 761, 829, 895, 963}; // 996 subcarriers
|
||||
const std::vector<uint32_t> HE_160_PILOT_INDICES = {32, 100, 166, 234, 274, 342, 408, 476, 519, 587, 653, 721, 761, 829, 895, 963, 1028, 1096, 1162, 1230, 1270, 1338, 1404, 1472, 1515, 1583, 1649, 1717, 1757, 1825, 1891, 1959}; // 1992 subcarriers
|
||||
|
||||
std::string saveFilePath;
|
||||
uint8_t *rawCsiData = nullptr;
|
||||
|
||||
void fixCsiBug();
|
||||
void processRawCsi();
|
||||
|
||||
double constrainAngle(double x);
|
||||
double angleConv(double angle);
|
||||
double angleDiff(double a, double b);
|
||||
double unwrap(double previousAngle, double newAngle);
|
||||
};
|
||||
|
||||
#endif
|
||||
45
include/CsiProcessor.h
Normal file
45
include/CsiProcessor.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef CSI_PROCESSOR_H
|
||||
#define CSI_PROCESSOR_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Csi.h"
|
||||
#include "main.h"
|
||||
|
||||
class CsiProcessor
|
||||
{
|
||||
|
||||
public:
|
||||
std::vector<Csi*> csiData;
|
||||
|
||||
bool loadCsi();
|
||||
void saveCsi();
|
||||
void process(Csi &csi);
|
||||
|
||||
|
||||
~CsiProcessor();
|
||||
private:
|
||||
void clearState();
|
||||
void interpolate(Csi &csi, enum processor type);
|
||||
void phaseCalibLinearTransform(Csi &csi);
|
||||
};
|
||||
|
||||
#endif
|
||||
100
include/Logger.h
Normal file
100
include/Logger.h
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <iomanip>
|
||||
#include <gtkmm.h>
|
||||
|
||||
enum Level
|
||||
{
|
||||
debug,
|
||||
error,
|
||||
warning,
|
||||
info
|
||||
};
|
||||
|
||||
class Logger
|
||||
{
|
||||
std::ostream *stream; // set this in a constructor to point
|
||||
// either to a file or console stream
|
||||
|
||||
public:
|
||||
inline static Level debugLevel = info;
|
||||
inline static Glib::RefPtr<Gtk::TextBuffer> guiOutput;
|
||||
|
||||
inline static Logger *INSTANCE = nullptr;
|
||||
|
||||
static Logger &log(Level n, bool persist = false)
|
||||
{
|
||||
if (INSTANCE && !persist)
|
||||
{
|
||||
delete INSTANCE;
|
||||
INSTANCE = nullptr;
|
||||
}
|
||||
|
||||
if (!INSTANCE)
|
||||
{
|
||||
INSTANCE = new Logger();
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto mcs = std::chrono::duration_cast<std::chrono::microseconds>(now.time_since_epoch()) % 1000000;
|
||||
auto timer = std::chrono::system_clock::to_time_t(now);
|
||||
std::tm bt = *std::localtime(&timer);
|
||||
std::ostringstream oss;
|
||||
oss << "[";
|
||||
oss << std::put_time(&bt, "%H:%M:%S"); // HH:MM:SS
|
||||
oss << '.' << std::setfill('0') << std::setw(6) << mcs.count();
|
||||
oss << "] ";
|
||||
*INSTANCE << oss.str().c_str();
|
||||
}
|
||||
Logger::debugLevel = n;
|
||||
return *INSTANCE;
|
||||
}
|
||||
|
||||
static gboolean guiLog(void *data)
|
||||
{
|
||||
std::string *msg = (std::string *)data;
|
||||
Logger::guiOutput->insert_at_cursor(/* Logger::guiOutput->get_iter_at_offset(-1), */ *msg);
|
||||
delete msg;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
Logger &operator<<(const T &v)
|
||||
{
|
||||
if (Logger::guiOutput)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << v;
|
||||
std::cout << ss.str();
|
||||
std::string *d = new std::string(ss.str());
|
||||
gdk_threads_add_idle(guiLog, (void*)d);
|
||||
} else {
|
||||
std::cout << v;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
75
include/MainController.h
Normal file
75
include/MainController.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef MAIN_CONTROLLER_H
|
||||
#define MAIN_CONTROLLER_H
|
||||
|
||||
#include "WiFiCsiController.h"
|
||||
#include "WiFIController.h"
|
||||
#include "PacketInjector.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include <thread>
|
||||
|
||||
class MainController
|
||||
{
|
||||
|
||||
public:
|
||||
static MainController *getInstance();
|
||||
|
||||
|
||||
static void deleteInstance();
|
||||
|
||||
void runNoGui();
|
||||
|
||||
void measureCsi(bool stop = false);
|
||||
|
||||
void injectPackets(bool stop = false);
|
||||
|
||||
void runGui();
|
||||
|
||||
void initInterface();
|
||||
~MainController();
|
||||
|
||||
private:
|
||||
MainController();
|
||||
|
||||
inline static MainController *INSTANCE = nullptr;
|
||||
|
||||
inline static MainWindow *mainWindow = nullptr;
|
||||
|
||||
pthread_t measureCsiThread = 0;
|
||||
|
||||
pthread_t injectPacketThread = 0;
|
||||
|
||||
PacketInjector packetInjector;
|
||||
|
||||
WiFIController wifiController;
|
||||
|
||||
std::vector<InterfaceInfo> bkpInterfaces;
|
||||
|
||||
|
||||
static void *measureCsi(void *arg);
|
||||
|
||||
static void intHandler(int dummy);
|
||||
|
||||
static void *injectPackets(void *arg);
|
||||
|
||||
void restoreState();
|
||||
};
|
||||
|
||||
#endif
|
||||
75
include/Netlink.h
Normal file
75
include/Netlink.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef NETLINK_H
|
||||
#define NETLINK_H
|
||||
|
||||
#include <linux/netlink.h>
|
||||
#include <netlink/msg.h>
|
||||
#include <linux/nl80211.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define ARRAY_SIZE(ar) (sizeof(ar) / sizeof(ar[0]))
|
||||
|
||||
enum commandIdentifiedBy
|
||||
{
|
||||
CIB_NONE,
|
||||
CIB_PHY,
|
||||
CIB_NETDEV,
|
||||
CIB_WDEV,
|
||||
};
|
||||
|
||||
struct nl80211_state
|
||||
{
|
||||
struct nl_sock *nl_sock;
|
||||
int nl80211_id;
|
||||
};
|
||||
|
||||
struct Cmd
|
||||
{
|
||||
uint8_t id;
|
||||
commandIdentifiedBy idby;
|
||||
int nlFlags;
|
||||
signed long long device;
|
||||
int (*handler)(struct nl80211_state *state, struct nl_msg *msg, void *arg);
|
||||
int (*valid_handler)(struct nl_msg *msg, void *arg);
|
||||
void *args;
|
||||
};
|
||||
|
||||
class Netlink
|
||||
{
|
||||
|
||||
public:
|
||||
void init();
|
||||
|
||||
protected:
|
||||
int nlExecCommand(Cmd &cmd);
|
||||
|
||||
private:
|
||||
struct nl80211_state nlstate;
|
||||
int nlInit(struct nl80211_state *state);
|
||||
|
||||
static int error_handler(sockaddr_nl *nla, nlmsgerr *err, void *arg);
|
||||
static int finish_handler(nl_msg *msg, void *arg);
|
||||
static int ack_handler(nl_msg *msg, void *arg);
|
||||
static int nlValidHandler(nl_msg *msg, void *arg);
|
||||
};
|
||||
|
||||
#endif
|
||||
43
include/PacketInjector.h
Normal file
43
include/PacketInjector.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef PACKET_INJECTOR_H
|
||||
#define PACKET_INJECTOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ieee80211_radiotap.h"
|
||||
#include "rs.h"
|
||||
|
||||
#define BIT(n) (0x1U << (n))
|
||||
|
||||
class PacketInjector
|
||||
{
|
||||
|
||||
public:
|
||||
void inject();
|
||||
void injectNoHT();
|
||||
void injectHT();
|
||||
void injectVHT();
|
||||
void injectHE();
|
||||
|
||||
|
||||
private:
|
||||
void send(uint32_t rateNFlags);
|
||||
};
|
||||
|
||||
#endif
|
||||
91
include/WiFIController.h
Normal file
91
include/WiFIController.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef WIFI_CONTROLLER_H
|
||||
#define WIFI_CONTROLLER_H
|
||||
|
||||
/* #define CONFIG_LIBNL30 // fix error compatibility iw
|
||||
#include <iw/iw.h>
|
||||
#include <iw/nl80211.h> */
|
||||
#include "Netlink.h"
|
||||
#include <linux/netlink.h>
|
||||
#include <netlink/msg.h>
|
||||
#include <linux/nl80211.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define ARRAY_SIZE(ar) (sizeof(ar) / sizeof(ar[0]))
|
||||
|
||||
struct InterfaceInfo
|
||||
{
|
||||
std::string ifName;
|
||||
int ifIndex;
|
||||
uint64_t wdev;
|
||||
std::string mac;
|
||||
std::string ssid;
|
||||
int ifType;
|
||||
int wiphy;
|
||||
uint32_t freq;
|
||||
int channel;
|
||||
int channelWidth;
|
||||
int centerFreq1;
|
||||
int centerFreq2;
|
||||
int channelType;
|
||||
double txdBm;
|
||||
};
|
||||
|
||||
struct ChanMode
|
||||
{
|
||||
const char *name;
|
||||
unsigned int width;
|
||||
int freq1_diff;
|
||||
int chantype; /* for older kernel */
|
||||
};
|
||||
|
||||
class WiFIController : public Netlink
|
||||
{
|
||||
|
||||
public:
|
||||
void killNetworkProcesses();
|
||||
void getInterfaces();
|
||||
void setTxPower();
|
||||
void addMonitorDevice(const char *name, const nl80211_iftype type);
|
||||
int setInterfaceUpDown(const char *ifName, bool up);
|
||||
void setFreq(uint16_t freq, const char *bw);
|
||||
void removeInterface(const char *name, int ifIndex = 0);
|
||||
void getPhys();
|
||||
static ChanMode getChanMode(const char *width);
|
||||
static uint16_t chanModeToWidth(ChanMode &chanMode);
|
||||
std::vector<InterfaceInfo> interfaces;
|
||||
std::vector<int64_t> phys;
|
||||
|
||||
private:
|
||||
std::string macN2a(const unsigned char *arg);
|
||||
int freqToCHannel(int freq);
|
||||
int phyLookup(char *name);
|
||||
|
||||
static int getCf1(const ChanMode *chanmode, unsigned long freq);
|
||||
static int processGetInterfacesHandler(nl_msg *msg, void *arg);
|
||||
static int processGetPhysHandler(nl_msg *msg, void *arg);
|
||||
static int processSetFreq(nl80211_state *state, nl_msg *msg, void *arg);
|
||||
static int setTxPowerHandler(nl80211_state *state, nl_msg *msg, void *arg);
|
||||
static int processAddMonitorDeviceHandler(nl80211_state *state, nl_msg *msg, void *arg);
|
||||
};
|
||||
|
||||
#endif
|
||||
45
include/WiFiCsiController.h
Normal file
45
include/WiFiCsiController.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef WIFI_CSI_CONTROLLER_H
|
||||
#define WIFI_CSI_CONTROLLER_H
|
||||
|
||||
#include "Netlink.h"
|
||||
#include "GnuPlot.h"
|
||||
|
||||
#define IWL_MVM_VENDOR_ATTR_CSI_HDR 0x4d
|
||||
#define IWL_MVM_VENDOR_ATTR_CSI_DATA 0x4e
|
||||
#define MAX_CMD 0x4f
|
||||
|
||||
class WiFiCsiController : public Netlink
|
||||
{
|
||||
|
||||
public:
|
||||
void init();
|
||||
int listenToCsi();
|
||||
void enableCsi(bool enable = true);
|
||||
|
||||
~WiFiCsiController();
|
||||
|
||||
private:
|
||||
static int listenToCsiHandler(nl80211_state *state, nl_msg *msg, void *arg);
|
||||
static int processListenToCsiHandler(nl_msg *msg, void *arg);
|
||||
GnuPlot gnuPlot;
|
||||
};
|
||||
|
||||
#endif
|
||||
62
include/gui/CsiProcessingWindow.h
Normal file
62
include/gui/CsiProcessingWindow.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef CSI_PROCESSING_WINDOW_H
|
||||
#define CSI_PROCESSING_WINDOW_H
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include "CsiProcessor.h"
|
||||
#include "GnuPlot.h"
|
||||
|
||||
class CsiProcessingWindow
|
||||
{
|
||||
public:
|
||||
void init(Glib::RefPtr<Gtk::Builder> &builder);
|
||||
|
||||
private:
|
||||
Glib::RefPtr<Gtk::FileChooserButton> inputFile;
|
||||
Glib::RefPtr<Gtk::Label> currentDataCount;
|
||||
Glib::RefPtr<Gtk::Button> previousCsiButton;
|
||||
Glib::RefPtr<Gtk::Button> nextCsiButton;
|
||||
Glib::RefPtr<Gtk::RadioButton> interpolationLinearRadioButton;
|
||||
Glib::RefPtr<Gtk::RadioButton> interpolationCubicRadioButton;
|
||||
Glib::RefPtr<Gtk::RadioButton> interpolationCosineButton;
|
||||
Glib::RefPtr<Gtk::CheckButton> phaseLinearTransformCheckButton;
|
||||
Glib::RefPtr<Gtk::Button> processingSaveGtkButton;
|
||||
|
||||
void inputFileChange();
|
||||
void refresh();
|
||||
void previousCsiButtonClicked();
|
||||
void nextCsiButtonClicked();
|
||||
|
||||
void interpolationLinearRadioButtonClicked();
|
||||
|
||||
void interpolationCubicRadioButtonClicked();
|
||||
|
||||
void interpolationCosineButtonClicked();
|
||||
|
||||
void phaseLinearTransformCheckButtonClicked();
|
||||
|
||||
void processingSaveGtkButtonClicked();
|
||||
|
||||
CsiProcessor csiProcessor;
|
||||
GnuPlot gnuPlot;
|
||||
uint32_t currentIndex = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
42
include/gui/GnuPlot.h
Normal file
42
include/gui/GnuPlot.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef GNU_PLOT_H
|
||||
#define GNU_PLOT_H
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include <gtkmm/socket.h>
|
||||
#include <Csi.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
class GnuPlot
|
||||
{
|
||||
public:
|
||||
void init();
|
||||
void setWindow(uint64_t id);
|
||||
void setBlank();
|
||||
void reload();
|
||||
void updateChart(Csi &csi);
|
||||
|
||||
private:
|
||||
inline static std::string lastCmd;
|
||||
inline static FILE *gnuPlotPipe;
|
||||
};
|
||||
|
||||
#endif
|
||||
114
include/gui/MainWindow.h
Normal file
114
include/gui/MainWindow.h
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef MAIN_WINDOW_H
|
||||
#define MAIN_WINDOW_H
|
||||
|
||||
#include <gtkmm.h>
|
||||
#include "gui/GnuPlot.h"
|
||||
#include "gui/CsiProcessingWindow.h"
|
||||
|
||||
class MainWindow : public Gtk::ApplicationWindow
|
||||
{
|
||||
Glib::RefPtr<Gtk::Builder> ui;
|
||||
|
||||
public:
|
||||
MainWindow(BaseObjectType *obj, Glib::RefPtr<Gtk::Builder> const &builder);
|
||||
void fatalError(std::string msg);
|
||||
|
||||
|
||||
private:
|
||||
int chartWidth = 0;
|
||||
int chartHeight = 0;
|
||||
bool measuring = false;
|
||||
bool injecting = false;
|
||||
|
||||
CsiProcessingWindow csiProcessingWindow;
|
||||
|
||||
std::stringstream coutBuffer;
|
||||
|
||||
std::map<std::string, std::string> errors;
|
||||
Glib::RefPtr<Gtk::Adjustment> consoleScrollbarAdjustment;
|
||||
Glib::RefPtr<Gtk::Builder> builder;
|
||||
Glib::RefPtr<Gtk::MessageDialog> errorDialog;
|
||||
|
||||
Glib::RefPtr<Gtk::Button> measureButton;
|
||||
Glib::RefPtr<Gtk::Button> injectButton;
|
||||
|
||||
Glib::RefPtr<Gtk::SpinButton> frequency;
|
||||
Glib::RefPtr<Gtk::ComboBoxText> channelWidth;
|
||||
Glib::RefPtr<Gtk::FileChooserButton> outputFile;
|
||||
Glib::RefPtr<Gtk::Label> filePath;
|
||||
Glib::RefPtr<Gtk::ComboBoxText> format;
|
||||
Glib::RefPtr<Gtk::ComboBoxText> mcs;
|
||||
Glib::RefPtr<Gtk::ComboBoxText> spatialStreams;
|
||||
Glib::RefPtr<Gtk::ComboBoxText> guardInterval;
|
||||
Glib::RefPtr<Gtk::ComboBoxText> ltf;
|
||||
Glib::RefPtr<Gtk::ComboBoxText> txPower;
|
||||
Glib::RefPtr<Gtk::ComboBoxText> coding;
|
||||
Glib::RefPtr<Gtk::SpinButton> injectDelay;
|
||||
Glib::RefPtr<Gtk::SpinButton> injectRepeat;
|
||||
|
||||
Glib::RefPtr<Gtk::TextView> console;
|
||||
Glib::RefPtr<Gtk::Label> errorMessages;
|
||||
|
||||
Glib::RefPtr<Gtk::Socket> chartSocket;
|
||||
GnuPlot gnuPlot;
|
||||
|
||||
void closeButton();
|
||||
|
||||
bool onWindowDelete(GdkEventAny *event);
|
||||
|
||||
void onWindowInit();
|
||||
|
||||
void onResize();
|
||||
|
||||
void frequencyChange();
|
||||
|
||||
void outputFileChange();
|
||||
|
||||
void channelWidthChange();
|
||||
|
||||
void formatChange();
|
||||
|
||||
void mcsChange();
|
||||
|
||||
void spatialStreamsChange();
|
||||
|
||||
void ltfChange();
|
||||
|
||||
void guardIntervalChange();
|
||||
|
||||
void txPowerChange();
|
||||
|
||||
void codingChange();
|
||||
|
||||
void injectDelayChange();
|
||||
|
||||
void injectRepeatChange();
|
||||
|
||||
void updateErrorMessages();
|
||||
|
||||
void measureButtonClicked();
|
||||
|
||||
void injectButtonClicked();
|
||||
|
||||
void updateSensitivity();
|
||||
};
|
||||
|
||||
#endif
|
||||
30
include/interpolation.h
Normal file
30
include/interpolation.h
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef INTERPOLATION_H
|
||||
#define INTERPOLATION_H
|
||||
|
||||
#include <complex>
|
||||
|
||||
namespace interpolation {
|
||||
double linearInterpolate(double y1, double y2, double mu);
|
||||
double cosineInterpolate(double y1, double y2, double mu);
|
||||
double cubicInterpolate(double y0, double y1, double y2, double y3, double mu);
|
||||
}
|
||||
|
||||
#endif
|
||||
3915
include/layout.h
Normal file
3915
include/layout.h
Normal file
File diff suppressed because it is too large
Load Diff
65
include/main.h
Normal file
65
include/main.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
|
||||
#define MONITOR_INTERFACE_NAME "mon0"
|
||||
|
||||
enum processor
|
||||
{
|
||||
interpolateLinear,
|
||||
interpolateCubic,
|
||||
interpolateCosine,
|
||||
phaseCalibrationLinearTransform,
|
||||
};
|
||||
|
||||
struct Arguments
|
||||
{
|
||||
bool verbose;
|
||||
uint16_t frequency;
|
||||
bool gui = false;
|
||||
bool plot = false;
|
||||
std::string bandwidth;
|
||||
std::string outputFile;
|
||||
uint8_t mcs;
|
||||
uint16_t channelWidth;
|
||||
uint8_t spatialStreams;
|
||||
uint8_t txPower;
|
||||
uint16_t guardInterval;
|
||||
uint32_t injectDelay;
|
||||
uint32_t injectRepeat;
|
||||
std::string coding;
|
||||
std::string format;
|
||||
bool inject;
|
||||
bool measure;
|
||||
std::string mode;
|
||||
std::string ltf;
|
||||
std::string inputFile;
|
||||
std::map<enum processor, bool> processors;
|
||||
};
|
||||
|
||||
/* Get the input argument from argp_parse, which we
|
||||
know is a pointer to our arguments structure. */
|
||||
extern struct Arguments arguments;
|
||||
|
||||
#endif
|
||||
609
lib/include/ieee80211_radiotap.h
Normal file
609
lib/include/ieee80211_radiotap.h
Normal file
@ -0,0 +1,609 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Intel Deutschland GmbH
|
||||
* Copyright (c) 2018-2019, 2021-2022 Intel Corporation
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __RADIOTAP_H
|
||||
#define __RADIOTAP_H
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* struct __attribute__((__packed__)) ieee82011_radiotap_header - base radiotap header
|
||||
*/
|
||||
struct __attribute__((__packed__)) ieee80211_radiotap_header
|
||||
{
|
||||
/**
|
||||
* @it_version: radiotap version, always 0
|
||||
*/
|
||||
uint8_t it_version;
|
||||
|
||||
/**
|
||||
* @it_pad: padding (or alignment)
|
||||
*/
|
||||
uint8_t it_pad;
|
||||
|
||||
/**
|
||||
* @it_len: overall radiotap header length
|
||||
*/
|
||||
__le16 it_len;
|
||||
|
||||
/**
|
||||
* @it_present: (first) present word
|
||||
*/
|
||||
__le32 it_present;
|
||||
|
||||
/**
|
||||
* @it_optional: all remaining presence bitmaps
|
||||
*/
|
||||
uint8_t it_optional[500];
|
||||
};
|
||||
|
||||
/* version is always 0 */
|
||||
#define PKTHDR_RADIOTAP_VERSION 0
|
||||
|
||||
/* see the radiotap website for the descriptions */
|
||||
enum ieee80211_radiotap_presence
|
||||
{
|
||||
IEEE80211_RADIOTAP_TSFT = 0,
|
||||
IEEE80211_RADIOTAP_FLAGS = 1,
|
||||
IEEE80211_RADIOTAP_RATE = 2,
|
||||
IEEE80211_RADIOTAP_CHANNEL = 3,
|
||||
IEEE80211_RADIOTAP_FHSS = 4,
|
||||
IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5,
|
||||
IEEE80211_RADIOTAP_DBM_ANTNOISE = 6,
|
||||
IEEE80211_RADIOTAP_LOCK_QUALITY = 7,
|
||||
IEEE80211_RADIOTAP_TX_ATTENUATION = 8,
|
||||
IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9,
|
||||
IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
|
||||
IEEE80211_RADIOTAP_ANTENNA = 11,
|
||||
IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12,
|
||||
IEEE80211_RADIOTAP_DB_ANTNOISE = 13,
|
||||
IEEE80211_RADIOTAP_RX_FLAGS = 14,
|
||||
IEEE80211_RADIOTAP_TX_FLAGS = 15,
|
||||
IEEE80211_RADIOTAP_RTS_RETRIES = 16,
|
||||
IEEE80211_RADIOTAP_DATA_RETRIES = 17,
|
||||
/* 18 is XChannel, but it's not defined yet */
|
||||
IEEE80211_RADIOTAP_MCS = 19,
|
||||
IEEE80211_RADIOTAP_AMPDU_STATUS = 20,
|
||||
IEEE80211_RADIOTAP_VHT = 21,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP = 22,
|
||||
IEEE80211_RADIOTAP_HE = 23,
|
||||
IEEE80211_RADIOTAP_HE_MU = 24,
|
||||
IEEE80211_RADIOTAP_ZERO_LEN_PSDU = 26,
|
||||
IEEE80211_RADIOTAP_LSIG = 27,
|
||||
IEEE80211_RADIOTAP_TLV = 28,
|
||||
|
||||
/* valid in every it_present bitmap, even vendor namespaces */
|
||||
IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29,
|
||||
IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30,
|
||||
IEEE80211_RADIOTAP_EXT = 31,
|
||||
IEEE80211_RADIOTAP_EHT_USIG = 33,
|
||||
IEEE80211_RADIOTAP_EHT = 34,
|
||||
};
|
||||
|
||||
/* for IEEE80211_RADIOTAP_FLAGS */
|
||||
enum ieee80211_radiotap_flags
|
||||
{
|
||||
IEEE80211_RADIOTAP_F_CFP = 0x01,
|
||||
IEEE80211_RADIOTAP_F_SHORTPRE = 0x02,
|
||||
IEEE80211_RADIOTAP_F_WEP = 0x04,
|
||||
IEEE80211_RADIOTAP_F_FRAG = 0x08,
|
||||
IEEE80211_RADIOTAP_F_FCS = 0x10,
|
||||
IEEE80211_RADIOTAP_F_DATAPAD = 0x20,
|
||||
IEEE80211_RADIOTAP_F_BADFCS = 0x40,
|
||||
};
|
||||
|
||||
/* for IEEE80211_RADIOTAP_CHANNEL */
|
||||
enum ieee80211_radiotap_channel_flags
|
||||
{
|
||||
IEEE80211_CHAN_CCK = 0x0020,
|
||||
IEEE80211_CHAN_OFDM = 0x0040,
|
||||
IEEE80211_CHAN_2GHZ = 0x0080,
|
||||
IEEE80211_CHAN_5GHZ = 0x0100,
|
||||
IEEE80211_CHAN_DYN = 0x0400,
|
||||
IEEE80211_CHAN_HALF = 0x4000,
|
||||
IEEE80211_CHAN_QUARTER = 0x8000,
|
||||
};
|
||||
|
||||
/* for IEEE80211_RADIOTAP_RX_FLAGS */
|
||||
enum ieee80211_radiotap_rx_flags
|
||||
{
|
||||
IEEE80211_RADIOTAP_F_RX_BADPLCP = 0x0002,
|
||||
};
|
||||
|
||||
/* for IEEE80211_RADIOTAP_TX_FLAGS */
|
||||
enum ieee80211_radiotap_tx_flags
|
||||
{
|
||||
IEEE80211_RADIOTAP_F_TX_FAIL = 0x0001,
|
||||
IEEE80211_RADIOTAP_F_TX_CTS = 0x0002,
|
||||
IEEE80211_RADIOTAP_F_TX_RTS = 0x0004,
|
||||
IEEE80211_RADIOTAP_F_TX_NOACK = 0x0008,
|
||||
IEEE80211_RADIOTAP_F_TX_NOSEQNO = 0x0010,
|
||||
IEEE80211_RADIOTAP_F_TX_ORDER = 0x0020,
|
||||
};
|
||||
|
||||
/* for IEEE80211_RADIOTAP_MCS "have" flags */
|
||||
enum ieee80211_radiotap_mcs_have
|
||||
{
|
||||
IEEE80211_RADIOTAP_MCS_HAVE_BW = 0x01,
|
||||
IEEE80211_RADIOTAP_MCS_HAVE_MCS = 0x02,
|
||||
IEEE80211_RADIOTAP_MCS_HAVE_GI = 0x04,
|
||||
IEEE80211_RADIOTAP_MCS_HAVE_FMT = 0x08,
|
||||
IEEE80211_RADIOTAP_MCS_HAVE_FEC = 0x10,
|
||||
IEEE80211_RADIOTAP_MCS_HAVE_STBC = 0x20,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_mcs_flags
|
||||
{
|
||||
IEEE80211_RADIOTAP_MCS_BW_MASK = 0x03,
|
||||
IEEE80211_RADIOTAP_MCS_BW_20 = 0,
|
||||
IEEE80211_RADIOTAP_MCS_BW_40 = 1,
|
||||
IEEE80211_RADIOTAP_MCS_BW_20L = 2,
|
||||
IEEE80211_RADIOTAP_MCS_BW_20U = 3,
|
||||
|
||||
IEEE80211_RADIOTAP_MCS_SGI = 0x04,
|
||||
IEEE80211_RADIOTAP_MCS_FMT_GF = 0x08,
|
||||
IEEE80211_RADIOTAP_MCS_FEC_LDPC = 0x10,
|
||||
IEEE80211_RADIOTAP_MCS_STBC_MASK = 0x60,
|
||||
IEEE80211_RADIOTAP_MCS_STBC_1 = 1,
|
||||
IEEE80211_RADIOTAP_MCS_STBC_2 = 2,
|
||||
IEEE80211_RADIOTAP_MCS_STBC_3 = 3,
|
||||
IEEE80211_RADIOTAP_MCS_STBC_SHIFT = 5,
|
||||
};
|
||||
|
||||
/* for IEEE80211_RADIOTAP_AMPDU_STATUS */
|
||||
enum ieee80211_radiotap_ampdu_flags
|
||||
{
|
||||
IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN = 0x0001,
|
||||
IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN = 0x0002,
|
||||
IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN = 0x0004,
|
||||
IEEE80211_RADIOTAP_AMPDU_IS_LAST = 0x0008,
|
||||
IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR = 0x0010,
|
||||
IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN = 0x0020,
|
||||
IEEE80211_RADIOTAP_AMPDU_EOF = 0x0040,
|
||||
IEEE80211_RADIOTAP_AMPDU_EOF_KNOWN = 0x0080,
|
||||
};
|
||||
|
||||
/* for IEEE80211_RADIOTAP_VHT */
|
||||
enum ieee80211_radiotap_vht_known
|
||||
{
|
||||
IEEE80211_RADIOTAP_VHT_KNOWN_STBC = 0x0001,
|
||||
IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA = 0x0002,
|
||||
IEEE80211_RADIOTAP_VHT_KNOWN_GI = 0x0004,
|
||||
IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS = 0x0008,
|
||||
IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM = 0x0010,
|
||||
IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED = 0x0020,
|
||||
IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH = 0x0040,
|
||||
IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID = 0x0080,
|
||||
IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID = 0x0100,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_vht_flags
|
||||
{
|
||||
IEEE80211_RADIOTAP_VHT_FLAG_STBC = 0x01,
|
||||
IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA = 0x02,
|
||||
IEEE80211_RADIOTAP_VHT_FLAG_SGI = 0x04,
|
||||
IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9 = 0x08,
|
||||
IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM = 0x10,
|
||||
IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED = 0x20,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_vht_coding
|
||||
{
|
||||
IEEE80211_RADIOTAP_CODING_LDPC_USER0 = 0x01,
|
||||
IEEE80211_RADIOTAP_CODING_LDPC_USER1 = 0x02,
|
||||
IEEE80211_RADIOTAP_CODING_LDPC_USER2 = 0x04,
|
||||
IEEE80211_RADIOTAP_CODING_LDPC_USER3 = 0x08,
|
||||
};
|
||||
|
||||
/* for IEEE80211_RADIOTAP_TIMESTAMP */
|
||||
enum ieee80211_radiotap_timestamp_unit_spos
|
||||
{
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MASK = 0x000F,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_UNIT_MS = 0x0000,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_UNIT_US = 0x0001,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_UNIT_NS = 0x0003,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_SPOS_MASK = 0x00F0,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_SPOS_BEGIN_MDPU = 0x0000,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_SPOS_PLCP_SIG_ACQ = 0x0010,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_PPDU = 0x0020,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_SPOS_EO_MPDU = 0x0030,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_SPOS_UNKNOWN = 0x00F0,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_timestamp_flags
|
||||
{
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_FLAG_64BIT = 0x00,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_FLAG_32BIT = 0x01,
|
||||
IEEE80211_RADIOTAP_TIMESTAMP_FLAG_ACCURACY = 0x02,
|
||||
};
|
||||
|
||||
struct __attribute__((__packed__)) ieee80211_radiotap_he
|
||||
{
|
||||
__le16 data1, data2, data3, data4, data5, data6;
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_he_bits
|
||||
{
|
||||
IEEE80211_RADIOTAP_HE_DATA1_FORMAT_MASK = 3,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_FORMAT_SU = 0,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_FORMAT_EXT_SU = 1,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_FORMAT_MU = 2,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_FORMAT_TRIG = 3,
|
||||
|
||||
IEEE80211_RADIOTAP_HE_DATA1_BSS_COLOR_KNOWN = 0x0004,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_BEAM_CHANGE_KNOWN = 0x0008,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_UL_DL_KNOWN = 0x0010,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN = 0x0020,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_DATA_DCM_KNOWN = 0x0040,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_CODING_KNOWN = 0x0080,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_LDPC_XSYMSEG_KNOWN = 0x0100,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_STBC_KNOWN = 0x0200,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE_KNOWN = 0x0400,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE2_KNOWN = 0x0800,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE3_KNOWN = 0x1000,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_SPTL_REUSE4_KNOWN = 0x2000,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN = 0x4000,
|
||||
IEEE80211_RADIOTAP_HE_DATA1_DOPPLER_KNOWN = 0x8000,
|
||||
|
||||
IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_KNOWN = 0x0001,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN = 0x0002,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_NUM_LTF_SYMS_KNOWN = 0x0004,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_PRE_FEC_PAD_KNOWN = 0x0008,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_TXBF_KNOWN = 0x0010,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_PE_DISAMBIG_KNOWN = 0x0020,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_TXOP_KNOWN = 0x0040,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_MIDAMBLE_KNOWN = 0x0080,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET = 0x3f00,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET_KNOWN = 0x4000,
|
||||
IEEE80211_RADIOTAP_HE_DATA2_PRISEC_80_SEC = 0x8000,
|
||||
|
||||
IEEE80211_RADIOTAP_HE_DATA3_BSS_COLOR = 0x003f,
|
||||
IEEE80211_RADIOTAP_HE_DATA3_BEAM_CHANGE = 0x0040,
|
||||
IEEE80211_RADIOTAP_HE_DATA3_UL_DL = 0x0080,
|
||||
IEEE80211_RADIOTAP_HE_DATA3_DATA_MCS = 0x0f00,
|
||||
IEEE80211_RADIOTAP_HE_DATA3_DATA_DCM = 0x1000,
|
||||
IEEE80211_RADIOTAP_HE_DATA3_CODING = 0x2000,
|
||||
IEEE80211_RADIOTAP_HE_DATA3_LDPC_XSYMSEG = 0x4000,
|
||||
IEEE80211_RADIOTAP_HE_DATA3_STBC = 0x8000,
|
||||
|
||||
IEEE80211_RADIOTAP_HE_DATA4_SU_MU_SPTL_REUSE = 0x000f,
|
||||
IEEE80211_RADIOTAP_HE_DATA4_MU_STA_ID = 0x7ff0,
|
||||
IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE1 = 0x000f,
|
||||
IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE2 = 0x00f0,
|
||||
IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE3 = 0x0f00,
|
||||
IEEE80211_RADIOTAP_HE_DATA4_TB_SPTL_REUSE4 = 0xf000,
|
||||
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC = 0x000f,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_20MHZ = 0,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_40MHZ = 1,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_80MHZ = 2,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_160MHZ = 3,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_26T = 4,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_52T = 5,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_106T = 6,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_242T = 7,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_484T = 8,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_996T = 9,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_DATA_BW_RU_ALLOC_2x996T = 10,
|
||||
|
||||
IEEE80211_RADIOTAP_HE_DATA5_GI = 0x0030,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_GI_0_8 = 0,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_GI_1_6 = 1,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_GI_3_2 = 2,
|
||||
|
||||
IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE = 0x00c0,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_UNKNOWN = 0,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_1X = 1,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_2X = 2,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE_4X = 3,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_NUM_LTF_SYMS = 0x0700,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_PRE_FEC_PAD = 0x3000,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_TXBF = 0x4000,
|
||||
IEEE80211_RADIOTAP_HE_DATA5_PE_DISAMBIG = 0x8000,
|
||||
|
||||
IEEE80211_RADIOTAP_HE_DATA6_NSTS = 0x000f,
|
||||
IEEE80211_RADIOTAP_HE_DATA6_DOPPLER = 0x0010,
|
||||
IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_KNOWN = 0x0020,
|
||||
IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW = 0x00c0,
|
||||
IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_20MHZ = 0,
|
||||
IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_40MHZ = 1,
|
||||
IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_80MHZ = 2,
|
||||
IEEE80211_RADIOTAP_HE_DATA6_TB_PPDU_BW_160MHZ = 3,
|
||||
IEEE80211_RADIOTAP_HE_DATA6_TXOP = 0x7f00,
|
||||
IEEE80211_RADIOTAP_HE_DATA6_MIDAMBLE_PDCTY = 0x8000,
|
||||
};
|
||||
|
||||
struct __attribute__((__packed__)) ieee80211_radiotap_he_mu
|
||||
{
|
||||
__le16 flags1, flags2;
|
||||
uint8_t ru_ch1[4];
|
||||
uint8_t ru_ch2[4];
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_he_mu_bits
|
||||
{
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS = 0x000f,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_MCS_KNOWN = 0x0010,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_DCM = 0x0020,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_DCM_KNOWN = 0x0040,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH2_CTR_26T_RU_KNOWN = 0x0080,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_RU_KNOWN = 0x0100,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH2_RU_KNOWN = 0x0200,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_CTR_26T_RU_KNOWN = 0x1000,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_CH1_CTR_26T_RU = 0x2000,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_COMP_KNOWN = 0x4000,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS1_SIG_B_SYMS_USERS_KNOWN = 0x8000,
|
||||
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW = 0x0003,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_20MHZ = 0x0000,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_40MHZ = 0x0001,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_80MHZ = 0x0002,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_160MHZ = 0x0003,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_BW_FROM_SIG_A_BW_KNOWN = 0x0004,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_SIG_B_COMP = 0x0008,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_SIG_B_SYMS_USERS = 0x00f0,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_PUNC_FROM_SIG_A_BW = 0x0300,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN = 0x0400,
|
||||
IEEE80211_RADIOTAP_HE_MU_FLAGS2_CH2_CTR_26T_RU = 0x0800,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_lsig_data1
|
||||
{
|
||||
IEEE80211_RADIOTAP_LSIG_DATA1_RATE_KNOWN = 0x0001,
|
||||
IEEE80211_RADIOTAP_LSIG_DATA1_LENGTH_KNOWN = 0x0002,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_lsig_data2
|
||||
{
|
||||
IEEE80211_RADIOTAP_LSIG_DATA2_RATE = 0x000f,
|
||||
IEEE80211_RADIOTAP_LSIG_DATA2_LENGTH = 0xfff0,
|
||||
};
|
||||
|
||||
struct __attribute__((__packed__)) ieee80211_radiotap_lsig
|
||||
{
|
||||
__le16 data1, data2;
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_zero_len_psdu_type
|
||||
{
|
||||
IEEE80211_RADIOTAP_ZERO_LEN_PSDU_SOUNDING = 0,
|
||||
IEEE80211_RADIOTAP_ZERO_LEN_PSDU_NOT_CAPTURED = 1,
|
||||
IEEE80211_RADIOTAP_ZERO_LEN_PSDU_VENDOR = 0xff,
|
||||
};
|
||||
|
||||
struct __attribute__((__packed__)) ieee80211_radiotap_tlv
|
||||
{
|
||||
__le16 type;
|
||||
__le16 len;
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct __attribute__((__packed__)) ieee80211_radiotap_vendor_content - vendor radiotap content information
|
||||
* @oui: radiotap vendor namespace OUI
|
||||
* @oui_subtype: radiotap vendor sub namespace
|
||||
* @vendor_type: radiotap vendor type
|
||||
* @reserved: should always be set to zero (to avoid leaking memory)
|
||||
* @data: the actual vendor namespace data
|
||||
*/
|
||||
struct __attribute__((__packed__)) ieee80211_radiotap_vendor_content
|
||||
{
|
||||
uint8_t oui[3];
|
||||
uint8_t oui_subtype;
|
||||
__le16 vendor_type;
|
||||
__le16 reserved;
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct __attribute__((__packed__)) ieee80211_radiotap_vendor_tlv - vendor radiotap data information
|
||||
* @type: should always be set to IEEE80211_RADIOTAP_VENDOR_NAMESPACE
|
||||
* @len: length of data
|
||||
* @content: vendor content see @ieee80211_radiotap_vendor_content
|
||||
*/
|
||||
struct __attribute__((__packed__)) ieee80211_radiotap_vendor_tlv
|
||||
{
|
||||
__le16 type; /* IEEE80211_RADIOTAP_VENDOR_NAMESPACE */
|
||||
__le16 len;
|
||||
struct ieee80211_radiotap_vendor_content content;
|
||||
};
|
||||
|
||||
/* ieee80211_radiotap_eht_usig - content of U-SIG tlv (type 33)
|
||||
* see www.radiotap.org/fields/U-SIG.html for details
|
||||
*/
|
||||
struct __attribute__((__packed__)) ieee80211_radiotap_eht_usig
|
||||
{
|
||||
__le32 common;
|
||||
__le32 value;
|
||||
__le32 mask;
|
||||
};
|
||||
|
||||
/* ieee80211_radiotap_eht - content of EHT tlv (type 34)
|
||||
* see www.radiotap.org/fields/EHT.html for details
|
||||
*/
|
||||
struct __attribute__((__packed__)) ieee80211_radiotap_eht
|
||||
{
|
||||
__le32 known;
|
||||
__le32 data[9];
|
||||
__le32 user_info[];
|
||||
};
|
||||
|
||||
/* Known field for EHT TLV
|
||||
* The ending defines for what the field applies as following
|
||||
* O - OFDMA (including TB), M - MU-MIMO, S - EHT sounding.
|
||||
*/
|
||||
enum ieee80211_radiotap_eht_known
|
||||
{
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_SPATIAL_REUSE = 0x00000002,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_GI = 0x00000004,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_EHT_LTF = 0x00000010,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_LDPC_EXTRA_SYM_OM = 0x00000020,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_PRE_PADD_FACOR_OM = 0x00000040,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_PE_DISAMBIGUITY_OM = 0x00000080,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_DISREGARD_O = 0x00000100,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_DISREGARD_S = 0x00000200,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_CRC1 = 0x00002000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_TAIL1 = 0x00004000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_CRC2_O = 0x00008000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_TAIL2_O = 0x00010000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_NSS_S = 0x00020000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_BEAMFORMED_S = 0x00040000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_NR_NON_OFDMA_USERS_M = 0x00080000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_ENCODING_BLOCK_CRC_M = 0x00100000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_ENCODING_BLOCK_TAIL_M = 0x00200000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_RU_MRU_SIZE_OM = 0x00400000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_RU_MRU_INDEX_OM = 0x00800000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_RU_ALLOC_TB_FMT = 0x01000000,
|
||||
IEEE80211_RADIOTAP_EHT_KNOWN_PRIMARY_80 = 0x02000000,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_eht_data
|
||||
{
|
||||
/* Data 0 */
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_SPATIAL_REUSE = 0x00000078,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_GI = 0x00000180,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_LTF = 0x00000600,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_EHT_LTF = 0x00003800,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_LDPC_EXTRA_SYM_OM = 0x00004000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_PRE_PADD_FACOR_OM = 0x00018000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_PE_DISAMBIGUITY_OM = 0x00020000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_DISREGARD_S = 0x000c0000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_DISREGARD_O = 0x003c0000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_CRC1_O = 0x03c00000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA0_TAIL1_O = 0xfc000000,
|
||||
/* Data 1 */
|
||||
IEEE80211_RADIOTAP_EHT_DATA1_RU_SIZE = 0x0000001f,
|
||||
IEEE80211_RADIOTAP_EHT_DATA1_RU_INDEX = 0x00001fe0,
|
||||
IEEE80211_RADIOTAP_EHT_DATA1_RU_ALLOC_CC_1_1_1 = 0x003fe000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA1_RU_ALLOC_CC_1_1_1_KNOWN = 0x00400000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA1_PRIMARY_80 = 0xc0000000,
|
||||
/* Data 2 */
|
||||
IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_1 = 0x000001ff,
|
||||
IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_1_KNOWN = 0x00000200,
|
||||
IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_1_1_2 = 0x0007fc00,
|
||||
IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_1_1_2_KNOWN = 0x00080000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_2 = 0x1ff00000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA2_RU_ALLOC_CC_2_1_2_KNOWN = 0x20000000,
|
||||
/* Data 3 */
|
||||
IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_1 = 0x000001ff,
|
||||
IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_1_KNOWN = 0x00000200,
|
||||
IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_2_2_1 = 0x0007fc00,
|
||||
IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_2_2_1_KNOWN = 0x00080000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_2 = 0x1ff00000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA3_RU_ALLOC_CC_1_2_2_KNOWN = 0x20000000,
|
||||
/* Data 4 */
|
||||
IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_2 = 0x000001ff,
|
||||
IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_2_KNOWN = 0x00000200,
|
||||
IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_1_2_3 = 0x0007fc00,
|
||||
IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_1_2_3_KNOWN = 0x00080000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_3 = 0x1ff00000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA4_RU_ALLOC_CC_2_2_3_KNOWN = 0x20000000,
|
||||
/* Data 5 */
|
||||
IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_1_2_4 = 0x000001ff,
|
||||
IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_1_2_4_KNOWN = 0x00000200,
|
||||
IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_2_2_4 = 0x0007fc00,
|
||||
IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_2_2_4_KNOWN = 0x00080000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_1_2_5 = 0x1ff00000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA5_RU_ALLOC_CC_1_2_5_KNOWN = 0x20000000,
|
||||
/* Data 6 */
|
||||
IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_2_2_5 = 0x000001ff,
|
||||
IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_2_2_5_KNOWN = 0x00000200,
|
||||
IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_1_2_6 = 0x0007fc00,
|
||||
IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_1_2_6_KNOWN = 0x00080000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_2_2_6 = 0x1ff00000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA6_RU_ALLOC_CC_2_2_6_KNOWN = 0x20000000,
|
||||
/* Data 7 */
|
||||
IEEE80211_RADIOTAP_EHT_DATA7_CRC2_O = 0x0000000f,
|
||||
IEEE80211_RADIOTAP_EHT_DATA7_TAIL_2_O = 0x000003f0,
|
||||
IEEE80211_RADIOTAP_EHT_DATA7_NSS_S = 0x0000f000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA7_BEAMFORMED_S = 0x00010000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA7_NUM_OF_NON_OFDMA_USERS = 0x000e0000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA7_USER_ENCODING_BLOCK_CRC = 0x00f00000,
|
||||
IEEE80211_RADIOTAP_EHT_DATA7_USER_ENCODING_BLOCK_TAIL = 0x3f000000,
|
||||
/* Data 8 */
|
||||
IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_PS_160 = 0x00000001,
|
||||
IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B0 = 0x00000002,
|
||||
IEEE80211_RADIOTAP_EHT_DATA8_RU_ALLOC_TB_FMT_B7_B1 = 0x000001fc,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_eht_user_info
|
||||
{
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID_KNOWN = 0x00000001,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_MCS_KNOWN = 0x00000002,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_CODING_KNOWN = 0x00000004,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_KNOWN_O = 0x00000010,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_KNOWN_O = 0x00000020,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_SPATIAL_CONFIG_KNOWN_M = 0x00000040,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_DATA_FOR_USER = 0x00000080,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_STA_ID = 0x0007ff00,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_CODING = 0x00080000,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_MCS = 0x00f00000,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_NSS_O = 0x0f000000,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_BEAMFORMING_O = 0x20000000,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_SPATIAL_CONFIG_M = 0x3f000000,
|
||||
IEEE80211_RADIOTAP_EHT_USER_INFO_RESEVED_c0000000 = 0xc0000000,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_eht_usig_common
|
||||
{
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER_KNOWN = 0x00000001,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW_KNOWN = 0x00000002,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL_KNOWN = 0x00000004,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR_KNOWN = 0x00000008,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP_KNOWN = 0x00000010,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_BAD_USIG_CRC = 0x00000020,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_VALIDATE_BITS_CHECKED = 0x00000040,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_VALIDATE_BITS_OK = 0x00000080,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_PHY_VER = 0x00007000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_BW = 0x00038000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_UL_DL = 0x00040000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_BSS_COLOR = 0x01f80000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG_COMMON_TXOP = 0xfe000000,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_eht_usig_mu
|
||||
{
|
||||
/* MU-USIG-1 */
|
||||
IEEE80211_RADIOTAP_EHT_USIG1_MU_B0_B24_DISREGARD = 0x0000001f,
|
||||
IEEE80211_RADIOTAP_EHT_USIG1_MU_B25_VALIDATE = 0x00000020,
|
||||
/* MU-USIG-2 */
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_MU_B0_B1_PPDU_TYPE = 0x000000c0,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_MU_B2_VALIDATE = 0x00000100,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_MU_B3_B7_PUNCTURED_INFO = 0x00003e00,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_MU_B8_VALIDATE = 0x00004000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_MU_B9_B10_SIG_MCS = 0x00018000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_MU_B11_B15_EHT_SIG_SYMBOLS = 0x003e0000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_MU_B16_B19_CRC = 0x03c00000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_MU_B20_B25_TAIL = 0xfc000000,
|
||||
};
|
||||
|
||||
enum ieee80211_radiotap_eht_usig_tb
|
||||
{
|
||||
/* TB-USIG-1 */
|
||||
IEEE80211_RADIOTAP_EHT_USIG1_TB_B20_B25_DISREGARD = 0x0000001f,
|
||||
|
||||
/* TB-USIG-2 */
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_TB_B0_B1_PPDU_TYPE = 0x000000c0,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_TB_B2_VALIDATE = 0x00000100,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_TB_B3_B6_SPATIAL_REUSE_1 = 0x00001e00,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_TB_B7_B10_SPATIAL_REUSE_2 = 0x0001e000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_TB_B11_B15_DISREGARD = 0x003e0000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_TB_B16_B19_CRC = 0x03c00000,
|
||||
IEEE80211_RADIOTAP_EHT_USIG2_TB_B20_B25_TAIL = 0xfc000000,
|
||||
};
|
||||
|
||||
#endif /* __RADIOTAP_H */
|
||||
7815
lib/include/nl80211.h
Normal file
7815
lib/include/nl80211.h
Normal file
File diff suppressed because it is too large
Load Diff
349
lib/include/rs.h
Normal file
349
lib/include/rs.h
Normal file
@ -0,0 +1,349 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
||||
/*
|
||||
* Copyright (C) 2012-2014, 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2017 Intel Deutschland GmbH
|
||||
*/
|
||||
#ifndef __iwl_fw_api_rs_h__
|
||||
#define __iwl_fw_api_rs_h__
|
||||
|
||||
/*
|
||||
* rate_n_flags bit fields version 1
|
||||
*
|
||||
* The 32-bit value has different layouts in the low 8 bites depending on the
|
||||
* format. There are three formats, HT, VHT and legacy (11abg, with subformats
|
||||
* for CCK and OFDM).
|
||||
*
|
||||
* High-throughput (HT) rate format
|
||||
* bit 8 is 1, bit 26 is 0, bit 9 is 0 (OFDM)
|
||||
* Very High-throughput (VHT) rate format
|
||||
* bit 8 is 0, bit 26 is 1, bit 9 is 0 (OFDM)
|
||||
* Legacy OFDM rate format for bits 7:0
|
||||
* bit 8 is 0, bit 26 is 0, bit 9 is 0 (OFDM)
|
||||
* Legacy CCK rate format for bits 7:0:
|
||||
* bit 8 is 0, bit 26 is 0, bit 9 is 1 (CCK)
|
||||
*/
|
||||
|
||||
/* Bit 8: (1) HT format, (0) legacy or VHT format */
|
||||
#define RATE_MCS_HT_POS 8
|
||||
#define RATE_MCS_HT_MSK_V1 BIT(RATE_MCS_HT_POS)
|
||||
|
||||
/* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */
|
||||
#define RATE_MCS_CCK_POS_V1 9
|
||||
#define RATE_MCS_CCK_MSK_V1 BIT(RATE_MCS_CCK_POS_V1)
|
||||
|
||||
/* Bit 26: (1) VHT format, (0) legacy format in bits 8:0 */
|
||||
#define RATE_MCS_VHT_POS_V1 26
|
||||
#define RATE_MCS_VHT_MSK_V1 BIT(RATE_MCS_VHT_POS_V1)
|
||||
|
||||
/*
|
||||
* High-throughput (HT) rate format for bits 7:0
|
||||
*
|
||||
* 2-0: MCS rate base
|
||||
* 0) 6 Mbps
|
||||
* 1) 12 Mbps
|
||||
* 2) 18 Mbps
|
||||
* 3) 24 Mbps
|
||||
* 4) 36 Mbps
|
||||
* 5) 48 Mbps
|
||||
* 6) 54 Mbps
|
||||
* 7) 60 Mbps
|
||||
* 4-3: 0) Single stream (SISO)
|
||||
* 1) Dual stream (MIMO)
|
||||
* 2) Triple stream (MIMO)
|
||||
* 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data
|
||||
* (bits 7-6 are zero)
|
||||
*
|
||||
* Together the low 5 bits work out to the MCS index because we don't
|
||||
* support MCSes above 15/23, and 0-7 have one stream, 8-15 have two
|
||||
* streams and 16-23 have three streams. We could also support MCS 32
|
||||
* which is the duplicate 20 MHz MCS (bit 5 set, all others zero.)
|
||||
*/
|
||||
#define RATE_HT_MCS_RATE_CODE_MSK_V1 0x7
|
||||
#define RATE_HT_MCS_NSS_POS_V1 3
|
||||
#define RATE_HT_MCS_NSS_MSK_V1 (3 << RATE_HT_MCS_NSS_POS_V1)
|
||||
#define RATE_HT_MCS_MIMO2_MSK BIT(RATE_HT_MCS_NSS_POS_V1)
|
||||
|
||||
/* Bit 10: (1) Use Green Field preamble */
|
||||
#define RATE_HT_MCS_GF_POS 10
|
||||
#define RATE_HT_MCS_GF_MSK (1 << RATE_HT_MCS_GF_POS)
|
||||
|
||||
#define RATE_HT_MCS_INDEX_MSK_V1 0x3f
|
||||
|
||||
/*
|
||||
* Very High-throughput (VHT) rate format for bits 7:0
|
||||
*
|
||||
* 3-0: VHT MCS (0-9)
|
||||
* 5-4: number of streams - 1:
|
||||
* 0) Single stream (SISO)
|
||||
* 1) Dual stream (MIMO)
|
||||
* 2) Triple stream (MIMO)
|
||||
*/
|
||||
|
||||
/* Bit 4-5: (0) SISO, (1) MIMO2 (2) MIMO3 */
|
||||
#define RATE_VHT_MCS_RATE_CODE_MSK 0xf
|
||||
|
||||
/*
|
||||
* Legacy OFDM rate format for bits 7:0
|
||||
*
|
||||
* 3-0: 0xD) 6 Mbps
|
||||
* 0xF) 9 Mbps
|
||||
* 0x5) 12 Mbps
|
||||
* 0x7) 18 Mbps
|
||||
* 0x9) 24 Mbps
|
||||
* 0xB) 36 Mbps
|
||||
* 0x1) 48 Mbps
|
||||
* 0x3) 54 Mbps
|
||||
* (bits 7-4 are 0)
|
||||
*
|
||||
* Legacy CCK rate format for bits 7:0:
|
||||
* bit 8 is 0, bit 26 is 0, bit 9 is 1 (CCK):
|
||||
*
|
||||
* 6-0: 10) 1 Mbps
|
||||
* 20) 2 Mbps
|
||||
* 55) 5.5 Mbps
|
||||
* 110) 11 Mbps
|
||||
* (bit 7 is 0)
|
||||
*/
|
||||
#define RATE_LEGACY_RATE_MSK_V1 0xff
|
||||
|
||||
/* Bit 10 - OFDM HE */
|
||||
#define RATE_MCS_HE_POS_V1 10
|
||||
#define RATE_MCS_HE_MSK_V1 BIT(RATE_MCS_HE_POS_V1)
|
||||
|
||||
/*
|
||||
* Bit 11-12: (0) 20MHz, (1) 40MHz, (2) 80MHz, (3) 160MHz
|
||||
* 0 and 1 are valid for HT and VHT, 2 and 3 only for VHT
|
||||
*/
|
||||
#define RATE_MCS_CHAN_WIDTH_POS 11
|
||||
#define RATE_MCS_CHAN_WIDTH_MSK_V1 (3 << RATE_MCS_CHAN_WIDTH_POS)
|
||||
|
||||
/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */
|
||||
#define RATE_MCS_SGI_POS_V1 13
|
||||
#define RATE_MCS_SGI_MSK_V1 BIT(RATE_MCS_SGI_POS_V1)
|
||||
|
||||
/* Bit 14-16: Antenna selection (1) Ant A, (2) Ant B, (4) Ant C */
|
||||
#define RATE_MCS_ANT_POS 14
|
||||
#define RATE_MCS_ANT_A_MSK (1 << RATE_MCS_ANT_POS)
|
||||
#define RATE_MCS_ANT_B_MSK (2 << RATE_MCS_ANT_POS)
|
||||
#define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | \
|
||||
RATE_MCS_ANT_B_MSK)
|
||||
#define RATE_MCS_ANT_MSK RATE_MCS_ANT_AB_MSK
|
||||
|
||||
/* Bit 17: (0) SS, (1) SS*2 */
|
||||
#define RATE_MCS_STBC_POS 17
|
||||
#define RATE_MCS_STBC_MSK BIT(RATE_MCS_STBC_POS)
|
||||
|
||||
/* Bit 18: OFDM-HE dual carrier mode */
|
||||
#define RATE_HE_DUAL_CARRIER_MODE 18
|
||||
#define RATE_HE_DUAL_CARRIER_MODE_MSK BIT(RATE_HE_DUAL_CARRIER_MODE)
|
||||
|
||||
/* Bit 19: (0) Beamforming is off, (1) Beamforming is on */
|
||||
#define RATE_MCS_BF_POS 19
|
||||
#define RATE_MCS_BF_MSK (1 << RATE_MCS_BF_POS)
|
||||
|
||||
/*
|
||||
* Bit 20-21: HE LTF type and guard interval
|
||||
* HE (ext) SU:
|
||||
* 0 1xLTF+0.8us
|
||||
* 1 2xLTF+0.8us
|
||||
* 2 2xLTF+1.6us
|
||||
* 3 & SGI (bit 13) clear 4xLTF+3.2us
|
||||
* 3 & SGI (bit 13) set 4xLTF+0.8us
|
||||
* HE MU:
|
||||
* 0 4xLTF+0.8us
|
||||
* 1 2xLTF+0.8us
|
||||
* 2 2xLTF+1.6us
|
||||
* 3 4xLTF+3.2us
|
||||
* HE-EHT TRIG:
|
||||
* 0 1xLTF+1.6us
|
||||
* 1 2xLTF+1.6us
|
||||
* 2 4xLTF+3.2us
|
||||
* 3 (does not occur)
|
||||
* EHT MU:
|
||||
* 0 2xLTF+0.8us
|
||||
* 1 2xLTF+1.6us
|
||||
* 2 4xLTF+0.8us
|
||||
* 3 4xLTF+3.2us
|
||||
*/
|
||||
#define RATE_MCS_HE_GI_LTF_POS 20
|
||||
#define RATE_MCS_HE_GI_LTF_MSK_V1 (3 << RATE_MCS_HE_GI_LTF_POS)
|
||||
|
||||
/* Bit 22-23: HE type. (0) SU, (1) SU_EXT, (2) MU, (3) trigger based */
|
||||
#define RATE_MCS_HE_TYPE_POS_V1 22
|
||||
#define RATE_MCS_HE_TYPE_SU_V1 (0 << RATE_MCS_HE_TYPE_POS_V1)
|
||||
#define RATE_MCS_HE_TYPE_EXT_SU_V1 BIT(RATE_MCS_HE_TYPE_POS_V1)
|
||||
#define RATE_MCS_HE_TYPE_MU_V1 (2 << RATE_MCS_HE_TYPE_POS_V1)
|
||||
#define RATE_MCS_HE_TYPE_TRIG_V1 (3 << RATE_MCS_HE_TYPE_POS_V1)
|
||||
#define RATE_MCS_HE_TYPE_MSK_V1 (3 << RATE_MCS_HE_TYPE_POS_V1)
|
||||
|
||||
/* Bit 24-25: (0) 20MHz (no dup), (1) 2x20MHz, (2) 4x20MHz, 3 8x20MHz */
|
||||
#define RATE_MCS_DUP_POS_V1 24
|
||||
#define RATE_MCS_DUP_MSK_V1 (3 << RATE_MCS_DUP_POS_V1)
|
||||
|
||||
/* Bit 27: (1) LDPC enabled, (0) LDPC disabled */
|
||||
#define RATE_MCS_LDPC_POS_V1 27
|
||||
#define RATE_MCS_LDPC_MSK_V1 BIT(RATE_MCS_LDPC_POS_V1)
|
||||
|
||||
/* Bit 28: (1) 106-tone RX (8 MHz RU), (0) normal bandwidth */
|
||||
#define RATE_MCS_HE_106T_POS_V1 28
|
||||
#define RATE_MCS_HE_106T_MSK_V1 BIT(RATE_MCS_HE_106T_POS_V1)
|
||||
|
||||
/* Bit 30-31: (1) RTS, (2) CTS */
|
||||
#define RATE_MCS_RTS_REQUIRED_POS (30)
|
||||
#define RATE_MCS_RTS_REQUIRED_MSK (0x1 << RATE_MCS_RTS_REQUIRED_POS)
|
||||
|
||||
#define RATE_MCS_CTS_REQUIRED_POS (31)
|
||||
#define RATE_MCS_CTS_REQUIRED_MSK (0x1 << RATE_MCS_CTS_REQUIRED_POS)
|
||||
|
||||
/* rate_n_flags bit field version 2
|
||||
*
|
||||
* The 32-bit value has different layouts in the low 8 bits depending on the
|
||||
* format. There are three formats, HT, VHT and legacy (11abg, with subformats
|
||||
* for CCK and OFDM).
|
||||
*
|
||||
*/
|
||||
|
||||
/* Bits 10-8: rate format
|
||||
* (0) Legacy CCK (1) Legacy OFDM (2) High-throughput (HT)
|
||||
* (3) Very High-throughput (VHT) (4) High-efficiency (HE)
|
||||
* (5) Extremely High-throughput (EHT)
|
||||
*/
|
||||
#define RATE_MCS_MOD_TYPE_POS 8
|
||||
#define RATE_MCS_MOD_TYPE_MSK (0x7 << RATE_MCS_MOD_TYPE_POS)
|
||||
#define RATE_MCS_CCK_MSK (0 << RATE_MCS_MOD_TYPE_POS)
|
||||
#define RATE_MCS_LEGACY_OFDM_MSK (1 << RATE_MCS_MOD_TYPE_POS)
|
||||
#define RATE_MCS_HT_MSK (2 << RATE_MCS_MOD_TYPE_POS)
|
||||
#define RATE_MCS_VHT_MSK (3 << RATE_MCS_MOD_TYPE_POS)
|
||||
#define RATE_MCS_HE_MSK (4 << RATE_MCS_MOD_TYPE_POS)
|
||||
#define RATE_MCS_EHT_MSK (5 << RATE_MCS_MOD_TYPE_POS)
|
||||
|
||||
/*
|
||||
* Legacy CCK rate format for bits 0:3:
|
||||
*
|
||||
* (0) 0xa - 1 Mbps
|
||||
* (1) 0x14 - 2 Mbps
|
||||
* (2) 0x37 - 5.5 Mbps
|
||||
* (3) 0x6e - 11 nbps
|
||||
*
|
||||
* Legacy OFDM rate format for bis 3:0:
|
||||
*
|
||||
* (0) 6 Mbps
|
||||
* (1) 9 Mbps
|
||||
* (2) 12 Mbps
|
||||
* (3) 18 Mbps
|
||||
* (4) 24 Mbps
|
||||
* (5) 36 Mbps
|
||||
* (6) 48 Mbps
|
||||
* (7) 54 Mbps
|
||||
*
|
||||
*/
|
||||
#define RATE_LEGACY_RATE_MSK 0x7
|
||||
|
||||
/*
|
||||
* HT, VHT, HE, EHT rate format for bits 3:0
|
||||
* 3-0: MCS
|
||||
*
|
||||
*/
|
||||
#define RATE_HT_MCS_CODE_MSK 0x7
|
||||
#define RATE_MCS_NSS_POS 4
|
||||
#define RATE_MCS_NSS_MSK (1 << RATE_MCS_NSS_POS)
|
||||
#define RATE_MCS_CODE_MSK 0xf
|
||||
#define RATE_HT_MCS_INDEX(r) ((((r)&RATE_MCS_NSS_MSK) >> 1) | \
|
||||
((r)&RATE_HT_MCS_CODE_MSK))
|
||||
|
||||
/* Bits 7-5: reserved */
|
||||
|
||||
/*
|
||||
* Bits 13-11: (0) 20MHz, (1) 40MHz, (2) 80MHz, (3) 160MHz, (4) 320MHz
|
||||
*/
|
||||
#define RATE_MCS_CHAN_WIDTH_MSK (0x7 << RATE_MCS_CHAN_WIDTH_POS)
|
||||
#define RATE_MCS_CHAN_WIDTH_20_VAL 0
|
||||
#define RATE_MCS_CHAN_WIDTH_20 (RATE_MCS_CHAN_WIDTH_20_VAL << RATE_MCS_CHAN_WIDTH_POS)
|
||||
#define RATE_MCS_CHAN_WIDTH_40_VAL 1
|
||||
#define RATE_MCS_CHAN_WIDTH_40 (RATE_MCS_CHAN_WIDTH_40_VAL << RATE_MCS_CHAN_WIDTH_POS)
|
||||
#define RATE_MCS_CHAN_WIDTH_80_VAL 2
|
||||
#define RATE_MCS_CHAN_WIDTH_80 (RATE_MCS_CHAN_WIDTH_80_VAL << RATE_MCS_CHAN_WIDTH_POS)
|
||||
#define RATE_MCS_CHAN_WIDTH_160_VAL 3
|
||||
#define RATE_MCS_CHAN_WIDTH_160 (RATE_MCS_CHAN_WIDTH_160_VAL << RATE_MCS_CHAN_WIDTH_POS)
|
||||
#define RATE_MCS_CHAN_WIDTH_320_VAL 4
|
||||
#define RATE_MCS_CHAN_WIDTH_320 (RATE_MCS_CHAN_WIDTH_320_VAL << RATE_MCS_CHAN_WIDTH_POS)
|
||||
|
||||
/* Bit 15-14: Antenna selection:
|
||||
* Bit 14: Ant A active
|
||||
* Bit 15: Ant B active
|
||||
*
|
||||
* All relevant definitions are same as in v1
|
||||
*/
|
||||
|
||||
/* Bit 16 (1) LDPC enables, (0) LDPC disabled */
|
||||
#define RATE_MCS_LDPC_POS 16
|
||||
#define RATE_MCS_LDPC_MSK (1 << RATE_MCS_LDPC_POS)
|
||||
|
||||
/* Bit 17: (0) SS, (1) SS*2 (same as v1) */
|
||||
|
||||
/* Bit 18: OFDM-HE dual carrier mode (same as v1) */
|
||||
|
||||
/* Bit 19: (0) Beamforming is off, (1) Beamforming is on (same as v1) */
|
||||
|
||||
/*
|
||||
* Bit 22-20: HE LTF type and guard interval
|
||||
* CCK:
|
||||
* 0 long preamble
|
||||
* 1 short preamble
|
||||
* HT/VHT:
|
||||
* 0 0.8us
|
||||
* 1 0.4us
|
||||
* HE (ext) SU:
|
||||
* 0 1xLTF+0.8us
|
||||
* 1 2xLTF+0.8us
|
||||
* 2 2xLTF+1.6us
|
||||
* 3 4xLTF+3.2us
|
||||
* 4 4xLTF+0.8us
|
||||
* HE MU:
|
||||
* 0 4xLTF+0.8us
|
||||
* 1 2xLTF+0.8us
|
||||
* 2 2xLTF+1.6us
|
||||
* 3 4xLTF+3.2us
|
||||
* HE TRIG:
|
||||
* 0 1xLTF+1.6us
|
||||
* 1 2xLTF+1.6us
|
||||
* 2 4xLTF+3.2us
|
||||
* */
|
||||
#define RATE_MCS_HE_GI_LTF_MSK (0x7 << RATE_MCS_HE_GI_LTF_POS)
|
||||
#define RATE_MCS_SGI_POS RATE_MCS_HE_GI_LTF_POS
|
||||
#define RATE_MCS_SGI_MSK (1 << RATE_MCS_SGI_POS)
|
||||
#define RATE_MCS_HE_SU_4_LTF 3
|
||||
#define RATE_MCS_HE_SU_4_LTF_08_GI 4
|
||||
|
||||
/* Bit 24-23: HE type. (0) SU, (1) SU_EXT, (2) MU, (3) trigger based */
|
||||
#define RATE_MCS_HE_TYPE_POS 23
|
||||
#define RATE_MCS_HE_TYPE_SU (0 << RATE_MCS_HE_TYPE_POS)
|
||||
#define RATE_MCS_HE_TYPE_EXT_SU (1 << RATE_MCS_HE_TYPE_POS)
|
||||
#define RATE_MCS_HE_TYPE_MU (2 << RATE_MCS_HE_TYPE_POS)
|
||||
#define RATE_MCS_HE_TYPE_TRIG (3 << RATE_MCS_HE_TYPE_POS)
|
||||
#define RATE_MCS_HE_TYPE_MSK (3 << RATE_MCS_HE_TYPE_POS)
|
||||
|
||||
/* Bit 25: duplicate channel enabled
|
||||
*
|
||||
* if this bit is set, duplicate is according to BW (bits 11-13):
|
||||
*
|
||||
* CCK: 2x 20MHz
|
||||
* OFDM Legacy: N x 20Mhz, (N = BW \ 2 , either 2, 4, 8, 16)
|
||||
* EHT: 2 x BW/2, (80 - 2x40, 160 - 2x80, 320 - 2x160)
|
||||
* */
|
||||
#define RATE_MCS_DUP_POS 25
|
||||
#define RATE_MCS_DUP_MSK (1 << RATE_MCS_DUP_POS)
|
||||
|
||||
/* Bit 26: (1) 106-tone RX (8 MHz RU), (0) normal bandwidth */
|
||||
#define RATE_MCS_HE_106T_POS 26
|
||||
#define RATE_MCS_HE_106T_MSK (1 << RATE_MCS_HE_106T_POS)
|
||||
|
||||
/* Bit 27: EHT extra LTF:
|
||||
* instead of 1 LTF for SISO use 2 LTFs,
|
||||
* instead of 2 LTFs for NSTS=2 use 4 LTFs*/
|
||||
#define RATE_MCS_EHT_EXTRA_LTF_POS 27
|
||||
#define RATE_MCS_EHT_EXTRA_LTF_MSK (1 << RATE_MCS_EHT_EXTRA_LTF_POS)
|
||||
|
||||
/* Bit 31-28: reserved */
|
||||
|
||||
#endif /* __iwl_fw_api_rs_h__ */
|
||||
46
readme.md
Normal file
46
readme.md
Normal file
@ -0,0 +1,46 @@
|
||||
# FeitCSI, the 802.11 CSI tool
|
||||
|
||||
FeitCSI is the **first open-source** tool that enables CSI extraction and injection frames for **all formats (802.11a/g/n/ac/ax)** in **all bandwidths (20/40/80/160 MHz)** from commodity intel NIC **AX200, AX210** (There is high possibility that newest intel NIC is also supported). The aim of FeitCSI tool is:
|
||||
|
||||
: - **easy to use**, providing a tool in different formats source, binary, and also live distribution with a tool for virtual environments or live USB and other discs
|
||||
- **high availability** on different devices (e.g. x86_64, arm)
|
||||
- **open-source**, which allows the community to contribute and improve this tool for purpose of future researches and next activities
|
||||
|
||||
---
|
||||
|
||||
## Functionality
|
||||
FeitCSI allows you to **extract CSI** and **inject frames** for **all frames 802.11a/g/n/ac/ax** and **all bandwidths (20/40/80/160 MHz) with NO LIMITS**. Based on the NIC used also **6 GHz band is supported** (5945 - 7125 MHz). The main tool provides for users [Command line interface](command_line_interface.md) where can set up all parameters. For users less proficient at the command line and for comfortable tuning parameters [Graphical user interface](graphical_user_interface.md) is provided.
|
||||
|
||||
!!! Warning
|
||||
FeitCSI is unlocked for all supported bands, channels, etc. You are responsible for following the laws of the country, frequency, and power levels in which the device is used.
|
||||
|
||||
Are you prepared? Read [Getting started](getting_started.md) guide.
|
||||
|
||||
---
|
||||
|
||||
## For users
|
||||
|
||||
Any use of the Software which results in an academic publication or other publication which includes a bibliography must include
|
||||
citations to the FeitCSI project:
|
||||
|
||||
"Miroslav Hutar, Peter Brida and Juraj Machaj. FeitCSI, the 802.11 CSI tool. https://feitcsi.kuskosoft.com"
|
||||
```
|
||||
@electronic{feitcsi:project,
|
||||
author = {Hutar, Miroslav and Brida, Peter and Machaj, Juraj},
|
||||
title = {FeitCSI, the 802.11 CSI tool},
|
||||
url = {https://feitcsi.kuskosoft.com},
|
||||
year = {2023}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Competition
|
||||
There are some platforms, that are used to extract CSI from commodity hardware. However, they don't support current standards or injection packets. The only one competition is PicoScenes. It is a robust and good platform but FeitCSI has several advantages against it:
|
||||
|
||||
* **All for free without limits** (Some of the functionality (full 6GHz spectrum, packet injection in 11ac/ax format with 80/160MHz channel bandwidth, ...) are allowed after payment for the license in PicoScenes)
|
||||
* **No restriction to specific version of Linux OS and computer architecture** (PicoScenes work only on CPU with SSE4.2 or AVX2 and you need to have Ubuntu 20.04 LTS or its variants. **FeitCSI will work on every computer architecture** where can be installed Linux (e.g. x86-64, ARM). But of course, you have to plug NICs via PCI.)
|
||||
* **Support virtual environment** (If you don't want to install software on your computer or you have trouble, just download our prepared image of FeitCSI and enjoy FeitCSI in the virtual environment. Follow the steps in [Getting started - Virtual environment](getting_started.md#virtual-environment))
|
||||
* **Live medium** (Our image can be also used in live medium (e.g. USB), not only in the virtual environment)
|
||||
* **No data collection** (PicoScenes has in eula that you agree to fill and share real information about your affiliation and research team also they collected and use statistics on selected information on your computer, including but not limited to computer hardware information, non-personal files on your computer and data or files generated by its software. Based on the last words your CSI data aren't safe. Looks a bit like spyware to me)
|
||||
* **User friendly GUI application** (We provide a GUI application where you can fast-tune parameters by filling in fields in the form)
|
||||
391
src/Csi.cpp
Normal file
391
src/Csi.cpp
Normal file
@ -0,0 +1,391 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "Csi.h"
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iterator>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <filesystem>
|
||||
#include "main.h"
|
||||
#include "rs.h"
|
||||
#include "Logger.h"
|
||||
|
||||
Csi::Csi()
|
||||
{
|
||||
}
|
||||
|
||||
Csi::~Csi()
|
||||
{
|
||||
if (this->rawCsiData)
|
||||
{
|
||||
delete rawCsiData;
|
||||
}
|
||||
}
|
||||
|
||||
void Csi::loadFromFile(std::string fileName)
|
||||
{
|
||||
std::ifstream ifs(fileName, std::ios::binary);
|
||||
ifs.read((char *)&this->rawHeaderData, CSI_HEADER_LENGTH);
|
||||
this->rawCsiData = new uint8_t[this->rawHeaderData.csiDataSize];
|
||||
|
||||
// uint8_t rawCsiData[this->rawHeaderData.csiDataSize];
|
||||
|
||||
ifs.read((char *)this->rawCsiData, this->rawHeaderData.csiDataSize);
|
||||
|
||||
this->processRawCsi();
|
||||
}
|
||||
|
||||
void Csi::loadFromMemory(uint8_t *pHeader, uint8_t *pRawCsiData)
|
||||
{
|
||||
memcpy(&this->rawHeaderData, pHeader, CSI_HEADER_LENGTH);
|
||||
this->rawCsiData = new uint8_t[this->rawHeaderData.csiDataSize];
|
||||
memcpy(this->rawCsiData, pRawCsiData, this->rawHeaderData.csiDataSize);
|
||||
|
||||
this->processRawCsi();
|
||||
}
|
||||
|
||||
void Csi::loadFromMemory(uint8_t *rawData)
|
||||
{
|
||||
memcpy(&this->rawHeaderData, rawData, CSI_HEADER_LENGTH);
|
||||
this->rawCsiData = new uint8_t[this->rawHeaderData.csiDataSize];
|
||||
memcpy(this->rawCsiData, &rawData[CSI_HEADER_LENGTH], this->rawHeaderData.csiDataSize);
|
||||
this->processRawCsi();
|
||||
}
|
||||
|
||||
void Csi::save()
|
||||
{
|
||||
std::ofstream outfile;
|
||||
outfile.open(arguments.outputFile, std::ios_base::app | std::ios::binary);
|
||||
if (outfile.fail())
|
||||
{
|
||||
throw std::ios_base::failure("Open file failed: " + std::string(std::strerror(errno)));
|
||||
}
|
||||
outfile.write(reinterpret_cast<char *>(&this->rawHeaderData), sizeof(RawHeaderData));
|
||||
outfile.write(reinterpret_cast<char *>(this->rawCsiData), this->rawHeaderData.csiDataSize);
|
||||
outfile.close();
|
||||
std::filesystem::permissions(arguments.outputFile, std::filesystem::perms::all & ~(std::filesystem::perms::owner_exec | std::filesystem::perms::group_exec | std::filesystem::perms::others_exec), std::filesystem::perm_options::add);
|
||||
}
|
||||
|
||||
void Csi::fixCsiBug()
|
||||
{
|
||||
if (this->channelWidth != RATE_MCS_CHAN_WIDTH_160)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->format != RATE_MCS_VHT_MSK && this->format != RATE_MCS_HE_MSK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t newSubcarrierSize = 0;
|
||||
if (this->format == RATE_MCS_VHT_MSK && this->rawHeaderData.numSubCarriers == 484)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (this->format == RATE_MCS_VHT_MSK)
|
||||
{
|
||||
newSubcarrierSize = 484;
|
||||
}
|
||||
|
||||
if (this->format == RATE_MCS_HE_MSK && this->rawHeaderData.numSubCarriers == 1992)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (this->format == RATE_MCS_HE_MSK)
|
||||
{
|
||||
newSubcarrierSize = 1992;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < this->rawHeaderData.csiDataSize; i = i + 4)
|
||||
{
|
||||
if (format == RATE_MCS_VHT_MSK)
|
||||
{
|
||||
if (i > (241 * 4) && i < (256 * 4)) // Fix the firmware bug
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t newTotalSize = newSubcarrierSize * 4 *this->numRx * this->numTx;
|
||||
uint8_t fixedCsiData[newTotalSize];
|
||||
|
||||
uint32_t newIndex = 0;
|
||||
uint32_t oldIndex = 0;
|
||||
for (uint32_t rx = 0; rx < this->numRx; rx++)
|
||||
{
|
||||
for (uint32_t tx = 0; tx < this->numTx; tx++)
|
||||
{
|
||||
for (uint32_t n = 0; n < this->numSubCarriers; n++)
|
||||
{
|
||||
if (this->format == RATE_MCS_VHT_MSK)
|
||||
{
|
||||
if (n > 241 && n < 256)
|
||||
{
|
||||
oldIndex += 4;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (this->format == RATE_MCS_HE_MSK)
|
||||
{
|
||||
if (n > 995 && n < 1024)
|
||||
{
|
||||
oldIndex += 4;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
memcpy(&fixedCsiData[newIndex], &this->rawCsiData[oldIndex], 4);
|
||||
oldIndex += 4;
|
||||
newIndex += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->numSubCarriers = newSubcarrierSize;
|
||||
this->rawHeaderData.numSubCarriers = this->numSubCarriers;
|
||||
this->rawHeaderData.csiDataSize = newTotalSize;
|
||||
delete this->rawCsiData;
|
||||
this->rawCsiData = new uint8_t[newTotalSize];
|
||||
memcpy(this->rawCsiData, fixedCsiData, newTotalSize);
|
||||
}
|
||||
|
||||
void Csi::processRawCsi()
|
||||
{
|
||||
this->numRx = this->rawHeaderData.numRx;
|
||||
this->numTx = this->rawHeaderData.numTx;
|
||||
this->numSubCarriers = this->rawHeaderData.numSubCarriers;
|
||||
|
||||
this->format = this->rawHeaderData.rateNflag & RATE_MCS_MOD_TYPE_MSK;
|
||||
this->channelWidth = this->rawHeaderData.rateNflag & RATE_MCS_CHAN_WIDTH_MSK;
|
||||
|
||||
this->fixCsiBug();
|
||||
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < this->rawHeaderData.csiDataSize; i = i + 4)
|
||||
{
|
||||
int16_t real = this->rawCsiData[i] | this->rawCsiData[i + 1] << 8;
|
||||
int16_t imag = this->rawCsiData[i + 2] | this->rawCsiData[i + 3] << 8;
|
||||
|
||||
|
||||
/* if (format == RATE_MCS_VHT_MSK)
|
||||
{
|
||||
if (i > (241 * 4) && i < (256 * 4)) // Fix the firmware bug
|
||||
continue;
|
||||
} */
|
||||
|
||||
const std::complex<double> c(real, imag);
|
||||
this->csi.push_back(c);
|
||||
this->magnitude.push_back(std::abs(c));
|
||||
this->phase.push_back(std::arg(c));
|
||||
}
|
||||
|
||||
//this->unwrapPhase();
|
||||
|
||||
if (arguments.verbose)
|
||||
{
|
||||
Logger::log(info) << "Subcarrier count: " << this->rawHeaderData.numSubCarriers << ", ";
|
||||
Logger::log(info, true) << "RX: " << +this->rawHeaderData.numRx << ", ";
|
||||
Logger::log(info, true) << "TX: " << +this->rawHeaderData.numTx << ", ";
|
||||
|
||||
switch (channelWidth)
|
||||
{
|
||||
case RATE_MCS_CHAN_WIDTH_20:
|
||||
Logger::log(info, true) << "Channel width: 20, ";
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_40:
|
||||
Logger::log(info, true) << "Channel width: 40, ";
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_80:
|
||||
Logger::log(info, true) << "Channel width: 80, ";
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_160:
|
||||
Logger::log(info, true) << "Channel width: 160, ";
|
||||
break;
|
||||
}
|
||||
switch (format)
|
||||
{
|
||||
case RATE_MCS_CCK_MSK: // VERY OLD FORMAT
|
||||
Logger::log(info, true) << "Format: CCK\n";
|
||||
break;
|
||||
case RATE_MCS_LEGACY_OFDM_MSK:
|
||||
Logger::log(info, true) << "Format: LEGACY_OFDM\n";
|
||||
break;
|
||||
break;
|
||||
case RATE_MCS_HT_MSK:
|
||||
Logger::log(info, true) << "Format: HT\n";
|
||||
break;
|
||||
break;
|
||||
case RATE_MCS_VHT_MSK:
|
||||
Logger::log(info, true) << "Format: VHT\n";
|
||||
break;
|
||||
break;
|
||||
case RATE_MCS_HE_MSK:
|
||||
Logger::log(info, true) << "Format: HE\n";
|
||||
break;
|
||||
break;
|
||||
case RATE_MCS_EHT_MSK:
|
||||
Logger::log(info, true) << "Format: EHT\n";
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Csi::backup()
|
||||
{
|
||||
if (this->csiBackup.empty())
|
||||
{
|
||||
this->csiBackup = this->csi;
|
||||
}
|
||||
}
|
||||
|
||||
void Csi::restore()
|
||||
{
|
||||
this->csi = this->csiBackup;
|
||||
this->recalcMagnitudePhase();
|
||||
}
|
||||
|
||||
void Csi::magnitudePhaseToComplex()
|
||||
{
|
||||
for (uint32_t i = 0; i < this->csi.size(); i++)
|
||||
{
|
||||
this->csi[i].real(this->magnitude[i] * cos(this->phase[i]));
|
||||
this->csi[i].imag(this->magnitude[i] * sin(this->phase[i]));
|
||||
}
|
||||
}
|
||||
|
||||
void Csi::recalcMagnitudePhase()
|
||||
{
|
||||
this->magnitude.clear();
|
||||
this->phase.clear();
|
||||
for (std::complex<double> c : this->csi)
|
||||
{
|
||||
this->magnitude.push_back(std::abs(c));
|
||||
this->phase.push_back(std::arg(c));
|
||||
}
|
||||
//this->unwrapPhase();
|
||||
}
|
||||
|
||||
const std::vector<uint32_t> Csi::getPilotIndices()
|
||||
{
|
||||
switch (this->format)
|
||||
{
|
||||
case RATE_MCS_CCK_MSK: // VERY OLD FORMAT NOT USED NOW
|
||||
break;
|
||||
case RATE_MCS_LEGACY_OFDM_MSK:
|
||||
return this->NO_NHT_20_PILOT_INDICES;
|
||||
break;
|
||||
case RATE_MCS_HT_MSK:
|
||||
switch (channelWidth)
|
||||
{
|
||||
case RATE_MCS_CHAN_WIDTH_20:
|
||||
return HT_VHT_20_PILOT_INDICES;
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_40:
|
||||
return HT_VHT_40_PILOT_INDICES;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case RATE_MCS_VHT_MSK:
|
||||
switch (this->channelWidth)
|
||||
{
|
||||
case RATE_MCS_CHAN_WIDTH_20:
|
||||
return HT_VHT_20_PILOT_INDICES;
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_40:
|
||||
return HT_VHT_40_PILOT_INDICES;
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_80:
|
||||
return VHT_80_PILOT_INDICES;
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_160:
|
||||
return VHT_160_PILOT_INDICES;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case RATE_MCS_HE_MSK:
|
||||
switch (channelWidth)
|
||||
{
|
||||
case RATE_MCS_CHAN_WIDTH_20:
|
||||
return HE_20_PILOT_INDICES;
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_40:
|
||||
return HE_40_PILOT_INDICES;
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_80:
|
||||
return HE_80_PILOT_INDICES;
|
||||
break;
|
||||
case RATE_MCS_CHAN_WIDTH_160:
|
||||
return HE_160_PILOT_INDICES;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case RATE_MCS_EHT_MSK:
|
||||
// TODO WiFi 7
|
||||
break;
|
||||
}
|
||||
std::vector<uint32_t> v;
|
||||
return v;
|
||||
}
|
||||
|
||||
double Csi::constrainAngle(double x){
|
||||
x = fmod(x + M_PI,M_2_PI);
|
||||
if (x < 0)
|
||||
x += M_2_PI;
|
||||
return x - M_PI;
|
||||
}
|
||||
|
||||
// convert to [-360,360]
|
||||
double Csi::angleConv(double angle){
|
||||
return fmod(constrainAngle(angle),M_2_PI);
|
||||
}
|
||||
|
||||
double Csi::angleDiff(double a,double b){
|
||||
double dif = fmod(b - a + M_PI,M_2_PI);
|
||||
if (dif < 0)
|
||||
dif += M_2_PI;
|
||||
return dif - M_PI;
|
||||
}
|
||||
|
||||
double Csi::unwrap(double previousAngle,double newAngle){
|
||||
float d = newAngle - previousAngle;
|
||||
d = d > M_PI ? d - 2 * M_PI : (d < -M_PI ? d + 2 * M_PI : d);
|
||||
return previousAngle + d;
|
||||
|
||||
//return previousAngle - angleDiff(newAngle,angleConv(previousAngle));
|
||||
}
|
||||
|
||||
void Csi::unwrapPhase()
|
||||
{
|
||||
uint32_t offset = 0;
|
||||
for (uint32_t rx = 0; rx < this->numRx; rx++)
|
||||
{
|
||||
for (uint32_t tx = 0; tx < this->numTx; tx++)
|
||||
{
|
||||
for (uint32_t n = 1; n < this->numSubCarriers; n++)
|
||||
{
|
||||
uint32_t index = n + offset;
|
||||
this->phase[index] = this->unwrap(this->phase[index - 1], this->phase[index]);
|
||||
}
|
||||
offset += this->numSubCarriers;
|
||||
}
|
||||
}
|
||||
}
|
||||
205
src/CsiProcessor.cpp
Normal file
205
src/CsiProcessor.cpp
Normal file
@ -0,0 +1,205 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "CsiProcessor.h"
|
||||
#include "main.h"
|
||||
#include "Logger.h"
|
||||
#include "GnuPlot.h"
|
||||
#include "interpolation.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <numeric>
|
||||
#include <filesystem>
|
||||
#include <cstring>
|
||||
|
||||
bool CsiProcessor::loadCsi()
|
||||
{
|
||||
this->clearState();
|
||||
std::ifstream ifs(arguments.inputFile, std::ios::binary);
|
||||
|
||||
ifs.seekg (0, ifs.end);
|
||||
int length = ifs.tellg();
|
||||
ifs.seekg (0, ifs.beg);
|
||||
int currentPosition = 0;
|
||||
|
||||
while (currentPosition < length)
|
||||
{
|
||||
uint32_t csiDataSize;
|
||||
|
||||
ifs.read((char *)&csiDataSize, 4);
|
||||
ifs.seekg(currentPosition, ifs.beg);
|
||||
|
||||
uint8_t rawData[CSI_HEADER_LENGTH + csiDataSize];
|
||||
ifs.read((char *)rawData, CSI_HEADER_LENGTH + csiDataSize);
|
||||
Csi *c = new Csi();
|
||||
c->loadFromMemory(rawData);
|
||||
this->csiData.push_back(c);
|
||||
currentPosition = ifs.tellg();
|
||||
//break;
|
||||
}
|
||||
|
||||
Logger::log(info) << "Csi loaded \n";
|
||||
return true;
|
||||
}
|
||||
|
||||
void CsiProcessor::saveCsi()
|
||||
{
|
||||
std::ofstream outfile;
|
||||
outfile.open(arguments.outputFile, std::ios_base::app | std::ios::binary);
|
||||
if (outfile.fail())
|
||||
{
|
||||
throw std::ios_base::failure("Open file failed: " + std::string(std::strerror(errno)));
|
||||
}
|
||||
this->process(*(this->csiData[0]));
|
||||
|
||||
for (Csi *c : this->csiData) {
|
||||
this->process(*c);
|
||||
c->rawHeaderData.csiDataSize = sizeof(std::complex<double>) * c->csi.size();
|
||||
outfile.write(reinterpret_cast<char *>(&c->rawHeaderData), sizeof(RawHeaderData));
|
||||
outfile.write(reinterpret_cast<char *>(c->csi.data()), c->rawHeaderData.csiDataSize);
|
||||
}
|
||||
outfile.close();
|
||||
std::filesystem::permissions(arguments.outputFile, std::filesystem::perms::all & ~(std::filesystem::perms::owner_exec | std::filesystem::perms::group_exec | std::filesystem::perms::others_exec), std::filesystem::perm_options::add);
|
||||
}
|
||||
|
||||
CsiProcessor::~CsiProcessor()
|
||||
{
|
||||
this->clearState();
|
||||
}
|
||||
|
||||
void CsiProcessor::clearState()
|
||||
{
|
||||
if (this->csiData.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Csi *c : this->csiData) {
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
void CsiProcessor::interpolate(Csi &csi, processor type)
|
||||
{
|
||||
const std::vector<uint32_t> pilotIndices = csi.getPilotIndices();
|
||||
uint32_t offset = 0;
|
||||
for (uint32_t rx = 0; rx < csi.numRx; rx++)
|
||||
{
|
||||
for (uint32_t tx = 0; tx < csi.numTx; tx++)
|
||||
{
|
||||
for (uint32_t pilotIndice : pilotIndices) {
|
||||
uint32_t index = pilotIndice + offset;
|
||||
if (type == processor::interpolateLinear)
|
||||
{
|
||||
csi.magnitude[index] = interpolation::linearInterpolate(csi.magnitude[index - 1], csi.magnitude[index + 1], 0.5);
|
||||
csi.phase[index] = interpolation::linearInterpolate(csi.phase[index - 1], csi.phase[index + 1], 0.5);
|
||||
}
|
||||
else if(type == processor::interpolateCubic)
|
||||
{
|
||||
csi.magnitude[index] = interpolation::cubicInterpolate(csi.magnitude[index - 2], csi.magnitude[index - 1], csi.magnitude[index + 1], csi.magnitude[index + 2], 0.5);
|
||||
csi.phase[index] = interpolation::cubicInterpolate(csi.phase[index - 2], csi.phase[index - 1], csi.phase[index + 1], csi.phase[index + 2], 0.5);
|
||||
}
|
||||
else if(type == processor::interpolateCosine)
|
||||
{
|
||||
csi.magnitude[index] = interpolation::cosineInterpolate(csi.magnitude[index - 1], csi.magnitude[index + 1], 0.5);
|
||||
csi.phase[index] = interpolation::cosineInterpolate(csi.phase[index - 1], csi.phase[index + 1], 0.5);
|
||||
}
|
||||
}
|
||||
offset += csi.numSubCarriers;
|
||||
}
|
||||
}
|
||||
|
||||
csi.magnitudePhaseToComplex();
|
||||
}
|
||||
|
||||
void CsiProcessor::process(Csi &csi)
|
||||
{
|
||||
csi.backup();
|
||||
csi.restore();
|
||||
|
||||
if (arguments.processors[processor::interpolateLinear])
|
||||
{
|
||||
this->interpolate(csi, processor::interpolateLinear);
|
||||
}
|
||||
else if (arguments.processors[processor::interpolateCubic])
|
||||
{
|
||||
this->interpolate(csi, processor::interpolateCubic);
|
||||
}
|
||||
else if (arguments.processors[processor::interpolateCosine])
|
||||
{
|
||||
this->interpolate(csi, processor::interpolateCosine);
|
||||
}
|
||||
|
||||
if (arguments.processors[processor::phaseCalibrationLinearTransform])
|
||||
{
|
||||
this->phaseCalibLinearTransform(csi);
|
||||
}
|
||||
}
|
||||
|
||||
//WiFi-Based Real-Time Calibration-Free Passive Human Motion Detection
|
||||
void CsiProcessor::phaseCalibLinearTransform(Csi &csi)
|
||||
{
|
||||
/* double a = (csi.phase.back() - csi.phase[0]) / (csi.phase.size());
|
||||
double b = std::reduce(csi.phase.begin(), csi.phase.end()) / csi.phase.size();
|
||||
|
||||
for (uint32_t i = 0; i < csi.phase.size(); i++) {
|
||||
csi.phase[i] = csi.phase[i] - (a*(i + 1) + b);
|
||||
} */
|
||||
|
||||
uint32_t offset = 0;
|
||||
//double sk[] = {-26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26};
|
||||
|
||||
std::vector<int> sk;
|
||||
for (int i = (csi.numSubCarriers / 2); i >= 0 ; i--)
|
||||
{
|
||||
sk.push_back(-i);
|
||||
}
|
||||
for (uint32_t i = 1; i <= (csi.numSubCarriers / 2) ; i++)
|
||||
{
|
||||
sk.push_back(i);
|
||||
}
|
||||
|
||||
|
||||
csi.unwrapPhase();
|
||||
|
||||
for (uint32_t rx = 0; rx < csi.numRx; rx++)
|
||||
{
|
||||
for (uint32_t tx = 0; tx < csi.numTx; tx++)
|
||||
{
|
||||
uint32_t firstIndex = offset;
|
||||
uint32_t lastIndex = offset + (csi.numSubCarriers - 1);
|
||||
|
||||
double sum = 0;
|
||||
for (uint32_t i = firstIndex; i <= lastIndex; i++) {
|
||||
sum += csi.phase[i];
|
||||
}
|
||||
|
||||
double a = (csi.phase[lastIndex] - csi.phase[firstIndex]) / (sk.back() - sk[0]);
|
||||
double b = sum / csi.numSubCarriers;
|
||||
|
||||
uint32_t k = 0;
|
||||
for (uint32_t i = firstIndex; i <= lastIndex; i++) {
|
||||
csi.phase[i] = csi.phase[i] - a*sk[k] - b;
|
||||
k++;
|
||||
}
|
||||
|
||||
offset += csi.numSubCarriers;
|
||||
}
|
||||
}
|
||||
csi.magnitudePhaseToComplex();
|
||||
}
|
||||
254
src/MainController.cpp
Normal file
254
src/MainController.cpp
Normal file
@ -0,0 +1,254 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "MainController.h"
|
||||
#include "main.h"
|
||||
#include "Logger.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "layout.h"
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
MainController::MainController()
|
||||
{
|
||||
signal(SIGINT, this->intHandler);
|
||||
}
|
||||
|
||||
MainController *MainController::getInstance()
|
||||
{
|
||||
if (INSTANCE == nullptr)
|
||||
{
|
||||
INSTANCE = new MainController();
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
void MainController::deleteInstance()
|
||||
{
|
||||
delete MainController::INSTANCE;
|
||||
}
|
||||
|
||||
void MainController::runNoGui()
|
||||
{
|
||||
this->initInterface();
|
||||
if (arguments.measure)
|
||||
{
|
||||
pthread_create(&this->measureCsiThread, NULL, &MainController::measureCsi, NULL);
|
||||
}
|
||||
if (arguments.inject)
|
||||
{
|
||||
pthread_create(&this->injectPacketThread, NULL, &MainController::injectPackets, NULL);
|
||||
}
|
||||
if (arguments.measure)
|
||||
{
|
||||
pthread_join(this->measureCsiThread, NULL);
|
||||
}
|
||||
if (arguments.inject)
|
||||
{
|
||||
pthread_join(this->injectPacketThread, NULL);
|
||||
}
|
||||
this->deleteInstance();
|
||||
}
|
||||
|
||||
void MainController::measureCsi(bool stop)
|
||||
{
|
||||
this->wifiController.setFreq(arguments.frequency, arguments.bandwidth.c_str());
|
||||
if (stop)
|
||||
{
|
||||
pthread_cancel(this->measureCsiThread);
|
||||
}
|
||||
else
|
||||
{
|
||||
pthread_create(&this->measureCsiThread, NULL, &MainController::measureCsi, NULL);
|
||||
pthread_detach(this->measureCsiThread);
|
||||
}
|
||||
}
|
||||
|
||||
void MainController::injectPackets(bool stop)
|
||||
{
|
||||
this->wifiController.setTxPower();
|
||||
this->wifiController.setFreq(arguments.frequency, arguments.bandwidth.c_str());
|
||||
if (stop)
|
||||
{
|
||||
pthread_cancel(this->injectPacketThread);
|
||||
}
|
||||
else
|
||||
{
|
||||
pthread_create(&this->injectPacketThread, NULL, &MainController::injectPackets, NULL);
|
||||
pthread_detach(this->injectPacketThread);
|
||||
}
|
||||
}
|
||||
|
||||
void MainController::runGui()
|
||||
{
|
||||
arguments.plot = true;
|
||||
arguments.verbose = true;
|
||||
arguments.measure = false;
|
||||
arguments.inject = false;
|
||||
gtk_init(NULL, NULL);
|
||||
Glib::init();
|
||||
auto app = Gtk::Application::create("com.kuskosoft.feitcsi");
|
||||
std::string layout((char*)MainWindow_glade);
|
||||
auto builder = Gtk::Builder::create_from_string(layout);
|
||||
builder->get_widget_derived("MainWindow", this->mainWindow);
|
||||
app->run(*this->mainWindow);
|
||||
}
|
||||
|
||||
void MainController::initInterface()
|
||||
{
|
||||
try
|
||||
{
|
||||
this->wifiController.init();
|
||||
this->wifiController.getInterfaces();
|
||||
this->wifiController.getPhys();
|
||||
|
||||
// delete actual interfaces
|
||||
for (InterfaceInfo interface : this->wifiController.interfaces)
|
||||
{
|
||||
if (arguments.verbose)
|
||||
{
|
||||
Logger::log(info) << "Remove interface " << interface.ifName << "\n";
|
||||
}
|
||||
this->bkpInterfaces.push_back(interface);
|
||||
this->wifiController.removeInterface(NULL, interface.ifIndex);
|
||||
}
|
||||
this->wifiController.addMonitorDevice(MONITOR_INTERFACE_NAME, NL80211_IFTYPE_MONITOR);
|
||||
this->wifiController.setInterfaceUpDown(MONITOR_INTERFACE_NAME, true);
|
||||
this->wifiController.setFreq(arguments.frequency, arguments.bandwidth.c_str());
|
||||
if (!MainController::mainWindow)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500)); //wait on init then set power and go next
|
||||
this->wifiController.setTxPower();
|
||||
}
|
||||
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
if (MainController::mainWindow)
|
||||
{
|
||||
MainController::mainWindow->fatalError(e.what());
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::log(error) << e.what() << '\n';
|
||||
delete MainController::INSTANCE;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *MainController::measureCsi(void *arg)
|
||||
{
|
||||
try
|
||||
{
|
||||
WiFiCsiController wcs;
|
||||
wcs.init();
|
||||
wcs.listenToCsi();
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
if (MainController::mainWindow)
|
||||
{
|
||||
MainController::mainWindow->fatalError(e.what());
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::log(error) << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *MainController::injectPackets(void *arg)
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketInjector pi;
|
||||
if (arguments.injectRepeat)
|
||||
{
|
||||
for (uint32_t i = 0; i < arguments.injectRepeat; i++)
|
||||
{
|
||||
pi.inject();
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(arguments.injectDelay));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
pi.inject();
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(arguments.injectDelay));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
if (MainController::mainWindow)
|
||||
{
|
||||
MainController::mainWindow->fatalError(e.what());
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::log(error) << e.what() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MainController::restoreState()
|
||||
{
|
||||
MainController *mainController = MainController::getInstance();
|
||||
|
||||
if (mainController->measureCsiThread)
|
||||
{
|
||||
pthread_cancel(mainController->measureCsiThread);
|
||||
}
|
||||
if (mainController->injectPacketThread)
|
||||
{
|
||||
pthread_cancel(mainController->injectPacketThread);
|
||||
}
|
||||
|
||||
mainController->wifiController.removeInterface(MONITOR_INTERFACE_NAME);
|
||||
for (InterfaceInfo interface : mainController->bkpInterfaces)
|
||||
{
|
||||
if (arguments.verbose)
|
||||
{
|
||||
Logger::log(info) << "Recovering interface " << interface.ifName << "\n";
|
||||
}
|
||||
mainController->wifiController.addMonitorDevice(interface.ifName.c_str(), (nl80211_iftype)interface.ifType);
|
||||
}
|
||||
|
||||
if (arguments.verbose)
|
||||
{
|
||||
Logger::log(info) << "Exiting recovery state...\n";
|
||||
}
|
||||
}
|
||||
|
||||
MainController::~MainController()
|
||||
{
|
||||
this->restoreState();
|
||||
}
|
||||
|
||||
void MainController::intHandler(int dummy)
|
||||
{
|
||||
delete MainController::INSTANCE;
|
||||
exit(0);
|
||||
}
|
||||
251
src/Netlink.cpp
Normal file
251
src/Netlink.cpp
Normal file
@ -0,0 +1,251 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "Netlink.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <iostream>
|
||||
#include <netlink/genl/genl.h>
|
||||
#include <netlink/genl/family.h>
|
||||
#include <netlink/genl/ctrl.h>
|
||||
#include <netlink/attr.h>
|
||||
|
||||
void Netlink::init()
|
||||
{
|
||||
/* int err = */ this->nlInit(&this->nlstate);
|
||||
// TODO if error
|
||||
}
|
||||
|
||||
int Netlink::nlInit(struct nl80211_state *state)
|
||||
{
|
||||
int err;
|
||||
std::string errMsg;
|
||||
|
||||
state->nl_sock = nl_socket_alloc();
|
||||
if (!state->nl_sock)
|
||||
{
|
||||
throw std::ios_base::failure("Failed to allocate netlink socket.\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (genl_connect(state->nl_sock))
|
||||
{
|
||||
errMsg = "Failed to connect to generic netlink.\n";
|
||||
err = -ENOLINK;
|
||||
goto out_handle_destroy;
|
||||
}
|
||||
|
||||
nl_socket_set_buffer_size(state->nl_sock, 8192, 8192);
|
||||
|
||||
/* try to set NETLINK_EXT_ACK to 1, ignoring errors */
|
||||
err = 1;
|
||||
setsockopt(nl_socket_get_fd(state->nl_sock), SOL_NETLINK,
|
||||
NETLINK_EXT_ACK, &err, sizeof(err));
|
||||
|
||||
state->nl80211_id = genl_ctrl_resolve(state->nl_sock, "nl80211");
|
||||
|
||||
if (state->nl80211_id < 0)
|
||||
{
|
||||
errMsg = "nl80211 not found.\n";
|
||||
err = -ENOENT;
|
||||
goto out_handle_destroy;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
out_handle_destroy:
|
||||
nl_socket_free(state->nl_sock);
|
||||
if (!errMsg.empty())
|
||||
{
|
||||
throw std::ios_base::failure(errMsg);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int Netlink::nlExecCommand(Cmd &cmd)
|
||||
{
|
||||
int err = 0;
|
||||
std::string errMsg;
|
||||
struct nl_msg *msg = nlmsg_alloc();
|
||||
if (!msg)
|
||||
{
|
||||
throw std::ios_base::failure("failed to allocate netlink message\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
struct nl_cb *cb = nl_cb_alloc(NL_CB_DEFAULT);
|
||||
struct nl_cb *s_cb = nl_cb_alloc(NL_CB_DEFAULT);
|
||||
|
||||
if (!cb || !s_cb)
|
||||
{
|
||||
errMsg = "failed to allocate netlink callbacks\n";
|
||||
err = 2;
|
||||
goto out;
|
||||
}
|
||||
|
||||
genlmsg_put(msg, 0, 0, this->nlstate.nl80211_id, 0, cmd.nlFlags, cmd.id, 0);
|
||||
|
||||
switch (cmd.idby)
|
||||
{
|
||||
case CIB_PHY:
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, cmd.device);
|
||||
break;
|
||||
case CIB_NETDEV:
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, cmd.device);
|
||||
break;
|
||||
case CIB_WDEV:
|
||||
NLA_PUT_U64(msg, NL80211_ATTR_WDEV, cmd.device);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd.handler)
|
||||
{
|
||||
err = cmd.handler(&this->nlstate, msg, cmd.args);
|
||||
}
|
||||
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
nl_socket_set_cb(this->nlstate.nl_sock, s_cb);
|
||||
|
||||
err = nl_send_auto_complete(this->nlstate.nl_sock, msg);
|
||||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
err = 1;
|
||||
|
||||
nl_cb_err(cb, NL_CB_CUSTOM, this->error_handler, &err);
|
||||
nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, this->finish_handler, &err);
|
||||
nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, this->ack_handler, &err);
|
||||
nl_cb_set(cb, NL_CB_MSG_IN, NL_CB_CUSTOM, cmd.valid_handler ? cmd.valid_handler : this->nlValidHandler, this);
|
||||
while (err > 0)
|
||||
{
|
||||
nl_recvmsgs(this->nlstate.nl_sock, cb);
|
||||
}
|
||||
|
||||
if (err < 0)
|
||||
{
|
||||
errMsg = "command failed: " + std::string(strerror(-err)) + std::to_string(err) + "\n";
|
||||
}
|
||||
|
||||
out:
|
||||
nl_cb_put(cb);
|
||||
nl_cb_put(s_cb);
|
||||
nlmsg_free(msg);
|
||||
if (!errMsg.empty())
|
||||
{
|
||||
throw std::ios_base::failure(errMsg);
|
||||
}
|
||||
return err;
|
||||
nla_put_failure:
|
||||
throw std::ios_base::failure("building message failed\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
int Netlink::nlValidHandler(struct nl_msg *msg, void *arg)
|
||||
{
|
||||
return NL_OK;
|
||||
}
|
||||
|
||||
int Netlink::error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
|
||||
{
|
||||
struct nlmsghdr *nlh = (struct nlmsghdr *)err - 1;
|
||||
int len = nlh->nlmsg_len;
|
||||
struct nlattr *attrs;
|
||||
struct nlattr *tb[NLMSGERR_ATTR_MAX + 1];
|
||||
int *ret = (int *)arg;
|
||||
int ack_len = sizeof(*nlh) + sizeof(int) + sizeof(*nlh);
|
||||
|
||||
if (err->error > 0)
|
||||
{
|
||||
/*
|
||||
* This is illegal, per netlink(7), but not impossible (think
|
||||
* "vendor commands"). Callers really expect negative error
|
||||
* codes, so make that happen.
|
||||
*/
|
||||
|
||||
throw std::ios_base::failure("ERROR: received positive netlink error code " + std::to_string(err->error) + "\n");
|
||||
*ret = -EPROTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
*ret = err->error;
|
||||
}
|
||||
|
||||
if (!(nlh->nlmsg_flags & NLM_F_ACK_TLVS))
|
||||
return NL_STOP;
|
||||
|
||||
if (!(nlh->nlmsg_flags & NLM_F_CAPPED))
|
||||
ack_len += err->msg.nlmsg_len - sizeof(*nlh);
|
||||
|
||||
if (len <= ack_len)
|
||||
return NL_STOP;
|
||||
|
||||
attrs = (nlattr *)((unsigned char *)nlh + ack_len);
|
||||
len -= ack_len;
|
||||
|
||||
nla_parse(tb, NLMSGERR_ATTR_MAX, attrs, len, NULL);
|
||||
if (tb[NLMSGERR_ATTR_MSG])
|
||||
{
|
||||
len = strnlen((char *)nla_data(tb[NLMSGERR_ATTR_MSG]),
|
||||
nla_len(tb[NLMSGERR_ATTR_MSG]));
|
||||
|
||||
throw std::ios_base::failure("kernel reports: " + std::string((char *)nla_data(tb[NLMSGERR_ATTR_MSG])) + "\n");
|
||||
}
|
||||
|
||||
return NL_STOP;
|
||||
}
|
||||
|
||||
int Netlink::finish_handler(struct nl_msg *msg, void *arg)
|
||||
{
|
||||
int *ret = (int *)arg;
|
||||
*ret = 0;
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
int Netlink::ack_handler(struct nl_msg *msg, void *arg)
|
||||
{
|
||||
int *ret = (int *)arg;
|
||||
*ret = 0;
|
||||
return NL_STOP;
|
||||
}
|
||||
|
||||
/* 1. EPERM: Operation not permitted - The requested operation is not allowed due to insufficient permissions.
|
||||
2. ESRCH: No such process - The specified process or resource could not be found.
|
||||
3. EINTR: Interrupted system call - The system call was interrupted by a signal.
|
||||
4. EBADF: Bad file descriptor - The file descriptor provided is not valid.
|
||||
5. EFAULT: Bad address - The provided memory address is invalid or inaccessible.
|
||||
6. EINVAL: Invalid argument - One or more of the arguments provided is not valid.
|
||||
7. EIO: Input/output error - An error occurred during input or output operations.
|
||||
8. ENOMEM: Out of memory - Insufficient memory is available to complete the requested operation.
|
||||
9. EACCES: Permission denied - The requested operation is not allowed due to permission restrictions.
|
||||
10. EBUSY: Device or resource busy - The requested device or resource is currently in use.
|
||||
|
||||
1. EPERM: -1
|
||||
2. ESRCH: -3
|
||||
3. EINTR: -4
|
||||
4. EBADF: -9
|
||||
5. EFAULT: -14
|
||||
6. EINVAL: -22
|
||||
7. EIO: -5
|
||||
8. ENOMEM: -12
|
||||
9. EACCES: -13
|
||||
10. EBUSY: -16 */
|
||||
183
src/PacketInjector.cpp
Normal file
183
src/PacketInjector.cpp
Normal file
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "PacketInjector.h"
|
||||
#include "main.h"
|
||||
#include "Logger.h"
|
||||
#include <string.h>
|
||||
#include <pcap.h>
|
||||
#include <iostream>
|
||||
|
||||
#define SPATIAL_STREAM 16
|
||||
|
||||
uint8_t ieee80211Header[] = {
|
||||
0xe0, 0x80, 0x00, 0x00, 0x00, 0x16, 0xea, 0x12, 0x34, 0x56, 0x00, 0x16, 0xea, 0x12, 0x34, 0x56, 0x98, 0x59, 0x7a, 0x8b, 0x34, 0x3b, 0x00, 0x00, 0x15, 0x03, 0x15, 0x20};
|
||||
|
||||
uint8_t ieee80211Body[] = {};
|
||||
|
||||
void PacketInjector::inject()
|
||||
{
|
||||
if (arguments.verbose)
|
||||
{
|
||||
Logger::log(info) << "Injecting " << arguments.format << "\n";
|
||||
}
|
||||
|
||||
|
||||
if (arguments.format == "NOHT")
|
||||
{
|
||||
this->injectNoHT();
|
||||
}
|
||||
else if (arguments.format == "HT")
|
||||
{
|
||||
this->injectHT();
|
||||
}
|
||||
else if (arguments.format == "VHT")
|
||||
{
|
||||
this->injectVHT();
|
||||
}
|
||||
else if (arguments.format == "HESU")
|
||||
{
|
||||
this->injectHE();
|
||||
}
|
||||
}
|
||||
|
||||
void PacketInjector::injectNoHT()
|
||||
{
|
||||
uint8_t mcs = 0;
|
||||
if (RATE_LEGACY_RATE_MSK >= arguments.mcs)
|
||||
{
|
||||
mcs = RATE_LEGACY_RATE_MSK & arguments.mcs;
|
||||
}
|
||||
uint32_t rateNFlags = RATE_MCS_LEGACY_OFDM_MSK | mcs;
|
||||
|
||||
this->send(rateNFlags);
|
||||
}
|
||||
|
||||
void PacketInjector::injectHT()
|
||||
{
|
||||
uint8_t mcs = 0;
|
||||
if (RATE_HT_MCS_CODE_MSK >= arguments.mcs)
|
||||
{
|
||||
mcs = RATE_HT_MCS_CODE_MSK & arguments.mcs;
|
||||
}
|
||||
uint32_t rateNFlags =
|
||||
RATE_MCS_HT_MSK |
|
||||
mcs |
|
||||
(arguments.channelWidth == 40 ? RATE_MCS_CHAN_WIDTH_40 : 0) |
|
||||
(arguments.spatialStreams == 2 ? SPATIAL_STREAM : 0) |
|
||||
(arguments.spatialStreams == 2 ? RATE_MCS_ANT_AB_MSK : 0) |
|
||||
(arguments.guardInterval == 400 ? RATE_MCS_SGI_MSK : 0) |
|
||||
(arguments.coding == "LDPC" ? RATE_MCS_LDPC_MSK : 0);
|
||||
this->send(rateNFlags);
|
||||
}
|
||||
|
||||
void PacketInjector::injectVHT()
|
||||
{
|
||||
uint8_t mcs = 0;
|
||||
if (RATE_MCS_CODE_MSK >= arguments.mcs)
|
||||
{
|
||||
mcs = RATE_MCS_CODE_MSK & arguments.mcs;
|
||||
}
|
||||
uint32_t rateNFlags =
|
||||
RATE_MCS_VHT_MSK |
|
||||
mcs |
|
||||
(arguments.channelWidth == 40 ? RATE_MCS_CHAN_WIDTH_40 : 0) |
|
||||
(arguments.channelWidth == 80 ? RATE_MCS_CHAN_WIDTH_80 : 0) |
|
||||
(arguments.channelWidth == 160 ? RATE_MCS_CHAN_WIDTH_160 : 0) |
|
||||
(arguments.spatialStreams == 2 ? SPATIAL_STREAM : 0) |
|
||||
(arguments.spatialStreams == 2 ? RATE_MCS_ANT_AB_MSK : 0) |
|
||||
(arguments.guardInterval == 400 ? RATE_MCS_SGI_MSK : 0) |
|
||||
(arguments.coding == "LDPC" ? RATE_MCS_LDPC_MSK : 0);
|
||||
this->send(rateNFlags);
|
||||
}
|
||||
|
||||
void PacketInjector::injectHE()
|
||||
{
|
||||
uint8_t mcs = 0;
|
||||
if (RATE_MCS_CODE_MSK >= arguments.mcs)
|
||||
{
|
||||
mcs = RATE_MCS_CODE_MSK & arguments.mcs;
|
||||
}
|
||||
|
||||
uint32_t ltf = 1;
|
||||
if (arguments.ltf == "2xLTF+0.8")
|
||||
{
|
||||
ltf = 1;
|
||||
}
|
||||
else if (arguments.ltf == "2xLTF+1.6")
|
||||
{
|
||||
ltf = 2;
|
||||
}
|
||||
else if (arguments.ltf == "4xLTF+3.2")
|
||||
{
|
||||
ltf = 3;
|
||||
}
|
||||
else if (arguments.ltf == "4xLTF+0.8")
|
||||
{
|
||||
ltf = 4;
|
||||
}
|
||||
ltf = (ltf << RATE_MCS_HE_GI_LTF_POS) & RATE_MCS_HE_GI_LTF_MSK;
|
||||
|
||||
uint32_t rateNFlags =
|
||||
RATE_MCS_HE_MSK |
|
||||
RATE_MCS_LDPC_MSK |
|
||||
mcs |
|
||||
ltf |
|
||||
(arguments.channelWidth == 40 ? RATE_MCS_CHAN_WIDTH_40 : 0) |
|
||||
(arguments.channelWidth == 80 ? RATE_MCS_CHAN_WIDTH_80 : 0) |
|
||||
(arguments.channelWidth == 160 ? RATE_MCS_CHAN_WIDTH_160 : 0) |
|
||||
(arguments.spatialStreams == 2 ? SPATIAL_STREAM : 0) |
|
||||
(arguments.spatialStreams == 2 ? RATE_MCS_ANT_AB_MSK : 0);
|
||||
this->send(rateNFlags);
|
||||
}
|
||||
|
||||
void PacketInjector::send(uint32_t rateNFlags)
|
||||
{
|
||||
uint32_t pos = 0;
|
||||
struct ieee80211_radiotap_header rthdr;
|
||||
rthdr.it_version = 0;
|
||||
rthdr.it_pad = 0;
|
||||
rthdr.it_present = 0;
|
||||
|
||||
rthdr.it_present |= BIT(IEEE80211_RADIOTAP_FLAGS);
|
||||
rthdr.it_optional[pos++] = 0x80;
|
||||
|
||||
memcpy(&rthdr.it_optional[pos++], &rateNFlags, 4);
|
||||
pos += 3;
|
||||
|
||||
rthdr.it_len = pos + 8;
|
||||
|
||||
uint8_t sendBuffer[1000];
|
||||
memcpy(sendBuffer, (uint8_t *)&rthdr, rthdr.it_len);
|
||||
memcpy(&sendBuffer[rthdr.it_len], ieee80211Header, sizeof(ieee80211Header));
|
||||
memcpy(&sendBuffer[rthdr.it_len + sizeof(ieee80211Header)], ieee80211Body, sizeof(ieee80211Body));
|
||||
|
||||
uint16_t totalSize = rthdr.it_len + sizeof(ieee80211Header) + sizeof(ieee80211Body);
|
||||
|
||||
char szErrbuf[500];
|
||||
pcap_t *ppcap = pcap_open_live("mon0", 800, 1, 20, szErrbuf);
|
||||
int r = pcap_inject(ppcap, sendBuffer, totalSize);
|
||||
if (r > 0)
|
||||
{
|
||||
//pcap_perror(ppcap, "Failed to inject packet");
|
||||
pcap_close(ppcap);
|
||||
//throw std::ios_base::failure("Failed to inject packet\n");
|
||||
}
|
||||
|
||||
//pcap_close(ppcap);
|
||||
}
|
||||
661
src/WiFIController.cpp
Normal file
661
src/WiFIController.cpp
Normal file
@ -0,0 +1,661 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "nl80211.h" //fix old libs
|
||||
#include "WiFIController.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <iwlib.h>
|
||||
#include <netlink/genl/genl.h>
|
||||
#include <netlink/genl/family.h>
|
||||
#include <netlink/genl/ctrl.h>
|
||||
#include <netlink/attr.h>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <thread>
|
||||
#include "main.h"
|
||||
#include "Logger.h"
|
||||
|
||||
const char *IF_MODES[NL80211_IFTYPE_MAX + 1] = {
|
||||
"unspecified",
|
||||
"IBSS",
|
||||
"managed",
|
||||
"AP",
|
||||
"AP/VLAN",
|
||||
"WDS",
|
||||
"monitor",
|
||||
"mesh point",
|
||||
"P2P-client",
|
||||
"P2P-GO",
|
||||
"P2P-device",
|
||||
"outside context of a BSS",
|
||||
"NAN",
|
||||
};
|
||||
|
||||
void WiFIController::killNetworkProcesses()
|
||||
{
|
||||
std::string procesNames[] = {
|
||||
"wpa_action",
|
||||
"wpa_supplicant",
|
||||
"wpa_cli",
|
||||
"dhclient",
|
||||
"ifplugd",
|
||||
"dhcdbd",
|
||||
"dhcpcd",
|
||||
"udhcpc",
|
||||
"NetworkManager",
|
||||
"knetworkmanager",
|
||||
"avahi-autoipd",
|
||||
"avahi-daemon",
|
||||
"wlassistant",
|
||||
"wifibox",
|
||||
"net_applet",
|
||||
"wicd-daemon",
|
||||
"wicd-client",
|
||||
"iwd",
|
||||
"hostapd"};
|
||||
|
||||
for (std::string name : procesNames)
|
||||
{
|
||||
char buf[512];
|
||||
std::string cmnd = "pidof " + name;
|
||||
FILE *pipe = popen(cmnd.c_str(), "r");
|
||||
fgets(buf, 512, pipe);
|
||||
std::stringstream ss(buf);
|
||||
std::string word;
|
||||
while (ss >> word)
|
||||
{ // Extract word from the stream.
|
||||
pid_t pid = std::atoi(word.c_str());
|
||||
if (pid)
|
||||
{
|
||||
kill(pid, SIGKILL);
|
||||
}
|
||||
}
|
||||
pclose(pipe);
|
||||
}
|
||||
}
|
||||
|
||||
void WiFIController::getInterfaces()
|
||||
{
|
||||
Cmd cmd{
|
||||
.id = NL80211_CMD_GET_INTERFACE,
|
||||
.idby = CIB_NONE,
|
||||
.nlFlags = NLM_F_DUMP,
|
||||
.handler = NULL,
|
||||
.valid_handler = this->processGetInterfacesHandler,
|
||||
};
|
||||
|
||||
this->nlExecCommand(cmd);
|
||||
}
|
||||
|
||||
void WiFIController::setTxPower()
|
||||
{
|
||||
Cmd cmd{
|
||||
.id = NL80211_CMD_SET_WIPHY,
|
||||
.idby = CIB_NETDEV,
|
||||
.nlFlags = 0,
|
||||
.device = if_nametoindex(MONITOR_INTERFACE_NAME),
|
||||
.handler = this->setTxPowerHandler,
|
||||
};
|
||||
|
||||
this->nlExecCommand(cmd);
|
||||
}
|
||||
|
||||
void WiFIController::addMonitorDevice(const char *name, const nl80211_iftype type)
|
||||
{
|
||||
if (this->phys.empty())
|
||||
{
|
||||
throw std::ios_base::failure("Error no phy devices\n");
|
||||
return;
|
||||
}
|
||||
|
||||
const void *settings[] = {name, &type};
|
||||
|
||||
Cmd cmd{
|
||||
.id = NL80211_CMD_NEW_INTERFACE,
|
||||
.idby = CIB_PHY,
|
||||
.nlFlags = 0,
|
||||
.device = this->phys[0],
|
||||
.handler = this->processAddMonitorDeviceHandler,
|
||||
.valid_handler = NULL,
|
||||
.args = settings,
|
||||
};
|
||||
this->nlExecCommand(cmd);
|
||||
}
|
||||
|
||||
int WiFIController::setInterfaceUpDown(const char *ifName, bool up)
|
||||
{
|
||||
// Create a socket file descriptor
|
||||
int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sockfd < 0)
|
||||
{
|
||||
perror("Failed to create socket");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Get the interface index
|
||||
struct ifreq ifr;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strncpy(ifr.ifr_name, ifName, IFNAMSIZ - 1);
|
||||
if (ioctl(sockfd, SIOCGIFINDEX, &ifr) < 0)
|
||||
{
|
||||
perror("Failed to get interface index");
|
||||
close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (up)
|
||||
{
|
||||
ifr.ifr_flags |= IFF_UP;
|
||||
}
|
||||
else
|
||||
{
|
||||
ifr.ifr_flags &= ~IFF_UP;
|
||||
}
|
||||
if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0)
|
||||
{
|
||||
perror("Failed to bring down interface");
|
||||
close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Close the socket
|
||||
close(sockfd);
|
||||
|
||||
if (arguments.verbose)
|
||||
{
|
||||
Logger::log(info) << "Interface " << ifName << " has been brought " << (up ? "up" : "down") << "\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WiFIController::setFreq(uint16_t freq, const char *bw)
|
||||
{
|
||||
const void *settings[] = {&freq, bw};
|
||||
Cmd cmd{
|
||||
.id = NL80211_CMD_SET_WIPHY,
|
||||
.idby = CIB_NETDEV,
|
||||
.nlFlags = 0,
|
||||
.device = if_nametoindex(MONITOR_INTERFACE_NAME),
|
||||
.handler = processSetFreq,
|
||||
.valid_handler = NULL,
|
||||
.args = settings,
|
||||
};
|
||||
this->nlExecCommand(cmd);
|
||||
}
|
||||
|
||||
void WiFIController::removeInterface(const char *name, int ifIndex)
|
||||
{
|
||||
Cmd cmd{
|
||||
.id = NL80211_CMD_DEL_INTERFACE,
|
||||
.idby = CIB_NETDEV,
|
||||
.nlFlags = 0,
|
||||
.device = ifIndex ? ifIndex : if_nametoindex(name),
|
||||
.handler = NULL,
|
||||
.valid_handler = NULL,
|
||||
};
|
||||
this->nlExecCommand(cmd);
|
||||
}
|
||||
|
||||
void WiFIController::getPhys()
|
||||
{
|
||||
Cmd cmd{
|
||||
.id = NL80211_CMD_GET_WIPHY,
|
||||
.idby = CIB_NONE,
|
||||
.nlFlags = NLM_F_DUMP,
|
||||
.handler = NULL,
|
||||
.valid_handler = this->processGetPhysHandler,
|
||||
};
|
||||
this->nlExecCommand(cmd);
|
||||
}
|
||||
|
||||
int WiFIController::processGetPhysHandler(struct nl_msg *msg, void *arg)
|
||||
{
|
||||
WiFIController *instance = (WiFIController *)arg;
|
||||
struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
|
||||
struct genlmsghdr *gnlh = (genlmsghdr *)nlmsg_data(nlmsg_hdr(msg));
|
||||
nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
|
||||
genlmsg_attrlen(gnlh, 0), NULL);
|
||||
|
||||
if (tb_msg[NL80211_ATTR_WIPHY])
|
||||
{
|
||||
int64_t phyId = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY]);
|
||||
instance->phys.push_back(phyId);
|
||||
}
|
||||
|
||||
return NL_OK;
|
||||
}
|
||||
|
||||
uint16_t WiFIController::chanModeToWidth(struct ChanMode &chanMode)
|
||||
{
|
||||
switch (chanMode.width)
|
||||
{
|
||||
case NL80211_CHAN_WIDTH_20:
|
||||
return 20;
|
||||
case NL80211_CHAN_WIDTH_40:
|
||||
return 40;
|
||||
case NL80211_CHAN_WIDTH_80:
|
||||
return 80;
|
||||
case NL80211_CHAN_WIDTH_160:
|
||||
return 160;
|
||||
case NL80211_CHAN_WIDTH_320:
|
||||
return 320;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ChanMode WiFIController::getChanMode(const char *width)
|
||||
{
|
||||
static const struct ChanMode chanMode[] = {
|
||||
{.name = "20",
|
||||
.width = NL80211_CHAN_WIDTH_20,
|
||||
.freq1_diff = 0,
|
||||
.chantype = NL80211_CHAN_HT20},
|
||||
{.name = "40",
|
||||
.width = NL80211_CHAN_WIDTH_40,
|
||||
.freq1_diff = 10,
|
||||
.chantype = NL80211_CHAN_HT40PLUS},
|
||||
{.name = "HT40-",
|
||||
.width = NL80211_CHAN_WIDTH_40,
|
||||
.freq1_diff = -10,
|
||||
.chantype = NL80211_CHAN_HT40MINUS},
|
||||
{.name = "NOHT",
|
||||
.width = NL80211_CHAN_WIDTH_20_NOHT,
|
||||
.freq1_diff = 0,
|
||||
.chantype = NL80211_CHAN_NO_HT},
|
||||
{.name = "5MHz",
|
||||
.width = NL80211_CHAN_WIDTH_5,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
{.name = "10MHz",
|
||||
.width = NL80211_CHAN_WIDTH_10,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
{.name = "80",
|
||||
.width = NL80211_CHAN_WIDTH_80,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
{.name = "160",
|
||||
.width = NL80211_CHAN_WIDTH_160,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
{.name = "320MHz",
|
||||
.width = NL80211_CHAN_WIDTH_320,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
{.name = "1MHz",
|
||||
.width = NL80211_CHAN_WIDTH_1,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
{.name = "2MHz",
|
||||
.width = NL80211_CHAN_WIDTH_2,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
{.name = "4MHz",
|
||||
.width = NL80211_CHAN_WIDTH_4,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
{.name = "8MHz",
|
||||
.width = NL80211_CHAN_WIDTH_8,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
{.name = "16MHz",
|
||||
.width = NL80211_CHAN_WIDTH_16,
|
||||
.freq1_diff = 0,
|
||||
.chantype = -1},
|
||||
};
|
||||
|
||||
struct ChanMode selectedChanMode = {};
|
||||
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(chanMode); i++)
|
||||
{
|
||||
if (strcasecmp(chanMode[i].name, width) == 0)
|
||||
{
|
||||
selectedChanMode = chanMode[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return selectedChanMode;
|
||||
}
|
||||
|
||||
int WiFIController::processSetFreq(struct nl80211_state *state, struct nl_msg *msg, void *arg)
|
||||
{
|
||||
void **settings = (void **)arg;
|
||||
uint16_t settingsFreq = *(uint16_t *)(settings[0]);
|
||||
char *settingsWidth = (char *)(settings[1]);
|
||||
|
||||
if (arguments.verbose)
|
||||
{
|
||||
Logger::log(info) << "Setting frequency " << settingsFreq << " channel width " << settingsWidth << "\n";
|
||||
}
|
||||
|
||||
uint32_t freq = settingsFreq;
|
||||
uint32_t freq_offset = 0;
|
||||
|
||||
unsigned int control_freq = freq;
|
||||
unsigned int control_freq_offset = freq_offset;
|
||||
unsigned int center_freq1 = freq;
|
||||
unsigned int center_freq1_offset = freq_offset;
|
||||
enum nl80211_chan_width width = control_freq < 1000 ? NL80211_CHAN_WIDTH_16 : NL80211_CHAN_WIDTH_20_NOHT;
|
||||
|
||||
struct ChanMode selectedChanMode = getChanMode(settingsWidth);
|
||||
|
||||
center_freq1 = getCf1(&selectedChanMode, freq);
|
||||
|
||||
/* For non-S1G frequency */
|
||||
if (center_freq1 > 1000)
|
||||
center_freq1_offset = 0;
|
||||
|
||||
width = (nl80211_chan_width)selectedChanMode.width;
|
||||
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, control_freq);
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ_OFFSET, control_freq_offset);
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_CHANNEL_WIDTH, width);
|
||||
|
||||
switch (width)
|
||||
{
|
||||
case NL80211_CHAN_WIDTH_20_NOHT:
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_NO_HT);
|
||||
break;
|
||||
case NL80211_CHAN_WIDTH_20:
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_HT20);
|
||||
break;
|
||||
case NL80211_CHAN_WIDTH_40:
|
||||
if (control_freq > center_freq1)
|
||||
{
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_HT40MINUS);
|
||||
}
|
||||
else
|
||||
{
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_CHANNEL_TYPE, NL80211_CHAN_HT40PLUS);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (center_freq1)
|
||||
{
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1, center_freq1);
|
||||
}
|
||||
|
||||
if (center_freq1_offset)
|
||||
{
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1_OFFSET, center_freq1_offset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
nla_put_failure:
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
int WiFIController::setTxPowerHandler(nl80211_state * state, nl_msg * msg, void * arg)
|
||||
{
|
||||
enum nl80211_tx_power_setting type = NL80211_TX_POWER_FIXED;
|
||||
int mbm = arguments.txPower * 100; //dBm to mbm *100
|
||||
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_TX_POWER_SETTING, type);
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_TX_POWER_LEVEL, mbm);
|
||||
|
||||
return 0;
|
||||
|
||||
nla_put_failure:
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
int WiFIController::processAddMonitorDeviceHandler(struct nl80211_state *state, struct nl_msg *msg, void *arg)
|
||||
{
|
||||
void **settings = (void **)arg;
|
||||
const char *name = (const char *)settings[0];
|
||||
nl80211_iftype *type = (nl80211_iftype *)(settings[1]);
|
||||
|
||||
NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, name);
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, *type);
|
||||
return 0;
|
||||
nla_put_failure:
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
int WiFIController::getCf1(const struct ChanMode *chanmode, unsigned long freq)
|
||||
{
|
||||
unsigned int cf1 = freq, j;
|
||||
unsigned int bw80[] = {5180, 5260, 5500, 5580, 5660, 5745,
|
||||
5955, 6035, 6115, 6195, 6275, 6355,
|
||||
6435, 6515, 6595, 6675, 6755, 6835,
|
||||
6195, 6995};
|
||||
unsigned int bw160[] = {5180, 5500, 5955, 6115, 6275, 6435,
|
||||
6595, 6755, 6915};
|
||||
/* based on 11be D2 E.1 Country information and operating classes */
|
||||
unsigned int bw320[] = {5955, 6115, 6275, 6435, 6595, 6755};
|
||||
|
||||
switch (chanmode->width)
|
||||
{
|
||||
case NL80211_CHAN_WIDTH_80:
|
||||
/* setup center_freq1 */
|
||||
for (j = 0; j < ARRAY_SIZE(bw80); j++)
|
||||
{
|
||||
if (freq >= bw80[j] && freq < bw80[j] + 80)
|
||||
break;
|
||||
}
|
||||
|
||||
if (j == ARRAY_SIZE(bw80))
|
||||
break;
|
||||
|
||||
cf1 = bw80[j] + 30;
|
||||
break;
|
||||
case NL80211_CHAN_WIDTH_160:
|
||||
/* setup center_freq1 */
|
||||
for (j = 0; j < ARRAY_SIZE(bw160); j++)
|
||||
{
|
||||
if (freq >= bw160[j] && freq < bw160[j] + 160)
|
||||
break;
|
||||
}
|
||||
|
||||
if (j == ARRAY_SIZE(bw160))
|
||||
break;
|
||||
|
||||
cf1 = bw160[j] + 70;
|
||||
break;
|
||||
case NL80211_CHAN_WIDTH_320:
|
||||
/* setup center_freq1 */
|
||||
for (j = 0; j < ARRAY_SIZE(bw320); j++)
|
||||
{
|
||||
if (freq >= bw320[j] && freq < bw320[j] + 160)
|
||||
break;
|
||||
}
|
||||
|
||||
if (j == ARRAY_SIZE(bw320))
|
||||
break;
|
||||
|
||||
cf1 = bw320[j] + 150;
|
||||
break;
|
||||
default:
|
||||
cf1 = freq + chanmode->freq1_diff;
|
||||
break;
|
||||
}
|
||||
|
||||
return cf1;
|
||||
}
|
||||
|
||||
int WiFIController::processGetInterfacesHandler(struct nl_msg *msg, void *arg)
|
||||
{
|
||||
WiFIController *instance = (WiFIController *)arg;
|
||||
struct genlmsghdr *gnlh = (genlmsghdr *)nlmsg_data(nlmsg_hdr(msg));
|
||||
struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
|
||||
|
||||
struct InterfaceInfo ifInfo;
|
||||
|
||||
nla_parse(tb_msg, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
|
||||
genlmsg_attrlen(gnlh, 0), NULL);
|
||||
|
||||
if (tb_msg[NL80211_ATTR_IFNAME])
|
||||
{
|
||||
ifInfo.ifName = nla_get_string(tb_msg[NL80211_ATTR_IFNAME]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ifInfo.ifName = "Unnamed/non-netdev interface";
|
||||
}
|
||||
|
||||
if (tb_msg[NL80211_ATTR_IFINDEX])
|
||||
{
|
||||
ifInfo.ifIndex = nla_get_u32(tb_msg[NL80211_ATTR_IFINDEX]);
|
||||
}
|
||||
if (tb_msg[NL80211_ATTR_WDEV])
|
||||
{
|
||||
ifInfo.wdev = (uint64_t)nla_get_u64(tb_msg[NL80211_ATTR_WDEV]);
|
||||
}
|
||||
if (tb_msg[NL80211_ATTR_MAC])
|
||||
{
|
||||
ifInfo.mac = instance->macN2a((const unsigned char *)nla_data(tb_msg[NL80211_ATTR_MAC]));
|
||||
}
|
||||
if (tb_msg[NL80211_ATTR_SSID])
|
||||
{
|
||||
ifInfo.ssid = (const char *)nla_data(tb_msg[NL80211_ATTR_SSID]);
|
||||
}
|
||||
if (tb_msg[NL80211_ATTR_IFTYPE])
|
||||
{
|
||||
ifInfo.ifType = nla_get_u32(tb_msg[NL80211_ATTR_IFTYPE]);
|
||||
/* if (iftype <= NL80211_IFTYPE_MAX && IF_MODES[iftype])
|
||||
{
|
||||
ifInfo.type = IF_MODES[iftype];
|
||||
}
|
||||
else
|
||||
{
|
||||
ifInfo.type = "unknown";
|
||||
} */
|
||||
}
|
||||
|
||||
if (tb_msg[NL80211_ATTR_WIPHY])
|
||||
{
|
||||
ifInfo.wiphy = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY]);
|
||||
}
|
||||
if (tb_msg[NL80211_ATTR_WIPHY_FREQ])
|
||||
{
|
||||
ifInfo.freq = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_FREQ]);
|
||||
ifInfo.channel = instance->freqToCHannel(ifInfo.freq);
|
||||
if (tb_msg[NL80211_ATTR_CHANNEL_WIDTH])
|
||||
{
|
||||
ifInfo.channelWidth = nla_get_u32(tb_msg[NL80211_ATTR_CHANNEL_WIDTH]);
|
||||
if (tb_msg[NL80211_ATTR_CENTER_FREQ1])
|
||||
{
|
||||
ifInfo.centerFreq1 = nla_get_u32(tb_msg[NL80211_ATTR_CENTER_FREQ1]);
|
||||
}
|
||||
if (tb_msg[NL80211_ATTR_CENTER_FREQ2])
|
||||
{
|
||||
ifInfo.centerFreq2 = nla_get_u32(tb_msg[NL80211_ATTR_CENTER_FREQ2]);
|
||||
}
|
||||
}
|
||||
else if (tb_msg[NL80211_ATTR_WIPHY_CHANNEL_TYPE])
|
||||
{
|
||||
ifInfo.channelType = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
|
||||
}
|
||||
}
|
||||
|
||||
if (tb_msg[NL80211_ATTR_WIPHY_TX_POWER_LEVEL])
|
||||
{
|
||||
int32_t txp = nla_get_u32(tb_msg[NL80211_ATTR_WIPHY_TX_POWER_LEVEL]);
|
||||
ifInfo.txdBm = txp % 100;
|
||||
ifInfo.txdBm += txp / 100;
|
||||
}
|
||||
|
||||
if (tb_msg[NL80211_ATTR_IFINDEX])
|
||||
{
|
||||
instance->interfaces.push_back(ifInfo);
|
||||
}
|
||||
|
||||
return NL_OK;
|
||||
}
|
||||
|
||||
std::string WiFIController::macN2a(const unsigned char *arg)
|
||||
{
|
||||
int i, l;
|
||||
char mac_addr[20];
|
||||
|
||||
l = 0;
|
||||
for (i = 0; i < ETH_ALEN; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
sprintf(mac_addr + l, "%02x", arg[i]);
|
||||
l += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(mac_addr + l, ":%02x", arg[i]);
|
||||
l += 3;
|
||||
}
|
||||
}
|
||||
std::string ret = mac_addr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int WiFIController::freqToCHannel(int freq)
|
||||
{
|
||||
if (freq < 1000)
|
||||
return 0;
|
||||
/* see 802.11-2007 17.3.8.3.2 and Annex J */
|
||||
if (freq == 2484)
|
||||
return 14;
|
||||
/* see 802.11ax D6.1 27.3.23.2 and Annex E */
|
||||
else if (freq == 5935)
|
||||
return 2;
|
||||
else if (freq < 2484)
|
||||
return (freq - 2407) / 5;
|
||||
else if (freq >= 4910 && freq <= 4980)
|
||||
return (freq - 4000) / 5;
|
||||
else if (freq < 5950)
|
||||
return (freq - 5000) / 5;
|
||||
else if (freq <= 45000) /* DMG band lower limit */
|
||||
/* see 802.11ax D6.1 27.3.23.2 */
|
||||
return (freq - 5950) / 5;
|
||||
else if (freq >= 58320 && freq <= 70200)
|
||||
return (freq - 56160) / 2160;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WiFIController::phyLookup(char *name)
|
||||
{
|
||||
char buf[200];
|
||||
int fd, pos;
|
||||
|
||||
snprintf(buf, sizeof(buf), "/sys/class/ieee80211/%s/index", name);
|
||||
|
||||
fd = open(buf, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
pos = read(fd, buf, sizeof(buf) - 1);
|
||||
if (pos < 0)
|
||||
{
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
buf[pos] = '\0';
|
||||
close(fd);
|
||||
return atoi(buf);
|
||||
}
|
||||
169
src/WiFiCsiController.cpp
Normal file
169
src/WiFiCsiController.cpp
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "WiFiCsiController.h"
|
||||
#include "Csi.h"
|
||||
#include "GnuPlot.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <netlink/genl/genl.h>
|
||||
#include <netlink/genl/family.h>
|
||||
#include <netlink/genl/ctrl.h>
|
||||
#include <netlink/attr.h>
|
||||
#include <net/if.h>
|
||||
#include <thread>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "main.h"
|
||||
#include "Logger.h"
|
||||
#include "rs.h"
|
||||
|
||||
void WiFiCsiController::init()
|
||||
{
|
||||
Netlink::init();
|
||||
this->enableCsi();
|
||||
}
|
||||
|
||||
int WiFiCsiController::listenToCsi()
|
||||
{
|
||||
gnuPlot.init();
|
||||
|
||||
Cmd cmd{
|
||||
.id = NL80211_CMD_VENDOR,
|
||||
.idby = CIB_NETDEV,
|
||||
.nlFlags = 0,
|
||||
.device = if_nametoindex(MONITOR_INTERFACE_NAME),
|
||||
.handler = this->listenToCsiHandler,
|
||||
.valid_handler = this->processListenToCsiHandler,
|
||||
};
|
||||
|
||||
return this->nlExecCommand(cmd);
|
||||
}
|
||||
|
||||
int WiFiCsiController::listenToCsiHandler(struct nl80211_state *state, struct nl_msg *msg, void *arg)
|
||||
{
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_VENDOR_ID, 0x001735);
|
||||
NLA_PUT_U32(msg, NL80211_ATTR_VENDOR_SUBCMD, 0x24);
|
||||
return 0;
|
||||
nla_put_failure:
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
int WiFiCsiController::processListenToCsiHandler(struct nl_msg *msg, void *arg)
|
||||
{
|
||||
WiFiCsiController *instance = (WiFiCsiController *)arg;
|
||||
struct nlattr *attrs[MAX_CMD + 1];
|
||||
struct nlmsghdr *nlh = nlmsg_hdr(msg);
|
||||
|
||||
nlmsg_parse(nlh, 32, attrs, MAX_CMD, NULL);
|
||||
if (attrs[IWL_MVM_VENDOR_ATTR_CSI_HDR])
|
||||
{
|
||||
unsigned int dataLength = nla_len(attrs[IWL_MVM_VENDOR_ATTR_CSI_HDR]);
|
||||
if (dataLength != CSI_HEADER_LENGTH)
|
||||
{
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
uint8_t header[dataLength];
|
||||
uint8_t *data = (uint8_t *)nla_data(attrs[IWL_MVM_VENDOR_ATTR_CSI_HDR]);
|
||||
memcpy(header, data, dataLength);
|
||||
|
||||
if (attrs[IWL_MVM_VENDOR_ATTR_CSI_DATA])
|
||||
{
|
||||
dataLength = nla_len(attrs[IWL_MVM_VENDOR_ATTR_CSI_DATA]);
|
||||
uint8_t rawCsi[dataLength];
|
||||
uint8_t *dataCsi = (uint8_t *)nla_data(attrs[IWL_MVM_VENDOR_ATTR_CSI_DATA]);
|
||||
memcpy(rawCsi, dataCsi, dataLength);
|
||||
|
||||
Csi c;
|
||||
c.loadFromMemory(header, dataCsi);
|
||||
instance->gnuPlot.updateChart(c);
|
||||
|
||||
if (
|
||||
(c.channelWidth == RATE_MCS_CHAN_WIDTH_20 && arguments.channelWidth == 20) ||
|
||||
(c.channelWidth == RATE_MCS_CHAN_WIDTH_40 && arguments.channelWidth == 40) ||
|
||||
(c.channelWidth == RATE_MCS_CHAN_WIDTH_80 && arguments.channelWidth == 80) ||
|
||||
(c.channelWidth == RATE_MCS_CHAN_WIDTH_160 && arguments.channelWidth == 160)
|
||||
|
||||
)
|
||||
{
|
||||
if (
|
||||
(c.format == RATE_MCS_LEGACY_OFDM_MSK && arguments.format == "NOHT") ||
|
||||
(c.format == RATE_MCS_HT_MSK && arguments.format == "HT") ||
|
||||
(c.format == RATE_MCS_VHT_MSK && arguments.format == "VHT") ||
|
||||
(c.format == RATE_MCS_HE_MSK && arguments.format == "HESU") ||
|
||||
(c.format == RATE_MCS_EHT_MSK && arguments.format == "EHT")
|
||||
|
||||
)
|
||||
{
|
||||
c.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NL_SKIP;
|
||||
}
|
||||
|
||||
void WiFiCsiController::enableCsi(bool enable)
|
||||
{
|
||||
if (arguments.verbose)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
Logger::log(info) << "Enabling CSI measurement\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::log(info) << "Disabling CSI measurement\n";
|
||||
}
|
||||
}
|
||||
|
||||
const char *baseDir = "/sys/kernel/debug/iwlwifi";
|
||||
|
||||
if (!std::filesystem::is_directory(baseDir))
|
||||
{
|
||||
throw std::ios_base::failure("/sys/kernel/debug/iwlwifi not found. Did you compile iwlwifi with debugfs enabled?\n");
|
||||
return;
|
||||
}
|
||||
|
||||
bool csiEnabled = false;
|
||||
for (const auto &dirEntry : std::filesystem::directory_iterator(baseDir))
|
||||
{
|
||||
std::filesystem::path path = dirEntry.path().string() + "/iwlmvm/csi_enabled";
|
||||
if (std::filesystem::exists(path))
|
||||
{
|
||||
std::ofstream ofs(path);
|
||||
ofs << (enable ? "1" : "0") << std::endl;
|
||||
ofs.flush();
|
||||
ofs.close();
|
||||
csiEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!csiEnabled)
|
||||
{
|
||||
throw std::ios_base::failure("Failed to enable csi measurement. Maybe device not support it.\n");
|
||||
}
|
||||
}
|
||||
|
||||
WiFiCsiController::~WiFiCsiController()
|
||||
{
|
||||
this->enableCsi(false);
|
||||
}
|
||||
141
src/gui/CsiProcessingWindow.cpp
Normal file
141
src/gui/CsiProcessingWindow.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "gui/CsiProcessingWindow.h"
|
||||
#include "GnuPlot.h"
|
||||
#include "main.h"
|
||||
#include "Logger.h"
|
||||
#include "CsiProcessingWindow.h"
|
||||
|
||||
void CsiProcessingWindow::init(Glib::RefPtr<Gtk::Builder> &builder)
|
||||
{
|
||||
this->inputFile = Glib::RefPtr<Gtk::FileChooserButton>::cast_dynamic(builder->get_object("inputFile"));
|
||||
this->inputFile->signal_file_set().connect(sigc::mem_fun(*this, &CsiProcessingWindow::inputFileChange));
|
||||
|
||||
this->previousCsiButton = Glib::RefPtr<Gtk::Button>::cast_dynamic(builder->get_object("previousCsiButton"));
|
||||
this->previousCsiButton->signal_clicked().connect(sigc::mem_fun(*this, &CsiProcessingWindow::previousCsiButtonClicked));
|
||||
|
||||
this->nextCsiButton = Glib::RefPtr<Gtk::Button>::cast_dynamic(builder->get_object("nextCsiButton"));
|
||||
this->nextCsiButton->signal_clicked().connect(sigc::mem_fun(*this, &CsiProcessingWindow::nextCsiButtonClicked));
|
||||
|
||||
this->interpolationLinearRadioButton = Glib::RefPtr<Gtk::RadioButton>::cast_dynamic(builder->get_object("interpolationLinearRadioButton"));
|
||||
this->interpolationLinearRadioButton->signal_clicked().connect(sigc::mem_fun(*this, &CsiProcessingWindow::interpolationLinearRadioButtonClicked));
|
||||
|
||||
this->interpolationCubicRadioButton = Glib::RefPtr<Gtk::RadioButton>::cast_dynamic(builder->get_object("interpolationCubicRadioButton"));
|
||||
this->interpolationCubicRadioButton->signal_clicked().connect(sigc::mem_fun(*this, &CsiProcessingWindow::interpolationCubicRadioButtonClicked));
|
||||
|
||||
this->interpolationCosineButton = Glib::RefPtr<Gtk::RadioButton>::cast_dynamic(builder->get_object("interpolationCosineButton"));
|
||||
this->interpolationCosineButton->signal_clicked().connect(sigc::mem_fun(*this, &CsiProcessingWindow::interpolationCosineButtonClicked));
|
||||
|
||||
this->phaseLinearTransformCheckButton = Glib::RefPtr<Gtk::CheckButton>::cast_dynamic(builder->get_object("phaseLinearTransformCheckButton"));
|
||||
this->phaseLinearTransformCheckButton->signal_clicked().connect(sigc::mem_fun(*this, &CsiProcessingWindow::phaseLinearTransformCheckButtonClicked));
|
||||
|
||||
this->processingSaveGtkButton = Glib::RefPtr<Gtk::Button>::cast_dynamic(builder->get_object("processingSaveGtkButton"));
|
||||
this->processingSaveGtkButton->signal_clicked().connect(sigc::mem_fun(*this, &CsiProcessingWindow::processingSaveGtkButtonClicked));
|
||||
|
||||
this->currentDataCount = Glib::RefPtr<Gtk::Label>::cast_dynamic(builder->get_object("currentDataCount"));
|
||||
}
|
||||
|
||||
void CsiProcessingWindow::inputFileChange()
|
||||
{
|
||||
arguments.inputFile = this->inputFile->get_filename();
|
||||
csiProcessor.loadCsi();
|
||||
this->refresh();
|
||||
}
|
||||
|
||||
void CsiProcessingWindow::refresh()
|
||||
{
|
||||
std::string indexLabelText = std::to_string(this->currentIndex) + " " + std::to_string(this->csiProcessor.csiData.size());
|
||||
|
||||
this->currentDataCount->set_text(indexLabelText);
|
||||
|
||||
if (!this->csiProcessor.csiData.empty())
|
||||
{
|
||||
gnuPlot.updateChart(*this->csiProcessor.csiData[this->currentIndex]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CsiProcessingWindow::previousCsiButtonClicked()
|
||||
{
|
||||
if (this->currentIndex > 0)
|
||||
{
|
||||
this->currentIndex--;
|
||||
this->csiProcessor.process(*this->csiProcessor.csiData[this->currentIndex]);
|
||||
this->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CsiProcessingWindow::nextCsiButtonClicked()
|
||||
{
|
||||
if (this->currentIndex < (this->csiProcessor.csiData.size() - 1))
|
||||
{
|
||||
this->currentIndex++;
|
||||
this->csiProcessor.process(*this->csiProcessor.csiData[this->currentIndex]);
|
||||
this->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CsiProcessingWindow::interpolationLinearRadioButtonClicked()
|
||||
{
|
||||
if (!this->csiProcessor.csiData.empty())
|
||||
{
|
||||
arguments.processors[processor::interpolateLinear] = this->interpolationLinearRadioButton->get_active();
|
||||
this->csiProcessor.process(*this->csiProcessor.csiData[this->currentIndex]);
|
||||
this->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CsiProcessingWindow::interpolationCubicRadioButtonClicked()
|
||||
{
|
||||
if (!this->csiProcessor.csiData.empty())
|
||||
{
|
||||
arguments.processors[processor::interpolateCubic] = this->interpolationCubicRadioButton->get_active();
|
||||
this->csiProcessor.process(*this->csiProcessor.csiData[this->currentIndex]);
|
||||
this->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CsiProcessingWindow::interpolationCosineButtonClicked()
|
||||
{
|
||||
if (!this->csiProcessor.csiData.empty())
|
||||
{
|
||||
arguments.processors[processor::interpolateCosine] = this->interpolationCosineButton->get_active();
|
||||
this->csiProcessor.process(*this->csiProcessor.csiData[this->currentIndex]);
|
||||
this->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CsiProcessingWindow::phaseLinearTransformCheckButtonClicked()
|
||||
{
|
||||
if (!this->csiProcessor.csiData.empty())
|
||||
{
|
||||
arguments.processors[processor::phaseCalibrationLinearTransform] = this->phaseLinearTransformCheckButton->get_active();
|
||||
this->csiProcessor.process(*this->csiProcessor.csiData[this->currentIndex]);
|
||||
this->refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void CsiProcessingWindow::processingSaveGtkButtonClicked()
|
||||
{
|
||||
if (!this->csiProcessor.csiData.empty())
|
||||
{
|
||||
arguments.outputFile = "processedCsi.bin";
|
||||
this->csiProcessor.saveCsi();
|
||||
}
|
||||
}
|
||||
138
src/gui/GnuPlot.cpp
Normal file
138
src/gui/GnuPlot.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "gui/GnuPlot.h"
|
||||
#include "main.h"
|
||||
#include "GnuPlot.h"
|
||||
|
||||
void GnuPlot::init()
|
||||
{
|
||||
if (!arguments.plot || gnuPlotPipe)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->gnuPlotPipe = popen("gnuplot > NUL 2>&1", "w");
|
||||
fprintf(this->gnuPlotPipe, "set term x11 noraise\n");
|
||||
fflush(this->gnuPlotPipe);
|
||||
}
|
||||
|
||||
void GnuPlot::setWindow(uint64_t id)
|
||||
{
|
||||
this->gnuPlotPipe = popen("gnuplot > NUL 2>&1", "w");
|
||||
fprintf(this->gnuPlotPipe, "set term x11 noraise\n");
|
||||
fprintf(this->gnuPlotPipe, "set terminal x11 window \"%#lx\"\n", id);
|
||||
fflush(this->gnuPlotPipe);
|
||||
}
|
||||
|
||||
void GnuPlot::setBlank()
|
||||
{
|
||||
const char *cmd = R"(
|
||||
set multiplot layout 2,1
|
||||
set ylabel "Magnitude"
|
||||
set xlabel "Subcarrier Index"
|
||||
set title "Magnitude (Abs) "
|
||||
set autoscale x
|
||||
set xrange [0:1]
|
||||
set yrange [0:1]
|
||||
plot 1/0
|
||||
set ylabel "Phase (rad) "
|
||||
set xlabel "Subcarrier Index"
|
||||
set title "Phase "
|
||||
set autoscale
|
||||
set xrange [0:1]
|
||||
set yrange [0:1]
|
||||
plot 1/0
|
||||
)";
|
||||
this->lastCmd = cmd;
|
||||
fprintf(this->gnuPlotPipe, cmd);
|
||||
fflush(this->gnuPlotPipe);
|
||||
}
|
||||
|
||||
void GnuPlot::updateChart(Csi &csi)
|
||||
{
|
||||
if (!arguments.plot)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
// ss << "set multiplot layout 2,1";
|
||||
ss << R"(
|
||||
set multiplot layout 2,1
|
||||
set ylabel "Magnitude"
|
||||
set xlabel "Subcarrier Index"
|
||||
set title "Magnitude (Abs) "
|
||||
set autoscale x
|
||||
)";
|
||||
|
||||
std::stringstream plotCmd;
|
||||
plotCmd << "set xrange [1:" << csi.numSubCarriers << "]\n";
|
||||
plotCmd << "plot";
|
||||
for (uint32_t tx = 0; tx < csi.numTx; tx++)
|
||||
{
|
||||
for (uint32_t rx = 0; rx < csi.numRx; rx++)
|
||||
{
|
||||
plotCmd << " '-' with lines title \"RX" << (rx + 1) << "TX" << (tx + 1) << "\", ";
|
||||
}
|
||||
}
|
||||
plotCmd << "\n";
|
||||
ss << plotCmd.str();
|
||||
|
||||
std::stringstream dataMagnitude;
|
||||
std::stringstream dataPhase;
|
||||
|
||||
uint32_t index = 0;
|
||||
for (uint32_t rx = 0; rx < csi.numRx; rx++)
|
||||
{
|
||||
for (uint32_t tx = 0; tx < csi.numTx; tx++)
|
||||
{
|
||||
for (uint32_t n = 0; n < csi.numSubCarriers; n++)
|
||||
{
|
||||
dataMagnitude << (n + 1) << " " << csi.magnitude[index] << "\n";
|
||||
dataPhase << (n + 1) << " " << csi.phase[index] << "\n";
|
||||
index++;
|
||||
}
|
||||
dataMagnitude << "e\n";
|
||||
dataPhase << "e\n";
|
||||
}
|
||||
}
|
||||
|
||||
ss << dataMagnitude.str();
|
||||
|
||||
ss << R"(
|
||||
set ylabel "Phase (rad) "
|
||||
set xlabel "Subcarrier Index"
|
||||
set title "Phase "
|
||||
set autoscale
|
||||
)";
|
||||
|
||||
ss << plotCmd.str();
|
||||
ss << dataPhase.str();
|
||||
ss << "unset multiplot\n";
|
||||
|
||||
this->lastCmd = ss.str();
|
||||
fprintf(this->gnuPlotPipe, ss.str().c_str());
|
||||
fflush(this->gnuPlotPipe);
|
||||
}
|
||||
|
||||
void GnuPlot::reload()
|
||||
{
|
||||
fprintf(this->gnuPlotPipe, this->lastCmd.c_str());
|
||||
fflush(this->gnuPlotPipe);
|
||||
}
|
||||
285
src/gui/MainWindow.cpp
Normal file
285
src/gui/MainWindow.cpp
Normal file
@ -0,0 +1,285 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "gui/MainWindow.h"
|
||||
#include "main.h"
|
||||
#include <iostream>
|
||||
#include "MainWindow.h"
|
||||
#include "MainController.h"
|
||||
#include "WiFIController.h"
|
||||
#include "Logger.h"
|
||||
|
||||
MainWindow::MainWindow(BaseObjectType *obj, Glib::RefPtr<Gtk::Builder> const &builder) : Gtk::ApplicationWindow(obj), builder{builder}
|
||||
{
|
||||
set_title("FeitCSI");
|
||||
set_default_size(1000, 800);
|
||||
|
||||
this->measureButton = Glib::RefPtr<Gtk::Button>::cast_dynamic(this->builder->get_object("measureButton"));
|
||||
this->measureButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::measureButtonClicked));
|
||||
|
||||
this->injectButton = Glib::RefPtr<Gtk::Button>::cast_dynamic(this->builder->get_object("injectButton"));
|
||||
this->injectButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::injectButtonClicked));
|
||||
|
||||
this->frequency = Glib::RefPtr<Gtk::SpinButton>::cast_dynamic(this->builder->get_object("frequency"));
|
||||
this->frequency->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::frequencyChange));
|
||||
|
||||
this->channelWidth = Glib::RefPtr<Gtk::ComboBoxText>::cast_dynamic(this->builder->get_object("channelWidth"));
|
||||
this->channelWidth->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::channelWidthChange));
|
||||
|
||||
this->outputFile = Glib::RefPtr<Gtk::FileChooserButton>::cast_dynamic(this->builder->get_object("outputFile"));
|
||||
this->outputFile->signal_file_set().connect(sigc::mem_fun(*this, &MainWindow::outputFileChange));
|
||||
|
||||
Glib::RefPtr<Gtk::FileChooserDialog> fDialog = Glib::RefPtr<Gtk::FileChooserDialog>::cast_dynamic(this->builder->get_object("filechooserdialog1"));
|
||||
|
||||
fDialog->set_action(Gtk::FILE_CHOOSER_ACTION_SAVE);
|
||||
fDialog->add_button("_Cancel", GTK_RESPONSE_CANCEL);
|
||||
fDialog->add_button("_Accept", GTK_RESPONSE_ACCEPT);
|
||||
this->filePath = Glib::RefPtr<Gtk::Label>::cast_dynamic(this->builder->get_object("filePath"));
|
||||
|
||||
this->format = Glib::RefPtr<Gtk::ComboBoxText>::cast_dynamic(this->builder->get_object("format"));
|
||||
this->format->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::formatChange));
|
||||
|
||||
this->mcs = Glib::RefPtr<Gtk::ComboBoxText>::cast_dynamic(this->builder->get_object("mcs"));
|
||||
this->mcs->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::mcsChange));
|
||||
|
||||
this->spatialStreams = Glib::RefPtr<Gtk::ComboBoxText>::cast_dynamic(this->builder->get_object("spatialStreams"));
|
||||
this->spatialStreams->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::spatialStreamsChange));
|
||||
|
||||
this->guardInterval = Glib::RefPtr<Gtk::ComboBoxText>::cast_dynamic(this->builder->get_object("guardInterval"));
|
||||
this->guardInterval->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::guardIntervalChange));
|
||||
|
||||
this->ltf = Glib::RefPtr<Gtk::ComboBoxText>::cast_dynamic(this->builder->get_object("ltf"));
|
||||
this->ltf->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::ltfChange));
|
||||
|
||||
this->txPower = Glib::RefPtr<Gtk::ComboBoxText>::cast_dynamic(this->builder->get_object("txPower"));
|
||||
this->txPower->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::txPowerChange));
|
||||
|
||||
this->coding = Glib::RefPtr<Gtk::ComboBoxText>::cast_dynamic(this->builder->get_object("coding"));
|
||||
this->coding->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::codingChange));
|
||||
|
||||
this->injectDelay = Glib::RefPtr<Gtk::SpinButton>::cast_dynamic(this->builder->get_object("injectDelay"));
|
||||
this->injectDelay->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::injectDelayChange));
|
||||
|
||||
this->injectRepeat = Glib::RefPtr<Gtk::SpinButton>::cast_dynamic(this->builder->get_object("injectRepeat"));
|
||||
this->injectRepeat->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::injectRepeatChange));
|
||||
|
||||
this->errorMessages = Glib::RefPtr<Gtk::Label>::cast_dynamic(this->builder->get_object("errorMessages"));
|
||||
|
||||
this->chartSocket = Glib::RefPtr<Gtk::Socket>::cast_dynamic(this->builder->get_object("chartSocket"));
|
||||
|
||||
this->console = Glib::RefPtr<Gtk::TextView>::cast_dynamic(this->builder->get_object("console"));
|
||||
Glib::RefPtr<Gtk::ScrolledWindow> consoleScrollbar = Glib::RefPtr<Gtk::ScrolledWindow>::cast_dynamic(this->builder->get_object("consoleScrollbar"));
|
||||
this->consoleScrollbarAdjustment = consoleScrollbar->get_vadjustment();
|
||||
|
||||
this->errorDialog = Glib::RefPtr<Gtk::MessageDialog>::cast_dynamic(this->builder->get_object("errorDialog"));
|
||||
Glib::RefPtr<Gtk::Button> errorDialogOkBtn = Glib::RefPtr<Gtk::Button>::cast_dynamic(this->builder->get_object("errorDialogOkBtn"));
|
||||
errorDialogOkBtn->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::closeButton));
|
||||
|
||||
Logger::guiOutput = this->console->get_buffer();
|
||||
|
||||
this->gnuPlot.setWindow(this->chartSocket->get_id());
|
||||
|
||||
this->signal_check_resize().connect_notify(sigc::mem_fun(*this, &MainWindow::onResize));
|
||||
|
||||
this->signal_show().connect(sigc::mem_fun(*this, &MainWindow::onWindowInit));
|
||||
this->signal_delete_event().connect(sigc::mem_fun(*this, &MainWindow::onWindowDelete));
|
||||
|
||||
this->csiProcessingWindow.init(this->builder);
|
||||
}
|
||||
|
||||
void MainWindow::fatalError(std::string msg)
|
||||
{
|
||||
errorDialog->set_message(msg + "\n Program will be closed now");
|
||||
errorDialog->show();
|
||||
}
|
||||
|
||||
void MainWindow::closeButton()
|
||||
{
|
||||
this->errorDialog->close();
|
||||
this->close();
|
||||
}
|
||||
|
||||
bool MainWindow::onWindowDelete(GdkEventAny *event)
|
||||
{
|
||||
MainController *mainController = MainController::getInstance();
|
||||
mainController->deleteInstance();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MainWindow::onWindowInit()
|
||||
{
|
||||
Glib::RefPtr<Gtk::Paned> socketConsolePaned = Glib::RefPtr<Gtk::Paned>::cast_dynamic(this->builder->get_object("socketConsolePaned"));
|
||||
socketConsolePaned->set_position(socketConsolePaned->get_allocated_height() * 0.8);
|
||||
MainController *mainController = MainController::getInstance();
|
||||
mainController->initInterface();
|
||||
this->gnuPlot.setBlank();
|
||||
}
|
||||
|
||||
void MainWindow::onResize()
|
||||
{
|
||||
if (this->measuring)
|
||||
{
|
||||
this->consoleScrollbarAdjustment->set_value(this->consoleScrollbarAdjustment->get_upper());
|
||||
return;
|
||||
}
|
||||
|
||||
int pHeight = this->chartSocket->get_allocated_height();
|
||||
int pWidth = this->chartSocket->get_allocated_width();
|
||||
|
||||
if (pHeight < 10 && pWidth < 10)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (pWidth != this->chartWidth || pHeight != this->chartHeight)
|
||||
{
|
||||
this->gnuPlot.reload();
|
||||
this->chartWidth = pWidth;
|
||||
this->chartHeight = pHeight;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::frequencyChange()
|
||||
{
|
||||
int v = std::atoi(this->frequency->get_text().raw().c_str());
|
||||
arguments.frequency = (uint16_t)v;
|
||||
}
|
||||
|
||||
void MainWindow::channelWidthChange()
|
||||
{
|
||||
arguments.bandwidth = this->channelWidth->get_active_text().raw();
|
||||
struct ChanMode chMode = WiFIController::getChanMode(arguments.bandwidth.c_str());
|
||||
arguments.channelWidth = WiFIController::chanModeToWidth(chMode);
|
||||
}
|
||||
|
||||
void MainWindow::outputFileChange()
|
||||
{
|
||||
arguments.outputFile = this->outputFile->get_filename();
|
||||
this->filePath->set_text(arguments.outputFile);
|
||||
}
|
||||
|
||||
void MainWindow::formatChange()
|
||||
{
|
||||
arguments.format = this->format->get_active_text().raw();
|
||||
}
|
||||
|
||||
void MainWindow::mcsChange()
|
||||
{
|
||||
int v = std::atoi(this->mcs->get_active_text().raw().c_str());
|
||||
arguments.mcs = (uint8_t)v;
|
||||
}
|
||||
|
||||
void MainWindow::spatialStreamsChange()
|
||||
{
|
||||
int v = std::atoi(this->spatialStreams->get_active_text().raw().c_str());
|
||||
arguments.spatialStreams = (uint8_t)v;
|
||||
}
|
||||
|
||||
void MainWindow::ltfChange()
|
||||
{
|
||||
arguments.ltf = this->ltf->get_active_text().raw();
|
||||
}
|
||||
|
||||
void MainWindow::guardIntervalChange()
|
||||
{
|
||||
int v = std::atoi(this->guardInterval->get_active_text().raw().c_str());
|
||||
arguments.guardInterval = (uint16_t)v;
|
||||
}
|
||||
|
||||
void MainWindow::txPowerChange()
|
||||
{
|
||||
int v = std::atoi(this->txPower->get_active_text().raw().c_str());
|
||||
arguments.txPower = (uint8_t)v;
|
||||
}
|
||||
|
||||
void MainWindow::codingChange()
|
||||
{
|
||||
arguments.coding = this->coding->get_active_text().raw();
|
||||
}
|
||||
|
||||
void MainWindow::injectDelayChange()
|
||||
{
|
||||
int v = std::atoi(this->injectDelay->get_text().raw().c_str());
|
||||
arguments.injectDelay = (uint32_t)v;
|
||||
}
|
||||
|
||||
void MainWindow::injectRepeatChange()
|
||||
{
|
||||
int v = std::atoi(this->injectRepeat->get_text().raw().c_str());
|
||||
arguments.injectRepeat = (uint32_t)v;
|
||||
}
|
||||
|
||||
void MainWindow::updateErrorMessages()
|
||||
{
|
||||
std::string concatErrors;
|
||||
for (const auto &kv : this->errors)
|
||||
{
|
||||
concatErrors += kv.second + "\n";
|
||||
}
|
||||
this->errorMessages->set_text(concatErrors);
|
||||
}
|
||||
|
||||
void MainWindow::measureButtonClicked()
|
||||
{
|
||||
MainController *mainController = MainController::getInstance();
|
||||
if (!this->measuring)
|
||||
{
|
||||
mainController->measureCsi();
|
||||
this->measureButton->set_label("Stop measure");
|
||||
this->measuring = true;
|
||||
} else {
|
||||
mainController->measureCsi(true);
|
||||
this->measureButton->set_label("Measure");
|
||||
this->measuring = false;
|
||||
}
|
||||
this->updateSensitivity();
|
||||
}
|
||||
|
||||
void MainWindow::injectButtonClicked()
|
||||
{
|
||||
MainController *mainController = MainController::getInstance();
|
||||
if (!this->injecting)
|
||||
{
|
||||
mainController->injectPackets();
|
||||
this->injectButton->set_label("Stop inject");
|
||||
this->injecting = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainController->injectPackets(true);
|
||||
this->injectButton->set_label("Inject");
|
||||
this->injecting = false;
|
||||
}
|
||||
this->updateSensitivity();
|
||||
}
|
||||
|
||||
void MainWindow::updateSensitivity()
|
||||
{
|
||||
this->frequency->set_sensitive(!this->measuring);
|
||||
this->channelWidth->set_sensitive(!this->measuring);
|
||||
this->outputFile->set_sensitive(!this->measuring);
|
||||
|
||||
this->format->set_sensitive(!this->injecting);
|
||||
this->mcs->set_sensitive(!this->injecting);
|
||||
this->spatialStreams->set_sensitive(!this->injecting);
|
||||
this->guardInterval->set_sensitive(!this->injecting);
|
||||
this->txPower->set_sensitive(!this->injecting);
|
||||
this->coding->set_sensitive(!this->injecting);
|
||||
this->injectDelay->set_sensitive(!this->injecting);
|
||||
this->injectRepeat->set_sensitive(!this->injecting);
|
||||
}
|
||||
48
src/interpolation.cpp
Normal file
48
src/interpolation.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "interpolation.h"
|
||||
#include <cmath>
|
||||
|
||||
namespace interpolation
|
||||
{
|
||||
double linearInterpolate(double y1, double y2, double mu)
|
||||
{
|
||||
return (y1 * (1 - mu) + y2 * mu);
|
||||
}
|
||||
|
||||
double cosineInterpolate(double y1, double y2, double mu)
|
||||
{
|
||||
double mu2;
|
||||
mu2 = (1 - cos(mu * M_PI)) / 2;
|
||||
return (y1 * (1 - mu2) + y2 * mu2);
|
||||
}
|
||||
|
||||
double cubicInterpolate(double y0, double y1, double y2, double y3, double mu)
|
||||
{
|
||||
double a0, a1, a2, a3, mu2;
|
||||
|
||||
mu2 = mu * mu;
|
||||
a0 = y3 - y2 - y0 + y1;
|
||||
a1 = y0 - y1 - a0;
|
||||
a2 = y2 - y0;
|
||||
a3 = y1;
|
||||
|
||||
return (a0 * mu * mu2 + a1 * mu2 + a2 * mu + a3);
|
||||
}
|
||||
}
|
||||
317
src/main.cpp
Normal file
317
src/main.cpp
Normal file
@ -0,0 +1,317 @@
|
||||
/*
|
||||
* FeitCSI is the tool for extracting CSI information from supported intel NICs.
|
||||
* Copyright (C) 2023 Miroslav Hutar.
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <argp.h>
|
||||
#include <chrono>
|
||||
#include "Csi.h"
|
||||
#include "WiFIController.h"
|
||||
#include "WiFiCsiController.h"
|
||||
#include "Netlink.h"
|
||||
#include "main.h"
|
||||
#include "PacketInjector.h"
|
||||
#include "MainController.h"
|
||||
#include "Logger.h"
|
||||
|
||||
struct Arguments arguments;
|
||||
|
||||
const char *argp_program_version =
|
||||
"argp-ex3 1.0";
|
||||
const char *argp_program_bug_address =
|
||||
"<bug-gnu-utils@gnu.org>";
|
||||
|
||||
/* Program documentation. */
|
||||
static char doc[] =
|
||||
"Argp example #3 -- a program with options and arguments using argp";
|
||||
|
||||
/* A description of the arguments we accept. */
|
||||
static char args_doc[] = "ARG1 ARG2";
|
||||
|
||||
/* The options we understand. */
|
||||
static struct argp_option options[] = {
|
||||
{"frequency", 'f', "FREQUENCY", 0, "Frequency to measure/inject CSI"},
|
||||
{"channel-width", 'w', "CHANNELWIDTH", 0, "Channel width to measure/inject CSI. Possible values [20|40|HT40-|80|160]"},
|
||||
{"output-file", 'o', "FILE", 0, "Output file where measurements should be stored."},
|
||||
{"mcs", 'm', "MCS", 0, "Mcs index [0-11]"},
|
||||
{"format", 'r', "FORMAT", 0, "Data frame format [NOHT|HT|VHT|HESU]"},
|
||||
{"spatial-streams", 's', "SPATIALSTREAMS", 0, "Number of spatial streams [1|2]"},
|
||||
{"guard-interval", 'g', "GUARDINTERVAL", 0, "Guard interval in ns [400|800]"},
|
||||
{"ltf", 'l', "LTF", 0, "HE LTF [2xLTF+0.8|2xLTF+1.6|4xLTF+3.2|4xLTF+0.8]"},
|
||||
{"coding", 'c', "CODING", 0, "Coding scheme [LDPC|BCC]"},
|
||||
{"tx-power", 't', "TXPOWER", 0, "TX power of antenna in dBm [1-22]"},
|
||||
{"mode", 'i', "MODE", 0, "Mode of program[measure|inject|measureinject]"},
|
||||
{"inject-delay", 'd', "INJECTDELAY", 0, "Delay between frame injections is us"},
|
||||
{"inject-repeat", 'j', "INJECTREPEAT", 0, "How many times inject frame"},
|
||||
{"verbose", 'v', 0, OPTION_ARG_OPTIONAL, "Produce verbose output"},
|
||||
{"plot", 'p', 0, OPTION_ARG_OPTIONAL, "Plot CSI data"},
|
||||
{"gui", 'x', 0, OPTION_ARG_OPTIONAL, "Run application in GUI"},
|
||||
{0}};
|
||||
|
||||
/* Used by main to communicate with parse_opt. */
|
||||
|
||||
/* Parse a single option. */
|
||||
static error_t
|
||||
parse_opt(int key, char *arg, struct argp_state *state)
|
||||
{
|
||||
/* Get the input argument from argp_parse, which we
|
||||
know is a pointer to our arguments structure. */
|
||||
struct Arguments *args = (struct Arguments *)state->input;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 'v':
|
||||
args->verbose = true;
|
||||
break;
|
||||
case 'x':
|
||||
args->gui = true;
|
||||
break;
|
||||
case 'p':
|
||||
args->plot = true;
|
||||
break;
|
||||
case 'i':
|
||||
{
|
||||
args->mode.assign(arg);
|
||||
if (args->mode == "measure")
|
||||
{
|
||||
args->measure = true;
|
||||
}
|
||||
else if (args->mode == "inject")
|
||||
{
|
||||
args->inject = true;
|
||||
args->measure = false;
|
||||
}
|
||||
else if (args->mode == "measureinject")
|
||||
{
|
||||
args->measure = true;
|
||||
args->inject = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
argp_failure(state, 1, 0, "Bad mode. Possible values [measure|inject|measureinject]");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'm':
|
||||
{
|
||||
int mcs = std::atoi(arg);
|
||||
if (mcs < 0 || mcs > 11)
|
||||
{
|
||||
argp_failure(state, 1, 0, "Bad MCS index. Possible values [0-11]");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
args->mcs = (uint8_t)mcs;
|
||||
break;
|
||||
}
|
||||
case 'r':
|
||||
{
|
||||
args->format.assign(arg);
|
||||
if (args->format == "NOHT" || args->format == "HT" || args->format == "VHT" || args->format == "HESU")
|
||||
{
|
||||
} else
|
||||
{
|
||||
argp_failure(state, 1, 0, "Bad format. Possible values [NOHT|HT|VHT|HESU]");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'c':
|
||||
{
|
||||
args->coding.assign(arg);
|
||||
if (args->coding == "LDPC" || args->coding == "BCC")
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
argp_failure(state, 1, 0, "Bad coding. Possible values [LDPC|BCC]");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'l':
|
||||
{
|
||||
args->ltf.assign(arg);
|
||||
if (args->ltf == "1xLTF+0.8" || args->ltf == "2xLTF+0.8" || args->ltf == "2xLTF+1.6" || args->ltf == "4xLTF+3.2" || args->ltf == "4xLTF+0.8")
|
||||
{
|
||||
} else
|
||||
{
|
||||
argp_failure(state, 1, 0, "Bad LTF. Possible values [2xLTF+0.8|2xLTF+1.6|4xLTF+3.2|4xLTF+0.8]");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'g':
|
||||
{
|
||||
int gi = std::atoi(arg);
|
||||
if (gi == 400 || gi == 800)
|
||||
{
|
||||
args->guardInterval = (uint16_t)gi;
|
||||
}
|
||||
else
|
||||
{
|
||||
argp_failure(state, 1, 0, "Bad guard interval. Possible values [400|800]");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'd':
|
||||
{
|
||||
int injd = std::atoi(arg);
|
||||
if (injd <= 0)
|
||||
{
|
||||
argp_failure(state, 1, 0, "Inject delay is not correct number");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
args->injectDelay = (uint32_t)injd;
|
||||
break;
|
||||
}
|
||||
case 'j':
|
||||
{
|
||||
int injr = std::atoi(arg);
|
||||
if (injr <= 0)
|
||||
{
|
||||
argp_failure(state, 1, 0, "Inject repeat is not correct number");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
args->injectRepeat = (uint32_t)injr;
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
{
|
||||
int ss = std::atoi(arg);
|
||||
if (ss < 1 || ss > 2)
|
||||
{
|
||||
argp_failure(state, 1, 0, "Bad spatial stream. Possible values [1|2]");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
args->spatialStreams = (uint8_t)ss;
|
||||
break;
|
||||
}
|
||||
case 't':
|
||||
{
|
||||
int tx = std::atoi(arg);
|
||||
if (tx < 1 || tx > 22)
|
||||
{
|
||||
argp_failure(state, 1, 0, "Bad tx power. Possible values [1-22]");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
args->txPower = (uint8_t)tx;
|
||||
break;
|
||||
}
|
||||
case 'f':
|
||||
{
|
||||
int f = std::atoi(arg);
|
||||
if (f <= 0)
|
||||
{
|
||||
argp_failure(state, 1, 0, "Frequency is not correct");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
args->frequency = (uint16_t)f;
|
||||
break;
|
||||
}
|
||||
case 'w':
|
||||
{
|
||||
struct ChanMode chMode = WiFIController::getChanMode(arg);
|
||||
if (chMode.width == 0)
|
||||
{
|
||||
argp_failure(state, 1, 0, "Bad bandwidth. Possible values of bandwidth are [20|40|HT40-|80|160]");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
args->bandwidth = arg;
|
||||
args->channelWidth = WiFIController::chanModeToWidth(chMode);
|
||||
break;
|
||||
}
|
||||
case 'o':
|
||||
args->outputFile = arg;
|
||||
break;
|
||||
case ARGP_KEY_ARG:
|
||||
case ARGP_KEY_END:
|
||||
if (args->frequency == 0 ||
|
||||
args->bandwidth.empty())
|
||||
{
|
||||
argp_failure(state, 1, 0, "Fill required arguments -f -b . See --help for more information");
|
||||
exit(ARGP_ERR_UNKNOWN);
|
||||
}
|
||||
return 0;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Our argp parser. */
|
||||
static struct argp argp = {options, parse_opt, args_doc, doc};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct Arguments defValues = {
|
||||
.verbose = false,
|
||||
.frequency = 2412,
|
||||
.gui = false,
|
||||
.plot = false,
|
||||
.bandwidth = "20",
|
||||
.mcs = 0,
|
||||
.channelWidth = 20,
|
||||
.spatialStreams = 1,
|
||||
.txPower = 10,
|
||||
.guardInterval = 400,
|
||||
.injectDelay = 100000,
|
||||
.injectRepeat = 0,
|
||||
.coding = "LDPC",
|
||||
.format = "HT",
|
||||
.inject = false,
|
||||
.measure = true,
|
||||
.mode = "measure",
|
||||
.ltf = "1xLTF+0.8",
|
||||
};
|
||||
|
||||
arguments = defValues;
|
||||
|
||||
if (arguments.outputFile.empty())
|
||||
{
|
||||
const auto t = std::chrono::system_clock::now();
|
||||
int64_t tInt = std::chrono::duration_cast<std::chrono::seconds>(t.time_since_epoch()).count();
|
||||
arguments.outputFile = "FeitCSI_" + std::to_string(tInt) + ".dat";
|
||||
}
|
||||
|
||||
/* Default values. */
|
||||
|
||||
argp_parse(&argp, argc, argv, 0, 0, &arguments);
|
||||
|
||||
// all arguments ok and sanitized go next
|
||||
|
||||
MainController *mainController = MainController::getInstance();
|
||||
if (!arguments.gui)
|
||||
{
|
||||
mainController->runNoGui();
|
||||
} else
|
||||
{
|
||||
arguments = defValues;
|
||||
mainController->runGui();
|
||||
}
|
||||
|
||||
if (arguments.verbose)
|
||||
{
|
||||
Logger::log(info) << "Exiting...\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// lib to install compile libgtkmm-3.0-dev libnl-genl-3-dev libiw-dev libpcap-dev
|
||||
// fix default output file when GUI running
|
||||
Loading…
Reference in New Issue
Block a user