From ccba7a7f9b9fd80d704585287e62502911602ba8 Mon Sep 17 00:00:00 2001 From: docker24016 <350790575+docker24016@users.noreply.github.com> Date: Mon, 2 Nov 2026 09:43:42 +0000 Subject: [PATCH] feat(#943): import du dissecteur Meshtastic LoRa d'Exploitee.rs --- dissectors/meshtastic-exploiteers/LICENSE | 674 +++++++ dissectors/meshtastic-exploiteers/README.md | 111 ++ .../src/meshtastic/aeslua/Copyright.txt | 25 + .../src/meshtastic/aeslua/License.txt | 450 +++++ .../src/meshtastic/aeslua/aes.lua | 512 +++++ .../src/meshtastic/aeslua/buffer.lua | 31 + .../src/meshtastic/aeslua/ciphermode.lua | 166 ++ .../src/meshtastic/aeslua/gf.lua | 121 ++ .../src/meshtastic/aeslua/util.lua | 159 ++ .../src/meshtastic/colorrules | 2 + .../src/meshtastic/meshtastic.lua | 335 ++++ .../google/protobuf/descriptor.proto | 1296 +++++++++++++ .../protobufs/meshtastic/admin.options | 12 + .../protobufs/meshtastic/admin.proto | 388 ++++ .../protobufs/meshtastic/apponly.options | 1 + .../protobufs/meshtastic/apponly.proto | 31 + .../protobufs/meshtastic/atak.options | 7 + .../protobufs/meshtastic/atak.proto | 257 +++ .../meshtastic/cannedmessages.options | 1 + .../protobufs/meshtastic/cannedmessages.proto | 19 + .../protobufs/meshtastic/channel.options | 5 + .../protobufs/meshtastic/channel.proto | 156 ++ .../protobufs/meshtastic/clientonly.options | 2 + .../protobufs/meshtastic/clientonly.proto | 42 + .../protobufs/meshtastic/config.options | 17 + .../protobufs/meshtastic/config.proto | 1012 ++++++++++ .../meshtastic/connection_status.options | 1 + .../meshtastic/connection_status.proto | 120 ++ .../protobufs/meshtastic/deviceonly.options | 16 + .../protobufs/meshtastic/deviceonly.proto | 258 +++ .../meshtastic/exploiteers_pager.options | 5 + .../meshtastic/exploiteers_pager.proto | 34 + .../protobufs/meshtastic/localonly.proto | 135 ++ .../protobufs/meshtastic/mesh.options | 65 + .../protobufs/meshtastic/mesh.proto | 1711 +++++++++++++++++ .../meshtastic/module_config.options | 28 + .../protobufs/meshtastic/module_config.proto | 802 ++++++++ .../protobufs/meshtastic/mqtt.options | 8 + .../protobufs/meshtastic/mqtt.proto | 106 + .../protobufs/meshtastic/paxcount.proto | 29 + .../protobufs/meshtastic/portnums.proto | 216 +++ .../meshtastic/remote_hardware.proto | 75 + .../protobufs/meshtastic/rtttl.options | 1 + .../protobufs/meshtastic/rtttl.proto | 19 + .../protobufs/meshtastic/storeforward.options | 1 + .../protobufs/meshtastic/storeforward.proto | 218 +++ .../protobufs/meshtastic/telemetry.options | 5 + .../protobufs/meshtastic/telemetry.proto | 403 ++++ .../protobufs/meshtastic/xmodem.options | 6 + .../protobufs/meshtastic/xmodem.proto | 27 + .../src/meshtastic/protobufs/nanopb.proto | 184 ++ 51 files changed, 10305 insertions(+) create mode 100644 dissectors/meshtastic-exploiteers/LICENSE create mode 100644 dissectors/meshtastic-exploiteers/README.md create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/Copyright.txt create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/License.txt create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/aes.lua create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/buffer.lua create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/ciphermode.lua create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/gf.lua create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/util.lua create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/colorrules create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/meshtastic.lua create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/google/protobuf/descriptor.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/admin.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/admin.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/apponly.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/apponly.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/atak.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/atak.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/cannedmessages.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/cannedmessages.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/channel.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/channel.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/clientonly.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/clientonly.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/config.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/config.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/connection_status.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/connection_status.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/deviceonly.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/deviceonly.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/exploiteers_pager.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/exploiteers_pager.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/localonly.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mesh.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mesh.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/module_config.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/module_config.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mqtt.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mqtt.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/paxcount.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/portnums.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/remote_hardware.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/rtttl.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/rtttl.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/storeforward.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/storeforward.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/telemetry.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/telemetry.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/xmodem.options create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/xmodem.proto create mode 100644 dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/nanopb.proto diff --git a/dissectors/meshtastic-exploiteers/LICENSE b/dissectors/meshtastic-exploiteers/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + 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. + + + Copyright (C) + + 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 . + +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: + + Copyright (C) + 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 +. + + 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 +. diff --git a/dissectors/meshtastic-exploiteers/README.md b/dissectors/meshtastic-exploiteers/README.md new file mode 100644 index 0000000..0facefc --- /dev/null +++ b/dissectors/meshtastic-exploiteers/README.md @@ -0,0 +1,111 @@ +# Meshtastic sur LoRa — dissecteur d'Exploitee.rs (Hacker Pager) + +Dissecteur Wireshark Lua des trames radio LoRa du réseau maillé +Meshtastic, publié par Exploitee.rs pour lire les captures de son +« Hacker Pager ». Il se branche sur le dissecteur LoRaTap natif (mot de +synchronisation 0x2b) et décode l'en-tête Meshtastic (destination, +émetteur, identifiant, sauts, accusé de réception, MQTT, empreinte du +canal). Il déchiffre ensuite la charge utile en AES-CTR avec la clé du +canal (préférence) et la confie au dissecteur protobuf de Wireshark +(`meshtastic.Data`, puis le message selon le `portnum` : texte, +`User`, position, télémétrie, routage…). Il signale aussi les doublons +et ajoute aux colonnes Source et Destination les noms des nœuds appris +dans les messages NODEINFO (issue #943). + +Ce dossier est distinct de `dissectors/meshtastic-talk/` et de +`dissectors/meshtastic-stridetastic/` : autre auteur, et ce script lit +les trames radio chiffrées (LoRaTap), pas des messages protobuf déjà +déchiffrés. + +## Import + +| | | +|---|---| +| Dépôt amont | https://github.com/exploiteers/Exploiteers-Wireshark-LoRa (dossier `meshtastic/`) | +| Commit importé | `ad985742a2a5893fa9753b780b86d365dce0beb0` du 08/10/2025 (dernier commit de la branche par défaut `main`, « Initial release ») ; tous les fichiers importés datent de ce commit | +| Licence amont | GPL-3.0-only : `LICENSE` du dépôt (texte de la GPLv3, sans mention « or later »). Bibliothèque `aeslua` (© 2006-2007 Matthias Hilbig) : LGPL-2.1-or-later d'après `aeslua/Copyright.txt` ; le fichier `aeslua/License.txt` qui l'accompagne contient pourtant le texte de la GPLv3. Fichiers `.proto` : ceux du projet Meshtastic (GPL-3.0), `google/protobuf/descriptor.proto` (BSD-3-Clause, © Google) et `nanopb.proto` (zlib, nanopb), sans en-tête de licence pour la plupart. Tout est compatible avec la GPL-3.0 de ce dépôt | +| Natif Wireshark 4.6.4 | Non : LoRaTap est natif, mais aucun dissecteur Meshtastic dans `tshark -G protocols` | + +Texte de la licence : fichier `LICENSE` de ce dossier (copie conforme +du `LICENSE` amont) ; les fichiers `Copyright.txt` et `License.txt` +d'aeslua restent à leur place dans `src/meshtastic/aeslua/`. Le dossier +`meshtastic/` amont est repris tel quel (aucune modification ; fins de +ligne CRLF de `meshtastic.lua` conservées) ; seule l'en-tête de +provenance de cinq lignes est ajoutée en tête de chaque fichier `.lua` +(convention du dépôt, issue #563). Les fichiers `.proto` et `colorrules` +ne sont pas modifiés. + +## Fichiers + +| Fichier | Rôle | +|---|---| +| `src/meshtastic/meshtastic.lua` | Chargement d'aeslua (ligne 28) ; clé du canal (ligne 35) et vecteur d'initialisation (ligne 73) ; protocole `meshtastic` (« Meshtastic », ligne 84) et préférence de clé (ligne 85, `AQ==` par défaut) ; sous-protocole de charge utile (ligne 136) ; post-dissecteur des noms (lignes 150 et 161) ; dissecteur ligne 170 (déchiffrement ligne 238) ; inscription sur `loratap.syncword` 0x2b (ligne 263) ; décodage par `portnum` (ligne 272) ; inscription sur `protobuf_field` `meshtastic.Data.payload` (ligne 334) | +| `src/meshtastic/aeslua/*.lua` | Bibliothèque AES en Lua pur (aeslua), appelée par `require("meshtastic.aeslua.…")` | +| `src/meshtastic/protobufs/` | Fichiers `.proto` de Meshtastic (21 fichiers dans `meshtastic/`, dont `exploiteers_pager.proto`, propre au Hacker Pager), `nanopb.proto` et `google/protobuf/descriptor.proto` | +| `src/meshtastic/colorrules` | Règle de couleur « Duplicate packets » (`meshtastic.duplicate`) | + +## Utilisation + +1. Copier le dossier `src/meshtastic/` entier dans le dossier des + plugins Lua personnels (`~/.local/lib/wireshark/plugins/meshtastic/`) : + le nom du dossier doit rester `meshtastic`, sinon les `require` + échouent. Le script ne peut pas être chargé seul par + `-X lua_script:` (« module 'meshtastic.aeslua.ciphermode' not + found »). +2. Préférences → Protocols → ProtoBuf : cocher « Load .proto files on + startup » et « Dissect protobuf fields as Wireshark fields » + (`protobuf.preload_protos`, `protobuf.pbf_as_hf`), puis ajouter + `plugins/meshtastic/protobufs/` aux « Protobuf search paths » avec + « Load all files ». +3. Préférences → Protocols → Meshtastic : clé du canal principal en + base64 (`AQ==` pour le canal par défaut LongFast). + +Filtres : `meshtastic`, `meshtastic.from`, `meshtastic.to`, +`meshtastic.id`, `meshtastic.payload.portnum`, `meshtastic.payload.text`, +`meshtastic.duplicate`, et les champs protobuf `pbf.meshtastic.*`. + +## Vérification à l'import + +`luac5.4 -p` : OK pour les six fichiers `.lua`. tshark 4.6.4, dossier +copié dans le dossier des plugins : chargement sans erreur. Le dépôt +amont ne contient aucune capture. Essais sur une capture synthétique +non commitée (LoRaTap v0, DLT 270, mot de synchronisation 0x2b), +charges utiles chiffrées en AES-128-CTR avec la clé par défaut, comme +le micrologiciel Meshtastic : + +| Essai | Résultat | +|---|---| +| Texte en diffusion | « 0x11223344 → 0xffffffff (broadcast) », « Text message: "Bonjour Haguenau" » | +| NODEINFO (`User`, nom long « Station Test Haguenau ») | « 0x11223344 is "Station Test Haguenau" » ; les trames suivantes de ce nœud affichent « 0x11223344 (Station Test Haguenau) » | +| Texte direct de 66 caractères (plusieurs blocs AES) | Déchiffré en entier | +| Même identifiant de paquet qu'une trame précédente | Note « Duplicate of an earlier packet » ; filtre `meshtastic.duplicate` : 1 trame | +| Octets non chiffrés quelconques | « Malformed meshtastic.Data protobuf » | +| Position et télémétrie | « latitude_i=487000000 longitude_i=78000000 », « time=1793612187 » | +| Clé `Ag==` au lieu de `AQ==` | Toutes les trames chiffrées : « Malformed meshtastic.Data protobuf » | +| Sans les réglages protobuf de l'étape 2 | Toutes les trames : « Malformed meshtastic.Data protobuf » | +| NODEINFO sans nom long | Erreur Lua « attempt to index a nil value » (ligne 282) | + +## Limites constatées + +- Les trois réglages protobuf de l'étape 2 sont indispensables : sans + eux, aucune trame n'est décodée. +- Un message NODEINFO sans nom long provoque une erreur Lua (ligne + 282 : `f_proto_meshtastic_User_long_name()` vaut `nil`). +- Les noms des nœuds ne sont connus qu'après leur message NODEINFO : les + trames antérieures n'en ont pas, même en deux passes (`-2`), car la + table est vidée à chaque passe (lignes 164 à 167). +- Seule la clé du canal principal est utilisée ; les messages directs + chiffrés par PKI (Meshtastic 2.5 et plus) ne sont pas déchiffrés. +- Le protocole s'appelle `meshtastic` (ligne 84), comme dans + `meshtastic-talk` et `meshtastic-stridetastic` : un seul des trois + scripts peut être chargé à la fois. +- Le script déclare un champ `eth.fcs.status` (ligne 132), déjà utilisé + par le dissecteur Ethernet, pour profiter de ses règles de couleur ; + et une fonction globale `call_protobuf` (ligne 266). +- La colonne Info des messages NODEINFO reçoit des ajouts du dissecteur + protobuf malgré `fence()` (remarque de l'auteur, ligne 283). +- Les fichiers `.proto` sont une copie figée (2025) de ceux de + Meshtastic ; les messages ajoutés depuis n'y sont pas. +- Les `portnum` 7 (texte compressé unishox2), 9 (audio codec2), 64, 68 + et 257 ne sont pas décodés ; le 33 (tunnel IP) n'a pas été essayé + (« TODO: Untested », ligne 304). diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/Copyright.txt b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/Copyright.txt new file mode 100644 index 0000000..a4f56d0 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/Copyright.txt @@ -0,0 +1,25 @@ +aeslua: Lua AES implementation +Copyright (c) 2006,2007 Matthias Hilbig + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU Lesser Public License as published by the +Free Software Foundation; either version 2.1 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 +Lesser Public License for more details. + +A copy of the terms and conditions of the license can be found in +License.txt or online at + + http://www.gnu.org/copyleft/lesser.html + +To obtain a copy, write to the Free Software Foundation, Inc., +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Author +------- +Matthias Hilbig +mhilbig@gmail.com diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/License.txt b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/License.txt new file mode 100644 index 0000000..6063a46 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/License.txt @@ -0,0 +1,450 @@ +---------------------------------------------------------------------- +The aeslua (all versions) is provided under the terms and +conditions of the GNU Lesser General Public Library, which is stated +below. It can also be found at: + + http://www.gnu.org/copyleft/lesser.html + +---------------------------------------------------------------------- + +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts +as the successor of the GNU Library Public License, version 2, hence the +version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to +share and change it. By contrast, the GNU General Public Licenses are +intended to guarantee your freedom to share and change free software--to +make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the Free +Software Foundation and other authors who decide to use it. You can use +it too, but we suggest you first think carefully about whether this +license or the ordinary General Public License is the better strategy to +use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, 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 +this service if you wish); that you receive source code or can get it if +you want it; that you can change the software and use pieces of it in +new free programs; and that you are informed that you can do these +things. + +To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for you +if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or +for a fee, you must give the recipients all the rights that we gave you. +You must make sure that they, too, receive or can get the source code. +If you link other code with the library, you must provide complete +object files to the recipients, so that they can relink them with the +library after making changes to the library and recompiling it. And you +must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is +no warranty for the free library. Also, if the library is modified by +someone else and passed on, the recipients should know that what they +have is not the original version, so that the original author's +reputation will not be affected by problems that might be introduced by +others. + +Finally, software patents pose a constant threat to the existence of any +free program. We wish to make sure that a company cannot effectively +restrict the users of a free program by obtaining a restrictive license +from a patent holder. Therefore, we insist that any patent license +obtained for a version of the library must be consistent with the full +freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License. This license, the GNU Lesser General Public +License, applies to certain designated libraries, and is quite different +from the ordinary General Public License. We use this license for +certain libraries in order to permit linking those libraries into +non-free programs. + +When a program is linked with a library, whether statically or using a +shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the entire +combination fits its criteria of freedom. The Lesser General Public +License permits more lax criteria for linking other code with the +library. + +We call this license the "Lesser" General Public License because it does +Less to protect the user's freedom than the ordinary General Public +License. It also provides other free software developers Less of an +advantage over competing non-free programs. These disadvantages are the +reason we use the ordinary General Public License for many libraries. +However, the Lesser license provides advantages in certain special +circumstances. + +For example, on rare occasions, there may be a special need to encourage +the widest possible use of a certain library, so that it becomes a +de-facto standard. To achieve this, non-free programs must be allowed to +use the library. A more frequent case is that a free library does the +same job as widely used non-free libraries. In this case, there is +little to gain by limiting the free library to free software only, so we +use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of free +software. For example, permission to use the GNU C Library in non-free +programs enables many more people to use the whole GNU operating system, +as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is linked +with the Library has the freedom and the wherewithal to run that program +using a modified version of the Library. + +The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or other +authorized party saying it may be distributed under the terms of this +Lesser General Public License (also called "this License"). Each +licensee is addressed as "you". + +A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which +has been distributed under these terms. A "work based on the Library" +means either the Library or any derivative work under copyright law: +that is to say, a work containing the Library or a portion of it, either +verbatim or with modifications and/or translated straightforwardly into +another language. (Hereinafter, translation is included without +limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making +modifications to it. For a library, complete source code means all the +source code for all modules it contains, plus any associated interface +definition files, plus the scripts used to control compilation and +installation of the library. + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of running +a program using the Library is not restricted, and output from such a +program is covered only if its contents constitute a work based on the +Library (independent of the use of the Library in a tool for writing +it). Whether that is true depends on what the Library does and what the +program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the notices +that refer to this License and to the absence of any warranty; and +distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of +it, thus forming a work based on the Library, and copy and distribute +such modifications or work under the terms of Section 1 above, provided +that you also meet all of these conditions: + + a) The modified work must itself be a software library. + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has +a purpose that is entirely well-defined independent of the application. +Therefore, Subsection 2d requires that any application-supplied function +or table used by this function must be optional: if the application does +not supply it, the square root function must still compute square +roots.) + + These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, and +can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based on +the Library, the distribution of the whole must be on the terms of this +License, whose permissions for other licensees extend to the entire +whole, and thus to each and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or +contest your rights to work written entirely by you; rather, the intent +is to exercise the right to control the distribution of derivative or +collective works based on the Library. + + In addition, mere aggregation of another work not based on the +Library with the Library (or with a work based on the Library) on a +volume of a storage or distribution medium does not bring the other work +under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so that +they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in these +notices. + +Once this change is made in a given copy, it is irreversible for that +copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the +Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative +of it, under Section 2) in object code or executable form under the +terms of Sections 1 and 2 above provided that you accompany it with the +complete corresponding machine-readable source code, which must be +distributed under the terms of Sections 1 and 2 above on a medium +customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a +designated place, then offering equivalent access to copy the source +code from the same place satisfies the requirement to distribute the +source code, even though third parties are not compelled to copy the +source along with the object code. + +5. A program that contains no derivative of any portion of the Library, +but is designed to work with the Library by being compiled or linked +with it, is called a "work that uses the Library". Such a work, in +isolation, is not a derivative work of the Library, and therefore falls +outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates +an executable that is a derivative of the Library (because it contains +portions of the Library), rather than a "work that uses the library". +The executable is therefore covered by this License. Section 6 states +terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be linked +without the Library, or if the work is itself a library. The threshold +for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure +layouts and accessors, and small macros and small inline functions (ten +lines or less in length), then the use of the object file is +unrestricted, regardless of whether it is legally a derivative work. +(Executables containing this object code plus portions of the Library +will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, whether +or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a +"work that uses the Library" with the Library to produce a work +containing portions of the Library, and distribute that work under terms +of your choice, provided that the terms permit modification of the work +for the customer's own use and reverse engineering for debugging such +modifications. + +You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work during +execution displays copyright notices, you must include the copyright +notice for the Library among them, as well as a reference directing the +user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood that + the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + c) Accompany the work with a written offer, valid for at least + three years, to give the same user the materials specified in + Subsection 6a, above, for a charge no more than the cost of + performing this distribution. + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" +must include any data and utility programs needed for reproducing the +executable from it. However, as a special exception, the materials to be +distributed need not include anything that is normally distributed (in +either source or binary form) with the major components (compiler, +kernel, and so on) of the operating system on which the executable runs, +unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions +of other proprietary libraries that do not normally accompany the +operating system. Such a contradiction means you cannot use both them +and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library +side-by-side in a single library together with other library facilities +not covered by this License, and distribute such a combined library, +provided that the separate distribution of the work based on the Library +and of the other library facilities is otherwise permitted, and provided +that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the +Library except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, link with, or distribute the +Library is void, and will automatically terminate your rights under this +License. However, parties who have received copies, or rights, from you +under this License will not have their licenses terminated so long as +such parties remain in full compliance. + +9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and all +its terms and conditions for copying, distributing or modifying the +Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + +11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +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 distribute +so as to satisfy simultaneously your obligations under this License and +any other pertinent obligations, then as a consequence you may not +distribute the Library at all. For example, if a patent license would +not permit royalty-free redistribution of the Library by all those who +receive copies directly or indirectly through you, then the only way you +could satisfy both it and this License would be to refrain entirely from +distribution of the Library. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply, and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is implemented +by public license practices. Many people have made generous +contributions to the wide range of software distributed through that +system in reliance on consistent application of that system; it is up to +the author/donor to decide if he or she is willing to distribute +software through any other system and a licensee cannot impose that +choice. + +This section is intended to make thoroughly clear what is believed to be +a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may +add an explicit geographical distribution limitation excluding those +countries, so that distribution is permitted only in or among countries +not thus excluded. In such case, this License incorporates the +limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions +of the Lesser 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 Library +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a license +version number, you may choose any version ever published by the Free +Software Foundation. + +14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free Software +Foundation; we sometimes make exceptions for this. Our decision will be +guided by the two goals of preserving the free status of all derivatives +of our free software and of promoting the sharing and reuse of software +generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE LIBRARY "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 LIBRARY IS WITH +YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL +NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY 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 LIBRARY +(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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR +OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/aes.lua b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/aes.lua new file mode 100644 index 0000000..e739912 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/aes.lua @@ -0,0 +1,512 @@ +-- SPDX-License-Identifier: LGPL-2.1-or-later +-- Importé de https://github.com/exploiteers/Exploiteers-Wireshark-LoRa (meshtastic/aeslua/aes.lua), +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025 (dernière modification du fichier : +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025). +-- Licence amont : LGPL-2.1-or-later (aeslua, © 2006-2007 Matthias Hilbig, meshtastic/aeslua/Copyright.txt) — voir README.md et LICENSE. +-- require("bit"); + +local gf = require("meshtastic.aeslua.gf"); +local util = require("meshtastic.aeslua.util"); + +-- +-- Implementation of AES with nearly pure lua (only bitlib is needed) +-- +-- AES with lua is slow, really slow :-) +-- + +local public = {}; +local private = {}; + +-- aeslua.aes = public; + +-- some constants +public.ROUNDS = "rounds"; +public.KEY_TYPE = "type"; +public.ENCRYPTION_KEY=1; +public.DECRYPTION_KEY=2; + +-- aes SBOX +private.SBox = {}; +private.iSBox = {}; + +-- aes tables +private.table0 = {}; +private.table1 = {}; +private.table2 = {}; +private.table3 = {}; + +private.tableInv0 = {}; +private.tableInv1 = {}; +private.tableInv2 = {}; +private.tableInv3 = {}; + +-- round constants +private.rCon = {0x01000000, + 0x02000000, + 0x04000000, + 0x08000000, + 0x10000000, + 0x20000000, + 0x40000000, + 0x80000000, + 0x1b000000, + 0x36000000, + 0x6c000000, + 0xd8000000, + 0xab000000, + 0x4d000000, + 0x9a000000, + 0x2f000000}; + +-- +-- affine transformation for calculating the S-Box of AES +-- +function private.affinMap(byte) + mask = 0xf8; + result = 0; + for i = 1,8 do + result = bit.lshift(result,1); + + parity = util.byteParity(bit.band(byte,mask)); + result = result + parity + + -- simulate roll + lastbit = bit.band(mask, 1); + mask = bit.band(bit.rshift(mask, 1),0xff); + if (lastbit ~= 0) then + mask = bit.bor(mask, 0x80); + else + mask = bit.band(mask, 0x7f); + end + end + + return bit.bxor(result, 0x63); +end + +-- +-- calculate S-Box and inverse S-Box of AES +-- apply affine transformation to inverse in finite field 2^8 +-- +function private.calcSBox() + for i = 0, 255 do + if (i ~= 0) then + inverse = gf.invert(i); + else + inverse = i; + end + mapped = private.affinMap(inverse); + private.SBox[i] = mapped; + private.iSBox[mapped] = i; + end +end + +-- +-- Calculate round tables +-- round tables are used to calculate shiftRow, MixColumn and SubBytes +-- with 4 table lookups and 4 xor operations. +-- +function private.calcRoundTables() + for x = 0,255 do + byte = private.SBox[x]; + private.table0[x] = util.putByte(gf.mul(0x03, byte), 0) + + util.putByte( byte , 1) + + util.putByte( byte , 2) + + util.putByte(gf.mul(0x02, byte), 3); + private.table1[x] = util.putByte( byte , 0) + + util.putByte( byte , 1) + + util.putByte(gf.mul(0x02, byte), 2) + + util.putByte(gf.mul(0x03, byte), 3); + private.table2[x] = util.putByte( byte , 0) + + util.putByte(gf.mul(0x02, byte), 1) + + util.putByte(gf.mul(0x03, byte), 2) + + util.putByte( byte , 3); + private.table3[x] = util.putByte(gf.mul(0x02, byte), 0) + + util.putByte(gf.mul(0x03, byte), 1) + + util.putByte( byte , 2) + + util.putByte( byte , 3); + end +end + +-- +-- Calculate inverse round tables +-- does the inverse of the normal roundtables for the equivalent +-- decryption algorithm. +-- +function private.calcInvRoundTables() + for x = 0,255 do + byte = private.iSBox[x]; + private.tableInv0[x] = util.putByte(gf.mul(0x0b, byte), 0) + + util.putByte(gf.mul(0x0d, byte), 1) + + util.putByte(gf.mul(0x09, byte), 2) + + util.putByte(gf.mul(0x0e, byte), 3); + private.tableInv1[x] = util.putByte(gf.mul(0x0d, byte), 0) + + util.putByte(gf.mul(0x09, byte), 1) + + util.putByte(gf.mul(0x0e, byte), 2) + + util.putByte(gf.mul(0x0b, byte), 3); + private.tableInv2[x] = util.putByte(gf.mul(0x09, byte), 0) + + util.putByte(gf.mul(0x0e, byte), 1) + + util.putByte(gf.mul(0x0b, byte), 2) + + util.putByte(gf.mul(0x0d, byte), 3); + private.tableInv3[x] = util.putByte(gf.mul(0x0e, byte), 0) + + util.putByte(gf.mul(0x0b, byte), 1) + + util.putByte(gf.mul(0x0d, byte), 2) + + util.putByte(gf.mul(0x09, byte), 3); + end +end + + +-- +-- rotate word: 0xaabbccdd gets 0xbbccddaa +-- used for key schedule +-- +function private.rotWord(word) + local tmp = bit.band(word,0xff000000); + return (bit.lshift(word,8) + bit.rshift(tmp,24)) ; +end + +-- +-- replace all bytes in a word with the SBox. +-- used for key schedule +-- +function private.subWord(word) + return util.putByte(private.SBox[util.getByte(word,0)],0) + + util.putByte(private.SBox[util.getByte(word,1)],1) + + util.putByte(private.SBox[util.getByte(word,2)],2) + + util.putByte(private.SBox[util.getByte(word,3)],3); +end + +-- +-- generate key schedule for aes encryption +-- +-- returns table with all round keys and +-- the necessary number of rounds saved in [public.ROUNDS] +-- +function public.expandEncryptionKey(key) + local keySchedule = {}; + local keyWords = math.floor(#key / 4); + + + if ((keyWords ~= 4 and keyWords ~= 6 and keyWords ~= 8) or (keyWords * 4 ~= #key)) then + print("Invalid key size: ", keyWords); + return nil; + end + + keySchedule[public.ROUNDS] = keyWords + 6; + keySchedule[public.KEY_TYPE] = public.ENCRYPTION_KEY; + + for i = 0,keyWords - 1 do + keySchedule[i] = util.putByte(key[i*4+1], 3) + + util.putByte(key[i*4+2], 2) + + util.putByte(key[i*4+3], 1) + + util.putByte(key[i*4+4], 0); + end + + for i = keyWords, (keySchedule[public.ROUNDS] + 1)*4 - 1 do + local tmp = keySchedule[i-1]; + + if ( i % keyWords == 0) then + tmp = private.rotWord(tmp); + tmp = private.subWord(tmp); + + local index = math.floor(i/keyWords); + tmp = bit.bxor(tmp,private.rCon[index]); + elseif (keyWords > 6 and i % keyWords == 4) then + tmp = private.subWord(tmp); + end + + keySchedule[i] = bit.bxor(keySchedule[(i-keyWords)],tmp); + end + + return keySchedule; +end + +-- +-- Inverse mix column +-- used for key schedule of decryption key +-- +function private.invMixColumnOld(word) + local b0 = util.getByte(word,3); + local b1 = util.getByte(word,2); + local b2 = util.getByte(word,1); + local b3 = util.getByte(word,0); + + return util.putByte(gf.add(gf.add(gf.add(gf.mul(0x0b, b1), + gf.mul(0x0d, b2)), + gf.mul(0x09, b3)), + gf.mul(0x0e, b0)),3) + + util.putByte(gf.add(gf.add(gf.add(gf.mul(0x0b, b2), + gf.mul(0x0d, b3)), + gf.mul(0x09, b0)), + gf.mul(0x0e, b1)),2) + + util.putByte(gf.add(gf.add(gf.add(gf.mul(0x0b, b3), + gf.mul(0x0d, b0)), + gf.mul(0x09, b1)), + gf.mul(0x0e, b2)),1) + + util.putByte(gf.add(gf.add(gf.add(gf.mul(0x0b, b0), + gf.mul(0x0d, b1)), + gf.mul(0x09, b2)), + gf.mul(0x0e, b3)),0); +end + +-- +-- Optimized inverse mix column +-- look at http://fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf +-- TODO: make it work +-- +function private.invMixColumn(word) + local b0 = util.getByte(word,3); + local b1 = util.getByte(word,2); + local b2 = util.getByte(word,1); + local b3 = util.getByte(word,0); + + local t = bit.bxor(b3,b2); + local u = bit.bxor(b1,b0); + local v = bit.bxor(t,u); + v = bit.bxor(v,gf.mul(0x08,v)); + w = bit.bxor(v,gf.mul(0x04, bit.bxor(b2,b0))); + v = bit.bxor(v,gf.mul(0x04, bit.bxor(b3,b1))); + + return util.putByte( bit.bxor(bit.bxor(b3,v), gf.mul(0x02, bit.bxor(b0,b3))), 0) + + util.putByte( bit.bxor(bit.bxor(b2,w), gf.mul(0x02, t )), 1) + + util.putByte( bit.bxor(bit.bxor(b1,v), gf.mul(0x02, bit.bxor(b0,b3))), 2) + + util.putByte( bit.bxor(bit.bxor(b0,w), gf.mul(0x02, u )), 3); +end + +-- +-- generate key schedule for aes decryption +-- +-- uses key schedule for aes encryption and transforms each +-- key by inverse mix column. +-- +function public.expandDecryptionKey(key) + local keySchedule = public.expandEncryptionKey(key); + if (keySchedule == nil) then + return nil; + end + + keySchedule[public.KEY_TYPE] = public.DECRYPTION_KEY; + + for i = 4, (keySchedule[public.ROUNDS] + 1)*4 - 5 do + keySchedule[i] = private.invMixColumnOld(keySchedule[i]); + end + + return keySchedule; +end + +-- +-- xor round key to state +-- +function private.addRoundKey(state, key, round) + for i = 0, 3 do + state[i] = bit.bxor(state[i], key[round*4+i]); + end +end + +-- +-- do encryption round (ShiftRow, SubBytes, MixColumn together) +-- +function private.doRound(origState, dstState) + dstState[0] = bit.bxor(bit.bxor(bit.bxor( + private.table0[util.getByte(origState[0],3)], + private.table1[util.getByte(origState[1],2)]), + private.table2[util.getByte(origState[2],1)]), + private.table3[util.getByte(origState[3],0)]); + + dstState[1] = bit.bxor(bit.bxor(bit.bxor( + private.table0[util.getByte(origState[1],3)], + private.table1[util.getByte(origState[2],2)]), + private.table2[util.getByte(origState[3],1)]), + private.table3[util.getByte(origState[0],0)]); + + dstState[2] = bit.bxor(bit.bxor(bit.bxor( + private.table0[util.getByte(origState[2],3)], + private.table1[util.getByte(origState[3],2)]), + private.table2[util.getByte(origState[0],1)]), + private.table3[util.getByte(origState[1],0)]); + + dstState[3] = bit.bxor(bit.bxor(bit.bxor( + private.table0[util.getByte(origState[3],3)], + private.table1[util.getByte(origState[0],2)]), + private.table2[util.getByte(origState[1],1)]), + private.table3[util.getByte(origState[2],0)]); +end + +-- +-- do last encryption round (ShiftRow and SubBytes) +-- +function private.doLastRound(origState, dstState) + dstState[0] = util.putByte(private.SBox[util.getByte(origState[0],3)], 3) + + util.putByte(private.SBox[util.getByte(origState[1],2)], 2) + + util.putByte(private.SBox[util.getByte(origState[2],1)], 1) + + util.putByte(private.SBox[util.getByte(origState[3],0)], 0); + + dstState[1] = util.putByte(private.SBox[util.getByte(origState[1],3)], 3) + + util.putByte(private.SBox[util.getByte(origState[2],2)], 2) + + util.putByte(private.SBox[util.getByte(origState[3],1)], 1) + + util.putByte(private.SBox[util.getByte(origState[0],0)], 0); + + dstState[2] = util.putByte(private.SBox[util.getByte(origState[2],3)], 3) + + util.putByte(private.SBox[util.getByte(origState[3],2)], 2) + + util.putByte(private.SBox[util.getByte(origState[0],1)], 1) + + util.putByte(private.SBox[util.getByte(origState[1],0)], 0); + + dstState[3] = util.putByte(private.SBox[util.getByte(origState[3],3)], 3) + + util.putByte(private.SBox[util.getByte(origState[0],2)], 2) + + util.putByte(private.SBox[util.getByte(origState[1],1)], 1) + + util.putByte(private.SBox[util.getByte(origState[2],0)], 0); +end + +-- +-- do decryption round +-- +function private.doInvRound(origState, dstState) + dstState[0] = bit.bxor(bit.bxor(bit.bxor( + private.tableInv0[util.getByte(origState[0],3)], + private.tableInv1[util.getByte(origState[3],2)]), + private.tableInv2[util.getByte(origState[2],1)]), + private.tableInv3[util.getByte(origState[1],0)]); + + dstState[1] = bit.bxor(bit.bxor(bit.bxor( + private.tableInv0[util.getByte(origState[1],3)], + private.tableInv1[util.getByte(origState[0],2)]), + private.tableInv2[util.getByte(origState[3],1)]), + private.tableInv3[util.getByte(origState[2],0)]); + + dstState[2] = bit.bxor(bit.bxor(bit.bxor( + private.tableInv0[util.getByte(origState[2],3)], + private.tableInv1[util.getByte(origState[1],2)]), + private.tableInv2[util.getByte(origState[0],1)]), + private.tableInv3[util.getByte(origState[3],0)]); + + dstState[3] = bit.bxor(bit.bxor(bit.bxor( + private.tableInv0[util.getByte(origState[3],3)], + private.tableInv1[util.getByte(origState[2],2)]), + private.tableInv2[util.getByte(origState[1],1)]), + private.tableInv3[util.getByte(origState[0],0)]); +end + +-- +-- do last decryption round +-- +function private.doInvLastRound(origState, dstState) + dstState[0] = util.putByte(private.iSBox[util.getByte(origState[0],3)], 3) + + util.putByte(private.iSBox[util.getByte(origState[3],2)], 2) + + util.putByte(private.iSBox[util.getByte(origState[2],1)], 1) + + util.putByte(private.iSBox[util.getByte(origState[1],0)], 0); + + dstState[1] = util.putByte(private.iSBox[util.getByte(origState[1],3)], 3) + + util.putByte(private.iSBox[util.getByte(origState[0],2)], 2) + + util.putByte(private.iSBox[util.getByte(origState[3],1)], 1) + + util.putByte(private.iSBox[util.getByte(origState[2],0)], 0); + + dstState[2] = util.putByte(private.iSBox[util.getByte(origState[2],3)], 3) + + util.putByte(private.iSBox[util.getByte(origState[1],2)], 2) + + util.putByte(private.iSBox[util.getByte(origState[0],1)], 1) + + util.putByte(private.iSBox[util.getByte(origState[3],0)], 0); + + dstState[3] = util.putByte(private.iSBox[util.getByte(origState[3],3)], 3) + + util.putByte(private.iSBox[util.getByte(origState[2],2)], 2) + + util.putByte(private.iSBox[util.getByte(origState[1],1)], 1) + + util.putByte(private.iSBox[util.getByte(origState[0],0)], 0); +end + +-- +-- encrypts 16 Bytes +-- key encryption key schedule +-- input array with input data +-- inputOffset start index for input +-- output array for encrypted data +-- outputOffset start index for output +-- +function public.encrypt(key, input, inputOffset, output, outputOffset) + --default parameters + inputOffset = inputOffset or 1; + output = output or {}; + outputOffset = outputOffset or 1; + + local state = {}; + local tmpState = {}; + + if (key[public.KEY_TYPE] ~= public.ENCRYPTION_KEY) then + print("No encryption key: ", key[public.KEY_TYPE]); + return; + end + + state = util.bytesToInts(input, inputOffset, 4); + private.addRoundKey(state, key, 0); + + local round = 1; + while (round < key[public.ROUNDS] - 1) do + -- do a double round to save temporary assignments + private.doRound(state, tmpState); + private.addRoundKey(tmpState, key, round); + round = round + 1; + + private.doRound(tmpState, state); + private.addRoundKey(state, key, round); + round = round + 1; + end + + private.doRound(state, tmpState); + private.addRoundKey(tmpState, key, round); + round = round +1; + + private.doLastRound(tmpState, state); + private.addRoundKey(state, key, round); + + return util.intsToBytes(state, output, outputOffset); +end + +-- +-- decrypt 16 bytes +-- key decryption key schedule +-- input array with input data +-- inputOffset start index for input +-- output array for decrypted data +-- outputOffset start index for output +--- +function public.decrypt(key, input, inputOffset, output, outputOffset) + -- default arguments + inputOffset = inputOffset or 1; + output = output or {}; + outputOffset = outputOffset or 1; + + local state = {}; + local tmpState = {}; + + if (key[public.KEY_TYPE] ~= public.DECRYPTION_KEY) then + print("No decryption key: ", key[public.KEY_TYPE]); + return; + end + + state = util.bytesToInts(input, inputOffset, 4); + private.addRoundKey(state, key, key[public.ROUNDS]); + + local round = key[public.ROUNDS] - 1; + while (round > 2) do + -- do a double round to save temporary assignments + private.doInvRound(state, tmpState); + private.addRoundKey(tmpState, key, round); + round = round - 1; + + private.doInvRound(tmpState, state); + private.addRoundKey(state, key, round); + round = round - 1; + end + + private.doInvRound(state, tmpState); + private.addRoundKey(tmpState, key, round); + round = round - 1; + + private.doInvLastRound(tmpState, state); + private.addRoundKey(state, key, round); + + return util.intsToBytes(state, output, outputOffset); +end + +-- calculate all tables when loading this file +private.calcSBox(); +private.calcRoundTables(); +private.calcInvRoundTables(); + +return public; \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/buffer.lua b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/buffer.lua new file mode 100644 index 0000000..306bbdc --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/buffer.lua @@ -0,0 +1,31 @@ +-- SPDX-License-Identifier: LGPL-2.1-or-later +-- Importé de https://github.com/exploiteers/Exploiteers-Wireshark-LoRa (meshtastic/aeslua/buffer.lua), +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025 (dernière modification du fichier : +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025). +-- Licence amont : LGPL-2.1-or-later (aeslua, © 2006-2007 Matthias Hilbig, meshtastic/aeslua/Copyright.txt) — voir README.md et LICENSE. +local public = {}; + +-- aeslua.buffer = public; + +function public.new () + return {}; +end + +function public.addString (stack, s) + table.insert(stack, s) + for i = #stack - 1, 1, -1 do + if #stack[i] > #stack[i+1] then + break; + end + stack[i] = stack[i] .. table.remove(stack); + end +end + +function public.toString (stack) + for i = #stack - 1, 1, -1 do + stack[i] = stack[i] .. table.remove(stack); + end + return stack[1]; +end + +return public; \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/ciphermode.lua b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/ciphermode.lua new file mode 100644 index 0000000..8f91590 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/ciphermode.lua @@ -0,0 +1,166 @@ +-- SPDX-License-Identifier: LGPL-2.1-or-later +-- Importé de https://github.com/exploiteers/Exploiteers-Wireshark-LoRa (meshtastic/aeslua/ciphermode.lua), +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025 (dernière modification du fichier : +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025). +-- Licence amont : LGPL-2.1-or-later (aeslua, © 2006-2007 Matthias Hilbig, meshtastic/aeslua/Copyright.txt) — voir README.md et LICENSE. +local aes = require("meshtastic.aeslua.aes"); +local util = require("meshtastic.aeslua.util"); +local buffer = require("meshtastic.aeslua.buffer"); + +local public = {}; + +-- aeslua.ciphermode = public; + +-- +-- Encrypt strings +-- key - byte array with key +-- string - string to encrypt +-- modefunction - function for cipher mode to use +-- +function public.encryptString(key, data, modeFunction) + local iv = iv or {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + local keySched = aes.expandEncryptionKey(key); + local encryptedData = buffer.new(); + + for i = 1, #data/16 do + local offset = (i-1)*16 + 1; + local byteData = {string.byte(data,offset,offset +15)}; + + modeFunction(keySched, byteData, iv); + + buffer.addString(encryptedData, string.char(table.unpack(byteData))); + end + + return buffer.toString(encryptedData); +end + +-- +-- the following 4 functions can be used as +-- modefunction for encryptString +-- + +-- Electronic code book mode encrypt function +function public.encryptECB(keySched, byteData, iv) + aes.encrypt(keySched, byteData, 1, byteData, 1); +end + +-- Cipher block chaining mode encrypt function +function public.encryptCBC(keySched, byteData, iv) + util.xorIV(byteData, iv); + + aes.encrypt(keySched, byteData, 1, byteData, 1); + + for j = 1,16 do + iv[j] = byteData[j]; + end +end + +-- Output feedback mode encrypt function +function public.encryptOFB(keySched, byteData, iv) + aes.encrypt(keySched, iv, 1, iv, 1); + util.xorIV(byteData, iv); +end + +-- Cipher feedback mode encrypt function +function public.encryptCFB(keySched, byteData, iv) + aes.encrypt(keySched, iv, 1, iv, 1); + util.xorIV(byteData, iv); + + for j = 1,16 do + iv[j] = byteData[j]; + end +end + +-- +-- Decrypt strings +-- key - byte array with key +-- string - string to decrypt +-- modefunction - function for cipher mode to use +-- iv - IV +-- +function public.decryptString(key, data, modeFunction, iv) + local keySched; + if (modeFunction == public.decryptOFB or modeFunction == public.decryptCFB or modeFunction == public.decryptCTR) then + keySched = aes.expandEncryptionKey(key); + else + keySched = aes.expandDecryptionKey(key); + end + + local decryptedData = buffer.new(); + + for i = 1, #data/16 do + local offset = (i-1)*16 + 1; + local byteData = {string.byte(data,offset,offset +15)}; + + iv = modeFunction(keySched, byteData, iv); + + buffer.addString(decryptedData, string.char(table.unpack(byteData))); + end + + return buffer.toString(decryptedData); +end + +-- +-- the following 4 functions can be used as +-- modefunction for decryptString +-- + +-- Electronic code book mode decrypt function +function public.decryptECB(keySched, byteData, iv) + + aes.decrypt(keySched, byteData, 1, byteData, 1); + + return iv; +end + +-- Cipher block chaining mode decrypt function +function public.decryptCBC(keySched, byteData, iv) + local nextIV = {}; + for j = 1,16 do + nextIV[j] = byteData[j]; + end + + aes.decrypt(keySched, byteData, 1, byteData, 1); + util.xorIV(byteData, iv); + + return nextIV; +end + +-- Output feedback mode decrypt function +function public.decryptOFB(keySched, byteData, iv) + aes.encrypt(keySched, iv, 1, iv, 1); + util.xorIV(byteData, iv); + + return iv; +end + +-- Cipher feedback mode decrypt function +function public.decryptCFB(keySched, byteData, iv) + local nextIV = {}; + for j = 1,16 do + nextIV[j] = byteData[j]; + end + + aes.encrypt(keySched, iv, 1, iv, 1); + + util.xorIV(byteData, iv); + + return nextIV; +end + +-- Counter mode decrypt function +function public.decryptCTR(keySched, byteData, iv) + local nextIV = {}; + for j = 1,16 do + nextIV[j] = iv[j]; + end + nextIV[#nextIV] = nextIV[#nextIV] + 1; + + aes.encrypt(keySched, iv, 1, iv, 1); + + util.xorIV(byteData, iv); + + return nextIV; +end + +return public; \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/gf.lua b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/gf.lua new file mode 100644 index 0000000..a0850ab --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/gf.lua @@ -0,0 +1,121 @@ +-- SPDX-License-Identifier: LGPL-2.1-or-later +-- Importé de https://github.com/exploiteers/Exploiteers-Wireshark-LoRa (meshtastic/aeslua/gf.lua), +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025 (dernière modification du fichier : +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025). +-- Licence amont : LGPL-2.1-or-later (aeslua, © 2006-2007 Matthias Hilbig, meshtastic/aeslua/Copyright.txt) — voir README.md et LICENSE. +-- require("bit"); + +-- finite field with base 2 and modulo irreducible polynom x^8+x^4+x^3+x+1 = 0x11d +local private = {}; +local public = {}; + +-- aeslua.gf = public; + +-- private data of gf +private.n = 0x100; +private.ord = 0xff; +private.irrPolynom = 0x11b; +private.exp = {}; +private.log = {}; + +-- +-- add two polynoms (its simply xor) +-- +function public.add(operand1, operand2) + return bit.bxor(operand1,operand2); +end + +-- +-- subtract two polynoms (same as addition) +-- +function public.sub(operand1, operand2) + return bit.bxor(operand1,operand2); +end + +-- +-- inverts element +-- a^(-1) = g^(order - log(a)) +-- +function public.invert(operand) + -- special case for 1 + if (operand == 1) then + return 1; + end; + -- normal invert + local exponent = private.ord - private.log[operand]; + return private.exp[exponent]; +end + +-- +-- multiply two elements using a logarithm table +-- a*b = g^(log(a)+log(b)) +-- +function public.mul(operand1, operand2) + if (operand1 == 0 or operand2 == 0) then + return 0; + end + + local exponent = private.log[operand1] + private.log[operand2]; + if (exponent >= private.ord) then + exponent = exponent - private.ord; + end + return private.exp[exponent]; +end + +-- +-- divide two elements +-- a/b = g^(log(a)-log(b)) +-- +function public.div(operand1, operand2) + if (operand1 == 0) then + return 0; + end + -- TODO: exception if operand2 == 0 + local exponent = private.log[operand1] - private.log[operand2]; + if (exponent < 0) then + exponent = exponent + private.ord; + end + return private.exp[exponent]; +end + +-- +-- print logarithmic table +-- +function public.printLog() + for i = 1, private.n do + print("log(", i-1, ")=", private.log[i-1]); + end +end + +-- +-- print exponentiation table +-- +function public.printExp() + for i = 1, private.n do + print("exp(", i-1, ")=", private.exp[i-1]); + end +end + +-- +-- calculate logarithmic and exponentiation table +-- +function private.initMulTable() + local a = 1; + + for i = 0,private.ord-1 do + private.exp[i] = a; + private.log[a] = i; + + -- multiply with generator x+1 -> left shift + 1 + a = bit.bxor(bit.lshift(a, 1), a); + + -- if a gets larger than order, reduce modulo irreducible polynom + if a > private.ord then + a = public.sub(a, private.irrPolynom); + end + end +end + +private.initMulTable(); + +return public; \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/util.lua b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/util.lua new file mode 100644 index 0000000..ca9f66a --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/aeslua/util.lua @@ -0,0 +1,159 @@ +-- SPDX-License-Identifier: LGPL-2.1-or-later +-- Importé de https://github.com/exploiteers/Exploiteers-Wireshark-LoRa (meshtastic/aeslua/util.lua), +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025 (dernière modification du fichier : +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025). +-- Licence amont : LGPL-2.1-or-later (aeslua, © 2006-2007 Matthias Hilbig, meshtastic/aeslua/Copyright.txt) — voir README.md et LICENSE. +-- require("bit"); + +local public = {}; +local private = {}; + +-- aeslua.util = public; + +-- +-- calculate the parity of one byte +-- +function public.byteParity(byte) + byte = bit.bxor(byte, bit.rshift(byte, 4)); + byte = bit.bxor(byte, bit.rshift(byte, 2)); + byte = bit.bxor(byte, bit.rshift(byte, 1)); + return bit.band(byte, 1); +end + +-- +-- get byte at position index +-- +function public.getByte(number, index) + if (index == 0) then + return bit.band(number,0xff); + else + return bit.band(bit.rshift(number, index*8),0xff); + end +end + + +-- +-- put number into int at position index +-- +function public.putByte(number, index) + if (index == 0) then + return bit.band(number,0xff); + else + return bit.lshift(bit.band(number,0xff),index*8); + end +end + +-- +-- convert byte array to int array +-- +function public.bytesToInts(bytes, start, n) + local ints = {}; + for i = 0, n - 1 do + ints[i] = public.putByte(bytes[start + (i*4) ], 3) + + public.putByte(bytes[start + (i*4) + 1], 2) + + public.putByte(bytes[start + (i*4) + 2], 1) + + public.putByte(bytes[start + (i*4) + 3], 0); + end + return ints; +end + +-- +-- convert int array to byte array +-- +function public.intsToBytes(ints, output, outputOffset, n) + n = n or #ints; + for i = 0, n do + for j = 0,3 do + output[outputOffset + i*4 + (3 - j)] = public.getByte(ints[i], j); + end + end + return output; +end + +-- +-- convert bytes to hexString +-- +function private.bytesToHex(bytes) + local hexBytes = ""; + + for i,byte in ipairs(bytes) do + hexBytes = hexBytes .. string.format("%02x ", byte); + end + + return hexBytes; +end + +-- +-- convert data to hex string +-- +function public.toHexString(data) + local type = type(data); + if (type == "number") then + return string.format("%08x",data); + elseif (type == "table") then + return private.bytesToHex(data); + elseif (type == "string") then + local bytes = {string.byte(data, 1, #data)}; + + return private.bytesToHex(bytes); + else + return data; + end +end + +function public.padByteString(data) + local dataLength = #data; + + local random1 = math.random(0,255); + local random2 = math.random(0,255); + + local prefix = string.char(random1, + random2, + random1, + random2, + public.getByte(dataLength, 3), + public.getByte(dataLength, 2), + public.getByte(dataLength, 1), + public.getByte(dataLength, 0)); + + data = prefix .. data; + + local paddingLength = math.ceil(#data/16)*16 - #data; + local padding = ""; + for i=1,paddingLength do + padding = padding .. string.char(math.random(0,255)); + end + + return data .. padding; +end + +function private.properlyDecrypted(data) + local random = {string.byte(data,1,4)}; + + if (random[1] == random[3] and random[2] == random[4]) then + return true; + end + + return false; +end + +function public.unpadByteString(data) + if (not private.properlyDecrypted(data)) then + return nil; + end + + local dataLength = public.putByte(string.byte(data,5), 3) + + public.putByte(string.byte(data,6), 2) + + public.putByte(string.byte(data,7), 1) + + public.putByte(string.byte(data,8), 0); + + return string.sub(data,9,8+dataLength); +end + +function public.xorIV(data, iv) + for i = 1,16 do + data[i] = bit.bxor(data[i], iv[i]); + end +end + +return public; \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/colorrules b/dissectors/meshtastic-exploiteers/src/meshtastic/colorrules new file mode 100644 index 0000000..d26ba9e --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/colorrules @@ -0,0 +1,2 @@ +# This file was created by Wireshark. Edit with care. +@Duplicate packets@meshtastic.duplicate@[48316,48316,48316][65535,65535,65535] diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/meshtastic.lua b/dissectors/meshtastic-exploiteers/src/meshtastic/meshtastic.lua new file mode 100644 index 0000000..d69c366 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/meshtastic.lua @@ -0,0 +1,335 @@ +-- SPDX-License-Identifier: GPL-3.0-only +-- Importé de https://github.com/exploiteers/Exploiteers-Wireshark-LoRa (meshtastic/meshtastic.lua), +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025 (dernière modification du fichier : +-- commit ad985742a2a5893fa9753b780b86d365dce0beb0 du 08/10/2025). +-- Licence amont : GPL-3.0 (LICENSE amont) — voir README.md et LICENSE. +-- Installation Instructions +-- +-- 1. Copy the meshtastic/ directory to the plugins/ directory of your "personal configuration folder". +-- See: https://www.wireshark.org/docs/wsug_html_chunked/ChAppFilesConfigurationSection.html +-- (you may need to create the plugins/ directory) +-- E.g. C:\Users\Dade\AppData\Roaming\Wireshark\plugins\meshtastic +-- 2. Open Wireshark. +-- 3. Edit > Preferences > Protocols > ProtoBuf +-- 4. Check "Load .proto files on startup." +-- 5. Check "Dissect protobuf fields as Wireshark fields." +-- 6. Click "Edit..." next to "Protobuf search paths". +-- 7. Add the plugins/meshtastic/protobuf/ directory. +-- 8. Check "Load all files" next to new entry. +-- 9. Save and close preferences. +-- 10. Open .pcap file. + +local info = { + version = "1.1", + author = "exploitee.rs", +}; +set_plugin_info(info); + +local ciphermode = require("meshtastic.aeslua.ciphermode"); +local protobuf_dissector = Dissector.get("protobuf"); +local ip_dissector = Dissector.get("ip"); +local names_table = {}; +local packets_table = {}; + + +local function get_crypto_key(key_base64_str) + -- From /meshtastic/firmware/src/mesh/Channels.cpp + local default_psk = { + 0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, + 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0x01 + }; + + local user_key = ByteArray.new(key_base64_str, true):base64_decode(); + + if user_key:len() == 0 then + -- Encryption disabled. + return {}; + elseif (user_key:len() == 1) then + -- Key is the default key with its last byte incremented by the user key. + local key = default_psk; + key[#key] = key[#key] + (user_key:int() - 1); + return key; + elseif (user_key:len() <= 16) then + local key = user_key; + key:set_size(16); + local key_table = {} + for i = 1, 16 do + key_table[i] = key:get_index(i - 1) + end + return key_table + elseif (user_key:len() <= 32) then + local key = user_key; + key:set_size(32); + local key_table = {} + for i = 1, 32 do + key_table[i] = key:get_index(i - 1) + end + return key_table + end + error("Error: Meshtastic channel key (set in Wireshark Preferences) is longer than 32 bytes") +end + + +local function get_crypto_iv(packet_id_range, from_range) + local iv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + for i = 1, 4 do + iv[i] = packet_id_range:bytes():get_index(i - 1); + iv[i + 8] = from_range:bytes():get_index(i - 1); + end + return iv; +end + + +-- Protocol for the outer packet. Invoked when the syncword in the LoRaTap header is 0x2b. +local proto_meshtastic = Proto.new("meshtastic", "Meshtastic"); +proto_meshtastic.prefs.crypto_key = Pref.string("Primary channel encryption key (base64)", "AQ=="); +local p = proto_meshtastic; +p.fields.to = ProtoField.uint32("meshtastic.to", "Destination node", base.HEX); +local f_to = Field.new("meshtastic.to"); +p.fields.from = ProtoField.uint32("meshtastic.from", "Sender node", base.HEX); +local f_from = Field.new("meshtastic.from"); +p.fields.id = ProtoField.uint32("meshtastic.id", "Packet ID", base.HEX); +p.fields.flags = ProtoField.uint8("meshtastic.flags", "Flags", base.HEX); +p.fields.hop_limit = ProtoField.uint8("meshtastic.flags.hop_limit", "Hop limit (remaining hops)", base.DEC, nil, 0x07); +p.fields.hop_start = ProtoField.uint8("meshtastic.flags.hop_start", "Hop limit (original)", base.DEC, nil, 0xE0); +p.fields.want_ack = ProtoField.bool("meshtastic.flags.want_ack", "ACK requested", 8, nil, 0x08); +p.fields.via_mqtt = ProtoField.bool("meshtastic.flags.via_mqtt", "Path included MQTT", 8, nil, 0x10); +p.fields.channel = ProtoField.uint8("meshtastic.channel_hash", "Channel hash", base.HEX); +p.fields.next_hop = ProtoField.uint8("meshtastic.next_hop", "Next hop node (unused)", base.HEX); +p.fields.relay_node = ProtoField.uint8("meshtastic.relay_node", "Relay node (unused)", base.HEX); +p.fields.payload = ProtoField.protocol("meshtastic.payload", "Payload", base.NONE); +p.fields.payload_decrypted = ProtoField.protocol("meshtastic.payload.decrypted", "Decrypted (using key in preferences)", base.NONE); +p.fields.portnum = ProtoField.int32("meshtastic.payload.portnum", "Portnum", base.DEC, { + [1]="TEXT_MESSAGE_APP", + [2]="REMOTE_HARDWARE_APP", + [3]="POSITION_APP", + [4]="NODEINFO_APP", + [5]="ROUTING_APP", + [6]="ADMIN_APP", + [7]="TEXT_MESSAGE_COMPRESSED_APP", + [8]="WAYPOINT_APP", + [9]="AUDIO_APP", + [10]="DETECTION_SENSOR_APP", + [32]="REPLY_APP", + [33]="IP_TUNNEL_APP", + [34]="PAXCOUNTER_APP", + [64]="SERIAL_APP", + [65]="STORE_FORWARD_APP", + [66]="RANGE_TEST_APP", + [67]="TELEMETRY_APP", + [68]="ZPS_APP", + [69]="SIMULATOR_APP", + [70]="TRACEROUTE_APP", + [71]="NEIGHBORINFO_APP", + [72]="ATAK_PLUGIN", + [73]="MAP_REPORT_APP", + [256]="PRIVATE_APP", + [257]="ATAK_FORWARDER", +}); +p.experts.malformed = ProtoExpert.new("meshtastic.malformed", "Invalid meshtastic.Data proto", expert.group.MALFORMED, expert.severity.ERROR); +p.experts.duplicate = ProtoExpert.new("meshtastic.duplicate", "Duplicate of an earlier packet", expert.group.PROTOCOL, expert.severity.NOTE); +-- Reuse this status field from eth so that built-in packet coloring rules for status will apply: +p.fields.status = ProtoField.uint8("eth.fcs.status", "Status"); + + +-- Sub-protocol for the payload, chained to the protobuf dissector, which is invoked by the outer protocol. +local proto_meshtastic_payload = Proto.new("meshtastic_data_payload", "meshtastic_data_payload"); +proto_meshtastic_payload.fields.text = ProtoField.string("meshtastic.payload.text", "Text message", base.UNICODE); +-- The protobuf dissector only defines its fields after it has already run. To +-- avoid undefined field errors, create placeholder fields with the same types +-- that will be overwritten later by the protobuf dissector. These Fields will +-- actually read data created by the protobuf dissector, not proto_meshtastic. +proto_meshtastic_payload.fields._dontuse1 = ProtoField.int32("pbf.meshtastic.Data.portnum", "portnum", base.DEC); +local f_proto_meshtastic_Data_portnum = Field.new("pbf.meshtastic.Data.portnum"); +proto_meshtastic_payload.fields._dontuse2 = ProtoField.string("pbf.meshtastic.User.long_name", "long_name", base.NONE); +local f_proto_meshtastic_User_long_name = Field.new("pbf.meshtastic.User.long_name"); + + +-- Protocol to hold a sub-dissector that relabels packets with source/destination node names +-- collected from NODEINFO messages. +local proto_post_names = Proto.new("meshtastic_names", "meshtastic_names"); +function proto_post_names.dissector(tvb, pinfo, treeitem) + local src_name = names_table[tostring(pinfo.cols.src)]; + if src_name ~= nil then + pinfo.cols.src:append(" (" .. src_name .. ")"); + end + local dst_name = names_table[tostring(pinfo.cols.dst)]; + if dst_name ~= nil then + pinfo.cols.dst:append(" (" .. dst_name .. ")"); + end +end +register_postdissector(proto_post_names); + + +function proto_meshtastic.init() + names_table = {}; + packets_table = {}; +end + + +function proto_meshtastic.dissector(tvb, pinfo, treeitem) + pinfo.cols.protocol:set('Meshtastic'); + + local subtree = treeitem:add(proto_meshtastic, tvb()); + local pos = 0; + + -- To + subtree:add_le(p.fields.to, tvb(pos, 4)); + pos = pos + 4; + pinfo.cols.dst:set(f_to().display); + if f_to().value == 0xffffffff then + pinfo.cols.dst:append(' (broadcast)'); + end + + -- From + local from_range = tvb(pos, 4); + subtree:add_le(p.fields.from, from_range); + pos = pos + 4; + pinfo.cols.src:set(f_from().display); + + -- Packet ID + local packet_id_range = tvb(pos, 4); + subtree:add_le(p.fields.id, packet_id_range); + local idstr = packet_id_range:bytes():tohex(); + if packets_table[idstr] == nil then + packets_table[idstr] = pinfo.number; + else + -- A packet with the same ID was found in a different frame. + local is_dup = packets_table[idstr] ~= pinfo.number; + if is_dup then subtree:add_proto_expert_info(p.experts.duplicate) end; + end + pos = pos + 4; + + -- Header fields (hops, ack, mqtt) + local flag_byte = tvb(pos, 1); + pos = pos + 1; + local flags = subtree:add(p.fields.flags, flag_byte) + flags:add(p.fields.hop_limit, flag_byte); + flags:add(p.fields.hop_start, flag_byte); + flags:add(p.fields.want_ack, flag_byte); + flags:add(p.fields.via_mqtt, flag_byte); + + -- Channel hash + subtree:add(p.fields.channel, tvb(pos, 1)); + pos = pos + 1; + + -- (Unused) next hop + subtree:add(p.fields.next_hop, tvb(pos, 1)); + pos = pos + 1; + + -- (Unused) relay node + subtree:add(p.fields.relay_node, tvb(pos, 1)); + pos = pos + 1; + + -- Encrypted payload bytes + local payload_tvb = tvb(pos); + local payload_tree = subtree:add(p.fields.payload, payload_tvb); + payload_tree:set_text("Payload: " .. payload_tvb:len() .. " bytes"); + + -- Decrypted payload (meshtastic.Data protobuf) + local protobuf_tree; + local protobuf_tvb; + local data_bytearray = tvb(pos):bytes(); + local data_size = data_bytearray:len(); + data_bytearray:set_size(256); -- Zero-pad before decrypting. + local key = get_crypto_key(proto_meshtastic.prefs.crypto_key); + if #key > 0 then + local iv = get_crypto_iv(packet_id_range, from_range); + local decrypted = string.sub(ciphermode.decryptString(key, data_bytearray:raw(), ciphermode.decryptCTR, iv), 1, data_size); + protobuf_tvb = ByteArray.new(decrypted, true):tvb("Decrypted payload"); + protobuf_tree = payload_tree:add(p.fields.payload_decrypted, protobuf_tvb()); + else + -- Channel doesn't have a decryption key, skip decryption. + protobuf_tvb = payload_tvb; + protobuf_tree = payload_tree; + end + pinfo.private["pb_msg_type"] = "message,meshtastic.Data"; + -- Call protobuf dissector, including proto_meshtastic_payload on the "payload" bytes field of the protobuf. + pcall(Dissector.call, protobuf_dissector, protobuf_tvb, pinfo, protobuf_tree); + + -- Portnum (field decoded by proto_meshtastic_payload) + local portnum = f_proto_meshtastic_Data_portnum(); + if portnum ~= nil then + subtree:add(p.fields.portnum, portnum.value); + pinfo.cols.dst_port = portnum.value; + else + protobuf_tree:add_tvb_expert_info(p.experts.malformed, protobuf_tvb); + protobuf_tree:add(p.fields.status, 0):set_hidden(true); + pinfo.cols.info:set("Malformed meshtastic.Data protobuf"); + end + + return pos +end +DissectorTable.get("loratap.syncword"):add(0x2b, proto_meshtastic); + + +function call_protobuf(msg_name, tvb, pinfo, treeitem) + pinfo.private["pb_msg_type"] = "message," .. msg_name; + pcall(Dissector.call, protobuf_dissector, tvb, pinfo, treeitem); +end + + +function proto_meshtastic_payload.dissector(tvb, pinfo, treeitem) + local portnum = f_proto_meshtastic_Data_portnum().value; + pinfo.cols.info:set("[" .. string.match(f_proto_meshtastic_Data_portnum().display, "[a-zA-Z0-9_]*") .. "]"); + + if portnum == 1 then + treeitem:add(proto_meshtastic_payload.fields.text, tvb()); + pinfo.cols.info:set("Text message: \"" .. tvb():string(ENC_UTF_8) .. "\""); + elseif portnum == 4 then + call_protobuf("meshtastic.User", tvb, pinfo, treeitem); + pinfo.cols.info:clear(); + pinfo.cols.info:set(f_from().display .. " is \"" .. f_proto_meshtastic_User_long_name().value .. "\""); + pinfo.cols.info:fence(); -- This doesn't seem to work (Protobuf dissector appends junk), but at least we tried... + names_table[tostring(pinfo.cols.src)] = f_proto_meshtastic_User_long_name().value; + elseif portnum == 2 then + call_protobuf("meshtastic.HardwareMessage", tvb, pinfo, treeitem); + elseif portnum == 3 then + call_protobuf("meshtastic.Position", tvb, pinfo, treeitem); + elseif portnum == 5 then + call_protobuf("meshtastic.Routing", tvb, pinfo, treeitem); + elseif portnum == 6 then + call_protobuf("meshtastic.AdminMessage", tvb, pinfo, treeitem); + elseif portnum == 7 then + treeitem:add("(unishox2 compressed data)"); + elseif portnum == 8 then + call_protobuf("meshtastic.Waypoint", tvb, pinfo, treeitem); + elseif portnum == 9 then + treeitem:set_text("(codec2 audio frames)"); + elseif portnum == 10 then + treeitem:add(proto_meshtastic_payload.fields.text, tvb()); + elseif portnum == 32 then + treeitem:add(proto_meshtastic_payload.fields.text, tvb()); + elseif portnum == 33 then + -- TODO: Untested. IP traffic tunneled over mesh using https://github.com/meshtastic/python/. + pcall(Dissector.call, ip_dissector, tvb, pinfo, treeitem); + elseif portnum == 34 then + call_protobuf("meshtastic.Paxcount", tvb, pinfo, treeitem); + elseif portnum == 64 then + treeitem:set_text("(binary data)"); + elseif portnum == 65 then + call_protobuf("meshtastic.StoreAndForward", tvb, pinfo, treeitem); + elseif portnum == 66 then + treeitem:add(proto_meshtastic_payload.fields.text, tvb()); + elseif portnum == 67 then + call_protobuf("meshtastic.Telemetry", tvb, pinfo, treeitem); + elseif portnum == 68 then + treeitem:set_text("(https://github.com/a-f-G-U-C/Meshtastic-ZPS?tab=readme-ov-file#message-format-details)"); + elseif portnum == 69 then + -- Simulator use. Not sure what's in it but seems unlikely to actually be broadcast. + elseif portnum == 70 then + call_protobuf("meshtastic.RouteDiscovery", tvb, pinfo, treeitem); + elseif portnum == 71 then + call_protobuf("meshtastic.NeighborInfo", tvb, pinfo, treeitem); + elseif portnum == 72 then + call_protobuf("meshtastic.TAKPacket", tvb, pinfo, treeitem); + elseif portnum == 73 then + call_protobuf("meshtastic.MapReport", tvb, pinfo, treeitem); + elseif portnum == 257 then + treeitem:set_text("(https://github.com/paulmandal/libcotshrink)"); + elseif portnum >= 256 then + treeitem:set_text("(PRIVATE_APP data)"); + end +end +DissectorTable.get("protobuf_field"):add("meshtastic.Data.payload", proto_meshtastic_payload.dissector); + diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/google/protobuf/descriptor.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/google/protobuf/descriptor.proto new file mode 100644 index 0000000..04cddf5 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/google/protobuf/descriptor.proto @@ -0,0 +1,1296 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// The messages in this file describe the definitions found in .proto files. +// A valid .proto file can be translated directly to a FileDescriptorProto +// without any other information (e.g. without reading its imports). + +syntax = "proto2"; + +package google.protobuf; + +option go_package = "google.golang.org/protobuf/types/descriptorpb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "DescriptorProtos"; +option csharp_namespace = "Google.Protobuf.Reflection"; +option objc_class_prefix = "GPB"; +option cc_enable_arenas = true; + +// descriptor.proto must be optimized for speed because reflection-based +// algorithms don't work during bootstrapping. +option optimize_for = SPEED; + +// The protocol compiler can output a FileDescriptorSet containing the .proto +// files it parses. +message FileDescriptorSet { + repeated FileDescriptorProto file = 1; +} + +// The full set of known editions. +enum Edition { + // A placeholder for an unknown edition value. + EDITION_UNKNOWN = 0; + + // A placeholder edition for specifying default behaviors *before* a feature + // was first introduced. This is effectively an "infinite past". + EDITION_LEGACY = 900; + + // Legacy syntax "editions". These pre-date editions, but behave much like + // distinct editions. These can't be used to specify the edition of proto + // files, but feature definitions must supply proto2/proto3 defaults for + // backwards compatibility. + EDITION_PROTO2 = 998; + EDITION_PROTO3 = 999; + + // Editions that have been released. The specific values are arbitrary and + // should not be depended on, but they will always be time-ordered for easy + // comparison. + EDITION_2023 = 1000; + EDITION_2024 = 1001; + + // Placeholder editions for testing feature resolution. These should not be + // used or relyed on outside of tests. + EDITION_1_TEST_ONLY = 1; + EDITION_2_TEST_ONLY = 2; + EDITION_99997_TEST_ONLY = 99997; + EDITION_99998_TEST_ONLY = 99998; + EDITION_99999_TEST_ONLY = 99999; + + // Placeholder for specifying unbounded edition support. This should only + // ever be used by plugins that can expect to never require any changes to + // support a new edition. + EDITION_MAX = 0x7FFFFFFF; +} + +// Describes a complete .proto file. +message FileDescriptorProto { + optional string name = 1; // file name, relative to root of source tree + optional string package = 2; // e.g. "foo", "foo.bar", etc. + + // Names of files imported by this file. + repeated string dependency = 3; + // Indexes of the public imported files in the dependency list above. + repeated int32 public_dependency = 10; + // Indexes of the weak imported files in the dependency list. + // For Google-internal migration only. Do not use. + repeated int32 weak_dependency = 11; + + // All top-level definitions in this file. + repeated DescriptorProto message_type = 4; + repeated EnumDescriptorProto enum_type = 5; + repeated ServiceDescriptorProto service = 6; + repeated FieldDescriptorProto extension = 7; + + optional FileOptions options = 8; + + // This field contains optional information about the original source code. + // You may safely remove this entire field without harming runtime + // functionality of the descriptors -- the information is needed only by + // development tools. + optional SourceCodeInfo source_code_info = 9; + + // The syntax of the proto file. + // The supported values are "proto2", "proto3", and "editions". + // + // If `edition` is present, this value must be "editions". + optional string syntax = 12; + + // The edition of the proto file. + optional Edition edition = 14; +} + +// Describes a message type. +message DescriptorProto { + optional string name = 1; + + repeated FieldDescriptorProto field = 2; + repeated FieldDescriptorProto extension = 6; + + repeated DescriptorProto nested_type = 3; + repeated EnumDescriptorProto enum_type = 4; + + message ExtensionRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Exclusive. + + optional ExtensionRangeOptions options = 3; + } + repeated ExtensionRange extension_range = 5; + + repeated OneofDescriptorProto oneof_decl = 8; + + optional MessageOptions options = 7; + + // Range of reserved tag numbers. Reserved tag numbers may not be used by + // fields or extension ranges in the same message. Reserved ranges may + // not overlap. + message ReservedRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Exclusive. + } + repeated ReservedRange reserved_range = 9; + // Reserved field names, which may not be used by fields in the same message. + // A given name may only be reserved once. + repeated string reserved_name = 10; +} + +message ExtensionRangeOptions { + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + message Declaration { + // The extension number declared within the extension range. + optional int32 number = 1; + + // The fully-qualified name of the extension field. There must be a leading + // dot in front of the full name. + optional string full_name = 2; + + // The fully-qualified type name of the extension field. Unlike + // Metadata.type, Declaration.type must have a leading dot for messages + // and enums. + optional string type = 3; + + // If true, indicates that the number is reserved in the extension range, + // and any extension field with the number will fail to compile. Set this + // when a declared extension field is deleted. + optional bool reserved = 5; + + // If true, indicates that the extension must be defined as repeated. + // Otherwise the extension must be defined as optional. + optional bool repeated = 6; + + reserved 4; // removed is_repeated + } + + // For external users: DO NOT USE. We are in the process of open sourcing + // extension declaration and executing internal cleanups before it can be + // used externally. + repeated Declaration declaration = 2 [retention = RETENTION_SOURCE]; + + // Any features defined in the specific edition. + optional FeatureSet features = 50; + + // The verification state of the extension range. + enum VerificationState { + // All the extensions of the range must be declared. + DECLARATION = 0; + UNVERIFIED = 1; + } + + // The verification state of the range. + // TODO: flip the default to DECLARATION once all empty ranges + // are marked as UNVERIFIED. + optional VerificationState verification = 3 + [default = UNVERIFIED, retention = RETENTION_SOURCE]; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +// Describes a field within a message. +message FieldDescriptorProto { + enum Type { + // 0 is reserved for errors. + // Order is weird for historical reasons. + TYPE_DOUBLE = 1; + TYPE_FLOAT = 2; + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + // negative values are likely. + TYPE_INT64 = 3; + TYPE_UINT64 = 4; + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + // negative values are likely. + TYPE_INT32 = 5; + TYPE_FIXED64 = 6; + TYPE_FIXED32 = 7; + TYPE_BOOL = 8; + TYPE_STRING = 9; + // Tag-delimited aggregate. + // Group type is deprecated and not supported after google.protobuf. However, Proto3 + // implementations should still be able to parse the group wire format and + // treat group fields as unknown fields. In Editions, the group wire format + // can be enabled via the `message_encoding` feature. + TYPE_GROUP = 10; + TYPE_MESSAGE = 11; // Length-delimited aggregate. + + // New in version 2. + TYPE_BYTES = 12; + TYPE_UINT32 = 13; + TYPE_ENUM = 14; + TYPE_SFIXED32 = 15; + TYPE_SFIXED64 = 16; + TYPE_SINT32 = 17; // Uses ZigZag encoding. + TYPE_SINT64 = 18; // Uses ZigZag encoding. + } + + enum Label { + // 0 is reserved for errors + LABEL_OPTIONAL = 1; + LABEL_REPEATED = 3; + // The required label is only allowed in google.protobuf. In proto3 and Editions + // it's explicitly prohibited. In Editions, the `field_presence` feature + // can be used to get this behavior. + LABEL_REQUIRED = 2; + } + + optional string name = 1; + optional int32 number = 3; + optional Label label = 4; + + // If type_name is set, this need not be set. If both this and type_name + // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + optional Type type = 5; + + // For message and enum types, this is the name of the type. If the name + // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + // rules are used to find the type (i.e. first the nested types within this + // message are searched, then within the parent, on up to the root + // namespace). + optional string type_name = 6; + + // For extensions, this is the name of the type being extended. It is + // resolved in the same manner as type_name. + optional string extendee = 2; + + // For numeric types, contains the original text representation of the value. + // For booleans, "true" or "false". + // For strings, contains the default text contents (not escaped in any way). + // For bytes, contains the C escaped value. All bytes >= 128 are escaped. + optional string default_value = 7; + + // If set, gives the index of a oneof in the containing type's oneof_decl + // list. This field is a member of that oneof. + optional int32 oneof_index = 9; + + // JSON name of this field. The value is set by protocol compiler. If the + // user has set a "json_name" option on this field, that option's value + // will be used. Otherwise, it's deduced from the field's name by converting + // it to camelCase. + optional string json_name = 10; + + optional FieldOptions options = 8; + + // If true, this is a proto3 "optional". When a proto3 field is optional, it + // tracks presence regardless of field type. + // + // When proto3_optional is true, this field must belong to a oneof to signal + // to old proto3 clients that presence is tracked for this field. This oneof + // is known as a "synthetic" oneof, and this field must be its sole member + // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs + // exist in the descriptor only, and do not generate any API. Synthetic oneofs + // must be ordered after all "real" oneofs. + // + // For message fields, proto3_optional doesn't create any semantic change, + // since non-repeated message fields always track presence. However it still + // indicates the semantic detail of whether the user wrote "optional" or not. + // This can be useful for round-tripping the .proto file. For consistency we + // give message fields a synthetic oneof also, even though it is not required + // to track presence. This is especially important because the parser can't + // tell if a field is a message or an enum, so it must always create a + // synthetic oneof. + // + // Proto2 optional fields do not set this flag, because they already indicate + // optional with `LABEL_OPTIONAL`. + optional bool proto3_optional = 17; +} + +// Describes a oneof. +message OneofDescriptorProto { + optional string name = 1; + optional OneofOptions options = 2; +} + +// Describes an enum type. +message EnumDescriptorProto { + optional string name = 1; + + repeated EnumValueDescriptorProto value = 2; + + optional EnumOptions options = 3; + + // Range of reserved numeric values. Reserved values may not be used by + // entries in the same enum. Reserved ranges may not overlap. + // + // Note that this is distinct from DescriptorProto.ReservedRange in that it + // is inclusive such that it can appropriately represent the entire int32 + // domain. + message EnumReservedRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Inclusive. + } + + // Range of reserved numeric values. Reserved numeric values may not be used + // by enum values in the same enum declaration. Reserved ranges may not + // overlap. + repeated EnumReservedRange reserved_range = 4; + + // Reserved enum value names, which may not be reused. A given name may only + // be reserved once. + repeated string reserved_name = 5; +} + +// Describes a value within an enum. +message EnumValueDescriptorProto { + optional string name = 1; + optional int32 number = 2; + + optional EnumValueOptions options = 3; +} + +// Describes a service. +message ServiceDescriptorProto { + optional string name = 1; + repeated MethodDescriptorProto method = 2; + + optional ServiceOptions options = 3; +} + +// Describes a method of a service. +message MethodDescriptorProto { + optional string name = 1; + + // Input and output type names. These are resolved in the same way as + // FieldDescriptorProto.type_name, but must refer to a message type. + optional string input_type = 2; + optional string output_type = 3; + + optional MethodOptions options = 4; + + // Identifies if client streams multiple client messages + optional bool client_streaming = 5 [default = false]; + // Identifies if server streams multiple server messages + optional bool server_streaming = 6 [default = false]; +} + +// =================================================================== +// Options + +// Each of the definitions above may have "options" attached. These are +// just annotations which may cause code to be generated slightly differently +// or may contain hints for code that manipulates protocol messages. +// +// Clients may define custom options as extensions of the *Options messages. +// These extensions may not yet be known at parsing time, so the parser cannot +// store the values in them. Instead it stores them in a field in the *Options +// message called uninterpreted_option. This field must have the same name +// across all *Options messages. We then use this field to populate the +// extensions when we build a descriptor, at which point all protos have been +// parsed and so all extensions are known. +// +// Extension numbers for custom options may be chosen as follows: +// * For options which will only be used within a single application or +// organization, or for experimental options, use field numbers 50000 +// through 99999. It is up to you to ensure that you do not use the +// same number for multiple options. +// * For options which will be published and used publicly by multiple +// independent entities, e-mail protobuf-global-extension-registry@google.com +// to reserve extension numbers. Simply provide your project name (e.g. +// Objective-C plugin) and your project website (if available) -- there's no +// need to explain how you intend to use them. Usually you only need one +// extension number. You can declare multiple options with only one extension +// number by putting them in a sub-message. See the Custom Options section of +// the docs for examples: +// https://developers.google.com/protocol-buffers/docs/proto#options +// If this turns out to be popular, a web service will be set up +// to automatically assign option numbers. + +message FileOptions { + + // Sets the Java package where classes generated from this .proto will be + // placed. By default, the proto package is used, but this is often + // inappropriate because proto packages do not normally start with backwards + // domain names. + optional string java_package = 1; + + // Controls the name of the wrapper Java class generated for the .proto file. + // That class will always contain the .proto file's getDescriptor() method as + // well as any top-level extensions defined in the .proto file. + // If java_multiple_files is disabled, then all the other classes from the + // .proto file will be nested inside the single wrapper outer class. + optional string java_outer_classname = 8; + + // If enabled, then the Java code generator will generate a separate .java + // file for each top-level message, enum, and service defined in the .proto + // file. Thus, these types will *not* be nested inside the wrapper class + // named by java_outer_classname. However, the wrapper class will still be + // generated to contain the file's getDescriptor() method as well as any + // top-level extensions defined in the file. + optional bool java_multiple_files = 10 [default = false]; + + // This option does nothing. + optional bool java_generate_equals_and_hash = 20 [deprecated=true]; + + // A proto2 file can set this to true to opt in to UTF-8 checking for Java, + // which will throw an exception if invalid UTF-8 is parsed from the wire or + // assigned to a string field. + // + // TODO: clarify exactly what kinds of field types this option + // applies to, and update these docs accordingly. + // + // Proto3 files already perform these checks. Setting the option explicitly to + // false has no effect: it cannot be used to opt proto3 files out of UTF-8 + // checks. + optional bool java_string_check_utf8 = 27 [default = false]; + + // Generated classes can be optimized for speed or code size. + enum OptimizeMode { + SPEED = 1; // Generate complete code for parsing, serialization, + // etc. + CODE_SIZE = 2; // Use ReflectionOps to implement these methods. + LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. + } + optional OptimizeMode optimize_for = 9 [default = SPEED]; + + // Sets the Go package where structs generated from this .proto will be + // placed. If omitted, the Go package will be derived from the following: + // - The basename of the package import path, if provided. + // - Otherwise, the package statement in the .proto file, if present. + // - Otherwise, the basename of the .proto file, without extension. + optional string go_package = 11; + + // Should generic services be generated in each language? "Generic" services + // are not specific to any particular RPC system. They are generated by the + // main code generators in each language (without additional plugins). + // Generic services were the only kind of service generation supported by + // early versions of google.protobuf. + // + // Generic services are now considered deprecated in favor of using plugins + // that generate code specific to your particular RPC system. Therefore, + // these default to false. Old code which depends on generic services should + // explicitly set them to true. + optional bool cc_generic_services = 16 [default = false]; + optional bool java_generic_services = 17 [default = false]; + optional bool py_generic_services = 18 [default = false]; + reserved 42; // removed php_generic_services + reserved "php_generic_services"; + + // Is this file deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for everything in the file, or it will be completely ignored; in the very + // least, this is a formalization for deprecating files. + optional bool deprecated = 23 [default = false]; + + // Enables the use of arenas for the proto messages in this file. This applies + // only to generated classes for C++. + optional bool cc_enable_arenas = 31 [default = true]; + + // Sets the objective c class prefix which is prepended to all objective c + // generated classes from this .proto. There is no default. + optional string objc_class_prefix = 36; + + // Namespace for generated classes; defaults to the package. + optional string csharp_namespace = 37; + + // By default Swift generators will take the proto package and CamelCase it + // replacing '.' with underscore and use that to prefix the types/symbols + // defined. When this options is provided, they will use this value instead + // to prefix the types/symbols defined. + optional string swift_prefix = 39; + + // Sets the php class prefix which is prepended to all php generated classes + // from this .proto. Default is empty. + optional string php_class_prefix = 40; + + // Use this option to change the namespace of php generated classes. Default + // is empty. When this option is empty, the package name will be used for + // determining the namespace. + optional string php_namespace = 41; + + // Use this option to change the namespace of php generated metadata classes. + // Default is empty. When this option is empty, the proto file name will be + // used for determining the namespace. + optional string php_metadata_namespace = 44; + + // Use this option to change the package of ruby generated classes. Default + // is empty. When this option is not set, the package name will be used for + // determining the ruby package. + optional string ruby_package = 45; + + // Any features defined in the specific edition. + optional FeatureSet features = 50; + + // The parser stores options it doesn't recognize here. + // See the documentation for the "Options" section above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. + // See the documentation for the "Options" section above. + extensions 1000 to max; + + reserved 38; +} + +message MessageOptions { + // Set true to use the old proto1 MessageSet wire format for extensions. + // This is provided for backwards-compatibility with the MessageSet wire + // format. You should not use this for any other reason: It's less + // efficient, has fewer features, and is more complicated. + // + // The message must be defined exactly as follows: + // message Foo { + // option message_set_wire_format = true; + // extensions 4 to max; + // } + // Note that the message cannot have any defined fields; MessageSets only + // have extensions. + // + // All extensions of your type must be singular messages; e.g. they cannot + // be int32s, enums, or repeated messages. + // + // Because this is an option, the above two restrictions are not enforced by + // the protocol compiler. + optional bool message_set_wire_format = 1 [default = false]; + + // Disables the generation of the standard "descriptor()" accessor, which can + // conflict with a field of the same name. This is meant to make migration + // from proto1 easier; new code should avoid fields named "descriptor". + optional bool no_standard_descriptor_accessor = 2 [default = false]; + + // Is this message deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the message, or it will be completely ignored; in the very least, + // this is a formalization for deprecating messages. + optional bool deprecated = 3 [default = false]; + + reserved 4, 5, 6; + + // Whether the message is an automatically generated map entry type for the + // maps field. + // + // For maps fields: + // map map_field = 1; + // The parsed descriptor looks like: + // message MapFieldEntry { + // option map_entry = true; + // optional KeyType key = 1; + // optional ValueType value = 2; + // } + // repeated MapFieldEntry map_field = 1; + // + // Implementations may choose not to generate the map_entry=true message, but + // use a native map in the target language to hold the keys and values. + // The reflection APIs in such implementations still need to work as + // if the field is a repeated message field. + // + // NOTE: Do not set the option in .proto files. Always use the maps syntax + // instead. The option should only be implicitly set by the proto compiler + // parser. + optional bool map_entry = 7; + + reserved 8; // javalite_serializable + reserved 9; // javanano_as_lite + + // Enable the legacy handling of JSON field name conflicts. This lowercases + // and strips underscored from the fields before comparison in proto3 only. + // The new behavior takes `json_name` into account and applies to proto2 as + // well. + // + // This should only be used as a temporary measure against broken builds due + // to the change in behavior for JSON field name conflicts. + // + // TODO This is legacy behavior we plan to remove once downstream + // teams have had time to migrate. + optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true]; + + // Any features defined in the specific edition. + optional FeatureSet features = 12; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message FieldOptions { + // NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead. + // The ctype option instructs the C++ code generator to use a different + // representation of the field than it normally would. See the specific + // options below. This option is only implemented to support use of + // [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of + // type "bytes" in the open source release. + // TODO: make ctype actually deprecated. + optional CType ctype = 1 [/*deprecated = true,*/ default = STRING]; + enum CType { + // Default mode. + STRING = 0; + + // The option [ctype=CORD] may be applied to a non-repeated field of type + // "bytes". It indicates that in C++, the data should be stored in a Cord + // instead of a string. For very large strings, this may reduce memory + // fragmentation. It may also allow better performance when parsing from a + // Cord, or when parsing with aliasing enabled, as the parsed Cord may then + // alias the original buffer. + CORD = 1; + + STRING_PIECE = 2; + } + // The packed option can be enabled for repeated primitive fields to enable + // a more efficient representation on the wire. Rather than repeatedly + // writing the tag and type for each element, the entire array is encoded as + // a single length-delimited blob. In proto3, only explicit setting it to + // false will avoid using packed encoding. This option is prohibited in + // Editions, but the `repeated_field_encoding` feature can be used to control + // the behavior. + optional bool packed = 2; + + // The jstype option determines the JavaScript type used for values of the + // field. The option is permitted only for 64 bit integral and fixed types + // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + // is represented as JavaScript string, which avoids loss of precision that + // can happen when a large value is converted to a floating point JavaScript. + // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + // use the JavaScript "number" type. The behavior of the default option + // JS_NORMAL is implementation dependent. + // + // This option is an enum to permit additional types to be added, e.g. + // goog.math.Integer. + optional JSType jstype = 6 [default = JS_NORMAL]; + enum JSType { + // Use the default type. + JS_NORMAL = 0; + + // Use JavaScript strings. + JS_STRING = 1; + + // Use JavaScript numbers. + JS_NUMBER = 2; + } + + // Should this field be parsed lazily? Lazy applies only to message-type + // fields. It means that when the outer message is initially parsed, the + // inner message's contents will not be parsed but instead stored in encoded + // form. The inner message will actually be parsed when it is first accessed. + // + // This is only a hint. Implementations are free to choose whether to use + // eager or lazy parsing regardless of the value of this option. However, + // setting this option true suggests that the protocol author believes that + // using lazy parsing on this field is worth the additional bookkeeping + // overhead typically needed to implement it. + // + // This option does not affect the public interface of any generated code; + // all method signatures remain the same. Furthermore, thread-safety of the + // interface is not affected by this option; const methods remain safe to + // call from multiple threads concurrently, while non-const methods continue + // to require exclusive access. + // + // Note that lazy message fields are still eagerly verified to check + // ill-formed wireformat or missing required fields. Calling IsInitialized() + // on the outer message would fail if the inner message has missing required + // fields. Failed verification would result in parsing failure (except when + // uninitialized messages are acceptable). + optional bool lazy = 5 [default = false]; + + // unverified_lazy does no correctness checks on the byte stream. This should + // only be used where lazy with verification is prohibitive for performance + // reasons. + optional bool unverified_lazy = 15 [default = false]; + + // Is this field deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for accessors, or it will be completely ignored; in the very least, this + // is a formalization for deprecating fields. + optional bool deprecated = 3 [default = false]; + + // For Google-internal migration only. Do not use. + optional bool weak = 10 [default = false]; + + // Indicate that the field value should not be printed out when using debug + // formats, e.g. when the field contains sensitive credentials. + optional bool debug_redact = 16 [default = false]; + + // If set to RETENTION_SOURCE, the option will be omitted from the binary. + // Note: as of January 2023, support for this is in progress and does not yet + // have an effect (b/264593489). + enum OptionRetention { + RETENTION_UNKNOWN = 0; + RETENTION_RUNTIME = 1; + RETENTION_SOURCE = 2; + } + + optional OptionRetention retention = 17; + + // This indicates the types of entities that the field may apply to when used + // as an option. If it is unset, then the field may be freely used as an + // option on any kind of entity. Note: as of January 2023, support for this is + // in progress and does not yet have an effect (b/264593489). + enum OptionTargetType { + TARGET_TYPE_UNKNOWN = 0; + TARGET_TYPE_FILE = 1; + TARGET_TYPE_EXTENSION_RANGE = 2; + TARGET_TYPE_MESSAGE = 3; + TARGET_TYPE_FIELD = 4; + TARGET_TYPE_ONEOF = 5; + TARGET_TYPE_ENUM = 6; + TARGET_TYPE_ENUM_ENTRY = 7; + TARGET_TYPE_SERVICE = 8; + TARGET_TYPE_METHOD = 9; + } + + repeated OptionTargetType targets = 19; + + message EditionDefault { + optional Edition edition = 3; + optional string value = 2; // Textproto value. + } + repeated EditionDefault edition_defaults = 20; + + // Any features defined in the specific edition. + optional FeatureSet features = 21; + + // Information about the support window of a feature. + message FeatureSupport { + // The edition that this feature was first available in. In editions + // earlier than this one, the default assigned to EDITION_LEGACY will be + // used, and proto files will not be able to override it. + optional Edition edition_introduced = 1; + + // The edition this feature becomes deprecated in. Using this after this + // edition may trigger warnings. + optional Edition edition_deprecated = 2; + + // The deprecation warning text if this feature is used after the edition it + // was marked deprecated in. + optional string deprecation_warning = 3; + + // The edition this feature is no longer available in. In editions after + // this one, the last default assigned will be used, and proto files will + // not be able to override it. + optional Edition edition_removed = 4; + } + optional FeatureSupport feature_support = 22; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; + + reserved 4; // removed jtype + reserved 18; // reserve target, target_obsolete_do_not_use +} + +message OneofOptions { + // Any features defined in the specific edition. + optional FeatureSet features = 1; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message EnumOptions { + + // Set this option to true to allow mapping different tag names to the same + // value. + optional bool allow_alias = 2; + + // Is this enum deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum, or it will be completely ignored; in the very least, this + // is a formalization for deprecating enums. + optional bool deprecated = 3 [default = false]; + + reserved 5; // javanano_as_lite + + // Enable the legacy handling of JSON field name conflicts. This lowercases + // and strips underscored from the fields before comparison in proto3 only. + // The new behavior takes `json_name` into account and applies to proto2 as + // well. + // TODO Remove this legacy behavior once downstream teams have + // had time to migrate. + optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true]; + + // Any features defined in the specific edition. + optional FeatureSet features = 7; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message EnumValueOptions { + // Is this enum value deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum value, or it will be completely ignored; in the very least, + // this is a formalization for deprecating enum values. + optional bool deprecated = 1 [default = false]; + + // Any features defined in the specific edition. + optional FeatureSet features = 2; + + // Indicate that fields annotated with this enum value should not be printed + // out when using debug formats, e.g. when the field contains sensitive + // credentials. + optional bool debug_redact = 3 [default = false]; + + // Information about the support window of a feature value. + optional FieldOptions.FeatureSupport feature_support = 4; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message ServiceOptions { + + // Any features defined in the specific edition. + optional FeatureSet features = 34; + + // Note: Field numbers 1 through 32 are reserved for Google's internal RPC + // framework. We apologize for hoarding these numbers to ourselves, but + // we were already using them long before we decided to release Protocol + // Buffers. + + // Is this service deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the service, or it will be completely ignored; in the very least, + // this is a formalization for deprecating services. + optional bool deprecated = 33 [default = false]; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message MethodOptions { + + // Note: Field numbers 1 through 32 are reserved for Google's internal RPC + // framework. We apologize for hoarding these numbers to ourselves, but + // we were already using them long before we decided to release Protocol + // Buffers. + + // Is this method deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the method, or it will be completely ignored; in the very least, + // this is a formalization for deprecating methods. + optional bool deprecated = 33 [default = false]; + + // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + // or neither? HTTP based RPC implementation may choose GET verb for safe + // methods, and PUT verb for idempotent methods instead of the default POST. + enum IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0; + NO_SIDE_EFFECTS = 1; // implies idempotent + IDEMPOTENT = 2; // idempotent, but may have side effects + } + optional IdempotencyLevel idempotency_level = 34 + [default = IDEMPOTENCY_UNKNOWN]; + + // Any features defined in the specific edition. + optional FeatureSet features = 35; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +// A message representing a option the parser does not recognize. This only +// appears in options protos created by the compiler::Parser class. +// DescriptorPool resolves these when building Descriptor objects. Therefore, +// options protos in descriptor objects (e.g. returned by Descriptor::options(), +// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions +// in them. +message UninterpretedOption { + // The name of the uninterpreted option. Each string represents a segment in + // a dot-separated name. is_extension is true iff a segment represents an + // extension (denoted with parentheses in options specs in .proto files). + // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents + // "foo.(bar.baz).moo". + message NamePart { + required string name_part = 1; + required bool is_extension = 2; + } + repeated NamePart name = 2; + + // The value of the uninterpreted option, in whatever type the tokenizer + // identified it as during parsing. Exactly one of these should be set. + optional string identifier_value = 3; + optional uint64 positive_int_value = 4; + optional int64 negative_int_value = 5; + optional double double_value = 6; + optional bytes string_value = 7; + optional string aggregate_value = 8; +} + +// =================================================================== +// Features + +// TODO Enums in C++ gencode (and potentially other languages) are +// not well scoped. This means that each of the feature enums below can clash +// with each other. The short names we've chosen maximize call-site +// readability, but leave us very open to this scenario. A future feature will +// be designed and implemented to handle this, hopefully before we ever hit a +// conflict here. +message FeatureSet { + enum FieldPresence { + FIELD_PRESENCE_UNKNOWN = 0; + EXPLICIT = 1; + IMPLICIT = 2; + LEGACY_REQUIRED = 3; + } + optional FieldPresence field_presence = 1 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "EXPLICIT" }, + edition_defaults = { edition: EDITION_PROTO3, value: "IMPLICIT" }, + edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" } + ]; + + enum EnumType { + ENUM_TYPE_UNKNOWN = 0; + OPEN = 1; + CLOSED = 2; + } + optional EnumType enum_type = 2 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "CLOSED" }, + edition_defaults = { edition: EDITION_PROTO3, value: "OPEN" } + ]; + + enum RepeatedFieldEncoding { + REPEATED_FIELD_ENCODING_UNKNOWN = 0; + PACKED = 1; + EXPANDED = 2; + } + optional RepeatedFieldEncoding repeated_field_encoding = 3 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "EXPANDED" }, + edition_defaults = { edition: EDITION_PROTO3, value: "PACKED" } + ]; + + enum Utf8Validation { + UTF8_VALIDATION_UNKNOWN = 0; + VERIFY = 2; + NONE = 3; + reserved 1; + } + optional Utf8Validation utf8_validation = 4 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "NONE" }, + edition_defaults = { edition: EDITION_PROTO3, value: "VERIFY" } + ]; + + enum MessageEncoding { + MESSAGE_ENCODING_UNKNOWN = 0; + LENGTH_PREFIXED = 1; + DELIMITED = 2; + } + optional MessageEncoding message_encoding = 5 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "LENGTH_PREFIXED" } + ]; + + enum JsonFormat { + JSON_FORMAT_UNKNOWN = 0; + ALLOW = 1; + LEGACY_BEST_EFFORT = 2; + } + optional JsonFormat json_format = 6 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_MESSAGE, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY_BEST_EFFORT" }, + edition_defaults = { edition: EDITION_PROTO3, value: "ALLOW" } + ]; + + reserved 999; + + // extensions 1000 to 9994 [ + // declaration = { + // number: 1000, + // full_name: ".pb.cpp", + // type: ".pb.CppFeatures" + // }, + // declaration = { + // number: 1001, + // full_name: ".pb.java", + // type: ".pb.JavaFeatures" + // }, + // declaration = { number: 1002, full_name: ".pb.go", type: ".pb.GoFeatures" }, + // declaration = { + // number: 9990, + // full_name: ".pb.proto1", + // type: ".pb.Proto1Features" + // } + // ]; + + extensions 9995 to 9999; // For internal testing + extensions 10000; // for https://github.com/bufbuild/protobuf-es +} + +// A compiled specification for the defaults of a set of features. These +// messages are generated from FeatureSet extensions and can be used to seed +// feature resolution. The resolution with this object becomes a simple search +// for the closest matching edition, followed by proto merges. +message FeatureSetDefaults { + // A map from every known edition with a unique set of defaults to its + // defaults. Not all editions may be contained here. For a given edition, + // the defaults at the closest matching edition ordered at or before it should + // be used. This field must be in strict ascending order by edition. + message FeatureSetEditionDefault { + optional Edition edition = 3; + + // Defaults of features that can be overridden in this edition. + optional FeatureSet overridable_features = 4; + + // Defaults of features that can't be overridden in this edition. + optional FeatureSet fixed_features = 5; + + reserved 1, 2; + reserved "features"; + } + repeated FeatureSetEditionDefault defaults = 1; + + // The minimum supported edition (inclusive) when this was constructed. + // Editions before this will not have defaults. + optional Edition minimum_edition = 4; + + // The maximum known edition (inclusive) when this was constructed. Editions + // after this will not have reliable defaults. + optional Edition maximum_edition = 5; +} + +// =================================================================== +// Optional source code info + +// Encapsulates information about the original source file from which a +// FileDescriptorProto was generated. +message SourceCodeInfo { + // A Location identifies a piece of source code in a .proto file which + // corresponds to a particular definition. This information is intended + // to be useful to IDEs, code indexers, documentation generators, and similar + // tools. + // + // For example, say we have a file like: + // message Foo { + // optional string foo = 1; + // } + // Let's look at just the field definition: + // optional string foo = 1; + // ^ ^^ ^^ ^ ^^^ + // a bc de f ghi + // We have the following locations: + // span path represents + // [a,i) [ 4, 0, 2, 0 ] The whole field definition. + // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + // + // Notes: + // - A location may refer to a repeated field itself (i.e. not to any + // particular index within it). This is used whenever a set of elements are + // logically enclosed in a single code segment. For example, an entire + // extend block (possibly containing multiple extension definitions) will + // have an outer location whose path refers to the "extensions" repeated + // field without an index. + // - Multiple locations may have the same path. This happens when a single + // logical declaration is spread out across multiple places. The most + // obvious example is the "extend" block again -- there may be multiple + // extend blocks in the same scope, each of which will have the same path. + // - A location's span is not always a subset of its parent's span. For + // example, the "extendee" of an extension declaration appears at the + // beginning of the "extend" block and is shared by all extensions within + // the block. + // - Just because a location's span is a subset of some other location's span + // does not mean that it is a descendant. For example, a "group" defines + // both a type and a field in a single declaration. Thus, the locations + // corresponding to the type and field and their components will overlap. + // - Code which tries to interpret locations should probably be designed to + // ignore those that it doesn't understand, as more types of locations could + // be recorded in the future. + repeated Location location = 1; + message Location { + // Identifies which part of the FileDescriptorProto was defined at this + // location. + // + // Each element is a field number or an index. They form a path from + // the root FileDescriptorProto to the place where the definition appears. + // For example, this path: + // [ 4, 3, 2, 7, 1 ] + // refers to: + // file.message_type(3) // 4, 3 + // .field(7) // 2, 7 + // .name() // 1 + // This is because FileDescriptorProto.message_type has field number 4: + // repeated DescriptorProto message_type = 4; + // and DescriptorProto.field has field number 2: + // repeated FieldDescriptorProto field = 2; + // and FieldDescriptorProto.name has field number 1: + // optional string name = 1; + // + // Thus, the above path gives the location of a field name. If we removed + // the last element: + // [ 4, 3, 2, 7 ] + // this path refers to the whole field declaration (from the beginning + // of the label to the terminating semicolon). + repeated int32 path = 1 [packed = true]; + + // Always has exactly three or four elements: start line, start column, + // end line (optional, otherwise assumed same as start line), end column. + // These are packed into a single field for efficiency. Note that line + // and column numbers are zero-based -- typically you will want to add + // 1 to each before displaying to a user. + repeated int32 span = 2 [packed = true]; + + // If this SourceCodeInfo represents a complete declaration, these are any + // comments appearing before and after the declaration which appear to be + // attached to the declaration. + // + // A series of line comments appearing on consecutive lines, with no other + // tokens appearing on those lines, will be treated as a single comment. + // + // leading_detached_comments will keep paragraphs of comments that appear + // before (but not connected to) the current element. Each paragraph, + // separated by empty lines, will be one comment element in the repeated + // field. + // + // Only the comment content is provided; comment markers (e.g. //) are + // stripped out. For block comments, leading whitespace and an asterisk + // will be stripped from the beginning of each line other than the first. + // Newlines are included in the output. + // + // Examples: + // + // optional int32 foo = 1; // Comment attached to foo. + // // Comment attached to bar. + // optional int32 bar = 2; + // + // optional string baz = 3; + // // Comment attached to baz. + // // Another line attached to baz. + // + // // Comment attached to moo. + // // + // // Another line attached to moo. + // optional double moo = 4; + // + // // Detached comment for corge. This is not leading or trailing comments + // // to moo or corge because there are blank lines separating it from + // // both. + // + // // Detached comment for corge paragraph 2. + // + // optional string corge = 5; + // /* Block comment attached + // * to corge. Leading asterisks + // * will be removed. */ + // /* Block comment attached to + // * grault. */ + // optional int32 grault = 6; + // + // // ignored detached comments. + optional string leading_comments = 3; + optional string trailing_comments = 4; + repeated string leading_detached_comments = 6; + } +} + +// Describes the relationship between generated code and its original source +// file. A GeneratedCodeInfo message is associated with only one generated +// source file, but may contain references to different source .proto files. +message GeneratedCodeInfo { + // An Annotation connects some span of text in generated code to an element + // of its generating .proto file. + repeated Annotation annotation = 1; + message Annotation { + // Identifies the element in the original source .proto file. This field + // is formatted the same as SourceCodeInfo.Location.path. + repeated int32 path = 1 [packed = true]; + + // Identifies the filesystem path to the original source .proto. + optional string source_file = 2; + + // Identifies the starting offset in bytes in the generated code + // that relates to the identified object. + optional int32 begin = 3; + + // Identifies the ending offset in bytes in the generated code that + // relates to the identified object. The end offset should be one past + // the last relevant byte (so the length of the text = end - begin). + optional int32 end = 4; + + // Represents the identified object's effect on the element in the original + // .proto file. + enum Semantic { + // There is no effect or the effect is indescribable. + NONE = 0; + // The element is set or otherwise mutated. + SET = 1; + // An alias to the element is returned. + ALIAS = 2; + } + optional Semantic semantic = 5; + } +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/admin.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/admin.options new file mode 100644 index 0000000..4804d89 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/admin.options @@ -0,0 +1,12 @@ +*AdminMessage.payload_variant anonymous_oneof:true + +*AdminMessage.set_canned_message_module_messages max_size:201 +*AdminMessage.get_canned_message_module_messages_response max_size:201 +*AdminMessage.delete_file_request max_size:201 + +*AdminMessage.set_ringtone_message max_size:231 +*AdminMessage.get_ringtone_response max_size:231 + +*HamParameters.call_sign max_size:8 +*HamParameters.short_name max_size:5 +*NodeRemoteHardwarePinsResponse.node_remote_hardware_pins max_count:16 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/admin.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/admin.proto new file mode 100644 index 0000000..9ddf856 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/admin.proto @@ -0,0 +1,388 @@ +syntax = "proto3"; + +package meshtastic; + +import "meshtastic/channel.proto"; +import "meshtastic/config.proto"; +import "meshtastic/connection_status.proto"; +import "meshtastic/mesh.proto"; +import "meshtastic/module_config.proto"; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "AdminProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * This message is handled by the Admin module and is responsible for all settings/channel read/write operations. + * This message is used to do settings operations to both remote AND local nodes. + * (Prior to 1.2 these operations were done via special ToRadio operations) + */ +message AdminMessage { + /* + * TODO: REPLACE + */ + enum ConfigType { + /* + * TODO: REPLACE + */ + DEVICE_CONFIG = 0; + + /* + * TODO: REPLACE + */ + POSITION_CONFIG = 1; + + /* + * TODO: REPLACE + */ + POWER_CONFIG = 2; + + /* + * TODO: REPLACE + */ + NETWORK_CONFIG = 3; + + /* + * TODO: REPLACE + */ + DISPLAY_CONFIG = 4; + + /* + * TODO: REPLACE + */ + LORA_CONFIG = 5; + + /* + * TODO: REPLACE + */ + BLUETOOTH_CONFIG = 6; + } + + /* + * TODO: REPLACE + */ + enum ModuleConfigType { + /* + * TODO: REPLACE + */ + MQTT_CONFIG = 0; + + /* + * TODO: REPLACE + */ + SERIAL_CONFIG = 1; + + /* + * TODO: REPLACE + */ + EXTNOTIF_CONFIG = 2; + + /* + * TODO: REPLACE + */ + STOREFORWARD_CONFIG = 3; + + /* + * TODO: REPLACE + */ + RANGETEST_CONFIG = 4; + + /* + * TODO: REPLACE + */ + TELEMETRY_CONFIG = 5; + + /* + * TODO: REPLACE + */ + CANNEDMSG_CONFIG = 6; + + /* + * TODO: REPLACE + */ + AUDIO_CONFIG = 7; + + /* + * TODO: REPLACE + */ + REMOTEHARDWARE_CONFIG = 8; + + /* + * TODO: REPLACE + */ + NEIGHBORINFO_CONFIG = 9; + + /* + * TODO: REPLACE + */ + AMBIENTLIGHTING_CONFIG = 10; + + /* + * TODO: REPLACE + */ + DETECTIONSENSOR_CONFIG = 11; + + /* + * TODO: REPLACE + */ + PAXCOUNTER_CONFIG = 12; + } + + /* + * TODO: REPLACE + */ + oneof payload_variant { + /* + * Send the specified channel in the response to this message + * NOTE: This field is sent with the channel index + 1 (to ensure we never try to send 'zero' - which protobufs treats as not present) + */ + uint32 get_channel_request = 1; + + /* + * TODO: REPLACE + */ + Channel get_channel_response = 2; + + /* + * Send the current owner data in the response to this message. + */ + bool get_owner_request = 3; + + /* + * TODO: REPLACE + */ + User get_owner_response = 4; + + /* + * Ask for the following config data to be sent + */ + ConfigType get_config_request = 5; + + /* + * Send the current Config in the response to this message. + */ + Config get_config_response = 6; + + /* + * Ask for the following config data to be sent + */ + ModuleConfigType get_module_config_request = 7; + + /* + * Send the current Config in the response to this message. + */ + ModuleConfig get_module_config_response = 8; + + /* + * Get the Canned Message Module messages in the response to this message. + */ + bool get_canned_message_module_messages_request = 10; + + /* + * Get the Canned Message Module messages in the response to this message. + */ + string get_canned_message_module_messages_response = 11; + + /* + * Request the node to send device metadata (firmware, protobuf version, etc) + */ + bool get_device_metadata_request = 12; + + /* + * Device metadata response + */ + DeviceMetadata get_device_metadata_response = 13; + + /* + * Get the Ringtone in the response to this message. + */ + bool get_ringtone_request = 14; + + /* + * Get the Ringtone in the response to this message. + */ + string get_ringtone_response = 15; + + /* + * Request the node to send it's connection status + */ + bool get_device_connection_status_request = 16; + + /* + * Device connection status response + */ + DeviceConnectionStatus get_device_connection_status_response = 17; + + /* + * Setup a node for licensed amateur (ham) radio operation + */ + HamParameters set_ham_mode = 18; + + /* + * Get the mesh's nodes with their available gpio pins for RemoteHardware module use + */ + bool get_node_remote_hardware_pins_request = 19; + + /* + * Respond with the mesh's nodes with their available gpio pins for RemoteHardware module use + */ + NodeRemoteHardwarePinsResponse get_node_remote_hardware_pins_response = 20; + + /* + * Enter (UF2) DFU mode + * Only implemented on NRF52 currently + */ + bool enter_dfu_mode_request = 21; + + /* + * Delete the file by the specified path from the device + */ + string delete_file_request = 22; + + /* + * Set zero and offset for scale chips + */ + uint32 set_scale = 23; + + /* + * Set the owner for this node + */ + User set_owner = 32; + + /* + * Set channels (using the new API). + * A special channel is the "primary channel". + * The other records are secondary channels. + * Note: only one channel can be marked as primary. + * If the client sets a particular channel to be primary, the previous channel will be set to SECONDARY automatically. + */ + Channel set_channel = 33; + + /* + * Set the current Config + */ + Config set_config = 34; + + /* + * Set the current Config + */ + ModuleConfig set_module_config = 35; + + /* + * Set the Canned Message Module messages text. + */ + string set_canned_message_module_messages = 36; + + /* + * Set the ringtone for ExternalNotification. + */ + string set_ringtone_message = 37; + + /* + * Remove the node by the specified node-num from the NodeDB on the device + */ + uint32 remove_by_nodenum = 38; + + /* + * Set specified node-num to be favorited on the NodeDB on the device + */ + uint32 set_favorite_node = 39; + + /* + * Set specified node-num to be un-favorited on the NodeDB on the device + */ + uint32 remove_favorite_node = 40; + + /* + * Set fixed position data on the node and then set the position.fixed_position = true + */ + Position set_fixed_position = 41; + + /* + * Clear fixed position coordinates and then set position.fixed_position = false + */ + bool remove_fixed_position = 42; + + /* + * Begins an edit transaction for config, module config, owner, and channel settings changes + * This will delay the standard *implicit* save to the file system and subsequent reboot behavior until committed (commit_edit_settings) + */ + bool begin_edit_settings = 64; + + /* + * Commits an open transaction for any edits made to config, module config, owner, and channel settings + */ + bool commit_edit_settings = 65; + + /* + * Tell the node to reboot into the OTA Firmware in this many seconds (or <0 to cancel reboot) + * Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth. + */ + int32 reboot_ota_seconds = 95; + + /* + * This message is only supported for the simulator Portduino build. + * If received the simulator will exit successfully. + */ + bool exit_simulator = 96; + + /* + * Tell the node to reboot in this many seconds (or <0 to cancel reboot) + */ + int32 reboot_seconds = 97; + + /* + * Tell the node to shutdown in this many seconds (or <0 to cancel shutdown) + */ + int32 shutdown_seconds = 98; + + /* + * Tell the node to factory reset, all device settings will be returned to factory defaults. + */ + int32 factory_reset = 99; + + /* + * Tell the node to reset the nodedb. + */ + int32 nodedb_reset = 100; + } +} + +/* + * Parameters for setting up Meshtastic for ameteur radio usage + */ +message HamParameters { + /* + * Amateur radio call sign, eg. KD2ABC + */ + string call_sign = 1; + + /* + * Transmit power in dBm at the LoRA transceiver, not including any amplification + */ + int32 tx_power = 2; + + /* + * The selected frequency of LoRA operation + * Please respect your local laws, regulations, and band plans. + * Ensure your radio is capable of operating of the selected frequency before setting this. + */ + float frequency = 3; + + /* + * Optional short name of user + */ + string short_name = 4; +} + +/* + * Response envelope for node_remote_hardware_pins + */ +message NodeRemoteHardwarePinsResponse { + /* + * Nodes and their respective remote hardware GPIO pins + */ + repeated NodeRemoteHardwarePin node_remote_hardware_pins = 1; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/apponly.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/apponly.options new file mode 100644 index 0000000..28244de --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/apponly.options @@ -0,0 +1 @@ +*ChannelSet.settings max_count:8 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/apponly.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/apponly.proto new file mode 100644 index 0000000..100833f --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/apponly.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package meshtastic; + +import "meshtastic/channel.proto"; +import "meshtastic/config.proto"; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "AppOnlyProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * This is the most compact possible representation for a set of channels. + * It includes only one PRIMARY channel (which must be first) and + * any SECONDARY channels. + * No DISABLED channels are included. + * This abstraction is used only on the the 'app side' of the world (ie python, javascript and android etc) to show a group of Channels as a (long) URL + */ +message ChannelSet { + /* + * Channel list with settings + */ + repeated ChannelSettings settings = 1; + + /* + * LoRa config + */ + Config.LoRaConfig lora_config = 2; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/atak.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/atak.options new file mode 100644 index 0000000..6baa7ea --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/atak.options @@ -0,0 +1,7 @@ +*Contact.callsign max_size:120 +*Contact.device_callsign max_size:120 +*Status.battery int_size:8 +*PLI.course int_size:16 +*GeoChat.message max_size:200 +*GeoChat.to max_size:120 +*GeoChat.to_callsign max_size:120 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/atak.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/atak.proto new file mode 100644 index 0000000..ccde335 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/atak.proto @@ -0,0 +1,257 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "ATAKProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * Packets for the official ATAK Plugin + */ +message TAKPacket { + /* + * Are the payloads strings compressed for LoRA transport? + */ + bool is_compressed = 1; + /* + * The contact / callsign for ATAK user + */ + Contact contact = 2; + /* + * The group for ATAK user + */ + Group group = 3; + /* + * The status of the ATAK EUD + */ + Status status = 4; + /* + * The payload of the packet + */ + oneof payload_variant { + /* + * TAK position report + */ + PLI pli = 5; + /* + * ATAK GeoChat message + */ + GeoChat chat = 6; + } +} + +/* + * ATAK GeoChat message + */ +message GeoChat { + /* + * The text message + */ + string message = 1; + + /* + * Uid recipient of the message + */ + optional string to = 2; + + /* + * Callsign of the recipient for the message + */ + optional string to_callsign = 3; +} + +/* + * ATAK Group + * <__group role='Team Member' name='Cyan'/> + */ +message Group { + /* + * Role of the group member + */ + MemberRole role = 1; + /* + * Team (color) + * Default Cyan + */ + Team team = 2; +} + +enum Team { + /* + * Unspecifed + */ + Unspecifed_Color = 0; + /* + * White + */ + White = 1; + /* + * Yellow + */ + Yellow = 2; + /* + * Orange + */ + Orange = 3; + /* + * Magenta + */ + Magenta = 4; + /* + * Red + */ + Red = 5; + /* + * Maroon + */ + Maroon = 6; + /* + * Purple + */ + Purple = 7; + /* + * Dark Blue + */ + Dark_Blue = 8; + /* + * Blue + */ + Blue = 9; + /* + * Cyan + */ + Cyan = 10; + /* + * Teal + */ + Teal = 11; + /* + * Green + */ + Green = 12; + /* + * Dark Green + */ + Dark_Green = 13; + /* + * Brown + */ + Brown = 14; +} + +/* + * Role of the group member + */ +enum MemberRole { + /* + * Unspecifed + */ + Unspecifed = 0; + /* + * Team Member + */ + TeamMember = 1; + /* + * Team Lead + */ + TeamLead = 2; + /* + * Headquarters + */ + HQ = 3; + /* + * Airsoft enthusiast + */ + Sniper = 4; + /* + * Medic + */ + Medic = 5; + /* + * ForwardObserver + */ + ForwardObserver = 6; + /* + * Radio Telephone Operator + */ + RTO = 7; + /* + * Doggo + */ + K9 = 8; +} + +/* + * ATAK EUD Status + * + */ +message Status { + /* + * Battery level + */ + uint32 battery = 1; +} + +/* + * ATAK Contact + * + */ +message Contact { + /* + * Callsign + */ + string callsign = 1; + + /* + * Device callsign + */ + string device_callsign = 2; + /* + * IP address of endpoint in integer form (0.0.0.0 default) + */ + // fixed32 enpoint_address = 3; + /* + * Port of endpoint (4242 default) + */ + // uint32 endpoint_port = 4; + /* + * Phone represented as integer + * Terrible practice, but we really need the wire savings + */ + // uint32 phone = 4; +} + +/* + * Position Location Information from ATAK + */ +message PLI { + /* + * The new preferred location encoding, multiply by 1e-7 to get degrees + * in floating point + */ + sfixed32 latitude_i = 1; + + /* + * The new preferred location encoding, multiply by 1e-7 to get degrees + * in floating point + */ + sfixed32 longitude_i = 2; + + /* + * Altitude (ATAK prefers HAE) + */ + int32 altitude = 3; + + /* + * Speed + */ + uint32 speed = 4; + + /* + * Course in degrees + */ + uint32 course = 5; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/cannedmessages.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/cannedmessages.options new file mode 100644 index 0000000..c1d537b --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/cannedmessages.options @@ -0,0 +1 @@ +*CannedMessageModuleConfig.messages max_size:201 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/cannedmessages.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/cannedmessages.proto new file mode 100644 index 0000000..baa5134 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/cannedmessages.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "CannedMessageConfigProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * Canned message module configuration. + */ +message CannedMessageModuleConfig { + /* + * Predefined messages for canned message module separated by '|' characters. + */ + string messages = 1; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/channel.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/channel.options new file mode 100644 index 0000000..d0bdcbc --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/channel.options @@ -0,0 +1,5 @@ +*Channel.index int_size:8 + +# 256 bit or 128 bit psk key +*ChannelSettings.psk max_size:32 +*ChannelSettings.name max_size:12 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/channel.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/channel.proto new file mode 100644 index 0000000..16c8c19 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/channel.proto @@ -0,0 +1,156 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "ChannelProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * This information can be encoded as a QRcode/url so that other users can configure + * their radio to join the same channel. + * A note about how channel names are shown to users: channelname-X + * poundsymbol is a prefix used to indicate this is a channel name (idea from @professr). + * Where X is a letter from A-Z (base 26) representing a hash of the PSK for this + * channel - so that if the user changes anything about the channel (which does + * force a new PSK) this letter will also change. Thus preventing user confusion if + * two friends try to type in a channel name of "BobsChan" and then can't talk + * because their PSKs will be different. + * The PSK is hashed into this letter by "0x41 + [xor all bytes of the psk ] modulo 26" + * This also allows the option of someday if people have the PSK off (zero), the + * users COULD type in a channel name and be able to talk. + * FIXME: Add description of multi-channel support and how primary vs secondary channels are used. + * FIXME: explain how apps use channels for security. + * explain how remote settings and remote gpio are managed as an example + */ +message ChannelSettings { + /* + * Deprecated in favor of LoraConfig.channel_num + */ + uint32 channel_num = 1 [deprecated = true]; + + /* + * A simple pre-shared key for now for crypto. + * Must be either 0 bytes (no crypto), 16 bytes (AES128), or 32 bytes (AES256). + * A special shorthand is used for 1 byte long psks. + * These psks should be treated as only minimally secure, + * because they are listed in this source code. + * Those bytes are mapped using the following scheme: + * `0` = No crypto + * `1` = The special "default" channel key: {0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59, 0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0x01} + * `2` through 10 = The default channel key, except with 1 through 9 added to the last byte. + * Shown to user as simple1 through 10 + */ + bytes psk = 2; + + /* + * A SHORT name that will be packed into the URL. + * Less than 12 bytes. + * Something for end users to call the channel + * If this is the empty string it is assumed that this channel + * is the special (minimally secure) "Default"channel. + * In user interfaces it should be rendered as a local language translation of "X". + * For channel_num hashing empty string will be treated as "X". + * Where "X" is selected based on the English words listed above for ModemPreset + */ + string name = 3; + + /* + * Used to construct a globally unique channel ID. + * The full globally unique ID will be: "name.id" where ID is shown as base36. + * Assuming that the number of meshtastic users is below 20K (true for a long time) + * the chance of this 64 bit random number colliding with anyone else is super low. + * And the penalty for collision is low as well, it just means that anyone trying to decrypt channel messages might need to + * try multiple candidate channels. + * Any time a non wire compatible change is made to a channel, this field should be regenerated. + * There are a small number of 'special' globally known (and fairly) insecure standard channels. + * Those channels do not have a numeric id included in the settings, but instead it is pulled from + * a table of well known IDs. + * (see Well Known Channels FIXME) + */ + fixed32 id = 4; + + /* + * If true, messages on the mesh will be sent to the *public* internet by any gateway ndoe + */ + bool uplink_enabled = 5; + + /* + * If true, messages seen on the internet will be forwarded to the local mesh. + */ + bool downlink_enabled = 6; + + /* + * Per-channel module settings. + */ + ModuleSettings module_settings = 7; +} + +/* + * This message is specifically for modules to store per-channel configuration data. + */ +message ModuleSettings { + /* + * Bits of precision for the location sent in position packets. + */ + uint32 position_precision = 1; + + /* + * Controls whether or not the phone / clients should mute the current channel + * Useful for noisy public channels you don't necessarily want to disable + */ + bool is_client_muted = 2; +} + +/* + * A pair of a channel number, mode and the (sharable) settings for that channel + */ +message Channel { + /* + * How this channel is being used (or not). + * Note: this field is an enum to give us options for the future. + * In particular, someday we might make a 'SCANNING' option. + * SCANNING channels could have different frequencies and the radio would + * occasionally check that freq to see if anything is being transmitted. + * For devices that have multiple physical radios attached, we could keep multiple PRIMARY/SCANNING channels active at once to allow + * cross band routing as needed. + * If a device has only a single radio (the common case) only one channel can be PRIMARY at a time + * (but any number of SECONDARY channels can't be sent received on that common frequency) + */ + enum Role { + /* + * This channel is not in use right now + */ + DISABLED = 0; + + /* + * This channel is used to set the frequency for the radio - all other enabled channels must be SECONDARY + */ + PRIMARY = 1; + + /* + * Secondary channels are only used for encryption/decryption/authentication purposes. + * Their radio settings (freq etc) are ignored, only psk is used. + */ + SECONDARY = 2; + } + + /* + * The index of this channel in the channel table (from 0 to MAX_NUM_CHANNELS-1) + * (Someday - not currently implemented) An index of -1 could be used to mean "set by name", + * in which case the target node will find and set the channel by settings.name. + */ + int32 index = 1; + + /* + * The new settings, or NULL to disable that channel + */ + ChannelSettings settings = 2; + + /* + * TODO: REPLACE + */ + Role role = 3; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/clientonly.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/clientonly.options new file mode 100644 index 0000000..bc98b39 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/clientonly.options @@ -0,0 +1,2 @@ +*DeviceProfile.long_name max_size:40 +*DeviceProfile.short_name max_size:5 \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/clientonly.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/clientonly.proto new file mode 100644 index 0000000..b1a27b1 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/clientonly.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +package meshtastic; + +import "meshtastic/localonly.proto"; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "ClientOnlyProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * This abstraction is used to contain any configuration for provisioning a node on any client. + * It is useful for importing and exporting configurations. + */ +message DeviceProfile { + /* + * Long name for the node + */ + optional string long_name = 1; + + /* + * Short name of the node + */ + optional string short_name = 2; + + /* + * The url of the channels from our node + */ + optional string channel_url = 3; + + /* + * The Config of the node + */ + optional LocalConfig config = 4; + + /* + * The ModuleConfig of the node + */ + optional LocalModuleConfig module_config = 5; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/config.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/config.options new file mode 100644 index 0000000..22dcc88 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/config.options @@ -0,0 +1,17 @@ +# longest current is 45 chars, plan with a bit of buffer +*DeviceConfig.tzdef max_size:65 + +*NetworkConfig.wifi_ssid max_size:33 +*NetworkConfig.wifi_psk max_size:65 +*NetworkConfig.ntp_server max_size:33 +*NetworkConfig.rsyslog_server max_size:33 + +# Max of three ignored nodes for our testing +*LoRaConfig.ignore_incoming max_count:3 + +*LoRaConfig.tx_power int_size:8 +*LoRaConfig.bandwidth int_size:16 +*LoRaConfig.coding_rate int_size:8 +*LoRaConfig.channel_num int_size:16 + +*PowerConfig.device_battery_ina_address int_size:8 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/config.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/config.proto new file mode 100644 index 0000000..7805f71 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/config.proto @@ -0,0 +1,1012 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "ConfigProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +message Config { + /* + * Configuration + */ + message DeviceConfig { + /* + * Defines the device's role on the Mesh network + */ + enum Role { + /* + * Description: App connected or stand alone messaging device. + * Technical Details: Default Role + */ + CLIENT = 0; + /* + * Description: Device that does not forward packets from other devices. + */ + CLIENT_MUTE = 1; + + /* + * Description: Infrastructure node for extending network coverage by relaying messages. Visible in Nodes list. + * Technical Details: Mesh packets will prefer to be routed over this node. This node will not be used by client apps. + * The wifi radio and the oled screen will be put to sleep. + * This mode may still potentially have higher power usage due to it's preference in message rebroadcasting on the mesh. + */ + ROUTER = 2; + + /* + * Description: Combination of both ROUTER and CLIENT. Not for mobile devices. + */ + ROUTER_CLIENT = 3; + + /* + * Description: Infrastructure node for extending network coverage by relaying messages with minimal overhead. Not visible in Nodes list. + * Technical Details: Mesh packets will simply be rebroadcasted over this node. Nodes configured with this role will not originate NodeInfo, Position, Telemetry + * or any other packet type. They will simply rebroadcast any mesh packets on the same frequency, channel num, spread factor, and coding rate. + */ + REPEATER = 4; + + /* + * Description: Broadcasts GPS position packets as priority. + * Technical Details: Position Mesh packets will be prioritized higher and sent more frequently by default. + * When used in conjunction with power.is_power_saving = true, nodes will wake up, + * send position, and then sleep for position.position_broadcast_secs seconds. + */ + TRACKER = 5; + + /* + * Description: Broadcasts telemetry packets as priority. + * Technical Details: Telemetry Mesh packets will be prioritized higher and sent more frequently by default. + * When used in conjunction with power.is_power_saving = true, nodes will wake up, + * send environment telemetry, and then sleep for telemetry.environment_update_interval seconds. + */ + SENSOR = 6; + + /* + * Description: Optimized for ATAK system communication and reduces routine broadcasts. + * Technical Details: Used for nodes dedicated for connection to an ATAK EUD. + * Turns off many of the routine broadcasts to favor CoT packet stream + * from the Meshtastic ATAK plugin -> IMeshService -> Node + */ + TAK = 7; + + /* + * Description: Device that only broadcasts as needed for stealth or power savings. + * Technical Details: Used for nodes that "only speak when spoken to" + * Turns all of the routine broadcasts but allows for ad-hoc communication + * Still rebroadcasts, but with local only rebroadcast mode (known meshes only) + * Can be used for clandestine operation or to dramatically reduce airtime / power consumption + */ + CLIENT_HIDDEN = 8; + + /* + * Description: Broadcasts location as message to default channel regularly for to assist with device recovery. + * Technical Details: Used to automatically send a text message to the mesh + * with the current position of the device on a frequent interval: + * "I'm lost! Position: lat / long" + */ + LOST_AND_FOUND = 9; + + /* + * Description: Enables automatic TAK PLI broadcasts and reduces routine broadcasts. + * Technical Details: Turns off many of the routine broadcasts to favor ATAK CoT packet stream + * and automatic TAK PLI (position location information) broadcasts. + * Uses position module configuration to determine TAK PLI broadcast interval. + */ + TAK_TRACKER = 10; + } + + /* + * Defines the device's behavior for how messages are rebroadcast + */ + enum RebroadcastMode { + /* + * Default behavior. + * Rebroadcast any observed message, if it was on our private channel or from another mesh with the same lora params. + */ + ALL = 0; + + /* + * Same as behavior as ALL but skips packet decoding and simply rebroadcasts them. + * Only available in Repeater role. Setting this on any other roles will result in ALL behavior. + */ + ALL_SKIP_DECODING = 1; + + /* + * Ignores observed messages from foreign meshes that are open or those which it cannot decrypt. + * Only rebroadcasts message on the nodes local primary / secondary channels. + */ + LOCAL_ONLY = 2; + + /* + * Ignores observed messages from foreign meshes like LOCAL_ONLY, + * but takes it step further by also ignoring messages from nodenums not in the node's known list (NodeDB) + */ + KNOWN_ONLY = 3; + } + + /* + * Sets the role of node + */ + Role role = 1; + + /* + * Disabling this will disable the SerialConsole by not initilizing the StreamAPI + */ + bool serial_enabled = 2; + + /* + * By default we turn off logging as soon as an API client connects (to keep shared serial link quiet). + * Set this to true to leave the debug log outputting even when API is active. + */ + bool debug_log_enabled = 3; + + /* + * For boards without a hard wired button, this is the pin number that will be used + * Boards that have more than one button can swap the function with this one. defaults to BUTTON_PIN if defined. + */ + uint32 button_gpio = 4; + + /* + * For boards without a PWM buzzer, this is the pin number that will be used + * Defaults to PIN_BUZZER if defined. + */ + uint32 buzzer_gpio = 5; + + /* + * Sets the role of node + */ + RebroadcastMode rebroadcast_mode = 6; + + /* + * Send our nodeinfo this often + * Defaults to 900 Seconds (15 minutes) + */ + uint32 node_info_broadcast_secs = 7; + + /* + * Treat double tap interrupt on supported accelerometers as a button press if set to true + */ + bool double_tap_as_button_press = 8; + + /* + * If true, device is considered to be "managed" by a mesh administrator + * Clients should then limit available configuration and administrative options inside the user interface + */ + bool is_managed = 9; + + /* + * Disables the triple-press of user button to enable or disable GPS + */ + bool disable_triple_click = 10; + + /* + * POSIX Timezone definition string from https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv. + */ + string tzdef = 11; + + /* + * If true, disable the default blinking LED (LED_PIN) behavior on the device + */ + bool led_heartbeat_disabled = 12; + } + + /* + * Position Config + */ + message PositionConfig { + /* + * Bit field of boolean configuration options, indicating which optional + * fields to include when assembling POSITION messages. + * Longitude, latitude, altitude, speed, heading, and DOP + * are always included (also time if GPS-synced) + * NOTE: the more fields are included, the larger the message will be - + * leading to longer airtime and a higher risk of packet loss + */ + enum PositionFlags { + /* + * Required for compilation + */ + UNSET = 0x0000; + + /* + * Include an altitude value (if available) + */ + ALTITUDE = 0x0001; + + /* + * Altitude value is MSL + */ + ALTITUDE_MSL = 0x0002; + + /* + * Include geoidal separation + */ + GEOIDAL_SEPARATION = 0x0004; + + /* + * Include the DOP value ; PDOP used by default, see below + */ + DOP = 0x0008; + + /* + * If POS_DOP set, send separate HDOP / VDOP values instead of PDOP + */ + HVDOP = 0x0010; + + /* + * Include number of "satellites in view" + */ + SATINVIEW = 0x0020; + + /* + * Include a sequence number incremented per packet + */ + SEQ_NO = 0x0040; + + /* + * Include positional timestamp (from GPS solution) + */ + TIMESTAMP = 0x0080; + + /* + * Include positional heading + * Intended for use with vehicle not walking speeds + * walking speeds are likely to be error prone like the compass + */ + HEADING = 0x0100; + + /* + * Include positional speed + * Intended for use with vehicle not walking speeds + * walking speeds are likely to be error prone like the compass + */ + SPEED = 0x0200; + } + + enum GpsMode { + /* + * GPS is present but disabled + */ + DISABLED = 0; + + /* + * GPS is present and enabled + */ + ENABLED = 1; + + /* + * GPS is not present on the device + */ + NOT_PRESENT = 2; + } + + /* + * We should send our position this often (but only if it has changed significantly) + * Defaults to 15 minutes + */ + uint32 position_broadcast_secs = 1; + + /* + * Adaptive position braoadcast, which is now the default. + */ + bool position_broadcast_smart_enabled = 2; + + /* + * If set, this node is at a fixed position. + * We will generate GPS position updates at the regular interval, but use whatever the last lat/lon/alt we have for the node. + * The lat/lon/alt can be set by an internal GPS or with the help of the app. + */ + bool fixed_position = 3; + + /* + * Is GPS enabled for this node? + */ + bool gps_enabled = 4 [deprecated = true]; + + /* + * How often should we try to get GPS position (in seconds) + * or zero for the default of once every 30 seconds + * or a very large value (maxint) to update only once at boot. + */ + uint32 gps_update_interval = 5; + + /* + * Deprecated in favor of using smart / regular broadcast intervals as implicit attempt time + */ + uint32 gps_attempt_time = 6 [deprecated = true]; + + /* + * Bit field of boolean configuration options for POSITION messages + * (bitwise OR of PositionFlags) + */ + uint32 position_flags = 7; + + /* + * (Re)define GPS_RX_PIN for your board. + */ + uint32 rx_gpio = 8; + + /* + * (Re)define GPS_TX_PIN for your board. + */ + uint32 tx_gpio = 9; + + /* + * The minimum distance in meters traveled (since the last send) before we can send a position to the mesh if position_broadcast_smart_enabled + */ + uint32 broadcast_smart_minimum_distance = 10; + + /* + * The minimum number of seconds (since the last send) before we can send a position to the mesh if position_broadcast_smart_enabled + */ + uint32 broadcast_smart_minimum_interval_secs = 11; + + /* + * (Re)define PIN_GPS_EN for your board. + */ + uint32 gps_en_gpio = 12; + + /* + * Set where GPS is enabled, disabled, or not present + */ + GpsMode gps_mode = 13; + } + + /* + * Power Config\ + * See [Power Config](/docs/settings/config/power) for additional power config details. + */ + message PowerConfig { + /* + * Description: Will sleep everything as much as possible, for the tracker and sensor role this will also include the lora radio. + * Don't use this setting if you want to use your device with the phone apps or are using a device without a user button. + * Technical Details: Works for ESP32 devices and NRF52 devices in the Sensor or Tracker roles + */ + bool is_power_saving = 1; + + /* + * Description: If non-zero, the device will fully power off this many seconds after external power is removed. + */ + uint32 on_battery_shutdown_after_secs = 2; + + /* + * Ratio of voltage divider for battery pin eg. 3.20 (R1=100k, R2=220k) + * Overrides the ADC_MULTIPLIER defined in variant for battery voltage calculation. + * https://meshtastic.org/docs/configuration/radio/power/#adc-multiplier-override + * Should be set to floating point value between 2 and 6 + */ + float adc_multiplier_override = 3; + + /* + * Description: The number of seconds for to wait before turning off BLE in No Bluetooth states + * Technical Details: ESP32 Only 0 for default of 1 minute + */ + uint32 wait_bluetooth_secs = 4; + + /* + * Super Deep Sleep Seconds + * While in Light Sleep if mesh_sds_timeout_secs is exceeded we will lower into super deep sleep + * for this value (default 1 year) or a button press + * 0 for default of one year + */ + uint32 sds_secs = 6; + + /* + * Description: In light sleep the CPU is suspended, LoRa radio is on, BLE is off an GPS is on + * Technical Details: ESP32 Only 0 for default of 300 + */ + uint32 ls_secs = 7; + + /* + * Description: While in light sleep when we receive packets on the LoRa radio we will wake and handle them and stay awake in no BLE mode for this value + * Technical Details: ESP32 Only 0 for default of 10 seconds + */ + uint32 min_wake_secs = 8; + + /* + * I2C address of INA_2XX to use for reading device battery voltage + */ + uint32 device_battery_ina_address = 9; + } + + /* + * Network Config + */ + message NetworkConfig { + enum AddressMode { + /* + * obtain ip address via DHCP + */ + DHCP = 0; + + /* + * use static ip address + */ + STATIC = 1; + } + + message IpV4Config { + /* + * Static IP address + */ + fixed32 ip = 1; + + /* + * Static gateway address + */ + fixed32 gateway = 2; + + /* + * Static subnet mask + */ + fixed32 subnet = 3; + + /* + * Static DNS server address + */ + fixed32 dns = 4; + } + + /* + * Enable WiFi (disables Bluetooth) + */ + bool wifi_enabled = 1; + + /* + * If set, this node will try to join the specified wifi network and + * acquire an address via DHCP + */ + string wifi_ssid = 3; + + /* + * If set, will be use to authenticate to the named wifi + */ + string wifi_psk = 4; + + /* + * NTP server to use if WiFi is conneced, defaults to `0.pool.ntp.org` + */ + string ntp_server = 5; + + /* + * Enable Ethernet + */ + bool eth_enabled = 6; + + /* + * acquire an address via DHCP or assign static + */ + AddressMode address_mode = 7; + + /* + * struct to keep static address + */ + IpV4Config ipv4_config = 8; + + /* + * rsyslog Server and Port + */ + string rsyslog_server = 9; + } + + /* + * Display Config + */ + message DisplayConfig { + /* + * How the GPS coordinates are displayed on the OLED screen. + */ + enum GpsCoordinateFormat { + /* + * GPS coordinates are displayed in the normal decimal degrees format: + * DD.DDDDDD DDD.DDDDDD + */ + DEC = 0; + + /* + * GPS coordinates are displayed in the degrees minutes seconds format: + * DD°MM'SS"C DDD°MM'SS"C, where C is the compass point representing the locations quadrant + */ + DMS = 1; + + /* + * Universal Transverse Mercator format: + * ZZB EEEEEE NNNNNNN, where Z is zone, B is band, E is easting, N is northing + */ + UTM = 2; + + /* + * Military Grid Reference System format: + * ZZB CD EEEEE NNNNN, where Z is zone, B is band, C is the east 100k square, D is the north 100k square, + * E is easting, N is northing + */ + MGRS = 3; + + /* + * Open Location Code (aka Plus Codes). + */ + OLC = 4; + + /* + * Ordnance Survey Grid Reference (the National Grid System of the UK). + * Format: AB EEEEE NNNNN, where A is the east 100k square, B is the north 100k square, + * E is the easting, N is the northing + */ + OSGR = 5; + } + + /* + * Unit display preference + */ + enum DisplayUnits { + /* + * Metric (Default) + */ + METRIC = 0; + + /* + * Imperial + */ + IMPERIAL = 1; + } + + /* + * Override OLED outo detect with this if it fails. + */ + enum OledType { + /* + * Default / Auto + */ + OLED_AUTO = 0; + + /* + * Default / Auto + */ + OLED_SSD1306 = 1; + + /* + * Default / Auto + */ + OLED_SH1106 = 2; + + /* + * Can not be auto detected but set by proto. Used for 128x128 screens + */ + OLED_SH1107 = 3; + } + + /* + * Number of seconds the screen stays on after pressing the user button or receiving a message + * 0 for default of one minute MAXUINT for always on + */ + uint32 screen_on_secs = 1; + + /* + * How the GPS coordinates are formatted on the OLED screen. + */ + GpsCoordinateFormat gps_format = 2; + + /* + * Automatically toggles to the next page on the screen like a carousel, based the specified interval in seconds. + * Potentially useful for devices without user buttons. + */ + uint32 auto_screen_carousel_secs = 3; + + /* + * If this is set, the displayed compass will always point north. if unset, the old behaviour + * (top of display is heading direction) is used. + */ + bool compass_north_top = 4; + + /* + * Flip screen vertically, for cases that mount the screen upside down + */ + bool flip_screen = 5; + + /* + * Perferred display units + */ + DisplayUnits units = 6; + + /* + * Override auto-detect in screen + */ + OledType oled = 7; + + enum DisplayMode { + /* + * Default. The old style for the 128x64 OLED screen + */ + DEFAULT = 0; + + /* + * Rearrange display elements to cater for bicolor OLED displays + */ + TWOCOLOR = 1; + + /* + * Same as TwoColor, but with inverted top bar. Not so good for Epaper displays + */ + INVERTED = 2; + + /* + * TFT Full Color Displays (not implemented yet) + */ + COLOR = 3; + } + /* + * Display Mode + */ + DisplayMode displaymode = 8; + + /* + * Print first line in pseudo-bold? FALSE is original style, TRUE is bold + */ + bool heading_bold = 9; + + /* + * Should we wake the screen up on accelerometer detected motion or tap + */ + bool wake_on_tap_or_motion = 10; + + enum CompassOrientation { + /* + * The compass and the display are in the same orientation. + */ + DEGREES_0 = 0; + + /* + * Rotate the compass by 90 degrees. + */ + DEGREES_90 = 1; + + /* + * Rotate the compass by 180 degrees. + */ + DEGREES_180 = 2; + + /* + * Rotate the compass by 270 degrees. + */ + DEGREES_270 = 3; + + /* + * Don't rotate the compass, but invert the result. + */ + DEGREES_0_INVERTED = 4; + + /* + * Rotate the compass by 90 degrees and invert. + */ + DEGREES_90_INVERTED = 5; + + /* + * Rotate the compass by 180 degrees and invert. + */ + DEGREES_180_INVERTED = 6; + + /* + * Rotate the compass by 270 degrees and invert. + */ + DEGREES_270_INVERTED = 7; + } + + /* + * Indicates how to rotate or invert the compass output to accurate display on the display. + */ + CompassOrientation compass_orientation = 11; + } + + /* + * Lora Config + */ + message LoRaConfig { + enum RegionCode { + /* + * Region is not set + */ + UNSET = 0; + + /* + * United States + */ + US = 1; + + /* + * European Union 433mhz + */ + EU_433 = 2; + + /* + * European Union 868mhz + */ + EU_868 = 3; + + /* + * China + */ + CN = 4; + + /* + * Japan + */ + JP = 5; + + /* + * Australia / New Zealand + */ + ANZ = 6; + + /* + * Korea + */ + KR = 7; + + /* + * Taiwan + */ + TW = 8; + + /* + * Russia + */ + RU = 9; + + /* + * India + */ + IN = 10; + + /* + * New Zealand 865mhz + */ + NZ_865 = 11; + + /* + * Thailand + */ + TH = 12; + + /* + * WLAN Band + */ + LORA_24 = 13; + + /* + * Ukraine 433mhz + */ + UA_433 = 14; + + /* + * Ukraine 868mhz + */ + UA_868 = 15; + + /* + * Malaysia 433mhz + */ + MY_433 = 16; + + /* + * Malaysia 919mhz + */ + MY_919 = 17; + + /* + * Singapore 923mhz + */ + SG_923 = 18; + } + + /* + * Standard predefined channel settings + * Note: these mappings must match ModemPreset Choice in the device code. + */ + enum ModemPreset { + /* + * Long Range - Fast + */ + LONG_FAST = 0; + + /* + * Long Range - Slow + */ + LONG_SLOW = 1; + + /* + * Very Long Range - Slow + */ + VERY_LONG_SLOW = 2; + + /* + * Medium Range - Slow + */ + MEDIUM_SLOW = 3; + + /* + * Medium Range - Fast + */ + MEDIUM_FAST = 4; + + /* + * Short Range - Slow + */ + SHORT_SLOW = 5; + + /* + * Short Range - Fast + */ + SHORT_FAST = 6; + + /* + * Long Range - Moderately Fast + */ + LONG_MODERATE = 7; + } + + /* + * When enabled, the `modem_preset` fields will be adhered to, else the `bandwidth`/`spread_factor`/`coding_rate` + * will be taked from their respective manually defined fields + */ + bool use_preset = 1; + + /* + * Either modem_config or bandwidth/spreading/coding will be specified - NOT BOTH. + * As a heuristic: If bandwidth is specified, do not use modem_config. + * Because protobufs take ZERO space when the value is zero this works out nicely. + * This value is replaced by bandwidth/spread_factor/coding_rate. + * If you'd like to experiment with other options add them to MeshRadio.cpp in the device code. + */ + ModemPreset modem_preset = 2; + + /* + * Bandwidth in MHz + * Certain bandwidth numbers are 'special' and will be converted to the + * appropriate floating point value: 31 -> 31.25MHz + */ + uint32 bandwidth = 3; + + /* + * A number from 7 to 12. + * Indicates number of chirps per symbol as 1< 7 results in the default + */ + uint32 hop_limit = 8; + + /* + * Disable TX from the LoRa radio. Useful for hot-swapping antennas and other tests. + * Defaults to false + */ + bool tx_enabled = 9; + + /* + * If zero, then use default max legal continuous power (ie. something that won't + * burn out the radio hardware) + * In most cases you should use zero here. + * Units are in dBm. + */ + int32 tx_power = 10; + + /* + * This controls the actual hardware frequency the radio transmits on. + * Most users should never need to be exposed to this field/concept. + * A channel number between 1 and NUM_CHANNELS (whatever the max is in the current region). + * If ZERO then the rule is "use the old channel name hash based + * algorithm to derive the channel number") + * If using the hash algorithm the channel number will be: hash(channel_name) % + * NUM_CHANNELS (Where num channels depends on the regulatory region). + */ + uint32 channel_num = 11; + + /* + * If true, duty cycle limits will be exceeded and thus you're possibly not following + * the local regulations if you're not a HAM. + * Has no effect if the duty cycle of the used region is 100%. + */ + bool override_duty_cycle = 12; + + /* + * If true, sets RX boosted gain mode on SX126X based radios + */ + bool sx126x_rx_boosted_gain = 13; + + /* + * This parameter is for advanced users and licensed HAM radio operators. + * Ignore Channel Calculation and use this frequency instead. The frequency_offset + * will still be applied. This will allow you to use out-of-band frequencies. + * Please respect your local laws and regulations. If you are a HAM, make sure you + * enable HAM mode and turn off encryption. + */ + float override_frequency = 14; + + /* + * For testing it is useful sometimes to force a node to never listen to + * particular other nodes (simulating radio out of range). All nodenums listed + * in ignore_incoming will have packets they send dropped on receive (by router.cpp) + */ + repeated uint32 ignore_incoming = 103; + + /* + * If true, the device will not process any packets received via LoRa that passed via MQTT anywhere on the path towards it. + */ + bool ignore_mqtt = 104; + } + + message BluetoothConfig { + enum PairingMode { + /* + * Device generates a random PIN that will be shown on the screen of the device for pairing + */ + RANDOM_PIN = 0; + + /* + * Device requires a specified fixed PIN for pairing + */ + FIXED_PIN = 1; + + /* + * Device requires no PIN for pairing + */ + NO_PIN = 2; + } + + /* + * Enable Bluetooth on the device + */ + bool enabled = 1; + + /* + * Determines the pairing strategy for the device + */ + PairingMode mode = 2; + + /* + * Specified PIN for PairingMode.FixedPin + */ + uint32 fixed_pin = 3; + + /* + * Enables device (serial style logs) over Bluetooth + */ + bool device_logging_enabled = 4; + } + + /* + * Payload Variant + */ + oneof payload_variant { + DeviceConfig device = 1; + PositionConfig position = 2; + PowerConfig power = 3; + NetworkConfig network = 4; + DisplayConfig display = 5; + LoRaConfig lora = 6; + BluetoothConfig bluetooth = 7; + } +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/connection_status.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/connection_status.options new file mode 100644 index 0000000..d4901dd --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/connection_status.options @@ -0,0 +1 @@ +*WifiConnectionStatus.ssid max_size:33 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/connection_status.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/connection_status.proto new file mode 100644 index 0000000..7551596 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/connection_status.proto @@ -0,0 +1,120 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "ConnStatusProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +message DeviceConnectionStatus { + /* + * WiFi Status + */ + optional WifiConnectionStatus wifi = 1; + /* + * WiFi Status + */ + optional EthernetConnectionStatus ethernet = 2; + + /* + * Bluetooth Status + */ + optional BluetoothConnectionStatus bluetooth = 3; + + /* + * Serial Status + */ + optional SerialConnectionStatus serial = 4; +} + +/* + * WiFi connection status + */ +message WifiConnectionStatus { + /* + * Connection status + */ + NetworkConnectionStatus status = 1; + + /* + * WiFi access point SSID + */ + string ssid = 2; + + /* + * RSSI of wireless connection + */ + int32 rssi = 3; +} + +/* + * Ethernet connection status + */ +message EthernetConnectionStatus { + /* + * Connection status + */ + NetworkConnectionStatus status = 1; +} + +/* + * Ethernet or WiFi connection status + */ +message NetworkConnectionStatus { + /* + * IP address of device + */ + fixed32 ip_address = 1; + + /* + * Whether the device has an active connection or not + */ + bool is_connected = 2; + + /* + * Whether the device has an active connection to an MQTT broker or not + */ + bool is_mqtt_connected = 3; + + /* + * Whether the device is actively remote syslogging or not + */ + bool is_syslog_connected = 4; +} + +/* + * Bluetooth connection status + */ +message BluetoothConnectionStatus { + /* + * The pairing PIN for bluetooth + */ + uint32 pin = 1; + + /* + * RSSI of bluetooth connection + */ + int32 rssi = 2; + + /* + * Whether the device has an active connection or not + */ + bool is_connected = 3; +} + +/* + * Serial connection status + */ +message SerialConnectionStatus { + /* + * Serial baud rate + */ + uint32 baud = 1; + + /* + * Whether the device has an active connection or not + */ + bool is_connected = 2; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/deviceonly.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/deviceonly.options new file mode 100644 index 0000000..e9477a0 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/deviceonly.options @@ -0,0 +1,16 @@ +# options for nanopb +# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options + +# FIXME - max_count is actually 32 but we save/load this as one long string of preencoded MeshPacket bytes - not a big array in RAM +*DeviceState.receive_queue max_count:1 + +*ChannelFile.channels max_count:8 + +*OEMStore.oem_text max_size:40 +*OEMStore.oem_icon_bits max_size:2048 +*OEMStore.oem_aes_key max_size:32 + +*DeviceState.node_remote_hardware_pins max_count:12 + +*NodeInfoLite.channel int_size:8 +*NodeInfoLite.hops_away int_size:8 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/deviceonly.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/deviceonly.proto new file mode 100644 index 0000000..eef59a7 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/deviceonly.proto @@ -0,0 +1,258 @@ +syntax = "proto3"; + +package meshtastic; + +import "meshtastic/channel.proto"; +import "meshtastic/localonly.proto"; +import "meshtastic/mesh.proto"; +import "meshtastic/module_config.proto"; +import "meshtastic/telemetry.proto"; +import "nanopb.proto"; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "DeviceOnly"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; +option (nanopb_fileopt).include = ""; + + +/* + * Position with static location information only for NodeDBLite + */ +message PositionLite { + /* + * The new preferred location encoding, multiply by 1e-7 to get degrees + * in floating point + */ + sfixed32 latitude_i = 1; + + /* + * TODO: REPLACE + */ + sfixed32 longitude_i = 2; + + /* + * In meters above MSL (but see issue #359) + */ + int32 altitude = 3; + + /* + * This is usually not sent over the mesh (to save space), but it is sent + * from the phone so that the local device can set its RTC If it is sent over + * the mesh (because there are devices on the mesh without GPS), it will only + * be sent by devices which has a hardware GPS clock. + * seconds since 1970 + */ + fixed32 time = 4; + + /* + * TODO: REPLACE + */ + Position.LocSource location_source = 5; +} + +message NodeInfoLite { + /* + * The node number + */ + uint32 num = 1; + + /* + * The user info for this node + */ + User user = 2; + + /* + * This position data. Note: before 1.2.14 we would also store the last time we've heard from this node in position.time, that is no longer true. + * Position.time now indicates the last time we received a POSITION from that node. + */ + PositionLite position = 3; + + /* + * Returns the Signal-to-noise ratio (SNR) of the last received message, + * as measured by the receiver. Return SNR of the last received message in dB + */ + float snr = 4; + + /* + * Set to indicate the last time we received a packet from this node + */ + fixed32 last_heard = 5; + /* + * The latest device metrics for the node. + */ + DeviceMetrics device_metrics = 6; + + /* + * local channel index we heard that node on. Only populated if its not the default channel. + */ + uint32 channel = 7; + + /* + * True if we witnessed the node over MQTT instead of LoRA transport + */ + bool via_mqtt = 8; + + /* + * Number of hops away from us this node is (0 if adjacent) + */ + uint32 hops_away = 9; + + /* + * True if node is in our favorites list + * Persists between NodeDB internal clean ups + */ + bool is_favorite = 10; +} + +/* + * Font sizes for the device screen + */ +enum ScreenFonts { + /* + * TODO: REPLACE + */ + FONT_SMALL = 0; + + /* + * TODO: REPLACE + */ + FONT_MEDIUM = 1; + + /* + * TODO: REPLACE + */ + FONT_LARGE = 2; +} + + +/* + * This message is never sent over the wire, but it is used for serializing DB + * state to flash in the device code + * FIXME, since we write this each time we enter deep sleep (and have infinite + * flash) it would be better to use some sort of append only data structure for + * the receive queue and use the preferences store for the other stuff + */ +message DeviceState { + /* + * Read only settings/info about this node + */ + MyNodeInfo my_node = 2; + + /* + * My owner info + */ + User owner = 3; + + /* + * Received packets saved for delivery to the phone + */ + repeated MeshPacket receive_queue = 5; + + /* + * A version integer used to invalidate old save files when we make + * incompatible changes This integer is set at build time and is private to + * NodeDB.cpp in the device code. + */ + uint32 version = 8; + + /* + * We keep the last received text message (only) stored in the device flash, + * so we can show it on the screen. + * Might be null + */ + MeshPacket rx_text_message = 7; + + /* + * Used only during development. + * Indicates developer is testing and changes should never be saved to flash. + * Deprecated in 2.3.1 + */ + bool no_save = 9 [deprecated = true]; + + /* + * Some GPS receivers seem to have bogus settings from the factory, so we always do one factory reset. + */ + bool did_gps_reset = 11; + + /* + * We keep the last received waypoint stored in the device flash, + * so we can show it on the screen. + * Might be null + */ + MeshPacket rx_waypoint = 12; + + /* + * The mesh's nodes with their available gpio pins for RemoteHardware module + */ + repeated NodeRemoteHardwarePin node_remote_hardware_pins = 13; + + /* + * New lite version of NodeDB to decrease memory footprint + */ + repeated NodeInfoLite node_db_lite = 14 [(nanopb).callback_datatype = "std::vector"]; +} + +/* + * The on-disk saved channels + */ +message ChannelFile { + /* + * The channels our node knows about + */ + repeated Channel channels = 1; + + /* + * A version integer used to invalidate old save files when we make + * incompatible changes This integer is set at build time and is private to + * NodeDB.cpp in the device code. + */ + uint32 version = 2; +} + +/* + * This can be used for customizing the firmware distribution. If populated, + * show a secondary bootup screen with custom logo and text for 2.5 seconds. + */ +message OEMStore { + /* + * The Logo width in Px + */ + uint32 oem_icon_width = 1; + + /* + * The Logo height in Px + */ + uint32 oem_icon_height = 2; + + /* + * The Logo in XBM bytechar format + */ + bytes oem_icon_bits = 3; + + /* + * Use this font for the OEM text. + */ + ScreenFonts oem_font = 4; + + /* + * Use this font for the OEM text. + */ + string oem_text = 5; + + /* + * The default device encryption key, 16 or 32 byte + */ + bytes oem_aes_key = 6; + + /* + * A Preset LocalConfig to apply during factory reset + */ + LocalConfig oem_local_config = 7; + + /* + * A Preset LocalModuleConfig to apply during factory reset + */ + LocalModuleConfig oem_local_module_config = 8; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/exploiteers_pager.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/exploiteers_pager.options new file mode 100644 index 0000000..797341b --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/exploiteers_pager.options @@ -0,0 +1,5 @@ +# These options are required to create char[] fields from proto strings +# in the generated structs. + +*StoredMessage.sender max_size:40 +*StoredMessage.msg max_size:237 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/exploiteers_pager.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/exploiteers_pager.proto new file mode 100644 index 0000000..65f5a53 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/exploiteers_pager.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package meshtastic.exploiteers_pager; + + +message StoredMessage { + message DateTime { + int32 year = 1; + int32 month = 2; + int32 day = 3; + int32 hours = 4; + int32 minutes = 5; + int32 seconds = 6; + } + + DateTime datetime = 1; + string sender = 2; + uint32 senderId = 3; + string msg = 4; + uint32 dmToId = 5; +} + +message Settings { + int32 brightness = 1; + int32 contrast = 2; + + bool notify_light = 3; + enum NotifySound { + NONE = 0; + DEFAULT = 1; + } + NotifySound notify_sound = 4; + bool notify_vibrate = 5; +} \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/localonly.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/localonly.proto new file mode 100644 index 0000000..9694d7b --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/localonly.proto @@ -0,0 +1,135 @@ +syntax = "proto3"; + +package meshtastic; + +import "meshtastic/config.proto"; +import "meshtastic/module_config.proto"; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "LocalOnlyProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * Protobuf structures common to apponly.proto and deviceonly.proto + * This is never sent over the wire, only for local use + */ + +message LocalConfig { + /* + * The part of the config that is specific to the Device + */ + Config.DeviceConfig device = 1; + + /* + * The part of the config that is specific to the GPS Position + */ + Config.PositionConfig position = 2; + + /* + * The part of the config that is specific to the Power settings + */ + Config.PowerConfig power = 3; + + /* + * The part of the config that is specific to the Wifi Settings + */ + Config.NetworkConfig network = 4; + + /* + * The part of the config that is specific to the Display + */ + Config.DisplayConfig display = 5; + + /* + * The part of the config that is specific to the Lora Radio + */ + Config.LoRaConfig lora = 6; + + /* + * The part of the config that is specific to the Bluetooth settings + */ + Config.BluetoothConfig bluetooth = 7; + + /* + * A version integer used to invalidate old save files when we make + * incompatible changes This integer is set at build time and is private to + * NodeDB.cpp in the device code. + */ + uint32 version = 8; +} + +message LocalModuleConfig { + /* + * The part of the config that is specific to the MQTT module + */ + ModuleConfig.MQTTConfig mqtt = 1; + + /* + * The part of the config that is specific to the Serial module + */ + ModuleConfig.SerialConfig serial = 2; + + /* + * The part of the config that is specific to the ExternalNotification module + */ + ModuleConfig.ExternalNotificationConfig external_notification = 3; + + /* + * The part of the config that is specific to the Store & Forward module + */ + ModuleConfig.StoreForwardConfig store_forward = 4; + + /* + * The part of the config that is specific to the RangeTest module + */ + ModuleConfig.RangeTestConfig range_test = 5; + + /* + * The part of the config that is specific to the Telemetry module + */ + ModuleConfig.TelemetryConfig telemetry = 6; + + /* + * The part of the config that is specific to the Canned Message module + */ + ModuleConfig.CannedMessageConfig canned_message = 7; + + /* + * The part of the config that is specific to the Audio module + */ + ModuleConfig.AudioConfig audio = 9; + + /* + * The part of the config that is specific to the Remote Hardware module + */ + ModuleConfig.RemoteHardwareConfig remote_hardware = 10; + + /* + * The part of the config that is specific to the Neighbor Info module + */ + ModuleConfig.NeighborInfoConfig neighbor_info = 11; + + /* + * The part of the config that is specific to the Ambient Lighting module + */ + ModuleConfig.AmbientLightingConfig ambient_lighting = 12; + + /* + * The part of the config that is specific to the Detection Sensor module + */ + ModuleConfig.DetectionSensorConfig detection_sensor = 13; + + /* + * Paxcounter Config + */ + ModuleConfig.PaxcounterConfig paxcounter = 14; + + /* + * A version integer used to invalidate old save files when we make + * incompatible changes This integer is set at build time and is private to + * NodeDB.cpp in the device code. + */ + uint32 version = 8; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mesh.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mesh.options new file mode 100644 index 0000000..6dcd248 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mesh.options @@ -0,0 +1,65 @@ +# options for nanopb +# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options + +*macaddr max_size:6 fixed_length:true # macaddrs +*id max_size:16 # node id strings + +*User.long_name max_size:40 +*User.short_name max_size:5 + +*RouteDiscovery.route max_count:8 + +# note: this payload length is ONLY the bytes that are sent inside of the Data protobuf (excluding protobuf overhead). The 16 byte header is +# outside of this envelope +*Data.payload max_size:237 + +*NodeInfo.channel int_size:8 +*NodeInfo.hops_away int_size:8 + +# Big enough for 1.2.28.568032c-d +*MyNodeInfo.firmware_version max_size:18 + +*MyNodeInfo.air_period_tx max_count:8 +*MyNodeInfo.air_period_rx max_count:8 + +# Note: the actual limit (because of header bytes) on the size of encrypted payloads is 251 bytes, but I use 256 +# here because we might need to fill with zeros for padding to encryption block size (16 bytes per block) +*MeshPacket.encrypted max_size:256 +*MeshPacket.payload_variant anonymous_oneof:true +*MeshPacket.hop_limit int_size:8 +*MeshPacket.hop_start int_size:8 +*MeshPacket.channel int_size:8 + +*QueueStatus.res int_size:8 +*QueueStatus.free int_size:8 +*QueueStatus.maxlen int_size:8 + +*ToRadio.payload_variant anonymous_oneof:true + +*FromRadio.payload_variant anonymous_oneof:true + +*Routing.variant anonymous_oneof:true + +*LogRecord.message max_size:64 +*LogRecord.source max_size:8 + +# MyMessage.name max_size:40 +# or fixed_length or fixed_count, or max_count + +#This value may want to be a few bytes smaller to compensate for the parent fields. +*Compressed.data max_size:237 + +*Waypoint.name max_size:30 +*Waypoint.description max_size:100 + +*NeighborInfo.neighbors max_count:10 + +*DeviceMetadata.firmware_version max_size:18 + +*MqttClientProxyMessage.topic max_size:60 +*MqttClientProxyMessage.data max_size:435 +*MqttClientProxyMessage.text max_size:435 + +*ChunkedPayload.chunk_count int_size:16 +*ChunkedPayload.chunk_index int_size:16 +*ChunkedPayload.payload_chunk max_size:228 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mesh.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mesh.proto new file mode 100644 index 0000000..eb6b0df --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mesh.proto @@ -0,0 +1,1711 @@ +syntax = "proto3"; + +package meshtastic; + +import "meshtastic/channel.proto"; +import "meshtastic/config.proto"; +import "meshtastic/module_config.proto"; +import "meshtastic/portnums.proto"; +import "meshtastic/telemetry.proto"; +import "meshtastic/xmodem.proto"; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "MeshProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * a gps position + */ +message Position { + /* + * The new preferred location encoding, multiply by 1e-7 to get degrees + * in floating point + */ + sfixed32 latitude_i = 1; + + /* + * TODO: REPLACE + */ + sfixed32 longitude_i = 2; + + /* + * In meters above MSL (but see issue #359) + */ + int32 altitude = 3; + + /* + * This is usually not sent over the mesh (to save space), but it is sent + * from the phone so that the local device can set its time if it is sent over + * the mesh (because there are devices on the mesh without GPS or RTC). + * seconds since 1970 + */ + fixed32 time = 4; + + /* + * How the location was acquired: manual, onboard GPS, external (EUD) GPS + */ + enum LocSource { + /* + * TODO: REPLACE + */ + LOC_UNSET = 0; + + /* + * TODO: REPLACE + */ + LOC_MANUAL = 1; + + /* + * TODO: REPLACE + */ + LOC_INTERNAL = 2; + + /* + * TODO: REPLACE + */ + LOC_EXTERNAL = 3; + } + + /* + * TODO: REPLACE + */ + LocSource location_source = 5; + + /* + * How the altitude was acquired: manual, GPS int/ext, etc + * Default: same as location_source if present + */ + enum AltSource { + /* + * TODO: REPLACE + */ + ALT_UNSET = 0; + + /* + * TODO: REPLACE + */ + ALT_MANUAL = 1; + + /* + * TODO: REPLACE + */ + ALT_INTERNAL = 2; + + /* + * TODO: REPLACE + */ + ALT_EXTERNAL = 3; + + /* + * TODO: REPLACE + */ + ALT_BAROMETRIC = 4; + } + + /* + * TODO: REPLACE + */ + AltSource altitude_source = 6; + + /* + * Positional timestamp (actual timestamp of GPS solution) in integer epoch seconds + */ + fixed32 timestamp = 7; + + /* + * Pos. timestamp milliseconds adjustment (rarely available or required) + */ + int32 timestamp_millis_adjust = 8; + + /* + * HAE altitude in meters - can be used instead of MSL altitude + */ + sint32 altitude_hae = 9; + + /* + * Geoidal separation in meters + */ + sint32 altitude_geoidal_separation = 10; + + /* + * Horizontal, Vertical and Position Dilution of Precision, in 1/100 units + * - PDOP is sufficient for most cases + * - for higher precision scenarios, HDOP and VDOP can be used instead, + * in which case PDOP becomes redundant (PDOP=sqrt(HDOP^2 + VDOP^2)) + * TODO: REMOVE/INTEGRATE + */ + uint32 PDOP = 11; + + /* + * TODO: REPLACE + */ + uint32 HDOP = 12; + + /* + * TODO: REPLACE + */ + uint32 VDOP = 13; + + /* + * GPS accuracy (a hardware specific constant) in mm + * multiplied with DOP to calculate positional accuracy + * Default: "'bout three meters-ish" :) + */ + uint32 gps_accuracy = 14; + + /* + * Ground speed in m/s and True North TRACK in 1/100 degrees + * Clarification of terms: + * - "track" is the direction of motion (measured in horizontal plane) + * - "heading" is where the fuselage points (measured in horizontal plane) + * - "yaw" indicates a relative rotation about the vertical axis + * TODO: REMOVE/INTEGRATE + */ + uint32 ground_speed = 15; + + /* + * TODO: REPLACE + */ + uint32 ground_track = 16; + + /* + * GPS fix quality (from NMEA GxGGA statement or similar) + */ + uint32 fix_quality = 17; + + /* + * GPS fix type 2D/3D (from NMEA GxGSA statement) + */ + uint32 fix_type = 18; + + /* + * GPS "Satellites in View" number + */ + uint32 sats_in_view = 19; + + /* + * Sensor ID - in case multiple positioning sensors are being used + */ + uint32 sensor_id = 20; + + /* + * Estimated/expected time (in seconds) until next update: + * - if we update at fixed intervals of X seconds, use X + * - if we update at dynamic intervals (based on relative movement etc), + * but "AT LEAST every Y seconds", use Y + */ + uint32 next_update = 21; + + /* + * A sequence number, incremented with each Position message to help + * detect lost updates if needed + */ + uint32 seq_number = 22; + + /* + * Indicates the bits of precision set by the sending node + */ + uint32 precision_bits = 23; +} + +/* + * Note: these enum names must EXACTLY match the string used in the device + * bin/build-all.sh script. + * Because they will be used to find firmware filenames in the android app for OTA updates. + * To match the old style filenames, _ is converted to -, p is converted to . + */ +enum HardwareModel { + /* + * TODO: REPLACE + */ + UNSET = 0; + + /* + * TODO: REPLACE + */ + TLORA_V2 = 1; + + /* + * TODO: REPLACE + */ + TLORA_V1 = 2; + + /* + * TODO: REPLACE + */ + TLORA_V2_1_1P6 = 3; + + /* + * TODO: REPLACE + */ + TBEAM = 4; + + /* + * The original heltec WiFi_Lora_32_V2, which had battery voltage sensing hooked to GPIO 13 + * (see HELTEC_V2 for the new version). + */ + HELTEC_V2_0 = 5; + + /* + * TODO: REPLACE + */ + TBEAM_V0P7 = 6; + + /* + * TODO: REPLACE + */ + T_ECHO = 7; + + /* + * TODO: REPLACE + */ + TLORA_V1_1P3 = 8; + + /* + * TODO: REPLACE + */ + RAK4631 = 9; + + /* + * The new version of the heltec WiFi_Lora_32_V2 board that has battery sensing hooked to GPIO 37. + * Sadly they did not update anything on the silkscreen to identify this board + */ + HELTEC_V2_1 = 10; + + /* + * Ancient heltec WiFi_Lora_32 board + */ + HELTEC_V1 = 11; + + /* + * New T-BEAM with ESP32-S3 CPU + */ + LILYGO_TBEAM_S3_CORE = 12; + + /* + * RAK WisBlock ESP32 core: https://docs.rakwireless.com/Product-Categories/WisBlock/RAK11200/Overview/ + */ + RAK11200 = 13; + + /* + * B&Q Consulting Nano Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:nano + */ + NANO_G1 = 14; + + /* + * TODO: REPLACE + */ + TLORA_V2_1_1P8 = 15; + + /* + * TODO: REPLACE + */ + TLORA_T3_S3 = 16; + + /* + * B&Q Consulting Nano G1 Explorer: https://wiki.uniteng.com/en/meshtastic/nano-g1-explorer + */ + NANO_G1_EXPLORER = 17; + + /* + * B&Q Consulting Nano G2 Ultra: https://wiki.uniteng.com/en/meshtastic/nano-g2-ultra + */ + NANO_G2_ULTRA = 18; + + /* + * LoRAType device: https://loratype.org/ + */ + LORA_TYPE = 19; + + /* + * wiphone https://www.wiphone.io/ + */ + WIPHONE = 20; + + /* + * WIO Tracker WM1110 family from Seeed Studio. Includes wio-1110-tracker and wio-1110-sdk + */ + WIO_WM1110 = 21; + + /* + * RAK2560 Solar base station based on RAK4630 + */ + RAK2560 = 22; + + /* + * B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station + */ + STATION_G1 = 25; + + /* + * RAK11310 (RP2040 + SX1262) + */ + RAK11310 = 26; + + /* + * Makerfabs SenseLoRA Receiver (RP2040 + RFM96) + */ + SENSELORA_RP2040 = 27; + + /* + * Makerfabs SenseLoRA Industrial Monitor (ESP32-S3 + RFM96) + */ + SENSELORA_S3 = 28; + + /* + * Canary Radio Company - CanaryOne: https://canaryradio.io/products/canaryone + */ + CANARYONE = 29; + + /* + * Waveshare RP2040 LoRa - https://www.waveshare.com/rp2040-lora.htm + */ + RP2040_LORA = 30; + + /* + * B&Q Consulting Station G2: https://wiki.uniteng.com/en/meshtastic/station-g2 + */ + STATION_G2 = 31; + + /* + * --------------------------------------------------------------------------- + * Less common/prototype boards listed here (needs one more byte over the air) + * --------------------------------------------------------------------------- + */ + LORA_RELAY_V1 = 32; + + /* + * TODO: REPLACE + */ + NRF52840DK = 33; + + /* + * TODO: REPLACE + */ + PPR = 34; + + /* + * TODO: REPLACE + */ + GENIEBLOCKS = 35; + + /* + * TODO: REPLACE + */ + NRF52_UNKNOWN = 36; + + /* + * TODO: REPLACE + */ + PORTDUINO = 37; + + /* + * The simulator built into the android app + */ + ANDROID_SIM = 38; + + /* + * Custom DIY device based on @NanoVHF schematics: https://github.com/NanoVHF/Meshtastic-DIY/tree/main/Schematics + */ + DIY_V1 = 39; + + /* + * nRF52840 Dongle : https://www.nordicsemi.com/Products/Development-hardware/nrf52840-dongle/ + */ + NRF52840_PCA10059 = 40; + + /* + * Custom Disaster Radio esp32 v3 device https://github.com/sudomesh/disaster-radio/tree/master/hardware/board_esp32_v3 + */ + DR_DEV = 41; + + /* + * M5 esp32 based MCU modules with enclosure, TFT and LORA Shields. All Variants (Basic, Core, Fire, Core2, Paper) https://m5stack.com/ + */ + M5STACK = 42; + + /* + * New Heltec LoRA32 with ESP32-S3 CPU + */ + HELTEC_V3 = 43; + + /* + * New Heltec Wireless Stick Lite with ESP32-S3 CPU + */ + HELTEC_WSL_V3 = 44; + + /* + * New BETAFPV ELRS Micro TX Module 2.4G with ESP32 CPU + */ + BETAFPV_2400_TX = 45; + + /* + * BetaFPV ExpressLRS "Nano" TX Module 900MHz with ESP32 CPU + */ + BETAFPV_900_NANO_TX = 46; + + /* + * Raspberry Pi Pico (W) with Waveshare SX1262 LoRa Node Module + */ + RPI_PICO = 47; + + /* + * Heltec Wireless Tracker with ESP32-S3 CPU, built-in GPS, and TFT + * Newer V1.1, version is written on the PCB near the display. + */ + HELTEC_WIRELESS_TRACKER = 48; + + /* + * Heltec Wireless Paper with ESP32-S3 CPU and E-Ink display + */ + HELTEC_WIRELESS_PAPER = 49; + + /* + * LilyGo T-Deck with ESP32-S3 CPU, Keyboard and IPS display + */ + T_DECK = 50; + + /* + * LilyGo T-Watch S3 with ESP32-S3 CPU and IPS display + */ + T_WATCH_S3 = 51; + + /* + * Bobricius Picomputer with ESP32-S3 CPU, Keyboard and IPS display + */ + PICOMPUTER_S3 = 52; + + /* + * Heltec HT-CT62 with ESP32-C3 CPU and SX1262 LoRa + */ + HELTEC_HT62 = 53; + + /* + * EBYTE SPI LoRa module and ESP32-S3 + */ + EBYTE_ESP32_S3 = 54; + + /* + * Waveshare ESP32-S3-PICO with PICO LoRa HAT and 2.9inch e-Ink + */ + ESP32_S3_PICO = 55; + + /* + * CircuitMess Chatter 2 LLCC68 Lora Module and ESP32 Wroom + * Lora module can be swapped out for a Heltec RA-62 which is "almost" pin compatible + * with one cut and one jumper Meshtastic works + */ + CHATTER_2 = 56; + + /* + * Heltec Wireless Paper, With ESP32-S3 CPU and E-Ink display + * Older "V1.0" Variant, has no "version sticker" + * E-Ink model is DEPG0213BNS800 + * Tab on the screen protector is RED + * Flex connector marking is FPC-7528B + */ + HELTEC_WIRELESS_PAPER_V1_0 = 57; + + /* + * Heltec Wireless Tracker with ESP32-S3 CPU, built-in GPS, and TFT + * Older "V1.0" Variant + */ + HELTEC_WIRELESS_TRACKER_V1_0 = 58; + + /* + * unPhone with ESP32-S3, TFT touchscreen, LSM6DS3TR-C accelerometer and gyroscope + */ + UNPHONE = 59; + + /* + * Teledatics TD-LORAC NRF52840 based M.2 LoRA module + * Compatible with the TD-WRLS development board + */ + TD_LORAC = 60; + + /* + * CDEBYTE EoRa-S3 board using their own MM modules, clone of LILYGO T3S3 + */ + CDEBYTE_EORA_S3 = 61; + + /* + * TWC_MESH_V4 + * Adafruit NRF52840 feather express with SX1262, SSD1306 OLED and NEO6M GPS + */ + TWC_MESH_V4 = 62; + + /* + * NRF52_PROMICRO_DIY + * Promicro NRF52840 with SX1262/LLCC68, SSD1306 OLED and NEO6M GPS + */ + NRF52_PROMICRO_DIY = 63; + + /* + * RadioMaster 900 Bandit Nano, https://www.radiomasterrc.com/products/bandit-nano-expresslrs-rf-module + * ESP32-D0WDQ6 With SX1276/SKY66122, SSD1306 OLED and No GPS + */ + RADIOMASTER_900_BANDIT_NANO = 64; + + /* + * Heltec Capsule Sensor V3 with ESP32-S3 CPU, Portable LoRa device that can replace GNSS modules or sensors + */ + HELTEC_CAPSULE_SENSOR_V3 = 65; + + /** + * EXPLOITEERS_PAGER + * exploitee.rs Hacker Pager. Retro-styled pager with Meshtastic messaging and LoRa utilities. ESP32-S3, SX1262. + */ + EXPLOITEERS_PAGER = 66; + + /* + * ------------------------------------------------------------------------------------------------------------------------------------------ + * Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. + * ------------------------------------------------------------------------------------------------------------------------------------------ + */ + PRIVATE_HW = 255; +} + +/* + * Broadcast when a newly powered mesh node wants to find a node num it can use + * Sent from the phone over bluetooth to set the user id for the owner of this node. + * Also sent from nodes to each other when a new node signs on (so all clients can have this info) + * The algorithm is as follows: + * when a node starts up, it broadcasts their user and the normal flow is for all + * other nodes to reply with their User as well (so the new node can build its nodedb) + * If a node ever receives a User (not just the first broadcast) message where + * the sender node number equals our node number, that indicates a collision has + * occurred and the following steps should happen: + * If the receiving node (that was already in the mesh)'s macaddr is LOWER than the + * new User who just tried to sign in: it gets to keep its nodenum. + * We send a broadcast message of OUR User (we use a broadcast so that the other node can + * receive our message, considering we have the same id - it also serves to let + * observers correct their nodedb) - this case is rare so it should be okay. + * If any node receives a User where the macaddr is GTE than their local macaddr, + * they have been vetoed and should pick a new random nodenum (filtering against + * whatever it knows about the nodedb) and rebroadcast their User. + * A few nodenums are reserved and will never be requested: + * 0xff - broadcast + * 0 through 3 - for future use + */ +message User { + /* + * A globally unique ID string for this user. + * In the case of Signal that would mean +16504442323, for the default macaddr derived id it would be !<8 hexidecimal bytes>. + * Note: app developers are encouraged to also use the following standard + * node IDs "^all" (for broadcast), "^local" (for the locally connected node) + */ + string id = 1; + + /* + * A full name for this user, i.e. "Kevin Hester" + */ + string long_name = 2; + + /* + * A VERY short name, ideally two characters. + * Suitable for a tiny OLED screen + */ + string short_name = 3; + + /* + * Deprecated in Meshtastic 2.1.x + * This is the addr of the radio. + * Not populated by the phone, but added by the esp32 when broadcasting + */ + bytes macaddr = 4 [deprecated = true]; + + /* + * TBEAM, HELTEC, etc... + * Starting in 1.2.11 moved to hw_model enum in the NodeInfo object. + * Apps will still need the string here for older builds + * (so OTA update can find the right image), but if the enum is available it will be used instead. + */ + HardwareModel hw_model = 5; + + /* + * In some regions Ham radio operators have different bandwidth limitations than others. + * If this user is a licensed operator, set this flag. + * Also, "long_name" should be their licence number. + */ + bool is_licensed = 6; + + /* + * Indicates that the user's role in the mesh + */ + Config.DeviceConfig.Role role = 7; +} + +/* + * A message used in our Dynamic Source Routing protocol (RFC 4728 based) + */ +message RouteDiscovery { + /* + * The list of nodenums this packet has visited so far + */ + repeated fixed32 route = 1; +} + +/* + * A Routing control Data packet handled by the routing module + */ +message Routing { + /* + * A failure in delivering a message (usually used for routing control messages, but might be provided in addition to ack.fail_id to provide + * details on the type of failure). + */ + enum Error { + /* + * This message is not a failure + */ + NONE = 0; + + /* + * Our node doesn't have a route to the requested destination anymore. + */ + NO_ROUTE = 1; + + /* + * We received a nak while trying to forward on your behalf + */ + GOT_NAK = 2; + + /* + * TODO: REPLACE + */ + TIMEOUT = 3; + + /* + * No suitable interface could be found for delivering this packet + */ + NO_INTERFACE = 4; + + /* + * We reached the max retransmission count (typically for naive flood routing) + */ + MAX_RETRANSMIT = 5; + + /* + * No suitable channel was found for sending this packet (i.e. was requested channel index disabled?) + */ + NO_CHANNEL = 6; + + /* + * The packet was too big for sending (exceeds interface MTU after encoding) + */ + TOO_LARGE = 7; + + /* + * The request had want_response set, the request reached the destination node, but no service on that node wants to send a response + * (possibly due to bad channel permissions) + */ + NO_RESPONSE = 8; + + /* + * Cannot send currently because duty cycle regulations will be violated. + */ + DUTY_CYCLE_LIMIT = 9; + + /* + * The application layer service on the remote node received your request, but considered your request somehow invalid + */ + BAD_REQUEST = 32; + + /* + * The application layer service on the remote node received your request, but considered your request not authorized + * (i.e you did not send the request on the required bound channel) + */ + NOT_AUTHORIZED = 33; + } + + oneof variant { + /* + * A route request going from the requester + */ + RouteDiscovery route_request = 1; + + /* + * A route reply + */ + RouteDiscovery route_reply = 2; + + /* + * A failure in delivering a message (usually used for routing control messages, but might be provided + * in addition to ack.fail_id to provide details on the type of failure). + */ + Error error_reason = 3; + } +} + +/* + * (Formerly called SubPacket) + * The payload portion fo a packet, this is the actual bytes that are sent + * inside a radio packet (because from/to are broken out by the comms library) + */ +message Data { + /* + * Formerly named typ and of type Type + */ + PortNum portnum = 1; + + /* + * TODO: REPLACE + */ + bytes payload = 2; + + /* + * Not normally used, but for testing a sender can request that recipient + * responds in kind (i.e. if it received a position, it should unicast back it's position). + * Note: that if you set this on a broadcast you will receive many replies. + */ + bool want_response = 3; + + /* + * The address of the destination node. + * This field is is filled in by the mesh radio device software, application + * layer software should never need it. + * RouteDiscovery messages _must_ populate this. + * Other message types might need to if they are doing multihop routing. + */ + fixed32 dest = 4; + + /* + * The address of the original sender for this message. + * This field should _only_ be populated for reliable multihop packets (to keep + * packets small). + */ + fixed32 source = 5; + + /* + * Only used in routing or response messages. + * Indicates the original message ID that this message is reporting failure on. (formerly called original_id) + */ + fixed32 request_id = 6; + + /* + * If set, this message is intened to be a reply to a previously sent message with the defined id. + */ + fixed32 reply_id = 7; + + /* + * Defaults to false. If true, then what is in the payload should be treated as an emoji like giving + * a message a heart or poop emoji. + */ + fixed32 emoji = 8; +} + +/* + * Waypoint message, used to share arbitrary locations across the mesh + */ +message Waypoint { + /* + * Id of the waypoint + */ + uint32 id = 1; + + /* + * latitude_i + */ + sfixed32 latitude_i = 2; + + /* + * longitude_i + */ + sfixed32 longitude_i = 3; + + /* + * Time the waypoint is to expire (epoch) + */ + uint32 expire = 4; + + /* + * If greater than zero, treat the value as a nodenum only allowing them to update the waypoint. + * If zero, the waypoint is open to be edited by any member of the mesh. + */ + uint32 locked_to = 5; + + /* + * Name of the waypoint - max 30 chars + */ + string name = 6; + + /* + * Description of the waypoint - max 100 chars + */ + string description = 7; + + /* + * Designator icon for the waypoint in the form of a unicode emoji + */ + fixed32 icon = 8; +} + +/* + * This message will be proxied over the PhoneAPI for the client to deliver to the MQTT server + */ +message MqttClientProxyMessage { + /* + * The MQTT topic this message will be sent /received on + */ + string topic = 1; + + /* + * The actual service envelope payload or text for mqtt pub / sub + */ + oneof payload_variant { + /* + * Bytes + */ + bytes data = 2; + + /* + * Text + */ + string text = 3; + } + + /* + * Whether the message should be retained (or not) + */ + bool retained = 4; +} + +/* + * A packet envelope sent/received over the mesh + * only payload_variant is sent in the payload portion of the LORA packet. + * The other fields are either not sent at all, or sent in the special 16 byte LORA header. + */ +message MeshPacket { + /* + * The priority of this message for sending. + * Higher priorities are sent first (when managing the transmit queue). + * This field is never sent over the air, it is only used internally inside of a local device node. + * API clients (either on the local node or connected directly to the node) + * can set this parameter if necessary. + * (values must be <= 127 to keep protobuf field to one byte in size. + * Detailed background on this field: + * I noticed a funny side effect of lora being so slow: Usually when making + * a protocol there isn’t much need to use message priority to change the order + * of transmission (because interfaces are fairly fast). + * But for lora where packets can take a few seconds each, it is very important + * to make sure that critical packets are sent ASAP. + * In the case of meshtastic that means we want to send protocol acks as soon as possible + * (to prevent unneeded retransmissions), we want routing messages to be sent next, + * then messages marked as reliable and finally 'background' packets like periodic position updates. + * So I bit the bullet and implemented a new (internal - not sent over the air) + * field in MeshPacket called 'priority'. + * And the transmission queue in the router object is now a priority queue. + */ + enum Priority { + /* + * Treated as Priority.DEFAULT + */ + UNSET = 0; + + /* + * TODO: REPLACE + */ + MIN = 1; + + /* + * Background position updates are sent with very low priority - + * if the link is super congested they might not go out at all + */ + BACKGROUND = 10; + + /* + * This priority is used for most messages that don't have a priority set + */ + DEFAULT = 64; + + /* + * If priority is unset but the message is marked as want_ack, + * assume it is important and use a slightly higher priority + */ + RELIABLE = 70; + + /* + * Ack/naks are sent with very high priority to ensure that retransmission + * stops as soon as possible + */ + ACK = 120; + + /* + * TODO: REPLACE + */ + MAX = 127; + } + + /* + * Identify if this is a delayed packet + */ + enum Delayed { + /* + * If unset, the message is being sent in real time. + */ + NO_DELAY = 0; + + /* + * The message is delayed and was originally a broadcast + */ + DELAYED_BROADCAST = 1; + + /* + * The message is delayed and was originally a direct message + */ + DELAYED_DIRECT = 2; + } + + /* + * The sending node number. + * Note: Our crypto implementation uses this field as well. + * See [crypto](/docs/overview/encryption) for details. + */ + fixed32 from = 1; + + /* + * The (immediate) destination for this packet + */ + fixed32 to = 2; + + /* + * (Usually) If set, this indicates the index in the secondary_channels table that this packet was sent/received on. + * If unset, packet was on the primary channel. + * A particular node might know only a subset of channels in use on the mesh. + * Therefore channel_index is inherently a local concept and meaningless to send between nodes. + * Very briefly, while sending and receiving deep inside the device Router code, this field instead + * contains the 'channel hash' instead of the index. + * This 'trick' is only used while the payload_variant is an 'encrypted'. + */ + uint32 channel = 3; + + /* + * Internally to the mesh radios we will route SubPackets encrypted per [this](docs/developers/firmware/encryption). + * However, when a particular node has the correct + * key to decode a particular packet, it will decode the payload into a SubPacket protobuf structure. + * Software outside of the device nodes will never encounter a packet where + * "decoded" is not populated (i.e. any encryption/decryption happens before reaching the applications) + * The numeric IDs for these fields were selected to keep backwards compatibility with old applications. + */ + + oneof payload_variant { + /* + * TODO: REPLACE + */ + Data decoded = 4; + + /* + * TODO: REPLACE + */ + bytes encrypted = 5; + } + + /* + * A unique ID for this packet. + * Always 0 for no-ack packets or non broadcast packets (and therefore take zero bytes of space). + * Otherwise a unique ID for this packet, useful for flooding algorithms. + * ID only needs to be unique on a _per sender_ basis, and it only + * needs to be unique for a few minutes (long enough to last for the length of + * any ACK or the completion of a mesh broadcast flood). + * Note: Our crypto implementation uses this id as well. + * See [crypto](/docs/overview/encryption) for details. + */ + fixed32 id = 6; + + /* + * The time this message was received by the esp32 (secs since 1970). + * Note: this field is _never_ sent on the radio link itself (to save space) Times + * are typically not sent over the mesh, but they will be added to any Packet + * (chain of SubPacket) sent to the phone (so the phone can know exact time of reception) + */ + fixed32 rx_time = 7; + + /* + * *Never* sent over the radio links. + * Set during reception to indicate the SNR of this packet. + * Used to collect statistics on current link quality. + */ + float rx_snr = 8; + + /* + * If unset treated as zero (no forwarding, send to adjacent nodes only) + * if 1, allow hopping through one node, etc... + * For our usecase real world topologies probably have a max of about 3. + * This field is normally placed into a few of bits in the header. + */ + uint32 hop_limit = 9; + + /* + * This packet is being sent as a reliable message, we would prefer it to arrive at the destination. + * We would like to receive a ack packet in response. + * Broadcasts messages treat this flag specially: Since acks for broadcasts would + * rapidly flood the channel, the normal ack behavior is suppressed. + * Instead, the original sender listens to see if at least one node is rebroadcasting this packet (because naive flooding algorithm). + * If it hears that the odds (given typical LoRa topologies) the odds are very high that every node should eventually receive the message. + * So FloodingRouter.cpp generates an implicit ack which is delivered to the original sender. + * If after some time we don't hear anyone rebroadcast our packet, we will timeout and retransmit, using the regular resend logic. + * Note: This flag is normally sent in a flag bit in the header when sent over the wire + */ + bool want_ack = 10; + + /* + * The priority of this message for sending. + * See MeshPacket.Priority description for more details. + */ + Priority priority = 11; + + /* + * rssi of received packet. Only sent to phone for dispay purposes. + */ + int32 rx_rssi = 12; + + /* + * Describe if this message is delayed + */ + Delayed delayed = 13 [deprecated = true]; + + /* + * Describes whether this packet passed via MQTT somewhere along the path it currently took. + */ + bool via_mqtt = 14; + + /* + * Hop limit with which the original packet started. Sent via LoRa using three bits in the unencrypted header. + * When receiving a packet, the difference between hop_start and hop_limit gives how many hops it traveled. + */ + uint32 hop_start = 15; +} + +/* + * Shared constants between device and phone + */ +enum Constants { + /* + * First enum must be zero, and we are just using this enum to + * pass int constants between two very different environments + */ + ZERO = 0; + + /* + * From mesh.options + * note: this payload length is ONLY the bytes that are sent inside of the Data protobuf (excluding protobuf overhead). The 16 byte header is + * outside of this envelope + */ + DATA_PAYLOAD_LEN = 237; +} + +/* + * The bluetooth to device link: + * Old BTLE protocol docs from TODO, merge in above and make real docs... + * use protocol buffers, and NanoPB + * messages from device to phone: + * POSITION_UPDATE (..., time) + * TEXT_RECEIVED(from, text, time) + * OPAQUE_RECEIVED(from, payload, time) (for signal messages or other applications) + * messages from phone to device: + * SET_MYID(id, human readable long, human readable short) (send down the unique ID + * string used for this node, a human readable string shown for that id, and a very + * short human readable string suitable for oled screen) SEND_OPAQUE(dest, payload) + * (for signal messages or other applications) SEND_TEXT(dest, text) Get all + * nodes() (returns list of nodes, with full info, last time seen, loc, battery + * level etc) SET_CONFIG (switches device to a new set of radio params and + * preshared key, drops all existing nodes, force our node to rejoin this new group) + * Full information about a node on the mesh + */ +message NodeInfo { + /* + * The node number + */ + uint32 num = 1; + + /* + * The user info for this node + */ + User user = 2; + + /* + * This position data. Note: before 1.2.14 we would also store the last time we've heard from this node in position.time, that is no longer true. + * Position.time now indicates the last time we received a POSITION from that node. + */ + Position position = 3; + + /* + * Returns the Signal-to-noise ratio (SNR) of the last received message, + * as measured by the receiver. Return SNR of the last received message in dB + */ + float snr = 4; + + /* + * TODO: REMOVE/INTEGRATE + * Returns the last measured frequency error. + * The LoRa receiver estimates the frequency offset between the receiver + * center frequency and that of the received LoRa signal. This function + * returns the estimates offset (in Hz) of the last received message. + * Caution: this measurement is not absolute, but is measured relative to the + * local receiver's oscillator. Apparent errors may be due to the + * transmitter, the receiver or both. \return The estimated center frequency + * offset in Hz of the last received message. + * int32 frequency_error = 6; + * enum RouteState { + * Invalid = 0; + * Discovering = 1; + * Valid = 2; + * } + * Not needed? + * RouteState route = 4; + */ + + /* + * TODO: REMOVE/INTEGRATE + * Not currently used (till full DSR deployment?) Our current preferred node node for routing - might be the same as num if + * we are adjacent Or zero if we don't yet know a route to this node. + * fixed32 next_hop = 5; + */ + + /* + * Set to indicate the last time we received a packet from this node + */ + fixed32 last_heard = 5; + /* + * The latest device metrics for the node. + */ + DeviceMetrics device_metrics = 6; + + /* + * local channel index we heard that node on. Only populated if its not the default channel. + */ + uint32 channel = 7; + + /* + * True if we witnessed the node over MQTT instead of LoRA transport + */ + bool via_mqtt = 8; + + /* + * Number of hops away from us this node is (0 if adjacent) + */ + uint32 hops_away = 9; + + /* + * True if node is in our favorites list + * Persists between NodeDB internal clean ups + */ + bool is_favorite = 10; +} + +/* + * Error codes for critical errors + * The device might report these fault codes on the screen. + * If you encounter a fault code, please post on the meshtastic.discourse.group + * and we'll try to help. + */ +enum CriticalErrorCode { + /* + * TODO: REPLACE + */ + NONE = 0; + + /* + * A software bug was detected while trying to send lora + */ + TX_WATCHDOG = 1; + + /* + * A software bug was detected on entry to sleep + */ + SLEEP_ENTER_WAIT = 2; + + /* + * No Lora radio hardware could be found + */ + NO_RADIO = 3; + + /* + * Not normally used + */ + UNSPECIFIED = 4; + + /* + * We failed while configuring a UBlox GPS + */ + UBLOX_UNIT_FAILED = 5; + + /* + * This board was expected to have a power management chip and it is missing or broken + */ + NO_AXP192 = 6; + + /* + * The channel tried to set a radio setting which is not supported by this chipset, + * radio comms settings are now undefined. + */ + INVALID_RADIO_SETTING = 7; + + /* + * Radio transmit hardware failure. We sent data to the radio chip, but it didn't + * reply with an interrupt. + */ + TRANSMIT_FAILED = 8; + + /* + * We detected that the main CPU voltage dropped below the minimum acceptable value + */ + BROWNOUT = 9; + + /* Selftest of SX1262 radio chip failed */ + SX1262_FAILURE = 10; + + /* + * A (likely software but possibly hardware) failure was detected while trying to send packets. + * If this occurs on your board, please post in the forum so that we can ask you to collect some information to allow fixing this bug + */ + RADIO_SPI_BUG = 11; +} + +/* + * Unique local debugging info for this node + * Note: we don't include position or the user info, because that will come in the + * Sent to the phone in response to WantNodes. + */ +message MyNodeInfo { + /* + * Tells the phone what our node number is, default starting value is + * lowbyte of macaddr, but it will be fixed if that is already in use + */ + uint32 my_node_num = 1; + + /* + * The total number of reboots this node has ever encountered + * (well - since the last time we discarded preferences) + */ + uint32 reboot_count = 8; + + /* + * The minimum app version that can talk to this device. + * Phone/PC apps should compare this to their build number and if too low tell the user they must update their app + */ + uint32 min_app_version = 11; +} + +/* + * Debug output from the device. + * To minimize the size of records inside the device code, if a time/source/level is not set + * on the message it is assumed to be a continuation of the previously sent message. + * This allows the device code to use fixed maxlen 64 byte strings for messages, + * and then extend as needed by emitting multiple records. + */ +message LogRecord { + /* + * Log levels, chosen to match python logging conventions. + */ + enum Level { + /* + * Log levels, chosen to match python logging conventions. + */ + UNSET = 0; + + /* + * Log levels, chosen to match python logging conventions. + */ + CRITICAL = 50; + + /* + * Log levels, chosen to match python logging conventions. + */ + ERROR = 40; + + /* + * Log levels, chosen to match python logging conventions. + */ + WARNING = 30; + + /* + * Log levels, chosen to match python logging conventions. + */ + INFO = 20; + + /* + * Log levels, chosen to match python logging conventions. + */ + DEBUG = 10; + + /* + * Log levels, chosen to match python logging conventions. + */ + TRACE = 5; + } + + /* + * Log levels, chosen to match python logging conventions. + */ + string message = 1; + + /* + * Seconds since 1970 - or 0 for unknown/unset + */ + fixed32 time = 2; + + /* + * Usually based on thread name - if known + */ + string source = 3; + + /* + * Not yet set + */ + Level level = 4; +} + +message QueueStatus { + /* Last attempt to queue status, ErrorCode */ + int32 res = 1; + + /* Free entries in the outgoing queue */ + uint32 free = 2; + + /* Maximum entries in the outgoing queue */ + uint32 maxlen = 3; + + /* What was mesh packet id that generated this response? */ + uint32 mesh_packet_id = 4; +} + +/* + * Packets from the radio to the phone will appear on the fromRadio characteristic. + * It will support READ and NOTIFY. When a new packet arrives the device will BLE notify? + * It will sit in that descriptor until consumed by the phone, + * at which point the next item in the FIFO will be populated. + */ +message FromRadio { + /* + * The packet id, used to allow the phone to request missing read packets from the FIFO, + * see our bluetooth docs + */ + uint32 id = 1; + + /* + * Log levels, chosen to match python logging conventions. + */ + oneof payload_variant { + /* + * Log levels, chosen to match python logging conventions. + */ + MeshPacket packet = 2; + + /* + * Tells the phone what our node number is, can be -1 if we've not yet joined a mesh. + * NOTE: This ID must not change - to keep (minimal) compatibility with <1.2 version of android apps. + */ + MyNodeInfo my_info = 3; + + /* + * One packet is sent for each node in the on radio DB + * starts over with the first node in our DB + */ + NodeInfo node_info = 4; + + /* + * Include a part of the config (was: RadioConfig radio) + */ + Config config = 5; + + /* + * Set to send debug console output over our protobuf stream + */ + LogRecord log_record = 6; + + /* + * Sent as true once the device has finished sending all of the responses to want_config + * recipient should check if this ID matches our original request nonce, if + * not, it means your config responses haven't started yet. + * NOTE: This ID must not change - to keep (minimal) compatibility with <1.2 version of android apps. + */ + uint32 config_complete_id = 7; + + /* + * Sent to tell clients the radio has just rebooted. + * Set to true if present. + * Not used on all transports, currently just used for the serial console. + * NOTE: This ID must not change - to keep (minimal) compatibility with <1.2 version of android apps. + */ + bool rebooted = 8; + + /* + * Include module config + */ + ModuleConfig moduleConfig = 9; + + /* + * One packet is sent for each channel + */ + Channel channel = 10; + + /* + * Queue status info + */ + QueueStatus queueStatus = 11; + + /* + * File Transfer Chunk + */ + XModem xmodemPacket = 12; + + /* + * Device metadata message + */ + DeviceMetadata metadata = 13; + + /* + * MQTT Client Proxy Message (device sending to client / phone for publishing to MQTT) + */ + MqttClientProxyMessage mqttClientProxyMessage = 14; + } +} + +/* + * Packets/commands to the radio will be written (reliably) to the toRadio characteristic. + * Once the write completes the phone can assume it is handled. + */ +message ToRadio { + /* + * Log levels, chosen to match python logging conventions. + */ + oneof payload_variant { + /* + * Send this packet on the mesh + */ + MeshPacket packet = 1; + + /* + * Phone wants radio to send full node db to the phone, This is + * typically the first packet sent to the radio when the phone gets a + * bluetooth connection. The radio will respond by sending back a + * MyNodeInfo, a owner, a radio config and a series of + * FromRadio.node_infos, and config_complete + * the integer you write into this field will be reported back in the + * config_complete_id response this allows clients to never be confused by + * a stale old partially sent config. + */ + uint32 want_config_id = 3; + + /* + * Tell API server we are disconnecting now. + * This is useful for serial links where there is no hardware/protocol based notification that the client has dropped the link. + * (Sending this message is optional for clients) + */ + bool disconnect = 4; + + /* + * File Transfer Chunk + */ + + XModem xmodemPacket = 5; + + /* + * MQTT Client Proxy Message (for client / phone subscribed to MQTT sending to device) + */ + MqttClientProxyMessage mqttClientProxyMessage = 6; + + /* + * Heartbeat message (used to keep the device connection awake on serial) + */ + Heartbeat heartbeat = 7; + } +} + +/* + * Compressed message payload + */ +message Compressed { + /* + * PortNum to determine the how to handle the compressed payload. + */ + PortNum portnum = 1; + + /* + * Compressed data. + */ + bytes data = 2; +} + +/* + * Full info on edges for a single node + */ +message NeighborInfo { + /* + * The node ID of the node sending info on its neighbors + */ + uint32 node_id = 1; + /* + * Field to pass neighbor info for the next sending cycle + */ + uint32 last_sent_by_id = 2; + + /* + * Broadcast interval of the represented node (in seconds) + */ + uint32 node_broadcast_interval_secs = 3; + /* + * The list of out edges from this node + */ + repeated Neighbor neighbors = 4; +} + +/* + * A single edge in the mesh + */ +message Neighbor { + /* + * Node ID of neighbor + */ + uint32 node_id = 1; + + /* + * SNR of last heard message + */ + float snr = 2; + + /* + * Reception time (in secs since 1970) of last message that was last sent by this ID. + * Note: this is for local storage only and will not be sent out over the mesh. + */ + fixed32 last_rx_time = 3; + + /* + * Broadcast interval of this neighbor (in seconds). + * Note: this is for local storage only and will not be sent out over the mesh. + */ + uint32 node_broadcast_interval_secs = 4; +} + +/* + * Device metadata response + */ +message DeviceMetadata { + /* + * Device firmware version string + */ + string firmware_version = 1; + + /* + * Device state version + */ + uint32 device_state_version = 2; + + /* + * Indicates whether the device can shutdown CPU natively or via power management chip + */ + bool canShutdown = 3; + + /* + * Indicates that the device has native wifi capability + */ + bool hasWifi = 4; + + /* + * Indicates that the device has native bluetooth capability + */ + bool hasBluetooth = 5; + + /* + * Indicates that the device has an ethernet peripheral + */ + bool hasEthernet = 6; + + /* + * Indicates that the device's role in the mesh + */ + Config.DeviceConfig.Role role = 7; + + /* + * Indicates the device's current enabled position flags + */ + uint32 position_flags = 8; + + /* + * Device hardware model + */ + HardwareModel hw_model = 9; + + /* + * Has Remote Hardware enabled + */ + bool hasRemoteHardware = 10; +} + +/* + * A heartbeat message is sent to the node from the client to keep the connection alive. + * This is currently only needed to keep serial connections alive, but can be used by any PhoneAPI. + */ +message Heartbeat {} + +/* + * RemoteHardwarePins associated with a node + */ +message NodeRemoteHardwarePin { + /* + * The node_num exposing the available gpio pin + */ + uint32 node_num = 1; + + /* + * The the available gpio pin for usage with RemoteHardware module + */ + RemoteHardwarePin pin = 2; +} + +message ChunkedPayload { + /* + * The ID of the entire payload + */ + uint32 payload_id = 1; + + /* + * The total number of chunks in the payload + */ + uint32 chunk_count = 2; + + /* + * The current chunk index in the total + */ + uint32 chunk_index = 3; + + /* + * The binary data of the current chunk + */ + bytes payload_chunk = 4; +} + +/* + * Wrapper message for broken repeated oneof support + */ +message resend_chunks { + repeated uint32 chunks = 1; +} + +/* + * Responses to a ChunkedPayload request + */ +message ChunkedPayloadResponse { + /* + * The ID of the entire payload + */ + uint32 payload_id = 1; + + oneof payload_variant { + /* + * Request to transfer chunked payload + */ + bool request_transfer = 2; + + /* + * Accept the transfer chunked payload + */ + bool accept_transfer = 3; + /* + * Request missing indexes in the chunked payload + */ + resend_chunks resend_chunks = 4; + } +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/module_config.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/module_config.options new file mode 100644 index 0000000..68aba7c --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/module_config.options @@ -0,0 +1,28 @@ +*CannedMessageConfig.allow_input_source max_size:16 + +*MQTTConfig.address max_size:64 +*MQTTConfig.username max_size:64 +*MQTTConfig.password max_size:64 +*MQTTConfig.root max_size:32 + +*AudioConfig.ptt_pin int_size:8 +*AudioConfig.i2s_ws int_size:8 +*AudioConfig.i2s_sd int_size:8 +*AudioConfig.i2s_din int_size:8 +*AudioConfig.i2s_sck int_size:8 + +*ExternalNotificationConfig.output_vibra int_size:8 +*ExternalNotificationConfig.output_buzzer int_size:8 +*ExternalNotificationConfig.nag_timeout int_size:16 + +*RemoteHardwareConfig.available_pins max_count:4 +*RemoteHardwarePin.name max_size:15 +*RemoteHardwarePin.gpio_pin int_size:8 + +*AmbientLightingConfig.current int_size:8 +*AmbientLightingConfig.red int_size:8 +*AmbientLightingConfig.green int_size:8 +*AmbientLightingConfig.blue int_size:8 + +*DetectionSensorConfig.monitor_pin int_size:8 +*DetectionSensorConfig.name max_size:20 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/module_config.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/module_config.proto new file mode 100644 index 0000000..8215e01 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/module_config.proto @@ -0,0 +1,802 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "ModuleConfigProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * Module Config + */ +message ModuleConfig { + /* + * MQTT Client Config + */ + message MQTTConfig { + /* + * If a meshtastic node is able to reach the internet it will normally attempt to gateway any channels that are marked as + * is_uplink_enabled or is_downlink_enabled. + */ + bool enabled = 1; + + /* + * The server to use for our MQTT global message gateway feature. + * If not set, the default server will be used + */ + string address = 2; + + /* + * MQTT username to use (most useful for a custom MQTT server). + * If using a custom server, this will be honoured even if empty. + * If using the default server, this will only be honoured if set, otherwise the device will use the default username + */ + string username = 3; + + /* + * MQTT password to use (most useful for a custom MQTT server). + * If using a custom server, this will be honoured even if empty. + * If using the default server, this will only be honoured if set, otherwise the device will use the default password + */ + string password = 4; + + /* + * Whether to send encrypted or decrypted packets to MQTT. + * This parameter is only honoured if you also set server + * (the default official mqtt.meshtastic.org server can handle encrypted packets) + * Decrypted packets may be useful for external systems that want to consume meshtastic packets + */ + bool encryption_enabled = 5; + + /* + * Whether to send / consume json packets on MQTT + */ + bool json_enabled = 6; + + /* + * If true, we attempt to establish a secure connection using TLS + */ + bool tls_enabled = 7; + + /* + * The root topic to use for MQTT messages. Default is "msh". + * This is useful if you want to use a single MQTT server for multiple meshtastic networks and separate them via ACLs + */ + string root = 8; + + /* + * If true, we can use the connected phone / client to proxy messages to MQTT instead of a direct connection + */ + bool proxy_to_client_enabled = 9; + + /* + * If true, we will periodically report unencrypted information about our node to a map via MQTT + */ + bool map_reporting_enabled = 10; + + /* + * Settings for reporting information about our node to a map via MQTT + */ + MapReportSettings map_report_settings = 11; + } + + /* + * Settings for reporting unencrypted information about our node to a map via MQTT + */ + message MapReportSettings { + /* + * How often we should report our info to the map (in seconds) + */ + uint32 publish_interval_secs = 1; + + /* + * Bits of precision for the location sent (default of 32 is full precision). + */ + uint32 position_precision = 2; + } + + /* + * RemoteHardwareModule Config + */ + message RemoteHardwareConfig { + /* + * Whether the Module is enabled + */ + bool enabled = 1; + + /* + * Whether the Module allows consumers to read / write to pins not defined in available_pins + */ + bool allow_undefined_pin_access = 2; + + /* + * Exposes the available pins to the mesh for reading and writing + */ + repeated RemoteHardwarePin available_pins = 3; + } + + /* + * NeighborInfoModule Config + */ + message NeighborInfoConfig { + /* + * Whether the Module is enabled + */ + bool enabled = 1; + + /* + * Interval in seconds of how often we should try to send our + * Neighbor Info to the mesh + */ + uint32 update_interval = 2; + } + + /* + * Detection Sensor Module Config + */ + message DetectionSensorConfig { + /* + * Whether the Module is enabled + */ + bool enabled = 1; + + /* + * Interval in seconds of how often we can send a message to the mesh when a state change is detected + */ + uint32 minimum_broadcast_secs = 2; + + /* + * Interval in seconds of how often we should send a message to the mesh with the current state regardless of changes + * When set to 0, only state changes will be broadcasted + * Works as a sort of status heartbeat for peace of mind + */ + uint32 state_broadcast_secs = 3; + /* + * Send ASCII bell with alert message + * Useful for triggering ext. notification on bell + */ + bool send_bell = 4; + + /* + * Friendly name used to format message sent to mesh + * Example: A name "Motion" would result in a message "Motion detected" + * Maximum length of 20 characters + */ + string name = 5; + + /* + * GPIO pin to monitor for state changes + */ + uint32 monitor_pin = 6; + + /* + * Whether or not the GPIO pin state detection is triggered on HIGH (1) + * Otherwise LOW (0) + */ + bool detection_triggered_high = 7; + + /* + * Whether or not use INPUT_PULLUP mode for GPIO pin + * Only applicable if the board uses pull-up resistors on the pin + */ + bool use_pullup = 8; + } + + /* + * Audio Config for codec2 voice + */ + message AudioConfig { + /* + * Baudrate for codec2 voice + */ + enum Audio_Baud { + CODEC2_DEFAULT = 0; + CODEC2_3200 = 1; + CODEC2_2400 = 2; + CODEC2_1600 = 3; + CODEC2_1400 = 4; + CODEC2_1300 = 5; + CODEC2_1200 = 6; + CODEC2_700 = 7; + CODEC2_700B = 8; + } + + /* + * Whether Audio is enabled + */ + bool codec2_enabled = 1; + + /* + * PTT Pin + */ + uint32 ptt_pin = 2; + + /* + * The audio sample rate to use for codec2 + */ + Audio_Baud bitrate = 3; + + /* + * I2S Word Select + */ + uint32 i2s_ws = 4; + + /* + * I2S Data IN + */ + uint32 i2s_sd = 5; + + /* + * I2S Data OUT + */ + uint32 i2s_din = 6; + + /* + * I2S Clock + */ + uint32 i2s_sck = 7; + } + + /* + * Config for the Paxcounter Module + */ + message PaxcounterConfig { + /* + * Enable the Paxcounter Module + */ + bool enabled = 1; + + /* + * Interval in seconds of how often we should try to send our + * metrics to the mesh + */ + + uint32 paxcounter_update_interval = 2; + + /* + * WiFi RSSI threshold. Defaults to -80 + */ + int32 wifi_threshold = 3; + + /* + * BLE RSSI threshold. Defaults to -80 + */ + int32 ble_threshold = 4; + + } + + /* + * Serial Config + */ + message SerialConfig { + /* + * TODO: REPLACE + */ + enum Serial_Baud { + BAUD_DEFAULT = 0; + BAUD_110 = 1; + BAUD_300 = 2; + BAUD_600 = 3; + BAUD_1200 = 4; + BAUD_2400 = 5; + BAUD_4800 = 6; + BAUD_9600 = 7; + BAUD_19200 = 8; + BAUD_38400 = 9; + BAUD_57600 = 10; + BAUD_115200 = 11; + BAUD_230400 = 12; + BAUD_460800 = 13; + BAUD_576000 = 14; + BAUD_921600 = 15; + } + + /* + * TODO: REPLACE + */ + enum Serial_Mode { + DEFAULT = 0; + SIMPLE = 1; + PROTO = 2; + TEXTMSG = 3; + NMEA = 4; + // NMEA messages specifically tailored for CalTopo + CALTOPO = 5; + } + + /* + * Preferences for the SerialModule + */ + bool enabled = 1; + + /* + * TODO: REPLACE + */ + bool echo = 2; + + /* + * RX pin (should match Arduino gpio pin number) + */ + uint32 rxd = 3; + + /* + * TX pin (should match Arduino gpio pin number) + */ + uint32 txd = 4; + + /* + * Serial baud rate + */ + Serial_Baud baud = 5; + + /* + * TODO: REPLACE + */ + uint32 timeout = 6; + + /* + * Mode for serial module operation + */ + Serial_Mode mode = 7; + + /* + * Overrides the platform's defacto Serial port instance to use with Serial module config settings + * This is currently only usable in output modes like NMEA / CalTopo and may behave strangely or not work at all in other modes + * Existing logging over the Serial Console will still be present + */ + bool override_console_serial_port = 8; + } + + /* + * External Notifications Config + */ + message ExternalNotificationConfig { + /* + * Enable the ExternalNotificationModule + */ + bool enabled = 1; + + /* + * When using in On/Off mode, keep the output on for this many + * milliseconds. Default 1000ms (1 second). + */ + uint32 output_ms = 2; + + /* + * Define the output pin GPIO setting Defaults to + * EXT_NOTIFY_OUT if set for the board. + * In standalone devices this pin should drive the LED to match the UI. + */ + uint32 output = 3; + + /* + * Optional: Define a secondary output pin for a vibra motor + * This is used in standalone devices to match the UI. + */ + uint32 output_vibra = 8; + + /* + * Optional: Define a tertiary output pin for an active buzzer + * This is used in standalone devices to to match the UI. + */ + uint32 output_buzzer = 9; + + /* + * IF this is true, the 'output' Pin will be pulled active high, false + * means active low. + */ + bool active = 4; + + /* + * True: Alert when a text message arrives (output) + */ + bool alert_message = 5; + + /* + * True: Alert when a text message arrives (output_vibra) + */ + bool alert_message_vibra = 10; + + /* + * True: Alert when a text message arrives (output_buzzer) + */ + bool alert_message_buzzer = 11; + + /* + * True: Alert when the bell character is received (output) + */ + bool alert_bell = 6; + + /* + * True: Alert when the bell character is received (output_vibra) + */ + bool alert_bell_vibra = 12; + + /* + * True: Alert when the bell character is received (output_buzzer) + */ + bool alert_bell_buzzer = 13; + + /* + * use a PWM output instead of a simple on/off output. This will ignore + * the 'output', 'output_ms' and 'active' settings and use the + * device.buzzer_gpio instead. + */ + bool use_pwm = 7; + + /* + * The notification will toggle with 'output_ms' for this time of seconds. + * Default is 0 which means don't repeat at all. 60 would mean blink + * and/or beep for 60 seconds + */ + uint32 nag_timeout = 14; + + /* + * When true, enables devices with native I2S audio output to use the RTTTL over speaker like a buzzer + * T-Watch S3 and T-Deck for example have this capability + */ + bool use_i2s_as_buzzer = 15; + } + + /* + * Store and Forward Module Config + */ + message StoreForwardConfig { + /* + * Enable the Store and Forward Module + */ + bool enabled = 1; + + /* + * TODO: REPLACE + */ + bool heartbeat = 2; + + /* + * TODO: REPLACE + */ + uint32 records = 3; + + /* + * TODO: REPLACE + */ + uint32 history_return_max = 4; + + /* + * TODO: REPLACE + */ + uint32 history_return_window = 5; + } + + /* + * Preferences for the RangeTestModule + */ + message RangeTestConfig { + /* + * Enable the Range Test Module + */ + bool enabled = 1; + + /* + * Send out range test messages from this node + */ + uint32 sender = 2; + + /* + * Bool value indicating that this node should save a RangeTest.csv file. + * ESP32 Only + */ + bool save = 3; + } + + /* + * Configuration for both device and environment metrics + */ + message TelemetryConfig { + /* + * Interval in seconds of how often we should try to send our + * device metrics to the mesh + */ + uint32 device_update_interval = 1; + + /* + * Interval in seconds of how often we should try to send our + * environment measurements to the mesh + */ + + uint32 environment_update_interval = 2; + + /* + * Preferences for the Telemetry Module (Environment) + * Enable/Disable the telemetry measurement module measurement collection + */ + bool environment_measurement_enabled = 3; + + /* + * Enable/Disable the telemetry measurement module on-device display + */ + bool environment_screen_enabled = 4; + + /* + * We'll always read the sensor in Celsius, but sometimes we might want to + * display the results in Fahrenheit as a "user preference". + */ + bool environment_display_fahrenheit = 5; + + /* + * Enable/Disable the air quality metrics + */ + bool air_quality_enabled = 6; + + /* + * Interval in seconds of how often we should try to send our + * air quality metrics to the mesh + */ + uint32 air_quality_interval = 7; + + /* + * Interval in seconds of how often we should try to send our + * air quality metrics to the mesh + */ + bool power_measurement_enabled = 8; + + /* + * Interval in seconds of how often we should try to send our + * air quality metrics to the mesh + */ + uint32 power_update_interval = 9; + + /* + * Interval in seconds of how often we should try to send our + * air quality metrics to the mesh + */ + bool power_screen_enabled = 10; + } + + /* + * TODO: REPLACE + */ + message CannedMessageConfig { + /* + * TODO: REPLACE + */ + enum InputEventChar { + /* + * TODO: REPLACE + */ + NONE = 0; + + /* + * TODO: REPLACE + */ + UP = 17; + + /* + * TODO: REPLACE + */ + DOWN = 18; + + /* + * TODO: REPLACE + */ + LEFT = 19; + + /* + * TODO: REPLACE + */ + RIGHT = 20; + + /* + * '\n' + */ + SELECT = 10; + + /* + * TODO: REPLACE + */ + BACK = 27; + + /* + * TODO: REPLACE + */ + CANCEL = 24; + } + + /* + * Enable the rotary encoder #1. This is a 'dumb' encoder sending pulses on both A and B pins while rotating. + */ + bool rotary1_enabled = 1; + + /* + * GPIO pin for rotary encoder A port. + */ + uint32 inputbroker_pin_a = 2; + + /* + * GPIO pin for rotary encoder B port. + */ + uint32 inputbroker_pin_b = 3; + + /* + * GPIO pin for rotary encoder Press port. + */ + uint32 inputbroker_pin_press = 4; + + /* + * Generate input event on CW of this kind. + */ + InputEventChar inputbroker_event_cw = 5; + + /* + * Generate input event on CCW of this kind. + */ + InputEventChar inputbroker_event_ccw = 6; + + /* + * Generate input event on Press of this kind. + */ + InputEventChar inputbroker_event_press = 7; + + /* + * Enable the Up/Down/Select input device. Can be RAK rotary encoder or 3 buttons. Uses the a/b/press definitions from inputbroker. + */ + bool updown1_enabled = 8; + + /* + * Enable/disable CannedMessageModule. + */ + bool enabled = 9; + + /* + * Input event origin accepted by the canned message module. + * Can be e.g. "rotEnc1", "upDownEnc1" or keyword "_any" + */ + string allow_input_source = 10; + + /* + * CannedMessageModule also sends a bell character with the messages. + * ExternalNotificationModule can benefit from this feature. + */ + bool send_bell = 11; + } + + /* + Ambient Lighting Module - Settings for control of onboard LEDs to allow users to adjust the brightness levels and respective color levels. + Initially created for the RAK14001 RGB LED module. + */ + message AmbientLightingConfig { + /* + * Sets LED to on or off. + */ + bool led_state = 1; + + /* + * Sets the current for the LED output. Default is 10. + */ + uint32 current = 2; + + /* + * Sets the red LED level. Values are 0-255. + */ + uint32 red = 3; + + /* + * Sets the green LED level. Values are 0-255. + */ + uint32 green = 4; + + /* + * Sets the blue LED level. Values are 0-255. + */ + uint32 blue = 5; + } + + /* + * TODO: REPLACE + */ + oneof payload_variant { + /* + * TODO: REPLACE + */ + MQTTConfig mqtt = 1; + + /* + * TODO: REPLACE + */ + SerialConfig serial = 2; + + /* + * TODO: REPLACE + */ + ExternalNotificationConfig external_notification = 3; + + /* + * TODO: REPLACE + */ + StoreForwardConfig store_forward = 4; + + /* + * TODO: REPLACE + */ + RangeTestConfig range_test = 5; + + /* + * TODO: REPLACE + */ + TelemetryConfig telemetry = 6; + + /* + * TODO: REPLACE + */ + CannedMessageConfig canned_message = 7; + + /* + * TODO: REPLACE + */ + AudioConfig audio = 8; + + /* + * TODO: REPLACE + */ + RemoteHardwareConfig remote_hardware = 9; + + /* + * TODO: REPLACE + */ + NeighborInfoConfig neighbor_info = 10; + + /* + * TODO: REPLACE + */ + AmbientLightingConfig ambient_lighting = 11; + + /* + * TODO: REPLACE + */ + DetectionSensorConfig detection_sensor = 12; + + /* + * TODO: REPLACE + */ + PaxcounterConfig paxcounter = 13; + } +} + +/* + * A GPIO pin definition for remote hardware module + */ +message RemoteHardwarePin { + /* + * GPIO Pin number (must match Arduino) + */ + uint32 gpio_pin = 1; + + /* + * Name for the GPIO pin (i.e. Front gate, mailbox, etc) + */ + string name = 2; + + /* + * Type of GPIO access available to consumers on the mesh + */ + RemoteHardwarePinType type = 3; +} + +enum RemoteHardwarePinType { + /* + * Unset/unused + */ + UNKNOWN = 0; + + /* + * GPIO pin can be read (if it is high / low) + */ + DIGITAL_READ = 1; + + /* + * GPIO pin can be written to (high / low) + */ + DIGITAL_WRITE = 2; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mqtt.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mqtt.options new file mode 100644 index 0000000..591e898 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mqtt.options @@ -0,0 +1,8 @@ +*ServiceEnvelope.packet type:FT_POINTER +*ServiceEnvelope.channel_id type:FT_POINTER +*ServiceEnvelope.gateway_id type:FT_POINTER + +*MapReport.long_name max_size:40 +*MapReport.short_name max_size:5 +*MapReport.firmware_version max_size:18 +*MapReport.num_online_local_nodes int_size:16 \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mqtt.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mqtt.proto new file mode 100644 index 0000000..2dbc820 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/mqtt.proto @@ -0,0 +1,106 @@ +syntax = "proto3"; + +package meshtastic; + +import "meshtastic/config.proto"; +import "meshtastic/mesh.proto"; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "MQTTProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * This message wraps a MeshPacket with extra metadata about the sender and how it arrived. + */ +message ServiceEnvelope { + /* + * The (probably encrypted) packet + */ + MeshPacket packet = 1; + + /* + * The global channel ID it was sent on + */ + string channel_id = 2; + + /* + * The sending gateway node ID. Can we use this to authenticate/prevent fake + * nodeid impersonation for senders? - i.e. use gateway/mesh id (which is authenticated) + local node id as + * the globally trusted nodenum + */ + string gateway_id = 3; +} + +/* + * Information about a node intended to be reported unencrypted to a map using MQTT. + */ +message MapReport { + /* + * A full name for this user, i.e. "Kevin Hester" + */ + string long_name = 1; + + /* + * A VERY short name, ideally two characters. + * Suitable for a tiny OLED screen + */ + string short_name = 2; + + /* + * Role of the node that applies specific settings for a particular use-case + */ + Config.DeviceConfig.Role role = 3; + + /* + * Hardware model of the node, i.e. T-Beam, Heltec V3, etc... + */ + HardwareModel hw_model = 4; + + /* + * Device firmware version string + */ + string firmware_version = 5; + + /* + * The region code for the radio (US, CN, EU433, etc...) + */ + Config.LoRaConfig.RegionCode region = 6; + + /* + * Modem preset used by the radio (LongFast, MediumSlow, etc...) + */ + Config.LoRaConfig.ModemPreset modem_preset = 7; + + /* + * Whether the node has a channel with default PSK and name (LongFast, MediumSlow, etc...) + * and it uses the default frequency slot given the region and modem preset. + */ + bool has_default_channel = 8; + + /* + * Latitude: multiply by 1e-7 to get degrees in floating point + */ + sfixed32 latitude_i = 9; + + /* + * Longitude: multiply by 1e-7 to get degrees in floating point + */ + sfixed32 longitude_i = 10; + + /* + * Altitude in meters above MSL + */ + int32 altitude = 11; + + /* + * Indicates the bits of precision for latitude and longitude set by the sending node + */ + uint32 position_precision = 12; + + /* + * Number of online nodes (heard in the last 2 hours) this node has in its list that were received locally (not via MQTT) + */ + uint32 num_online_local_nodes = 13; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/paxcount.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/paxcount.proto new file mode 100644 index 0000000..47b2639 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/paxcount.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "PaxcountProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * TODO: REPLACE + */ +message Paxcount { + /* + * seen Wifi devices + */ + uint32 wifi = 1; + + /* + * Seen BLE devices + */ + uint32 ble = 2; + + /* + * Uptime in seconds + */ + uint32 uptime = 3; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/portnums.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/portnums.proto new file mode 100644 index 0000000..5808eb7 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/portnums.proto @@ -0,0 +1,216 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "Portnums"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * For any new 'apps' that run on the device or via sister apps on phones/PCs they should pick and use a + * unique 'portnum' for their application. + * If you are making a new app using meshtastic, please send in a pull request to add your 'portnum' to this + * master table. + * PortNums should be assigned in the following range: + * 0-63 Core Meshtastic use, do not use for third party apps + * 64-127 Registered 3rd party apps, send in a pull request that adds a new entry to portnums.proto to register your application + * 256-511 Use one of these portnums for your private applications that you don't want to register publically + * All other values are reserved. + * Note: This was formerly a Type enum named 'typ' with the same id # + * We have change to this 'portnum' based scheme for specifying app handlers for particular payloads. + * This change is backwards compatible by treating the legacy OPAQUE/CLEAR_TEXT values identically. + */ +enum PortNum { + /* + * Deprecated: do not use in new code (formerly called OPAQUE) + * A message sent from a device outside of the mesh, in a form the mesh does not understand + * NOTE: This must be 0, because it is documented in IMeshService.aidl to be so + * ENCODING: binary undefined + */ + UNKNOWN_APP = 0; + + /* + * A simple UTF-8 text message, which even the little micros in the mesh + * can understand and show on their screen eventually in some circumstances + * even signal might send messages in this form (see below) + * ENCODING: UTF-8 Plaintext (?) + */ + TEXT_MESSAGE_APP = 1; + + /* + * Reserved for built-in GPIO/example app. + * See remote_hardware.proto/HardwareMessage for details on the message sent/received to this port number + * ENCODING: Protobuf + */ + REMOTE_HARDWARE_APP = 2; + + /* + * The built-in position messaging app. + * Payload is a Position message. + * ENCODING: Protobuf + */ + POSITION_APP = 3; + + /* + * The built-in user info app. + * Payload is a User message. + * ENCODING: Protobuf + */ + NODEINFO_APP = 4; + + /* + * Protocol control packets for mesh protocol use. + * Payload is a Routing message. + * ENCODING: Protobuf + */ + ROUTING_APP = 5; + + /* + * Admin control packets. + * Payload is a AdminMessage message. + * ENCODING: Protobuf + */ + ADMIN_APP = 6; + + /* + * Compressed TEXT_MESSAGE payloads. + * ENCODING: UTF-8 Plaintext (?) with Unishox2 Compression + * NOTE: The Device Firmware converts a TEXT_MESSAGE_APP to TEXT_MESSAGE_COMPRESSED_APP if the compressed + * payload is shorter. There's no need for app developers to do this themselves. Also the firmware will decompress + * any incoming TEXT_MESSAGE_COMPRESSED_APP payload and convert to TEXT_MESSAGE_APP. + */ + TEXT_MESSAGE_COMPRESSED_APP = 7; + + /* + * Waypoint payloads. + * Payload is a Waypoint message. + * ENCODING: Protobuf + */ + WAYPOINT_APP = 8; + + /* + * Audio Payloads. + * Encapsulated codec2 packets. On 2.4 GHZ Bandwidths only for now + * ENCODING: codec2 audio frames + * NOTE: audio frames contain a 3 byte header (0xc0 0xde 0xc2) and a one byte marker for the decompressed bitrate. + * This marker comes from the 'moduleConfig.audio.bitrate' enum minus one. + */ + AUDIO_APP = 9; + + /* + * Same as Text Message but originating from Detection Sensor Module. + * NOTE: This portnum traffic is not sent to the public MQTT starting at firmware version 2.2.9 + */ + DETECTION_SENSOR_APP = 10; + + /* + * Provides a 'ping' service that replies to any packet it receives. + * Also serves as a small example module. + * ENCODING: ASCII Plaintext + */ + REPLY_APP = 32; + + /* + * Used for the python IP tunnel feature + * ENCODING: IP Packet. Handled by the python API, firmware ignores this one and pases on. + */ + IP_TUNNEL_APP = 33; + + /* + * Paxcounter lib included in the firmware + * ENCODING: protobuf + */ + PAXCOUNTER_APP = 34; + + /* + * Provides a hardware serial interface to send and receive from the Meshtastic network. + * Connect to the RX/TX pins of a device with 38400 8N1. Packets received from the Meshtastic + * network is forwarded to the RX pin while sending a packet to TX will go out to the Mesh network. + * Maximum packet size of 240 bytes. + * Module is disabled by default can be turned on by setting SERIAL_MODULE_ENABLED = 1 in SerialPlugh.cpp. + * ENCODING: binary undefined + */ + SERIAL_APP = 64; + + /* + * STORE_FORWARD_APP (Work in Progress) + * Maintained by Jm Casler (MC Hamster) : jm@casler.org + * ENCODING: Protobuf + */ + STORE_FORWARD_APP = 65; + + /* + * Optional port for messages for the range test module. + * ENCODING: ASCII Plaintext + * NOTE: This portnum traffic is not sent to the public MQTT starting at firmware version 2.2.9 + */ + RANGE_TEST_APP = 66; + + /* + * Provides a format to send and receive telemetry data from the Meshtastic network. + * Maintained by Charles Crossan (crossan007) : crossan007@gmail.com + * ENCODING: Protobuf + */ + TELEMETRY_APP = 67; + + /* + * Experimental tools for estimating node position without a GPS + * Maintained by Github user a-f-G-U-C (a Meshtastic contributor) + * Project files at https://github.com/a-f-G-U-C/Meshtastic-ZPS + * ENCODING: arrays of int64 fields + */ + ZPS_APP = 68; + + /* + * Used to let multiple instances of Linux native applications communicate + * as if they did using their LoRa chip. + * Maintained by GitHub user GUVWAF. + * Project files at https://github.com/GUVWAF/Meshtasticator + * ENCODING: Protobuf (?) + */ + SIMULATOR_APP = 69; + + /* + * Provides a traceroute functionality to show the route a packet towards + * a certain destination would take on the mesh. + * ENCODING: Protobuf + */ + TRACEROUTE_APP = 70; + + /* + * Aggregates edge info for the network by sending out a list of each node's neighbors + * ENCODING: Protobuf + */ + NEIGHBORINFO_APP = 71; + + /* + * ATAK Plugin + * Portnum for payloads from the official Meshtastic ATAK plugin + */ + ATAK_PLUGIN = 72; + + /* + * Provides unencrypted information about a node for consumption by a map via MQTT + */ + MAP_REPORT_APP = 73; + + /* + * Private applications should use portnums >= 256. + * To simplify initial development and testing you can use "PRIVATE_APP" + * in your code without needing to rebuild protobuf files (via [regen-protos.sh](https://github.com/meshtastic/firmware/blob/master/bin/regen-protos.sh)) + */ + PRIVATE_APP = 256; + + /* + * ATAK Forwarder Module https://github.com/paulmandal/atak-forwarder + * ENCODING: libcotshrink + */ + ATAK_FORWARDER = 257; + + /* + * Currently we limit port nums to no higher than this value + */ + MAX = 511; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/remote_hardware.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/remote_hardware.proto new file mode 100644 index 0000000..ba4a693 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/remote_hardware.proto @@ -0,0 +1,75 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "RemoteHardware"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * An example app to show off the module system. This message is used for + * REMOTE_HARDWARE_APP PortNums. + * Also provides easy remote access to any GPIO. + * In the future other remote hardware operations can be added based on user interest + * (i.e. serial output, spi/i2c input/output). + * FIXME - currently this feature is turned on by default which is dangerous + * because no security yet (beyond the channel mechanism). + * It should be off by default and then protected based on some TBD mechanism + * (a special channel once multichannel support is included?) + */ +message HardwareMessage { + /* + * TODO: REPLACE + */ + enum Type { + /* + * Unset/unused + */ + UNSET = 0; + + /* + * Set gpio gpios based on gpio_mask/gpio_value + */ + WRITE_GPIOS = 1; + + /* + * We are now interested in watching the gpio_mask gpios. + * If the selected gpios change, please broadcast GPIOS_CHANGED. + * Will implicitly change the gpios requested to be INPUT gpios. + */ + WATCH_GPIOS = 2; + + /* + * The gpios listed in gpio_mask have changed, the new values are listed in gpio_value + */ + GPIOS_CHANGED = 3; + + /* + * Read the gpios specified in gpio_mask, send back a READ_GPIOS_REPLY reply with gpio_value populated + */ + READ_GPIOS = 4; + + /* + * A reply to READ_GPIOS. gpio_mask and gpio_value will be populated + */ + READ_GPIOS_REPLY = 5; + } + + /* + * What type of HardwareMessage is this? + */ + Type type = 1; + + /* + * What gpios are we changing. Not used for all MessageTypes, see MessageType for details + */ + uint64 gpio_mask = 2; + + /* + * For gpios that were listed in gpio_mask as valid, what are the signal levels for those gpios. + * Not used for all MessageTypes, see MessageType for details + */ + uint64 gpio_value = 3; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/rtttl.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/rtttl.options new file mode 100644 index 0000000..1ae0c2f --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/rtttl.options @@ -0,0 +1 @@ +*RTTTLConfig.ringtone max_size:230 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/rtttl.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/rtttl.proto new file mode 100644 index 0000000..11c8b92 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/rtttl.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "RTTTLConfigProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * Canned message module configuration. + */ +message RTTTLConfig { + /* + * Ringtone for PWM Buzzer in RTTTL Format. + */ + string ringtone = 1; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/storeforward.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/storeforward.options new file mode 100644 index 0000000..8580aab --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/storeforward.options @@ -0,0 +1 @@ +*StoreAndForward.text max_size:237 \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/storeforward.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/storeforward.proto new file mode 100644 index 0000000..651eae5 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/storeforward.proto @@ -0,0 +1,218 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "StoreAndForwardProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * TODO: REPLACE + */ +message StoreAndForward { + /* + * 001 - 063 = From Router + * 064 - 127 = From Client + */ + enum RequestResponse { + /* + * Unset/unused + */ + UNSET = 0; + + /* + * Router is an in error state. + */ + ROUTER_ERROR = 1; + + /* + * Router heartbeat + */ + ROUTER_HEARTBEAT = 2; + + /* + * Router has requested the client respond. This can work as a + * "are you there" message. + */ + ROUTER_PING = 3; + + /* + * The response to a "Ping" + */ + ROUTER_PONG = 4; + + /* + * Router is currently busy. Please try again later. + */ + ROUTER_BUSY = 5; + + /* + * Router is responding to a request for history. + */ + ROUTER_HISTORY = 6; + + /* + * Router is responding to a request for stats. + */ + ROUTER_STATS = 7; + + /* + * Router sends a text message from its history that was a direct message. + */ + ROUTER_TEXT_DIRECT = 8; + + /* + * Router sends a text message from its history that was a broadcast. + */ + ROUTER_TEXT_BROADCAST = 9; + + /* + * Client is an in error state. + */ + CLIENT_ERROR = 64; + + /* + * Client has requested a replay from the router. + */ + CLIENT_HISTORY = 65; + + /* + * Client has requested stats from the router. + */ + CLIENT_STATS = 66; + + /* + * Client has requested the router respond. This can work as a + * "are you there" message. + */ + CLIENT_PING = 67; + + /* + * The response to a "Ping" + */ + CLIENT_PONG = 68; + + /* + * Client has requested that the router abort processing the client's request + */ + CLIENT_ABORT = 106; + } + + /* + * TODO: REPLACE + */ + message Statistics { + /* + * Number of messages we have ever seen + */ + uint32 messages_total = 1; + + /* + * Number of messages we have currently saved our history. + */ + uint32 messages_saved = 2; + + /* + * Maximum number of messages we will save + */ + uint32 messages_max = 3; + + /* + * Router uptime in seconds + */ + uint32 up_time = 4; + + /* + * Number of times any client sent a request to the S&F. + */ + uint32 requests = 5; + + /* + * Number of times the history was requested. + */ + uint32 requests_history = 6; + + /* + * Is the heartbeat enabled on the server? + */ + bool heartbeat = 7; + + /* + * Maximum number of messages the server will return. + */ + uint32 return_max = 8; + + /* + * Maximum history window in minutes the server will return messages from. + */ + uint32 return_window = 9; + } + + /* + * TODO: REPLACE + */ + message History { + /* + * Number of that will be sent to the client + */ + uint32 history_messages = 1; + + /* + * The window of messages that was used to filter the history client requested + */ + uint32 window = 2; + + /* + * Index in the packet history of the last message sent in a previous request to the server. + * Will be sent to the client before sending the history and can be set in a subsequent request to avoid getting packets the server already sent to the client. + */ + uint32 last_request = 3; + } + + /* + * TODO: REPLACE + */ + message Heartbeat { + /* + * Period in seconds that the heartbeat is sent out that will be sent to the client + */ + uint32 period = 1; + + /* + * If set, this is not the primary Store & Forward router on the mesh + */ + uint32 secondary = 2; + } + + /* + * TODO: REPLACE + */ + RequestResponse rr = 1; + + /* + * TODO: REPLACE + */ + oneof variant { + /* + * TODO: REPLACE + */ + Statistics stats = 2; + + /* + * TODO: REPLACE + */ + History history = 3; + + /* + * TODO: REPLACE + */ + Heartbeat heartbeat = 4; + + /* + * Text from history message. + */ + bytes text = 5; + } +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/telemetry.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/telemetry.options new file mode 100644 index 0000000..72aba92 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/telemetry.options @@ -0,0 +1,5 @@ +# options for nanopb +# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options + +*EnvironmentMetrics.iaq int_size:16 +*EnvironmentMetrics.wind_direction int_size:16 \ No newline at end of file diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/telemetry.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/telemetry.proto new file mode 100644 index 0000000..cf43fc8 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/telemetry.proto @@ -0,0 +1,403 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "TelemetryProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +/* + * Key native device metrics such as battery level + */ +message DeviceMetrics { + /* + * 0-100 (>100 means powered) + */ + uint32 battery_level = 1; + + /* + * Voltage measured + */ + float voltage = 2; + + /* + * Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). + */ + float channel_utilization = 3; + + /* + * Percent of airtime for transmission used within the last hour. + */ + float air_util_tx = 4; + + /* + * How long the device has been running since the last reboot (in seconds) + */ + uint32 uptime_seconds = 5; +} + +/* + * Weather station or other environmental metrics + */ +message EnvironmentMetrics { + /* + * Temperature measured + */ + float temperature = 1; + + /* + * Relative humidity percent measured + */ + float relative_humidity = 2; + + /* + * Barometric pressure in hPA measured + */ + float barometric_pressure = 3; + + /* + * Gas resistance in MOhm measured + */ + float gas_resistance = 4; + + /* + * Voltage measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) + */ + float voltage = 5; + + /* + * Current measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) + */ + float current = 6; + + /* + * relative scale IAQ value as measured by Bosch BME680 . value 0-500. + * Belongs to Air Quality but is not particle but VOC measurement. Other VOC values can also be put in here. + */ + uint32 iaq = 7; + + /* + * RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. + */ + float distance = 8; + + /* + * VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. + */ + float lux = 9; + + /* + * VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. + */ + float white_lux = 10; + + /* + * Infrared lux + */ + float ir_lux = 11; + + /* + * Ultraviolet lux + */ + float uv_lux = 12; + + /* + * Wind direction in degrees + * 0 degrees = North, 90 = East, etc... + */ + uint32 wind_direction = 13; + + /* + * Wind speed in m/s + */ + float wind_speed = 14; + + /* + * Weight in KG + */ + float weight = 15; +} + +/* + * Power Metrics (voltage / current / etc) + */ +message PowerMetrics { + /* + * Voltage (Ch1) + */ + float ch1_voltage = 1; + + /* + * Current (Ch1) + */ + float ch1_current = 2; + + /* + * Voltage (Ch2) + */ + float ch2_voltage = 3; + + /* + * Current (Ch2) + */ + float ch2_current = 4; + + /* + * Voltage (Ch3) + */ + float ch3_voltage = 5; + + /* + * Current (Ch3) + */ + float ch3_current = 6; +} + +/* + * Air quality metrics + */ +message AirQualityMetrics { + /* + * Concentration Units Standard PM1.0 + */ + uint32 pm10_standard = 1; + + /* + * Concentration Units Standard PM2.5 + */ + uint32 pm25_standard = 2; + + /* + * Concentration Units Standard PM10.0 + */ + uint32 pm100_standard = 3; + + /* + * Concentration Units Environmental PM1.0 + */ + uint32 pm10_environmental = 4; + + /* + * Concentration Units Environmental PM2.5 + */ + uint32 pm25_environmental = 5; + + /* + * Concentration Units Environmental PM10.0 + */ + uint32 pm100_environmental = 6; + + /* + * 0.3um Particle Count + */ + uint32 particles_03um = 7; + + /* + * 0.5um Particle Count + */ + uint32 particles_05um = 8; + + /* + * 1.0um Particle Count + */ + uint32 particles_10um = 9; + + /* + * 2.5um Particle Count + */ + uint32 particles_25um = 10; + + /* + * 5.0um Particle Count + */ + uint32 particles_50um = 11; + + /* + * 10.0um Particle Count + */ + uint32 particles_100um = 12; +} + +/* + * Types of Measurements the telemetry module is equipped to handle + */ +message Telemetry { + /* + * Seconds since 1970 - or 0 for unknown/unset + */ + fixed32 time = 1; + + oneof variant { + /* + * Key native device metrics such as battery level + */ + DeviceMetrics device_metrics = 2; + + /* + * Weather station or other environmental metrics + */ + EnvironmentMetrics environment_metrics = 3; + + /* + * Air quality metrics + */ + AirQualityMetrics air_quality_metrics = 4; + + /* + * Power Metrics + */ + PowerMetrics power_metrics = 5; + } +} + +/* + * Supported I2C Sensors for telemetry in Meshtastic + */ +enum TelemetrySensorType { + /* + * No external telemetry sensor explicitly set + */ + SENSOR_UNSET = 0; + + /* + * High accuracy temperature, pressure, humidity + */ + BME280 = 1; + + /* + * High accuracy temperature, pressure, humidity, and air resistance + */ + BME680 = 2; + + /* + * Very high accuracy temperature + */ + MCP9808 = 3; + + /* + * Moderate accuracy current and voltage + */ + INA260 = 4; + + /* + * Moderate accuracy current and voltage + */ + INA219 = 5; + + /* + * High accuracy temperature and pressure + */ + BMP280 = 6; + + /* + * High accuracy temperature and humidity + */ + SHTC3 = 7; + + /* + * High accuracy pressure + */ + LPS22 = 8; + + /* + * 3-Axis magnetic sensor + */ + QMC6310 = 9; + + /* + * 6-Axis inertial measurement sensor + */ + QMI8658 = 10; + + /* + * 3-Axis magnetic sensor + */ + QMC5883L = 11; + + /* + * High accuracy temperature and humidity + */ + SHT31 = 12; + + /* + * PM2.5 air quality sensor + */ + PMSA003I = 13; + + /* + * INA3221 3 Channel Voltage / Current Sensor + */ + INA3221 = 14; + + /* + * BMP085/BMP180 High accuracy temperature and pressure (older Version of BMP280) + */ + BMP085 = 15; + + /* + * RCWL-9620 Doppler Radar Distance Sensor, used for water level detection + */ + RCWL9620 = 16; + + /* + * Sensirion High accuracy temperature and humidity + */ + SHT4X = 17; + + /* + * VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. + */ + VEML7700 = 18; + + /* + * MLX90632 non-contact IR temperature sensor. + */ + MLX90632 = 19; + + /* + * TI OPT3001 Ambient Light Sensor + */ + OPT3001 = 20; + + /* + * Lite On LTR-390UV-01 UV Light Sensor + */ + LTR390UV = 21; + + /* + * AMS TSL25911FN RGB Light Sensor + */ + TSL25911FN = 22; + + /* + * AHT10 Integrated temperature and humidity sensor + */ + AHT10 = 23; + + /* + * DFRobot Lark Weather station (temperature, humidity, pressure, wind speed and direction) + */ + DFROBOT_LARK = 24; + + /* + * NAU7802 Scale Chip or compatible + */ + NAU7802 = 25; +} + +/* + * NAU7802 Telemetry configuration, for saving to flash + */ +message Nau7802Config { + /* + * The offset setting for the NAU7802 + */ + int32 zeroOffset = 1; + + /* + * The calibration factor for the NAU7802 + */ + float calibrationFactor = 2; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/xmodem.options b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/xmodem.options new file mode 100644 index 0000000..3af6125 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/xmodem.options @@ -0,0 +1,6 @@ +# options for nanopb +# https://jpa.kapsi.fi/nanopb/docs/reference.html#proto-file-options + +*XModem.buffer max_size:128 +*XModem.seq int_size:16 +*XModem.crc16 int_size:16 diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/xmodem.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/xmodem.proto new file mode 100644 index 0000000..732780a --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/meshtastic/xmodem.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; + +package meshtastic; + +option csharp_namespace = "Meshtastic.Protobufs"; +option go_package = "github.com/meshtastic/go/generated"; +option java_outer_classname = "XmodemProtos"; +option java_package = "com.geeksville.mesh"; +option swift_prefix = ""; + +message XModem { + enum Control { + NUL = 0; + SOH = 1; + STX = 2; + EOT = 4; + ACK = 6; + NAK = 21; + CAN = 24; + CTRLZ = 26; + } + + Control control = 1; + uint32 seq = 2; + uint32 crc16 = 3; + bytes buffer = 4; +} diff --git a/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/nanopb.proto b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/nanopb.proto new file mode 100644 index 0000000..2f27e34 --- /dev/null +++ b/dissectors/meshtastic-exploiteers/src/meshtastic/protobufs/nanopb.proto @@ -0,0 +1,184 @@ +// Custom options for defining: +// - Maximum size of string/bytes +// - Maximum number of elements in array +// +// These are used by nanopb to generate statically allocable structures +// for memory-limited environments. + +syntax = "proto2"; + +import "google/protobuf/descriptor.proto"; + +option java_package = "fi.kapsi.koti.jpa.nanopb"; + +enum FieldType { + FT_DEFAULT = 0; // Automatically decide field type, generate static field if possible. + FT_CALLBACK = 1; // Always generate a callback field. + FT_POINTER = 4; // Always generate a dynamically allocated field. + FT_STATIC = 2; // Generate a static field or raise an exception if not possible. + FT_IGNORE = 3; // Ignore the field completely. + FT_INLINE = 5; // Legacy option, use the separate 'fixed_length' option instead +} + +enum IntSize { + IS_DEFAULT = 0; // Default, 32/64bit based on type in .proto + IS_8 = 8; + IS_16 = 16; + IS_32 = 32; + IS_64 = 64; +} + +enum TypenameMangling { + M_NONE = 0; // Default, no typename mangling + M_STRIP_PACKAGE = 1; // Strip current package name + M_FLATTEN = 2; // Only use last path component + M_PACKAGE_INITIALS = 3; // Replace the package name by the initials +} + +enum DescriptorSize { + DS_AUTO = 0; // Select minimal size based on field type + DS_1 = 1; // 1 word; up to 15 byte fields, no arrays + DS_2 = 2; // 2 words; up to 4095 byte fields, 4095 entry arrays + DS_4 = 4; // 4 words; up to 2^32-1 byte fields, 2^16-1 entry arrays + DS_8 = 8; // 8 words; up to 2^32-1 entry arrays +} + +// This is the inner options message, which basically defines options for +// a field. When it is used in message or file scope, it applies to all +// fields. +message NanoPBOptions { + // Allocated size for 'bytes' and 'string' fields. + // For string fields, this should include the space for null terminator. + optional int32 max_size = 1; + + // Maximum length for 'string' fields. Setting this is equivalent + // to setting max_size to a value of length+1. + optional int32 max_length = 14; + + // Allocated number of entries in arrays ('repeated' fields) + optional int32 max_count = 2; + + // Size of integer fields. Can save some memory if you don't need + // full 32 bits for the value. + optional IntSize int_size = 7 [default = IS_DEFAULT]; + + // Force type of field (callback or static allocation) + optional FieldType type = 3 [default = FT_DEFAULT]; + + // Use long names for enums, i.e. EnumName_EnumValue. + optional bool long_names = 4 [default = true]; + + // Add 'packed' attribute to generated structs. + // Note: this cannot be used on CPUs that break on unaligned + // accesses to variables. + optional bool packed_struct = 5 [default = false]; + + // Add 'packed' attribute to generated enums. + optional bool packed_enum = 10 [default = false]; + + // Skip this message + optional bool skip_message = 6 [default = false]; + + // Generate oneof fields as normal optional fields instead of union. + optional bool no_unions = 8 [default = false]; + + // integer type tag for a message + optional uint32 msgid = 9; + + // decode oneof as anonymous union + optional bool anonymous_oneof = 11 [default = false]; + + // Proto3 singular field does not generate a "has_" flag + optional bool proto3 = 12 [default = false]; + + // Force proto3 messages to have no "has_" flag. + // This was default behavior until nanopb-0.4.0. + optional bool proto3_singular_msgs = 21 [default = false]; + + // Generate an enum->string mapping function (can take up lots of space). + optional bool enum_to_string = 13 [default = false]; + + // Generate bytes arrays with fixed length + optional bool fixed_length = 15 [default = false]; + + // Generate repeated field with fixed count + optional bool fixed_count = 16 [default = false]; + + // Generate message-level callback that is called before decoding submessages. + // This can be used to set callback fields for submsgs inside oneofs. + optional bool submsg_callback = 22 [default = false]; + + // Shorten or remove package names from type names. + // This option applies only on the file level. + optional TypenameMangling mangle_names = 17 [default = M_NONE]; + + // Data type for storage associated with callback fields. + optional string callback_datatype = 18 [default = "pb_callback_t"]; + + // Callback function used for encoding and decoding. + // Prior to nanopb-0.4.0, the callback was specified in per-field pb_callback_t + // structure. This is still supported, but does not work inside e.g. oneof or pointer + // fields. Instead, a new method allows specifying a per-message callback that + // will be called for all callback fields in a message type. + optional string callback_function = 19 [default = "pb_default_field_callback"]; + + // Select the size of field descriptors. This option has to be defined + // for the whole message, not per-field. Usually automatic selection is + // ok, but if it results in compilation errors you can increase the field + // size here. + optional DescriptorSize descriptorsize = 20 [default = DS_AUTO]; + + // Set default value for has_ fields. + optional bool default_has = 23 [default = false]; + + // Extra files to include in generated `.pb.h` + repeated string include = 24; + + // Automatic includes to exclude from generated `.pb.h` + // Same as nanopb_generator.py command line flag -x. + repeated string exclude = 26; + + // Package name that applies only for nanopb. + optional string package = 25; + + // Override type of the field in generated C code. Only to be used with related field types + optional google.protobuf.FieldDescriptorProto.Type type_override = 27; + + // Due to historical reasons, nanopb orders fields in structs by their tag number + // instead of the order in .proto. Set this to false to keep the .proto order. + // The default value will probably change to false in nanopb-0.5.0. + optional bool sort_by_tag = 28 [default = true]; + + // Set the FT_DEFAULT field conversion strategy. + // A field that can become a static member of a c struct (e.g. int, bool, etc) + // will be a a static field. + // Fields with dynamic length are converted to either a pointer or a callback. + optional FieldType fallback_type = 29 [default = FT_CALLBACK]; +} + +// Extensions to protoc 'Descriptor' type in order to define options +// inside a .proto file. +// +// Protocol Buffers extension number registry +// -------------------------------- +// Project: Nanopb +// Contact: Petteri Aimonen +// Web site: http://kapsi.fi/~jpa/nanopb +// Extensions: 1010 (all types) +// -------------------------------- + +extend google.protobuf.FileOptions { + optional NanoPBOptions nanopb_fileopt = 1010; +} + +extend google.protobuf.MessageOptions { + optional NanoPBOptions nanopb_msgopt = 1010; +} + +extend google.protobuf.EnumOptions { + optional NanoPBOptions nanopb_enumopt = 1010; +} + +extend google.protobuf.FieldOptions { + optional NanoPBOptions nanopb = 1010; +}