Adding xbnet as submodule
Create and publish a Docker image / build-and-push-image (push) Successful in 5m10s
Details
Create and publish a Docker image / build-and-push-image (push) Successful in 5m10s
Details
This commit is contained in:
parent
a6cdf2efd7
commit
deffceff5f
|
@ -0,0 +1,4 @@
|
|||
[submodule "xbnet"]
|
||||
path = xbnet
|
||||
url = https://git.spirirobotics.com/Spiri/xbnet
|
||||
branch = main
|
|
@ -1,51 +0,0 @@
|
|||
name: build
|
||||
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
tags: '*'
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Prep build for ${{ matrix.os }}
|
||||
run: sudo apt-get install libudev-dev
|
||||
- name: Build for ${{ matrix.os }}
|
||||
run: cargo build --verbose --release
|
||||
- name: Run tests for ${{ matrix.os }}
|
||||
run: cargo test --verbose
|
||||
- name: Create Release for ${{ matrix.os }}
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
continue-on-error: true
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
- name: Upload binaries to release for ${{ matrix.os }}
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
if: startsWith(github.ref, 'refs/tags')
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: target/release/xbnet
|
||||
asset_name: xbnet-${{ matrix.os }}.bin
|
||||
tag: ${{ github.ref }}
|
||||
overwrite: true
|
||||
body: ""
|
|
@ -1,5 +0,0 @@
|
|||
/target
|
||||
**/*.rs.bk
|
||||
*~
|
||||
\#*
|
||||
br*.txt
|
674
xbnet/COPYING
674
xbnet/COPYING
|
@ -1,674 +0,0 @@
|
|||
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>.
|
|
@ -1,479 +0,0 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "CoreFoundation-sys"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "IOKit-sys"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"CoreFoundation-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.33.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "etherparse"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "format_escape_default"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libudev"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libudev-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libudev-sys"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mach"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mach"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "serialport"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"CoreFoundation-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"IOKit-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libudev 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simplelog"
|
||||
version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"chrono 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "structopt"
|
||||
version = "0.3.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt-derive 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "structopt-derive"
|
||||
version = "0.4.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro-error 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"proc-macro2 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tun-tap"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-xid"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "xbnet"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"etherparse 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"format_escape_default 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serialport 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"simplelog 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tun-tap 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum CoreFoundation-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e9889e6db118d49d88d84728d0e964d973a5680befb5f85f55141beea5c20b"
|
||||
"checksum IOKit-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "99696c398cbaf669d2368076bdb3d627fb0ce51a26899d7c61228c5c0af3bf4a"
|
||||
"checksum aho-corasick 0.7.13 (registry+https://github.com/rust-lang/crates.io-index)" = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86"
|
||||
"checksum autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||
"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
||||
"checksum bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38"
|
||||
"checksum cc 1.0.60 (registry+https://github.com/rust-lang/crates.io-index)" = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c"
|
||||
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
"checksum chrono 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)" = "9942f5f46d88ae2926edcd93a8a5b24151133cf6dc4e5f4c3fadb1c532ac8041"
|
||||
"checksum clap 2.33.3 (registry+https://github.com/rust-lang/crates.io-index)" = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"
|
||||
"checksum crossbeam-channel 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa"
|
||||
"checksum crossbeam-utils 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"
|
||||
"checksum etherparse 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2fa20922281f9ee5ffcda45e80d56085829279f1270f79fbabc39809a4354807"
|
||||
"checksum format_escape_default 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb2a22fc101e1c1be19e7401b58d502802839a4a7fd58ad35369a386b4639e9"
|
||||
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
|
||||
"checksum hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
|
||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
"checksum libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235"
|
||||
"checksum libudev 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea626d3bdf40a1c5aee3bcd4f40826970cae8d80a8fec934c82a63840094dcfe"
|
||||
"checksum libudev-sys 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324"
|
||||
"checksum log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
|
||||
"checksum mach 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2fd13ee2dd61cc82833ba05ade5a30bb3d63f7ced605ef827063c63078302de9"
|
||||
"checksum mach 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "86dd2487cdfea56def77b88438a2c915fb45113c5319bfe7e14306ca4cd0b0e1"
|
||||
"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||
"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"
|
||||
"checksum num-integer 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
|
||||
"checksum num-traits 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
|
||||
"checksum pkg-config 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33"
|
||||
"checksum proc-macro-error 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
"checksum proc-macro-error-attr 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
"checksum proc-macro2 1.0.22 (registry+https://github.com/rust-lang/crates.io-index)" = "e4b93dba1818d32e781f9d008edd577bab215e83ef50e8a1ddf1ad301b19a09f"
|
||||
"checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
|
||||
"checksum regex 1.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"
|
||||
"checksum regex-syntax 0.6.18 (registry+https://github.com/rust-lang/crates.io-index)" = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
|
||||
"checksum serialport 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8d3ecaf58010bedccae17be55d4ed6f2ecde5646fc48ce8c66ea2d35a1419c"
|
||||
"checksum simplelog 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3cf9a002ccce717d066b3ccdb8a28829436249867229291e91b25d99bd723f0d"
|
||||
"checksum structopt 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a33f6461027d7f08a13715659b2948e1602c31a3756aeae9378bfe7518c72e82"
|
||||
"checksum structopt-derive 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c92e775028122a4b3dd55d58f14fc5120289c69bee99df1d117ae30f84b225c9"
|
||||
"checksum syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b"
|
||||
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
|
||||
"checksum thread_local 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
|
||||
"checksum time 0.1.44 (registry+https://github.com/rust-lang/crates.io-index)" = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
|
||||
"checksum tun-tap 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "53ccbe9cfffdaa7eefd36538bb26f228d4bd319a8aeca044d54377612a646bcd"
|
||||
"checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0"
|
||||
"checksum unicode-width 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
|
||||
"checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
"checksum version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
@ -1,42 +0,0 @@
|
|||
# Copyright (C) 2019-2020 John Goerzen <jgoerzen@complete.org
|
||||
#
|
||||
# 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/>.
|
||||
|
||||
|
||||
[package]
|
||||
name = "xbnet"
|
||||
version = "1.1.0"
|
||||
authors = ["John Goerzen <jgoerzen@complete.org>"]
|
||||
edition = "2018"
|
||||
license = "GPL-3.0+"
|
||||
description = "Run TCP/IP over XBee RF radio links"
|
||||
homepage = "https://github.com/jgoerzen/xbnet"
|
||||
repository = "https://github.com/jgoerzen/xbnet"
|
||||
readme = "README.md"
|
||||
keywords = ["radio", "networking", "serial", "xbee"]
|
||||
categories = ["embedded", "network-programming", "command-line-utilities"]
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
serialport = "3.3.0"
|
||||
log = "0.4"
|
||||
simplelog = {version = "^0.7.4", default-features = false}
|
||||
hex = "0.4.2"
|
||||
crossbeam-channel = "0.3.9"
|
||||
format_escape_default = "0.1.1"
|
||||
structopt = {version = "0.3", default-features = false}
|
||||
tun-tap = {version = "0.1.2", default-features = false}
|
||||
bytes = "0.5"
|
||||
etherparse = "0.9.0"
|
|
@ -1,33 +0,0 @@
|
|||
# XBee Networking Tools
|
||||
|
||||
![build](https://github.com/jgoerzen/xbnet/workflows/build/badge.svg) ![docs](https://docs.rs/xbnet/badge.svg)
|
||||
|
||||
|
||||
This package is for doing fantastic things with your XBee device. You can, of course, already use it as a serial replacement, so you can run PPP and UUCP across it. XBee radios are low-cost, long-range, low-speed devices; with bitrates from 10Kbps to 250Kbps, they can reach many miles using simple antennas and low cost.
|
||||
|
||||
With xbnet, you can also run Ethernet across it. Or ZModem. Or TCP/IP (IPv4 and IPv6). SPX if you want? I guess so. SSH? Of course!
|
||||
|
||||
This is tested with the XBee SX modules, but ought to work with any modern XBee module.
|
||||
|
||||
XBee devices are particularly interesting because of their self-healing mesh (DigiMesh) technology. They will auto-route traffic to the destination, via intermediate hops if necessary. They also support bitrates high enough for a TCP stack, with nearly the range of LoRA.
|
||||
|
||||
**For details, see the [extensive documentation](https://github.com/jgoerzen/xbnet/blob/master/doc/xbnet.1.md)**.
|
||||
|
||||
This is a followup to, and fork of, my [lorapipe](https://github.com/jgoerzen/lorapipe) project, which is something similar for LoRA radios.
|
||||
|
||||
# Copyright
|
||||
|
||||
Copyright (C) 2019-2020 John Goerzen <jgoerzen@complete.org>
|
||||
|
||||
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/>.
|
|
@ -1,4 +0,0 @@
|
|||
ALL: xbnet.1
|
||||
|
||||
%.1: %.1.md
|
||||
pandoc --standalone --to man $< -o $@
|
|
@ -1,596 +0,0 @@
|
|||
.\" Automatically generated by Pandoc 2.2.1
|
||||
.\"
|
||||
.TH "XBNET" "1" "October 2019" "John Goerzen" "xbnet Manual"
|
||||
.hy
|
||||
.SH NAME
|
||||
.PP
|
||||
xbnet \- Transfer data and run a network over XBee long\-range radios
|
||||
.SH SYNOPSIS
|
||||
.PP
|
||||
\f[B]xbnet\f[] [ \f[I]OPTIONS\f[] ] \f[B]PORT\f[] \f[B]COMMAND\f[] [
|
||||
\f[I]command_options\f[] ]
|
||||
.SH OVERVIEW
|
||||
.PP
|
||||
\f[B]xbnet\f[] is designed to integrate XBee long\-range radios into a
|
||||
Unix/Linux system.
|
||||
In particular, xbnet can:
|
||||
.IP \[bu] 2
|
||||
Bidirectionally pipe data across a XBee radio system
|
||||
.IP \[bu] 2
|
||||
Do an RF ping
|
||||
.IP \[bu] 2
|
||||
Operate as a virtual Ethernet device or a virtual tunnel device
|
||||
.RS 2
|
||||
.IP \[bu] 2
|
||||
Run TCP/IP (IPv4 and IPv6) atop either of these.
|
||||
.RE
|
||||
.SH HARDWARE REQUIREMENTS
|
||||
.PP
|
||||
\f[B]xbnet\f[] is designed to run with a Digi XBee device.
|
||||
It is tested with the SX devices but should work with any.
|
||||
.PP
|
||||
Drivers for other hardware may be added in the future.
|
||||
.SH PROTOCOL
|
||||
.PP
|
||||
XBee frames are smaller than typical Ethernet or TCP frames.
|
||||
XBee frames, in fact, are typically limited to about 255 bytes on the SX
|
||||
series; other devices may have different limits.
|
||||
Therefore, xbnet supports fragmentation and reassembly.
|
||||
It will split a frame to be transmitted into the size supported by XBee,
|
||||
and reassemble on the other end.
|
||||
.PP
|
||||
XBee, of course, cannot guarantee that all frames will be received, and
|
||||
therefore xbnet can't make that guarantee either.
|
||||
However, the protocols you may run atop it \[en] from UUCP to ZModem to
|
||||
TCP/IP \[en] should handle this.
|
||||
.PP
|
||||
When running in \f[B]xbnet tap\f[] mode, it is simulating an Ethernet
|
||||
interface.
|
||||
Every Ethernet packet has a source and destination MAC address.
|
||||
xbnet will maintain a cache of the Ethernet MAC addresses it has seen
|
||||
and what XBee MAC address they came from.
|
||||
Therefore, when it sees a request to transmit to a certain Ethernet MAC,
|
||||
it will reuse what it knows from its cache and direct the packet to the
|
||||
appropriate XBee destination.
|
||||
Ethernet broadcasts are converted into XBee broadcasts.
|
||||
.PP
|
||||
The \f[B]xbnet tun\f[] mode operates in a similar fashion; it keeps a
|
||||
cache of seen IP addresses and their corresponding XBee MAC addresses,
|
||||
and directs packets appropriately.
|
||||
.SH RADIO PARAMETERS AND INITIALIZATION
|
||||
.PP
|
||||
This program requires API mode from the board.
|
||||
It will perform that initialization automatically.
|
||||
Additional configurations may be added by you using the
|
||||
\f[B]\[en]initfile\f[] option.
|
||||
.SH APPLICATION HINTS
|
||||
.SS FULL TCP/IP USING TUN
|
||||
.PP
|
||||
This is the marquee feature of xbnet.
|
||||
It provides a full TCP/IP stack across the XBee links, supporting both
|
||||
IPv4 and IPv6.
|
||||
You can do anything you wish with the participating nodes in your mesh:
|
||||
ping, ssh, route the Internet across them, etc.
|
||||
Up to you! A Raspberry Pi with wifi and xbnet could provide an Internet
|
||||
gateway for an entire XBee mesh, if you so desire.
|
||||
.PP
|
||||
This works by creating a virtual network device in Linux, called a
|
||||
\[lq]tun\[rq] device.
|
||||
Traffic going out that device will be routed onto XBee, and traffic
|
||||
coming in will be routed to the computer.
|
||||
.PP
|
||||
To make this work, you will first bring up the interface with xbnet.
|
||||
Then, give it an IP address with ifconfig or ipaddr.
|
||||
Do the same on the remote end, and boom, you can ping!
|
||||
.PP
|
||||
Note that for this mode, xbnet must be run as root (or granted
|
||||
\f[C]CAP_NET_ADMIN\f[]).
|
||||
.PP
|
||||
Here's an example.
|
||||
Start on machine A:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
sudo\ xbnet\ /dev/ttyUSB3\ tun
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
Wait until it tells you what interface it created.
|
||||
By default, this will be \f[B]xbnet0\f[].
|
||||
Now run:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
sudo\ ip\ addr\ add\ 192.168.3.3/24\ dev\ xbnet0
|
||||
sudo\ ip\ link\ set\ dev\ xbnet0\ up
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
If you don't have the \f[B]ip\f[] program, you can use the older\-style
|
||||
\f[B]ifconfig\f[] instead.
|
||||
This one command does the same as the two newer\-style ones above:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
sudo\ ifconfig\ xbnet0\ 192.168.3.3\ netmask\ 255.255.255.0\
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
Now, on machine B, start xbnet the same as on machine A.
|
||||
Give it a different IP
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
sudo\ ip\ addr\ add\ 192.168.3.4/24\ dev\ xbnet0
|
||||
sudo\ ip\ link\ set\ dev\ xbnet0\ up
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
Now you can ping from A to B:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
ping\ 192.168.3.4
|
||||
PING\ 192.168.3.4\ (192.168.3.4)\ 56(84)\ bytes\ of\ data.
|
||||
64\ bytes\ from\ 192.168.3.4:\ icmp_seq=1\ ttl=64\ time=130\ ms
|
||||
64\ bytes\ from\ 192.168.3.4:\ icmp_seq=2\ ttl=64\ time=89.1\ ms
|
||||
64\ bytes\ from\ 192.168.3.4:\ icmp_seq=3\ ttl=64\ time=81.6\ ms
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
For more details, see the tun command below.
|
||||
.SS ETHERNET MODE WITH TAP
|
||||
.PP
|
||||
The tap mode is similar to the tun mode, except it simulates a full
|
||||
Ethernet connection.
|
||||
You might want this if you need to run a non\-IP protocol, or if you
|
||||
want to do something like bridge two Ethernet segments.
|
||||
The configuration is very similar.
|
||||
.PP
|
||||
Be aware that a lot of programs generate broadcasts across an Ethernet
|
||||
interface, and bridging will do even more.
|
||||
It would be easy to overwhelm your XBee network with this kind of cruft,
|
||||
so the tun mode is recommended unless you have a specific need for tap.
|
||||
.SS TRANSPARENT MODE
|
||||
.PP
|
||||
XBee systems have a \[lq]transparent mode\[rq] in which you can
|
||||
configure a particular destination and use them as a raw serial port.
|
||||
You should definitely consider if this meets your needs for
|
||||
serial\-based protocols; it would eliminate xbnet from the path
|
||||
entirely.
|
||||
.PP
|
||||
However, you may still wish to use xbnet; perhaps for its debugging.
|
||||
Also there are some scenarios (such at TCP/IP with multiple
|
||||
destinations) that really cannot be done in transparent mode \[en] and
|
||||
that is what xbnet is for, and where it shines.
|
||||
.SS SOCAT
|
||||
.PP
|
||||
The \f[B]socat\f[](1) program can be particularly helpful; it can
|
||||
gateway TCP ports and various other sorts of things into \f[B]xbnet\f[].
|
||||
This is helpful if the \f[B]xbnet\f[] system is across a network from
|
||||
the system you wish to run an application on.
|
||||
\f[B]ssh\f[](1) can also be useful for this purpose.
|
||||
.PP
|
||||
A basic command might be like this:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
socat\ TCP\-LISTEN:12345\ EXEC:\[aq]xbnet\ /dev/ttyUSB0\ pipe\ \-\-dest=1234,pty,rawer\[aq]
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
Some systems might require disabling buffering in some situations, or
|
||||
using a pty.
|
||||
In those instances, something like this may be in order:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
socat\ TCP\-LISTEN:10104\ EXEC:\[aq]stdbuf\ \-i0\ \-o0\ \-e0\ xbnet\ /dev/ttyUSB4\ pipe\ \-\-dest=1234,pty,rawer\[aq]
|
||||
\f[]
|
||||
.fi
|
||||
.SS UUCP
|
||||
.PP
|
||||
For UUCP, I recommend protocol \f[C]i\f[] with the default window\-size
|
||||
setting.
|
||||
Use as large of a packet size as you can; for slow links, perhaps 32, up
|
||||
to around 244 for fast, high\-quality links.
|
||||
.PP
|
||||
Protocol \f[C]g\f[] (or \f[C]G\f[] with a smaller packet size) can also
|
||||
work, but won't work as well.
|
||||
.PP
|
||||
Make sure to specify \f[C]half\-duplex\ true\f[] in
|
||||
\f[C]/etc/uucp/port\f[].
|
||||
.PP
|
||||
Here is an example of settings in \f[C]sys\f[]:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
protocol\ i
|
||||
protocol\-parameter\ i\ packet\-size\ 90
|
||||
protocol\-parameter\ i\ timeout\ 30
|
||||
chat\-timeout\ 60
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
Note that UUCP protocol i adds 10 bytes of overhead per packet and xbnet
|
||||
adds 1 byte of overhead, so this is designed to work with the default
|
||||
recommended packet size of 255.
|
||||
.PP
|
||||
Then in \f[C]/etc/uucp/port\f[]:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
half\-duplex\ true
|
||||
reliable\ false
|
||||
\f[]
|
||||
.fi
|
||||
.SS YMODEM (and generic example of bidirectional pipe)
|
||||
.PP
|
||||
ZModem makes a good fit for the higher bitrate XBee modules.
|
||||
For the slower settings, consider YModem; its 128\-byte block size may
|
||||
be more suitable for very slow links than ZModem's 1K.
|
||||
.PP
|
||||
Here's an example of how to make it work.
|
||||
Let's say we want to transmit /bin/true over the radio.
|
||||
We could run this:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
socat\ EXEC:\[aq]sz\ \-\-ymodem\ /bin/true\[aq]\ EXEC:\[aq]xbnet\ /dev/ttyUSB0\ pipe\ \-\-dest=1234,pty,rawer\[aq]
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
And on the receiving end:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
socat\ EXEC:\[aq]rz\ \-\-ymodem\[aq]\ EXEC:\[aq]xbnet\ /dev/ttyUSB0\ pipe\ \-\-dest=5678,pty,rawer\[aq]
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
This approach can also be used with many other programs.
|
||||
For instance, \f[C]uucico\ \-l\f[] for UUCP logins.
|
||||
.SS KERMIT
|
||||
.PP
|
||||
Using the C\-kermit distribution (\f[B]apt\-get install ckermit\f[]),
|
||||
you can configure for \f[B]xbnet\f[] like this:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
set\ duplex\ half
|
||||
set\ window\ 2
|
||||
set\ receive\ timeout\ 10
|
||||
set\ send\ timeout\ 10
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
Then, on one side, run:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
pipe\ xbnet\ /dev/ttyUSB0\ pipe\ \-\-dest=1234
|
||||
Ctrl\-\\\ c
|
||||
server
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
And on the other:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
pipe\ xbnet\ /dev/ttyUSB0\ pipe\ \-\-dest=5678
|
||||
Ctrl\-\\\ c
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
Now you can do things like \f[C]rdir\f[] (to see ls from the remote),
|
||||
\f[C]get\f[], \f[C]put\f[], etc.
|
||||
.SS DEBUGGING WITH CU
|
||||
.PP
|
||||
To interact directly with the modem, something like this will work:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
cu\ \-h\ \-\-line\ /dev/ttyUSB0\ \-s\ 9600\ \-e\ \-o\ \ \-\-nostop
|
||||
\f[]
|
||||
.fi
|
||||
.SH RUNNING TCP/IP OVER XBEE WITH PPP
|
||||
.PP
|
||||
PPP is the fastest way to run TCP/IP over XBee with \f[B]xbnet\f[] if
|
||||
you only need to have two nodes talk to each other.
|
||||
PPP can work in transparent mode without xbnet as well.
|
||||
It is subject to a few limitations:
|
||||
.IP \[bu] 2
|
||||
PPP cannot support ad\-hoc communication to multiple devices.
|
||||
It is strictly point\-to\-point between two devices.
|
||||
.IP \[bu] 2
|
||||
PPP compression should not be turned on.
|
||||
This is because PPP normally assumes a lossless connection, and any
|
||||
dropped packets become rather expensive for PPP to handle, since
|
||||
compression has to be re\-set.
|
||||
Better to use compression at the protocol level; for instance, with
|
||||
\f[B]ssh \-C\f[].
|
||||
.PP
|
||||
To set up PPP, on one device, create /etc/ppp/peers/xbee with this
|
||||
content:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
hide\-password\
|
||||
noauth
|
||||
debug
|
||||
nodefaultroute
|
||||
192.168.2.3:192.168.2.2\
|
||||
mru\ 1024
|
||||
passive
|
||||
115200
|
||||
nobsdcomp
|
||||
nodeflate
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
On the other device, swap the order of those IP addresses.
|
||||
.PP
|
||||
Now, fire it up on each end with a command like this:
|
||||
.IP
|
||||
.nf
|
||||
\f[C]
|
||||
socat\ EXEC:\[aq]pppd\ nodetach\ file\ /etc/ppp/peers/lora,pty,rawer\[aq]\ \\
|
||||
\ \ EXEC:\[aq]xbnet\ \-\-initfile=init\-fast.txt\ /dev/ttyUSB0\ pipe\ \-\-dest=1234,pty,rawer\[aq]
|
||||
\f[]
|
||||
.fi
|
||||
.PP
|
||||
According to the PPP docs, an MRU of 296 might be suitable for slower
|
||||
links.
|
||||
.PP
|
||||
This will now permit you to ping across the link.
|
||||
Additional options can be added to add, for instance, a bit of
|
||||
authentication at the start and so forth (though note that XBee, being
|
||||
RF, means that a session could be hijacked, so don't put a lot of stock
|
||||
in this as a limit; best to add firewall rules, etc.)
|
||||
.PP
|
||||
Of course, ssh can nicely run over this, but for more versatility,
|
||||
consider the tap or tun options.
|
||||
.SH PERFORMANCE TUNING
|
||||
.PP
|
||||
Here are some tips to improve performance:
|
||||
.SS DISABLING XBEE ACKS
|
||||
.PP
|
||||
By default, the XBee system requests an acknowledgment from the remote
|
||||
node.
|
||||
The XBee firmware will automatically attempt retransmits if they don't
|
||||
get an ACK in the expected timeframe.
|
||||
Although higher\-level protocols also will do ACK and retransmit, they
|
||||
don't have the XBee level of knowledge of the link layer timing and so
|
||||
XBee may be able to detect and correct for a missing packet much
|
||||
quicker.
|
||||
.PP
|
||||
However, sometimes all these ACKs can cause significant degredation in
|
||||
performance.
|
||||
Whether or not they do for you will depend on your network topology and
|
||||
usage patterns; you probably should just try it both ways.
|
||||
Use \f[B]disable\-xbee\-acks\f[] to disable the XBee level ACKs on
|
||||
messages sent from a given node and see what it does.
|
||||
.SS PROTOCOL SELECTION
|
||||
.PP
|
||||
If all you really need is point\-to\-point, then consider using PPP
|
||||
rather than tun.
|
||||
PPP supports header compression which may reduce the TCP/IP overhead
|
||||
significantly.
|
||||
.SS PACKET SIZE
|
||||
.PP
|
||||
Bear in mind the underlying packet size.
|
||||
For low\-overhead protocols, you might want to use a packet size less
|
||||
than the XBee packet size.
|
||||
For high\-overhead protocols such as TCP, you may find that using large
|
||||
packet sizes and letting \f[B]xbnet\f[] do fragmentation gives much
|
||||
better performance on clean links, especially at the lower XBee
|
||||
bitrates.
|
||||
.SS SERIAL COMMUNICATION SPEED
|
||||
.PP
|
||||
By defualt, XBee modules communicate at 9600bps.
|
||||
You should change this and write the updated setting to the module, and
|
||||
give it to xbnet with \f[B]\[en]serial\-speed\f[].
|
||||
.SH TROUBLESHOOTING
|
||||
.SS BROADCAST ISSUES
|
||||
.SH SECURITY
|
||||
.PP
|
||||
xbnet is a low\-level tool and should not be considered secure on its
|
||||
own.
|
||||
The \f[B]xbnet pipe\f[] command, for instance, will display information
|
||||
from any node on your mesh.
|
||||
Here are some tips:
|
||||
.PP
|
||||
Of course, begin by securing things at the XBee layer.
|
||||
Enable encryption and passwords for remote AT commands in XBee.
|
||||
.PP
|
||||
If you are running a network protocol across XBee, enable firewalls at
|
||||
every node on the network.
|
||||
Remember, joining a node to a networked mesh is like giving it a port on
|
||||
your switch! Consider how nodes can talk to each other.
|
||||
.PP
|
||||
Use encryption and authentication at the application layer as well.
|
||||
ssh or gpg would be a fantastic choice here.
|
||||
.PP
|
||||
For nodes that are using xbnet to access the Internet, consider not
|
||||
giving them direct Internet access, but rather requiring them to access
|
||||
via something like OpenVPN or SSH forwarding.
|
||||
.SH INSTALLATION
|
||||
.PP
|
||||
\f[B]xbnet\f[] is a Rust program and can be built by running
|
||||
\f[B]\f[BC]cargo\ build\ \-\-release\f[B]\f[].
|
||||
The executable will then be placed in \f[B]target/release/xbnet\f[].
|
||||
Rust can be easily installed from <https://www.rust-lang.org/>.
|
||||
.SH INVOCATION
|
||||
.PP
|
||||
Every invocation of \f[B]xbnet\f[] requires at least the name of a
|
||||
serial port (for instance, \f[B]/dev/ttyUSB0\f[]) and a subcommand to
|
||||
run.
|
||||
.SH GLOBAL OPTIONS
|
||||
.PP
|
||||
These options may be specified for any command, and must be given before
|
||||
the port and command on the command line.
|
||||
.TP
|
||||
.B \f[B]\-d\f[], \f[B]\[en]debug\f[]
|
||||
Activate debug mode.
|
||||
Details of program operation will be sent to stderr.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\-h\f[], \f[B]\[en]help\f[]
|
||||
Display brief help on program operation.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\[en]disable\-xbee\-acks\f[]
|
||||
Disable the XBee protocol\-level acknowledgments of transmitted packets.
|
||||
This may improve, or hurt, performance; see the conversation under the
|
||||
PERFORMANCE TUNING section.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\[en]initfile\f[] \f[I]FILE\f[]
|
||||
A file listing commands to send to the radio to initialize it.
|
||||
Each command must yield an \f[C]OK\f[] result from the radio.
|
||||
After running these commands, \f[B]xbnet\f[] will issue additional
|
||||
commands to ensure the radio is in the operating mode required by
|
||||
\f[B]xbnet\f[].
|
||||
Enable \f[B]\[en]debug\f[] to see all initialization activity.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\[en]request\-xbee\-tx\-reports\f[]
|
||||
The XBee firmware can return back a report about the success or failure
|
||||
of a transmission.
|
||||
\f[B]xbnet\f[] has no use for these reports, though they are displayed
|
||||
for you if \f[B]\[en]debug\f[] is given.
|
||||
By default, \f[B]xbnet\f[] suppresses the generation of these reports.
|
||||
If you give this option and \f[B]\[en]debug\f[], then you can see them.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\[en]serial\-speed\f[] \f[I]SPEED\f[]
|
||||
Communicate with the XBee module at the given serial speed, given in
|
||||
bits per second (baud rate).
|
||||
If not given, defaults to 9600, which is the Digi default for the XBee
|
||||
modules.
|
||||
You can change this default with XBee commands and save the new default
|
||||
persistently to the board.
|
||||
It is strongly recommended that you do so, because many XBee modules can
|
||||
communicate much faster than 9600bps.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\-V\f[], \f[B]\[en]version\f[]
|
||||
Display the version number of \f[B]xbnet\f[].
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[I]PORT\f[]
|
||||
The name of the serial port to which the radio is attached.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[I]COMMAND\f[]
|
||||
The subcommand which will be executed.
|
||||
.RS
|
||||
.RE
|
||||
.SH SUBCOMMANDS
|
||||
.SS xbnet \&... pipe
|
||||
.PP
|
||||
The \f[B]pipe\f[] subcommand permits piping data between radios.
|
||||
It requires a \f[B]\[en]dest\f[] parameter, which gives the hex MAC
|
||||
address of the recipient of data sent to xbnet's stdin.
|
||||
pipe is described extensively above.
|
||||
.PP
|
||||
Note that \f[B]\[en]dest\f[] will not restrict the devices that xbnet
|
||||
will receive data from.
|
||||
.SS xbnet \&... ping
|
||||
.PP
|
||||
The \f[B]ping\f[] subcommand will transmit a simple line of text every 5
|
||||
seconds including an increasing counter.
|
||||
It can be displayed at the other end with \f[B]xbnet \&... pipe\f[] or
|
||||
reflected with \f[B]xbnet \&... pong\f[].
|
||||
Like \f[B]pipe\f[], it requires a destination MAC address.
|
||||
.SS xbnet \&... pong
|
||||
.PP
|
||||
The \f[B]pong\f[] subcommand receives packets and crafts a reply.
|
||||
It is intended to be used with \f[B]xbnet \&... ping\f[].
|
||||
.SS xbnet \&... tun & tap
|
||||
.PP
|
||||
These commands run a network stack across XBee and are described
|
||||
extensively above.
|
||||
They have several optional parameters:
|
||||
.TP
|
||||
.B \f[B]\[en]broadcast\-everything\f[] (tun and tap)
|
||||
Normally, \f[B]xbnet\f[] will use unicast (directed) transmissions to
|
||||
remotes where it knows their XBee MAC address.
|
||||
This is more efficient on the XBee network.
|
||||
However, in some cases you may simply want it to use broadcast packets
|
||||
for all transmissions, and this accomplishes that.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\[en]broadcast\-unknown\f[] (tap only)
|
||||
Normally, \f[B]xbnet\f[] will drop Ethernet frames destined for MAC
|
||||
addresses that it hasn't seen.
|
||||
(Broadcast packets still go out.) This is suitable for most situations.
|
||||
However, you can also have it broadcast all packets do unknown MAC
|
||||
addresses.
|
||||
This can be useful in some obscure situations such as multicast.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\[en]disable\-ipv4\f[] and \f[B]disable\-ipv6\f[] (tun only)
|
||||
Disable all relaying of either IPv4 or IPv6 packets.
|
||||
This is not valid in tap mode because tap doesn't operate at this
|
||||
protocol level.
|
||||
It is recommended you disable protocols you don't use.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\[en]iface\-name\f[] \f[I]NAME\f[] (tun and tap)
|
||||
Request a specific name for the tun or tap interface.
|
||||
By default, this requests \f[B]xbnet%d\f[].
|
||||
The kernel replaces \f[B]%d\f[] with an integer starting at 0, finding
|
||||
an unused interface.
|
||||
It can be useful to specify an explicit interface here for use in
|
||||
scripts.
|
||||
.RS
|
||||
.RE
|
||||
.TP
|
||||
.B \f[B]\[en]max\-ip\-cache\f[] \f[I]SECONDS\f[] (tun only)
|
||||
Specifies how long it caches the XBee MAC address for a given IP
|
||||
address.
|
||||
After this many seconds without receiving a packet from the given IP
|
||||
address, \f[B]xbnet\f[] will send the next packet to the IP as a
|
||||
broadcast and then cache the result.
|
||||
The only reason to expire IPs from the cache is if you re\-provision
|
||||
them on other devices.
|
||||
The tap mode doesn't have a timed cache, since the OS will re\-ARP
|
||||
(generating a broadcast anyhow) if it fails to communicate with a given
|
||||
IP.
|
||||
.RS
|
||||
.RE
|
||||
.SH AUTHOR
|
||||
.PP
|
||||
John Goerzen <jgoerzen@complete.org>
|
||||
.SH COPYRIGHT AND LICENSE
|
||||
.PP
|
||||
Copyright (C) 2019\-2020 John Goerzen <jgoerzen@complete.org>
|
||||
.PP
|
||||
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.
|
||||
.PP
|
||||
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.
|
||||
.PP
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program.
|
||||
If not, see <http://www.gnu.org/licenses/>.
|
||||
.SH AUTHORS
|
||||
John Goerzen.
|
|
@ -1,414 +0,0 @@
|
|||
% XBNET(1) John Goerzen | xbnet Manual
|
||||
% John Goerzen
|
||||
% October 2019
|
||||
|
||||
# NAME
|
||||
|
||||
xbnet - Transfer data and run a network over XBee long-range radios
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
**xbnet** [ *OPTIONS* ] **PORT** **COMMAND** [ *command_options* ]
|
||||
|
||||
# OVERVIEW
|
||||
|
||||
**xbnet** is designed to integrate XBee long-range radios into a
|
||||
Unix/Linux system. In particular, xbnet can:
|
||||
|
||||
- Bidirectionally pipe data across a XBee radio system
|
||||
- Do an RF ping
|
||||
- Operate as a virtual Ethernet device or a virtual tunnel device
|
||||
- Run TCP/IP (IPv4 and IPv6) atop either of these.
|
||||
|
||||
# HARDWARE REQUIREMENTS
|
||||
|
||||
**xbnet** is designed to run with a Digi XBee device. It is tested with the SX devices but should work with any.
|
||||
|
||||
Drivers for other hardware may be added in the future.
|
||||
|
||||
# PROTOCOL
|
||||
|
||||
XBee frames are smaller than typical Ethernet or TCP frames. XBee frames, in fact, are typically limited to about 255 bytes on the SX series; other devices may have different limits. Therefore, xbnet supports fragmentation and reassembly. It will split a frame to be transmitted into the size supported by XBee, and reassemble on the other end.
|
||||
|
||||
XBee, of course, cannot guarantee that all frames will be received, and therefore xbnet can't make that guarantee either. However, the protocols you may run atop it -- from UUCP to ZModem to TCP/IP -- should handle this.
|
||||
|
||||
When running in **xbnet tap** mode, it is simulating an Ethernet interface. Every Ethernet packet has a source and destination MAC address. xbnet will maintain a cache of the Ethernet MAC addresses it has seen and what XBee MAC address they came from. Therefore, when it sees a request to transmit to a certain Ethernet MAC, it will reuse what it knows from its cache and direct the packet to the appropriate XBee destination. Ethernet broadcasts are converted into XBee broadcasts.
|
||||
|
||||
The **xbnet tun** mode operates in a similar fashion; it keeps a cache of seen IP addresses and their corresponding XBee MAC addresses, and directs packets appropriately.
|
||||
|
||||
# RADIO PARAMETERS AND INITIALIZATION
|
||||
|
||||
This program requires API mode from the board. It will perform that initialization automatically. Additional configurations may be added by you using the **--initfile** option.
|
||||
|
||||
# APPLICATION HINTS
|
||||
|
||||
## FULL TCP/IP USING TUN
|
||||
|
||||
This is the marquee feature of xbnet. It provides a full TCP/IP stack across the XBee links, supporting both IPv4 and IPv6. You can do anything you wish with the participating nodes in your mesh: ping, ssh, route the Internet across them, etc. Up to you! A Raspberry Pi with wifi and xbnet could provide an Internet gateway for an entire XBee mesh, if you so desire.
|
||||
|
||||
This works by creating a virtual network device in Linux, called a "tun" device. Traffic going out that device will be routed onto XBee, and traffic coming in will be routed to the computer.
|
||||
|
||||
To make this work, you will first bring up the interface with xbnet. Then, give it an IP address with ifconfig or ipaddr. Do the same on the remote end, and boom, you can ping!
|
||||
|
||||
Note that for this mode, xbnet must be run as root (or granted `CAP_NET_ADMIN`).
|
||||
|
||||
Here's an example. Start on machine A:
|
||||
|
||||
```
|
||||
sudo xbnet /dev/ttyUSB3 tun
|
||||
```
|
||||
|
||||
Wait until it tells you what interface it created. By default, this will be **xbnet0**. Now run:
|
||||
|
||||
```
|
||||
sudo ip addr add 192.168.3.3/24 dev xbnet0
|
||||
sudo ip link set dev xbnet0 up
|
||||
```
|
||||
|
||||
If you don't have the **ip** program, you can use the older-style **ifconfig** instead. This one command does the same as the two newer-style ones above:
|
||||
|
||||
```
|
||||
sudo ifconfig xbnet0 192.168.3.3 netmask 255.255.255.0
|
||||
```
|
||||
|
||||
Now, on machine B, start xbnet the same as on machine A. Give it a different IP
|
||||
|
||||
```
|
||||
sudo ip addr add 192.168.3.4/24 dev xbnet0
|
||||
sudo ip link set dev xbnet0 up
|
||||
```
|
||||
|
||||
Now you can ping from A to B:
|
||||
|
||||
```
|
||||
ping 192.168.3.4
|
||||
PING 192.168.3.4 (192.168.3.4) 56(84) bytes of data.
|
||||
64 bytes from 192.168.3.4: icmp_seq=1 ttl=64 time=130 ms
|
||||
64 bytes from 192.168.3.4: icmp_seq=2 ttl=64 time=89.1 ms
|
||||
64 bytes from 192.168.3.4: icmp_seq=3 ttl=64 time=81.6 ms
|
||||
```
|
||||
|
||||
For more details, see the tun command below.
|
||||
|
||||
## ETHERNET MODE WITH TAP
|
||||
|
||||
The tap mode is similar to the tun mode, except it simulates a full Ethernet connection. You might want this if you need to run a non-IP protocol, or if you want to do something like bridge two Ethernet segments. The configuration is very similar.
|
||||
|
||||
Be aware that a lot of programs generate broadcasts across an Ethernet interface, and bridging will do even more. It would be easy to overwhelm your XBee network with this kind of cruft, so the tun mode is recommended unless you have a specific need for tap.
|
||||
|
||||
## TRANSPARENT MODE
|
||||
|
||||
XBee systems have a "transparent mode" in which you can configure a particular destination and use them as a raw serial port. You should definitely consider if this meets your needs for serial-based protocols; it would eliminate xbnet from the path entirely.
|
||||
|
||||
However, you may still wish to use xbnet; perhaps for its debugging. Also there are some scenarios (such at TCP/IP with multiple destinations) that really cannot be done in transparent mode -- and that is what xbnet is for, and where it shines.
|
||||
|
||||
## SOCAT
|
||||
|
||||
The **socat**(1) program can be particularly helpful; it can gateway TCP
|
||||
ports and various other sorts of things into **xbnet**. This is
|
||||
helpful if the **xbnet** system is across a network from the system
|
||||
you wish to run an application on. **ssh**(1) can also be useful for
|
||||
this purpose.
|
||||
|
||||
A basic command might be like this:
|
||||
|
||||
```
|
||||
socat TCP-LISTEN:12345 EXEC:'xbnet /dev/ttyUSB0 pipe --dest=1234,pty,rawer'
|
||||
```
|
||||
|
||||
Some systems might require disabling buffering in some situations, or
|
||||
using a pty. In those instances, something like this may be in order:
|
||||
|
||||
```
|
||||
socat TCP-LISTEN:10104 EXEC:'stdbuf -i0 -o0 -e0 xbnet /dev/ttyUSB4 pipe --dest=1234,pty,rawer'
|
||||
```
|
||||
|
||||
You can send a file this way; for instance, on one end:
|
||||
|
||||
```
|
||||
socet 'EXEC:sz -vv -b /bin/sh,pipes' EXEC:xbnet /dev/ttyUSB4 pipe --dest 1234,nofork,pipes'
|
||||
```
|
||||
|
||||
And on the other, you use `rz` instead of `sz`.
|
||||
|
||||
## UUCP
|
||||
|
||||
For UUCP, I recommend protocol `i` with the default window-size
|
||||
setting. Use as large of a packet size as you can; for slow links,
|
||||
perhaps 32, up to around 244 for fast, high-quality links.
|
||||
|
||||
Protocol `g` (or `G` with a smaller packet size) can also work, but
|
||||
won't work as well.
|
||||
|
||||
Make sure to specify `half-duplex true` in `/etc/uucp/port`.
|
||||
|
||||
Here is an example of settings in `sys`:
|
||||
```
|
||||
protocol i
|
||||
protocol-parameter i packet-size 90
|
||||
protocol-parameter i timeout 30
|
||||
chat-timeout 60
|
||||
```
|
||||
|
||||
Note that UUCP protocol i adds 10 bytes of overhead per packet and xbnet adds 1 byte of overhead, so
|
||||
this is designed to work with the default recommended packet size of
|
||||
255.
|
||||
|
||||
Then in `/etc/uucp/port`:
|
||||
|
||||
```
|
||||
half-duplex true
|
||||
reliable false
|
||||
```
|
||||
|
||||
## YMODEM (and generic example of bidirectional pipe)
|
||||
|
||||
ZModem makes a good fit for the higher bitrate XBee modules. For the slower settings, consider YModem; its 128-byte block size may be more suitable for very slow links than ZModem's 1K.
|
||||
|
||||
Here's an example
|
||||
of how to make it work. Let's say we want to transmit /bin/true over
|
||||
the radio. We could run this:
|
||||
|
||||
```
|
||||
socat EXEC:'sz --ymodem /bin/true' EXEC:'xbnet /dev/ttyUSB0 pipe --dest=1234,pty,rawer'
|
||||
```
|
||||
|
||||
And on the receiving end:
|
||||
|
||||
```
|
||||
socat EXEC:'rz --ymodem' EXEC:'xbnet /dev/ttyUSB0 pipe --dest=5678,pty,rawer'
|
||||
```
|
||||
|
||||
This approach can also be used with many other programs. For
|
||||
instance, `uucico -l` for UUCP logins.
|
||||
|
||||
## KERMIT
|
||||
|
||||
Using the C-kermit distribution (**apt-get install ckermit**), you can
|
||||
configure for **xbnet** like this:
|
||||
|
||||
```
|
||||
set duplex half
|
||||
set window 2
|
||||
set receive timeout 10
|
||||
set send timeout 10
|
||||
```
|
||||
|
||||
Then, on one side, run:
|
||||
|
||||
```
|
||||
pipe xbnet /dev/ttyUSB0 pipe --dest=1234
|
||||
Ctrl-\ c
|
||||
server
|
||||
```
|
||||
|
||||
And on the other:
|
||||
|
||||
```
|
||||
pipe xbnet /dev/ttyUSB0 pipe --dest=5678
|
||||
Ctrl-\ c
|
||||
```
|
||||
|
||||
Now you can do things like `rdir` (to see ls from the remote), `get`,
|
||||
`put`, etc.
|
||||
|
||||
## DEBUGGING WITH CU
|
||||
|
||||
To interact directly with the modem, something like this will work:
|
||||
|
||||
```
|
||||
cu -h --line /dev/ttyUSB0 -s 9600 -e -o --nostop
|
||||
```
|
||||
|
||||
# RUNNING TCP/IP OVER XBEE WITH PPP
|
||||
|
||||
PPP is the fastest way to run TCP/IP over XBee with **xbnet** if you only need to have two nodes talk to each other. PPP can work in transparent mode without xbnet as well. It
|
||||
is subject to a few limitations:
|
||||
|
||||
- PPP cannot support
|
||||
ad-hoc communication to multiple devices. It is strictly point-to-point between two devices.
|
||||
- PPP compression should not be turned on. This is because PPP
|
||||
normally assumes a lossless connection, and any dropped packets
|
||||
become rather expensive for PPP to handle, since compression has to
|
||||
be re-set. Better to use compression at the protocol level; for
|
||||
instance, with **ssh -C**.
|
||||
|
||||
To set up PPP, on one device, create /etc/ppp/peers/xbee with this
|
||||
content:
|
||||
|
||||
```
|
||||
hide-password
|
||||
noauth
|
||||
debug
|
||||
nodefaultroute
|
||||
192.168.2.3:192.168.2.2
|
||||
mru 1024
|
||||
passive
|
||||
115200
|
||||
nobsdcomp
|
||||
nodeflate
|
||||
```
|
||||
|
||||
On the other device, swap the order of those IP addresses.
|
||||
|
||||
Now, fire it up on each end with a command like this:
|
||||
|
||||
```
|
||||
socat EXEC:'pppd nodetach file /etc/ppp/peers/lora,pty,rawer' \
|
||||
EXEC:'xbnet --initfile=init-fast.txt /dev/ttyUSB0 pipe --dest=1234,pty,rawer'
|
||||
```
|
||||
|
||||
According to the PPP docs, an MRU of 296 might be suitable for slower
|
||||
links.
|
||||
|
||||
This will now permit you to ping across the link. Additional options
|
||||
can be added to add, for instance, a bit of authentication at the
|
||||
start and so forth (though note that XBee, being RF, means that a
|
||||
session could be hijacked, so don't put a lot of stock in this as a
|
||||
limit; best to add firewall rules, etc.)
|
||||
|
||||
Of course, ssh can nicely run over this, but for more versatility, consider the tap or tun options.
|
||||
|
||||
# PERFORMANCE TUNING
|
||||
|
||||
Here are some tips to improve performance:
|
||||
|
||||
## DISABLING XBEE ACKS
|
||||
|
||||
By default, the XBee system requests an acknowledgment from the remote node. The XBee firmware will automatically attempt retransmits if they don't get an ACK in the expected timeframe. Although higher-level protocols also will do ACK and retransmit, they don't have the XBee level of knowledge of the link layer timing and so XBee may be able to detect and correct for a missing packet much quicker.
|
||||
|
||||
However, sometimes all these ACKs can cause significant degredation in performance. Whether or not they do for you will depend on your network topology and usage patterns; you probably should just try it both ways. Use **disable-xbee-acks** to disable the XBee level ACKs on messages sent from a given node and see what it does.
|
||||
|
||||
## PROTOCOL SELECTION
|
||||
|
||||
If all you really need is point-to-point, then consider using PPP rather than tun. PPP supports header compression which may reduce the TCP/IP overhead significantly.
|
||||
|
||||
## PACKET SIZE
|
||||
|
||||
Bear in mind the underlying packet size. For low-overhead protocols, you might want to use a packet size less than the XBee packet size. For high-overhead protocols such as TCP, you may find that using large packet sizes and letting **xbnet** do fragmentation gives much better performance on clean links, especially at the lower XBee bitrates.
|
||||
|
||||
## SERIAL COMMUNICATION SPEED
|
||||
|
||||
By defualt, XBee modules communicate at 9600bps. You should change this and write the updated setting to the module, and give it to xbnet with **--serial-speed**.
|
||||
|
||||
# TROUBLESHOOTING
|
||||
|
||||
## BROADCAST ISSUES
|
||||
|
||||
# SECURITY
|
||||
|
||||
xbnet is a low-level tool and should not be considered secure on its own. The **xbnet pipe** command, for instance, will display information from any node on your mesh. Here are some tips:
|
||||
|
||||
Of course, begin by securing things at the XBee layer. Enable encryption and passwords for remote AT commands in XBee.
|
||||
|
||||
If you are running a network protocol across XBee, enable firewalls at every node on the network. Remember, joining a node to a networked mesh is like giving it a port on your switch! Consider how nodes can talk to each other.
|
||||
|
||||
Use encryption and authentication at the application layer as well. ssh or gpg would be a fantastic choice here.
|
||||
|
||||
For nodes that are using xbnet to access the Internet, consider not giving them direct Internet access, but rather requiring them to access via something like OpenVPN or SSH forwarding.
|
||||
|
||||
# INSTALLATION
|
||||
|
||||
**xbnet** is a Rust program and can be built by running **`cargo
|
||||
build --release`**. The executable will then be placed in
|
||||
**target/release/xbnet**. Rust can be easily installed from
|
||||
<https://www.rust-lang.org/>.
|
||||
|
||||
# INVOCATION
|
||||
|
||||
Every invocation of **xbnet** requires at least the name of a
|
||||
serial port (for instance, **/dev/ttyUSB0**) and a subcommand to run.
|
||||
|
||||
# GLOBAL OPTIONS
|
||||
|
||||
These options may be specified for any command, and must be given
|
||||
before the port and command on the command line.
|
||||
|
||||
**-d**, **--debug**
|
||||
: Activate debug mode. Details of program operation will be sent to
|
||||
stderr.
|
||||
|
||||
**-h**, **--help**
|
||||
: Display brief help on program operation.
|
||||
|
||||
**--disable-xbee-acks**
|
||||
: Disable the XBee protocol-level acknowledgments of transmitted packets. This may improve, or hurt, performance; see the conversation under the PERFORMANCE TUNING section.
|
||||
|
||||
**--initfile** *FILE*
|
||||
: A file listing commands to send to the radio to initialize it. Each command must yield an `OK` result from the radio. After running these commands, **xbnet** will issue additional commands to ensure the radio is in the operating mode required by **xbnet**. Enable **--debug** to see all initialization activity.
|
||||
|
||||
**--request-xbee-tx-reports**
|
||||
: The XBee firmware can return back a report about the success or failure of a transmission. **xbnet** has no use for these reports, though they are displayed for you if **--debug** is given. By default, **xbnet** suppresses the generation of these reports. If you give this option and **--debug**, then you can see them.
|
||||
|
||||
**--serial-speed** *SPEED*
|
||||
: Communicate with the XBee module at the given serial speed, given in bits per second (baud rate). If not given, defaults to 9600, which is the Digi default for the XBee modules. You can change this default with XBee commands and save the new default persistently to the board. It is strongly recommended that you do so, because many XBee modules can communicate much faster than 9600bps.
|
||||
|
||||
**-V**, **--version**
|
||||
: Display the version number of **xbnet**.
|
||||
|
||||
*PORT*
|
||||
: The name of the serial port to which the radio is attached.
|
||||
|
||||
*COMMAND*
|
||||
: The subcommand which will be executed.
|
||||
|
||||
# SUBCOMMANDS
|
||||
|
||||
## xbnet ... pipe
|
||||
|
||||
The **pipe** subcommand permits piping data between radios. It requires a **--dest** parameter, which gives the hex MAC address of the recipient of data sent to xbnet's stdin. pipe is described extensively above.
|
||||
|
||||
Note that **--dest** will not restrict the devices that xbnet will receive data from.
|
||||
|
||||
## xbnet ... ping
|
||||
|
||||
The **ping** subcommand will transmit a simple line of text every 5
|
||||
seconds including an increasing counter. It can be displayed at the
|
||||
other end with **xbnet ... pipe** or reflected with **xbnet
|
||||
... pong**. Like **pipe**, it requires a destination MAC address.
|
||||
|
||||
## xbnet ... pong
|
||||
|
||||
The **pong** subcommand receives packets and crafts a reply. It is
|
||||
intended to be used with **xbnet ... ping**.
|
||||
|
||||
## xbnet ... tun & tap
|
||||
|
||||
These commands run a network stack across XBee and are described extensively above. They have several optional parameters:
|
||||
|
||||
**--broadcast-everything** (tun and tap)
|
||||
: Normally, **xbnet** will use unicast (directed) transmissions to remotes where it knows their XBee MAC address. This is more efficient on the XBee network. However, in some cases you may simply want it to use broadcast packets for all transmissions, and this accomplishes that.
|
||||
|
||||
**--broadcast-unknown** (tap only)
|
||||
: Normally, **xbnet** will drop Ethernet frames destined for MAC addresses that it hasn't seen. (Broadcast packets still go out.) This is suitable for most situations. However, you can also have it broadcast all packets do unknown MAC addresses. This can be useful in some obscure situations such as multicast.
|
||||
|
||||
**--disable-ipv4** and **disable-ipv6** (tun only)
|
||||
: Disable all relaying of either IPv4 or IPv6 packets. This is not valid in tap mode because tap doesn't operate at this protocol level. It is recommended you disable protocols you don't use.
|
||||
|
||||
**--iface-name** *NAME* (tun and tap)
|
||||
: Request a specific name for the tun or tap interface. By default, this requests **xbnet%d**. The kernel replaces **%d** with an integer starting at 0, finding an unused interface. It can be useful to specify an explicit interface here for use in scripts.
|
||||
|
||||
**--max-ip-cache** *SECONDS* (tun only)
|
||||
: Specifies how long it caches the XBee MAC address for a given IP address. After this many seconds without receiving a packet from the given IP address, **xbnet** will send the next packet to the IP as a broadcast and then cache the result. The only reason to expire IPs from the cache is if you re-provision them on other devices. The tap mode doesn't have a timed cache, since the OS will re-ARP (generating a broadcast anyhow) if it fails to communicate with a given IP.
|
||||
|
||||
|
||||
# AUTHOR
|
||||
|
||||
John Goerzen <jgoerzen@complete.org>
|
||||
|
||||
# COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright (C) 2019-2020 John Goerzen <jgoerzen@complete.org>
|
||||
|
||||
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/>.
|
|
@ -1,227 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2019-2020 John Goerzen <jgoerzen@complete.org
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
|
||||
use log::*;
|
||||
use simplelog::*;
|
||||
use std::io;
|
||||
use std::thread;
|
||||
|
||||
mod ping;
|
||||
mod pipe;
|
||||
mod ser;
|
||||
mod tap;
|
||||
mod tun;
|
||||
mod xb;
|
||||
mod xbpacket;
|
||||
mod xbrx;
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(
|
||||
name = "xbnet",
|
||||
about = "Networking for XBee Radios",
|
||||
author = "John Goerzen <jgoerzen@complete.org>"
|
||||
)]
|
||||
struct Opt {
|
||||
/// Activate debug mode
|
||||
// short and long flags (-d, --debug) will be deduced from the field's name
|
||||
#[structopt(short, long)]
|
||||
debug: bool,
|
||||
|
||||
/// Radio initialization command file
|
||||
#[structopt(long, parse(from_os_str))]
|
||||
initfile: Option<PathBuf>,
|
||||
|
||||
/// Serial port to use to communicate with radio
|
||||
#[structopt(parse(from_os_str))]
|
||||
port: PathBuf,
|
||||
|
||||
/// The speed in bps (baud rate) to use to communicate on the serial port
|
||||
#[structopt(long, default_value = "9600")]
|
||||
serial_speed: u32,
|
||||
|
||||
/// Disable the Xbee-level ACKs
|
||||
#[structopt(long)]
|
||||
disable_xbee_acks: bool,
|
||||
|
||||
/// Request XBee transmit reports. These will appear in debug mode but otherwise are not considered.
|
||||
#[structopt(long)]
|
||||
request_xbee_tx_reports: bool,
|
||||
|
||||
#[structopt(subcommand)]
|
||||
cmd: Command,
|
||||
}
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
enum Command {
|
||||
/// Transmit ping requests
|
||||
Ping {
|
||||
/// The 64-bit destination for the ping, in hex
|
||||
#[structopt(long)]
|
||||
dest: String,
|
||||
},
|
||||
/// Receive ping requests and transmit pongs
|
||||
Pong,
|
||||
/// Pipe data across radios using the xbnet protocol
|
||||
Pipe {
|
||||
/// The 64-bit destination for the pipe, in hex
|
||||
#[structopt(long)]
|
||||
dest: String,
|
||||
// FIXME: add a paremter to accept data from only that place
|
||||
},
|
||||
/// Create a virtual Ethernet interface and send frames across XBee
|
||||
Tap {
|
||||
/// Broadcast to XBee, instead of dropping, packets to unknown destinations. Has no effect if --broadcast_everything is given.
|
||||
#[structopt(long)]
|
||||
broadcast_unknown: bool,
|
||||
|
||||
/// Broadcast every packet out the XBee side
|
||||
#[structopt(long)]
|
||||
broadcast_everything: bool,
|
||||
|
||||
/// Name for the interface; defaults to "xbnet%d" which the OS usually turns to "xbnet0".
|
||||
/// Note that this name is not guaranteed; the name allocated by the OS is displayed
|
||||
/// at startup.
|
||||
#[structopt(long, default_value = "xbnet%d")]
|
||||
iface_name: String,
|
||||
},
|
||||
/// Create a virtual IP interface and send frames across XBee
|
||||
Tun {
|
||||
/// Broadcast every packet out the XBee side
|
||||
#[structopt(long)]
|
||||
broadcast_everything: bool,
|
||||
|
||||
/** The maximum number of seconds to store the destination XBee MAC for an IP address. */
|
||||
#[structopt(long, default_value = "300")]
|
||||
max_ip_cache: u64,
|
||||
|
||||
/// Name for the interface; defaults to "xbnet%d" which the OS usually turns to "xbnet0".
|
||||
/// Note that this name is not guaranteed; the name allocated by the OS is displayed
|
||||
/// at startup.
|
||||
#[structopt(long, default_value = "xbnet%d")]
|
||||
iface_name: String,
|
||||
|
||||
/// Disable all IPv4 support
|
||||
#[structopt(long)]
|
||||
disable_ipv4: bool,
|
||||
|
||||
/// Disable all IPv6 support
|
||||
#[structopt(long)]
|
||||
disable_ipv6: bool,
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let opt = Opt::from_args();
|
||||
|
||||
if opt.debug {
|
||||
WriteLogger::init(LevelFilter::Trace, Config::default(), io::stderr())
|
||||
.expect("Failed to init log");
|
||||
}
|
||||
info!("xbnet starting");
|
||||
|
||||
let (ser_reader, ser_writer) = ser::new(opt.port, opt.serial_speed).expect("Failed to initialize serial port");
|
||||
let (mut xb, xbeesender, writerthread) = xb::XB::new(
|
||||
ser_reader,
|
||||
ser_writer,
|
||||
opt.initfile,
|
||||
opt.disable_xbee_acks,
|
||||
opt.request_xbee_tx_reports,
|
||||
);
|
||||
let mut xbreframer = xbrx::XBReframer::new();
|
||||
|
||||
match opt.cmd {
|
||||
Command::Ping { dest } => {
|
||||
let dest_u64: u64 = u64::from_str_radix(&dest, 16).expect("Invalid destination");
|
||||
thread::spawn(move || {
|
||||
ping::genpings(dest_u64, xbeesender).expect("Failure in genpings")
|
||||
});
|
||||
ping::displaypongs(&mut xbreframer, &mut xb.ser_reader);
|
||||
// Make sure queued up data is sent
|
||||
let _ = writerthread.join();
|
||||
}
|
||||
Command::Pong => {
|
||||
ping::pong(&mut xbreframer, &mut xb.ser_reader, xbeesender).expect("Failure in pong");
|
||||
// Make sure queued up data is sent
|
||||
let _ = writerthread.join();
|
||||
}
|
||||
Command::Pipe { dest } => {
|
||||
let dest_u64: u64 = u64::from_str_radix(&dest, 16).expect("Invalid destination");
|
||||
let maxpacketsize = xb.maxpacketsize;
|
||||
thread::spawn(move || {
|
||||
pipe::stdout_processor(&mut xbreframer, &mut xb.ser_reader)
|
||||
.expect("Failure in stdout_processor")
|
||||
});
|
||||
pipe::stdin_processor(dest_u64, maxpacketsize - 1, xbeesender)
|
||||
.expect("Failure in stdin_processor");
|
||||
// Make sure queued up data is sent
|
||||
let _ = writerthread.join();
|
||||
}
|
||||
Command::Tap {
|
||||
broadcast_unknown,
|
||||
broadcast_everything,
|
||||
iface_name,
|
||||
} => {
|
||||
let tap_reader = tap::XBTap::new_tap(
|
||||
xb.mymac,
|
||||
broadcast_unknown,
|
||||
broadcast_everything,
|
||||
iface_name,
|
||||
)
|
||||
.expect("Failure initializing tap");
|
||||
let tap_writer = tap_reader.clone();
|
||||
thread::spawn(move || {
|
||||
tap_writer
|
||||
.frames_from_xb_processor(&mut xbreframer, &mut xb.ser_reader)
|
||||
.expect("Failure in frames_from_xb_processor");
|
||||
});
|
||||
tap_reader
|
||||
.frames_from_tap_processor(xbeesender)
|
||||
.expect("Failure in frames_from_tap_processor");
|
||||
// Make sure queued up data is sent
|
||||
let _ = writerthread.join();
|
||||
}
|
||||
Command::Tun {
|
||||
broadcast_everything,
|
||||
iface_name,
|
||||
max_ip_cache,
|
||||
disable_ipv4,
|
||||
disable_ipv6,
|
||||
} => {
|
||||
let max_ip_cache = Duration::from_secs(max_ip_cache);
|
||||
let tun_reader =
|
||||
tun::XBTun::new_tun(xb.mymac, broadcast_everything, iface_name, max_ip_cache, disable_ipv4, disable_ipv6)
|
||||
.expect("Failure initializing tun");
|
||||
let tun_writer = tun_reader.clone();
|
||||
thread::spawn(move || {
|
||||
tun_writer
|
||||
.frames_from_xb_processor(&mut xbreframer, &mut xb.ser_reader)
|
||||
.expect("Failure in frames_from_xb_processor");
|
||||
});
|
||||
tun_reader
|
||||
.frames_from_tun_processor(xbeesender)
|
||||
.expect("Failure in frames_from_tap_processor");
|
||||
// Make sure queued up data is sent
|
||||
let _ = writerthread.join();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2019-2020 John Goerzen <jgoerzen@complete.org
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
use crate::ser::*;
|
||||
use crate::xb::*;
|
||||
use crate::xbpacket::*;
|
||||
use crate::xbrx::*;
|
||||
use bytes::*;
|
||||
use crossbeam_channel;
|
||||
use std::io;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
const INTERVAL: u64 = 5; // FIXME: this should be configurable
|
||||
|
||||
pub fn genpings(dest: u64, sender: crossbeam_channel::Sender<XBTX>) -> io::Result<()> {
|
||||
let mut counter: u64 = 1;
|
||||
loop {
|
||||
let sendstr = format!("Ping {}", counter);
|
||||
println!("SEND: {}", sendstr);
|
||||
sender
|
||||
.send(XBTX::TXData(XBDestAddr::U64(dest), Bytes::from(sendstr)))
|
||||
.unwrap();
|
||||
thread::sleep(Duration::from_secs(INTERVAL));
|
||||
counter += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// Show pongs
|
||||
pub fn displaypongs(xbreframer: &mut XBReframer, ser: &mut XBSerReader) -> () {
|
||||
loop {
|
||||
let (fromu64, _fromu16, payload) = xbreframer.rxframe(ser);
|
||||
println!(
|
||||
"RECV from {}: {}",
|
||||
hex::encode(fromu64.to_be_bytes()),
|
||||
String::from_utf8_lossy(&payload)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Reply to pings
|
||||
pub fn pong(
|
||||
xbreframer: &mut XBReframer,
|
||||
ser: &mut XBSerReader,
|
||||
sender: crossbeam_channel::Sender<XBTX>,
|
||||
) -> io::Result<()> {
|
||||
loop {
|
||||
let (fromu64, _addr_16, payload) = xbreframer.rxframe(ser);
|
||||
if payload.starts_with(b"Ping ") {
|
||||
println!(
|
||||
"RECV from {}: {}",
|
||||
hex::encode(fromu64.to_be_bytes()),
|
||||
String::from_utf8_lossy(&payload)
|
||||
);
|
||||
let resp = Bytes::from(format!("Pong {}", String::from_utf8_lossy(&payload[5..])));
|
||||
sender
|
||||
.send(XBTX::TXData(XBDestAddr::U64(fromu64), resp))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2019 John Goerzen <jgoerzen@complete.org
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
use crate::ser::*;
|
||||
use crate::xb::*;
|
||||
use crate::xbpacket::*;
|
||||
use crate::xbrx::*;
|
||||
use bytes::*;
|
||||
use crossbeam_channel;
|
||||
use std::io;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
pub fn stdin_processor(
|
||||
dest: u64,
|
||||
maxframesize: usize,
|
||||
sender: crossbeam_channel::Sender<XBTX>,
|
||||
) -> io::Result<()> {
|
||||
let stdin = io::stdin();
|
||||
let mut br = io::BufReader::new(stdin);
|
||||
let mut buf = vec![0u8; maxframesize - 1];
|
||||
|
||||
loop {
|
||||
let res = br.read(&mut buf)?;
|
||||
if res == 0 {
|
||||
// EOF
|
||||
sender.send(XBTX::Shutdown).unwrap();
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
sender
|
||||
.send(XBTX::TXData(
|
||||
XBDestAddr::U64(dest),
|
||||
Bytes::copy_from_slice(&buf[0..res]),
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn stdout_processor(xbreframer: &mut XBReframer, ser: &mut XBSerReader) -> io::Result<()> {
|
||||
let mut stdout = io::stdout();
|
||||
loop {
|
||||
let (_fromu64, _fromu16, payload) = xbreframer.rxframe(ser);
|
||||
stdout.write_all(&payload)?;
|
||||
stdout.flush()?;
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2019 John Goerzen <jgoerzen@complete.org
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
|
||||
use bytes::*;
|
||||
use log::*;
|
||||
use serialport::prelude::*;
|
||||
use std::io;
|
||||
use std::io::{BufRead, BufReader, Write};
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct XBSerReader {
|
||||
pub br: BufReader<Box<dyn SerialPort>>,
|
||||
pub portname: PathBuf,
|
||||
}
|
||||
|
||||
pub struct XBSerWriter {
|
||||
pub swrite: Box<dyn SerialPort>,
|
||||
pub portname: PathBuf,
|
||||
}
|
||||
|
||||
/// Initialize the serial system, configuring the port.
|
||||
pub fn new(portname: PathBuf, speed: u32) -> io::Result<(XBSerReader, XBSerWriter)> {
|
||||
let settings = SerialPortSettings {
|
||||
baud_rate: speed,
|
||||
data_bits: DataBits::Eight,
|
||||
flow_control: FlowControl::Hardware,
|
||||
parity: Parity::None,
|
||||
stop_bits: StopBits::One,
|
||||
timeout: Duration::new(60 * 60 * 24 * 365 * 20, 0),
|
||||
};
|
||||
let readport = serialport::open_with_settings(&portname, &settings)?;
|
||||
let writeport = readport.try_clone()?;
|
||||
|
||||
Ok((
|
||||
XBSerReader {
|
||||
br: BufReader::new(readport),
|
||||
portname: portname.clone(),
|
||||
},
|
||||
XBSerWriter {
|
||||
swrite: writeport,
|
||||
portname,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
impl XBSerReader {
|
||||
/// Read a line from the port. Return it with EOL characters removed.
|
||||
/// None if EOF reached.
|
||||
pub fn readln(&mut self) -> io::Result<Option<String>> {
|
||||
let mut buf = Vec::new();
|
||||
let size = self.br.read_until(0x0D, &mut buf)?;
|
||||
let buf = String::from_utf8_lossy(&buf);
|
||||
if size == 0 {
|
||||
debug!("{:?}: Received EOF from serial port", self.portname);
|
||||
Ok(None)
|
||||
} else {
|
||||
let buf = String::from(buf.trim());
|
||||
trace!("{:?} SERIN: {}", self.portname, buf);
|
||||
Ok(Some(buf))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl XBSerWriter {
|
||||
/// Transmits a command with terminating EOL characters
|
||||
pub fn writeln(&mut self, data: &str) -> io::Result<()> {
|
||||
trace!("{:?} SEROUT: {}", self.portname, data);
|
||||
let mut data = BytesMut::from(data.as_bytes());
|
||||
data.put(&b"\r\n"[..]);
|
||||
// Give the receiver a chance to process
|
||||
self.swrite.write_all(&data)?;
|
||||
self.swrite.flush()
|
||||
}
|
||||
}
|
182
xbnet/src/tap.rs
182
xbnet/src/tap.rs
|
@ -1,182 +0,0 @@
|
|||
/*! tap virtual Ethernet gateway */
|
||||
|
||||
/*
|
||||
Copyright (C) 2019-2020 John Goerzen <jgoerzen@complete.org
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
|
||||
use tun_tap::{Iface, Mode};
|
||||
|
||||
use crate::ser::*;
|
||||
use crate::xb::*;
|
||||
use crate::xbpacket::*;
|
||||
use crate::xbrx::*;
|
||||
use bytes::*;
|
||||
use crossbeam_channel;
|
||||
use etherparse::*;
|
||||
use log::*;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryInto;
|
||||
use std::io;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
pub const ETHER_BROADCAST: [u8; 6] = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff];
|
||||
pub const XB_BROADCAST: u64 = 0xffff;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct XBTap {
|
||||
pub myxbmac: u64,
|
||||
pub name: String,
|
||||
pub broadcast_unknown: bool,
|
||||
pub broadcast_everything: bool,
|
||||
pub tap: Arc<Iface>,
|
||||
|
||||
/** We can't just blindly generate destination MACs because there is a bug
|
||||
in the firmware that causes the radio to lock up if we send too many
|
||||
packets to a MAC that's not online. So, we keep a translation map of
|
||||
MACs we've seen. */
|
||||
pub dests: Arc<Mutex<HashMap<[u8; 6], u64>>>,
|
||||
}
|
||||
|
||||
impl XBTap {
|
||||
pub fn new_tap(
|
||||
myxbmac: u64,
|
||||
broadcast_unknown: bool,
|
||||
broadcast_everything: bool,
|
||||
iface_name_requested: String,
|
||||
) -> io::Result<XBTap> {
|
||||
let tap = Iface::without_packet_info(&iface_name_requested, Mode::Tap)?;
|
||||
let name = tap.name();
|
||||
|
||||
println!("Interface {} (XBee MAC {:x}) ready", name, myxbmac,);
|
||||
|
||||
let mut desthm = HashMap::new();
|
||||
desthm.insert(ETHER_BROADCAST, XB_BROADCAST);
|
||||
|
||||
Ok(XBTap {
|
||||
myxbmac,
|
||||
broadcast_unknown,
|
||||
broadcast_everything,
|
||||
name: String::from(name),
|
||||
tap: Arc::new(tap),
|
||||
dests: Arc::new(Mutex::new(desthm)),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_xb_dest_mac(&self, ethermac: &[u8; 6]) -> Option<u64> {
|
||||
if self.broadcast_everything {
|
||||
return Some(XB_BROADCAST);
|
||||
}
|
||||
|
||||
match self.dests.lock().unwrap().get(ethermac) {
|
||||
None => {
|
||||
if self.broadcast_unknown {
|
||||
Some(XB_BROADCAST)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
Some(dest) => Some(*dest),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn frames_from_tap_processor(
|
||||
&self,
|
||||
sender: crossbeam_channel::Sender<XBTX>,
|
||||
) -> io::Result<()> {
|
||||
let mut buf = [0u8; 9100]; // Enough to handle even jumbo frames
|
||||
loop {
|
||||
let size = self.tap.recv(&mut buf)?;
|
||||
let tapdata = &buf[0..size];
|
||||
trace!("TAPIN: {}", hex::encode(tapdata));
|
||||
match SlicedPacket::from_ethernet(tapdata) {
|
||||
Err(x) => {
|
||||
warn!("Error parsing packet from tap; discarding: {:?}", x);
|
||||
}
|
||||
Ok(packet) => {
|
||||
if let Some(LinkSlice::Ethernet2(header)) = packet.link {
|
||||
trace!(
|
||||
"TAPIN: Packet is {} -> {}",
|
||||
hex::encode(header.source()),
|
||||
hex::encode(header.destination())
|
||||
);
|
||||
match self.get_xb_dest_mac(header.destination().try_into().unwrap()) {
|
||||
None => warn!("Destination MAC address unknown; discarding packet"),
|
||||
Some(destxbmac) => {
|
||||
let res = sender.try_send(XBTX::TXData(
|
||||
XBDestAddr::U64(destxbmac),
|
||||
Bytes::copy_from_slice(tapdata),
|
||||
));
|
||||
match res {
|
||||
Ok(()) => (),
|
||||
Err(crossbeam_channel::TrySendError::Full(_)) => {
|
||||
debug!("Dropped packet due to full TX buffer")
|
||||
}
|
||||
Err(e) => Err(e).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
warn!("Unable to get Ethernet2 header from tap packet; discarding");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn frames_from_xb_processor(
|
||||
&self,
|
||||
xbreframer: &mut XBReframer,
|
||||
ser: &mut XBSerReader,
|
||||
) -> io::Result<()> {
|
||||
loop {
|
||||
let (fromu64, _fromu16, payload) = xbreframer.rxframe(ser);
|
||||
|
||||
// Register the sender in our map of known MACs
|
||||
match SlicedPacket::from_ethernet(&payload) {
|
||||
Err(x) => {
|
||||
warn!(
|
||||
"Packet from XBee wasn't valid Ethernet; continueing anyhow: {:?}",
|
||||
x
|
||||
);
|
||||
}
|
||||
Ok(packet) => {
|
||||
if let Some(LinkSlice::Ethernet2(header)) = packet.link {
|
||||
trace!(
|
||||
"SERIN: Packet Ethernet header is {} -> {}",
|
||||
hex::encode(header.source()),
|
||||
hex::encode(header.destination())
|
||||
);
|
||||
if !self.broadcast_everything {
|
||||
self.dests
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(header.source().try_into().unwrap(), fromu64);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.tap.send(&payload)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn showmac(mac: &[u8; 6]) -> String {
|
||||
format!(
|
||||
"{:x}:{:x}:{:x}:{:x}:{:x}:{:x}",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
|
||||
)
|
||||
}
|
226
xbnet/src/tun.rs
226
xbnet/src/tun.rs
|
@ -1,226 +0,0 @@
|
|||
/*! tun virtual IP gateway */
|
||||
|
||||
/*
|
||||
Copyright (C) 2019-2020 John Goerzen <jgoerzen@complete.org
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
|
||||
use tun_tap::{Iface, Mode};
|
||||
|
||||
use crate::ser::*;
|
||||
use crate::xb::*;
|
||||
use crate::xbpacket::*;
|
||||
use crate::xbrx::*;
|
||||
use bytes::*;
|
||||
use crossbeam_channel;
|
||||
use etherparse::*;
|
||||
use log::*;
|
||||
use std::collections::HashMap;
|
||||
use std::io;
|
||||
use std::net::IpAddr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
pub const XB_BROADCAST: u64 = 0xffff;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct XBTun {
|
||||
pub myxbmac: u64,
|
||||
pub name: String,
|
||||
pub broadcast_everything: bool,
|
||||
pub tun: Arc<Iface>,
|
||||
pub max_ip_cache: Duration,
|
||||
pub disable_ipv4: bool,
|
||||
pub disable_ipv6: bool,
|
||||
|
||||
/** The map from IP Addresses (v4 or v6) to destination MAC addresses. Also
|
||||
includes a timestamp at which the destination expires. */
|
||||
pub dests: Arc<Mutex<HashMap<IpAddr, (u64, Instant)>>>,
|
||||
}
|
||||
|
||||
impl XBTun {
|
||||
pub fn new_tun(
|
||||
myxbmac: u64,
|
||||
broadcast_everything: bool,
|
||||
iface_name_requested: String,
|
||||
max_ip_cache: Duration,
|
||||
disable_ipv4: bool,
|
||||
disable_ipv6: bool,
|
||||
) -> io::Result<XBTun> {
|
||||
let tun = Iface::without_packet_info(&iface_name_requested, Mode::Tun)?;
|
||||
let name = tun.name();
|
||||
|
||||
println!("Interface {} (XBee MAC {:x}) ready", name, myxbmac,);
|
||||
|
||||
let desthm = HashMap::new();
|
||||
|
||||
Ok(XBTun {
|
||||
myxbmac,
|
||||
broadcast_everything,
|
||||
max_ip_cache,
|
||||
disable_ipv4,
|
||||
disable_ipv6,
|
||||
name: String::from(name),
|
||||
tun: Arc::new(tun),
|
||||
dests: Arc::new(Mutex::new(desthm)),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_xb_dest_mac(&self, ipaddr: &IpAddr) -> u64 {
|
||||
if self.broadcast_everything {
|
||||
return XB_BROADCAST;
|
||||
}
|
||||
|
||||
match self.dests.lock().unwrap().get(ipaddr) {
|
||||
// Broadcast if we don't know it
|
||||
None => {
|
||||
XB_BROADCAST
|
||||
},
|
||||
Some((dest, expiration)) => {
|
||||
if Instant::now() >= *expiration {
|
||||
// Broadcast it if the cache entry has expired
|
||||
XB_BROADCAST
|
||||
} else {
|
||||
*dest
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn frames_from_tun_processor(
|
||||
&self,
|
||||
sender: crossbeam_channel::Sender<XBTX>,
|
||||
) -> io::Result<()> {
|
||||
let mut buf = [0u8; 9100]; // Enough to handle even jumbo frames
|
||||
loop {
|
||||
let size = self.tun.recv(&mut buf)?;
|
||||
let tundata = &buf[0..size];
|
||||
trace!("TUNIN: {}", hex::encode(tundata));
|
||||
match SlicedPacket::from_ip(tundata) {
|
||||
Err(x) => {
|
||||
warn!("Error parsing packet from tun; discarding: {:?}", x);
|
||||
}
|
||||
Ok(packet) => {
|
||||
let ips = extract_ips(&packet);
|
||||
if let Some((source, destination)) = ips {
|
||||
match destination {
|
||||
IpAddr::V6(_) =>
|
||||
if self.disable_ipv6 {
|
||||
debug!("Dropping packet because --disable-ipv6 given");
|
||||
continue;
|
||||
},
|
||||
IpAddr::V4(_) =>
|
||||
if self.disable_ipv4 {
|
||||
debug!("Dropping packet because --disable-ipv4 given");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
let destxbmac = self.get_xb_dest_mac(&destination);
|
||||
trace!(
|
||||
"TAPIN: Packet {} -> {} (MAC {:x})",
|
||||
source,
|
||||
destination,
|
||||
destxbmac
|
||||
);
|
||||
let res = sender.try_send(XBTX::TXData(
|
||||
XBDestAddr::U64(destxbmac),
|
||||
Bytes::copy_from_slice(tundata),
|
||||
));
|
||||
match res {
|
||||
Ok(()) => (),
|
||||
Err(crossbeam_channel::TrySendError::Full(_)) => {
|
||||
debug!("Dropped packet due to full TX buffer")
|
||||
}
|
||||
Err(e) => Err(e).unwrap(),
|
||||
}
|
||||
} else {
|
||||
warn!("Unable to get IP header from tun packet; discarding");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn frames_from_xb_processor(
|
||||
&self,
|
||||
xbreframer: &mut XBReframer,
|
||||
ser: &mut XBSerReader,
|
||||
) -> io::Result<()> {
|
||||
loop {
|
||||
let (fromu64, _fromu16, payload) = xbreframer.rxframe(ser);
|
||||
|
||||
// Register the sender in our map of known MACs
|
||||
match SlicedPacket::from_ip(&payload) {
|
||||
Err(x) => {
|
||||
warn!(
|
||||
"Packet from XBee wasn't valid IPv4 or IPv6; continuing anyhow: {:?}",
|
||||
x
|
||||
);
|
||||
}
|
||||
Ok(packet) => {
|
||||
let ips = extract_ips(&packet);
|
||||
if let Some((source, destination)) = ips {
|
||||
trace!("SERIN: Packet is {} -> {}", source, destination);
|
||||
match source {
|
||||
IpAddr::V6(_) =>
|
||||
if self.disable_ipv6 {
|
||||
debug!("Dropping packet because --disable-ipv6 given");
|
||||
continue;
|
||||
},
|
||||
IpAddr::V4(_) =>
|
||||
if self.disable_ipv4 {
|
||||
debug!("Dropping packet because --disable-ipv4 given");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if !self.broadcast_everything {
|
||||
self.dests.lock().unwrap().insert(
|
||||
source,
|
||||
(
|
||||
fromu64,
|
||||
Instant::now().checked_add(self.max_ip_cache).unwrap(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
match self.tun.send(&payload) {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
warn!("Failure to send packet to tun interface; have you given it an IP? Error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the source and destination IPs
|
||||
pub fn extract_ips<'a>(packet: &SlicedPacket<'a>) -> Option<(IpAddr, IpAddr)> {
|
||||
match &packet.ip {
|
||||
Some(InternetSlice::Ipv4(header)) => Some((
|
||||
IpAddr::V4(header.source_addr()),
|
||||
IpAddr::V4(header.destination_addr()),
|
||||
)),
|
||||
Some(InternetSlice::Ipv6(header, _)) => Some((
|
||||
IpAddr::V6(header.source_addr()),
|
||||
IpAddr::V6(header.destination_addr()),
|
||||
)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
221
xbnet/src/xb.rs
221
xbnet/src/xb.rs
|
@ -1,221 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 2019-2020 John Goerzen <jgoerzen@complete.org
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
|
||||
use crate::ser::*;
|
||||
use crate::xbpacket::*;
|
||||
use bytes::Bytes;
|
||||
use crossbeam_channel;
|
||||
use hex;
|
||||
use log::*;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::io::{BufRead, BufReader, Error, ErrorKind};
|
||||
use std::path::PathBuf;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
pub fn mkerror(msg: &str) -> Error {
|
||||
Error::new(ErrorKind::Other, msg)
|
||||
}
|
||||
|
||||
/// Data to be transmitted out XBee.
|
||||
pub enum XBTX {
|
||||
/// Transmit this data
|
||||
TXData(XBDestAddr, Bytes),
|
||||
/// Shut down the transmitting thread
|
||||
Shutdown,
|
||||
}
|
||||
|
||||
/// Main XBeeNet struct
|
||||
pub struct XB {
|
||||
pub ser_reader: XBSerReader,
|
||||
|
||||
/// My 64-bit MAC address
|
||||
pub mymac: u64,
|
||||
|
||||
/// Maximum packet size
|
||||
pub maxpacketsize: usize,
|
||||
}
|
||||
|
||||
/// Assert that a given response didn't indicate an EOF, and that it
|
||||
/// matches the given text. Return an IOError if either of these
|
||||
/// conditions aren't met. The response type is as given by
|
||||
/// ['ser::XBSer::readln'].
|
||||
pub fn assert_response(resp: String, expected: String) -> io::Result<()> {
|
||||
if resp == expected {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(mkerror(&format!(
|
||||
"Unexpected response: got {}, expected {}",
|
||||
resp, expected
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
impl XB {
|
||||
/** Creates a new XB. Returns an instance to be used for reading,
|
||||
as well as a separate sender to be used in a separate thread to handle
|
||||
outgoing frames. This will spawn a thread to handle the writing to XBee, which is returned.
|
||||
|
||||
If initfile is given, its lines will be sent to the radio, one at a time,
|
||||
expecting OK after each one, to initialize it.
|
||||
|
||||
May panic if an error occurs during initialization.
|
||||
*/
|
||||
pub fn new(
|
||||
mut ser_reader: XBSerReader,
|
||||
mut ser_writer: XBSerWriter,
|
||||
initfile: Option<PathBuf>,
|
||||
disable_xbee_acks: bool,
|
||||
request_xbee_tx_reports: bool,
|
||||
) -> (XB, crossbeam_channel::Sender<XBTX>, thread::JoinHandle<()>) {
|
||||
// FIXME: make this maximum of 5 configurable
|
||||
let (writertx, writerrx) = crossbeam_channel::bounded(5);
|
||||
|
||||
debug!("Configuring radio");
|
||||
thread::sleep(Duration::from_secs(2));
|
||||
trace!("Sending +++");
|
||||
ser_writer.swrite.write_all(b"+++").unwrap();
|
||||
ser_writer.swrite.flush().unwrap();
|
||||
|
||||
loop {
|
||||
// There might be other packets flowing in while we wait for the OK. FIXME: this could still find
|
||||
// it prematurely if OK\r occurs in a packet.
|
||||
trace!("Waiting for OK");
|
||||
let line = ser_reader.readln().unwrap().unwrap();
|
||||
if line.ends_with("OK") {
|
||||
trace!("Received OK");
|
||||
break;
|
||||
} else {
|
||||
trace!("Will continue waiting for OK");
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(file) = initfile {
|
||||
let f = fs::File::open(file).unwrap();
|
||||
let reader = BufReader::new(f);
|
||||
for line in reader.lines() {
|
||||
let line = line.unwrap();
|
||||
if line.len() > 0 {
|
||||
ser_writer.writeln(&line).unwrap();
|
||||
assert_eq!(ser_reader.readln().unwrap().unwrap(), String::from("OK"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enter API mode
|
||||
ser_writer.writeln("ATAP 1").unwrap();
|
||||
assert_eq!(ser_reader.readln().unwrap().unwrap(), String::from("OK"));
|
||||
|
||||
// Standard API output mode
|
||||
ser_writer.writeln("ATAO 0").unwrap();
|
||||
assert_eq!(ser_reader.readln().unwrap().unwrap(), String::from("OK"));
|
||||
|
||||
// Get our own MAC address
|
||||
ser_writer.writeln("ATSH").unwrap();
|
||||
let serialhigh = ser_reader.readln().unwrap().unwrap();
|
||||
let serialhighu64 = u64::from_str_radix(&serialhigh, 16).unwrap();
|
||||
|
||||
ser_writer.writeln("ATSL").unwrap();
|
||||
let seriallow = ser_reader.readln().unwrap().unwrap();
|
||||
let seriallowu64 = u64::from_str_radix(&seriallow, 16).unwrap();
|
||||
|
||||
let mymac = serialhighu64 << 32 | seriallowu64;
|
||||
|
||||
// Get maximum packet size
|
||||
ser_writer.writeln("ATNP").unwrap();
|
||||
let maxpacket = ser_reader.readln().unwrap().unwrap();
|
||||
let maxpacketsize = usize::from(u16::from_str_radix(&maxpacket, 16).unwrap());
|
||||
|
||||
// Exit command mode
|
||||
ser_writer.writeln("ATCN").unwrap();
|
||||
assert_eq!(ser_reader.readln().unwrap().unwrap(), String::from("OK"));
|
||||
|
||||
debug!("Radio configuration complete");
|
||||
|
||||
let writerthread = thread::spawn(move || {
|
||||
writerthread(
|
||||
ser_writer,
|
||||
maxpacketsize,
|
||||
writerrx,
|
||||
disable_xbee_acks,
|
||||
request_xbee_tx_reports,
|
||||
)
|
||||
});
|
||||
|
||||
(
|
||||
XB {
|
||||
ser_reader,
|
||||
mymac,
|
||||
maxpacketsize,
|
||||
},
|
||||
writertx,
|
||||
writerthread,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn writerthread(
|
||||
mut ser: XBSerWriter,
|
||||
maxpacketsize: usize,
|
||||
writerrx: crossbeam_channel::Receiver<XBTX>,
|
||||
disable_xbee_acks: bool,
|
||||
request_xbee_tx_reports: bool,
|
||||
) {
|
||||
let mut packetstream = PacketStream::new();
|
||||
for item in writerrx.iter() {
|
||||
match item {
|
||||
XBTX::Shutdown => return,
|
||||
XBTX::TXData(dest, data) => {
|
||||
// Here we receive a block of data, which hasn't been
|
||||
// packetized. Packetize it and send out the result.
|
||||
|
||||
match packetstream.packetize_data(
|
||||
maxpacketsize,
|
||||
&dest,
|
||||
&data,
|
||||
disable_xbee_acks,
|
||||
request_xbee_tx_reports,
|
||||
) {
|
||||
Ok(packets) => {
|
||||
for packet in packets.into_iter() {
|
||||
match packet.serialize() {
|
||||
Ok(datatowrite) => {
|
||||
trace!(
|
||||
"TX ID {:X} to {:?} data {}",
|
||||
packet.frame_id,
|
||||
&dest,
|
||||
hex::encode(&datatowrite)
|
||||
);
|
||||
ser.swrite.write_all(&datatowrite).unwrap();
|
||||
ser.swrite.flush().unwrap();
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Serialization error: {:?}", e);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Packetization error: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,249 +0,0 @@
|
|||
/*! XBee packet transmission */
|
||||
/*
|
||||
Copyright (C) 2020 John Goerzen <jgoerzen@complete.org
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
|
||||
use bytes::*;
|
||||
use log::*;
|
||||
use std::convert::{TryFrom, TryInto};
|
||||
use std::fmt;
|
||||
|
||||
/** XBee transmissions can give either a 64-bit or a 16-bit destination
|
||||
address. This permits the user to select one. */
|
||||
#[derive(Eq, PartialEq, Clone)]
|
||||
pub enum XBDestAddr {
|
||||
/// A 16-bit destination address. When a 64-bit address is given, this is transmitted as 0xFFFE.
|
||||
U16(u16),
|
||||
|
||||
/// The 64-bit destination address. 0xFFFF for broadcast.
|
||||
/// When a 16-bit destination is given, this will be transmitted as 0xFFFFFFFFFFFFFFFF.
|
||||
U64(u64),
|
||||
}
|
||||
|
||||
impl fmt::Debug for XBDestAddr {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
XBDestAddr::U16(x) => {
|
||||
f.write_str("U16(")?;
|
||||
f.write_str(&hex::encode(x.to_be_bytes()))?;
|
||||
f.write_str(")")
|
||||
}
|
||||
XBDestAddr::U64(x) => {
|
||||
f.write_str("U64(")?;
|
||||
f.write_str(&hex::encode(x.to_be_bytes()))?;
|
||||
f.write_str(")")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Possible errors from serialization */
|
||||
#[derive(Eq, PartialEq, Debug)]
|
||||
pub enum TXGenError {
|
||||
/// The payload was an invalid length
|
||||
InvalidLen,
|
||||
}
|
||||
|
||||
/** A Digi 64-bit transmit request, frame type 0x10 */
|
||||
#[derive(Eq, PartialEq, Debug)]
|
||||
pub struct XBTXRequest {
|
||||
/// The frame ID, which will be returned in the subsequent response frame.
|
||||
/// Set to 0 to disable a response for this transmission.
|
||||
pub frame_id: u8,
|
||||
|
||||
/// The destination address
|
||||
pub dest_addr: XBDestAddr,
|
||||
|
||||
/// The number of hops a broadcast transmission can traverse. When 0, the value if NH is used.
|
||||
pub broadcast_radius: u8,
|
||||
|
||||
/// Transmit options bitfield. When 0, uses the TO setting.
|
||||
pub transmit_options: u8,
|
||||
|
||||
/// The payload
|
||||
pub payload: Bytes,
|
||||
}
|
||||
|
||||
impl XBTXRequest {
|
||||
pub fn serialize(&self) -> Result<Bytes, TXGenError> {
|
||||
if self.payload.is_empty() {
|
||||
return Err(TXGenError::InvalidLen);
|
||||
}
|
||||
|
||||
// We generate the bits that are outside the length & checksum parts, then the
|
||||
// inner parts, then combine them.
|
||||
let mut fullframe = BytesMut::new();
|
||||
|
||||
fullframe.put_u8(0x7e); // Start delimeter
|
||||
|
||||
let mut innerframe = BytesMut::new();
|
||||
// Frame type
|
||||
innerframe.put_u8(0x10);
|
||||
|
||||
innerframe.put_u8(self.frame_id);
|
||||
match self.dest_addr {
|
||||
XBDestAddr::U16(dest) => {
|
||||
innerframe.put_u64(0xFFFFFFFFFFFFFFFFu64);
|
||||
innerframe.put_u16(dest);
|
||||
}
|
||||
XBDestAddr::U64(dest) => {
|
||||
innerframe.put_u64(dest);
|
||||
innerframe.put_u16(0xFFFEu16);
|
||||
}
|
||||
};
|
||||
|
||||
innerframe.put_u8(self.broadcast_radius);
|
||||
innerframe.put_u8(self.transmit_options);
|
||||
innerframe.put_slice(&self.payload);
|
||||
|
||||
// That's it for the inner frame. Now fill in the outer frame.
|
||||
if let Ok(lenu16) = u16::try_from(innerframe.len()) {
|
||||
fullframe.put_u16(lenu16);
|
||||
fullframe.put_slice(&innerframe);
|
||||
fullframe.put_u8(xbchecksum(&innerframe));
|
||||
Ok(fullframe.freeze())
|
||||
} else {
|
||||
Err(TXGenError::InvalidLen)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Calculate an XBee checksum over a slice
|
||||
pub fn xbchecksum(data: &[u8]) -> u8 {
|
||||
let sumu64: u64 = data.into_iter().map(|x| u64::from(*x)).sum();
|
||||
0xffu8 - (sumu64 as u8)
|
||||
}
|
||||
|
||||
/** Return a 48-bit MAC given the 64-bit MAC. Truncates the most significant bits.
|
||||
|
||||
# Example
|
||||
|
||||
```
|
||||
use xbnet::xbpacket::*;
|
||||
|
||||
let mac64 = 0x123456789abcdeffu64;
|
||||
let mac48 = mac64to48(mac64);
|
||||
assert_eq!([0x56, 0x78, 0x9a, 0xbc, 0xde, 0xff], mac48);
|
||||
assert_eq(mac64, mac48to64(mac48, mac64));
|
||||
```
|
||||
*/
|
||||
pub fn mac64to48(mac64: u64) -> [u8; 6] {
|
||||
let macbytes = mac64.to_be_bytes();
|
||||
macbytes[2..].try_into().unwrap()
|
||||
}
|
||||
|
||||
/** Return a 64-bit MAC given a pattern 64-bit MAC and a 48-bit MAC. The 16 most
|
||||
significant bits from the pattern will be used to complete the 48-bit MAC to 64-bit.
|
||||
*/
|
||||
pub fn mac48to64(mac48: &[u8; 6], pattern64: u64) -> u64 {
|
||||
let mut mac64bytes = [0u8; 8];
|
||||
mac64bytes[2..].copy_from_slice(mac48);
|
||||
let mut mac64 = u64::from_be_bytes(mac64bytes);
|
||||
mac64 |= pattern64 & 0xffff000000000000;
|
||||
mac64
|
||||
}
|
||||
|
||||
pub struct PacketStream {
|
||||
/// The counter for the frame
|
||||
framecounter: u8,
|
||||
}
|
||||
|
||||
impl PacketStream {
|
||||
pub fn new() -> Self {
|
||||
PacketStream { framecounter: 1 }
|
||||
}
|
||||
|
||||
pub fn get_and_incr_framecounter(&mut self) -> u8 {
|
||||
let retval = self.framecounter;
|
||||
if self.framecounter == std::u8::MAX {
|
||||
self.framecounter = 1
|
||||
} else {
|
||||
self.framecounter += 1
|
||||
}
|
||||
retval
|
||||
}
|
||||
|
||||
/** Convert the given data into zero or more packets for transmission.
|
||||
|
||||
We create a leading byte that indicates how many more XBee packets are remaining
|
||||
for the block. When zero, the receiver should process the accumulated data. */
|
||||
pub fn packetize_data(
|
||||
&mut self,
|
||||
maxpacketsize: usize,
|
||||
dest: &XBDestAddr,
|
||||
data: &[u8],
|
||||
disable_xbee_acks: bool,
|
||||
request_xbee_tx_reports: bool,
|
||||
) -> Result<Vec<XBTXRequest>, String> {
|
||||
let mut retval = Vec::new();
|
||||
if data.is_empty() {
|
||||
return Ok(retval);
|
||||
}
|
||||
|
||||
// trace!("xbpacket: data len {}", data.len());
|
||||
let chunks: Vec<&[u8]> = data.chunks(maxpacketsize - 1).collect();
|
||||
// trace!("xbpacket: chunk count {}", chunks.len());
|
||||
let mut chunks_remaining: u8 = u8::try_from(chunks.len())
|
||||
.map_err(|e| String::from("More than 255 chunks to transmit"))?;
|
||||
for chunk in chunks {
|
||||
// trace!("xbpacket: chunks_remaining: {}", chunks_remaining);
|
||||
let mut payload = BytesMut::new();
|
||||
payload.put_u8(chunks_remaining - 1);
|
||||
payload.put_slice(chunk);
|
||||
let frame_id = if request_xbee_tx_reports {
|
||||
self.get_and_incr_framecounter()
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let packet = XBTXRequest {
|
||||
frame_id,
|
||||
dest_addr: dest.clone(),
|
||||
broadcast_radius: 0,
|
||||
transmit_options: if disable_xbee_acks { 0x01 } else { 0 },
|
||||
payload: Bytes::from(payload),
|
||||
};
|
||||
|
||||
retval.push(packet);
|
||||
chunks_remaining -= 1;
|
||||
}
|
||||
|
||||
Ok(retval)
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// RX side
|
||||
|
||||
/** A Digi receive packet, 0x90 */
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub struct RXPacket {
|
||||
pub sender_addr64: u64,
|
||||
pub sender_addr16: u16,
|
||||
pub rx_options: u8,
|
||||
pub payload: Bytes,
|
||||
}
|
||||
|
||||
/** A Digi extended transmit status frame, 0x8B */
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub struct ExtTxStatus {
|
||||
pub frame_id: u8,
|
||||
pub dest_addr_16: u16,
|
||||
pub tx_retry_count: u8,
|
||||
pub delivery_status: u8,
|
||||
pub discovery_status: u8,
|
||||
}
|
|
@ -1,162 +0,0 @@
|
|||
/*! Receiving data from XBee */
|
||||
|
||||
/*
|
||||
Copyright (C) 2019-2020 John Goerzen <jgoerzen@complete.org
|
||||
|
||||
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/>.
|
||||
|
||||
*/
|
||||
|
||||
use crate::ser::*;
|
||||
use crate::xbpacket::*;
|
||||
use bytes::*;
|
||||
use hex;
|
||||
use log::*;
|
||||
use std::collections::HashMap;
|
||||
use std::io::Read;
|
||||
|
||||
/** Attempts to read a packet from the port. Returns
|
||||
None if it's not an RX frame, or if there is a checksum mismatch. */
|
||||
pub fn rxxbpacket(ser: &mut XBSerReader) -> Option<RXPacket> {
|
||||
let mut junkbytes = BytesMut::new();
|
||||
loop {
|
||||
let mut startdelim = [0u8; 1];
|
||||
ser.br.read_exact(&mut startdelim).unwrap();
|
||||
if startdelim[0] != 0x7e {
|
||||
if junkbytes.is_empty() {
|
||||
error!("Receiving junk");
|
||||
}
|
||||
|
||||
junkbytes.put_u8(startdelim[0]);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// OK, got the start delimeter. Log the junk, if any.
|
||||
if !junkbytes.is_empty() {
|
||||
error!(
|
||||
"Found start delimeter after reading junk: {}",
|
||||
hex::encode(&junkbytes)
|
||||
);
|
||||
junkbytes.clear();
|
||||
}
|
||||
|
||||
// Read the length.
|
||||
|
||||
let mut lenbytes = [0u8; 2];
|
||||
ser.br.read_exact(&mut lenbytes).unwrap();
|
||||
let length = usize::from(u16::from_be_bytes(lenbytes));
|
||||
|
||||
// Now read the rest of the frame.
|
||||
let mut inner = vec![0u8; length];
|
||||
|
||||
ser.br.read_exact(&mut inner).unwrap();
|
||||
|
||||
// And the checksum.
|
||||
let mut checksum = [0u8; 1];
|
||||
ser.br.read_exact(&mut checksum).unwrap();
|
||||
|
||||
if xbchecksum(&inner) != checksum[0] {
|
||||
error!("SERIN: Checksum mismatch; data: {}", hex::encode(inner));
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut inner = Bytes::from(inner);
|
||||
let frametype = inner.get_u8();
|
||||
match frametype {
|
||||
0x8B => {
|
||||
// Delivery status update. Log and ignore.
|
||||
let frame_id = inner.get_u8();
|
||||
let dest_addr_16 = inner.get_u16();
|
||||
let tx_retry_count = inner.get_u8();
|
||||
let delivery_status = inner.get_u8();
|
||||
let discovery_status = inner.get_u8();
|
||||
trace!("TX STATUS: frame_id: {:X}, dest_addr_16: {:X}, tx_retry_count: {:X}, delivery_status: {:X}, discovery_status: {:X}",
|
||||
frame_id, dest_addr_16, tx_retry_count, delivery_status, discovery_status);
|
||||
None
|
||||
}
|
||||
0x90 => {
|
||||
let sender_addr64 = inner.get_u64();
|
||||
let sender_addr16 = inner.get_u16();
|
||||
let rx_options = inner.get_u8();
|
||||
let payload = inner.to_bytes();
|
||||
trace!(
|
||||
"SERIN: packet from {} / {}, payload {}",
|
||||
hex::encode(sender_addr64.to_be_bytes()),
|
||||
hex::encode(sender_addr16.to_be_bytes()),
|
||||
hex::encode(&payload)
|
||||
);
|
||||
Some(RXPacket {
|
||||
sender_addr64,
|
||||
sender_addr16,
|
||||
rx_options,
|
||||
payload,
|
||||
})
|
||||
}
|
||||
_ => {
|
||||
debug!("SERIN: Non-0x90 frame; data: {}", hex::encode(inner));
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Like rxxbpacket, but wait until we have a valid packet.
|
||||
pub fn rxxbpacket_wait(ser: &mut XBSerReader) -> RXPacket {
|
||||
loop {
|
||||
if let Some(packet) = rxxbpacket(ser) {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Receives XBee packets, recomposes into larger frames.
|
||||
pub struct XBReframer {
|
||||
buf: HashMap<u64, BytesMut>,
|
||||
}
|
||||
|
||||
/** Receive a frame that may have been split up into multiple XBee frames. Reassemble
|
||||
as needed and return when we've got something that can be returned. */
|
||||
impl XBReframer {
|
||||
pub fn new() -> Self {
|
||||
XBReframer {
|
||||
buf: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Receive a frame. Indicate the sender (u64, u16) and payload.
|
||||
pub fn rxframe(&mut self, ser: &mut XBSerReader) -> (u64, u16, Bytes) {
|
||||
loop {
|
||||
let packet = rxxbpacket_wait(ser);
|
||||
let mut frame = BytesMut::new();
|
||||
if let Some(olddata) = self.buf.get(&packet.sender_addr64) {
|
||||
frame.extend_from_slice(olddata);
|
||||
};
|
||||
|
||||
frame.extend_from_slice(&packet.payload[1..]);
|
||||
if packet.payload[0] == 0x0 {
|
||||
self.buf.remove(&packet.sender_addr64);
|
||||
return (packet.sender_addr64, packet.sender_addr16, frame.freeze());
|
||||
} else {
|
||||
self.buf.insert(packet.sender_addr64, frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn discardframes(&mut self, ser: &mut XBSerReader) -> () {
|
||||
loop {
|
||||
let _ = self.rxframe(ser);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue