├── .gitignore
├── .travis.yml
├── .vscode
└── extensions.json
├── README.md
├── SerialToPipe
├── bin
│ └── Win32
│ │ └── Nrf24Sniff.exe
└── src
│ ├── .vs
│ └── Nrf24Sniff
│ │ └── v16
│ │ └── Browse.VC.db
│ ├── Nrf24Sniff.sln
│ └── Nrf24Sniff
│ ├── LICENSE.txt
│ ├── Nrf24Sniff.cpp
│ ├── Nrf24Sniff.vcxproj
│ ├── Nrf24Sniff.vcxproj.filters
│ ├── ReadMe.txt
│ ├── XGetopt.cpp
│ ├── XGetopt.h
│ ├── stdafx.cpp
│ ├── stdafx.h
│ └── targetver.h
├── Wireshark
├── bin
│ ├── Win32
│ │ ├── mysensors1.dll
│ │ ├── mysensors2.dll
│ │ ├── nrf24.dll
│ │ └── radiohead.dll
│ └── Win64
│ │ ├── mysensors1.dll
│ │ ├── mysensors2.dll
│ │ ├── nrf24.dll
│ │ └── radiohead.dll
└── src
│ ├── mysensors1
│ ├── AUTHORS
│ ├── CMakeLists.txt
│ ├── COPYING
│ ├── ChangeLog
│ ├── Makefile.am
│ ├── Makefile.common
│ ├── Makefile.nmake
│ ├── moduleinfo.h
│ ├── moduleinfo.nmake
│ ├── packet-mysensors1.c
│ └── plugin.rc.in
│ ├── mysensors2
│ ├── AUTHORS
│ ├── CMakeLists.txt
│ ├── COPYING
│ ├── ChangeLog
│ ├── Makefile.am
│ ├── Makefile.common
│ ├── Makefile.nmake
│ ├── moduleinfo.h
│ ├── moduleinfo.nmake
│ ├── packet-mysensors2.c
│ └── plugin.rc.in
│ ├── nrf24
│ ├── AUTHORS
│ ├── CMakeLists.txt
│ ├── COPYING
│ ├── ChangeLog
│ ├── Makefile.am
│ ├── Makefile.common
│ ├── Makefile.nmake
│ ├── moduleinfo.h
│ ├── moduleinfo.nmake
│ ├── packet-nrf24.c
│ └── plugin.rc.in
│ └── radiohead
│ ├── AUTHORS
│ ├── CMakeLists.txt
│ ├── COPYING
│ ├── ChangeLog
│ ├── Makefile.am
│ ├── Makefile.common
│ ├── Makefile.nmake
│ ├── moduleinfo.h
│ ├── moduleinfo.nmake
│ ├── packet-datagram.c
│ ├── packet-mesh.c
│ ├── packet-router.c
│ └── plugin.rc.in
├── include
└── README
├── lib
├── CircularBuffer
│ └── CircularBuffer.h
├── README
└── RF24
│ ├── RF24.cpp
│ ├── RF24.h
│ ├── RF24_config.h
│ └── nRF24L01.h
├── platformio.ini
├── src
├── NRF24_sniff_types.h
└── main.cpp
└── test
└── README
/.gitignore:
--------------------------------------------------------------------------------
1 | .pio
2 | .vscode/.browse.c_cpp.db*
3 | .vscode/c_cpp_properties.json
4 | .vscode/launch.json
5 | .vscode/ipch
6 | *.pch
7 | *.obj
8 | *.ilk
9 | *.pdb
10 | *.log
11 | *.idb
12 |
13 | # Compiled Object files
14 | *.slo
15 | *.lo
16 | *.o
17 | *.obj
18 |
19 | # Compiled Dynamic libraries
20 | *.so
21 | *.dylib
22 |
23 | # Compiled Static libraries
24 | *.lai
25 | *.la
26 | *.a
27 | *.lib
28 |
29 | # Visual Studio
30 | *.ipch
31 | *.sdf
32 | *.suo
33 | *.user
34 | *.log
35 | *.opensdf
36 | Debug
37 | Release
38 |
39 | # Executables
40 | *.out
41 | *.app
42 |
43 | # SVN storage
44 | .svn
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | # Continuous Integration (CI) is the practice, in software
2 | # engineering, of merging all developer working copies with a shared mainline
3 | # several times a day < https://docs.platformio.org/page/ci/index.html >
4 | #
5 | # Documentation:
6 | #
7 | # * Travis CI Embedded Builds with PlatformIO
8 | # < https://docs.travis-ci.com/user/integration/platformio/ >
9 | #
10 | # * PlatformIO integration with Travis CI
11 | # < https://docs.platformio.org/page/ci/travis.html >
12 | #
13 | # * User Guide for `platformio ci` command
14 | # < https://docs.platformio.org/page/userguide/cmd_ci.html >
15 | #
16 | #
17 | # Please choose one of the following templates (proposed below) and uncomment
18 | # it (remove "# " before each line) or use own configuration according to the
19 | # Travis CI documentation (see above).
20 | #
21 |
22 |
23 | #
24 | # Template #1: General project. Test it using existing `platformio.ini`.
25 | #
26 |
27 | # language: python
28 | # python:
29 | # - "2.7"
30 | #
31 | # sudo: false
32 | # cache:
33 | # directories:
34 | # - "~/.platformio"
35 | #
36 | # install:
37 | # - pip install -U platformio
38 | # - platformio update
39 | #
40 | # script:
41 | # - platformio run
42 |
43 |
44 | #
45 | # Template #2: The project is intended to be used as a library with examples.
46 | #
47 |
48 | # language: python
49 | # python:
50 | # - "2.7"
51 | #
52 | # sudo: false
53 | # cache:
54 | # directories:
55 | # - "~/.platformio"
56 | #
57 | # env:
58 | # - PLATFORMIO_CI_SRC=path/to/test/file.c
59 | # - PLATFORMIO_CI_SRC=examples/file.ino
60 | # - PLATFORMIO_CI_SRC=path/to/test/directory
61 | #
62 | # install:
63 | # - pip install -U platformio
64 | # - platformio update
65 | #
66 | # script:
67 | # - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
68 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | // See http://go.microsoft.com/fwlink/?LinkId=827846
3 | // for the documentation about the extensions.json format
4 | "recommendations": [
5 | "platformio.platformio-ide"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Approach to use nrf24_sniffer on ESP32 platform (without WIFI)
2 | ## --------------------------------------------------------------
3 |
4 | Original work : http://yveaux.blogspot.nl/2014/07/nrf24l01-sniffer-part-1.html
5 |
6 | ## PULL GPIO15 LOW (no verbose startup info after DTR reset) !!!
7 | ## -----------------------------------------------------------
8 |
9 |
10 | This project is a modification of original Yveaux work to adapt ESP32 devkit1 board & nrf24L01 laying around as packet sniffer.
11 | Changing platform required some code work to Arduino part and to Windows "pipe driver" part.
12 |
13 | Developed in VSCode+Platformio / VSCommunity.
14 |
15 | 1) Requirements:
16 | - ESP32 based board, eg. ESP32 DevKitV1 or Lolin/NodeMCU...
17 | - nRF24L01+ board
18 | - WireShark 1.10.8 (old, old version... newest - 3.2 doesn't work with these plugins)
19 | - PC with Windows
20 |
21 | 2) Wired connections :
22 | ESP32 nRF24
23 | GND 1
24 | VCC (3v3) 2
25 | 22 CE 3
26 | 5 CSN 4
27 | 18 SCK 5
28 | 23 MOSI 6
29 | 19 MISO 7
30 | 21 IRQ 8
31 |
32 | 3) Usage:
33 | - compile arduino source with VSCode+Platformio (ESP32 platform + Arduino library installed)
34 | - flash into ESP32 board
35 | - install WireShark, copy into Program Files\Wireshark\plugins files from Wireshark dir (only one !! of mysensors.dll)
36 | - run Nrf24Sniff.exe -h to see help text
37 |
38 | Add pipe connection in Wireshark [\\\\.\pipe\wireshark] and go.
39 |
40 | NOTE:
41 | https://developercommunity.visualstudio.com/content/problem/967670/hello-world-c-program-reported-as-trojanwin32wacat.html
42 |
43 |
--------------------------------------------------------------------------------
/SerialToPipe/bin/Win32/Nrf24Sniff.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/SerialToPipe/bin/Win32/Nrf24Sniff.exe
--------------------------------------------------------------------------------
/SerialToPipe/src/.vs/Nrf24Sniff/v16/Browse.VC.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/SerialToPipe/src/.vs/Nrf24Sniff/v16/Browse.VC.db
--------------------------------------------------------------------------------
/SerialToPipe/src/Nrf24Sniff.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Express 2012 for Windows Desktop
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Nrf24Sniff", "Nrf24Sniff\Nrf24Sniff.vcxproj", "{5430E57F-BF07-4833-978E-E7D5826C37A9}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {5430E57F-BF07-4833-978E-E7D5826C37A9}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {5430E57F-BF07-4833-978E-E7D5826C37A9}.Debug|Win32.Build.0 = Debug|Win32
14 | {5430E57F-BF07-4833-978E-E7D5826C37A9}.Release|Win32.ActiveCfg = Release|Win32
15 | {5430E57F-BF07-4833-978E-E7D5826C37A9}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/SerialToPipe/src/Nrf24Sniff/Nrf24Sniff.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 |
14 | {5430E57F-BF07-4833-978E-E7D5826C37A9}
15 | Win32Proj
16 | Nrf24Sniff
17 |
18 |
19 |
20 | Application
21 | true
22 | v142
23 | MultiByte
24 |
25 |
26 | Application
27 | false
28 | v142
29 | true
30 | MultiByte
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 | true
44 |
45 |
46 | false
47 |
48 |
49 |
50 | Use
51 | Level3
52 | Disabled
53 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
54 | true
55 | MultiThreaded
56 |
57 |
58 | Console
59 | true
60 |
61 |
62 |
63 |
64 | Level3
65 | Use
66 | MaxSpeed
67 | true
68 | true
69 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
70 | true
71 | MultiThreaded
72 |
73 |
74 | Console
75 | true
76 | true
77 | true
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 | Create
92 | Create
93 |
94 |
95 |
96 |
97 |
98 |
99 |
--------------------------------------------------------------------------------
/SerialToPipe/src/Nrf24Sniff/Nrf24Sniff.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 | Header Files
29 |
30 |
31 |
32 |
33 | Source Files
34 |
35 |
36 | Source Files
37 |
38 |
39 | Source Files
40 |
41 |
42 |
--------------------------------------------------------------------------------
/SerialToPipe/src/Nrf24Sniff/ReadMe.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/SerialToPipe/src/Nrf24Sniff/ReadMe.txt
--------------------------------------------------------------------------------
/SerialToPipe/src/Nrf24Sniff/XGetopt.cpp:
--------------------------------------------------------------------------------
1 | // XGetopt.cpp Version 1.2
2 | //
3 | // Author: Hans Dietrich
4 | // hdietrich2@hotmail.com
5 | //
6 | // Description:
7 | // XGetopt.cpp implements getopt(), a function to parse command lines.
8 | //
9 | // History
10 | // Version 1.2 - 2003 May 17
11 | // - Added Unicode support
12 | //
13 | // Version 1.1 - 2002 March 10
14 | // - Added example to XGetopt.cpp module header
15 | //
16 | // This software is released into the public domain.
17 | // You are free to use it in any way you like.
18 | //
19 | // This software is provided "as is" with no expressed
20 | // or implied warranty. I accept no liability for any
21 | // damage or loss of business that this software may cause.
22 | //
23 | ///////////////////////////////////////////////////////////////////////////////
24 |
25 |
26 | ///////////////////////////////////////////////////////////////////////////////
27 | // if you are using precompiled headers then include this line:
28 | #include "stdafx.h"
29 | ///////////////////////////////////////////////////////////////////////////////
30 |
31 |
32 | ///////////////////////////////////////////////////////////////////////////////
33 | // if you are not using precompiled headers then include these lines:
34 | //#include
35 | //#include
36 | //#include
37 | ///////////////////////////////////////////////////////////////////////////////
38 |
39 |
40 | #include "XGetopt.h"
41 |
42 |
43 | ///////////////////////////////////////////////////////////////////////////////
44 | //
45 | // X G e t o p t . c p p
46 | //
47 | //
48 | // NAME
49 | // getopt -- parse command line options
50 | //
51 | // SYNOPSIS
52 | // int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
53 | //
54 | // extern TCHAR *optarg;
55 | // extern int optind;
56 | //
57 | // DESCRIPTION
58 | // The getopt() function parses the command line arguments. Its
59 | // arguments argc and argv are the argument count and array as
60 | // passed into the application on program invocation. In the case
61 | // of Visual C++ programs, argc and argv are available via the
62 | // variables __argc and __argv (double underscores), respectively.
63 | // getopt returns the next option letter in argv that matches a
64 | // letter in optstring. (Note: Unicode programs should use
65 | // __targv instead of __argv. Also, all character and string
66 | // literals should be enclosed in _T( ) ).
67 | //
68 | // optstring is a string of recognized option letters; if a letter
69 | // is followed by a colon, the option is expected to have an argument
70 | // that may or may not be separated from it by white space. optarg
71 | // is set to point to the start of the option argument on return from
72 | // getopt.
73 | //
74 | // Option letters may be combined, e.g., "-ab" is equivalent to
75 | // "-a -b". Option letters are case sensitive.
76 | //
77 | // getopt places in the external variable optind the argv index
78 | // of the next argument to be processed. optind is initialized
79 | // to 0 before the first call to getopt.
80 | //
81 | // When all options have been processed (i.e., up to the first
82 | // non-option argument), getopt returns EOF, optarg will point
83 | // to the argument, and optind will be set to the argv index of
84 | // the argument. If there are no non-option arguments, optarg
85 | // will be set to NULL.
86 | //
87 | // The special option "--" may be used to delimit the end of the
88 | // options; EOF will be returned, and "--" (and everything after it)
89 | // will be skipped.
90 | //
91 | // RETURN VALUE
92 | // For option letters contained in the string optstring, getopt
93 | // will return the option letter. getopt returns a question mark (?)
94 | // when it encounters an option letter not included in optstring.
95 | // EOF is returned when processing is finished.
96 | //
97 | // BUGS
98 | // 1) Long options are not supported.
99 | // 2) The GNU double-colon extension is not supported.
100 | // 3) The environment variable POSIXLY_CORRECT is not supported.
101 | // 4) The + syntax is not supported.
102 | // 5) The automatic permutation of arguments is not supported.
103 | // 6) This implementation of getopt() returns EOF if an error is
104 | // encountered, instead of -1 as the latest standard requires.
105 | //
106 | // EXAMPLE
107 | // BOOL CMyApp::ProcessCommandLine(int argc, TCHAR *argv[])
108 | // {
109 | // int c;
110 | //
111 | // while ((c = getopt(argc, argv, _T("aBn:"))) != EOF)
112 | // {
113 | // switch (c)
114 | // {
115 | // case _T('a'):
116 | // TRACE(_T("option a\n"));
117 | // //
118 | // // set some flag here
119 | // //
120 | // break;
121 | //
122 | // case _T('B'):
123 | // TRACE( _T("option B\n"));
124 | // //
125 | // // set some other flag here
126 | // //
127 | // break;
128 | //
129 | // case _T('n'):
130 | // TRACE(_T("option n: value=%d\n"), atoi(optarg));
131 | // //
132 | // // do something with value here
133 | // //
134 | // break;
135 | //
136 | // case _T('?'):
137 | // TRACE(_T("ERROR: illegal option %s\n"), argv[optind-1]);
138 | // return FALSE;
139 | // break;
140 | //
141 | // default:
142 | // TRACE(_T("WARNING: no handler for option %c\n"), c);
143 | // return FALSE;
144 | // break;
145 | // }
146 | // }
147 | // //
148 | // // check for non-option args here
149 | // //
150 | // return TRUE;
151 | // }
152 | //
153 | ///////////////////////////////////////////////////////////////////////////////
154 |
155 | TCHAR *optarg; // global argument pointer
156 | int optind = 0; // global argv index
157 |
158 | int getopt(int argc, TCHAR *argv[], TCHAR *optstring)
159 | {
160 | static TCHAR *next = NULL;
161 | if (optind == 0)
162 | next = NULL;
163 |
164 | optarg = NULL;
165 |
166 | if (next == NULL || *next == _T('\0'))
167 | {
168 | if (optind == 0)
169 | optind++;
170 |
171 | if (optind >= argc || argv[optind][0] != _T('-') || argv[optind][1] == _T('\0'))
172 | {
173 | optarg = NULL;
174 | if (optind < argc)
175 | optarg = argv[optind];
176 | return EOF;
177 | }
178 |
179 | if (_tcscmp(argv[optind], _T("--")) == 0)
180 | {
181 | optind++;
182 | optarg = NULL;
183 | if (optind < argc)
184 | optarg = argv[optind];
185 | return EOF;
186 | }
187 |
188 | next = argv[optind];
189 | next++; // skip past -
190 | optind++;
191 | }
192 |
193 | TCHAR c = *next++;
194 | TCHAR *cp = _tcschr(optstring, c);
195 |
196 | if (cp == NULL || c == _T(':'))
197 | return _T('?');
198 |
199 | cp++;
200 | if (*cp == _T(':'))
201 | {
202 | if (*next != _T('\0'))
203 | {
204 | optarg = next;
205 | next = NULL;
206 | }
207 | else if (optind < argc)
208 | {
209 | optarg = argv[optind];
210 | optind++;
211 | }
212 | else
213 | {
214 | return _T('?');
215 | }
216 | }
217 |
218 | return c;
219 | }
220 |
--------------------------------------------------------------------------------
/SerialToPipe/src/Nrf24Sniff/XGetopt.h:
--------------------------------------------------------------------------------
1 | // XGetopt.h Version 1.2
2 | //
3 | // Author: Hans Dietrich
4 | // hdietrich2@hotmail.com
5 | //
6 | // This software is released into the public domain.
7 | // You are free to use it in any way you like.
8 | //
9 | // This software is provided "as is" with no expressed
10 | // or implied warranty. I accept no liability for any
11 | // damage or loss of business that this software may cause.
12 | //
13 | // Ref: http://www.codeproject.com/Articles/1940/XGetopt-A-Unix-compatible-getopt-for-MFC-and-Win
14 | //
15 | ///////////////////////////////////////////////////////////////////////////////
16 |
17 | #ifndef XGETOPT_H
18 | #define XGETOPT_H
19 |
20 | extern int optind, opterr;
21 | extern TCHAR *optarg;
22 |
23 | int getopt(int argc, TCHAR *argv[], TCHAR *optstring);
24 |
25 | #endif //XGETOPT_H
26 |
--------------------------------------------------------------------------------
/SerialToPipe/src/Nrf24Sniff/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // Nrf24Sniff.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/SerialToPipe/src/Nrf24Sniff/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #include
11 | #include
12 |
13 |
14 |
15 | // TODO: reference additional headers your program requires here
16 |
--------------------------------------------------------------------------------
/SerialToPipe/src/Nrf24Sniff/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/Wireshark/bin/Win32/mysensors1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/bin/Win32/mysensors1.dll
--------------------------------------------------------------------------------
/Wireshark/bin/Win32/mysensors2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/bin/Win32/mysensors2.dll
--------------------------------------------------------------------------------
/Wireshark/bin/Win32/nrf24.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/bin/Win32/nrf24.dll
--------------------------------------------------------------------------------
/Wireshark/bin/Win32/radiohead.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/bin/Win32/radiohead.dll
--------------------------------------------------------------------------------
/Wireshark/bin/Win64/mysensors1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/bin/Win64/mysensors1.dll
--------------------------------------------------------------------------------
/Wireshark/bin/Win64/mysensors2.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/bin/Win64/mysensors2.dll
--------------------------------------------------------------------------------
/Wireshark/bin/Win64/nrf24.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/bin/Win64/nrf24.dll
--------------------------------------------------------------------------------
/Wireshark/bin/Win64/radiohead.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/bin/Win64/radiohead.dll
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/AUTHORS:
--------------------------------------------------------------------------------
1 | Authors:
2 | Ivo Pullens
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # CMakeLists.txt
2 | #
3 | # $Id$
4 | #
5 | # Wireshark - Network traffic analyzer
6 | # By Gerald Combs
7 | # Copyright 1998 Gerald Combs
8 | #
9 | # This program is free software; you can redistribute it and/or
10 | # modify it under the terms of the GNU General Public License
11 | # as published by the Free Software Foundation; either version 2
12 | # of the License, or (at your option) any later version.
13 | #
14 | # This program is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with this program; if not, write to the Free Software
21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 | #
23 |
24 | set(DISSECTOR_SRC
25 | packet-mysensors1.c
26 | )
27 |
28 | #set(DISSECTOR_SUPPORT_SRC
29 | # wimax_tlv.c
30 | #)
31 |
32 | set(PLUGIN_FILES
33 | plugin.c
34 | ${DISSECTOR_SRC}
35 | )
36 | # ${DISSECTOR_SUPPORT_SRC}
37 |
38 | set(CLEAN_FILES
39 | ${PLUGIN_FILES}
40 | )
41 |
42 | if (WERROR)
43 | set_source_files_properties(
44 | ${CLEAN_FILES}
45 | PROPERTIES
46 | COMPILE_FLAGS -Werror
47 | )
48 | endif()
49 |
50 | include_directories(${CMAKE_CURRENT_SOURCE_DIR})
51 |
52 | register_dissector_files(plugin.c
53 | plugin
54 | ${DISSECTOR_SRC}
55 | )
56 |
57 | add_library(mysensors1 ${LINK_MODE_MODULE}
58 | ${PLUGIN_FILES}
59 | )
60 | set_target_properties(mysensors1 PROPERTIES PREFIX "")
61 | set_target_properties(mysensors1 PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
62 |
63 | target_link_libraries(mysensors1)
64 |
65 | install(TARGETS mysensors1
66 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} NAMELINK_SKIP
67 | RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION}
68 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION}
69 | )
70 |
71 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/ChangeLog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/src/mysensors1/ChangeLog
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/Makefile.am:
--------------------------------------------------------------------------------
1 | # Makefile.am
2 | # Automake file for MySenors plugin
3 | #
4 | # $Id$
5 | #
6 | # Wireshark - Network traffic analyzer
7 | # By Gerald Combs
8 | # Copyright 1998 Gerald Combs
9 | #
10 | # This program is free software; you can redistribute it and/or
11 | # modify it under the terms of the GNU General Public License
12 | # as published by the Free Software Foundation; either version 2
13 | # of the License, or (at your option) any later version.
14 | #
15 | # This program is distributed in the hope that it will be useful,
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | # GNU General Public License for more details.
19 | #
20 | # You should have received a copy of the GNU General Public License
21 | # along with this program; if not, write to the Free Software
22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #
24 |
25 | include $(top_srcdir)/Makefile.am.inc
26 |
27 | AM_CPPFLAGS = -I$(top_srcdir) -I../wimax
28 |
29 | include Makefile.common
30 |
31 | if HAVE_WARNINGS_AS_ERRORS
32 | AM_CFLAGS = -Werror
33 | endif
34 |
35 | plugindir = @plugindir@
36 |
37 | plugin_LTLIBRARIES = mysensors1.la
38 |
39 | mysensors1_la_SOURCES = \
40 | plugin.c \
41 | moduleinfo.h \
42 | $(SRC_FILES) \
43 | $(HEADER_FILES)
44 |
45 | mysensors1_la_LDFLAGS = -module -avoid-version
46 | mysensors1_la_LIBADD = @PLUGIN_LIBS@
47 |
48 | # Libs must be cleared, or else libtool won't create a shared module.
49 | # If your module needs to be linked against any particular libraries,
50 | # add them here.
51 | LIBS =
52 |
53 | #
54 | # Build plugin.c, which contains the plugin version[] string, a
55 | # function plugin_register() that calls the register routines for all
56 | # protocols, and a function plugin_reg_handoff() that calls the handoff
57 | # registration routines for all protocols.
58 | #
59 | # We do this by scanning sources. If that turns out to be too slow,
60 | # maybe we could just require every .o file to have an register routine
61 | # of a given name (packet-aarp.o -> proto_register_aarp, etc.).
62 | #
63 | # Formatting conventions: The name of the proto_register_* routines an
64 | # proto_reg_handoff_* routines must start in column zero, or must be
65 | # preceded only by "void " starting in column zero, and must not be
66 | # inside #if.
67 | #
68 | # REGISTER_SRC_FILES is assumed to have all the files that need to be scanned.
69 | #
70 | # For some unknown reason, having a big "for" loop in the Makefile
71 | # to scan all the files doesn't work with some "make"s; they seem to
72 | # pass only the first few names in the list to the shell, for some
73 | # reason.
74 | #
75 | # Therefore, we have a script to generate the plugin.c file.
76 | # The shell script runs slowly, as multiple greps and seds are run
77 | # for each input file; this is especially slow on Windows. Therefore,
78 | # if Python is present (as indicated by PYTHON being defined), we run
79 | # a faster Python script to do that work instead.
80 | #
81 | # The first argument is the directory in which the source files live.
82 | # The second argument is "plugin", to indicate that we should build
83 | # a plugin.c file for a plugin.
84 | # All subsequent arguments are the files to scan.
85 | #
86 | plugin.c: $(REGISTER_SRC_FILES) Makefile.common $(top_srcdir)/tools/make-dissector-reg \
87 | $(top_srcdir)/tools/make-dissector-reg.py
88 | @if test -n "$(PYTHON)"; then \
89 | echo Making plugin.c with python ; \
90 | $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \
91 | plugin $(REGISTER_SRC_FILES) ; \
92 | else \
93 | echo Making plugin.c with shell script ; \
94 | $(top_srcdir)/tools/make-dissector-reg $(srcdir) \
95 | $(plugin_src) plugin $(REGISTER_SRC_FILES) ; \
96 | fi
97 |
98 | #
99 | # Currently plugin.c can be included in the distribution because
100 | # we always build all protocol dissectors. We used to have to check
101 | # whether or not to build the snmp dissector. If we again need to
102 | # variably build something, making plugin.c non-portable, uncomment
103 | # the dist-hook line below.
104 | #
105 | # Oh, yuk. We don't want to include "plugin.c" in the distribution, as
106 | # its contents depend on the configuration, and therefore we want it
107 | # to be built when the first "make" is done; however, Automake insists
108 | # on putting *all* source into the distribution.
109 | #
110 | # We work around this by having a "dist-hook" rule that deletes
111 | # "plugin.c", so that "dist" won't pick it up.
112 | #
113 | #dist-hook:
114 | # @rm -f $(distdir)/plugin.c
115 |
116 | CLEANFILES = \
117 | mysensors1 \
118 | *~
119 |
120 | MAINTAINERCLEANFILES = \
121 | Makefile.in \
122 | plugin.c
123 |
124 | EXTRA_DIST = \
125 | Makefile.common \
126 | Makefile.nmake \
127 | moduleinfo.nmake \
128 | plugin.rc.in \
129 | CMakeLists.txt
130 |
131 | checkapi:
132 | $(PERL) $(top_srcdir)/tools/checkAPIs.pl -g abort -g termoutput -build \
133 | $(CLEAN_SRC_FILES) $(CLEAN_HEADER_FILES)
134 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/Makefile.common:
--------------------------------------------------------------------------------
1 | # Makefile.common for MySensors1 plugin
2 | # Contains the stuff from Makefile.am and Makefile.nmake that is
3 | # a) common to both files and
4 | # b) portable between both files
5 | #
6 | # $Id$
7 | #
8 | # Wireshark - Network traffic analyzer
9 | # By Gerald Combs
10 | # Copyright 1998 Gerald Combs
11 | #
12 | # This program is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU General Public License
14 | # as published by the Free Software Foundation; either version 2
15 | # of the License, or (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License
23 | # along with this program; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 |
26 | # the name of the plugin
27 | PLUGIN_NAME = mysensors1
28 |
29 | # the dissector sources (without any helpers)
30 | # Non-generated sources to be scanned for registration routines
31 | NONGENERATED_REGISTER_C_FILES = \
32 | packet-mysensors1.c
33 |
34 | # Non-generated sources
35 | NONGENERATED_C_FILES = \
36 | $(NONGENERATED_REGISTER_C_FILES)
37 |
38 | include ../Makefile.common.inc
39 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/Makefile.nmake:
--------------------------------------------------------------------------------
1 | # Makefile.nmake
2 | # nmake file for MySensors1 plugin
3 | #
4 | # $Id$
5 | #
6 |
7 | include ..\..\config.nmake
8 | include ..\..\Makefile.nmake.inc
9 |
10 | include moduleinfo.nmake
11 |
12 | include Makefile.common
13 |
14 | CFLAGS=$(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \
15 | /I../.. /I../wimax $(GLIB_CFLAGS) \
16 | /I$(PCAP_DIR)\include
17 |
18 | .c.obj::
19 | $(CC) $(CFLAGS) -Fd.\ -c $<
20 |
21 | LDFLAGS = $(PLUGIN_LDFLAGS)
22 |
23 | !IFDEF ENABLE_LIBWIRESHARK
24 | LINK_PLUGIN_WITH=..\..\epan\libwireshark.lib
25 | CFLAGS=$(CFLAGS)
26 |
27 | OBJECTS = $(C_FILES:.c=.obj) $(CPP_FILES:.cpp=.obj) plugin.obj
28 |
29 | RESOURCE=$(PLUGIN_NAME).res
30 |
31 | all: $(PLUGIN_NAME).dll
32 |
33 | $(PLUGIN_NAME).rc : moduleinfo.nmake
34 | sed -e s/@PLUGIN_NAME@/$(PLUGIN_NAME)/ \
35 | -e s/@RC_MODULE_VERSION@/$(RC_MODULE_VERSION)/ \
36 | -e s/@RC_VERSION@/$(RC_VERSION)/ \
37 | -e s/@MODULE_VERSION@/$(MODULE_VERSION)/ \
38 | -e s/@PACKAGE@/$(PACKAGE)/ \
39 | -e s/@VERSION@/$(VERSION)/ \
40 | -e s/@MSVC_VARIANT@/$(MSVC_VARIANT)/ \
41 | < plugin.rc.in > $@
42 |
43 | $(PLUGIN_NAME).dll $(PLUGIN_NAME).exp $(PLUGIN_NAME).lib : $(OBJECTS) $(LINK_PLUGIN_WITH) $(RESOURCE)
44 | link -dll /out:$(PLUGIN_NAME).dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \
45 | $(GLIB_LIBS) $(RESOURCE)
46 |
47 | #
48 | # Build plugin.c, which contains the plugin version[] string, a
49 | # function plugin_register() that calls the register routines for all
50 | # protocols, and a function plugin_reg_handoff() that calls the handoff
51 | # registration routines for all protocols.
52 | #
53 | # We do this by scanning sources. If that turns out to be too slow,
54 | # maybe we could just require every .o file to have an register routine
55 | # of a given name (packet-aarp.o -> proto_register_aarp, etc.).
56 | #
57 | # Formatting conventions: The name of the proto_register_* routines an
58 | # proto_reg_handoff_* routines must start in column zero, or must be
59 | # preceded only by "void " starting in column zero, and must not be
60 | # inside #if.
61 | #
62 | # REGISTER_SRC_FILES is assumed to have all the files that need to be scanned.
63 | #
64 | # For some unknown reason, having a big "for" loop in the Makefile
65 | # to scan all the files doesn't work with some "make"s; they seem to
66 | # pass only the first few names in the list to the shell, for some
67 | # reason.
68 | #
69 | # Therefore, we have a script to generate the plugin.c file.
70 | # The shell script runs slowly, as multiple greps and seds are run
71 | # for each input file; this is especially slow on Windows. Therefore,
72 | # if Python is present (as indicated by PYTHON being defined), we run
73 | # a faster Python script to do that work instead.
74 | #
75 | # The first argument is the directory in which the source files live.
76 | # The second argument is "plugin", to indicate that we should build
77 | # a plugin.c file for a plugin.
78 | # All subsequent arguments are the files to scan.
79 | #
80 | !IFDEF PYTHON
81 | plugin.c: $(REGISTER_SRC_FILES) moduleinfo.h Makefile.common ../../tools/make-dissector-reg.py
82 | @echo Making plugin.c (using python)
83 | @$(PYTHON) "../../tools/make-dissector-reg.py" . plugin $(REGISTER_SRC_FILES)
84 | !ELSE
85 | plugin.c: $(REGISTER_SRC_FILES) moduleinfo.h Makefile.common ../../tools/make-dissector-reg
86 | @echo Making plugin.c (using sh)
87 | @$(SH) ../../tools/make-dissector-reg . plugin $(REGISTER_SRC_FILES)
88 | !ENDIF
89 |
90 | !ENDIF
91 |
92 | clean:
93 | rm -f $(OBJECTS) $(RESOURCE) plugin.c *.pdb *.sbr \
94 | $(PLUGIN_NAME).dll $(PLUGIN_NAME).dll.manifest $(PLUGIN_NAME).lib \
95 | $(PLUGIN_NAME).exp $(PLUGIN_NAME).rc
96 |
97 | distclean: clean
98 |
99 | maintainer-clean: distclean
100 |
101 | checkapi:
102 | $(PERL) ../../tools/checkAPIs.pl -g abort -g termoutput -build \
103 | $(CLEAN_SRC_FILES) $(CLEAN_HEADER_FILES)
104 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/moduleinfo.h:
--------------------------------------------------------------------------------
1 | /* moduleinfo.h
2 | *
3 | * Copyright (c) 2007 by Intel Corporation.
4 | *
5 | * Author: Lu Pan
6 | *
7 | * $Id$
8 | *
9 | * Wireshark - Network traffic analyzer
10 | * By Gerald Combs
11 | * Copyright 1999 Gerald Combs
12 | *
13 | * This program is free software; you can redistribute it and/or
14 | * modify it under the terms of the GNU General Public License
15 | * as published by the Free Software Foundation; either version 2
16 | * of the License, or (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program; if not, write to the Free Software
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 |
28 | /* Included *after* config.h, in order to re-define these macros */
29 |
30 | #ifdef PACKAGE
31 | #undef PACKAGE
32 | #endif
33 |
34 | /* Name of package */
35 | #define PACKAGE "mysensors1"
36 |
37 |
38 | #ifdef VERSION
39 | #undef VERSION
40 | #endif
41 |
42 | /* Version number of package */
43 |
44 | #define stringiz1(x) #x
45 | #define stringize(x) stringiz1(x)
46 |
47 | #ifndef BUILD_NUMBER
48 | #define BUILD_NUMBER 0
49 | #endif
50 |
51 | #define VERSION "1.1." stringize(BUILD_NUMBER)
52 |
53 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/moduleinfo.nmake:
--------------------------------------------------------------------------------
1 | #
2 | # $Id$
3 | #
4 |
5 | # The name
6 | PACKAGE=mysensors1
7 |
8 | # The version
9 | MODULE_VERSION_MAJOR=1
10 | MODULE_VERSION_MINOR=0
11 | MODULE_VERSION_MICRO=0
12 | MODULE_VERSION_EXTRA=0
13 |
14 | #
15 | # The RC_VERSION should be comma-separated, not dot-separated,
16 | # as per Graham Bloice's message in
17 | #
18 | # http://www.ethereal.com/lists/ethereal-dev/200303/msg00283.html
19 | #
20 | # "The RC_VERSION variable in config.nmake should be comma separated.
21 | # This allows the resources to be built correctly and the version
22 | # number to be correctly displayed in the explorer properties dialog
23 | # for the executables, and XP's tooltip, rather than 0.0.0.0."
24 | #
25 |
26 | MODULE_VERSION=$(MODULE_VERSION_MAJOR).$(MODULE_VERSION_MINOR).$(MODULE_VERSION_MICRO).$(MODULE_VERSION_EXTRA)
27 | RC_MODULE_VERSION=$(MODULE_VERSION_MAJOR),$(MODULE_VERSION_MINOR),$(MODULE_VERSION_MICRO),$(MODULE_VERSION_EXTRA)
28 |
29 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/packet-mysensors1.c:
--------------------------------------------------------------------------------
1 | /* packet-mysensors1.c
2 | * MySensors wireless network dissector (v1.3, protocol 1)
3 | *
4 | * Copyright (c) 2014, Ivo Pullens
5 | *
6 | * $Id$
7 | *
8 | * Wireshark - Network traffic analyzer
9 | * By Gerald Combs
10 | * Copyright 1999 Gerald Combs
11 | *
12 | * This program is free software; you can redistribute it and/or
13 | * modify it under the terms of the GNU General Public License
14 | * as published by the Free Software Foundation; either version 2
15 | * of the License, or (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | */
26 |
27 |
28 | #include "config.h"
29 | #include
30 | #include
31 | #include
32 | #include
33 |
34 | #define MYSENSORS_ABBREV "mysensors1"
35 |
36 | #define MYSENSORS_MSG_HEADER_LENGTH (7)
37 | #define MYSENSORS_MSG_HEADER_CRC_OFFSET (0)
38 | #define MYSENSORS_MSG_MAX_LENGTH (33) // Bug in MyMessage definition; MyMessage.data[MAX_PAYLOAD+1] makes 32+1 maximum size...
39 | #define MYSENSORS_MSG_MAX_PAYLOAD_LENGTH (MYSENSORS_MSG_MAX_LENGTH - MYSENSORS_MSG_HEADER_LENGTH)
40 |
41 | static dissector_handle_t mysensors_handle;
42 |
43 | static int hf_mysensors_crc = -1;
44 | static int hf_mysensors_crc_valid = -1;
45 | static int hf_mysensors_version = -1;
46 | static int hf_mysensors_binary = -1;
47 | static int hf_mysensors_sender = -1;
48 | static int hf_mysensors_dest = -1;
49 | static int hf_mysensors_last = -1;
50 | static int hf_mysensors_sensor = -1;
51 | static int hf_mysensors_commandtype = -1;
52 | static int hf_mysensors_type = -1;
53 |
54 | static int ett_mysensors = -1;
55 | static gint proto_mysensors = -1;
56 | const guint encoding = ENC_LITTLE_ENDIAN;
57 |
58 | static dissector_handle_t data_handle;
59 |
60 | typedef enum {
61 | V1_13 = 1,
62 | V2_14 = 2,
63 | } MySensors_Version;
64 |
65 | static const value_string version_types[] = {
66 | { V1_13, "v1.3" },
67 | { V2_14, "v1.4" },
68 | { 0, NULL }
69 | };
70 |
71 | typedef enum {
72 | C_PRESENTATION = 0,
73 | C_SET = 1,
74 | C_REQ = 2,
75 | C_ACK = 3,
76 | C_INTERNAL = 4
77 | } MySensors_Command;
78 |
79 | static const value_string command_types[] = {
80 | { C_PRESENTATION, "PRESENTATION" },
81 | { C_SET, "SET" },
82 | { C_REQ, "REQ" },
83 | { C_ACK, "ACK" },
84 | { C_INTERNAL, "INTERNAL" },
85 | { 0, NULL }
86 | };
87 |
88 | /* Variable types, used for messages of type C_SET, C_REQ or C_ACK */
89 | static const value_string data_types[] = {
90 | { 0, "TEMP" },
91 | { 1, "HUM" },
92 | { 2, "LIGHT" },
93 | { 3, "DIMMER" },
94 | { 4, "PRESSURE" },
95 | { 5, "FORECAST" },
96 | { 6, "RAIN" },
97 | { 7, "RAINRATE" },
98 | { 8, "WIND" },
99 | { 9, "GUST" },
100 | { 10, "DIRECTION" },
101 | { 11, "UV" },
102 | { 12, "WEIGHT" },
103 | { 13, "DISTANCE" },
104 | { 14, "IMPEDANCE" },
105 | { 15, "ARMED" },
106 | { 16, "TRIPPED" },
107 | { 17, "WATT" },
108 | { 18, "KWH" },
109 | { 19, "SCENE_ON" },
110 | { 20, "SCENE_OFF" },
111 | { 21, "HEATER" },
112 | { 22, "HEATER_SW" },
113 | { 23, "LIGHT_LEVEL" },
114 | { 24, "VAR1" },
115 | { 25, "VAR2" },
116 | { 26, "VAR3" },
117 | { 27, "VAR4" },
118 | { 28, "VAR5" },
119 | { 29, "UP" },
120 | { 30, "DOWN" },
121 | { 31, "STOP" },
122 | { 32, "IR_SEND" },
123 | { 33, "IR_RECEIVE" },
124 | { 34, "FLOW" },
125 | { 35, "VOLUME" },
126 | { 36, "LOCK_STATUS" },
127 | { 0, NULL }
128 | };
129 |
130 | /* Internal types, used for messages of type C_INTERNAL */
131 | static const value_string internal_types[] = {
132 | { 0, "BATTERY_LEVEL" },
133 | { 1, "BATTERY_DATE" },
134 | { 2, "LAST_TRIP" },
135 | { 3, "TIME" },
136 | { 4, "VERSION" },
137 | { 5, "REQUEST_ID" },
138 | { 6, "INCLUSION_MODE" },
139 | { 7, "RELAY_NODE" },
140 | { 8, "LAST_UPDATE" },
141 | { 9, "PING" },
142 | { 10, "PING_ACK" },
143 | { 11, "LOG_MESSAGE" },
144 | { 12, "CHILDREN" },
145 | { 13, "UNIT" },
146 | { 14, "SKETCH_NAME" },
147 | { 15, "SKETCH_VERSION" },
148 | { 0, NULL }
149 | };
150 |
151 | /* Sensor types, used for messages of type C_PRESENTATION */
152 | static const value_string sensor_types[] = {
153 | { 0, "DOOR" },
154 | { 1, "MOTION" },
155 | { 2, "SMOKE" },
156 | { 3, "LIGHT" },
157 | { 4, "DIMMER" },
158 | { 5, "COVER" },
159 | { 6, "TEMP" },
160 | { 7, "HUM" },
161 | { 8, "BARO" },
162 | { 9, "WIND" },
163 | { 10, "RAIN" },
164 | { 11, "UV" },
165 | { 12, "WEIGHT" },
166 | { 13, "POWER" },
167 | { 14, "HEATER" },
168 | { 15, "DISTANCE" },
169 | { 16, "LIGHT_LEVEL" },
170 | { 17, "ARDUINO_NODE" },
171 | { 18, "ARDUINO_RELAY" },
172 | { 19, "LOCK" },
173 | { 20, "IR" },
174 | { 21, "WATER" },
175 | { 0, NULL }
176 | };
177 |
178 | static uint8_t crc8Message(tvbuff_t* tvb)
179 | {
180 | uint8_t crc = 0x00;
181 | uint8_t loop_count;
182 | uint8_t bit_counter;
183 | uint8_t feedback_bit;
184 | uint8_t len = min(tvb_length(tvb), MYSENSORS_MSG_MAX_LENGTH);
185 | uint8_t message[MYSENSORS_MSG_MAX_LENGTH] = {0, };
186 | uint8_t *mp = message;
187 | // Pull a copy to work with
188 | (void)tvb_memcpy(tvb, &message, 0, len);
189 |
190 | // Must set crc to a constant value.
191 | message[MYSENSORS_MSG_HEADER_CRC_OFFSET] = 0;
192 |
193 | for (loop_count = 0; loop_count != sizeof(message); ++loop_count)
194 | {
195 | uint8_t data;
196 | data = *mp++;
197 |
198 | bit_counter = 8;
199 | do {
200 | feedback_bit = (crc ^ data) & 0x01;
201 | if ( feedback_bit == 0x01 )
202 | {
203 | crc = crc ^ 0x18; //0X18 = X^8+X^5+X^4+X^0
204 | }
205 | crc = (crc >> 1) & 0x7F;
206 | if ( feedback_bit == 0x01 )
207 | {
208 | crc = crc | 0x80;
209 | }
210 |
211 | data = data >> 1;
212 | bit_counter--;
213 | } while (bit_counter > 0);
214 | }
215 | return crc;
216 | }
217 |
218 | static const gchar* typeToStr( MySensors_Command commandType, guint8 type )
219 | {
220 | switch (commandType)
221 | {
222 | case C_PRESENTATION:
223 | return val_to_str(type, sensor_types, "%d");
224 | case C_SET:
225 | case C_REQ:
226 | case C_ACK:
227 | return val_to_str(type, data_types, "%d");
228 | case C_INTERNAL:
229 | return val_to_str(type, internal_types, "%d");
230 | }
231 | return "?";
232 | }
233 |
234 | static inline gchar toHexChar(guint8 v)
235 | {
236 | v &= 0x0F;
237 | if (v < 10)
238 | return '0'+v;
239 |
240 | v -= 10;
241 | return 'A'+v;
242 | }
243 |
244 | static gchar* buildColInfo( packet_info *pinfo, guint8 payloadLen, gboolean binary, MySensors_Command commandType,
245 | guint8 type, guint8 sensor, tvbuff_t* tvb_data )
246 | {
247 | static gchar buff[100];
248 | gchar* s = buff;
249 | s += sprintf( s, "Msg:%s, Type:%s, ChildId:%d",
250 | val_to_str(commandType, command_types, "%d"),
251 | typeToStr(commandType, type),
252 | sensor
253 | );
254 | if ((payloadLen > 0) && (payloadLen <= MYSENSORS_MSG_MAX_PAYLOAD_LENGTH))
255 | {
256 | if (binary)
257 | {
258 | static gchar hexbuff[MYSENSORS_MSG_MAX_PAYLOAD_LENGTH*3+1];
259 | gchar* p = hexbuff;
260 | guint8 i;
261 | for (i = 0; i < payloadLen; ++i)
262 | {
263 | guint8 v = tvb_get_guint8(tvb_data, i);
264 | *p++ = toHexChar(v >> 4);
265 | *p++ = toHexChar(v);
266 | *p++ = ' ';
267 | }
268 | *(p-1) = 0;
269 |
270 | s += sprintf( s, ", Data:0x%s", hexbuff );
271 | }
272 | else
273 | {
274 | s += sprintf( s, ", Data:'%s'", tvb_format_text_wsp(tvb_data, 0, payloadLen) );
275 | }
276 | }
277 | return buff;
278 | }
279 |
280 | // Get a byte from a bit offset, where high nibble is at offset+12 and low nibble is at offset 0.
281 | // E.g. btes 0xA0 02 == l. .h => 0x2A
282 | #define TVB_GET_BYTE_SWAPPED(tvb,bitoffset,var) \
283 | { \
284 | guint16 v = tvb_get_bits16(tvb,bitoffset,16,encoding); \
285 | var = (guint8)((v << 4) | (v >> 12)); \
286 | }
287 |
288 | // content format
289 | static void dissect_mysensors(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
290 | {
291 | // your variable definitions go here
292 | int bitoffset = 0;
293 |
294 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "mysensors");
295 |
296 | // Clear out stuff in the info column
297 | col_clear(pinfo->cinfo,COL_INFO);
298 | if (tree)
299 | {
300 | // in case that someone wants to know some details of our protocol
301 | // spawn a subtree and cut the sequence in readable parts
302 | proto_item *pi = NULL;
303 | proto_item *ti = NULL;
304 | proto_tree *mysensors_tree = NULL;
305 | tvbuff_t* tvb_next;
306 | guint8 payload_crc, calc_crc, type, sender, last, dest, childid;
307 | MySensors_Command commandType;
308 | gboolean crc_ok, binary;
309 | gchar* info;
310 | guint8 payloadLen;
311 |
312 | ti = proto_tree_add_item(tree, proto_mysensors, tvb, 0 /*start*/, -1 /*to end*/, ENC_NA);
313 | mysensors_tree = proto_item_add_subtree(ti, ett_mysensors);
314 |
315 | /* --- HEADER FORMAT ---
316 | 7 bytes:
317 | 00 01 02 03 04 05 06
318 | Aa Bb Cc Dd Ee Ff Gg
319 |
320 | Aa = CRC
321 | b = binary << 3 | version
322 | cB = from
323 | dC = to
324 | eD = last
325 | fE = childId
326 | F = messageType
327 | Gg = type
328 | */
329 |
330 | /* CRC - Calculate and compare to CRC in header*/
331 | calc_crc = crc8Message(tvb);
332 |
333 | proto_tree_add_item(mysensors_tree, hf_mysensors_crc, tvb, bitoffset>>3, 1, encoding);
334 | payload_crc = tvb_get_guint8(tvb, bitoffset>>3);
335 | crc_ok = calc_crc == payload_crc;
336 | pi = proto_tree_add_boolean(mysensors_tree, hf_mysensors_crc_valid, tvb, bitoffset>>3, 8, crc_ok);
337 | PROTO_ITEM_SET_GENERATED(pi);
338 | if (!crc_ok)
339 | {
340 | // Color the CRC when invalid.
341 | expert_add_info_format(pinfo, pi, PI_CHECKSUM, PI_WARN, "Calculated CRC 0x%02x, payload CRC 0x%02x", calc_crc, payload_crc);
342 | }
343 | bitoffset += 8;
344 |
345 | /* Binary */
346 | proto_tree_add_bits_item(mysensors_tree, hf_mysensors_binary, tvb, bitoffset+4, 1, encoding);
347 | binary = tvb_get_bits8(tvb, bitoffset+4, 1);
348 |
349 | /* Version */
350 | proto_tree_add_bits_item(mysensors_tree, hf_mysensors_version, tvb, bitoffset+5, 3, encoding);
351 |
352 | /* From (sender) */
353 | TVB_GET_BYTE_SWAPPED(tvb, bitoffset, sender);
354 | proto_tree_add_uint(mysensors_tree, hf_mysensors_sender, tvb, bitoffset>>3, 2, sender);
355 | bitoffset += 8;
356 |
357 | /* To (dest) */
358 | TVB_GET_BYTE_SWAPPED(tvb, bitoffset, dest);
359 | proto_tree_add_uint(mysensors_tree, hf_mysensors_dest, tvb, bitoffset>>3, 2, dest);
360 | bitoffset += 8;
361 |
362 | /* Last (dest) */
363 | TVB_GET_BYTE_SWAPPED(tvb, bitoffset, last);
364 | proto_tree_add_uint(mysensors_tree, hf_mysensors_last, tvb, bitoffset>>3, 2, last);
365 | bitoffset += 8;
366 |
367 | /* ChildId */
368 | TVB_GET_BYTE_SWAPPED(tvb, bitoffset, childid);
369 | proto_tree_add_uint(mysensors_tree, hf_mysensors_sensor, tvb, bitoffset>>3, 2, childid);
370 | bitoffset += 8;
371 |
372 | /* MessageType (commandType) */
373 | proto_tree_add_bits_item(mysensors_tree, hf_mysensors_commandtype, tvb, bitoffset, 4, encoding);
374 | commandType = (MySensors_Command)tvb_get_bits8(tvb, bitoffset, 4);
375 | bitoffset += 8;
376 |
377 | /* Type */
378 | type = tvb_get_guint8(tvb, bitoffset>>3);
379 | proto_tree_add_uint_format_value(mysensors_tree, hf_mysensors_type, tvb, bitoffset>>3, 1, type, "%s (%d)", typeToStr(commandType, type), (guint8)type);
380 | bitoffset += 8;
381 |
382 | // Create tvb for the payload.
383 | payloadLen = tvb_length(tvb) - (bitoffset>>3);
384 | tvb_next = tvb_new_subset(tvb, bitoffset>>3, payloadLen, payloadLen);
385 |
386 | info = buildColInfo( pinfo, payloadLen, binary, commandType, type, childid, tvb_next );
387 | col_add_str(pinfo->cinfo, COL_INFO, info);
388 | proto_item_append_text(ti, " - %s", info);
389 | col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "%d", sender);
390 | col_add_fstr(pinfo->cinfo, COL_DEF_DST, "%d", dest);
391 |
392 | // Pass payload to generic data dissector
393 | call_dissector(data_handle, tvb_next, pinfo, mysensors_tree);
394 | }
395 | }
396 |
397 | static gboolean dissect_mysensors_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
398 | {
399 | guint8 version;
400 |
401 | /* 0) Test minimum packet length */
402 | if (tvb_length(tvb) < MYSENSORS_MSG_HEADER_LENGTH)
403 | return FALSE;
404 |
405 | /* 1) Test protocol verion -- only version 1 (1.3) currently supported */
406 | version = tvb_get_bits8(tvb, 13, 3);
407 | if (version != V1_13)
408 | return FALSE;
409 |
410 | dissect_mysensors(tvb, pinfo, tree);
411 |
412 | return TRUE;
413 | }
414 |
415 | void proto_register_mysensors(void)
416 | {
417 | static hf_register_info hf[] = {
418 | { &hf_mysensors_crc, { "CRC", MYSENSORS_ABBREV ".crc", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
419 | { &hf_mysensors_crc_valid, { "CRC Valid", MYSENSORS_ABBREV ".crcvalid", FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
420 | { &hf_mysensors_version, { "Version", MYSENSORS_ABBREV ".version", FT_UINT8, BASE_DEC, VALS(version_types), 0x0, NULL, HFILL } },
421 | { &hf_mysensors_binary, { "Binary", MYSENSORS_ABBREV ".binary", FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
422 | { &hf_mysensors_sender, { "Sender node", MYSENSORS_ABBREV ".sender", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
423 | { &hf_mysensors_dest, { "Destination node", MYSENSORS_ABBREV ".dest", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
424 | { &hf_mysensors_last, { "Last node", MYSENSORS_ABBREV ".last", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
425 | { &hf_mysensors_sensor, { "ChildID", MYSENSORS_ABBREV ".childid", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
426 | { &hf_mysensors_commandtype, { "Message type", MYSENSORS_ABBREV ".msgtype", FT_UINT8, BASE_DEC, VALS(command_types), 0x0, NULL, HFILL } },
427 | { &hf_mysensors_type, { "Sub type", MYSENSORS_ABBREV ".subtype", FT_UINT8, BASE_DEC, NULL /*representation differs with command*/, 0x0, NULL, HFILL } },
428 | };
429 | static int *ett[] = {
430 | &ett_mysensors // subtree nrf24mysensors
431 | };
432 |
433 | proto_mysensors = proto_register_protocol (
434 | "MySensors1", // name
435 | "mysensors1", // short name
436 | MYSENSORS_ABBREV // abbrev
437 | );
438 | register_dissector(MYSENSORS_ABBREV, dissect_mysensors, proto_mysensors);
439 |
440 | proto_register_field_array(proto_mysensors, hf, array_length(hf));
441 | proto_register_subtree_array(ett, array_length(ett));
442 | }
443 |
444 | /* Register Protocol handler */
445 | void proto_reg_handoff_mysensors(void)
446 | {
447 | mysensors_handle = create_dissector_handle(dissect_mysensors, proto_mysensors);
448 | heur_dissector_add("nrf24" /*parent protocol*/, dissect_mysensors_heur, proto_mysensors);
449 | data_handle = find_dissector("data");
450 | }
451 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors1/plugin.rc.in:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/src/mysensors1/plugin.rc.in
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/AUTHORS:
--------------------------------------------------------------------------------
1 | Authors:
2 | Ivo Pullens
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # CMakeLists.txt
2 | #
3 | # $Id$
4 | #
5 | # Wireshark - Network traffic analyzer
6 | # By Gerald Combs
7 | # Copyright 1998 Gerald Combs
8 | #
9 | # This program is free software; you can redistribute it and/or
10 | # modify it under the terms of the GNU General Public License
11 | # as published by the Free Software Foundation; either version 2
12 | # of the License, or (at your option) any later version.
13 | #
14 | # This program is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with this program; if not, write to the Free Software
21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 | #
23 |
24 | set(DISSECTOR_SRC
25 | packet-mysensors2.c
26 | )
27 |
28 | #set(DISSECTOR_SUPPORT_SRC
29 | # wimax_tlv.c
30 | #)
31 |
32 | set(PLUGIN_FILES
33 | plugin.c
34 | ${DISSECTOR_SRC}
35 | )
36 | # ${DISSECTOR_SUPPORT_SRC}
37 |
38 | set(CLEAN_FILES
39 | ${PLUGIN_FILES}
40 | )
41 |
42 | if (WERROR)
43 | set_source_files_properties(
44 | ${CLEAN_FILES}
45 | PROPERTIES
46 | COMPILE_FLAGS -Werror
47 | )
48 | endif()
49 |
50 | include_directories(${CMAKE_CURRENT_SOURCE_DIR})
51 |
52 | register_dissector_files(plugin.c
53 | plugin
54 | ${DISSECTOR_SRC}
55 | )
56 |
57 | add_library(mysensors2 ${LINK_MODE_MODULE}
58 | ${PLUGIN_FILES}
59 | )
60 | set_target_properties(mysensors2 PROPERTIES PREFIX "")
61 | set_target_properties(mysensors2 PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
62 |
63 | target_link_libraries(mysensors2)
64 |
65 | install(TARGETS mysensors2
66 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} NAMELINK_SKIP
67 | RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION}
68 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION}
69 | )
70 |
71 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/ChangeLog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/src/mysensors2/ChangeLog
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/Makefile.am:
--------------------------------------------------------------------------------
1 | # Makefile.am
2 | # Automake file for MySenors plugin
3 | #
4 | # $Id$
5 | #
6 | # Wireshark - Network traffic analyzer
7 | # By Gerald Combs
8 | # Copyright 1998 Gerald Combs
9 | #
10 | # This program is free software; you can redistribute it and/or
11 | # modify it under the terms of the GNU General Public License
12 | # as published by the Free Software Foundation; either version 2
13 | # of the License, or (at your option) any later version.
14 | #
15 | # This program is distributed in the hope that it will be useful,
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | # GNU General Public License for more details.
19 | #
20 | # You should have received a copy of the GNU General Public License
21 | # along with this program; if not, write to the Free Software
22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #
24 |
25 | include $(top_srcdir)/Makefile.am.inc
26 |
27 | AM_CPPFLAGS = -I$(top_srcdir) -I../wimax
28 |
29 | include Makefile.common
30 |
31 | if HAVE_WARNINGS_AS_ERRORS
32 | AM_CFLAGS = -Werror
33 | endif
34 |
35 | plugindir = @plugindir@
36 |
37 | plugin_LTLIBRARIES = mysensors2.la
38 |
39 | mysensors2_la_SOURCES = \
40 | plugin.c \
41 | moduleinfo.h \
42 | $(SRC_FILES) \
43 | $(HEADER_FILES)
44 |
45 | mysensors2_la_LDFLAGS = -module -avoid-version
46 | mysensors2_la_LIBADD = @PLUGIN_LIBS@
47 |
48 | # Libs must be cleared, or else libtool won't create a shared module.
49 | # If your module needs to be linked against any particular libraries,
50 | # add them here.
51 | LIBS =
52 |
53 | #
54 | # Build plugin.c, which contains the plugin version[] string, a
55 | # function plugin_register() that calls the register routines for all
56 | # protocols, and a function plugin_reg_handoff() that calls the handoff
57 | # registration routines for all protocols.
58 | #
59 | # We do this by scanning sources. If that turns out to be too slow,
60 | # maybe we could just require every .o file to have an register routine
61 | # of a given name (packet-aarp.o -> proto_register_aarp, etc.).
62 | #
63 | # Formatting conventions: The name of the proto_register_* routines an
64 | # proto_reg_handoff_* routines must start in column zero, or must be
65 | # preceded only by "void " starting in column zero, and must not be
66 | # inside #if.
67 | #
68 | # REGISTER_SRC_FILES is assumed to have all the files that need to be scanned.
69 | #
70 | # For some unknown reason, having a big "for" loop in the Makefile
71 | # to scan all the files doesn't work with some "make"s; they seem to
72 | # pass only the first few names in the list to the shell, for some
73 | # reason.
74 | #
75 | # Therefore, we have a script to generate the plugin.c file.
76 | # The shell script runs slowly, as multiple greps and seds are run
77 | # for each input file; this is especially slow on Windows. Therefore,
78 | # if Python is present (as indicated by PYTHON being defined), we run
79 | # a faster Python script to do that work instead.
80 | #
81 | # The first argument is the directory in which the source files live.
82 | # The second argument is "plugin", to indicate that we should build
83 | # a plugin.c file for a plugin.
84 | # All subsequent arguments are the files to scan.
85 | #
86 | plugin.c: $(REGISTER_SRC_FILES) Makefile.common $(top_srcdir)/tools/make-dissector-reg \
87 | $(top_srcdir)/tools/make-dissector-reg.py
88 | @if test -n "$(PYTHON)"; then \
89 | echo Making plugin.c with python ; \
90 | $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \
91 | plugin $(REGISTER_SRC_FILES) ; \
92 | else \
93 | echo Making plugin.c with shell script ; \
94 | $(top_srcdir)/tools/make-dissector-reg $(srcdir) \
95 | $(plugin_src) plugin $(REGISTER_SRC_FILES) ; \
96 | fi
97 |
98 | #
99 | # Currently plugin.c can be included in the distribution because
100 | # we always build all protocol dissectors. We used to have to check
101 | # whether or not to build the snmp dissector. If we again need to
102 | # variably build something, making plugin.c non-portable, uncomment
103 | # the dist-hook line below.
104 | #
105 | # Oh, yuk. We don't want to include "plugin.c" in the distribution, as
106 | # its contents depend on the configuration, and therefore we want it
107 | # to be built when the first "make" is done; however, Automake insists
108 | # on putting *all* source into the distribution.
109 | #
110 | # We work around this by having a "dist-hook" rule that deletes
111 | # "plugin.c", so that "dist" won't pick it up.
112 | #
113 | #dist-hook:
114 | # @rm -f $(distdir)/plugin.c
115 |
116 | CLEANFILES = \
117 | mysensors2 \
118 | *~
119 |
120 | MAINTAINERCLEANFILES = \
121 | Makefile.in \
122 | plugin.c
123 |
124 | EXTRA_DIST = \
125 | Makefile.common \
126 | Makefile.nmake \
127 | moduleinfo.nmake \
128 | plugin.rc.in \
129 | CMakeLists.txt
130 |
131 | checkapi:
132 | $(PERL) $(top_srcdir)/tools/checkAPIs.pl -g abort -g termoutput -build \
133 | $(CLEAN_SRC_FILES) $(CLEAN_HEADER_FILES)
134 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/Makefile.common:
--------------------------------------------------------------------------------
1 | # Makefile.common for MySensors2 plugin
2 | # Contains the stuff from Makefile.am and Makefile.nmake that is
3 | # a) common to both files and
4 | # b) portable between both files
5 | #
6 | # $Id$
7 | #
8 | # Wireshark - Network traffic analyzer
9 | # By Gerald Combs
10 | # Copyright 1998 Gerald Combs
11 | #
12 | # This program is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU General Public License
14 | # as published by the Free Software Foundation; either version 2
15 | # of the License, or (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License
23 | # along with this program; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 |
26 | # the name of the plugin
27 | PLUGIN_NAME = mysensors2
28 |
29 | # the dissector sources (without any helpers)
30 | # Non-generated sources to be scanned for registration routines
31 | NONGENERATED_REGISTER_C_FILES = \
32 | packet-mysensors2.c
33 |
34 | # Non-generated sources
35 | NONGENERATED_C_FILES = \
36 | $(NONGENERATED_REGISTER_C_FILES)
37 |
38 | include ../Makefile.common.inc
39 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/Makefile.nmake:
--------------------------------------------------------------------------------
1 | # Makefile.nmake
2 | # nmake file for MySensors2 plugin
3 | #
4 | # $Id$
5 | #
6 |
7 | include ..\..\config.nmake
8 | include ..\..\Makefile.nmake.inc
9 |
10 | include moduleinfo.nmake
11 |
12 | include Makefile.common
13 |
14 | CFLAGS=$(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \
15 | /I../.. /I../wimax $(GLIB_CFLAGS) \
16 | /I$(PCAP_DIR)\include
17 |
18 | .c.obj::
19 | $(CC) $(CFLAGS) -Fd.\ -c $<
20 |
21 | LDFLAGS = $(PLUGIN_LDFLAGS)
22 |
23 | !IFDEF ENABLE_LIBWIRESHARK
24 | LINK_PLUGIN_WITH=..\..\epan\libwireshark.lib
25 | CFLAGS=$(CFLAGS)
26 |
27 | OBJECTS = $(C_FILES:.c=.obj) $(CPP_FILES:.cpp=.obj) plugin.obj
28 |
29 | RESOURCE=$(PLUGIN_NAME).res
30 |
31 | all: $(PLUGIN_NAME).dll
32 |
33 | $(PLUGIN_NAME).rc : moduleinfo.nmake
34 | sed -e s/@PLUGIN_NAME@/$(PLUGIN_NAME)/ \
35 | -e s/@RC_MODULE_VERSION@/$(RC_MODULE_VERSION)/ \
36 | -e s/@RC_VERSION@/$(RC_VERSION)/ \
37 | -e s/@MODULE_VERSION@/$(MODULE_VERSION)/ \
38 | -e s/@PACKAGE@/$(PACKAGE)/ \
39 | -e s/@VERSION@/$(VERSION)/ \
40 | -e s/@MSVC_VARIANT@/$(MSVC_VARIANT)/ \
41 | < plugin.rc.in > $@
42 |
43 | $(PLUGIN_NAME).dll $(PLUGIN_NAME).exp $(PLUGIN_NAME).lib : $(OBJECTS) $(LINK_PLUGIN_WITH) $(RESOURCE)
44 | link -dll /out:$(PLUGIN_NAME).dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \
45 | $(GLIB_LIBS) $(RESOURCE)
46 |
47 | #
48 | # Build plugin.c, which contains the plugin version[] string, a
49 | # function plugin_register() that calls the register routines for all
50 | # protocols, and a function plugin_reg_handoff() that calls the handoff
51 | # registration routines for all protocols.
52 | #
53 | # We do this by scanning sources. If that turns out to be too slow,
54 | # maybe we could just require every .o file to have an register routine
55 | # of a given name (packet-aarp.o -> proto_register_aarp, etc.).
56 | #
57 | # Formatting conventions: The name of the proto_register_* routines an
58 | # proto_reg_handoff_* routines must start in column zero, or must be
59 | # preceded only by "void " starting in column zero, and must not be
60 | # inside #if.
61 | #
62 | # REGISTER_SRC_FILES is assumed to have all the files that need to be scanned.
63 | #
64 | # For some unknown reason, having a big "for" loop in the Makefile
65 | # to scan all the files doesn't work with some "make"s; they seem to
66 | # pass only the first few names in the list to the shell, for some
67 | # reason.
68 | #
69 | # Therefore, we have a script to generate the plugin.c file.
70 | # The shell script runs slowly, as multiple greps and seds are run
71 | # for each input file; this is especially slow on Windows. Therefore,
72 | # if Python is present (as indicated by PYTHON being defined), we run
73 | # a faster Python script to do that work instead.
74 | #
75 | # The first argument is the directory in which the source files live.
76 | # The second argument is "plugin", to indicate that we should build
77 | # a plugin.c file for a plugin.
78 | # All subsequent arguments are the files to scan.
79 | #
80 | !IFDEF PYTHON
81 | plugin.c: $(REGISTER_SRC_FILES) moduleinfo.h Makefile.common ../../tools/make-dissector-reg.py
82 | @echo Making plugin.c (using python)
83 | @$(PYTHON) "../../tools/make-dissector-reg.py" . plugin $(REGISTER_SRC_FILES)
84 | !ELSE
85 | plugin.c: $(REGISTER_SRC_FILES) moduleinfo.h Makefile.common ../../tools/make-dissector-reg
86 | @echo Making plugin.c (using sh)
87 | @$(SH) ../../tools/make-dissector-reg . plugin $(REGISTER_SRC_FILES)
88 | !ENDIF
89 |
90 | !ENDIF
91 |
92 | clean:
93 | rm -f $(OBJECTS) $(RESOURCE) plugin.c *.pdb *.sbr \
94 | $(PLUGIN_NAME).dll $(PLUGIN_NAME).dll.manifest $(PLUGIN_NAME).lib \
95 | $(PLUGIN_NAME).exp $(PLUGIN_NAME).rc
96 |
97 | distclean: clean
98 |
99 | maintainer-clean: distclean
100 |
101 | checkapi:
102 | $(PERL) ../../tools/checkAPIs.pl -g abort -g termoutput -build \
103 | $(CLEAN_SRC_FILES) $(CLEAN_HEADER_FILES)
104 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/moduleinfo.h:
--------------------------------------------------------------------------------
1 | /* moduleinfo.h
2 | *
3 | * Copyright (c) 2007 by Intel Corporation.
4 | *
5 | * Author: Lu Pan
6 | *
7 | * $Id$
8 | *
9 | * Wireshark - Network traffic analyzer
10 | * By Gerald Combs
11 | * Copyright 1999 Gerald Combs
12 | *
13 | * This program is free software; you can redistribute it and/or
14 | * modify it under the terms of the GNU General Public License
15 | * as published by the Free Software Foundation; either version 2
16 | * of the License, or (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program; if not, write to the Free Software
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 |
28 | /* Included *after* config.h, in order to re-define these macros */
29 |
30 | #ifdef PACKAGE
31 | #undef PACKAGE
32 | #endif
33 |
34 | /* Name of package */
35 | #define PACKAGE "mysensors2"
36 |
37 |
38 | #ifdef VERSION
39 | #undef VERSION
40 | #endif
41 |
42 | /* Version number of package */
43 |
44 | #define stringiz1(x) #x
45 | #define stringize(x) stringiz1(x)
46 |
47 | #ifndef BUILD_NUMBER
48 | #define BUILD_NUMBER 0
49 | #endif
50 |
51 | #define VERSION "1.1." stringize(BUILD_NUMBER)
52 |
53 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/moduleinfo.nmake:
--------------------------------------------------------------------------------
1 | #
2 | # $Id$
3 | #
4 |
5 | # The name
6 | PACKAGE=mysensors2
7 |
8 | # The version
9 | MODULE_VERSION_MAJOR=1
10 | MODULE_VERSION_MINOR=0
11 | MODULE_VERSION_MICRO=0
12 | MODULE_VERSION_EXTRA=0
13 |
14 | #
15 | # The RC_VERSION should be comma-separated, not dot-separated,
16 | # as per Graham Bloice's message in
17 | #
18 | # http://www.ethereal.com/lists/ethereal-dev/200303/msg00283.html
19 | #
20 | # "The RC_VERSION variable in config.nmake should be comma separated.
21 | # This allows the resources to be built correctly and the version
22 | # number to be correctly displayed in the explorer properties dialog
23 | # for the executables, and XP's tooltip, rather than 0.0.0.0."
24 | #
25 |
26 | MODULE_VERSION=$(MODULE_VERSION_MAJOR).$(MODULE_VERSION_MINOR).$(MODULE_VERSION_MICRO).$(MODULE_VERSION_EXTRA)
27 | RC_MODULE_VERSION=$(MODULE_VERSION_MAJOR),$(MODULE_VERSION_MINOR),$(MODULE_VERSION_MICRO),$(MODULE_VERSION_EXTRA)
28 |
29 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/packet-mysensors2.c:
--------------------------------------------------------------------------------
1 | /* packet-mysensors2.c
2 | * MySensors wireless network dissector (v1.4, protocol 2)
3 | *
4 | * Copyright (c) 2014, Ivo Pullens
5 | *
6 | * $Id$
7 | *
8 | * Wireshark - Network traffic analyzer
9 | * By Gerald Combs
10 | * Copyright 1999 Gerald Combs
11 | *
12 | * This program is free software; you can redistribute it and/or
13 | * modify it under the terms of the GNU General Public License
14 | * as published by the Free Software Foundation; either version 2
15 | * of the License, or (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | */
26 |
27 | #include "config.h"
28 | #include
29 | #include
30 | #include
31 | #include
32 |
33 | #define MYSENSORS_MSG_HEADER_LENGTH (7)
34 |
35 | static dissector_handle_t mysensors_handle;
36 |
37 | static int hf_mysensors_version = -1;
38 | static int hf_mysensors_length = -1;
39 | static int hf_mysensors_commandtype = -1;
40 | static int hf_mysensors_isack = -1;
41 | static int hf_mysensors_reqack = -1;
42 | static int hf_mysensors_datatype = -1;
43 | static int hf_mysensors_type = -1;
44 | static int hf_mysensors_sensor = -1;
45 | static int hf_mysensors_sender = -1;
46 | static int hf_mysensors_last = -1;
47 | static int hf_mysensors_dest = -1;
48 |
49 | static int ett_mysensors = -1;
50 | static gint proto_mysensors = -1;
51 | const guint encoding = ENC_LITTLE_ENDIAN;
52 |
53 | static dissector_handle_t data_handle;
54 |
55 | typedef enum {
56 | V1_13 = 1,
57 | V2_14 = 2,
58 | } MySensors_Version;
59 |
60 | static const value_string version_types[] = {
61 | { V1_13, "v1.3" },
62 | { V2_14, "v1.4" },
63 | { 0, NULL }
64 | };
65 |
66 | typedef enum {
67 | C_PRESENTATION = 0,
68 | C_SET = 1,
69 | C_REQ = 2,
70 | C_INTERNAL = 3,
71 | C_STREAM = 4
72 | } MySensors_Command;
73 |
74 | static const value_string command_types[] = {
75 | { C_PRESENTATION, "PRESENTATION" },
76 | { C_SET, "SET" },
77 | { C_REQ, "REQ" },
78 | { C_INTERNAL, "INTERNAL" },
79 | { C_STREAM, "STREAM" },
80 | { 0, NULL }
81 | };
82 |
83 | typedef enum {
84 | P_STRING = 0,
85 | P_BYTE,
86 | P_INT16,
87 | P_UINT16,
88 | P_LONG32,
89 | P_ULONG32,
90 | P_CUSTOM,
91 | P_FLOAT32,
92 | } MySensors_PayloadType;
93 |
94 | static const value_string payload_types[] = {
95 | { 0, "STRING" },
96 | { 1, "BYTE" },
97 | { 2, "INT16" },
98 | { 3, "UINT16" },
99 | { 4, "LONG32" },
100 | { 5, "ULONG32" },
101 | { 6, "CUSTOM" },
102 | { 7, "FLOAT32" },
103 | { 0, NULL }
104 | };
105 |
106 | /* Variable types, used for messages of type C_SET, C_REQ or C_SET_WITH_ACK */
107 | static const value_string data_types[] = {
108 | { 0, "TEMP" },
109 | { 1, "HUM" },
110 | { 2, "LIGHT" },
111 | { 3, "DIMMER" },
112 | { 4, "PRESSURE" },
113 | { 5, "FORECAST" },
114 | { 6, "RAIN" },
115 | { 7, "RAINRATE" },
116 | { 8, "WIND" },
117 | { 9, "GUST" },
118 | { 10, "DIRECTION" },
119 | { 11, "UV" },
120 | { 12, "WEIGHT" },
121 | { 13, "DISTANCE" },
122 | { 14, "IMPEDANCE" },
123 | { 15, "ARMED" },
124 | { 16, "TRIPPED" },
125 | { 17, "WATT" },
126 | { 18, "KWH" },
127 | { 19, "SCENE_ON" },
128 | { 20, "SCENE_OFF" },
129 | { 21, "HEATER" },
130 | { 22, "HEATER_SW" },
131 | { 23, "LIGHT_LEVEL" },
132 | { 24, "VAR1" },
133 | { 25, "VAR2" },
134 | { 26, "VAR3" },
135 | { 27, "VAR4" },
136 | { 28, "VAR5" },
137 | { 29, "UP" },
138 | { 30, "DOWN" },
139 | { 31, "STOP" },
140 | { 32, "IR_SEND" },
141 | { 33, "IR_RECEIVE" },
142 | { 34, "FLOW" },
143 | { 35, "VOLUME" },
144 | { 36, "LOCK_STATUS" },
145 | { 37, "DUST_LEVEL" },
146 | { 38, "VOLTAGE" },
147 | { 39, "CURRENT" },
148 | { 0, NULL }
149 | };
150 |
151 | /* Internal types, used for messages of type C_INTERNAL */
152 | static const value_string internal_types[] = {
153 | { 0, "BATTERY_LEVEL" },
154 | { 1, "TIME" },
155 | { 2, "VERSION" },
156 | { 3, "ID_REQUEST" },
157 | { 4, "ID_RESPONSE" },
158 | { 5, "INCLUSION_MODE" },
159 | { 6, "CONFIG" },
160 | { 7, "FIND_PARENT" },
161 | { 8, "FIND_PARENT_RESPONSE" },
162 | { 9, "LOG_MESSAGE" },
163 | { 10, "CHILDREN" },
164 | { 11, "SKETCH_NAME" },
165 | { 12, "SKETCH_VERSION" },
166 | { 13, "REBOOT" },
167 | { 14, "GATEWAY_READY" },
168 | { 0, NULL }
169 | };
170 |
171 | /* Sensor types, used for messages of type C_PRESENTATION */
172 | static const value_string sensor_types[] = {
173 | { 0, "DOOR" },
174 | { 1, "MOTION" },
175 | { 2, "SMOKE" },
176 | { 3, "LIGHT" },
177 | { 4, "DIMMER" },
178 | { 5, "COVER" },
179 | { 6, "TEMP" },
180 | { 7, "HUM" },
181 | { 8, "BARO" },
182 | { 9, "WIND" },
183 | { 10, "RAIN" },
184 | { 11, "UV" },
185 | { 12, "WEIGHT" },
186 | { 13, "POWER" },
187 | { 14, "HEATER" },
188 | { 15, "DISTANCE" },
189 | { 16, "LIGHT_LEVEL" },
190 | { 17, "ARDUINO_NODE" },
191 | { 18, "ARDUINO_RELAY" },
192 | { 19, "LOCK" },
193 | { 20, "IR" },
194 | { 21, "WATER" },
195 | { 22, "AIR_QUALITY" },
196 | { 23, "CUSTOM" },
197 | { 24, "DUST" },
198 | { 25, "SCENE_CONTROLLER" },
199 | { 0, NULL }
200 | };
201 |
202 | /* Stream types, used for messages of type C_STREAM */
203 | static const value_string stream_types[] = {
204 | { 0, "FIRMWARE_CONFIG_REQUEST" },
205 | { 1, "FIRMWARE_CONFIG_RESPONSE" },
206 | { 2, "FIRMWARE_REQUEST" },
207 | { 3, "FIRMWARE_RESPONSE" },
208 | { 4, "SOUND" },
209 | { 5, "IMAGE" },
210 | { 0, NULL }
211 | };
212 |
213 | static const value_string ack_types[] = {
214 | { 0, "NoAck" },
215 | { 1, "Ack" },
216 | { 0, NULL }
217 | };
218 |
219 | static const gchar* typeToStr( MySensors_Command commandType, guint8 type )
220 | {
221 | switch (commandType)
222 | {
223 | case C_PRESENTATION:
224 | return val_to_str(type, sensor_types, "%d");
225 | case C_SET:
226 | case C_REQ:
227 | return val_to_str(type, data_types, "%d");
228 | case C_INTERNAL:
229 | return val_to_str(type, internal_types, "%d");
230 | case C_STREAM:
231 | return val_to_str(type, stream_types, "%d");
232 | }
233 | return "?";
234 | }
235 |
236 | static const gchar* payloadToStr( guint8 dataType, tvbuff_t* tvb_data, guint8 payloadLen )
237 | {
238 | static gchar buff[100];
239 | switch(dataType)
240 | {
241 | case P_STRING:
242 | (void)sprintf(buff, "'%s'", tvb_format_text_wsp(tvb_data, 0, payloadLen));
243 | break;
244 | case P_BYTE:
245 | (void)sprintf(buff, "%u", tvb_get_guint8(tvb_data, 0));
246 | break;
247 | case P_INT16:
248 | (void)sprintf(buff, "%i", tvb_get_letohs(tvb_data, 0));
249 | break;
250 | case P_UINT16:
251 | (void)sprintf(buff, "%u", tvb_get_letohs(tvb_data, 0));
252 | break;
253 | case P_LONG32:
254 | (void)sprintf(buff, "%li", tvb_get_letohl(tvb_data, 0));
255 | break;
256 | case P_ULONG32:
257 | (void)sprintf(buff, "%lu", tvb_get_letohl(tvb_data, 0));
258 | break;
259 | case P_FLOAT32:
260 | (void)sprintf(buff, "%f", (float)tvb_get_letohl(tvb_data, 0));
261 | break;
262 | case P_CUSTOM:
263 | default:
264 | (void)sprintf(buff, "?");
265 | break;
266 | }
267 | return buff;
268 | }
269 |
270 | static gchar* buildColInfo( packet_info *pinfo, guint8 payloadLen, guint8 dataType, MySensors_Command commandType,
271 | guint8 reqack, guint8 isack, guint8 type, guint8 sensor, tvbuff_t* tvb_data )
272 | {
273 | static gchar buff[100];
274 | gchar* s = buff;
275 | s += sprintf( s, "Cmd:%s, ReqAck:%d, IsAck:%d, Type:%s, Sns:%d",
276 | val_to_str(commandType, command_types, "%d"),
277 | reqack,
278 | isack,
279 | typeToStr(commandType, type),
280 | sensor
281 | );
282 | if (payloadLen > 0)
283 | {
284 | s += sprintf( s, ", Data:%s [%s]",
285 | payloadToStr(dataType, tvb_data, payloadLen),
286 | val_to_str(dataType, payload_types, "%d")
287 | );
288 | }
289 | return buff;
290 | }
291 |
292 | // content format
293 | static void dissect_mysensors(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
294 | {
295 | // your variable definitions go here
296 | int bitoffset = 0;
297 |
298 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "mysensors");
299 |
300 | // Clear out stuff in the info column
301 | col_clear(pinfo->cinfo,COL_INFO);
302 | if (tree)
303 | {
304 | // in case that someone wants to know some details of our protocol
305 | // spawn a subtree and cut the sequence in readable parts
306 | proto_item *pi = NULL;
307 | proto_item *ti = NULL;
308 | proto_tree *mysensors_tree = NULL;
309 | tvbuff_t* tvb_next;
310 | guint8 payloadLen, dataType, type, sensor, sender, last, dest, reqack, isack;
311 | MySensors_Command commandType;
312 | gchar* info;
313 |
314 | ti = proto_tree_add_item(tree, proto_mysensors, tvb, 0 /*start*/, -1 /*to end*/, ENC_NA);
315 | mysensors_tree = proto_item_add_subtree(ti, ett_mysensors);
316 |
317 | proto_tree_add_item(mysensors_tree, hf_mysensors_last, tvb, bitoffset>>3, 1, encoding);
318 | last = tvb_get_guint8(tvb, bitoffset>>3);
319 | bitoffset += 8;
320 | proto_tree_add_item(mysensors_tree, hf_mysensors_sender, tvb, bitoffset>>3, 1, encoding);
321 | sender = tvb_get_guint8(tvb, bitoffset>>3);
322 | bitoffset += 8;
323 | proto_tree_add_item(mysensors_tree, hf_mysensors_dest, tvb, bitoffset>>3, 1, encoding);
324 | dest = tvb_get_guint8(tvb, bitoffset>>3);
325 | bitoffset += 8;
326 |
327 | proto_tree_add_bits_item(mysensors_tree, hf_mysensors_length, tvb, bitoffset, 5, encoding);
328 | payloadLen = tvb_get_bits8(tvb, bitoffset, 5);
329 | bitoffset += 5;
330 | proto_tree_add_bits_item(mysensors_tree, hf_mysensors_version, tvb, bitoffset, 3, encoding);
331 | bitoffset += 3;
332 | proto_tree_add_bits_item(mysensors_tree, hf_mysensors_datatype, tvb, bitoffset, 3, encoding);
333 | dataType = tvb_get_bits8(tvb, bitoffset, 3); // Type of payload
334 | bitoffset += 3;
335 | proto_tree_add_bits_item(mysensors_tree, hf_mysensors_isack, tvb, bitoffset, 1, encoding);
336 | isack = (MySensors_Command)tvb_get_bits8(tvb, bitoffset, 1);
337 | bitoffset += 1;
338 | proto_tree_add_bits_item(mysensors_tree, hf_mysensors_reqack, tvb, bitoffset, 1, encoding);
339 | reqack = (MySensors_Command)tvb_get_bits8(tvb, bitoffset, 1);
340 | bitoffset += 1;
341 | proto_tree_add_bits_item(mysensors_tree, hf_mysensors_commandtype, tvb, bitoffset, 3, encoding);
342 | commandType = (MySensors_Command)tvb_get_bits8(tvb, bitoffset, 3);
343 | bitoffset += 3;
344 |
345 | type = tvb_get_guint8(tvb, bitoffset>>3);
346 | proto_tree_add_uint_format_value(mysensors_tree, hf_mysensors_type, tvb, bitoffset>>3, 1, type, "%s (%d)", typeToStr(commandType, type), (guint8)type);
347 | bitoffset += 8;
348 | proto_tree_add_item(mysensors_tree, hf_mysensors_sensor, tvb, bitoffset>>3, 1, encoding);
349 | sensor = tvb_get_guint8(tvb, bitoffset>>3);
350 | bitoffset += 8;
351 |
352 | // Create tvb for the payload.
353 | tvb_next = tvb_new_subset(tvb, bitoffset>>3, payloadLen, payloadLen);
354 |
355 | info = buildColInfo( pinfo, payloadLen, dataType, commandType, reqack, isack, type, sensor, tvb_next );
356 | col_add_str(pinfo->cinfo, COL_INFO, info);
357 | proto_item_append_text(ti, " - %s", info);
358 | col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "%d", sender);
359 | col_add_fstr(pinfo->cinfo, COL_DEF_DST, "%d", dest);
360 |
361 | // Pass payload to generic data dissector
362 | call_dissector(data_handle, tvb_next, pinfo, mysensors_tree);
363 | }
364 | }
365 |
366 | static gboolean dissect_mysensors_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
367 | {
368 | guint8 version;
369 |
370 | /* 0) Test minimum packet length */
371 | if (tvb_length(tvb) < MYSENSORS_MSG_HEADER_LENGTH)
372 | return FALSE;
373 |
374 | /* 1) Test protocol verion -- only version 2 (1.4) currently supported */
375 | version = tvb_get_bits8(tvb, 3*8+5, 3);
376 | if (version != V2_14)
377 | return FALSE;
378 |
379 | dissect_mysensors(tvb, pinfo, tree);
380 |
381 | return TRUE;
382 | }
383 |
384 | void proto_register_mysensors(void)
385 | {
386 | static hf_register_info hf[] = {
387 | { &hf_mysensors_last, { "Last node", "mysensors.last", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
388 | { &hf_mysensors_sender, { "Sender node", "mysensors.sender", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
389 | { &hf_mysensors_dest, { "Destination node", "mysensors.dest", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
390 | { &hf_mysensors_length, { "Length", "mysensors.paylen", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
391 | { &hf_mysensors_version, { "Version", "mysensors.version", FT_UINT8, BASE_DEC, VALS(version_types), 0x0, NULL, HFILL } },
392 | { &hf_mysensors_datatype, { "Data type", "mysensors.datatype", FT_UINT8, BASE_DEC, VALS(payload_types), 0x0, NULL, HFILL } },
393 | { &hf_mysensors_commandtype, { "Command type", "mysensors.cmdtype", FT_UINT8, BASE_DEC, VALS(command_types), 0x0, NULL, HFILL } },
394 | { &hf_mysensors_isack, { "IsAck", "mysensors.isack", FT_UINT8, BASE_DEC, VALS(ack_types), 0x0, NULL, HFILL } },
395 | { &hf_mysensors_reqack, { "ReqAck", "mysensors.reqack", FT_UINT8, BASE_DEC, VALS(ack_types), 0x0, NULL, HFILL } },
396 | { &hf_mysensors_type, { "Type", "mysensors.type", FT_UINT8, BASE_DEC, NULL /*representation differs with command*/, 0x0, NULL, HFILL } },
397 | { &hf_mysensors_sensor, { "Sensor", "mysensors.sensor", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } },
398 | };
399 | static int *ett[] = {
400 | &ett_mysensors // subtree nrf24mysensors
401 | };
402 |
403 | proto_mysensors = proto_register_protocol (
404 | "MySensors2", // name
405 | "mysensors2", // short name
406 | "mysensors2" // abbref
407 | );
408 | register_dissector("mysensors2", dissect_mysensors, proto_mysensors);
409 |
410 | proto_register_field_array(proto_mysensors, hf, array_length(hf));
411 | proto_register_subtree_array(ett, array_length(ett));
412 | }
413 |
414 | /* Register Protocol handler */
415 | void proto_reg_handoff_mysensors(void)
416 | {
417 | mysensors_handle = create_dissector_handle(dissect_mysensors, proto_mysensors);
418 | heur_dissector_add("nrf24" /*parent protocol*/, dissect_mysensors_heur, proto_mysensors);
419 | heur_dissector_add("rhmesh" /*parent protocol*/, dissect_mysensors_heur, proto_mysensors);
420 | data_handle = find_dissector("data");
421 | }
422 |
--------------------------------------------------------------------------------
/Wireshark/src/mysensors2/plugin.rc.in:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/src/mysensors2/plugin.rc.in
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/AUTHORS:
--------------------------------------------------------------------------------
1 | Authors:
2 | Ivo Pullens
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # CMakeLists.txt
2 | #
3 | # $Id$
4 | #
5 | # Wireshark - Network traffic analyzer
6 | # By Gerald Combs
7 | # Copyright 1998 Gerald Combs
8 | #
9 | # This program is free software; you can redistribute it and/or
10 | # modify it under the terms of the GNU General Public License
11 | # as published by the Free Software Foundation; either version 2
12 | # of the License, or (at your option) any later version.
13 | #
14 | # This program is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with this program; if not, write to the Free Software
21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 | #
23 |
24 | set(DISSECTOR_SRC
25 | packet-nrf24.c
26 | )
27 |
28 | #set(DISSECTOR_SUPPORT_SRC
29 | # wimax_tlv.c
30 | #)
31 |
32 | set(PLUGIN_FILES
33 | plugin.c
34 | ${DISSECTOR_SRC}
35 | )
36 | # ${DISSECTOR_SUPPORT_SRC}
37 |
38 | set(CLEAN_FILES
39 | ${PLUGIN_FILES}
40 | )
41 |
42 | if (WERROR)
43 | set_source_files_properties(
44 | ${CLEAN_FILES}
45 | PROPERTIES
46 | COMPILE_FLAGS -Werror
47 | )
48 | endif()
49 |
50 | include_directories(${CMAKE_CURRENT_SOURCE_DIR})
51 |
52 | register_dissector_files(plugin.c
53 | plugin
54 | ${DISSECTOR_SRC}
55 | )
56 |
57 | add_library(nrf24 ${LINK_MODE_MODULE}
58 | ${PLUGIN_FILES}
59 | )
60 | set_target_properties(nrf24 PROPERTIES PREFIX "")
61 | set_target_properties(nrf24 PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
62 |
63 | target_link_libraries(nrf24)
64 |
65 | install(TARGETS nrf24
66 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} NAMELINK_SKIP
67 | RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION}
68 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION}
69 | )
70 |
71 |
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Library General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License
307 | along with this program; if not, write to the Free Software
308 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
309 |
310 |
311 | Also add information on how to contact you by electronic and paper mail.
312 |
313 | If the program is interactive, make it output a short notice like this
314 | when it starts in an interactive mode:
315 |
316 | Gnomovision version 69, Copyright (C) year name of author
317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 | This is free software, and you are welcome to redistribute it
319 | under certain conditions; type `show c' for details.
320 |
321 | The hypothetical commands `show w' and `show c' should show the appropriate
322 | parts of the General Public License. Of course, the commands you use may
323 | be called something other than `show w' and `show c'; they could even be
324 | mouse-clicks or menu items--whatever suits your program.
325 |
326 | You should also get your employer (if you work as a programmer) or your
327 | school, if any, to sign a "copyright disclaimer" for the program, if
328 | necessary. Here is a sample; alter the names:
329 |
330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
332 |
333 | , 1 April 1989
334 | Ty Coon, President of Vice
335 |
336 | This General Public License does not permit incorporating your program into
337 | proprietary programs. If your program is a subroutine library, you may
338 | consider it more useful to permit linking proprietary applications with the
339 | library. If this is what you want to do, use the GNU Library General
340 | Public License instead of this License.
341 |
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/ChangeLog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/src/nrf24/ChangeLog
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/Makefile.am:
--------------------------------------------------------------------------------
1 | # Makefile.am
2 | # Automake file for NRF24 plugin
3 | #
4 | # $Id$
5 | #
6 | # Wireshark - Network traffic analyzer
7 | # By Gerald Combs
8 | # Copyright 1998 Gerald Combs
9 | #
10 | # This program is free software; you can redistribute it and/or
11 | # modify it under the terms of the GNU General Public License
12 | # as published by the Free Software Foundation; either version 2
13 | # of the License, or (at your option) any later version.
14 | #
15 | # This program is distributed in the hope that it will be useful,
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | # GNU General Public License for more details.
19 | #
20 | # You should have received a copy of the GNU General Public License
21 | # along with this program; if not, write to the Free Software
22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #
24 |
25 | include $(top_srcdir)/Makefile.am.inc
26 |
27 | AM_CPPFLAGS = -I$(top_srcdir) -I../wimax
28 |
29 | include Makefile.common
30 |
31 | if HAVE_WARNINGS_AS_ERRORS
32 | AM_CFLAGS = -Werror
33 | endif
34 |
35 | plugindir = @plugindir@
36 |
37 | plugin_LTLIBRARIES = nrf24.la
38 |
39 | nrf24_la_SOURCES = \
40 | plugin.c \
41 | moduleinfo.h \
42 | $(SRC_FILES) \
43 | $(HEADER_FILES)
44 |
45 | nrf24_la_LDFLAGS = -module -avoid-version
46 | nrf24_la_LIBADD = @PLUGIN_LIBS@
47 |
48 | # Libs must be cleared, or else libtool won't create a shared module.
49 | # If your module needs to be linked against any particular libraries,
50 | # add them here.
51 | LIBS =
52 |
53 | #
54 | # Build plugin.c, which contains the plugin version[] string, a
55 | # function plugin_register() that calls the register routines for all
56 | # protocols, and a function plugin_reg_handoff() that calls the handoff
57 | # registration routines for all protocols.
58 | #
59 | # We do this by scanning sources. If that turns out to be too slow,
60 | # maybe we could just require every .o file to have an register routine
61 | # of a given name (packet-aarp.o -> proto_register_aarp, etc.).
62 | #
63 | # Formatting conventions: The name of the proto_register_* routines an
64 | # proto_reg_handoff_* routines must start in column zero, or must be
65 | # preceded only by "void " starting in column zero, and must not be
66 | # inside #if.
67 | #
68 | # REGISTER_SRC_FILES is assumed to have all the files that need to be scanned.
69 | #
70 | # For some unknown reason, having a big "for" loop in the Makefile
71 | # to scan all the files doesn't work with some "make"s; they seem to
72 | # pass only the first few names in the list to the shell, for some
73 | # reason.
74 | #
75 | # Therefore, we have a script to generate the plugin.c file.
76 | # The shell script runs slowly, as multiple greps and seds are run
77 | # for each input file; this is especially slow on Windows. Therefore,
78 | # if Python is present (as indicated by PYTHON being defined), we run
79 | # a faster Python script to do that work instead.
80 | #
81 | # The first argument is the directory in which the source files live.
82 | # The second argument is "plugin", to indicate that we should build
83 | # a plugin.c file for a plugin.
84 | # All subsequent arguments are the files to scan.
85 | #
86 | plugin.c: $(REGISTER_SRC_FILES) Makefile.common $(top_srcdir)/tools/make-dissector-reg \
87 | $(top_srcdir)/tools/make-dissector-reg.py
88 | @if test -n "$(PYTHON)"; then \
89 | echo Making plugin.c with python ; \
90 | $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \
91 | plugin $(REGISTER_SRC_FILES) ; \
92 | else \
93 | echo Making plugin.c with shell script ; \
94 | $(top_srcdir)/tools/make-dissector-reg $(srcdir) \
95 | $(plugin_src) plugin $(REGISTER_SRC_FILES) ; \
96 | fi
97 |
98 | #
99 | # Currently plugin.c can be included in the distribution because
100 | # we always build all protocol dissectors. We used to have to check
101 | # whether or not to build the snmp dissector. If we again need to
102 | # variably build something, making plugin.c non-portable, uncomment
103 | # the dist-hook line below.
104 | #
105 | # Oh, yuk. We don't want to include "plugin.c" in the distribution, as
106 | # its contents depend on the configuration, and therefore we want it
107 | # to be built when the first "make" is done; however, Automake insists
108 | # on putting *all* source into the distribution.
109 | #
110 | # We work around this by having a "dist-hook" rule that deletes
111 | # "plugin.c", so that "dist" won't pick it up.
112 | #
113 | #dist-hook:
114 | # @rm -f $(distdir)/plugin.c
115 |
116 | CLEANFILES = \
117 | nrf24 \
118 | *~
119 |
120 | MAINTAINERCLEANFILES = \
121 | Makefile.in \
122 | plugin.c
123 |
124 | EXTRA_DIST = \
125 | Makefile.common \
126 | Makefile.nmake \
127 | moduleinfo.nmake \
128 | plugin.rc.in \
129 | CMakeLists.txt
130 |
131 | checkapi:
132 | $(PERL) $(top_srcdir)/tools/checkAPIs.pl -g abort -g termoutput -build \
133 | $(CLEAN_SRC_FILES) $(CLEAN_HEADER_FILES)
134 |
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/Makefile.common:
--------------------------------------------------------------------------------
1 | # Makefile.common for NRF24 plugin
2 | # Contains the stuff from Makefile.am and Makefile.nmake that is
3 | # a) common to both files and
4 | # b) portable between both files
5 | #
6 | # $Id$
7 | #
8 | # Wireshark - Network traffic analyzer
9 | # By Gerald Combs
10 | # Copyright 1998 Gerald Combs
11 | #
12 | # This program is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU General Public License
14 | # as published by the Free Software Foundation; either version 2
15 | # of the License, or (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License
23 | # along with this program; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 |
26 | # the name of the plugin
27 | PLUGIN_NAME = nrf24
28 |
29 | # the dissector sources (without any helpers)
30 | # Non-generated sources to be scanned for registration routines
31 | NONGENERATED_REGISTER_C_FILES = \
32 | packet-nrf24.c
33 |
34 | # Non-generated sources
35 | NONGENERATED_C_FILES = \
36 | $(NONGENERATED_REGISTER_C_FILES)
37 |
38 | include ../Makefile.common.inc
39 |
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/Makefile.nmake:
--------------------------------------------------------------------------------
1 | # Makefile.nmake
2 | # nmake file for NRF24 plugin
3 | #
4 | # $Id$
5 | #
6 |
7 | include ..\..\config.nmake
8 | include ..\..\Makefile.nmake.inc
9 |
10 | include moduleinfo.nmake
11 |
12 | include Makefile.common
13 |
14 | CFLAGS=$(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \
15 | /I../.. /I../wimax $(GLIB_CFLAGS) \
16 | /I$(PCAP_DIR)\include
17 |
18 | .c.obj::
19 | $(CC) $(CFLAGS) -Fd.\ -c $<
20 |
21 | LDFLAGS = $(PLUGIN_LDFLAGS)
22 |
23 | !IFDEF ENABLE_LIBWIRESHARK
24 | LINK_PLUGIN_WITH=..\..\epan\libwireshark.lib
25 | CFLAGS=$(CFLAGS)
26 |
27 | OBJECTS = $(C_FILES:.c=.obj) $(CPP_FILES:.cpp=.obj) plugin.obj
28 |
29 | RESOURCE=$(PLUGIN_NAME).res
30 |
31 | all: $(PLUGIN_NAME).dll
32 |
33 | $(PLUGIN_NAME).rc : moduleinfo.nmake
34 | sed -e s/@PLUGIN_NAME@/$(PLUGIN_NAME)/ \
35 | -e s/@RC_MODULE_VERSION@/$(RC_MODULE_VERSION)/ \
36 | -e s/@RC_VERSION@/$(RC_VERSION)/ \
37 | -e s/@MODULE_VERSION@/$(MODULE_VERSION)/ \
38 | -e s/@PACKAGE@/$(PACKAGE)/ \
39 | -e s/@VERSION@/$(VERSION)/ \
40 | -e s/@MSVC_VARIANT@/$(MSVC_VARIANT)/ \
41 | < plugin.rc.in > $@
42 |
43 | $(PLUGIN_NAME).dll $(PLUGIN_NAME).exp $(PLUGIN_NAME).lib : $(OBJECTS) $(LINK_PLUGIN_WITH) $(RESOURCE)
44 | link -dll /out:$(PLUGIN_NAME).dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \
45 | $(GLIB_LIBS) $(RESOURCE)
46 |
47 | #
48 | # Build plugin.c, which contains the plugin version[] string, a
49 | # function plugin_register() that calls the register routines for all
50 | # protocols, and a function plugin_reg_handoff() that calls the handoff
51 | # registration routines for all protocols.
52 | #
53 | # We do this by scanning sources. If that turns out to be too slow,
54 | # maybe we could just require every .o file to have an register routine
55 | # of a given name (packet-aarp.o -> proto_register_aarp, etc.).
56 | #
57 | # Formatting conventions: The name of the proto_register_* routines an
58 | # proto_reg_handoff_* routines must start in column zero, or must be
59 | # preceded only by "void " starting in column zero, and must not be
60 | # inside #if.
61 | #
62 | # REGISTER_SRC_FILES is assumed to have all the files that need to be scanned.
63 | #
64 | # For some unknown reason, having a big "for" loop in the Makefile
65 | # to scan all the files doesn't work with some "make"s; they seem to
66 | # pass only the first few names in the list to the shell, for some
67 | # reason.
68 | #
69 | # Therefore, we have a script to generate the plugin.c file.
70 | # The shell script runs slowly, as multiple greps and seds are run
71 | # for each input file; this is especially slow on Windows. Therefore,
72 | # if Python is present (as indicated by PYTHON being defined), we run
73 | # a faster Python script to do that work instead.
74 | #
75 | # The first argument is the directory in which the source files live.
76 | # The second argument is "plugin", to indicate that we should build
77 | # a plugin.c file for a plugin.
78 | # All subsequent arguments are the files to scan.
79 | #
80 | !IFDEF PYTHON
81 | plugin.c: $(REGISTER_SRC_FILES) moduleinfo.h Makefile.common ../../tools/make-dissector-reg.py
82 | @echo Making plugin.c (using python)
83 | @$(PYTHON) "../../tools/make-dissector-reg.py" . plugin $(REGISTER_SRC_FILES)
84 | !ELSE
85 | plugin.c: $(REGISTER_SRC_FILES) moduleinfo.h Makefile.common ../../tools/make-dissector-reg
86 | @echo Making plugin.c (using sh)
87 | @$(SH) ../../tools/make-dissector-reg . plugin $(REGISTER_SRC_FILES)
88 | !ENDIF
89 |
90 | !ENDIF
91 |
92 | clean:
93 | rm -f $(OBJECTS) $(RESOURCE) plugin.c *.pdb *.sbr \
94 | $(PLUGIN_NAME).dll $(PLUGIN_NAME).dll.manifest $(PLUGIN_NAME).lib \
95 | $(PLUGIN_NAME).exp $(PLUGIN_NAME).rc
96 |
97 | distclean: clean
98 |
99 | maintainer-clean: distclean
100 |
101 | checkapi:
102 | $(PERL) ../../tools/checkAPIs.pl -g abort -g termoutput -build \
103 | $(CLEAN_SRC_FILES) $(CLEAN_HEADER_FILES)
104 |
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/moduleinfo.h:
--------------------------------------------------------------------------------
1 | /* moduleinfo.h
2 | *
3 | * Copyright (c) 2007 by Intel Corporation.
4 | *
5 | * Author: Lu Pan
6 | *
7 | * $Id$
8 | *
9 | * Wireshark - Network traffic analyzer
10 | * By Gerald Combs
11 | * Copyright 1999 Gerald Combs
12 | *
13 | * This program is free software; you can redistribute it and/or
14 | * modify it under the terms of the GNU General Public License
15 | * as published by the Free Software Foundation; either version 2
16 | * of the License, or (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program; if not, write to the Free Software
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 |
28 | /* Included *after* config.h, in order to re-define these macros */
29 |
30 | #ifdef PACKAGE
31 | #undef PACKAGE
32 | #endif
33 |
34 | /* Name of package */
35 | #define PACKAGE "nrf24"
36 |
37 |
38 | #ifdef VERSION
39 | #undef VERSION
40 | #endif
41 |
42 | /* Version number of package */
43 |
44 | #define stringiz1(x) #x
45 | #define stringize(x) stringiz1(x)
46 |
47 | #ifndef BUILD_NUMBER
48 | #define BUILD_NUMBER 0
49 | #endif
50 |
51 | #define VERSION "1.1." stringize(BUILD_NUMBER)
52 |
53 |
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/moduleinfo.nmake:
--------------------------------------------------------------------------------
1 | #
2 | # $Id$
3 | #
4 |
5 | # The name
6 | PACKAGE=nrf24
7 |
8 | # The version
9 | MODULE_VERSION_MAJOR=1
10 | MODULE_VERSION_MINOR=0
11 | MODULE_VERSION_MICRO=0
12 | MODULE_VERSION_EXTRA=0
13 |
14 | #
15 | # The RC_VERSION should be comma-separated, not dot-separated,
16 | # as per Graham Bloice's message in
17 | #
18 | # http://www.ethereal.com/lists/ethereal-dev/200303/msg00283.html
19 | #
20 | # "The RC_VERSION variable in config.nmake should be comma separated.
21 | # This allows the resources to be built correctly and the version
22 | # number to be correctly displayed in the explorer properties dialog
23 | # for the executables, and XP's tooltip, rather than 0.0.0.0."
24 | #
25 |
26 | MODULE_VERSION=$(MODULE_VERSION_MAJOR).$(MODULE_VERSION_MINOR).$(MODULE_VERSION_MICRO).$(MODULE_VERSION_EXTRA)
27 | RC_MODULE_VERSION=$(MODULE_VERSION_MAJOR),$(MODULE_VERSION_MINOR),$(MODULE_VERSION_MICRO),$(MODULE_VERSION_EXTRA)
28 |
29 |
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/packet-nrf24.c:
--------------------------------------------------------------------------------
1 | /* packet-nrf24.c
2 | * Nordic Semi. NRF24L01+ dissector for Enhanced Shockburst mode.
3 | *
4 | * Copyright (c) 2014, Ivo Pullens
5 | *
6 | * $Id$
7 | *
8 | * Wireshark - Network traffic analyzer
9 | * By Gerald Combs
10 | * Copyright 1999 Gerald Combs
11 | *
12 | * This program is free software; you can redistribute it and/or
13 | * modify it under the terms of the GNU General Public License
14 | * as published by the Free Software Foundation; either version 2
15 | * of the License, or (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | */
26 |
27 | #include "config.h"
28 |
29 | #include
30 | #include
31 | #include
32 |
33 | #define BITS_TO_BYTES(x) (((x)+7)>>3)
34 | #define BYTES_TO_BITS(x) ((x)<<3)
35 |
36 | //#define BYTE_ALIGN_PCAP
37 |
38 | #define MYSENSORS_MIN_PAYLOAD_LEN (8)
39 |
40 | #define NRF24_ADDRESS_LENGTH (5)
41 | #define NRF24_CONTROLFIELD_PAYLOAD_LENGTH_LENGTH_BITS (6)
42 | #define NRF24_CONTROLFIELD_PID_LENGTH_LENGTH_BITS (2)
43 | #define NRF24_CONTROLFIELD_NOACK_LENGTH_LENGTH_BITS (1)
44 | #define NRF24_CONTROLFIELD_LENGTH_BITS (NRF24_CONTROLFIELD_PAYLOAD_LENGTH_LENGTH_BITS+NRF24_CONTROLFIELD_PID_LENGTH_LENGTH_BITS+NRF24_CONTROLFIELD_NOACK_LENGTH_LENGTH_BITS)
45 | #define NRF24_CRC_LENGTH (2)
46 |
47 | #ifdef BYTE_ALIGN_PCAP
48 | #define NRF24_CONTROLFIELD_SHIFT (7)
49 | #else
50 | #define NRF24_CONTROLFIELD_SHIFT (0)
51 | #endif
52 | #define NRF24_OFFSET_CONTROLFIELD_BITS (BYTES_TO_BITS(NRF24_ADDRESS_LENGTH)+NRF24_CONTROLFIELD_SHIFT)
53 |
54 | #define NRF24_PAYLOADLENGTH_MASK ((((guint16)1)< equals CRC-16-CCITT polynomial)
128 | */
129 | guint16 crc16(tvbuff_t *tvb, const guint16 len_bits)
130 | {
131 | guint16 crc = 0xffff;
132 | if ((len_bits > 0) && (len_bits <= BYTES_TO_BITS(tvb_length(tvb))))
133 | {
134 | // The length of the data might not be a multiple of full bytes.
135 | // Therefore we proceed over the data bit-by-bit (like the NRF24 does) to
136 | // calculate the CRC.
137 | guint16 data;
138 | guint8 byte, shift;
139 | guint16 bitoffs = 0;
140 |
141 | // Get a new byte for the next 8 bits.
142 | byte = tvb_get_guint8(tvb, bitoffs>>3);
143 | while (bitoffs < len_bits)
144 | {
145 | shift = bitoffs & 7;
146 | // Shift the active bit to the position of bit 15
147 | data = ((guint16)byte) << (8 + shift);
148 | // Assure all other bits are 0
149 | data &= 0x8000;
150 | crc ^= data;
151 | if (crc & 0x8000)
152 | {
153 | crc = (crc << 1) ^ 0x1021; // 0x1021 = (1) 0001 0000 0010 0001 = x^16+x^12+x^5+1
154 | }
155 | else
156 | {
157 | crc = (crc << 1);
158 | }
159 | ++bitoffs;
160 | if (0 == (bitoffs & 7))
161 | {
162 | // Get a new byte for the next 8 bits.
163 | byte = tvb_get_guint8(tvb, bitoffs>>3);
164 | }
165 | }
166 | }
167 | return crc;
168 | }
169 | #else
170 | #error CRC calculation not yet implemented/tested for byte aligned data...
171 | /* For byte aligned data we could simply pass the start-bit and nr of bits and the generated CRC so far for each
172 | string of bits. Then just continue calculation for each partial string to get the final CRC */
173 | #endif
174 |
175 |
176 | static gchar* buildColInfo( packet_info *pinfo, guint64 nodeAddress, guint8 payloadLen, guint8 pid, gboolean noAck)
177 | {
178 | static gchar buff[100];
179 | char *b = buff;
180 | guint8 i;
181 |
182 | b += sprintf(b, "Adr:0x");
183 | for (i = 0; i < NRF24_ADDRESS_LENGTH; ++i)
184 | {
185 | b += sprintf(b, "%02x", (guint8)(nodeAddress >> BYTES_TO_BITS(NRF24_ADDRESS_LENGTH-i-1)));
186 | }
187 | b += sprintf(b, ", Len:%d%s, Pid:%d, %s", payloadLen, payloadLen == 0 ? "(ack)" : "", pid, noAck ? "NoAck" : "Ack");
188 | return buff;
189 | }
190 |
191 | // content format
192 | static void dissect_nrf24(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
193 | {
194 | // your variable definitions go here
195 | int bitoffset = 0;
196 |
197 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "nrf24");
198 | col_add_fstr(pinfo->cinfo, COL_PACKET_LENGTH, "%d", tvb_length(tvb) );
199 |
200 | // Clear out stuff in the info column
201 | col_clear(pinfo->cinfo, COL_INFO);
202 | if (tree)
203 | {
204 | // in case that someone wants to know some details of our protocol
205 | // spawn a subtree and cut the sequence in readable parts
206 | proto_item *ti = NULL;
207 | proto_item *pi = NULL;
208 | proto_tree *nrf24_tree = NULL;
209 | gboolean crc_ok;
210 | guint64 nodeAddress;
211 | guint16 packetLenBits, calc_crc, packet_crc, controlField;
212 | guint8 payloadLen, pid, noAck;
213 |
214 | // Get control field (in lower NRF24_CONTROLFIELD_LENGTH_BITS bits) & extract payload length, pid & noack
215 | controlField = tvb_get_bits16(tvb, NRF24_OFFSET_CONTROLFIELD_BITS, NRF24_CONTROLFIELD_LENGTH_BITS, ENC_BIG_ENDIAN);
216 | payloadLen = (controlField >> (NRF24_CONTROLFIELD_PID_LENGTH_LENGTH_BITS+NRF24_CONTROLFIELD_NOACK_LENGTH_LENGTH_BITS))& NRF24_PAYLOADLENGTH_MASK;
217 | pid = (controlField >> NRF24_CONTROLFIELD_NOACK_LENGTH_LENGTH_BITS) & NRF24_PID_MASK;
218 | noAck = controlField & NRF24_NOACK_MASK;
219 |
220 | packetLenBits = BYTES_TO_BITS(NRF24_ADDRESS_LENGTH)
221 | +NRF24_CONTROLFIELD_LENGTH_BITS
222 | +BYTES_TO_BITS(payloadLen)
223 | +BYTES_TO_BITS(NRF24_CRC_LENGTH);
224 |
225 | ti = proto_tree_add_item(tree, proto_nrf24, tvb, 0 /*start*/, BITS_TO_BYTES(packetLenBits) /*end*/, ENC_NA);
226 | calc_crc = crc16(tvb, packetLenBits - BYTES_TO_BITS(NRF24_CRC_LENGTH));
227 |
228 | nrf24_tree = proto_item_add_subtree(ti, ett_nrf24);
229 |
230 | proto_tree_add_item(nrf24_tree, hf_nrf24_nodeaddress, tvb, BITS_TO_BYTES(bitoffset), NRF24_ADDRESS_LENGTH, ENC_NA);
231 | nodeAddress = tvb_get_ntoh64(tvb, 0);
232 | nodeAddress >>= BYTES_TO_BITS(sizeof(guint64)-NRF24_ADDRESS_LENGTH);
233 | bitoffset += BYTES_TO_BITS(NRF24_ADDRESS_LENGTH);
234 |
235 | proto_tree_add_bitmask(nrf24_tree, tvb, BITS_TO_BYTES(bitoffset), hf_nrf24_control, ett_nrf24_control, control_fields, ENC_BIG_ENDIAN);
236 | bitoffset += NRF24_CONTROLFIELD_LENGTH_BITS;
237 |
238 | #ifdef FT_CRC_ADDRESS
239 | // CRC is located in last bits of packet
240 | #ifdef BYTE_ALIGN_PCAP
241 | proto_tree_add_item(nrf24_tree, hf_nrf24_crc, tvb, BITS_TO_BYTES(bitoffset)+payloadLen, NRF24_CRC_LENGTH, ENC_NA);
242 | #else
243 | proto_tree_add_bits_item(nrf24_tree, hf_nrf24_crc, tvb, bitoffset+BYTES_TO_BITS(payloadLen), BYTES_TO_BITS(NRF24_CRC_LENGTH), ENC_NA);
244 | packet_crc = tvb_get_bits16(tvb, bitoffset+BYTES_TO_BITS(payloadLen), BYTES_TO_BITS(NRF24_CRC_LENGTH), ENC_BIG_ENDIAN);
245 | crc_ok = calc_crc == packet_crc;
246 | pi = proto_tree_add_boolean(nrf24_tree, hf_nrf24_crc_valid, tvb, BITS_TO_BYTES(bitoffset), 8, crc_ok);
247 | PROTO_ITEM_SET_GENERATED(pi);
248 | if (!crc_ok)
249 | {
250 | // Color the CRC when invalid.
251 | expert_add_info_format(pinfo, pi, PI_CHECKSUM, PI_WARN, "Calculated CRC 0x%02x, packet CRC 0x%02x", calc_crc, packet_crc);
252 | }
253 | // proto_tree_add_debug_text(tree, "CRC packet=0x%04x, calculated=0x%04x", packet_crc, calc_crc);
254 | #endif
255 | #endif
256 | if (crc_ok)
257 | {
258 | gchar* info = buildColInfo( pinfo, nodeAddress, payloadLen, pid, noAck != 0);
259 | col_add_str(pinfo->cinfo, COL_INFO, info );
260 | proto_item_append_text(ti, " - %s", info);
261 | col_add_str(pinfo->cinfo, COL_DEF_SRC, "?");
262 | col_add_fstr(pinfo->cinfo, COL_DEF_DST, "%d", (guint8)nodeAddress);
263 | }
264 | else
265 | {
266 | col_add_str(pinfo->cinfo, COL_INFO, "CRC Error");
267 | }
268 |
269 | if (payloadLen > 0)
270 | {
271 | tvbuff_t* tvb_next;
272 | #ifdef BYTE_ALIGN_PCAP
273 | tvb_next = tvb_new_subset(tvb, BITS_TO_BYTES(bitoffset), payloadLen, payloadLen);
274 | #else
275 | tvb_next = tvb_new_octet_aligned(tvb, bitoffset, BYTES_TO_BITS(payloadLen));
276 | #endif
277 | // proto_tree_add_debug_text(tree, "Payload offset=%d, len=%d", bitoffset, payloadLen<<3);
278 |
279 | add_new_data_source(pinfo, tvb_next, "NRF24 Payload Data");
280 | // The NRF24 header contains no indication of the payload type. Therefore we
281 | // pass it on to a list of heuristic dissectors for NRF24 payloads, or display
282 | // it as data when none found.
283 | if (!crc_ok || !dissector_try_heuristic(heur_subdissector_list, tvb_next, pinfo, tree, NULL))
284 | {
285 | call_dissector(data_handle, tvb_next, pinfo, tree);
286 | }
287 | }
288 | }
289 | }
290 |
291 | #define PAYLOADLENGTH_MASK (NRF24_PAYLOADLENGTH_MASK << (16-NRF24_CONTROLFIELD_SHIFT-NRF24_CONTROLFIELD_PAYLOAD_LENGTH_LENGTH_BITS))
292 | #define PID_MASK (NRF24_PID_MASK << (16-NRF24_CONTROLFIELD_SHIFT-NRF24_CONTROLFIELD_PAYLOAD_LENGTH_LENGTH_BITS-NRF24_CONTROLFIELD_PID_LENGTH_LENGTH_BITS))
293 | #define NOACK_MASK (NRF24_NOACK_MASK <<(16-NRF24_CONTROLFIELD_SHIFT-NRF24_CONTROLFIELD_PAYLOAD_LENGTH_LENGTH_BITS-NRF24_CONTROLFIELD_PID_LENGTH_LENGTH_BITS-NRF24_CONTROLFIELD_NOACK_LENGTH_LENGTH_BITS))
294 |
295 | void proto_register_nrf24(void)
296 | {
297 | /*
298 | NRF24L01
299 | 8bit address
300 | 7bit fill
301 | 9bit packet control
302 | 6bit payload length
303 | 2bit PID
304 | 1bite NO_ACK
305 | 0..32bytes Payload
306 | 1-2bytes CRC
307 | */
308 | static hf_register_info hf[] = {
309 | { &hf_nrf24_nodeaddress, { "Node address", "nrf24.node", FT_NRF24_ADDRESS, BASE_HEX, NULL, 0x0, NULL, HFILL } },
310 | { &hf_nrf24_control, { "Control field", "nrf24.ctrl", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL } },
311 | { &hf_nrf24_control_payloadlength, { "Payload length", "nrf24.ctrl.len", FT_UINT16, BASE_DEC, NULL, PAYLOADLENGTH_MASK, NULL, HFILL } },
312 | { &hf_nrf24_control_pid, { "PID", "nrf24.ctrl.pid", FT_UINT16, BASE_DEC, NULL, PID_MASK, NULL, HFILL } },
313 | { &hf_nrf24_control_noack, { "No ack", "nrf24.ctrl.noack", FT_UINT16, BASE_DEC, VALS(noack_types), NOACK_MASK, NULL, HFILL } },
314 | #ifdef FT_CRC_ADDRESS
315 | { &hf_nrf24_crc, { "CRC", "nrf24.crc", FT_CRC_ADDRESS, BASE_HEX, NULL, 0x0, NULL, HFILL } },
316 | { &hf_nrf24_crc_valid, { "CRC Valid", "nrf24.crcvalid", FT_BOOLEAN, BASE_NONE, NULL, 0x0, NULL, HFILL } },
317 | #endif
318 | };
319 | static int *ett[] = {
320 | &ett_nrf24, // subtree nrf24mysns
321 | &ett_nrf24_control // subtree nrf24mysns control field
322 | };
323 |
324 | proto_nrf24 = proto_register_protocol (
325 | "NRF24", // name
326 | "nrf24", // short name
327 | "nrf24" // abb ref
328 | );
329 | register_dissector("nrf24", dissect_nrf24, proto_nrf24);
330 |
331 |
332 | register_heur_dissector_list("nrf24", &heur_subdissector_list);
333 |
334 | proto_register_field_array(proto_nrf24, hf, array_length(hf));
335 | proto_register_subtree_array(ett, array_length(ett));
336 | }
337 |
338 | /* Register Protocol handler */
339 | void proto_reg_handoff_nrf24(void)
340 | {
341 | static dissector_handle_t nrf24_handle;
342 |
343 | nrf24_handle = create_dissector_handle(dissect_nrf24, proto_nrf24);
344 | data_handle = find_dissector("data");
345 | }
346 |
--------------------------------------------------------------------------------
/Wireshark/src/nrf24/plugin.rc.in:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/src/nrf24/plugin.rc.in
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/AUTHORS:
--------------------------------------------------------------------------------
1 | Authors:
2 | Ivo Pullens
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # CMakeLists.txt
2 | #
3 | # $Id$
4 | #
5 | # Wireshark - Network traffic analyzer
6 | # By Gerald Combs
7 | # Copyright 1998 Gerald Combs
8 | #
9 | # This program is free software; you can redistribute it and/or
10 | # modify it under the terms of the GNU General Public License
11 | # as published by the Free Software Foundation; either version 2
12 | # of the License, or (at your option) any later version.
13 | #
14 | # This program is distributed in the hope that it will be useful,
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | # GNU General Public License for more details.
18 | #
19 | # You should have received a copy of the GNU General Public License
20 | # along with this program; if not, write to the Free Software
21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 | #
23 |
24 | set(DISSECTOR_SRC
25 | packet-datagram.c
26 | packet-router.c
27 | packet-mesh.c
28 | )
29 |
30 | set(PLUGIN_FILES
31 | plugin.c
32 | ${DISSECTOR_SRC}
33 | )
34 | # ${DISSECTOR_SUPPORT_SRC}
35 |
36 | set(CLEAN_FILES
37 | ${PLUGIN_FILES}
38 | )
39 |
40 | if (WERROR)
41 | set_source_files_properties(
42 | ${CLEAN_FILES}
43 | PROPERTIES
44 | COMPILE_FLAGS -Werror
45 | )
46 | endif()
47 |
48 | include_directories(${CMAKE_CURRENT_SOURCE_DIR})
49 |
50 | register_dissector_files(plugin.c
51 | plugin
52 | ${DISSECTOR_SRC}
53 | )
54 |
55 | add_library(radiohead ${LINK_MODE_MODULE}
56 | ${PLUGIN_FILES}
57 | )
58 | set_target_properties(radiohead PROPERTIES PREFIX "")
59 | set_target_properties(radiohead PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}")
60 |
61 | target_link_libraries(radiohead)
62 |
63 | install(TARGETS radiohead
64 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION} NAMELINK_SKIP
65 | RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION}
66 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/@CPACK_PACKAGE_NAME@/plugins/${CPACK_PACKAGE_VERSION}
67 | )
68 |
69 |
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/ChangeLog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/src/radiohead/ChangeLog
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/Makefile.am:
--------------------------------------------------------------------------------
1 | # Makefile.am
2 | # Automake file for radiohead plugin
3 | #
4 | # $Id$
5 | #
6 | # Wireshark - Network traffic analyzer
7 | # By Gerald Combs
8 | # Copyright 1998 Gerald Combs
9 | #
10 | # This program is free software; you can redistribute it and/or
11 | # modify it under the terms of the GNU General Public License
12 | # as published by the Free Software Foundation; either version 2
13 | # of the License, or (at your option) any later version.
14 | #
15 | # This program is distributed in the hope that it will be useful,
16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 | # GNU General Public License for more details.
19 | #
20 | # You should have received a copy of the GNU General Public License
21 | # along with this program; if not, write to the Free Software
22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 | #
24 |
25 | include $(top_srcdir)/Makefile.am.inc
26 |
27 | AM_CPPFLAGS = -I$(top_srcdir) -I../wimax
28 |
29 | include Makefile.common
30 |
31 | if HAVE_WARNINGS_AS_ERRORS
32 | AM_CFLAGS = -Werror
33 | endif
34 |
35 | plugindir = @plugindir@
36 |
37 | plugin_LTLIBRARIES = radiohead.la
38 |
39 | radiohead_la_SOURCES = \
40 | plugin.c \
41 | moduleinfo.h \
42 | $(SRC_FILES) \
43 | $(HEADER_FILES)
44 |
45 | radiohead_la_LDFLAGS = -module -avoid-version
46 | radiohead_la_LIBADD = @PLUGIN_LIBS@
47 |
48 | # Libs must be cleared, or else libtool won't create a shared module.
49 | # If your module needs to be linked against any particular libraries,
50 | # add them here.
51 | LIBS =
52 |
53 | #
54 | # Build plugin.c, which contains the plugin version[] string, a
55 | # function plugin_register() that calls the register routines for all
56 | # protocols, and a function plugin_reg_handoff() that calls the handoff
57 | # registration routines for all protocols.
58 | #
59 | # We do this by scanning sources. If that turns out to be too slow,
60 | # maybe we could just require every .o file to have an register routine
61 | # of a given name (packet-aarp.o -> proto_register_aarp, etc.).
62 | #
63 | # Formatting conventions: The name of the proto_register_* routines an
64 | # proto_reg_handoff_* routines must start in column zero, or must be
65 | # preceded only by "void " starting in column zero, and must not be
66 | # inside #if.
67 | #
68 | # REGISTER_SRC_FILES is assumed to have all the files that need to be scanned.
69 | #
70 | # For some unknown reason, having a big "for" loop in the Makefile
71 | # to scan all the files doesn't work with some "make"s; they seem to
72 | # pass only the first few names in the list to the shell, for some
73 | # reason.
74 | #
75 | # Therefore, we have a script to generate the plugin.c file.
76 | # The shell script runs slowly, as multiple greps and seds are run
77 | # for each input file; this is especially slow on Windows. Therefore,
78 | # if Python is present (as indicated by PYTHON being defined), we run
79 | # a faster Python script to do that work instead.
80 | #
81 | # The first argument is the directory in which the source files live.
82 | # The second argument is "plugin", to indicate that we should build
83 | # a plugin.c file for a plugin.
84 | # All subsequent arguments are the files to scan.
85 | #
86 | plugin.c: $(REGISTER_SRC_FILES) Makefile.common $(top_srcdir)/tools/make-dissector-reg \
87 | $(top_srcdir)/tools/make-dissector-reg.py
88 | @if test -n "$(PYTHON)"; then \
89 | echo Making plugin.c with python ; \
90 | $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \
91 | plugin $(REGISTER_SRC_FILES) ; \
92 | else \
93 | echo Making plugin.c with shell script ; \
94 | $(top_srcdir)/tools/make-dissector-reg $(srcdir) \
95 | $(plugin_src) plugin $(REGISTER_SRC_FILES) ; \
96 | fi
97 |
98 | #
99 | # Currently plugin.c can be included in the distribution because
100 | # we always build all protocol dissectors. We used to have to check
101 | # whether or not to build the snmp dissector. If we again need to
102 | # variably build something, making plugin.c non-portable, uncomment
103 | # the dist-hook line below.
104 | #
105 | # Oh, yuk. We don't want to include "plugin.c" in the distribution, as
106 | # its contents depend on the configuration, and therefore we want it
107 | # to be built when the first "make" is done; however, Automake insists
108 | # on putting *all* source into the distribution.
109 | #
110 | # We work around this by having a "dist-hook" rule that deletes
111 | # "plugin.c", so that "dist" won't pick it up.
112 | #
113 | #dist-hook:
114 | # @rm -f $(distdir)/plugin.c
115 |
116 | CLEANFILES = \
117 | radiohead \
118 | *~
119 |
120 | MAINTAINERCLEANFILES = \
121 | Makefile.in \
122 | plugin.c
123 |
124 | EXTRA_DIST = \
125 | Makefile.common \
126 | Makefile.nmake \
127 | moduleinfo.nmake \
128 | plugin.rc.in \
129 | CMakeLists.txt
130 |
131 | checkapi:
132 | $(PERL) $(top_srcdir)/tools/checkAPIs.pl -g abort -g termoutput -build \
133 | $(CLEAN_SRC_FILES) $(CLEAN_HEADER_FILES)
134 |
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/Makefile.common:
--------------------------------------------------------------------------------
1 | # Makefile.common for RadioHead plugin
2 | # Contains the stuff from Makefile.am and Makefile.nmake that is
3 | # a) common to both files and
4 | # b) portable between both files
5 | #
6 | # $Id$
7 | #
8 | # Wireshark - Network traffic analyzer
9 | # By Gerald Combs
10 | # Copyright 1998 Gerald Combs
11 | #
12 | # This program is free software; you can redistribute it and/or
13 | # modify it under the terms of the GNU General Public License
14 | # as published by the Free Software Foundation; either version 2
15 | # of the License, or (at your option) any later version.
16 | #
17 | # This program is distributed in the hope that it will be useful,
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | # GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License
23 | # along with this program; if not, write to the Free Software
24 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 |
26 | # the name of the plugin
27 | PLUGIN_NAME = radiohead
28 |
29 | # the dissector sources (without any helpers)
30 | # Non-generated sources to be scanned for registration routines
31 | NONGENERATED_REGISTER_C_FILES = \
32 | packet-datagram.c \
33 | packet-router.c \
34 | packet-mesh.c \
35 |
36 | # Non-generated sources
37 | NONGENERATED_C_FILES = \
38 | $(NONGENERATED_REGISTER_C_FILES)
39 |
40 | include ../Makefile.common.inc
41 |
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/Makefile.nmake:
--------------------------------------------------------------------------------
1 | # Makefile.nmake
2 | # nmake file for radiohead plugin
3 | #
4 | # $Id$
5 | #
6 |
7 | include ..\..\config.nmake
8 | include ..\..\Makefile.nmake.inc
9 |
10 | include moduleinfo.nmake
11 |
12 | include Makefile.common
13 |
14 | CFLAGS=$(WARNINGS_ARE_ERRORS) $(STANDARD_CFLAGS) \
15 | /I../.. /I../wimax $(GLIB_CFLAGS) \
16 | /I$(PCAP_DIR)\include
17 |
18 | .c.obj::
19 | $(CC) $(CFLAGS) -Fd.\ -c $<
20 |
21 | LDFLAGS = $(PLUGIN_LDFLAGS)
22 |
23 | !IFDEF ENABLE_LIBWIRESHARK
24 | LINK_PLUGIN_WITH=..\..\epan\libwireshark.lib
25 | CFLAGS=$(CFLAGS)
26 |
27 | OBJECTS = $(C_FILES:.c=.obj) $(CPP_FILES:.cpp=.obj) plugin.obj
28 |
29 | RESOURCE=$(PLUGIN_NAME).res
30 |
31 | all: $(PLUGIN_NAME).dll
32 |
33 | $(PLUGIN_NAME).rc : moduleinfo.nmake
34 | sed -e s/@PLUGIN_NAME@/$(PLUGIN_NAME)/ \
35 | -e s/@RC_MODULE_VERSION@/$(RC_MODULE_VERSION)/ \
36 | -e s/@RC_VERSION@/$(RC_VERSION)/ \
37 | -e s/@MODULE_VERSION@/$(MODULE_VERSION)/ \
38 | -e s/@PACKAGE@/$(PACKAGE)/ \
39 | -e s/@VERSION@/$(VERSION)/ \
40 | -e s/@MSVC_VARIANT@/$(MSVC_VARIANT)/ \
41 | < plugin.rc.in > $@
42 |
43 | $(PLUGIN_NAME).dll $(PLUGIN_NAME).exp $(PLUGIN_NAME).lib : $(OBJECTS) $(LINK_PLUGIN_WITH) $(RESOURCE)
44 | link -dll /out:$(PLUGIN_NAME).dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \
45 | $(GLIB_LIBS) $(RESOURCE)
46 |
47 | #
48 | # Build plugin.c, which contains the plugin version[] string, a
49 | # function plugin_register() that calls the register routines for all
50 | # protocols, and a function plugin_reg_handoff() that calls the handoff
51 | # registration routines for all protocols.
52 | #
53 | # We do this by scanning sources. If that turns out to be too slow,
54 | # maybe we could just require every .o file to have an register routine
55 | # of a given name (packet-aarp.o -> proto_register_aarp, etc.).
56 | #
57 | # Formatting conventions: The name of the proto_register_* routines an
58 | # proto_reg_handoff_* routines must start in column zero, or must be
59 | # preceded only by "void " starting in column zero, and must not be
60 | # inside #if.
61 | #
62 | # REGISTER_SRC_FILES is assumed to have all the files that need to be scanned.
63 | #
64 | # For some unknown reason, having a big "for" loop in the Makefile
65 | # to scan all the files doesn't work with some "make"s; they seem to
66 | # pass only the first few names in the list to the shell, for some
67 | # reason.
68 | #
69 | # Therefore, we have a script to generate the plugin.c file.
70 | # The shell script runs slowly, as multiple greps and seds are run
71 | # for each input file; this is especially slow on Windows. Therefore,
72 | # if Python is present (as indicated by PYTHON being defined), we run
73 | # a faster Python script to do that work instead.
74 | #
75 | # The first argument is the directory in which the source files live.
76 | # The second argument is "plugin", to indicate that we should build
77 | # a plugin.c file for a plugin.
78 | # All subsequent arguments are the files to scan.
79 | #
80 | !IFDEF PYTHON
81 | plugin.c: $(REGISTER_SRC_FILES) moduleinfo.h Makefile.common ../../tools/make-dissector-reg.py
82 | @echo Making plugin.c (using python)
83 | @$(PYTHON) "../../tools/make-dissector-reg.py" . plugin $(REGISTER_SRC_FILES)
84 | !ELSE
85 | plugin.c: $(REGISTER_SRC_FILES) moduleinfo.h Makefile.common ../../tools/make-dissector-reg
86 | @echo Making plugin.c (using sh)
87 | @$(SH) ../../tools/make-dissector-reg . plugin $(REGISTER_SRC_FILES)
88 | !ENDIF
89 |
90 | !ENDIF
91 |
92 | clean:
93 | rm -f $(OBJECTS) $(RESOURCE) plugin.c *.pdb *.sbr \
94 | $(PLUGIN_NAME).dll $(PLUGIN_NAME).dll.manifest $(PLUGIN_NAME).lib \
95 | $(PLUGIN_NAME).exp $(PLUGIN_NAME).rc
96 |
97 | distclean: clean
98 |
99 | maintainer-clean: distclean
100 |
101 | checkapi:
102 | $(PERL) ../../tools/checkAPIs.pl -g abort -g termoutput -build \
103 | $(CLEAN_SRC_FILES) $(CLEAN_HEADER_FILES)
104 |
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/moduleinfo.h:
--------------------------------------------------------------------------------
1 | /* moduleinfo.h
2 | *
3 | * Copyright (c) 2007 by Intel Corporation.
4 | *
5 | * Author: Lu Pan
6 | *
7 | * $Id$
8 | *
9 | * Wireshark - Network traffic analyzer
10 | * By Gerald Combs
11 | * Copyright 1999 Gerald Combs
12 | *
13 | * This program is free software; you can redistribute it and/or
14 | * modify it under the terms of the GNU General Public License
15 | * as published by the Free Software Foundation; either version 2
16 | * of the License, or (at your option) any later version.
17 | *
18 | * This program is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with this program; if not, write to the Free Software
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 | */
27 |
28 | /* Included *after* config.h, in order to re-define these macros */
29 |
30 | #ifdef PACKAGE
31 | #undef PACKAGE
32 | #endif
33 |
34 | /* Name of package */
35 | #define PACKAGE "radiohead"
36 |
37 |
38 | #ifdef VERSION
39 | #undef VERSION
40 | #endif
41 |
42 | /* Version number of package */
43 |
44 | #define stringiz1(x) #x
45 | #define stringize(x) stringiz1(x)
46 |
47 | #ifndef BUILD_NUMBER
48 | #define BUILD_NUMBER 0
49 | #endif
50 |
51 | #define VERSION "1.1." stringize(BUILD_NUMBER)
52 |
53 |
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/moduleinfo.nmake:
--------------------------------------------------------------------------------
1 | #
2 | # $Id$
3 | #
4 |
5 | # The name
6 | PACKAGE=radiohead
7 |
8 | # The version
9 | MODULE_VERSION_MAJOR=1
10 | MODULE_VERSION_MINOR=0
11 | MODULE_VERSION_MICRO=0
12 | MODULE_VERSION_EXTRA=0
13 |
14 | #
15 | # The RC_VERSION should be comma-separated, not dot-separated,
16 | # as per Graham Bloice's message in
17 | #
18 | # http://www.ethereal.com/lists/ethereal-dev/200303/msg00283.html
19 | #
20 | # "The RC_VERSION variable in config.nmake should be comma separated.
21 | # This allows the resources to be built correctly and the version
22 | # number to be correctly displayed in the explorer properties dialog
23 | # for the executables, and XP's tooltip, rather than 0.0.0.0."
24 | #
25 |
26 | MODULE_VERSION=$(MODULE_VERSION_MAJOR).$(MODULE_VERSION_MINOR).$(MODULE_VERSION_MICRO).$(MODULE_VERSION_EXTRA)
27 | RC_MODULE_VERSION=$(MODULE_VERSION_MAJOR),$(MODULE_VERSION_MINOR),$(MODULE_VERSION_MICRO),$(MODULE_VERSION_EXTRA)
28 |
29 |
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/packet-datagram.c:
--------------------------------------------------------------------------------
1 | /* packet-radiohead.c
2 | * Dissector for RadioHead wireless networking stack.
3 | *
4 | * Copyright (c) 2014, Ivo Pullens
5 | *
6 | * $Id$
7 | *
8 | * Wireshark - Network traffic analyzer
9 | * By Gerald Combs
10 | * Copyright 1999 Gerald Combs
11 | *
12 | * This program is free software; you can redistribute it and/or
13 | * modify it under the terms of the GNU General Public License
14 | * as published by the Free Software Foundation; either version 2
15 | * of the License, or (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | */
26 |
27 | #include "config.h"
28 |
29 | #include
30 | #include
31 | #include
32 |
33 | // Flags -- RHReliableDatagram.h
34 | #define RH_FLAGS_ACK_BIT (7)
35 | #define RH_FLAGS_ACK_MASK (((guint16)1)<>3)
40 | #define BYTES_TO_BITS(x) ((x)<<3)
41 |
42 | static const guint encoding = ENC_LITTLE_ENDIAN;
43 |
44 | static dissector_handle_t radiohead_datagram_handle;
45 |
46 | static heur_dissector_list_t heur_subdissector_list;
47 |
48 | static int hf_radiohead_datagram_to = -1;
49 | static int hf_radiohead_datagram_from = -1;
50 | static int hf_radiohead_datagram_id = -1;
51 | static int hf_radiohead_datagram_flags = -1;
52 | static int hf_radiohead_datagram_flags_ack = -1;
53 |
54 | static const int *flags_field[] = {
55 | &hf_radiohead_datagram_flags_ack,
56 | NULL
57 | };
58 |
59 | static int ett_radiohead_datagram = -1;
60 | static int ett_radiohead_datagram_flags = -1;
61 | static gint proto_radiohead_datagram = -1;
62 |
63 | static dissector_handle_t data_handle;
64 |
65 |
66 | static const value_string ack_types[] = {
67 | { 0, "NO_ACK" },
68 | { 1, "ACK" },
69 | { 0, NULL }
70 | };
71 |
72 | static gchar* radiohead_datagram_buildColInfo( packet_info *pinfo, /*const guint8 to, const guint8 from,*/ const guint8 id, const guint8 flags)
73 | {
74 | static gchar buff[100];
75 | gchar* s = buff;
76 | s += sprintf( s, "Id:%d", id);
77 | s += sprintf( s, ", Flags:%s", val_to_str((flags & RH_FLAGS_ACK_MASK)>>RH_FLAGS_ACK_BIT, ack_types, "%d") );
78 | return buff;
79 | }
80 |
81 | // content format
82 | static void dissect_radiohead_datagram(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
83 | {
84 | // your variable definitions go here
85 | int offset = 0;
86 |
87 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "rhdatagram");
88 | col_add_fstr(pinfo->cinfo, COL_PACKET_LENGTH, "%d", tvb_length(tvb) );
89 |
90 | // Clear out stuff in the info column
91 | col_clear(pinfo->cinfo, COL_INFO);
92 | if (tree)
93 | {
94 | // in case that someone wants to know some details of our protocol
95 | // spawn a subtree and cut the sequence in readable parts
96 | proto_item *ti = NULL;
97 | proto_item *pi = NULL;
98 | proto_tree *radiohead_tree = NULL;
99 | guint8 to, from, id, flags;
100 | guint length;
101 | gchar* info;
102 |
103 | ti = proto_tree_add_item(tree, proto_radiohead_datagram, tvb, 0 /*start*/, -1 /*end*/, encoding);
104 | radiohead_tree = proto_item_add_subtree(ti, ett_radiohead_datagram);
105 |
106 | length = tvb_length(tvb);
107 |
108 | proto_tree_add_item(radiohead_tree, hf_radiohead_datagram_to, tvb, offset, 1, encoding);
109 | to = tvb_get_guint8(tvb, offset);
110 | offset++;
111 | proto_tree_add_item(radiohead_tree, hf_radiohead_datagram_from, tvb, offset, 1, encoding);
112 | from = tvb_get_guint8(tvb, offset);
113 | offset++;
114 | proto_tree_add_item(radiohead_tree, hf_radiohead_datagram_id, tvb, offset, 1, encoding);
115 | id = tvb_get_guint8(tvb, offset);
116 | offset++;
117 | flags = tvb_get_guint8(tvb, offset);
118 | proto_tree_add_bitmask(radiohead_tree, tvb, offset, hf_radiohead_datagram_flags, ett_radiohead_datagram_flags, flags_field, encoding);
119 | offset++;
120 |
121 | info = radiohead_datagram_buildColInfo( pinfo, /*to, from,*/ id, flags);
122 | col_add_str(pinfo->cinfo, COL_INFO, info);
123 | proto_item_append_text(ti, " - %s", info);
124 | col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "%d", from);
125 | col_add_fstr(pinfo->cinfo, COL_DEF_DST, "%d", to);
126 |
127 | if (tvb_length_remaining(tvb, offset /*TODO: bits or bytes?*/) > 0)
128 | {
129 | tvbuff_t* tvb_next;
130 | tvb_next = tvb_new_subset(tvb, offset/*start*/, -1 /*to end*/, -1/*reported length*/ );
131 |
132 | add_new_data_source(pinfo, tvb_next, "RadioHead Datagram Payload Data");
133 | // The radiohead header contains no indication of the payload type. Therefore we
134 | // pass it on to a list of heuristic dissectors for radiohead payloads, or display
135 | // it as data when none found.
136 | if (!dissector_try_heuristic(heur_subdissector_list, tvb_next, pinfo, tree, NULL))
137 | {
138 | call_dissector(data_handle, tvb_next, pinfo, tree);
139 | }
140 | }
141 | }
142 | }
143 |
144 | static gboolean dissect_radiohead_datagram_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
145 | {
146 | /* 0) Test minimum packet length */
147 | if (tvb_length(tvb) < RH_DATAGRAM_MSG_HEADER_LENGTH)
148 | return FALSE;
149 |
150 | /* 1) ... */
151 |
152 | dissect_radiohead_datagram(tvb, pinfo, tree);
153 |
154 | return TRUE;
155 | }
156 |
157 | void proto_register_radiohead_datagram(void)
158 | {
159 | /*
160 | RadioHead 1.32
161 | RHDatagram:
162 | -TO The node address that the message is being sent to (broadcast RH_BROADCAST_ADDRESS (255) is permitted)
163 | -FROM The node address of the sending node
164 | -ID A message ID, distinct (over short time scales) for each message sent by a particilar node
165 | -FLAGS A bitmask of flags. The most significant 4 bits are reserved for use by RadioHead. The least significant 4 bits are reserved for applications.
166 |
167 | RHReliableDatagram:
168 | RHDatagram header, RH_FLAGS_ACK bit set,
169 | - 1 octet of payload containing ASCII '!' (since some drivers cannot handle 0 length payloads)
170 | */
171 |
172 | static hf_register_info hf[] = {
173 | // Name Abbrev Type Display Strings Bitmask Blurb DontTouch
174 | { &hf_radiohead_datagram_to, { "To", "radiohead.datagram.to", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
175 | { &hf_radiohead_datagram_from, { "From", "radiohead.datagram.from", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
176 | { &hf_radiohead_datagram_id, { "Id", "radiohead.datagram.id", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
177 | { &hf_radiohead_datagram_flags, { "Flags", "radiohead.datagram.flags", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } },
178 | { &hf_radiohead_datagram_flags_ack, { "Ack", "radiohead.datagram.flags.ack", FT_UINT8, BASE_DEC, VALS(ack_types), RH_FLAGS_ACK_MASK, NULL, HFILL } },
179 | };
180 | static int *ett[] = {
181 | &ett_radiohead_datagram, // subtree radiohead
182 | &ett_radiohead_datagram_flags // subtree radiohead flags field
183 | };
184 |
185 | proto_radiohead_datagram = proto_register_protocol (
186 | "RadioHeadDatagram", // name
187 | "rhdatagram", // short name
188 | "rhdatagram" // abbrev
189 | );
190 | register_dissector("rhdatagram", dissect_radiohead_datagram, proto_radiohead_datagram);
191 | register_heur_dissector_list("rhdatagram", &heur_subdissector_list);
192 |
193 | proto_register_field_array(proto_radiohead_datagram, hf, array_length(hf));
194 | proto_register_subtree_array(ett, array_length(ett));
195 | }
196 |
197 | /* Register Protocol handler */
198 | void proto_reg_handoff_radiohead_datagram(void)
199 | {
200 | radiohead_datagram_handle = create_dissector_handle(dissect_radiohead_datagram, proto_radiohead_datagram);
201 | heur_dissector_add("nrf24" /*parent protocol*/, dissect_radiohead_datagram_heur, proto_radiohead_datagram);
202 | data_handle = find_dissector("data");
203 | }
204 |
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/packet-mesh.c:
--------------------------------------------------------------------------------
1 | /* packet-radiohead.c
2 | * Dissector for RadioHead wireless networking stack.
3 | *
4 | * Copyright (c) 2014, Ivo Pullens
5 | *
6 | * $Id$
7 | *
8 | * Wireshark - Network traffic analyzer
9 | * By Gerald Combs
10 | * Copyright 1999 Gerald Combs
11 | *
12 | * This program is free software; you can redistribute it and/or
13 | * modify it under the terms of the GNU General Public License
14 | * as published by the Free Software Foundation; either version 2
15 | * of the License, or (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | */
26 |
27 | #include "config.h"
28 |
29 | #include
30 | #include
31 | #include
32 |
33 | /* RHMesh.h */
34 | #define RH_MESH_MESSAGE_TYPE_MIN RH_MESH_MESSAGE_TYPE_APPLICATION
35 | #define RH_MESH_MESSAGE_TYPE_APPLICATION 0
36 | #define RH_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_REQUEST 1
37 | #define RH_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_RESPONSE 2
38 | #define RH_MESH_MESSAGE_TYPE_ROUTE_FAILURE 3
39 | #define RH_MESH_MESSAGE_TYPE_MAX RH_MESH_MESSAGE_TYPE_ROUTE_FAILURE
40 |
41 |
42 | #define RH_MESH_MSG_HEADER_LENGTH (1)
43 |
44 | #define BITS_TO_BYTES(x) (((x)+7)>>3)
45 | #define BYTES_TO_BITS(x) ((x)<<3)
46 |
47 | static const guint encoding = ENC_LITTLE_ENDIAN;
48 |
49 | static dissector_handle_t radiohead_mesh_handle;
50 |
51 | static heur_dissector_list_t heur_subdissector_list;
52 |
53 | static int hf_radiohead_mesh_type = -1;
54 | static int hf_radiohead_mesh_routedisc_destlen = -1;
55 | static int hf_radiohead_mesh_routedisc_dest = -1;
56 | static int hf_radiohead_mesh_routedisc_route = -1;
57 | static int hf_radiohead_mesh_routefail_dest = -1;
58 |
59 | static int ett_radiohead_mesh = -1;
60 | static int ett_radiohead_routedisc = -1;
61 | static int ett_radiohead_routefail = -1;
62 | static gint proto_radiohead_mesh = -1;
63 |
64 | static dissector_handle_t data_handle;
65 | static dissector_handle_t mesh_route_discovery_handle;
66 | static dissector_handle_t mesh_route_fail;
67 |
68 | static const value_string msgtype_types[] = {
69 | { RH_MESH_MESSAGE_TYPE_APPLICATION, "APPLICATION" },
70 | { RH_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_REQUEST, "ROUTE_DISCOVERY_REQUEST" },
71 | { RH_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_RESPONSE, "ROUTE_DISCOVERY_RESPONSE" },
72 | { RH_MESH_MESSAGE_TYPE_ROUTE_FAILURE, "ROUTE_FAILURE" },
73 | { 0, NULL }
74 | };
75 |
76 |
77 | static gchar* radiohead_mesh_buildColInfo( packet_info *pinfo, const guint8 type)
78 | {
79 | static gchar buff[100];
80 | gchar* s = buff;
81 | s += sprintf( s, "Type:%s", val_to_str(type, msgtype_types, "%d") );
82 | return buff;
83 | }
84 |
85 | // content format
86 | static void dissect_radiohead_mesh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
87 | {
88 | // your variable definitions go here
89 | int offset = 0;
90 |
91 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "rhmesh");
92 | col_add_fstr(pinfo->cinfo, COL_PACKET_LENGTH, "%d", tvb_length(tvb) );
93 |
94 | // Clear out stuff in the info column
95 | col_clear(pinfo->cinfo, COL_INFO);
96 | if (tree)
97 | {
98 | // in case that someone wants to know some details of our protocol
99 | // spawn a subtree and cut the sequence in readable parts
100 | proto_item *ti = NULL;
101 | proto_item *pi = NULL;
102 | proto_tree *radiohead_tree = NULL;
103 | guint8 type;
104 | guint length;
105 | gchar* info;
106 |
107 | ti = proto_tree_add_item(tree, proto_radiohead_mesh, tvb, 0 /*start*/, -1 /*end*/, encoding);
108 | radiohead_tree = proto_item_add_subtree(ti, ett_radiohead_mesh);
109 |
110 | length = tvb_length(tvb);
111 |
112 | pi = proto_tree_add_item(radiohead_tree, hf_radiohead_mesh_type, tvb, offset, 1, encoding);
113 | type = tvb_get_guint8(tvb, offset);
114 | offset++;
115 |
116 | info = radiohead_mesh_buildColInfo( pinfo, type);
117 | col_add_str(pinfo->cinfo, COL_INFO, info);
118 | proto_item_append_text(ti, " - %s", info);
119 |
120 | if (tvb_length_remaining(tvb, offset) > 0)
121 | {
122 | proto_tree *pt = NULL;
123 | gint len;
124 | switch( type )
125 | {
126 | case RH_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_REQUEST: /*fallthrough*/
127 | case RH_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_RESPONSE:
128 | pt = proto_item_add_subtree (pi, ett_radiohead_routedisc);
129 | proto_tree_add_item(pt, hf_radiohead_mesh_routedisc_destlen, tvb, offset, 1, encoding);
130 | offset++;
131 | proto_tree_add_item(pt, hf_radiohead_mesh_routedisc_dest, tvb, offset, 1, encoding);
132 | offset++;
133 | len = tvb_length_remaining(tvb, offset);
134 | if (len > 0)
135 | {
136 | proto_tree_add_item(pt, hf_radiohead_mesh_routedisc_route, tvb, offset, len, encoding);
137 | offset += len;
138 | }
139 | break;
140 | case RH_MESH_MESSAGE_TYPE_ROUTE_FAILURE:
141 | pt = proto_item_add_subtree (pi, ett_radiohead_routefail);
142 | proto_tree_add_item(pt, hf_radiohead_mesh_routedisc_dest, tvb, offset, 1, encoding);
143 | offset++;
144 | break;
145 | case RH_MESH_MESSAGE_TYPE_APPLICATION: /*fallthrough*/
146 | default:
147 | {
148 | tvbuff_t* tvb_next = tvb_new_subset(tvb, offset/*start*/, -1 /*to end*/, -1/*reported length*/ );
149 | add_new_data_source(pinfo, tvb_next, "RadioHead Mesh Payload Data");
150 | if (!dissector_try_heuristic(heur_subdissector_list, tvb_next, pinfo, tree, NULL))
151 | {
152 | call_dissector(data_handle, tvb_next, pinfo, tree);
153 | }
154 | }
155 | break;
156 | }
157 | }
158 | }
159 | }
160 |
161 |
162 | static gboolean dissect_radiohead_mesh_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
163 | {
164 | gint8 type;
165 |
166 | /* 0) Test minimum packet length */
167 | if (tvb_length(tvb) < RH_MESH_MSG_HEADER_LENGTH)
168 | return FALSE;
169 |
170 | /* 1) First octet must contain a valid RH_MESH_MESSAGE_TYPE_* type */
171 | type = tvb_get_guint8(tvb, 0);
172 | if ((type < RH_MESH_MESSAGE_TYPE_MIN) || (type > RH_MESH_MESSAGE_TYPE_MAX))
173 | return FALSE;
174 |
175 | dissect_radiohead_mesh(tvb, pinfo, tree);
176 | return TRUE;
177 | }
178 |
179 | void proto_register_radiohead_mesh(void)
180 | {
181 | /*
182 | RadioHead 1.32
183 | RHMesh:
184 | - MeshMessageHeader
185 | - 1 octet MSGTYPE
186 |
187 | * MeshApplicationMessage (message type RH_MESH_MESSAGE_TYPE_APPLICATION). Carries an application layer message for the caller of RHMesh
188 | - 0..n octets DATA
189 | * MeshRouteDiscoveryMessage (message types RH_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_REQUEST and RH_MESH_MESSAGE_TYPE_ROUTE_DISCOVERY_RESPONSE). Carries Route Discovery messages (broadcast) and replies (unicast).
190 | - 1 octet DESTLEN. Reserved (must be 1)
191 | - 1 octet DEST. The address of the destination node whose route is being sought.
192 | - 0..n octets ROUTE. List of node addresses visited so far. Length is implcit.
193 | * MeshRouteFailureMessage (message type RH_MESH_MESSAGE_TYPE_ROUTE_FAILURE) Informs nodes of route failures.
194 | - 1 octet DEST. The address of the destination towards which the route failed.
195 | */
196 | static hf_register_info hf[] = {
197 | // Name Abbrev Type Display Strings Bitmask Blurb DontTouch
198 | { &hf_radiohead_mesh_type, { "Type", "radiohead.mesh.type", FT_UINT8, BASE_DEC, VALS(msgtype_types), 0, NULL, HFILL } },
199 | { &hf_radiohead_mesh_routedisc_destlen, { "Dest len", "radiohead.mesh.routedisc.destlen", FT_UINT8, BASE_DEC, 0, 0, NULL, HFILL } },
200 | { &hf_radiohead_mesh_routedisc_dest, { "Dest", "radiohead.mesh.routedisc.dest", FT_UINT8, BASE_DEC, 0, 0, NULL, HFILL } },
201 | { &hf_radiohead_mesh_routedisc_route, { "Route", "radiohead.mesh.routedisc.route", FT_BYTES, BASE_NONE, 0, 0, NULL, HFILL } },
202 | { &hf_radiohead_mesh_routefail_dest, { "Dest", "radiohead.mesh.routefail.dest", FT_UINT8, BASE_DEC, 0, 0, NULL, HFILL } },
203 | };
204 | static int *ett[] = {
205 | &ett_radiohead_mesh, // subtree radiohead
206 | &ett_radiohead_routedisc,
207 | &ett_radiohead_routefail
208 | };
209 |
210 | proto_radiohead_mesh = proto_register_protocol (
211 | "RadioHeadMesh", // name
212 | "rhmesh", // short name
213 | "rhmesh" // abbrev
214 | );
215 | register_dissector("rhmesh", dissect_radiohead_mesh, proto_radiohead_mesh);
216 | register_heur_dissector_list("rhmesh", &heur_subdissector_list);
217 |
218 | proto_register_field_array(proto_radiohead_mesh, hf, array_length(hf));
219 | proto_register_subtree_array(ett, array_length(ett));
220 | }
221 |
222 | /* Register Protocol handler */
223 | void proto_reg_handoff_radiohead_mesh(void)
224 | {
225 | radiohead_mesh_handle = create_dissector_handle(dissect_radiohead_mesh, proto_radiohead_mesh);
226 | heur_dissector_add("rhrouter" /*parent protocol*/, dissect_radiohead_mesh_heur, proto_radiohead_mesh);
227 | data_handle = find_dissector("data");
228 | }
229 |
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/packet-router.c:
--------------------------------------------------------------------------------
1 | /* packet-radiohead.c
2 | * Dissector for RadioHead wireless networking stack.
3 | *
4 | * Copyright (c) 2014, Ivo Pullens
5 | *
6 | * $Id$
7 | *
8 | * Wireshark - Network traffic analyzer
9 | * By Gerald Combs
10 | * Copyright 1999 Gerald Combs
11 | *
12 | * This program is free software; you can redistribute it and/or
13 | * modify it under the terms of the GNU General Public License
14 | * as published by the Free Software Foundation; either version 2
15 | * of the License, or (at your option) any later version.
16 | *
17 | * This program is distributed in the hope that it will be useful,
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 | * GNU General Public License for more details.
21 | *
22 | * You should have received a copy of the GNU General Public License
23 | * along with this program; if not, write to the Free Software
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 | */
26 |
27 | #include "config.h"
28 |
29 | #include
30 | #include
31 | #include
32 |
33 | #define RH_ROUTER_MSG_HEADER_LENGTH (5)
34 |
35 | #define BITS_TO_BYTES(x) (((x)+7)>>3)
36 | #define BYTES_TO_BITS(x) ((x)<<3)
37 |
38 | static const guint encoding = ENC_LITTLE_ENDIAN;
39 |
40 | static dissector_handle_t radiohead_router_handle;
41 |
42 | static heur_dissector_list_t heur_subdissector_list;
43 |
44 | static int hf_radiohead_router_dest = -1;
45 | static int hf_radiohead_router_source = -1;
46 | static int hf_radiohead_router_hops = -1;
47 | static int hf_radiohead_router_id = -1;
48 | static int hf_radiohead_router_flags = -1;
49 |
50 | static int ett_radiohead_router = -1;
51 | static gint proto_radiohead_router = -1;
52 |
53 | static dissector_handle_t data_handle;
54 |
55 | static gchar* radiohead_router_buildColInfo( packet_info *pinfo, const guint8 hops, const guint8 id, const guint8 flags)
56 | {
57 | static gchar buff[100];
58 | gchar* s = buff;
59 | s += sprintf( s, "Id:%d", id);
60 | s += sprintf( s, ", Hops:%d", hops);
61 | s += sprintf( s, ", Flags:%d", flags);
62 | return buff;
63 | }
64 |
65 | // content format
66 | static void dissect_radiohead_router(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
67 | {
68 | // your variable definitions go here
69 | int offset = 0;
70 |
71 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "rhrouter");
72 | col_add_fstr(pinfo->cinfo, COL_PACKET_LENGTH, "%d", tvb_length(tvb) );
73 |
74 | // Clear out stuff in the info column
75 | col_clear(pinfo->cinfo, COL_INFO);
76 | if (tree)
77 | {
78 | // in case that someone wants to know some details of our protocol
79 | // spawn a subtree and cut the sequence in readable parts
80 | proto_item *ti = NULL;
81 | proto_item *pi = NULL;
82 | proto_tree *radiohead_tree = NULL;
83 | guint8 dest, source, hops, id, flags;
84 | guint length;
85 | gchar* info;
86 |
87 | ti = proto_tree_add_item(tree, proto_radiohead_router, tvb, 0 /*start*/, -1 /*end*/, encoding);
88 | radiohead_tree = proto_item_add_subtree(ti, ett_radiohead_router);
89 |
90 | length = tvb_length(tvb);
91 |
92 | proto_tree_add_item(radiohead_tree, hf_radiohead_router_dest, tvb, offset, 1, encoding);
93 | dest = tvb_get_guint8(tvb, offset);
94 | offset++;
95 | proto_tree_add_item(radiohead_tree, hf_radiohead_router_source, tvb, offset, 1, encoding);
96 | source = tvb_get_guint8(tvb, offset);
97 | offset++;
98 | proto_tree_add_item(radiohead_tree, hf_radiohead_router_hops, tvb, offset, 1, encoding);
99 | hops = tvb_get_guint8(tvb, offset);
100 | offset++;
101 | proto_tree_add_item(radiohead_tree, hf_radiohead_router_id, tvb, offset, 1, encoding);
102 | id = tvb_get_guint8(tvb, offset);
103 | offset++;
104 | proto_tree_add_item(radiohead_tree, hf_radiohead_router_flags, tvb, offset, 1, encoding);
105 | flags = tvb_get_guint8(tvb, offset);
106 | offset++;
107 |
108 | info = radiohead_router_buildColInfo( pinfo, hops, id, flags);
109 | col_add_str(pinfo->cinfo, COL_INFO, info);
110 | proto_item_append_text(ti, " - %s", info);
111 | col_add_fstr(pinfo->cinfo, COL_DEF_SRC, "%d", source);
112 | col_add_fstr(pinfo->cinfo, COL_DEF_DST, "%d", dest);
113 |
114 | if (tvb_length_remaining(tvb, offset /*TODO: bits or bytes?*/) > 0)
115 | {
116 | tvbuff_t* tvb_next;
117 | tvb_next = tvb_new_subset(tvb, offset/*start*/, -1 /*to end*/, -1/*reported length*/ );
118 |
119 | add_new_data_source(pinfo, tvb_next, "RadioHead Router Payload Data");
120 | // The radiohead header contains no indication of the payload type. Therefore we
121 | // pass it on to a list of heuristic dissectors for radiohead payloads, or display
122 | // it as data when none found.
123 | if (!dissector_try_heuristic(heur_subdissector_list, tvb_next, pinfo, tree, NULL))
124 | {
125 | call_dissector(data_handle, tvb_next, pinfo, tree);
126 | }
127 | }
128 | }
129 | }
130 |
131 | static gboolean dissect_radiohead_router_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
132 | {
133 | /* 0) Test minimum packet length */
134 | if (tvb_length(tvb) < RH_ROUTER_MSG_HEADER_LENGTH)
135 | return FALSE;
136 |
137 | /* 1) ... */
138 |
139 | dissect_radiohead_router(tvb, pinfo, tree);
140 |
141 | return TRUE;
142 | }
143 |
144 | void proto_register_radiohead_router(void)
145 | {
146 | /*
147 | RadioHead 1.32
148 | RHRouter:
149 | - 1 octet DEST, the destination node address (ie the address of the final destination node for this message)
150 | - 1 octet SOURCE, the source node address (ie the address of the originating node that first sent the message).
151 | - 1 octet HOPS, the number of hops this message has traversed so far.
152 | - 1 octet ID, an incrementing message ID for end-to-end message tracking for use by subclasses. Not used by RHRouter.
153 | - 1 octet FLAGS, a bitmask for use by subclasses. Not used by RHRouter.
154 | - 0 or more octets DATA, the application payload data. The length of this data is implicit in the length of the entire message.
155 | */
156 |
157 | static hf_register_info hf[] = {
158 | // Name Abbrev Type Display Strings Bitmask Blurb DontTouch
159 | { &hf_radiohead_router_dest, { "Dest", "radiohead.router.dest", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
160 | { &hf_radiohead_router_source, { "Source", "radiohead.router.source", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
161 | { &hf_radiohead_router_hops, { "Hops", "radiohead.router.hops", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
162 | { &hf_radiohead_router_id, { "Id", "radiohead.router.id", FT_UINT8, BASE_DEC, NULL, 0, NULL, HFILL } },
163 | { &hf_radiohead_router_flags, { "Flags", "radiohead.router.flags", FT_UINT8, BASE_HEX, NULL, 0, NULL, HFILL } },
164 | };
165 | static int *ett[] = {
166 | &ett_radiohead_router // subtree radiohead
167 | };
168 |
169 | proto_radiohead_router = proto_register_protocol (
170 | "RadioHeadRouter", // name
171 | "rhrouter", // short name
172 | "rhrouter" // abbrev
173 | );
174 | register_dissector("rhrouter", dissect_radiohead_router, proto_radiohead_router);
175 | register_heur_dissector_list("rhrouter", &heur_subdissector_list);
176 |
177 | proto_register_field_array(proto_radiohead_router, hf, array_length(hf));
178 | proto_register_subtree_array(ett, array_length(ett));
179 | }
180 |
181 | /* Register Protocol handler */
182 | void proto_reg_handoff_radiohead_router(void)
183 | {
184 | radiohead_router_handle = create_dissector_handle(dissect_radiohead_router, proto_radiohead_router);
185 | heur_dissector_add("rhdatagram" /*parent protocol*/, dissect_radiohead_router_heur, proto_radiohead_router);
186 | data_handle = find_dissector("data");
187 | }
188 |
--------------------------------------------------------------------------------
/Wireshark/src/radiohead/plugin.rc.in:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gobol/esp32_rf24_sniffer/6c0aa6850f18dc2c6600f9273d2ebaba09ee2948/Wireshark/src/radiohead/plugin.rc.in
--------------------------------------------------------------------------------
/include/README:
--------------------------------------------------------------------------------
1 |
2 | This directory is intended for project header files.
3 |
4 | A header file is a file containing C declarations and macro definitions
5 | to be shared between several project source files. You request the use of a
6 | header file in your project source file (C, C++, etc) located in `src` folder
7 | by including it, with the C preprocessing directive `#include'.
8 |
9 | ```src/main.c
10 |
11 | #include "header.h"
12 |
13 | int main (void)
14 | {
15 | ...
16 | }
17 | ```
18 |
19 | Including a header file produces the same results as copying the header file
20 | into each source file that needs it. Such copying would be time-consuming
21 | and error-prone. With a header file, the related declarations appear
22 | in only one place. If they need to be changed, they can be changed in one
23 | place, and programs that include the header file will automatically use the
24 | new version when next recompiled. The header file eliminates the labor of
25 | finding and changing all the copies as well as the risk that a failure to
26 | find one copy will result in inconsistencies within a program.
27 |
28 | In C, the usual convention is to give header files names that end with `.h'.
29 | It is most portable to use only letters, digits, dashes, and underscores in
30 | header file names, and at most one dot.
31 |
32 | Read more about using header files in official GCC documentation:
33 |
34 | * Include Syntax
35 | * Include Operation
36 | * Once-Only Headers
37 | * Computed Includes
38 |
39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
40 |
--------------------------------------------------------------------------------
/lib/CircularBuffer/CircularBuffer.h:
--------------------------------------------------------------------------------
1 | /*
2 | CircularBuffer - An Arduino circular buffering library for arbitrary types.
3 |
4 | Created by Ivo Pullens, Emmission, 2014 -- www.emmission.nl
5 |
6 | This library is free software; you can redistribute it and/or
7 | modify it under the terms of the GNU Lesser General Public
8 | License as published by the Free Software Foundation; either
9 | version 2.1 of the License, or (at your option) any later version.
10 |
11 | This library is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | Lesser General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public
17 | License along with this library; if not, write to the Free Software
18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 | */
20 |
21 | #ifndef CircularBuffer_h
22 | #define CircularBuffer_h
23 |
24 | #define DISABLE_IRQ \
25 | cli();
26 |
27 | #define RESTORE_IRQ \
28 | sei();
29 |
30 | template class CircularBuffer
31 | {
32 | public:
33 | /** Constructor
34 | * @param buffer Preallocated buffer of at least size records.
35 | * @param size Number of records available in the buffer.
36 | */
37 | CircularBuffer(T* buffer, const uint8_t size )
38 | : m_size(size), m_buff(buffer)
39 | {
40 | clear();
41 | }
42 |
43 | /** Clear all entries in the circular buffer. */
44 | void clear(void)
45 | {
46 | m_front = 0;
47 | m_fill = 0;
48 | }
49 |
50 | /** Test if the circular buffer is empty */
51 | inline bool empty(void) const
52 | {
53 | return !m_fill;
54 | }
55 |
56 | /** Return the number of records stored in the buffer */
57 | inline uint8_t available(void) const
58 | {
59 | return m_fill;
60 | }
61 |
62 | /** Test if the circular buffer is full */
63 | inline bool full(void) const
64 | {
65 | return m_fill == m_size;
66 | }
67 |
68 | /** Aquire record on front of the buffer, for writing.
69 | * After filling the record, it has to be pushed to actually
70 | * add it to the buffer.
71 | * @return Pointer to record, or NULL when buffer is full.
72 | */
73 | T* getFront(void) const
74 | {
75 | DISABLE_IRQ;
76 | T* f = NULL;
77 | if (!full())
78 | f = get(m_front);
79 | RESTORE_IRQ;
80 | return f;
81 | }
82 |
83 | /** Push record to front of the buffer
84 | * @param record Record to push. If record was aquired previously (using getFront) its
85 | * data will not be copied as it is already present in the buffer.
86 | * @return True, when record was pushed successfully.
87 | */
88 | bool pushFront(T* record)
89 | {
90 | bool ok = false;
91 | DISABLE_IRQ;
92 | if (!full())
93 | {
94 | T* f = get(m_front);
95 | if (f != record)
96 | *f = *record;
97 | m_front = (m_front+1) % m_size;
98 | m_fill++;
99 | ok = true;
100 | }
101 | RESTORE_IRQ;
102 | return ok;
103 | }
104 |
105 | /** Aquire record on back of the buffer, for reading.
106 | * After reading the record, it has to be pop'ed to actually
107 | * remove it from the buffer.
108 | * @return Pointer to record, or NULL when buffer is empty.
109 | */
110 | T* getBack(void) const
111 | {
112 | T* b = NULL;
113 | DISABLE_IRQ;
114 | if (!empty())
115 | b = get(back());
116 | RESTORE_IRQ;
117 | return b;
118 | }
119 |
120 | /** Remove record from back of the buffer.
121 | * @return True, when record was pop'ed successfully.
122 | */
123 | bool popBack(void)
124 | {
125 | bool ok = false;
126 | DISABLE_IRQ;
127 | if (!empty())
128 | {
129 | m_fill--;
130 | ok = true;
131 | }
132 | RESTORE_IRQ;
133 | return ok;
134 | }
135 |
136 | protected:
137 | inline T * get(const uint8_t idx) const
138 | {
139 | return &(m_buff[idx]);
140 | }
141 | inline uint8_t back(void) const
142 | {
143 | return (m_front - m_fill + m_size) % m_size;
144 | }
145 |
146 | const uint8_t m_size; // Total number of records that can be stored in the buffer.
147 | T* const m_buff; // Ptr to buffer holding all records.
148 | volatile uint8_t m_front; // Index of front element (not pushed yet).
149 | volatile uint8_t m_fill; // Amount of records currently pushed.
150 | };
151 |
152 | #endif // CircularBuffer_h
153 |
--------------------------------------------------------------------------------
/lib/README:
--------------------------------------------------------------------------------
1 |
2 | This directory is intended for project specific (private) libraries.
3 | PlatformIO will compile them to static libraries and link into executable file.
4 |
5 | The source code of each library should be placed in a an own separate directory
6 | ("lib/your_library_name/[here are source files]").
7 |
8 | For example, see a structure of the following two libraries `Foo` and `Bar`:
9 |
10 | |--lib
11 | | |
12 | | |--Bar
13 | | | |--docs
14 | | | |--examples
15 | | | |--src
16 | | | |- Bar.c
17 | | | |- Bar.h
18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
19 | | |
20 | | |--Foo
21 | | | |- Foo.c
22 | | | |- Foo.h
23 | | |
24 | | |- README --> THIS FILE
25 | |
26 | |- platformio.ini
27 | |--src
28 | |- main.c
29 |
30 | and a contents of `src/main.c`:
31 | ```
32 | #include
33 | #include
34 |
35 | int main (void)
36 | {
37 | ...
38 | }
39 |
40 | ```
41 |
42 | PlatformIO Library Dependency Finder will find automatically dependent
43 | libraries scanning project source files.
44 |
45 | More information about PlatformIO Library Dependency Finder
46 | - https://docs.platformio.org/page/librarymanager/ldf.html
47 |
--------------------------------------------------------------------------------
/lib/RF24/RF24_config.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | Copyright (C) 2011 J. Coliz
4 |
5 | This program is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU General Public License
7 | version 2 as published by the Free Software Foundation.
8 |
9 | Added Arduino Due support from https://github.com/mcrosson/
10 | */
11 |
12 | #ifndef __RF24_CONFIG_H__
13 | #define __RF24_CONFIG_H__
14 |
15 | #if ARDUINO < 100
16 | #include
17 | #else
18 | #include
19 | #endif
20 |
21 | #include
22 |
23 | //TMRh20:
24 | //#define MINIMAL
25 |
26 | // Define _BV for non-Arduino platforms and for Arduino DUE
27 | #if defined (ARDUINO)
28 | #include
29 | #else
30 | #include
31 | #include
32 | #include
33 | extern HardwareSPI SPI;
34 | #define _BV(x) (1<<(x))
35 | #endif
36 |
37 |
38 | #undef SERIAL_DEBUG
39 | #ifdef SERIAL_DEBUG
40 | #define IF_SERIAL_DEBUG(x) ({x;})
41 | #else
42 | #define IF_SERIAL_DEBUG(x)
43 | #if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__)
44 | #define printf_P(...)
45 | #endif
46 | #endif
47 |
48 | // Avoid spurious warnings
49 | // Arduino DUE is arm and uses traditional PROGMEM constructs
50 | #if 1
51 | #if ! defined( NATIVE ) && defined( ARDUINO ) && ! defined(__arm__)
52 | #undef PROGMEM
53 | #define PROGMEM __attribute__(( section(".progmem.data") ))
54 | #undef PSTR
55 | #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];}))
56 | #endif
57 | #endif
58 |
59 | // Progmem is Arduino-specific
60 | // Arduino DUE is arm and does not include avr/pgmspace
61 | #if defined(ARDUINO) && ! defined(__arm__) && ! defined(ESP32)
62 | #include
63 | #define PRIPSTR "%S"
64 | #else
65 | #if ! defined(ARDUINO) // This doesn't work on Arduino DUE
66 | typedef char const char;
67 | #else // Fill in pgm_read_byte that is used, but missing from DUE
68 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
69 | #endif
70 |
71 | typedef uint16_t prog_uint16_t;
72 | #define PSTR(x) (x)
73 | #define printf_P printf
74 | #define strlen_P strlen
75 | #define PROGMEM
76 | #define pgm_read_word(p) (*(p))
77 | #define PRIPSTR "%s"
78 | #endif
79 |
80 |
81 |
82 | // ATTiny support code is from https://github.com/jscrane/RF24
83 |
84 | #if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
85 | #include
86 | #include
87 | #include
88 |
89 | #define SPI_CLOCK_DIV4 0x00
90 | #define SPI_CLOCK_DIV16 0x01
91 | #define SPI_CLOCK_DIV64 0x02
92 | #define SPI_CLOCK_DIV128 0x03
93 | #define SPI_CLOCK_DIV2 0x04
94 | #define SPI_CLOCK_DIV8 0x05
95 | #define SPI_CLOCK_DIV32 0x06
96 | //#define SPI_CLOCK_DIV64 0x07
97 |
98 | #define SPI_MODE0 0x00
99 | #define SPI_MODE1 0x04
100 | #define SPI_MODE2 0x08
101 | #define SPI_MODE3 0x0C
102 |
103 | #define SPI_MODE_MASK 0x0C // CPOL = bit 3, CPHA = bit 2 on SPCR
104 | #define SPI_CLOCK_MASK 0x03 // SPR1 = bit 1, SPR0 = bit 0 on SPCR
105 | #define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR
106 |
107 |
108 |
109 | class SPIClass {
110 | public:
111 | static byte transfer(byte _data);
112 |
113 | // SPI Configuration methods
114 |
115 | inline static void attachInterrupt();
116 | inline static void detachInterrupt(); // Default
117 |
118 | static void begin(); // Default
119 | static void end();
120 |
121 | static void setBitOrder(uint8_t);
122 | static void setDataMode(uint8_t);
123 | static void setClockDivider(uint8_t);
124 | };
125 | extern SPIClass SPI;
126 |
127 | #endif //ATTiny
128 | #endif // __RF24_CONFIG_H__
129 |
130 |
--------------------------------------------------------------------------------
/lib/RF24/nRF24L01.h:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2007 Stefan Engelke
3 | Portions Copyright (C) 2011 Greg Copeland
4 |
5 | Permission is hereby granted, free of charge, to any person
6 | obtaining a copy of this software and associated documentation
7 | files (the "Software"), to deal in the Software without
8 | restriction, including without limitation the rights to use, copy,
9 | modify, merge, publish, distribute, sublicense, and/or sell copies
10 | of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 | DEALINGS IN THE SOFTWARE.
24 | */
25 |
26 | /* Memory Map */
27 | #define CONFIG 0x00
28 | #define EN_AA 0x01
29 | #define EN_RXADDR 0x02
30 | #define SETUP_AW 0x03
31 | #define SETUP_RETR 0x04
32 | #define RF_CH 0x05
33 | #define RF_SETUP 0x06
34 | #define RF_STATUS 0x07
35 | #define OBSERVE_TX 0x08
36 | #define CD 0x09
37 | #define RX_ADDR_P0 0x0A
38 | #define RX_ADDR_P1 0x0B
39 | #define RX_ADDR_P2 0x0C
40 | #define RX_ADDR_P3 0x0D
41 | #define RX_ADDR_P4 0x0E
42 | #define RX_ADDR_P5 0x0F
43 | #define TX_ADDR 0x10
44 | #define RX_PW_P0 0x11
45 | #define RX_PW_P1 0x12
46 | #define RX_PW_P2 0x13
47 | #define RX_PW_P3 0x14
48 | #define RX_PW_P4 0x15
49 | #define RX_PW_P5 0x16
50 | #define FIFO_STATUS 0x17
51 | #define DYNPD 0x1C
52 | #define FEATURE 0x1D
53 |
54 | /* Bit Mnemonics */
55 | #define MASK_RX_DR 6
56 | #define MASK_TX_DS 5
57 | #define MASK_MAX_RT 4
58 | #define EN_CRC 3
59 | #define CRCO 2
60 | #define PWR_UP 1
61 | #define PRIM_RX 0
62 | #define ENAA_P5 5
63 | #define ENAA_P4 4
64 | #define ENAA_P3 3
65 | #define ENAA_P2 2
66 | #define ENAA_P1 1
67 | #define ENAA_P0 0
68 | #define ERX_P5 5
69 | #define ERX_P4 4
70 | #define ERX_P3 3
71 | #define ERX_P2 2
72 | #define ERX_P1 1
73 | #define ERX_P0 0
74 | #define AW 0
75 | #define ARD 4
76 | #define ARC 0
77 | #define PLL_LOCK 4
78 | #define RF_DR 3
79 | #define RF_PWR 6
80 | #define RX_DR 6
81 | #define TX_DS 5
82 | #define MAX_RT 4
83 | #define RX_P_NO 1
84 | #define TX_FULL 0
85 | #define PLOS_CNT 4
86 | #define ARC_CNT 0
87 | #define TX_REUSE 6
88 | #define FIFO_FULL 5
89 | #define TX_EMPTY 4
90 | #define RX_FULL 1
91 | #define RX_EMPTY 0
92 | #define DPL_P5 5
93 | #define DPL_P4 4
94 | #define DPL_P3 3
95 | #define DPL_P2 2
96 | #define DPL_P1 1
97 | #define DPL_P0 0
98 | #define EN_DPL 2
99 | #define EN_ACK_PAY 1
100 | #define EN_DYN_ACK 0
101 |
102 | /* Instruction Mnemonics */
103 | #define R_REGISTER 0x00
104 | #define W_REGISTER 0x20
105 | #define REGISTER_MASK 0x1F
106 | #define ACTIVATE 0x50
107 | #define R_RX_PL_WID 0x60
108 | #define R_RX_PAYLOAD 0x61
109 | #define W_TX_PAYLOAD 0xA0
110 | #define W_ACK_PAYLOAD 0xA8
111 | #define FLUSH_TX 0xE1
112 | #define FLUSH_RX 0xE2
113 | #define REUSE_TX_PL 0xE3
114 | #define nRF_NOP 0xFF
115 |
116 | /* Non-P omissions */
117 | #define LNA_HCURR 0
118 |
119 | /* P model memory Map */
120 | #define RPD 0x09
121 | #define W_TX_PAYLOAD_NO_ACK 0xB0
122 |
123 | /* P model bit Mnemonics */
124 | #define RF_DR_LOW 5
125 | #define RF_DR_HIGH 3
126 | #define RF_PWR_LOW 1
127 | #define RF_PWR_HIGH 2
128 |
--------------------------------------------------------------------------------
/platformio.ini:
--------------------------------------------------------------------------------
1 | ; PlatformIO Project Configuration File
2 | ;
3 | ; Build options: build flags, source filter
4 | ; Upload options: custom upload port, speed and extra flags
5 | ; Library options: dependencies, extra library storages
6 | ; Advanced options: extra scripting
7 | ;
8 | ; Please visit documentation for the other options and examples
9 | ; https://docs.platformio.org/page/projectconf.html
10 |
11 | [env:esp32doit-devkit-v1]
12 | platform = espressif32
13 | board = esp32doit-devkit-v1
14 | framework = arduino
15 |
16 | upload_speed = 921600
17 | upload_port = COM8
18 | monitor_speed = 115200
19 | monitor_port = COM8
20 |
21 |
--------------------------------------------------------------------------------
/src/NRF24_sniff_types.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of NRF24_Sniff.
3 |
4 | Created by Ivo Pullens, Emmission, 2014 -- www.emmission.nl
5 |
6 | NRF24_Sniff is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | NRF24_Sniff is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU General Public License
17 | along with NRF24_Sniff. If not, see .
18 | */
19 |
20 | #ifndef NRF24_sniff_types_h
21 | #define NRF24_sniff_types_h
22 |
23 | #pragma pack(1)
24 |
25 |
26 | typedef struct _NRF24_packet_t
27 | {
28 | uint32_t timestamp;
29 | uint8_t packetsLost;
30 | uint8_t packet[MAX_RF_PAYLOAD_SIZE];
31 | } NRF24_packet_t;
32 |
33 | typedef struct _Serial_header_t
34 | {
35 | uint32_t timestamp;
36 | uint8_t packetsLost;
37 | uint8_t address[RF_MAX_ADDR_WIDTH]; // MSB first, always RF_MAX_ADDR_WIDTH bytes.
38 | } Serial_header_t;
39 |
40 | typedef struct _Serial_config_t
41 | {
42 | uint32_t channel;
43 | uint32_t rate; // rf24_datarate_e: 0 = 1Mb/s, 1 = 2Mb/s, 2 = 250Kb/s
44 | uint32_t addressLen; // Number of bytes used in address, range [2..5]
45 | uint32_t addressPromiscLen; // Number of bytes used in promiscuous address, range [2..5]. E.g. addressLen=5, addressPromiscLen=4 => 1 byte unique identifier.
46 | uint64_t address; // Base address, LSB first.
47 | uint32_t crcLength; // Length of active CRC, range [0..2]
48 | uint32_t maxPayloadSize; // Maximum size of payload for nRF (including nRF header), range[4?..32]
49 | } Serial_config_t;
50 |
51 | #define MSG_TYPE_PACKET (0)
52 | #define MSG_TYPE_CONFIG (1)
53 |
54 | #define SET_MSG_TYPE(var,type) (((var) & 0x3F) | ((type) << 6))
55 | #define GET_MSG_TYPE(var) ((var) >> 6)
56 | #define GET_MSG_LEN(var) ((var) & 0x3F)
57 |
58 | #endif // NRF24_sniff_types_h
59 |
--------------------------------------------------------------------------------
/src/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | NRF24_Sniff - An Arduino sketch to promiscuous capture all wireless
3 | traffic generated by Nordic Semi. NRF24L01+ modules.
4 |
5 | Created by Ivo Pullens, Emmission, 2014 -- www.emmission.nl
6 |
7 | This program is free software: you can redistribute it and/or modify
8 | it under the terms of the GNU General Public License as published by
9 | the Free Software Foundation, either version 3 of the License, or
10 | (at your option) any later version.
11 |
12 | This program is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | GNU General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program. If not, see .
19 | */
20 |
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 |
27 | #define LED_SUPPORTED
28 |
29 | // Hardware configuration
30 | #define RF_CE_PIN (22)
31 | #define RF_CS_PIN (5)
32 | #define RF_IRQ_PIN (21)
33 | #define RF_IRQ (RF_IRQ_PIN) // Usually the interrupt = pin -2 (on uno/nano anyway)
34 |
35 | #ifdef LED_SUPPORTED
36 | #define LED_PIN_LISTEN (2)
37 | #define LED_PIN_RX (2)
38 | #define LED_PIN_TX (2)
39 | #define LED_PIN_CONFIG (2)
40 | #define LED_PIN_BUFF_FULL (2)
41 | #endif
42 |
43 | #define RF_MAX_ADDR_WIDTH (5) // Maximum address width, in bytes. MySensors use 5 bytes for addressing, where lowest byte is for node addressing.
44 | #define MAX_RF_PAYLOAD_SIZE (32)
45 | #define SER_BAUDRATE (115200)
46 | #define PACKET_BUFFER_SIZE (30) // Maximum number of packets that can be buffered between reception by NRF and transmission over serial port.
47 | #define PIPE (0) // Pipe number to use for listening
48 |
49 |
50 | // Startup defaults until user reconfigures it
51 | #define DEFAULT_RF_CHANNEL (2) // 76 = Default channel for MySensors.
52 | #define DEFAULT_RF_DATARATE (RF24_2MBPS) // Datarate
53 | #define DEFAULT_RF_ADDR_WIDTH (RF_MAX_ADDR_WIDTH) // We use all but the lowest address byte for promiscuous listening. First byte of data received will then be the node address.
54 | #define DEFAULT_RF_ADDR_PROMISC_WIDTH (DEFAULT_RF_ADDR_WIDTH-1)
55 | //#define DEFAULT_RADIO_ID ((uint64_t)0xABCDABC000LL) // 0xABCDABC000LL = MySensors v1 (1.3) default
56 | //#define DEFAULT_RADIO_ID ((uint64_t)0xA8A8E1FC00LL) // 0xA8A8E1FC00LL = MySensors v2 (1.4) default
57 | #define DEFAULT_RADIO_ID ((uint64_t)0xE7E7E7E7E7LL) //
58 | #define DEFAULT_RF_CRC_LENGTH (2) // Length (in bytes) of NRF24 CRC
59 | #define DEFAULT_RF_PAYLOAD_SIZE (MAX_RF_PAYLOAD_SIZE) // Define NRF24 payload size to maximum, so we'll slurp as many bytes as possible from the packet.
60 |
61 |
62 | // If BINARY_OUTPUT is defined, this sketch will output in hex format to the PC.
63 | // If undefined it will output text output for development.
64 | #define BINARY_OUTPUT
65 |
66 | #include "NRF24_sniff_types.h"
67 |
68 |
69 | #ifndef BINARY_OUTPUT
70 | int my_putc( char c, FILE *t )
71 | {
72 | Serial.write( c );
73 | }
74 | #endif
75 |
76 | // Set up nRF24L01 radio on SPI bus plus CE/CS pins
77 | static RF24 radio(RF_CE_PIN, RF_CS_PIN);
78 |
79 | static NRF24_packet_t bufferData[PACKET_BUFFER_SIZE];
80 | static CircularBuffer packetBuffer(bufferData, sizeof(bufferData)/sizeof(bufferData[0]));
81 | static Serial_header_t serialHdr;
82 | static Serial_config_t conf = {
83 | DEFAULT_RF_CHANNEL, DEFAULT_RF_DATARATE, DEFAULT_RF_ADDR_WIDTH,
84 | DEFAULT_RF_ADDR_PROMISC_WIDTH, DEFAULT_RADIO_ID, DEFAULT_RF_CRC_LENGTH,
85 | DEFAULT_RF_PAYLOAD_SIZE
86 | };
87 |
88 | #define GET_PAYLOAD_LEN(p) ((p->packet[conf.addressLen-conf.addressPromiscLen] & 0xFC) >> 2) // First 6 bits of nRF header contain length.
89 |
90 | inline static void dumpData(uint8_t* p, int len)
91 | {
92 | #ifndef BINARY_OUTPUT
93 | while (len--) { printf("%02x", *p++); }
94 | Serial.print(' ');
95 | #else
96 | Serial.write(p, len);
97 | #endif
98 | }
99 |
100 | // static void sendConf(Serial_config_t cfg) {
101 | // uint8_t v;
102 | // Serial.write(&cfg.channel,1);
103 | // Serial.write(&cfg.rate,1);
104 | // Serial.write(&cfg.addressLen,1);
105 | // Serial.write(&cfg.addressPromiscLen,1);
106 | // for (int i=0;i<8;i++) {
107 | // v = cfg.address >> i;
108 | // Serial.write(&v,1);
109 | // }
110 | // Serial.write(&cfg.crcLength,1);
111 | // Serial.write(&cfg.maxPayloadSize,1);
112 | // }
113 |
114 | static void handleNrfIrq()
115 | {
116 | static uint8_t lostPacketCount = 0;
117 | // Loop until RX buffer(s) contain no more packets.
118 | while (radio.available())
119 | {
120 | #ifdef LED_SUPPORTED
121 | digitalWrite(LED_PIN_RX, HIGH);
122 | #endif
123 | if (!packetBuffer.full())
124 | {
125 | #ifdef LED_SUPPORTED
126 | digitalWrite(LED_PIN_BUFF_FULL, LOW);
127 | #endif
128 | NRF24_packet_t* p = packetBuffer.getFront();
129 | p->timestamp = micros(); // Micros does not increase in interrupt, but it can be used.
130 | p->packetsLost = lostPacketCount;
131 | uint8_t packetLen = radio.getPayloadSize();
132 | if (packetLen > MAX_RF_PAYLOAD_SIZE)
133 | packetLen = MAX_RF_PAYLOAD_SIZE;
134 |
135 | radio.read( p->packet, packetLen );
136 |
137 | // Determine length of actual payload (in bytes) received from NRF24 packet control field (bits 7..2 of byte with offset 1)
138 | // Enhanced shockburst format is assumed!
139 | if (GET_PAYLOAD_LEN(p) <= MAX_RF_PAYLOAD_SIZE)
140 | {
141 | // Seems like a valid packet. Enqueue it.
142 | packetBuffer.pushFront(p);
143 | }
144 | else
145 | {
146 | // Packet with invalid size received. Could increase some counter...
147 | }
148 | lostPacketCount = 0;
149 | }
150 | else
151 | {
152 | // Buffer full. Increase lost packet counter.
153 | #ifdef LED_SUPPORTED
154 | digitalWrite(LED_PIN_BUFF_FULL, HIGH);
155 | #endif
156 | bool tx_ok, tx_fail, rx_ready;
157 | if (lostPacketCount < 255)
158 | lostPacketCount++;
159 | // Call 'whatHappened' to reset interrupt status.
160 | radio.whatHappened(tx_ok, tx_fail, rx_ready);
161 | // Flush buffer to drop the packet.
162 | radio.flush_rx();
163 | }
164 | #ifdef LED_SUPPORTED
165 | digitalWrite(LED_PIN_RX, LOW);
166 | #endif
167 | }
168 | }
169 |
170 | static void activateConf( void )
171 | {
172 | #ifdef LED_SUPPORTED
173 | digitalWrite(LED_PIN_CONFIG, HIGH);
174 | #endif
175 |
176 | // Match MySensors' channel & datarate
177 | radio.setChannel(conf.channel);
178 | radio.setDataRate((rf24_datarate_e)conf.rate);
179 |
180 | // Disable CRC & set fixed payload size to allow all packets captured to be returned by Nrf24.
181 | radio.disableCRC();
182 | radio.setPayloadSize(conf.maxPayloadSize);
183 |
184 | // Configure listening pipe with the 'promiscuous' address and start listening
185 | radio.setAddressWidth(conf.addressPromiscLen);
186 | radio.openReadingPipe( PIPE, conf.address >> (8*(conf.addressLen - conf.addressPromiscLen)) );
187 | radio.startListening();
188 |
189 | // Attach interrupt handler to NRF IRQ output. Overwrites any earlier handler.
190 | attachInterrupt(RF_IRQ, handleNrfIrq, FALLING); // NRF24 Irq pin is active low.
191 |
192 | // Initialize serial header's address member to promiscuous address.
193 | uint64_t addr = conf.address; // TODO: probably add some shifting!
194 | for (int8_t i = sizeof(serialHdr.address)-1; i >= 0; --i)
195 | {
196 | serialHdr.address[i] = addr;
197 | addr >>= 8;
198 | }
199 |
200 | // Send config back. Write record length & message type
201 | uint8_t lenAndType = SET_MSG_TYPE(sizeof(conf), MSG_TYPE_CONFIG);
202 | dumpData(&lenAndType, sizeof(lenAndType));
203 | // Write config
204 | // sendConf(conf);
205 | dumpData((uint8_t*)&conf, sizeof(conf) );
206 |
207 | #ifndef BINARY_OUTPUT
208 | Serial.print("uint8_t: "); Serial.println(sizeof(uint8_t), DEC);
209 | Serial.print("uint64_t: "); Serial.println(sizeof(uint64_t), DEC);
210 | Serial.print("Channel: "); Serial.println(conf.channel);
211 | Serial.print("Datarate: ");
212 | switch (conf.rate)
213 | {
214 | case 0: Serial.println("1Mb/s"); break;
215 | case 1: Serial.println("2Mb/s"); break;
216 | case 2: Serial.println("250Kb/s"); break;
217 | }
218 | Serial.print("Address: 0x");
219 | uint64_t adr = conf.address;
220 | for (int8_t i = conf.addressLen-1; i >= 0; --i)
221 | {
222 | if ( i >= conf.addressLen - conf.addressPromiscLen )
223 | {
224 | Serial.print((uint8_t)(adr >> (8*i)), HEX);
225 | }
226 | else
227 | {
228 | Serial.print("**");
229 | }
230 | }
231 | Serial.println("");
232 | Serial.print("Max payload: "); Serial.println(conf.maxPayloadSize);
233 | Serial.print("CRC length: "); Serial.println(conf.crcLength);
234 | Serial.println("");
235 |
236 | radio.printDetails();
237 |
238 | Serial.println("");
239 | Serial.println("Listening...");
240 | #endif
241 | #ifdef LED_SUPPORTED
242 | digitalWrite(LED_PIN_CONFIG, LOW);
243 | #endif
244 | }
245 |
246 |
247 | void setup(void)
248 | {
249 | #ifdef LED_SUPPORTED
250 | pinMode(LED_PIN_LISTEN, OUTPUT);
251 | pinMode(LED_PIN_RX, OUTPUT);
252 | pinMode(LED_PIN_TX, OUTPUT);
253 | pinMode(LED_PIN_CONFIG, OUTPUT);
254 | pinMode(LED_PIN_BUFF_FULL, OUTPUT);
255 | digitalWrite(LED_PIN_LISTEN, LOW);
256 | digitalWrite(LED_PIN_RX, LOW);
257 | digitalWrite(LED_PIN_TX, LOW);
258 | digitalWrite(LED_PIN_CONFIG, LOW);
259 | digitalWrite(LED_PIN_BUFF_FULL, LOW);
260 | #endif
261 |
262 | Serial.begin(SER_BAUDRATE);
263 |
264 | #ifndef BINARY_OUTPUT
265 | //fdevopen( &my_putc, 0);
266 | Serial.println("-- RF24 Sniff --");
267 | #endif
268 |
269 | radio.begin();
270 |
271 | // Disable shockburst
272 | radio.setAutoAck(false);
273 | radio.setRetries(0,0);
274 |
275 | // Configure nRF IRQ input
276 | pinMode(RF_IRQ_PIN, INPUT);
277 |
278 | #ifdef LED_SUPPORTED
279 | digitalWrite(LED_PIN_LISTEN, HIGH);
280 | #endif
281 |
282 | activateConf();
283 | }
284 |
285 | void loop(void)
286 | {
287 | while (!packetBuffer.empty())
288 | {
289 | #ifdef LED_SUPPORTED
290 | digitalWrite(LED_PIN_TX, HIGH);
291 | #endif
292 | // One or more records present
293 | NRF24_packet_t* p = packetBuffer.getBack();
294 | int serialHdrLen = sizeof(serialHdr) - (conf.addressLen - conf.addressPromiscLen);
295 | serialHdr.timestamp = p->timestamp;
296 | serialHdr.packetsLost = p->packetsLost;
297 |
298 | // Calculate data length in bits, then round up to get full number of bytes.
299 | uint8_t dataLen = ( (serialHdrLen<<3) /* Serial packet header */
300 | + ((conf.addressLen - conf.addressPromiscLen)<<3) /* NRF24 LSB address byte(s) */
301 | + 9 /* NRF24 control field */
302 | + (GET_PAYLOAD_LEN(p) << 3) /* NRF24 payload length */
303 | + (conf.crcLength << 3) /* NRF24 crc length */
304 | + 7 /* Round up to full nr. of bytes */
305 | ) >> 3; /* Convert from bits to bytes */
306 |
307 | // Write record length & message type
308 | uint8_t lenAndType = SET_MSG_TYPE(dataLen, MSG_TYPE_PACKET);
309 | dumpData(&dataLen, sizeof(lenAndType));
310 | // Write serial header
311 | dumpData((uint8_t*)&serialHdr, serialHdrLen );
312 | // Write packet data
313 | dumpData(p->packet, dataLen - serialHdrLen);
314 |
315 | #ifndef BINARY_OUTPUT
316 | if (p->packetsLost > 0)
317 | {
318 | Serial.print(" Lost: "); Serial.print(p->packetsLost);
319 | }
320 | Serial.println("");
321 | #endif
322 | // Remove record as we're done with it.
323 | packetBuffer.popBack();
324 | #ifdef LED_SUPPORTED
325 | digitalWrite(LED_PIN_TX, LOW);
326 | #endif
327 | }
328 |
329 | // Test if new config comes in
330 | uint8_t lenAndType;
331 | if (Serial.available() >= sizeof(lenAndType) + sizeof(conf))
332 | {
333 | lenAndType = Serial.read();
334 | if ((GET_MSG_TYPE(lenAndType) == MSG_TYPE_CONFIG) && (GET_MSG_LEN(lenAndType) == sizeof(conf)))
335 | {
336 | // Disable nRF interrupt while reading & activating new configuration.
337 | noInterrupts();
338 | // Retrieve the new configuration
339 | uint8_t* c = (uint8_t*)(&conf);
340 | for (uint8_t i = 0; i < sizeof(conf); ++i)
341 | {
342 | *c++ = Serial.read();
343 | }
344 | // Clear any packets in the buffer and flush rx buffer.
345 | packetBuffer.clear();
346 | radio.flush_rx();
347 | // Activate new config & re-enable nRF interrupt.
348 | activateConf();
349 |
350 | interrupts();
351 | }
352 | else
353 | {
354 | #ifndef BINARY_OUTPUT
355 | Serial.println("Illegal configuration received!");
356 | #endif
357 | }
358 | }
359 | }
360 | // vim:cin:ai:sts=2 sw=2 ft=cpp1
361 |
--------------------------------------------------------------------------------
/test/README:
--------------------------------------------------------------------------------
1 |
2 | This directory is intended for PIO Unit Testing and project tests.
3 |
4 | Unit Testing is a software testing method by which individual units of
5 | source code, sets of one or more MCU program modules together with associated
6 | control data, usage procedures, and operating procedures, are tested to
7 | determine whether they are fit for use. Unit testing finds problems early
8 | in the development cycle.
9 |
10 | More information about PIO Unit Testing:
11 | - https://docs.platformio.org/page/plus/unit-testing.html
12 |
--------------------------------------------------------------------------------