├── LICENSE ├── README.md ├── lua ├── README.md ├── hep.lua └── vendors │ └── eep-um.lua └── pcap ├── .empty ├── hep.pcap └── hep3_compressed.pcap.pcapng /LICENSE: -------------------------------------------------------------------------------- 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 Lesser 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 along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Logo](http://sipcapture.org/data/images/sipcapture_header.png)](http://sipcapture.org) 2 | # HEP 3 | 4 | 5 | # HEP-Wireshark 6 | Wireshark Dissector for the [HEP](http://hep.sipcapture.org) Encapsulation Protocol 7 | 8 | ## Lua dissector 9 | 10 | See lua/README.md. 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lua/README.md: -------------------------------------------------------------------------------- 1 | # Wireshark dissector for HEP protocol 2 | 3 | This dissector supports both HEP version 2 and 3. 4 | 5 | ## The HEP protocol 6 | 7 | ### HEP3 8 | 9 | https://github.com/sipcapture/HEP/blob/master/docs/HEP3_rev12.pdf 10 | 11 | 12 | ## Install dissector 13 | 14 | Check in `About Wireshark` -> `Folders` where plugins are installed. Then drop hep.lua inside the Personal or Global Plugins folder. 15 | 16 | e.g. of personal folder: `~/.config/wireshark/plugins/` 17 | 18 | ## Libraries used 19 | 20 | https://www.wireshark.org/docs/wsdg_html_chunked/wsluarm_modules.html 21 | -------------------------------------------------------------------------------- /lua/hep.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2016 (C) Giacomo Vacca 3 | -- Copyright 2016 (C) Federico Cabiddu 4 | -- Copyright 2017 (C) Alexandr Dubovikov 5 | -- Copyright 2022 (C) Michele Campus 6 | -- 7 | -- This file 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 2 of the License, or 10 | -- (at your option) any later version 11 | -- 12 | -- 13 | -- This file is distributed in the hope that it will be useful, 14 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | -- GNU General Public License for more details. 17 | -- 18 | -- You should have received a copy of the GNU General Public License 19 | -- along with this program; if not, write to the Free Software 20 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | -- Just copy this in your Wireshark plugins folder (either personal or global plugins) 22 | FOUROCTETS = 4 23 | TWOOCTETS = 2 24 | ONEOCTET = 1 25 | 26 | hep_proto = Proto("hep", "HEP Protocol") 27 | hep1_proto = Proto("hep1", "HEP1 Protocol") 28 | hep2_proto = Proto("hep2", "HEP2 Protocol") 29 | hep3_proto = Proto("hep3", "HEP3 Protocol") 30 | 31 | hep_proto.fields = {} 32 | local fds = hep_proto.fields 33 | fds.version = ProtoField.new("Version", "hep.version", ftypes.UINT8) 34 | 35 | hep1_proto.fields = {} 36 | local fds1 = hep1_proto.fields 37 | fds1.version = ProtoField.new("Version", "hep1.version", ftypes.UINT8) 38 | fds1.hep_packet_size = ProtoField.new("HEP Packet Size (Bytes)", "hep1.hep_packet_size", ftypes.UINT8) 39 | fds1.ip_family = ProtoField.new("IP family", "hep1.ip_family", ftypes.STRING) 40 | fds1.transport_layer_protocol = ProtoField.new("Ingested Transport Protocol", "hep1.transport_layer_protocol", 41 | ftypes.STRING) 42 | fds1.source_port = ProtoField.new("Source port", "hep1.source_port", ftypes.UINT16) 43 | fds1.destination_port = ProtoField.new("Destination port", "hep1.destination_port", ftypes.UINT16) 44 | fds1.source_ip_address = ProtoField.new("Source IPv4 address", "hep1.source_ip_address", ftypes.IPv4) 45 | fds1.destination_ip_address = ProtoField.new("Destination IPv4 address", "hep1.destination_ip_address", ftypes.IPv4) 46 | fds1.payload = ProtoField.new("Encapsulated Payload", "hep1.payload", ftypes.STRING) 47 | 48 | hep2_proto.fields = {} 49 | local fds2 = hep2_proto.fields 50 | fds2.version = ProtoField.new("Version", "hep2.version", ftypes.UINT8) 51 | fds2.hep_packet_size = ProtoField.new("HEP Packet Size (Bytes)", "hep2.hep_packet_size", ftypes.UINT8) 52 | fds2.ip_family = ProtoField.new("IP family", "hep2.ip_family", ftypes.STRING) 53 | fds2.transport_layer_protocol = ProtoField.new("Ingested Transport Protocol", "hep2.transport_layer_protocol", 54 | ftypes.STRING) 55 | fds2.source_port = ProtoField.new("Source port", "hep2.source_port", ftypes.UINT16) 56 | fds2.destination_port = ProtoField.new("Destination port", "hep2.destination_port", ftypes.UINT16) 57 | fds2.source_ip_address = ProtoField.new("Source IPv4 address", "hep2.source_ip_address", ftypes.IPv4) 58 | fds2.destination_ip_address = ProtoField.new("Destination IPv4 address", "hep2.destination_ip_address", ftypes.IPv4) 59 | fds2.timestamp_unix = ProtoField.new("Unix Timestamp (LE)", "hep2.timestamp_unix", ftypes.UINT32) 60 | fds2.timestamp_microsec = ProtoField.new("Timestamp µs (LE)", "hep2.timestamp_microsec", ftypes.UINT32) 61 | fds2.capture_node_id = ProtoField.new("Capture Node ID (LE)", "hep2.capture_node_id", ftypes.UINT16) 62 | fds2.payload = ProtoField.new("Encapsulated Payload", "hep3.payload", ftypes.STRING) 63 | 64 | hep3_proto.fields = {} 65 | local fds3 = hep3_proto.fields 66 | fds3.hep_version = ProtoField.new("HEP Version", "hep3.version", ftypes.STRING) 67 | fds3.hep_packet_size = ProtoField.new("HEP Packet Size (Bytes)", "hep3.hep_packet_size", ftypes.UINT16) 68 | fds3.ip_family = ProtoField.new("IP family", "hep3.ip_family", ftypes.STRING) 69 | fds3.transport_layer_protocol = ProtoField.new("Ingested Transport Protocol", "hep3.transport_layer_protocol", 70 | ftypes.STRING) 71 | fds3.application_protocol = ProtoField.new("Application Protocol", "hep3.application_protocol", ftypes.STRING) 72 | fds3.source_ipv4_address = ProtoField.new("Source IPv4 address", "hep3.source_ipv4_address", ftypes.IPv4) 73 | fds3.destination_ipv4_address = ProtoField.new("Destination IPv4 address", "hep3.destination_ipv4_address", ftypes.IPv4) 74 | fds3.source_ipv6_address = ProtoField.new("Source IPv6 address", "hep3.source_ipv6_address", ftypes.IPv6) 75 | fds3.destination_ipv6_address = ProtoField.new("Destination IPv6 address", "hep3.destination_ipv6_address", ftypes.IPv6) 76 | fds3.vlan_id = ProtoField.new("VLAN ID", "hep3.vlan_id", ftypes.UINT16) 77 | fds3.group_id = ProtoField.new("Group ID", "hep3.group_id", ftypes.STRING) 78 | fds3.source_mac = ProtoField.new("Source MAC address", "hep3.source_mac", ftypes.STRING) -- .ETHER 79 | fds3.destination_mac = ProtoField.new("Destination MAC address", "hep3.destination_mac", ftypes.STRING) -- .ETHER 80 | fds3.ethernet_type = ProtoField.new("Ethernet Type", "hep3.ethernet_type", ftypes.UINT16) 81 | fds3.ip_TOS = ProtoField.new("IP TOS", "hep3.ip_TOS", ftypes.UINT8) 82 | fds3.tcp_flags = ProtoField.new("TCP Flags", "hep3.tcp_flags", ftypes.UINT8) 83 | fds3.source_port = ProtoField.new("Source port", "hep3.source_port", ftypes.UINT16) 84 | fds3.destination_port = ProtoField.new("Destination port", "hep3.destination_port", ftypes.UINT16) 85 | fds3.mos = ProtoField.new("MOS", "hep3.mos", ftypes.UINT16) 86 | fds3.timestamp_unix = ProtoField.new("Unix Timestamp", "hep3.timestamp_unix", ftypes.UINT32) 87 | fds3.timestamp_microsec = ProtoField.new("Timestamp µs", "hep3.timestamp_microsec", ftypes.UINT32) 88 | fds3.capture_node_id = ProtoField.new("Capture Node ID", "hep3.capture_node_id", ftypes.UINT32) 89 | fds3.auth_key = ProtoField.new("Authentication Key", "hep3.auth_key", ftypes.STRING) 90 | fds3.node_name = ProtoField.new("Capture Node Name", "hep3.node_name", ftypes.STRING) 91 | fds3.correlation_id = ProtoField.new("Correlation ID", "hep3.correlation_id", ftypes.STRING) 92 | fds3.payload = ProtoField.new("Encapsulated Payload", "hep3.payload", ftypes.STRING) 93 | fds3.vendor_id = ProtoField.new("Vendor ID", "hep3.vendor_id", ftypes.UINT16) 94 | 95 | -------------------------------------------------------------------------------- 96 | function get_chunk_data(buffer, offset) 97 | return tostring(buffer(offset, FOUROCTETS)) 98 | end 99 | 100 | function get_data(buffer, offset) 101 | chunk_payload_len = buffer(offset + FOUROCTETS, TWOOCTETS):uint() - (FOUROCTETS + TWOOCTETS) 102 | chunk_payload_offset = offset + FOUROCTETS + TWOOCTETS 103 | total_len = buffer:len() 104 | if (chunk_payload_len + chunk_payload_offset) > total_len then 105 | chunk_payload_len = total_len - chunk_payload_offset 106 | end 107 | return buffer(chunk_payload_offset, chunk_payload_len), chunk_payload_offset, chunk_payload_len 108 | end 109 | 110 | function add_element(subtree, buffer, offset, len, description, info) 111 | subtree:add(buffer(offset, len), description .. ": " .. info) 112 | -- return next offset 113 | return offset + len 114 | end 115 | 116 | function get_ip_family(buffer, offset, subtree) 117 | data, offset, len = get_data(buffer, offset) 118 | if tostring(data) == "02" then 119 | info = "IPv4" 120 | elseif tostring(data) == "0a" then 121 | info = "IPv6" 122 | else 123 | info = "Unknown IP Family" 124 | end 125 | subtree:add(fds3.ip_family, buffer(offset, len), info) 126 | return offset + len 127 | end 128 | 129 | function get_transport_proto_id(buffer, offset, subtree) 130 | data, offset, len = get_data(buffer, offset) 131 | if tostring(data) == "11" then 132 | info = "UDP" 133 | elseif tostring(data) == "06" then 134 | info = "TCP" 135 | elseif tostring(data) == "84" then 136 | info = "SCTP" 137 | -- else 138 | -- TODO; add 139 | end 140 | subtree:add(fds3.transport_layer_protocol, buffer(offset, len), info) 141 | return offset + len 142 | end 143 | 144 | function get_source_ipv4_address(buffer, offset, subtree) 145 | data, offset, len = get_data(buffer, offset) 146 | info = data:ipv4() 147 | subtree:add(fds3.source_ipv4_address, buffer(offset, len), info) 148 | return offset + len 149 | end 150 | 151 | function get_destination_ipv4_address(buffer, offset, subtree) 152 | data, offset, len = get_data(buffer, offset) 153 | info = data:ipv4() 154 | subtree:add(fds3.destination_ipv4_address, buffer(offset, len), info) 155 | return offset + len 156 | end 157 | 158 | -- function decompose_ipv6(data) 159 | -- -- this function may only be useful in legacy versions of Wireshark 160 | -- local data = tostring(data) 161 | -- local i = 1 162 | -- local ret = string.sub(data, i, i+3) 163 | -- for j=0, 6, 1 164 | -- do 165 | -- i = i + 4 166 | -- ret = ret .. ":" .. string.sub(data, i, i+3) 167 | -- end 168 | -- ret = string.gsub(ret, ":0000", ":") 169 | -- ret = string.gsub(ret, ":000", ":") 170 | -- ret = string.gsub(ret, ":00", ":") 171 | -- ret = string.gsub(ret, ":0", ":") 172 | -- ret = string.gsub(ret, "::::", "::") 173 | -- ret = string.gsub(ret, ":::", "::") 174 | -- return ret 175 | -- end 176 | 177 | function get_source_ipv6_address(buffer, offset, subtree) 178 | data, offset, len = get_data(buffer, offset) 179 | -- local info = decompose_ipv6(data) 180 | info = data:ipv6() 181 | subtree:add(fds3.source_ipv6_address, buffer(offset, len), info) 182 | return offset + len 183 | end 184 | 185 | function get_destination_ipv6_address(buffer, offset, subtree) 186 | data, offset, len = get_data(buffer, offset) 187 | -- local info = decompose_ipv6(data) 188 | info = data:ipv6() 189 | subtree:add(fds3.destination_ipv6_address, buffer(offset, len), info) 190 | return offset + len 191 | end 192 | 193 | function get_source_port(buffer, offset, subtree) 194 | data, offset, len = get_data(buffer, offset) 195 | info = data:uint() 196 | subtree:add(fds3.source_port, buffer(offset, len), info) 197 | return offset + len 198 | end 199 | 200 | function get_destination_port(buffer, offset, subtree) 201 | data, offset, len = get_data(buffer, offset) 202 | info = data:uint() 203 | subtree:add(fds3.destination_port, buffer(offset, len), info) 204 | return offset + len 205 | end 206 | 207 | function get_mos(buffer, offset, subtree) 208 | data, offset, len = get_data(buffer, offset) 209 | info = data:uint() 210 | subtree:add(fds3.mos, buffer(offset, len), info) 211 | return offset + len 212 | end 213 | 214 | function get_timestamp(buffer, offset, subtree) 215 | data, offset, len = get_data(buffer, offset) 216 | info = data:uint() 217 | subtree:add(fds3.timestamp_unix, buffer(offset, len), info) 218 | return offset + len 219 | end 220 | 221 | function get_timestamp_microsec(buffer, offset, subtree) 222 | data, offset, len = get_data(buffer, offset) 223 | info = data:uint() 224 | subtree:add(fds3.timestamp_microsec, buffer(offset, len), info) 225 | return offset + len 226 | end 227 | 228 | function get_vlan_id(buffer, offset, subtree) 229 | data, offset, len = get_data(buffer, offset) 230 | info = data:uint() 231 | subtree:add(fds3.vlan_id, buffer(offset, len), info) 232 | return offset + len 233 | end 234 | 235 | function get_group_id(buffer, offset, subtree) 236 | data, offset, len = get_data(buffer, offset) 237 | info = data:uint() 238 | subtree:add(fds3.group_id, buffer(offset, len), info) 239 | return offset + len 240 | end 241 | 242 | function get_source_mac(buffer, offset, subtree) 243 | data, offset, len = get_data(buffer, offset) 244 | info = data:string() -- :ether() also avail, but range must be 6 bytes 245 | subtree:add(fds3.source_mac, buffer(offset, len), info) 246 | return offset + len 247 | end 248 | 249 | function get_destination_mac(buffer, offset, subtree) 250 | data, offset, len = get_data(buffer, offset) 251 | info = data:string() -- :ether() also avail, but range must be 6 bytes 252 | subtree:add(fds3.destination_mac, buffer(offset, len), info) 253 | return offset + len 254 | end 255 | 256 | function get_ethernet_type(buffer, offset, subtree) 257 | data, offset, len = get_data(buffer, offset) 258 | info = data:uint() 259 | subtree:add(fds3.ethernet_type, buffer(offset, len), info) 260 | return offset + len 261 | end 262 | 263 | function get_tcp_flags(buffer, offset, subtree) 264 | data, offset, len = get_data(buffer, offset) 265 | info = data:uint() 266 | subtree:add(fds3.tcp_flags, buffer(offset, len), info) 267 | return offset + len 268 | end 269 | 270 | function get_ip_TOS(buffer, offset, subtree) 271 | data, offset, len = get_data(buffer, offset) 272 | info = data:uint() 273 | subtree:add(fds3.ip_TOS, buffer(offset, len), info) 274 | return offset + len 275 | end 276 | 277 | function process_vendor_id(buffer, offset, subtree) 278 | data, offset, len = get_data(buffer, offset) 279 | info = data:uint() 280 | subtree:add(fds3.vendor_id, buffer(offset, len), info) 281 | return offset + len 282 | end 283 | 284 | function get_application_protocol(buffer, offset, subtree) 285 | data, offset, len = get_data(buffer, offset) 286 | 287 | if (tostring(data) == "01") then 288 | info = "SIP" 289 | elseif (tostring(data) == "02") then -- 2 290 | info = "XMPP" 291 | elseif (tostring(data) == "03") then -- 3 292 | info = "SDP" 293 | elseif (tostring(data) == "04") then -- 4 294 | info = "RTP" 295 | elseif (tostring(data) == "05") then -- 5 296 | info = "JSON/RTCP" 297 | elseif (tostring(data) == "06") then -- 6 298 | info = "MGCP" 299 | elseif (tostring(data) == "07") then -- 7 300 | info = "MEGACO" -- H.248 301 | elseif (tostring(data) == "08") then -- 8 302 | info = "M2UA" 303 | elseif (tostring(data) == "09") then -- 9 304 | info = "M3UA" -- SS7/SIGTRAN 305 | elseif (tostring(data) == "0a") then -- 10 306 | info = "IAX" 307 | elseif (tostring(data) == "0b") then -- 11 308 | info = "H3222" 309 | elseif (tostring(data) == "0c") then -- 12 310 | info = "H321" 311 | elseif (tostring(data) == "0d") then -- 13 312 | info = "M2PA" 313 | elseif (tostring(data) == "14") then -- 14 314 | info = "JSON/webRTC" 315 | elseif (tostring(data) == "20") then -- 32 316 | info = "JSON/QOS/32" 317 | elseif (tostring(data) == "22") then -- 34 318 | info = "JSON/QOS/34" 319 | elseif (tostring(data) == "23") then -- 35 320 | info = "MOS" 321 | elseif (tostring(data) == "32") then -- 50 322 | info = "JSON/SIP" 323 | elseif (tostring(data) == "33") then -- 51 324 | info = "RESERVED" 325 | elseif (tostring(data) == "34") then -- 52 326 | info = "RESERVED" 327 | elseif (tostring(data) == "35") then -- 53 328 | info = "JSON/DNS" 329 | elseif (tostring(data) == "36") then -- 54 330 | info = "JSON/M3UA(ISUP)" 331 | elseif (tostring(data) == "37") then -- 55 332 | info = "JSON/RTSP" 333 | elseif (tostring(data) == "38") then -- 56 334 | info = "JSON/DIAMETER" 335 | elseif (tostring(data) == "39") then -- 57 336 | info = "JSON/GSM_MAP" 337 | elseif (tostring(data) == "63") then -- 99 338 | info = "JSON/QOS/99" 339 | elseif (tostring(data) == "64") then -- 100 340 | info = "LOG" -- for ingest into Loki 341 | else 342 | info = "Unknown Application Protocol" 343 | -- TODO; add more protocol types 344 | end 345 | 346 | subtree:add(fds3.application_protocol, buffer(offset, len), info) 347 | next_offset = offset + len 348 | -- Careful. It must return the protocol type too. Improvable. 349 | return next_offset, info 350 | end 351 | 352 | function get_capture_node_id(buffer, offset, subtree) 353 | data, offset, len = get_data(buffer, offset) 354 | info = data:uint() 355 | subtree:add(fds3.capture_node_id, buffer(offset, len), info) 356 | return offset + len 357 | end 358 | 359 | function get_auth_key(buffer, offset, subtree) 360 | data, offset, len = get_data(buffer, offset) 361 | info = data:string() 362 | subtree:add(fds3.auth_key, buffer(offset, len), info) 363 | return offset + len 364 | end 365 | 366 | function get_node_name(buffer, offset, subtree) 367 | data, offset, len = get_data(buffer, offset) 368 | info = data:string() 369 | subtree:add(fds3.node_name, buffer(offset, len), info) 370 | return offset + len 371 | end 372 | 373 | function get_correlation_id(buffer, offset, subtree) 374 | data, offset, len = get_data(buffer, offset) 375 | info = data:string() 376 | subtree:add(fds3.correlation_id, buffer(offset, len), info) 377 | return offset + len 378 | end 379 | 380 | function skip_unknown_chunk(buffer, offset) 381 | data, offset, len = get_data(buffer, offset) 382 | return offset + len 383 | end 384 | 385 | function determine_payload_content(buffer, offset, subtree, pinfo, tree, application_protocol) 386 | data, offset, len = get_data(buffer, offset) 387 | info = data:string() 388 | subtree:add(fds3.payload, buffer(offset, len), info) 389 | 390 | if (application_protocol == "SIP") then 391 | Dissector.get("sip"):call(buffer(offset):tvb(), pinfo, tree) 392 | pinfo.cols.protocol = "HEP3/SIP" 393 | elseif ((application_protocol == "JSON") or (application_protocol == "JSON/RTCP") or 394 | (application_protocol == "JSON/QOS/32") or (application_protocol == "JSON/QOS/99") or 395 | (application_protocol == "MOS") or (application_protocol == "JSON/QOS/34")) then 396 | Dissector.get("json"):call(buffer(offset):tvb(), pinfo, tree) 397 | pinfo.cols.protocol = "HEP3/" .. application_protocol 398 | elseif (application_protocol == "LOG") then 399 | pinfo.cols.protocol = "HEP3/" .. application_protocol 400 | elseif (application_protocol == "M2UA") then 401 | Dissector.get("m2ua"):call(buffer(offset):tvb(), pinfo, tree) 402 | pinfo.cols.protocol = "HEP3/M2UA" 403 | elseif (application_protocol == "RTP") then 404 | Dissector.get("rtp"):call(buffer(offset):tvb(), pinfo, tree) 405 | pinfo.cols.protocol = "HEP3/RTP" 406 | elseif (application_protocol == "M2PA") then 407 | Dissector.get("m2pa"):call(buffer(offset):tvb(), pinfo, tree) 408 | pinfo.cols.protocol = "HEP3/M2PA" 409 | else 410 | pinfo.cols.protocol = "HEP3" 411 | end 412 | 413 | next_offset = offset + len 414 | return next_offset 415 | end 416 | 417 | function dissect_hep1(buffer, offset, subtree, pinfo, tree) 418 | version = buffer(offset, ONEOCTET):uint() 419 | subtree:add(fds1.version, buffer(offset, ONEOCTET), version) 420 | 421 | offset = ONEOCTET 422 | 423 | total_len = buffer(offset, ONEOCTET):uint() 424 | subtree:add(fds1.hep_packet_size, buffer(offset, ONEOCTET), total_len) 425 | 426 | offset = offset + ONEOCTET 427 | 428 | ip_family_buffer = buffer(offset, ONEOCTET) 429 | 430 | if (tostring(ip_family_buffer) == "02") then 431 | ip_family = "IPv4" 432 | elseif (tostring(ip_family_buffer) == "10") then 433 | ip_family = "IPv6" 434 | else 435 | ip_family = "Unknown IP Family" 436 | end 437 | 438 | subtree:add(fds1.ip_family, buffer(offset, ONEOCTET), ip_family) 439 | 440 | offset = offset + ONEOCTET 441 | 442 | transport_layer_protocol_id_buffer = buffer(offset, ONEOCTET) 443 | 444 | if (tostring(transport_layer_protocol_id_buffer) == "11") then 445 | transport_layer_protocol = "UDP" 446 | elseif (tostring(transport_layer_protocol_id_buffer) == "06") then 447 | transport_layer_protocol = "TCP" 448 | -- elseif (tostring(transport_layer_protocol_id_buffer) == "01") then 449 | -- Fixes https://github.com/sipcapture/hep-wireshark/issues/4 450 | -- transport_layer_protocol = "UDP (incorrect id)" --issue capture uses UDP 451 | else 452 | transport_layer_protocol = "Unidentified Transport" 453 | -- TODO: Add remaining 454 | end 455 | 456 | subtree:add(fds1.transport_layer_protocol, buffer(offset, ONEOCTET), transport_layer_protocol) 457 | offset = offset + ONEOCTET 458 | 459 | source_port = buffer(offset, TWOOCTETS):uint() 460 | subtree:add(fds1.source_port, buffer(offset, TWOOCTETS), source_port) 461 | offset = offset + TWOOCTETS 462 | 463 | destination_port = buffer(offset, TWOOCTETS):uint() 464 | subtree:add(fds1.destination_port, buffer(offset, TWOOCTETS), destination_port) 465 | offset = offset + TWOOCTETS 466 | 467 | ip = buffer(offset, FOUROCTETS):ipv4() 468 | subtree:add(fds1.source_ip_address, buffer(offset, FOUROCTETS), ip) 469 | offset = offset + FOUROCTETS 470 | 471 | ip = buffer(offset, FOUROCTETS):ipv4() 472 | subtree:add(fds1.destination_ip_address, buffer(offset, FOUROCTETS), ip) 473 | offset = offset + FOUROCTETS 474 | 475 | Dissector.get("sip"):call(buffer(offset):tvb(), pinfo, tree) 476 | 477 | pinfo.cols.protocol = "HEP1/SIP" 478 | 479 | return 480 | end 481 | 482 | function dissect_hep2(buffer, offset, subtree, pinfo, tree) 483 | version = buffer(offset, ONEOCTET):uint() 484 | subtree:add(fds2.version, buffer(offset, ONEOCTET), version) 485 | 486 | offset = ONEOCTET 487 | 488 | total_len = buffer(offset, ONEOCTET):uint() 489 | subtree:add(fds2.hep_packet_size, buffer(offset, ONEOCTET), total_len) 490 | 491 | offset = offset + ONEOCTET 492 | 493 | ip_family_buffer = buffer(offset, ONEOCTET) 494 | 495 | if (tostring(ip_family_buffer) == "02") then 496 | ip_family = "IPv4" 497 | elseif (tostring(ip_family_buffer) == "10") then 498 | ip_family = "IPv6" 499 | else 500 | ip_family = "Unknown IP Family" 501 | end 502 | 503 | subtree:add(fds2.ip_family, buffer(offset, ONEOCTET), ip_family) 504 | 505 | offset = offset + ONEOCTET 506 | 507 | transport_layer_protocol_id_buffer = buffer(offset, ONEOCTET) 508 | 509 | if (tostring(transport_layer_protocol_id_buffer) == "11") then 510 | transport_layer_protocol = "UDP" 511 | elseif (tostring(transport_layer_protocol_id_buffer) == "06") then 512 | transport_layer_protocol = "TCP" 513 | -- elseif (tostring(transport_layer_protocol_id_buffer) == "01") then 514 | -- Fixes https://github.com/sipcapture/hep-wireshark/issues/4 515 | -- transport_layer_protocol = "UDP (incorrect id)" --issue capture uses UDP 516 | else 517 | transport_layer_protocol = "Unidentified Transport" 518 | -- TODO: Add remaining 519 | end 520 | 521 | subtree:add(fds2.transport_layer_protocol, buffer(offset, ONEOCTET), transport_layer_protocol) 522 | offset = offset + ONEOCTET 523 | 524 | source_port = buffer(offset, TWOOCTETS):uint() 525 | subtree:add(fds2.source_port, buffer(offset, TWOOCTETS), source_port) 526 | offset = offset + TWOOCTETS 527 | 528 | destination_port = buffer(offset, TWOOCTETS):uint() 529 | subtree:add(fds2.destination_port, buffer(offset, TWOOCTETS), destination_port) 530 | offset = offset + TWOOCTETS 531 | 532 | ip = buffer(offset, FOUROCTETS):ipv4() 533 | subtree:add(fds2.source_ip_address, buffer(offset, FOUROCTETS), ip) 534 | offset = offset + FOUROCTETS 535 | 536 | ip = buffer(offset, FOUROCTETS):ipv4() 537 | subtree:add(fds2.destination_ip_address, buffer(offset, FOUROCTETS), ip) 538 | offset = offset + FOUROCTETS 539 | 540 | ts = buffer(offset, FOUROCTETS):le_uint() 541 | subtree:add(fds2.timestamp_unix, buffer(offset, FOUROCTETS), ts) 542 | offset = offset + FOUROCTETS 543 | 544 | ts_us = buffer(offset, FOUROCTETS):le_uint() 545 | subtree:add(fds2.timestamp_microsec, buffer(offset, FOUROCTETS), ts_us) 546 | offset = offset + FOUROCTETS 547 | 548 | capture_node_id = buffer(offset, TWOOCTETS):le_uint() 549 | subtree:add(fds2.capture_node_id, buffer(offset, TWOOCTETS), capture_node_id) 550 | offset = offset + TWOOCTETS 551 | 552 | data_buffer = buffer(offset, TWOOCTETS):le_uint() 553 | subtree:add(buffer(offset, TWOOCTETS), "Unknown Type: " .. tostring(data_buffer)) 554 | offset = offset + TWOOCTETS 555 | 556 | Dissector.get("sip"):call(buffer(offset):tvb(), pinfo, tree) 557 | 558 | pinfo.cols.protocol = "HEP2/SIP" 559 | 560 | return 561 | end 562 | 563 | function dissect_hep3(buffer, offset, subtree, pinfo, tree) 564 | hep_version = buffer(offset, FOUROCTETS):string() 565 | subtree:add(fds3.hep_version, buffer(offset, FOUROCTETS), hep_version) 566 | offset = offset + FOUROCTETS 567 | 568 | total_len = buffer(offset, TWOOCTETS):uint() 569 | subtree:add(fds3.hep_packet_size, buffer(offset, TWOOCTETS), total_len) 570 | 571 | offset = offset + TWOOCTETS 572 | chunk_type = get_chunk_data(buffer, offset) 573 | 574 | while (offset < (total_len - 1)) do 575 | if chunk_type == "00000001" then 576 | offset = get_ip_family(buffer, offset, subtree) 577 | elseif chunk_type == "00000002" then 578 | offset = get_transport_proto_id(buffer, offset, subtree) 579 | elseif chunk_type == "00000003" then 580 | offset = get_source_ipv4_address(buffer, offset, subtree) 581 | elseif chunk_type == "00000004" then 582 | offset = get_destination_ipv4_address(buffer, offset, subtree) 583 | elseif chunk_type == "00000005" then 584 | offset = get_source_ipv6_address(buffer, offset, subtree) 585 | elseif chunk_type == "00000006" then 586 | offset = get_destination_ipv6_address(buffer, offset, subtree) 587 | elseif chunk_type == "00000007" then 588 | offset = get_source_port(buffer, offset, subtree) 589 | elseif chunk_type == "00000008" then 590 | offset = get_destination_port(buffer, offset, subtree) 591 | elseif chunk_type == "00000009" then 592 | offset = get_timestamp(buffer, offset, subtree) 593 | elseif chunk_type == "0000000a" then 594 | offset = get_timestamp_microsec(buffer, offset, subtree) 595 | elseif chunk_type == "0000000b" then 596 | offset, application_protocol = get_application_protocol(buffer, offset, subtree) 597 | elseif chunk_type == "0000000c" then 598 | offset = get_capture_node_id(buffer, offset, subtree) 599 | elseif chunk_type == "0000000e" then 600 | offset = get_auth_key(buffer, offset, subtree) 601 | elseif chunk_type == "00000013" then 602 | offset = get_node_name(buffer, offset, subtree) 603 | elseif chunk_type == "0000000f" then 604 | offset = determine_payload_content(buffer, offset, subtree, pinfo, tree, application_protocol) 605 | elseif chunk_type == "00000010" then 606 | -- compressed payload. Treat as normal payload 607 | -- https://github.com/sipcapture/hep-wireshark/issues/5 608 | offset = determine_payload_content(buffer, offset, subtree, pinfo, tree, application_protocol) 609 | elseif chunk_type == "00000011" then 610 | offset = get_correlation_id(buffer, offset, subtree) 611 | elseif chunk_type == "00000012" then 612 | offset = get_vlan_id(buffer, offset, subtree) 613 | -- elseif chunk_type == "00000013" then 614 | -- offset = get_group_id(buffer, offset, subtree) 615 | elseif chunk_type == "00000014" then 616 | offset = get_source_mac(buffer, offset, subtree) 617 | elseif chunk_type == "00000015" then 618 | offset = get_destination_mac(buffer, offset, subtree) 619 | elseif chunk_type == "00000016" then 620 | offset = get_ethernet_type(buffer, offset, subtree) 621 | elseif chunk_type == "00000017" then 622 | offset = get_tcp_flags(buffer, offset, subtree) 623 | elseif chunk_type == "00000018" then 624 | offset = get_ip_TOS(buffer, offset, subtree) 625 | elseif chunk_type == "00000020" then 626 | offset = get_mos(buffer, offset, subtree) 627 | else 628 | -- proceed unknown chunk 629 | if (offset < (total_len - 1)) then 630 | offset = skip_unknown_chunk(buffer, offset) 631 | end 632 | end 633 | 634 | if (offset < (total_len - 1)) then 635 | chunk_type = get_chunk_data(buffer, offset) 636 | end 637 | end -- while 638 | end 639 | 640 | function hep1_proto_dissector(buffer, pinfo, tree) 641 | local subtree = tree:add(hep1_proto, buffer(), "HEP1 Protocol") 642 | dissect_hep1(buffer, offset, subtree, pinfo, tree) 643 | end 644 | 645 | function hep2_proto_dissector(buffer, pinfo, tree) 646 | local subtree = tree:add(hep2_proto, buffer(), "HEP2 Protocol") 647 | dissect_hep2(buffer, offset, subtree, pinfo, tree) 648 | end 649 | 650 | function hep3_proto_dissector(buffer, pinfo, tree) 651 | local subtree = tree:add(hep3_proto, buffer(), "HEP3 Protocol") 652 | dissect_hep3(buffer, offset, subtree, pinfo, tree) 653 | end 654 | 655 | function hep_proto.dissector(buffer, pinfo, tree) 656 | offset = 0 657 | version = buffer(offset, FOUROCTETS):string() 658 | 659 | if (version == "HEP3") then 660 | hep3_proto_dissector(buffer, pinfo, tree) 661 | return 662 | end 663 | 664 | -- Let's try HEP2 665 | version = buffer(offset, ONEOCTET) 666 | 667 | if (tostring(version) == "02") then 668 | hep2_proto_dissector(buffer, pinfo, tree) 669 | return 670 | elseif (tostring(version) == "01") then 671 | hep1_proto_dissector(buffer, pinfo, tree) 672 | return 673 | else 674 | -- Not HEP3 or HEP2 675 | end 676 | end 677 | 678 | -- 679 | udp_table = DissectorTable.get("udp.port") 680 | udp_table:add(9060, hep_proto) 681 | udp_table:add(9063, hep_proto) 682 | 683 | tcp_table = DissectorTable.get("tcp.port") 684 | tcp_table:add(9060, hep_proto) 685 | tcp_table:add(9062, hep_proto) 686 | -------------------------------------------------------------------------------- /lua/vendors/eep-um.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- Copyright 2016 (C) Giacomo Vacca 3 | -- Copyright 2016 (C) Federico Cabiddu 4 | -- Copyright 2017 (C) Alexandr Dubovikov 5 | -- 6 | -- 7 | -- This file 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 2 of the License, or 10 | -- (at your option) any later version 11 | -- 12 | -- 13 | -- This file is distributed in the hope that it will be useful, 14 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | -- GNU General Public License for more details. 17 | -- 18 | -- You should have received a copy of the GNU General Public License 19 | -- along with this program; if not, write to the Free Software 20 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | 22 | -- Just copy this in your Wireshark plugins folder (either personal or global plugins) 23 | 24 | 25 | FOUROCTETS = 4 26 | TWOOCTETS = 2 27 | ONEOCTET = 1 28 | 29 | 30 | eep3_proto = Proto("eep3", "EEP3 Protocol") 31 | 32 | eep3_proto.fields = {} 33 | local fds3 = eep3_proto.fields 34 | fds3.eep_id = ProtoField.new("HEP ID", "eep3.id", ftypes.STRING) 35 | fds3.length = ProtoField.new("Length (Bytes)", "eep3.length", ftypes.UINT16) 36 | fds3.protocol_family = ProtoField.new("Protocol family", "eep3.protocol_family", ftypes.STRING) 37 | fds3.protocol_id = ProtoField.new("Protocol ID", "eep3.protocol_id", ftypes.STRING) 38 | fds3.protocol_type = ProtoField.new("Protocol Type", "eep3.protocol_type", ftypes.STRING) 39 | fds3.src_ipv4_address = ProtoField.new("Source IPv4 address", "eep3.src_ipv4_address", ftypes.IPv4) 40 | fds3.dst_ipv4_address = ProtoField.new("Destination IPv4 address", "eep3.dst_ipv4_address", ftypes.IPv4) 41 | fds3.dst_ipv6_address = ProtoField.new("Destination IPv6 address", "eep3.dst_ipv6_address", ftypes.STRING) 42 | fds3.src_ipv6_address = ProtoField.new("Source IPv6 address", "eep3.src_ipv6_address", ftypes.STRING) 43 | fds3.src_port = ProtoField.new("Source port", "eep3.src_port", ftypes.UINT16) 44 | fds3.dst_port = ProtoField.new("Destination port", "eep3.dst_port", ftypes.UINT16) 45 | fds3.timestamp = ProtoField.new("Timestamp", "eep3.timestamp", ftypes.UINT32) 46 | fds3.timestamp_us = ProtoField.new("Timestamp us", "eep3.timestamp_us", ftypes.UINT32) 47 | 48 | -------------------------------------------------------------------------------- 49 | fds3.network_element_id = ProtoField.new("Network Element ID", "eep3.network_element_id", ftypes.UINT32) 50 | fds3.location = ProtoField.new("Location", "eep3.location", ftypes.STRING) 51 | fds3.record_type = ProtoField.new("Record Type", "eep3.record_type", ftypes.UINT8) 52 | fds3.payload = ProtoField.new("Payload", "eep3.payload", ftypes.STRING) 53 | fds3.network_operator_id = ProtoField.new("Network operator", "eep3.network_operator_id", ftypes.STRING) 54 | fds3.direction_int = ProtoField.new("Direction Interception", "eep3.direction_int", ftypes.UINT8) 55 | fds3.direction_pr = ProtoField.new("Direction Session", "eep3.direction_pr", ftypes.UINT8) 56 | fds3.liid = ProtoField.new("LIID", "eep3.liid", ftypes.UINT32) 57 | fds3.cid = ProtoField.new("CID", "eep3.cid", ftypes.UINT32) 58 | fds3.seqnum = ProtoField.new("Sequence Number", "eep3.seqnum", ftypes.UINT32) 59 | fds3.node_type = ProtoField.new("Node Type", "eep3.node_type", ftypes.UINT8) 60 | fds3.data_type = ProtoField.new("Data Type", "eep3.data_type", ftypes.UINT16) 61 | 62 | 63 | -------------------------------------------------------------------------------- 64 | function get_chunk_type(buffer, offset) 65 | -- debug("CHUNK GET1:"..offset) 66 | -- debug("CHUNK GET2:"..FOUROCTETS) 67 | return tostring(buffer(offset, FOUROCTETS)) 68 | end 69 | 70 | function get_data(buffer, offset) 71 | chunk_payload_len = buffer(offset + FOUROCTETS, TWOOCTETS):uint() - (FOUROCTETS + TWOOCTETS) 72 | chunk_payload_offset = offset + FOUROCTETS + TWOOCTETS 73 | return buffer(chunk_payload_offset, chunk_payload_len), chunk_payload_offset, chunk_payload_len 74 | end 75 | 76 | function add_element(subtree, buffer, offset, len, description, info) 77 | subtree:add(buffer(offset, len), description .. ": " .. info) 78 | -- return next offset 79 | return offset + len 80 | end 81 | 82 | function process_proto_family(buffer, offset, subtree) 83 | data, offset, len = get_data(buffer, offset) 84 | if tostring(data) == "02" then 85 | info = "IPv4" 86 | elseif tostring(data) == "0a" then 87 | info = "IPv6" 88 | else 89 | info = "Unknown" 90 | end 91 | subtree:add(fds3.protocol_family, buffer(offset, len), info) 92 | return offset + len 93 | end 94 | 95 | function process_proto_id(buffer, offset, subtree) 96 | data, offset, len = get_data(buffer, offset) 97 | if tostring(data) == "11" then 98 | info = "UDP" 99 | elseif tostring(data) == "06" then 100 | info = "TCP" 101 | --else 102 | -- TODO; add 103 | end 104 | subtree:add(fds3.protocol_id, buffer(offset, len), info) 105 | return offset + len 106 | end 107 | 108 | function process_src_ipv4_address(buffer, offset, subtree) 109 | data, offset, len = get_data(buffer, offset) 110 | info = data:ipv4() 111 | subtree:add(fds3.src_ipv4_address, buffer(offset, len), info) 112 | return offset + len 113 | end 114 | 115 | function process_dst_ipv4_address(buffer, offset, subtree) 116 | data, offset, len = get_data(buffer, offset) 117 | info = data:ipv4() 118 | subtree:add(fds3.dst_ipv4_address, buffer(offset, len), info) 119 | return offset + len 120 | end 121 | 122 | function decompose_ipv6(data) 123 | local data = tostring(data) 124 | local i = 1 125 | local ret = string.sub(data, i, i+3) 126 | for j=0, 6, 1 127 | do 128 | i = i + 4 129 | ret = ret .. ":" .. string.sub(data, i, i+3) 130 | end 131 | ret = string.gsub(ret, ":0000", ":") 132 | ret = string.gsub(ret, ":000", ":") 133 | ret = string.gsub(ret, ":00", ":") 134 | ret = string.gsub(ret, ":0", ":") 135 | ret = string.gsub(ret, "::::", "::") 136 | ret = string.gsub(ret, ":::", "::") 137 | return ret 138 | end 139 | 140 | function process_src_ipv6_address(buffer, offset, subtree) 141 | data, offset, len = get_data(buffer, offset) 142 | local info = decompose_ipv6(data) 143 | subtree:add(fds3.src_ipv6_address, buffer(offset, len), tostring(info)) 144 | return offset + len 145 | end 146 | 147 | function process_dst_ipv6_address(buffer, offset, subtree) 148 | data, offset, len = get_data(buffer, offset) 149 | local info = decompose_ipv6(data) 150 | subtree:add(fds3.dst_ipv6_address, buffer(offset, len), tostring(info)) 151 | return offset + len 152 | end 153 | 154 | function process_src_port(buffer, offset, subtree) 155 | data, offset, len = get_data(buffer, offset) 156 | info = data:uint() 157 | subtree:add(fds3.src_port, buffer(offset, len), info) 158 | return offset + len 159 | end 160 | 161 | function process_dst_port(buffer, offset, subtree) 162 | data, offset, len = get_data(buffer, offset) 163 | info = data:uint() 164 | subtree:add(fds3.dst_port, buffer(offset, len), info) 165 | return offset + len 166 | end 167 | 168 | function process_timestamp(buffer, offset, subtree) 169 | data, offset, len = get_data(buffer, offset) 170 | info = data:uint() 171 | subtree:add(fds3.timestamp, buffer(offset, len), info) 172 | return offset + len 173 | end 174 | 175 | function process_timestamp_us(buffer, offset, subtree) 176 | data, offset, len = get_data(buffer, offset) 177 | info = data:uint() 178 | subtree:add(fds3.timestamp_us, buffer(offset, len), info) 179 | return offset + len 180 | end 181 | 182 | function process_unknown_chunk(buffer, offset) 183 | data, offset, len = get_data(buffer, offset) 184 | return offset + len 185 | end 186 | 187 | function process_protocol_type(buffer, offset, subtree) 188 | data, offset, len = get_data(buffer, offset) 189 | 190 | if (tostring(data) == "01") then 191 | info = "SIP" 192 | elseif (tostring(data) == "05") then -- 5 193 | info = "JSON/RTCP" 194 | elseif (tostring(data) == "14") then -- 14 195 | info = "JSON/webRTC" 196 | elseif (tostring(data) == "20") then -- 32 197 | info = "JSON/QOS" 198 | elseif (tostring(data) == "63") then -- 99 199 | info = "JSON/QOS" 200 | elseif (tostring(data) == "64") then -- 100 201 | info = "LOG" 202 | else 203 | info = "Unknown" 204 | -- TODO; add more protocol types 205 | end 206 | 207 | subtree:add(fds3.protocol_type, buffer(offset, len), info) 208 | next_offset = offset + len 209 | -- Careful. It must return the protocol type too. Improvable. 210 | return next_offset, info 211 | end 212 | 213 | function process_network_element_id(buffer, offset, subtree) 214 | data, offset, len = get_data(buffer, offset) 215 | info = data:uint() 216 | subtree:add(fds3.network_element_id, buffer(offset, len), info) 217 | return offset + len 218 | end 219 | 220 | function process_location(buffer, offset, subtree) 221 | data, offset, len = get_data(buffer, offset) 222 | info = data:string() 223 | subtree:add(fds3.location, buffer(offset, len), info) 224 | return offset + len 225 | end 226 | 227 | function process_record_type(buffer, offset, subtree) 228 | data, offset, len = get_data(buffer, offset) 229 | info = data:uint() 230 | subtree:add(fds3.record_type, buffer(offset, len), info) 231 | return offset + len 232 | end 233 | 234 | function process_network_operator_id(buffer, offset, subtree) 235 | data, offset, len = get_data(buffer, offset) 236 | info = data:string() 237 | subtree:add(fds3.network_operator_id, buffer(offset, len), info) 238 | return offset + len 239 | end 240 | 241 | function process_direction_int(buffer, offset, subtree) 242 | data, offset, len = get_data(buffer, offset) 243 | info = data:uint() 244 | subtree:add(fds3.direction_int, buffer(offset, len), info) 245 | return offset + len 246 | end 247 | 248 | function process_direction_pr(buffer, offset, subtree) 249 | data, offset, len = get_data(buffer, offset) 250 | info = data:uint() 251 | subtree:add(fds3.direction_pr, buffer(offset, len), info) 252 | return offset + len 253 | end 254 | 255 | function process_liid(buffer, offset, subtree) 256 | data, offset, len = get_data(buffer, offset) 257 | info = data:uint() 258 | subtree:add(fds3.liid, buffer(offset, len), info) 259 | return offset + len 260 | end 261 | 262 | function process_cid(buffer, offset, subtree) 263 | data, offset, len = get_data(buffer, offset) 264 | info = data:uint() 265 | subtree:add(fds3.cid, buffer(offset, len), info) 266 | return offset + len 267 | end 268 | 269 | function process_seqnum(buffer, offset, subtree) 270 | data, offset, len = get_data(buffer, offset) 271 | info = data:uint() 272 | subtree:add(fds3.seqnum, buffer(offset, len), info) 273 | return offset + len 274 | end 275 | 276 | function process_node_type(buffer, offset, subtree) 277 | data, offset, len = get_data(buffer, offset) 278 | info = data:uint() 279 | subtree:add(fds3.node_type, buffer(offset, len), info) 280 | return offset + len 281 | end 282 | 283 | function process_data_type(buffer, offset, subtree) 284 | data, offset, len = get_data(buffer, offset) 285 | info = data:uint() 286 | subtree:add(fds3.data_type, buffer(offset, len), info) 287 | return offset + len 288 | end 289 | 290 | 291 | function process_payload(buffer, offset, subtree, pinfo, tree, protocol_type) 292 | data, offset, len = get_data(buffer, offset) 293 | info = data:string() 294 | subtree:add(fds3.payload, buffer(offset, len), info) 295 | 296 | if (protocol_type == "SIP") then 297 | Dissector.get("sip"):call(buffer(offset):tvb(), pinfo, tree) 298 | pinfo.cols.protocol = "EEP3/SIP" 299 | elseif ((protocol_type == "JSON") or (protocol_type == "JSON/RTCP") or (protocol_type == "JSON/QOS")) then 300 | Dissector.get("json"):call(buffer(offset):tvb(), pinfo, tree) 301 | pinfo.cols.protocol = "EEP3/" .. protocol_type 302 | elseif (protocol_type == "LOG") then 303 | pinfo.cols.protocol = "EEP3/" .. protocol_type 304 | else 305 | pinfo.cols.protocol = "EEP3" 306 | end 307 | 308 | next_offset = offset + len 309 | return next_offset 310 | end 311 | 312 | function dissect_eep3(buffer, offset, subtree, pinfo, tree) 313 | eep_id = buffer(offset, FOUROCTETS):string() 314 | subtree:add(fds3.eep_id, buffer(offset, FOUROCTETS), eep_id) 315 | offset = offset + FOUROCTETS 316 | 317 | total_len = buffer(offset, TWOOCTETS):uint() 318 | subtree:add(fds3.length, buffer(offset, TWOOCTETS), total_len) 319 | 320 | -- debug("TOTAL LEN:" .. total_len) 321 | 322 | offset = offset + TWOOCTETS 323 | chunk_type = get_chunk_type(buffer, offset) 324 | 325 | while (offset < (total_len -1)) do 326 | if chunk_type == "00090001" then 327 | offset = process_proto_family(buffer, offset, subtree) 328 | elseif chunk_type == "00090002" then 329 | offset = process_proto_id(buffer, offset, subtree) 330 | elseif chunk_type == "00090003" then 331 | offset = process_src_ipv4_address(buffer, offset, subtree) 332 | elseif chunk_type == "00090004" then 333 | offset = process_dst_ipv4_address(buffer, offset, subtree) 334 | elseif chunk_type == "00090005" then 335 | offset = process_src_ipv6_address(buffer, offset, subtree) 336 | elseif chunk_type == "00090006" then 337 | offset = process_dst_ipv6_address(buffer, offset, subtree) 338 | elseif chunk_type == "00090007" then 339 | offset = process_src_port(buffer, offset, subtree) 340 | elseif chunk_type == "00090008" then 341 | offset = process_dst_port(buffer, offset, subtree) 342 | elseif chunk_type == "00090009" then 343 | offset = process_timestamp(buffer, offset, subtree) 344 | elseif chunk_type == "0009000a" then 345 | offset = process_timestamp_us(buffer, offset, subtree) 346 | elseif chunk_type == "0009000b" then 347 | offset, protocol_type = process_protocol_type(buffer, offset, subtree) 348 | elseif chunk_type == "0009000c" then 349 | offset = process_network_element_id(buffer, offset, subtree) 350 | elseif chunk_type == "0009000d" then 351 | offset = process_location(buffer, offset, subtree) 352 | elseif chunk_type == "0009000e" then 353 | offset = process_record_type(buffer, offset, subtree) 354 | elseif chunk_type == "0009000f" then 355 | offset = process_payload(buffer, offset, subtree, pinfo, tree, protocol_type) 356 | elseif chunk_type == "00090011" then 357 | offset = process_network_operator_id(buffer, offset, subtree) 358 | elseif chunk_type == "00090012" then 359 | offset = process_direction_int(buffer, offset, subtree) 360 | elseif chunk_type == "00090013" then 361 | offset = process_direction_pr(buffer, offset, subtree) 362 | elseif chunk_type == "00090014" then 363 | offset = process_liid(buffer, offset, subtree) 364 | elseif chunk_type == "00090015" then 365 | offset = process_cid(buffer, offset, subtree) 366 | elseif chunk_type == "00090016" then 367 | offset = process_seqnum(buffer, offset, subtree) 368 | elseif chunk_type == "00090017" then 369 | offset = process_node_type(buffer, offset, subtree) 370 | elseif chunk_type == "00090018" then 371 | offset = process_data_type(buffer, offset, subtree) 372 | else 373 | -- something not quite right 374 | if (offset < (total_len - 1)) then 375 | offset = process_unknown_chunk(buffer, offset) 376 | end 377 | end 378 | 379 | -- debug("chunk_type:" .. chunk_type) 380 | -- debug("offset:" .. offset) 381 | 382 | if (offset < (total_len - 1)) then 383 | chunk_type = get_chunk_type(buffer, offset) 384 | end 385 | end -- while 386 | end 387 | 388 | function eep3_proto_dissector(buffer, pinfo, tree) 389 | local subtree = tree:add(eep3_proto, buffer(), "EEP3 Protocol") 390 | dissect_eep3(buffer, offset, subtree, pinfo, tree) 391 | end 392 | 393 | function eep3_proto.dissector(buffer, pinfo, tree) 394 | offset = 0 395 | version = buffer(offset, FOUROCTETS):string() 396 | 397 | -- local size = buffer:len() 398 | -- debug("REAL LEN:" .. size) 399 | 400 | if (version == "EEP3") then 401 | eep3_proto_dissector(buffer, pinfo, tree) 402 | return 403 | end 404 | end 405 | 406 | 407 | -- 408 | tcp_table = DissectorTable.get("tcp.port") 409 | tcp_table:add(9999, eep3_proto) 410 | -------------------------------------------------------------------------------- /pcap/.empty: -------------------------------------------------------------------------------- 1 | PCAP File Directory 2 | -------------------------------------------------------------------------------- /pcap/hep.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sipcapture/hep-wireshark/263d84df79dfde5f880180d244dcbb87bd264f9a/pcap/hep.pcap -------------------------------------------------------------------------------- /pcap/hep3_compressed.pcap.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sipcapture/hep-wireshark/263d84df79dfde5f880180d244dcbb87bd264f9a/pcap/hep3_compressed.pcap.pcapng --------------------------------------------------------------------------------