diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gryphon/.cvsignore | 12 | ||||
-rw-r--r-- | plugins/gryphon/AUTHORS | 5 | ||||
-rw-r--r-- | plugins/gryphon/COPYING | 340 | ||||
-rw-r--r-- | plugins/gryphon/ChangeLog | 0 | ||||
-rw-r--r-- | plugins/gryphon/INSTALL | 0 | ||||
-rw-r--r-- | plugins/gryphon/Makefile.am | 21 | ||||
-rw-r--r-- | plugins/gryphon/NEWS | 0 | ||||
-rw-r--r-- | plugins/gryphon/README | 9 | ||||
-rwxr-xr-x | plugins/gryphon/autogen.sh | 46 | ||||
-rw-r--r-- | plugins/gryphon/configure.in | 69 | ||||
-rw-r--r-- | plugins/gryphon/packet-gryphon.c | 1560 | ||||
-rw-r--r-- | plugins/gryphon/packet-gryphon.h | 398 |
12 files changed, 2460 insertions, 0 deletions
diff --git a/plugins/gryphon/.cvsignore b/plugins/gryphon/.cvsignore new file mode 100644 index 0000000000..f8189aa957 --- /dev/null +++ b/plugins/gryphon/.cvsignore @@ -0,0 +1,12 @@ +.deps +Makefile +Makefile.in +aclocal.m4 +config.cache +config.h +config.h.in +config.log +config.status +configure +stamp-h +stamp-h.in diff --git a/plugins/gryphon/AUTHORS b/plugins/gryphon/AUTHORS new file mode 100644 index 0000000000..105619ac4b --- /dev/null +++ b/plugins/gryphon/AUTHORS @@ -0,0 +1,5 @@ +Author : +Steve Limkemann <stevelim@dgtech.com> + +Plugin conversion : +Olivier Abad <abad@daba.dhis.net> diff --git a/plugins/gryphon/COPYING b/plugins/gryphon/COPYING new file mode 100644 index 0000000000..d60c31a97a --- /dev/null +++ b/plugins/gryphon/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/plugins/gryphon/ChangeLog b/plugins/gryphon/ChangeLog new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/plugins/gryphon/ChangeLog diff --git a/plugins/gryphon/INSTALL b/plugins/gryphon/INSTALL new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/plugins/gryphon/INSTALL diff --git a/plugins/gryphon/Makefile.am b/plugins/gryphon/Makefile.am new file mode 100644 index 0000000000..bd0ef583a1 --- /dev/null +++ b/plugins/gryphon/Makefile.am @@ -0,0 +1,21 @@ +# Makefile.am +# fichier Automake pour gryphon +# + +ETHEREAL_DIR=../.. + +bin_PROGRAMS = gryphon + +CLEANFILES = \ + packet-gryphon.o + gryphon + *~ + +gryphon_SOURCES = \ + packet-gryphon.c \ + packet-gryphon.h + +INCLUDES = -I$(ETHEREAL_DIR) + +gryphon: packet-gryphon.o + $(LD) -shared -o $@ $< diff --git a/plugins/gryphon/NEWS b/plugins/gryphon/NEWS new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/plugins/gryphon/NEWS diff --git a/plugins/gryphon/README b/plugins/gryphon/README new file mode 100644 index 0000000000..77ef1da2b1 --- /dev/null +++ b/plugins/gryphon/README @@ -0,0 +1,9 @@ +Dearborn Group Technology has released under GPL this plugin +for Ethereal. It decodes the protocol used by their Gryphon +automotive network tool. + +The plugin decodes the communication protocol, but not any +vehicle network messages. + +Dearborn Group Technology can be found at http://www.dgtech.com/ +The author is Steve Limkemann <stevelim@dgtech.com> diff --git a/plugins/gryphon/autogen.sh b/plugins/gryphon/autogen.sh new file mode 100755 index 0000000000..0612adcf83 --- /dev/null +++ b/plugins/gryphon/autogen.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# +# Run this to generate all the initial makefiles. +# +# $Id: autogen.sh,v 1.1 1999/12/15 06:53:27 gram Exp $ + +DIE=0 +PROJECT="Gryphon" + +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have autoconf installed to compile $PROJECT." + echo "Download the appropriate package for your distribution/OS," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +(automake --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "You must have automake installed to compile $PROJECT." + echo "Download the appropriate package for your distribution/OS," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + DIE=1 +} + +if test "$DIE" -eq 1 ; then + exit 1 +fi + +if test -z "$*"; then + echo "Running ./configure with no arguments. If you wish to pass any," + echo "please specify them on the $0 command line." +fi + +for dir in . ; do + echo processing $dir + (cd $dir; \ + aclocalinclude="$ACLOCAL_FLAGS"; \ + aclocal $aclocalinclude; \ + autoheader; automake --add-missing --gnu $am_opt; autoconf) +done + +./configure "$@" + +echo +echo "Now type 'make' to compile $PROJECT." diff --git a/plugins/gryphon/configure.in b/plugins/gryphon/configure.in new file mode 100644 index 0000000000..ff6ab60036 --- /dev/null +++ b/plugins/gryphon/configure.in @@ -0,0 +1,69 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(packet-gryphon.c) +AM_INIT_AUTOMAKE(gryphon, 0.0.1) +AM_CONFIG_HEADER(config.h) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CPP + +# If we're running gcc, add '-Wall' to CFLAGS. +AC_MSG_CHECKING(to see if we can add '-Wall' to CFLAGS) +if test x$GCC != x ; then + CFLAGS="-Wall $CFLAGS" + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + +# Checks for glib first, or gtk+ if not present +AM_PATH_GLIB(1.2.0, CFLAGS="$CFLAGS $GLIB_CFLAGS" LIBS="$LIBS $GLIB_LIBS") + +dnl Checks for header files +dnl WARNING: do *NOT* check for "unistd.h" unless you work around the +dnl following problem: +dnl +dnl At least on FreeBSD 3.2, "/usr/include/zlib.h" includes +dnl "/usr/include/zconf.h", which, if HAVE_UNISTD_H is defined, +dnl #defines "z_off_t" to be "off_t", and if HAVE_UNISTD_H is +dnl not defines, #defines "z_off_t" to be "long" if it's not +dnl already #defined. +dnl +dnl In 4.4-Lite-derived systems such as FreeBSD, "off_t" is +dnl "long long int", not "long int", so the definition of "z_off_t" - +dnl and therefore the types of the arguments to routines such as +dnl "gzseek()", as declared, with prototypes, in "zlib.h" - depends +dnl on whether HAVE_UNISTD_H is defined prior to including "zlib.h"! +dnl +dnl It's not defined in the FreeBSD 3.2 "zlib", so if we include "zlib.h" +dnl after defining HAVE_UNISTD_H, we get a misdeclaration of "gzseek()", +dnl and, if we're building with "zlib" support, anything that seeks +dnl on a file may not work. +dnl +dnl Other BSDs may have the same problem, if they haven't done something +dnl such as defining HAVE_UNISTD_H in "zconf.h". +dnl +dnl If "config.h" defines HAVE_UNISTD_H - which it will, on all systems +dnl that have it, if we test for it here, and all 4.4-Lite-derived +dnl BSDs have it - then, given that "zlib.h" is included by "file.h", +dnl that means that unless we include "zlib.h" before we include +dnl "config.h", we get a misdeclaration of "gzseek()". +dnl +dnl Unfortunately, it's "config.h" that tells us whether we have "zlib" +dnl in the first place, so we don't know whether to include "zlib.h" +dnl until we include "config.h".... +dnl +dnl Fortunately, we don't use "unistd.h", so we don't need to check +dnl for it. +dnl +dnl If we ever *do* end up requiring HAVE_UNISTD_H, a fix might be to +dnl turn "file_seek()" into a subroutine, at least if HAVE_ZLIB is +dnl defined, have it take an "off_t" as its second argument, and +dnl put it into a file that doesn't require HAVE_UNISTD_H. +dnl +AC_HEADER_STDC +AC_CHECK_HEADERS(sys/time.h netinet/in.h) + +AC_CANONICAL_HOST + +AC_OUTPUT(Makefile) diff --git a/plugins/gryphon/packet-gryphon.c b/plugins/gryphon/packet-gryphon.c new file mode 100644 index 0000000000..8b3e9df60f --- /dev/null +++ b/plugins/gryphon/packet-gryphon.c @@ -0,0 +1,1560 @@ +/* packet-gryphon.c + * Routines for Gryphon protocol packet disassembly + * + * $Id: packet-gryphon.c,v 1.1 1999/12/15 06:53:30 gram Exp $ + * + * Ethereal - Network traffic analyzer + * By Steve Limkemann <stevelim@dgtech.com> + * Copyright 1998 Steve Limkemann + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +#include <string.h> +#include <ctype.h> + +#include <glib.h> +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif +#include "packet.h" +#include "dfilter.h" +#include "packet-gryphon.h" + +const gchar version[] = VERSION; +const gchar desc[] = "DG Gryphon Protocol"; +const gchar protocol[] = "tcp"; +const gchar filter_string[] = "tcp.port == 7000"; + +static int proto_gryphon = -1; + +static int hf_gryph_src = -1; +static int hf_gryph_srcchan = -1; +static int hf_gryph_dest = -1; +static int hf_gryph_destchan= -1; +static int hf_gryph_type = -1; +static int hf_gryph_cmd = -1; + +static gint ett_gryphon = -1; +static gint ett_gryphon_header = -1; +static gint ett_gryphon_body = -1; +static gint ett_gryphon_command_data = -1; +static gint ett_gryphon_response_data = -1; +static gint ett_gryphon_data_header = -1; +static gint ett_gryphon_flags = -1; +static gint ett_gryphon_data_body = -1; +static gint ett_gryphon_cmd_filter_block = -1; +static gint ett_gryphon_cmd_events_data = -1; +static gint ett_gryphon_cmd_config_device = -1; +static gint ett_gryphon_cmd_sched_data = -1; +static gint ett_gryphon_cmd_sched_cmd = -1; +static gint ett_gryphon_cmd_response_block = -1; +static gint ett_gryphon_pgm_list = -1; +static gint ett_gryphon_pgm_status = -1; +static gint ett_gryphon_pgm_options = -1; + + +void dissector(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) +{ + + proto_tree *gryphon_tree, *header_tree, *body_tree; + proto_item *ti, *header_item, *body_item; + const u_char *data, *dataend, *msgend; + int src, msglen, msgpad, dest, frmtyp, i, end_of_frame; + static const u_char *frame_type[] = {"", + "Command request", + "Command response", + "Network (vehicle) data", + "Event", + "Miscelaneous", + "Text string"}; + static const value_string src_dest[] = { + {SD_CARD, "Card"}, + {SD_SERVER, "Server"}, + {SD_CLIENT, "Client"}, + {SD_SCHED, "Scheduler"}, + {SD_SCRIPT, "Script Processor"}, + {SD_PGM, "Program Loader"}, + {SD_USDT, "USDT Server"}, + {SD_BLM, "Bus Load Monitoring"}, + {SD_FLIGHT, "Flight Recorder"}, + {SD_RESP, "Message Responder"}, + {-1, "- unknown -"}, + }; + + data = &pd[offset]; + if (fd) { + end_of_frame = END_OF_FRAME; + } + else { + end_of_frame = pntohs (data + 4) + 8; + end_of_frame += 3 - (end_of_frame + 3 ) % 4; + } + dataend = data + end_of_frame; + + if (fd && check_col(fd, COL_PROTOCOL)) + col_add_str(fd, COL_PROTOCOL, "Gryphon"); + + if (END_OF_FRAME < 8) + return; + + if (fd && check_col(fd, COL_INFO)) { + /* + * Indicate what kind of message this is. + */ + col_add_str (fd, COL_INFO, frame_type[data[6]]); + } + if (tree) { + if (fd) { + ti = proto_tree_add_item(tree, proto_gryphon, offset, + end_of_frame, NULL); + gryphon_tree = proto_item_add_subtree(ti, ett_gryphon); + } else + gryphon_tree = tree; + + while (data < dataend) { + src = data[0]; + dest = data[2]; + frmtyp = data[6]; + msglen = pntohs ((unsigned short *)&data[4]); + + header_item = proto_tree_add_text(gryphon_tree, offset, + MSG_HDR_SZ, "Header", NULL); + header_tree = proto_item_add_subtree(header_item, + ett_gryphon_header); + for (i = 0; i < SIZEOF(src_dest); i++) { + if (src_dest[i].value == src) + break; + } + if (i >= SIZEOF(src_dest)) + i = SIZEOF(src_dest) - 1; + proto_tree_add_text(header_tree, offset, 2, + "Source: %s, channel %hd", src_dest[i].strptr, data[1]); + proto_tree_add_item_hidden(header_tree, hf_gryph_src, offset, 1, src); + proto_tree_add_item_hidden(header_tree, hf_gryph_srcchan, offset+1, 1, data[1]); + + for (i = 0; i < SIZEOF(src_dest); i++) { + if (src_dest[i].value == dest) + break; + } + if (i >= SIZEOF(src_dest)) + i = SIZEOF(src_dest) - 1; + proto_tree_add_text(header_tree, offset+2, 2, + "Destination: %s, channel %hd", src_dest[i].strptr, data[3]); + proto_tree_add_item_hidden(header_tree, hf_gryph_dest, offset+2, 1, dest); + proto_tree_add_item_hidden(header_tree, hf_gryph_destchan, offset+3, 1, data[3]); + + proto_tree_add_text(header_tree, offset+4, 2, + "Data length: %d bytes", msglen); + proto_tree_add_text(header_tree, offset+6, 1, + "Frame type: %s", frame_type[frmtyp]); + proto_tree_add_text(header_tree, offset+7, 1, "reserved", NULL); + + proto_tree_add_item_hidden(header_tree, hf_gryph_type, offset+6, 1, frmtyp); + msgpad = 3 - (msglen + 3) % 4; + msgend = data + msglen + msgpad + MSG_HDR_SZ; + + body_item = proto_tree_add_text(gryphon_tree, offset + MSG_HDR_SZ, + msglen + msgpad, "Body", NULL); + body_tree = proto_item_add_subtree(body_item, ett_gryphon_body); + + offset += MSG_HDR_SZ; + data += MSG_HDR_SZ; + switch (frmtyp) { + case GY_FT_CMD: + decode_command (dest, &data, dataend, &offset, msglen, body_tree); + break; + case GY_FT_RESP: + decode_response (src, &data, dataend, &offset, msglen, body_tree); + break; + case GY_FT_DATA: + decode_data (src, &data, dataend, &offset, msglen, body_tree); + break; + case GY_FT_EVENT: + decode_event (src, &data, dataend, &offset, msglen, body_tree); + break; + case GY_FT_MISC: + break; + case GY_FT_TEXT: + break; + default: + } + if (data < msgend - msgpad) { + i = msgend - msgpad - data; + proto_tree_add_text(gryphon_tree, offset, i, "Data", NULL); + BUMP (offset, data, i); + } + if (data < msgend) { + i = msgend - data; + proto_tree_add_text(gryphon_tree, offset, i, "padding", NULL); + BUMP (offset, data, i); + } +/* data = dataend;*/ + } + + } +} + + +static const val_str_dsp cmds[] = { + {CMD_INIT, "Initialize", cmd_init, NULL}, + {CMD_GET_STAT, "Get status", NULL, NULL}, + {CMD_GET_CONFIG, "Get configuration", NULL, resp_config}, + {CMD_EVENT_ENABLE, "Enable event", eventnum, NULL}, + {CMD_EVENT_DISABLE, "Disable event", eventnum, NULL}, + {CMD_GET_TIME, "Get time", NULL, resp_time}, + {CMD_GET_RXDROP, "Get number of dropped RX messages", NULL, NULL}, + {CMD_RESET_RXDROP, "Clear number of dropped RX messages", NULL, NULL}, + {CMD_BCAST_ON, "Set broadcasts on", NULL, NULL}, + {CMD_BCAST_OFF, "Set broadcasts off", NULL, NULL}, + {CMD_CARD_SET_SPEED, "Set channel baud rate", speed, NULL}, + {CMD_CARD_GET_SPEED, "Get channel baud rate", NULL, speed}, + {CMD_CARD_SET_FILTER, "Set filter (depricated)", cmd_setfilt, NULL}, + {CMD_CARD_GET_FILTER, "Get filter", resp_addfilt, cmd_addfilt}, + {CMD_CARD_TX, "Transmit message", decode_data, NULL}, + {CMD_CARD_TX_LOOP_ON, "Set transmit loopback on", NULL, NULL}, + {CMD_CARD_TX_LOOP_OFF, "Set transmit loopback off", NULL, NULL}, + {CMD_CARD_IOCTL, "IOCTL pass-through", cmd_ioctl, NULL}, + {CMD_CARD_ADD_FILTER, "Add a filter", cmd_addfilt, resp_addfilt}, + {CMD_CARD_MODIFY_FILTER, "Modify a filter", cmd_modfilt, NULL}, + {CMD_CARD_GET_FILTER_HANDLES, "Get filter handles", NULL, resp_filthan}, + {CMD_CARD_SET_DEFAULT_FILTER, "Set default filter", dfiltmode, NULL}, + {CMD_CARD_GET_DEFAULT_FILTER, "Get default filter mode", NULL, dfiltmode}, + {CMD_CARD_SET_FILTER_MODE, "Set filter mode", filtmode, NULL}, + {CMD_CARD_GET_FILTER_MODE, "Get filter mode", NULL, filtmode}, + {CMD_CARD_GET_EVNAMES, "Get event names", NULL, resp_events}, + {CMD_CARD_GET_SPEEDS, "Get defined speeds", NULL, NULL}, + {CMD_SERVER_REG, "Register with server", cmd_register, resp_register}, + {CMD_BLM_SET_MODE, "Set Bus Load Monitoring mode", blm_mode, NULL}, + {CMD_BLM_GET_MODE, "Get Bus Load Monitoring mode", NULL, blm_mode}, + {CMD_BLM_GET_DATA, "Get Bus Load data", NULL, resp_blm_data}, + {CMD_BLM_GET_STATS, "Get Bus Load statistics", NULL, resp_blm_stat}, + {CMD_FLIGHT_GET_CONFIG, "Get flight recorder channel info", NULL, NULL}, + {CMD_FLIGHT_START_MON, "Start flight recorder monitoring", NULL, NULL}, + {CMD_FLIGHT_STOP_MON, "Stop flight recorder monitoring", NULL, NULL}, + {CMD_MSGRESP_ADD, "Add response message", cmd_addresp, resp_addresp}, + {CMD_MSGRESP_GET, "Get response message", resp_addresp, cmd_addresp}, + {CMD_MSGRESP_MODIFY, "Modify response message state", cmd_modresp, NULL}, + {CMD_MSGRESP_GET_HANDLES, "Get response message handles", NULL, resp_resphan}, + {CMD_PGM_DESC, "Describe program to to uploaded", cmd_desc, resp_desc}, + {CMD_PGM_UPLOAD, "Upload a program to the Gryphon", cmd_upload, NULL}, + {CMD_PGM_DELETE, "Delete an uploaded program", cmd_delete, NULL}, + {CMD_PGM_LIST, "Get a list of uploaded programs", cmd_list, resp_list}, + {CMD_PGM_START, "Start an uploaded program", cmd_start, resp_start}, + {CMD_PGM_STOP, "Stop an uploaded program", resp_start, NULL}, + {CMD_PGM_STATUS, "Get status of an uploaded program", cmd_delete, resp_status}, + {CMD_PGM_OPTIONS, "Set program upload options", cmd_options, resp_status}, + {CMD_SCHED_TX, "Schedule transmission of messages", cmd_sched, resp_sched}, + {CMD_SCHED_KILL_TX, "Stop and destroy a message transmission", NULL, NULL}, + {CMD_SCHED_STOP_TX, "Kill a message transmission (deprecated)", NULL, NULL}, + {-1, "- unknown -", NULL, NULL}, + }; + +static const value_string responses[] = { + {RESP_OK, "OK - no error"}, + {RESP_UNKNOWN_ERR, "Unknown error"}, + {RESP_UNKNOWN_CMD, "Unrecognised command"}, + {RESP_UNSUPPORTED, "Unsupported command"}, + {RESP_INVAL_CHAN, "Invalid channel specified"}, + {RESP_INVAL_DST, "Invalid destination"}, + {RESP_INVAL_PARAM, "Invalid parameter(s)"}, + {RESP_INVAL_MSG, "Invalid message"}, + {RESP_INVAL_LEN, "Invalid length field"}, + {RESP_TX_FAIL, "Transmit failed"}, + {RESP_RX_FAIL, "Receive failed"}, + {RESP_AUTH_FAIL, "Authorization failed"}, + {RESP_MEM_ALLOC_ERR, "Memory allocation error"}, + {RESP_TIMEOUT, "Command timed out"}, + {RESP_UNAVAILABLE, "Unavailable"}, + {RESP_BUF_FULL, "Buffer full"}, + {RESP_NO_SUCH_JOB, "No such job"}, + {-1, "- unknown -"}, + }; + +static const value_string filter_data_types[] = { + {FILTER_DATA_TYPE_HEADER_FRAME, "frame header"}, + {FILTER_DATA_TYPE_HEADER, "data message header"}, + {FILTER_DATA_TYPE_DATA, "data message data"}, + {FILTER_DATA_TYPE_EXTRA_DATA, "data message extra data"}, + {-1, "- unknown -"}, + }; + +static const value_string operators[] = { + {BIT_FIELD_CHECK, "Bit field check"}, + {SVALUE_GT, "Greater than (signed)"}, + {SVALUE_GE, "Greater than or equal to (signed)"}, + {SVALUE_LT, "Less than (signed)"}, + {SVALUE_LE, "Less than or equal to (signed)"}, + {VALUE_EQ, "Equal to"}, + {VALUE_NE, "Not equal to"}, + {UVALUE_GT, "Greater than (unsigned)"}, + {UVALUE_GE, "Greater than or equal to (unsigned)"}, + {UVALUE_LT, "Less than (unsigned)"}, + {UVALUE_LE, "Less than or equal to (unsigned)"}, + {DIG_LOW_TO_HIGH, "Digital, low to high transistion"}, + {DIG_HIGH_TO_LOW, "Digital, high to low transistion"}, + {DIG_TRANSITION, "Digital, change of state"}, + {-1, "- unknown -"}, + }; + +static const value_string modes[] = { + {FILTER_OFF_PASS_ALL, "Filter off, pass all messages"}, + {FILTER_OFF_BLOCK_ALL, "Filter off, block all messages"}, + {FILTER_ON, "Filter on"}, + {-1, "- unknown -"}, + }; + +static const value_string dmodes[] = { + {DEFAULT_FILTER_BLOCK, "Block"}, + {DEFAULT_FILTER_PASS, "Pass"}, + {-1, "- unknown -"}, + }; + +static const value_string filtacts[] = { + {DELETE_FILTER, "Delete"}, + {ACTIVATE_FILTER, "Activate"}, + {DEACTIVATE_FILTER, "Deactivate"}, + {-1, "- unknown -"}, + }; + +static const value_string ioctls[] = { + {GINIT, "GINIT: Initialize"}, + {GLOOPON, "GLOOPON: Loop on"}, + {GLOOPOFF, "GLOOPOFF: Loop off"}, + {GGETHWTYPE, "GGETHWTYPE: Get hardware type"}, + {GGETREG, "GGETREG: Get register"}, + {GSETREG, "GSETREG: Set register"}, + {GGETRXCOUNT, "GGETRXCOUNT: Get the receive message counter"}, + {GSETRXCOUNT, "GSETRXCOUNT: Set the receive message counter"}, + {GGETTXCOUNT, "GGETTXCOUNT: Get the transmit message counter"}, + {GSETTXCOUNT, "GSETTXCOUNT: Set the transmit message counter"}, + {GGETRXDROP, "GGETRXDROP: Get the number of dropped receive messages"}, + {GSETRXDROP, "GSETRXDROP: Set the number of dropped receive messages"}, + {GGETTXDROP, "GGETTXDROP: Get the number of dropped transmit messages"}, + {GSETTXDROP, "GSETTXDROP: Set the number of dropped transmit messages"}, + {GGETRXBAD, "GGETRXBAD: Get the number of bad receive messages"}, + {GGETTXBAD, "GGETTXBAD: Get the number of bad transmit messages"}, + {GGETCOUNTS, "GGETCOUNTS: Get total message counter"}, + {GGETBLMON, "GGETBLMON: Get bus load monitoring status"}, + {GSETBLMON, "GSETBLMON: Set bus load monitoring status (turn on/off)"}, + {GGETERRLEV, "GGETERRLEV: Get error level"}, + {GSETERRLEV, "GSETERRLEV: Set error level"}, + {GGETBITRATE, "GGETBITRATE: Get bit rate"}, + {GGETRAM, "GGETRAM: Read value from RAM"}, + {GSETRAM, "GSETRAM: Write value to RAM"}, + {GCANGETBTRS, "GCANGETBTRS: Read CAN bit timing registers"}, + {GCANSETBTRS, "GCANSETBTRS: Write CAN bit timing registers"}, + {GCANGETBC, "GCANGETBC: Read CAN byte count"}, + {GCANSETBC, "GCANSETBC: Write CAN byte count"}, + {GCANGETMODE, "GCANGETMODE"}, + {GCANSETMODE, "GCANSETMODE"}, + {GCANGETTRANS, "GCANGETTRANS"}, + {GCANSETTRANS, "GCANSETTRANS"}, + {GCANSENDERR, "GCANSENDERR"}, + {GCANRGETOBJ, "GCANRGETOBJ"}, + {GCANRSETSTDID, "GCANRSETSTDID"}, + {GCANRSETEXTID, "GCANRSETEXTID"}, + {GCANRSETDATA, "GCANRSETDATA"}, + {GCANRENABLE, "GCANRENABLE"}, + {GCANRDISABLE, "GCANRDISABLE"}, + {GCANRGETMASKS, "GCANRGETMASKS"}, + {GCANRSETMASKS, "GCANRSETMASKS"}, + {GCANSWGETMODE, "GCANSWGETMODE"}, + {GCANSWSETMODE, "GCANSWSETMODE"}, + {GDLCGETFOURX, "GDLCGETFOURX"}, + {GDLCSETFOURX, "GDLCSETFOURX"}, + {GDLCGETLOAD, "GDLCGETLOAD"}, + {GDLCSETLOAD, "GDLCSETLOAD"}, + {GDLCSENDBREAK, "GDLCSENDBREAK"}, + {GDLCABORTTX, "GDLCABORTTX"}, + {GDLCGETHDRMODE, "DLCGETHDRMODE"}, + {GDLCSETHDRMODE, "GDLCSETHDRMODE"}, + {GHONSLEEP, "GHONSLEEP"}, + {GHONSILENCE, "GHONSILENCE"}, + {GKWPSETPTIMES, "GKWPSETPTIMES"}, + {GKWPSETWTIMES, "GKWPSETWTIMES"}, + {GKWPDOWAKEUP, "GKWPDOWAKEUP"}, + {GKWPGETBITTIME, "GKWPGETBITTIME"}, + {GKWPSETBITTIME, "GKWPSETBITTIME"}, + {GKWPSETNODEADDR, "GKWPSETNODEADDR"}, + {GKWPGETNODETYPE, "GKWPGETNODETYPE"}, + {GKWPSETNODETYPE, "GKWPSETNODETYPE"}, + {GKWPSETWAKETYPE, "GKWPSETWAKETYPE"}, + {GKWPSETTARGADDR, "GKWPSETTARGADDR"}, + {GKWPSETKEYBYTES, "GKWPSETKEYBYTES"}, + {GKWPSETSTARTREQ, "GKWPSETSTARTREQ"}, + {GKWPSETSTARTRESP, "GKWPSETSTARTRESP"}, + {GKWPSETPROTOCOL, "GKWPSETPROTOCOL"}, + {GKWPGETLASTKEYBYTES, "GKWPGETLASTKEYBYTES"}, + {GKWPSETLASTKEYBYTES, "GKWPSETLASTKEYBYTES"}, + {GSCPGETBBR, "GSCPGETBBR"}, + {GSCPSETBBR, "GSCPSETBBR"}, + {GSCPGETID, "GSCPGETID"}, + {GSCPSETID, "GSCPSETID"}, + {GSCPADDFUNCID, "GSCPADDFUNCID"}, + {GSCPCLRFUNCID, "GSCPCLRFUNCID"}, + {GUBPGETBITRATE, "GUBPGETBITRATE"}, + {GUBPSETBITRATE, "GUBPSETBITRATE"}, + {GUBPGETINTERBYTE, "GUBPGETINTERBYTE"}, + {GUBPSETINTERBYTE, "GUBPSETINTERBYTE"}, + {GUBPGETNACKMODE, "GUBPGETNACKMODE"}, + {GUBPSETNACKMODE, "GUBPSETNACKMODE"}, + {-1, "- unknown -"}, + }; + + +void +decode_command (int dst, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + int cmd, i; + proto_tree *ft; + proto_item *pi; + + cmd = (*data)[0]; + proto_tree_add_item_hidden(pt, hf_gryph_cmd, *offset, 1, cmd); + if (cmd > 0x3F) + cmd += dst * 256; + + for (i = 0; i < SIZEOF(cmds); i++) { + if (cmds[i].value == cmd) + break; + } + if (i >= SIZEOF(cmds) && dst >= SD_KNOWN) { + cmd = (cmd & 0xFF) + SD_CARD * 256; + for (i = 0; i < SIZEOF(cmds); i++) { + if (cmds[i].value == cmd) + break; + } + } + if (i >= SIZEOF(cmds)) + i = SIZEOF(cmds) - 1; + + proto_tree_add_text (pt, *offset, 4, "Command: %s", cmds[i].strptr); + BUMP (*offset, *data, 4); + + if (cmds[i].cmd_fnct && dataend - *data) { + pi = proto_tree_add_text(pt, *offset, dataend - *data, "Data: (%d bytes)", dataend - *data); + ft = proto_item_add_subtree(pi, ett_gryphon_command_data); + (*(cmds[i].cmd_fnct)) (dst, data, dataend, offset, msglen, ft); + } +} + +void +decode_response (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + int cmd, i, j, resp; + proto_tree *ft; + proto_item *pi; + + cmd = (*data)[0]; + if (cmd > 0x3F) + cmd += src * 256; + + for (i = 0; i < SIZEOF(cmds); i++) { + if (cmds[i].value == cmd) + break; + } + if (i >= SIZEOF(cmds) && src >= SD_KNOWN) { + cmd = (cmd & 0xFF) + SD_CARD * 256; + for (i = 0; i < SIZEOF(cmds); i++) { + if (cmds[i].value == cmd) + break; + } + } + if (i >= SIZEOF(cmds)) + i = SIZEOF(cmds) - 1; + proto_tree_add_text (pt, *offset, 4, "Command: %s", cmds[i].strptr); + BUMP (*offset, *data, 4); + + resp = pntohl ((unsigned long *)data[0]); + for (j = 0; j < SIZEOF(responses); j++) { + if (responses[j].value == resp) + break; + } + if (j >= SIZEOF(responses)) + j = SIZEOF(responses) - 1; + proto_tree_add_text (pt, *offset, 4, "Status: %s", responses[j].strptr); + BUMP (*offset, *data, 4); + + if (cmds[i].rsp_fnct) { + pi = proto_tree_add_text(pt, *offset, dataend - *data, "Data: (%d bytes)", dataend - *data); + ft = proto_item_add_subtree(pi, ett_gryphon_response_data); + (*(cmds[i].rsp_fnct)) (src, data, dataend, offset, msglen, ft); + } +} + +void +decode_data (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + proto_item *item, *item1; + proto_tree *tree, *tree1; + int hdrsize, datasize, extrasize, hdrbits, msgsize, padding, mode; + int hours, minutes, seconds, fraction; + unsigned long timestamp; + + hdrsize = (*data)[0]; + hdrbits = (*data)[1]; + datasize = pntohs ((unsigned short *)((*data)+2)); + extrasize = (*data)[4]; + padding = 3 - (hdrsize + datasize + extrasize + 3) % 4; + msgsize = hdrsize + datasize + extrasize + padding + 16; + + item = proto_tree_add_text(pt, *offset, 16, "Message header", NULL); + tree = proto_item_add_subtree (item, ett_gryphon_data_header); + proto_tree_add_text(tree, *offset, 2, "Header length: %d bytes, %d bits", hdrsize, hdrbits); + proto_tree_add_text(tree, *offset+2, 2, "Data length: %d bytes", datasize); + proto_tree_add_text(tree, *offset+4, 1, "Extra data length: %d bytes", extrasize); + mode = (*data)[5]; + item1 = proto_tree_add_text(tree, *offset+5, 1, "Mode: %hd", mode); + if (mode) { + tree1 = proto_item_add_subtree (item1, ett_gryphon_flags); + if (mode & 0x80) + proto_tree_add_text(tree1, *offset+5, 1, "1... .... = Transmitted message", NULL); + if (mode & 0x40) + proto_tree_add_text(tree1, *offset+5, 1, ".1.. .... = Received message", NULL); + if (mode & 0x20) + proto_tree_add_text(tree1, *offset+5, 1, "..1. .... = Local message", NULL); + if (mode & 0x10) + proto_tree_add_text(tree1, *offset+5, 1, "...1 .... = Remote message", NULL); + if (mode & 0x01) + proto_tree_add_text(tree1, *offset+5, 1, ".... ...1 = Internal message", NULL); + } + proto_tree_add_text(tree, *offset+6, 1, "Priority: %d", (*data)[6]); + proto_tree_add_text(tree, *offset+7, 1, "Error status: %hd", (*data)[7]); + timestamp = pntohl ((unsigned long *)((*data)+8)); + hours = timestamp /(100000 * 60 *60); + minutes = (timestamp / (100000 * 60)) % 60; + seconds = (timestamp / 100000) % 60; + fraction = timestamp % 100000; + proto_tree_add_text(tree, *offset+8, 4, "Timestamp: %d:%02d:%02d.%05d", hours, minutes, seconds, fraction); + proto_tree_add_text(tree, *offset+12, 1, "Context: %hd", (*data)[12]); + proto_tree_add_text(tree, *offset+13, 3, "reserved:", NULL); + BUMP (*offset, *data, 16); + item = proto_tree_add_text(pt, *offset, msgsize-16-padding, "Message Body", NULL); + tree = proto_item_add_subtree (item, ett_gryphon_data_body); + if (hdrsize) { + proto_tree_add_text(tree, *offset, hdrsize, "Header", NULL); + BUMP (*offset, *data, hdrsize); + } + if (datasize) { + proto_tree_add_text(tree, *offset, datasize, "Data", NULL); + BUMP (*offset, *data, datasize); + } + if (extrasize) { + proto_tree_add_text(tree, *offset, extrasize, "Extra data", NULL); + BUMP (*offset, *data, extrasize); + } + if (padding) { + proto_tree_add_text(pt, *offset, padding, "padding", NULL); + BUMP (*offset, *data, padding); + } +} + +void +decode_event (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + int hours, minutes, seconds, fraction, padding, length; + unsigned long timestamp; + const u_char *msgend; + + padding = 3 - (msglen + 3) % 4; + msgend = *data + msglen; + proto_tree_add_text(pt, *offset, 1, "Event ID: %hd", **data); + proto_tree_add_text(pt, *offset+1, 1, "Event context: %hd", *((*data)+1)); + proto_tree_add_text(pt, *offset+2, 2, "reserved", NULL); + BUMP (*offset, *data, 4); + timestamp = pntohl ((unsigned long *)(*data)); + hours = timestamp /(100000 * 60 *60); + minutes = (timestamp / (100000 * 60)) % 60; + seconds = (timestamp / 100000) % 60; + fraction = timestamp % 100000; + proto_tree_add_text(pt, *offset, 4, "Timestamp: %d:%02d:%02d.%05d", hours, minutes, seconds, fraction); + BUMP (*offset, *data, 4); + if (*data < msgend) { + length = msgend - *data; + proto_tree_add_text (pt, *offset, length, "Data (%d bytes)", length); + BUMP (*offset, *data, length); + } + if (padding) { + proto_tree_add_text (pt, *offset, padding, "padding", NULL); + BUMP (*offset, *data, padding); + } +} + +void +cmd_init (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + char *ptr; + + if (*data >= dataend) + return; + if (**data == 0) + ptr = "Always initialize"; + else + ptr = "Initialize if not previously initialized"; + proto_tree_add_text(pt, *offset, 1, "Mode: %s", ptr); + proto_tree_add_text(pt, *offset+1, 3, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +eventnum (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + unsigned char event = **data; + + if (event) + proto_tree_add_text(pt, *offset, 1, "Event number: %hd", event); + else + proto_tree_add_text(pt, *offset, 1, "Event numbers: All", NULL); + proto_tree_add_text(pt, *offset+1, 3, "padding", NULL); + BUMP (*offset, *data, 4); +} + +void +resp_time (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + int hours, minutes, seconds, fraction; + union { + unsigned int lng[2]; + unsigned long long int lnglng; + } ts; + unsigned int timestamp; + unsigned char date[45]; + + ts.lng[1] = pntohl ((unsigned int *)(*data)); + ts.lng[0] = pntohl ((unsigned int *)((*data)+4)); + timestamp = ts.lnglng / 100000LL; + strncpy (date, ctime((time_t*)×tamp), sizeof(date)); + date[strlen(date)-1] = 0x00; + proto_tree_add_text(pt, *offset, 8, "Date/Time: %s", date); + timestamp = ts.lng[0]; + hours = timestamp /(100000 * 60 *60); + minutes = (timestamp / (100000 * 60)) % 60; + seconds = (timestamp / 100000) % 60; + fraction = timestamp % 100000; + proto_tree_add_text(pt, *offset+4, 4, "Timestamp: %d:%02d:%02d.%05d", hours, minutes, seconds, fraction); + BUMP (*offset, *data, 8); +} + +void +cmd_setfilt (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + int flag = pntohl ((unsigned int *)((*data)+4)); + int length, padding; + unsigned char mode[30]; + + length = *((*data)+4) + *((*data)+5) + pntohs ((unsigned short *)((*data)+6)); + if (flag) + strcpy (mode, "Pass"); + else + strcpy (mode, "Block"); + if (length == 0) + strcat (mode, " all"); + proto_tree_add_text(pt, *offset, 4, "Pass/Block flag: %s", mode); + proto_tree_add_text(pt, *offset+4, 4, "Length of Pattern & Mask: %d", length); + BUMP (*offset, *data, 8); + if (length) { + proto_tree_add_text(pt, *offset, length * 2, "discarded data", NULL); + BUMP (*offset, *data, length * 2); + } + padding = 3 - (length * 2 + 3) % 4; + if (padding) { + proto_tree_add_text(pt, *offset+1, 3, "padding", NULL); + BUMP (*offset, *data, padding); + } +} + +void +cmd_ioctl (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + unsigned int ioctl; + int i; + + ioctl = pntohl ((unsigned int *)(*data)); + for (i = 0; i < SIZEOF(ioctls); i++) { + if (ioctls[i].value == ioctl) + break; + } + if (i >= SIZEOF(ioctls)) + i = SIZEOF(ioctls) - 1; + proto_tree_add_text(pt, *offset, 4, "IOCTL: %s", ioctls[i].strptr); + BUMP (*offset, *data, 4); + proto_tree_add_text(pt, *offset, dataend - *data, "Data", NULL); + BUMP (*offset, *data, dataend - *data); +} + +void +cmd_addfilt (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + proto_item *item; + proto_tree *tree; + int blocks, i, length; + char *ptr; + char pass[] = ".... ...1 = Conforming messages are passed"; + char block[] = ".... ...0 = Conforming messages are blocked"; + char active[] = ".... ..1. = The filter is active"; + char inactive[] = ".... ..0. = The filter is inactive"; + + item = proto_tree_add_text(pt, *offset, 1, "Flags", NULL); + tree = proto_item_add_subtree (item, ett_gryphon_flags); + if (**data & FILTER_PASS_FLAG) + ptr = pass; + else + ptr = block; + proto_tree_add_text(tree, *offset, 1, ptr, NULL); + if (**data & FILTER_ACTIVE_FLAG) + ptr = active; + else + ptr = inactive; + proto_tree_add_text(tree, *offset, 1, ptr, NULL); + BUMP (*offset, *data, 1); + blocks = **data; + proto_tree_add_text(pt, *offset, 1, "Number of filter blocks = %d", blocks); + proto_tree_add_text(pt, *offset+1, 6, "reserved", NULL); + BUMP (*offset, *data, 7); + for (i = 1; i <= blocks; i++) { + length = pntohs ((unsigned short *)((*data)+2)) * 2 + 8; + length += 3 - (length + 3) % 4; + item = proto_tree_add_text(pt, *offset, length, "Filter block %d", i); + tree = proto_item_add_subtree (item, ett_gryphon_cmd_filter_block); + filter_block (src, data, dataend, offset, msglen, tree); + } +} + +void +resp_addfilt (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + proto_tree_add_text(pt, *offset, 1, "Filter handle: %hd", **data); + proto_tree_add_text(pt, *offset+1, 3, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +cmd_modfilt (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + unsigned char action; + int i; + + if (**data) + proto_tree_add_text(pt, *offset, 1, "Filter handle: %hd", **data); + else + proto_tree_add_text(pt, *offset, 1, "Filter handles: all", NULL); + action = *((*data) + 1); + for (i = 0; i < SIZEOF(filtacts); i++) { + if (filtacts[i].value == action) + break; + } + if (i >= SIZEOF(filtacts)) + i = SIZEOF(filtacts) - 1; + proto_tree_add_text(pt, *offset+1, 1, "Action: %s filter", filtacts[i].strptr); + proto_tree_add_text(pt, *offset+2, 2, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +resp_filthan (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + int handles = **data; + int i, padding; + + proto_tree_add_text(pt, *offset, 1, "Number of filter handles: %d", handles); + for (i = 1; i <= handles; i++){ + proto_tree_add_text(pt, *offset+i, 1, "Handle %d: %hd", i, *(*data+i)); + } + padding = 3 - (handles + 1 + 3) % 4; + if (padding) + proto_tree_add_text(pt, *offset+1+handles, padding, "padding", NULL); + BUMP (*offset, *data, 1+handles+padding); +} + +void +dfiltmode (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + int i; + unsigned char mode; + + mode = **data; + for (i = 0; i < SIZEOF(modes); i++) { + if (dmodes[i].value == mode) + break; + } + if (i >= SIZEOF(dmodes)) + i = SIZEOF(dmodes) - 1; + proto_tree_add_text(pt, *offset, 1, "Filter mode: %s", dmodes[i].strptr); + proto_tree_add_text(pt, *offset+1, 3, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +filtmode (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + int i; + unsigned char mode; + + mode = **data; + for (i = 0; i < SIZEOF(modes); i++) { + if (modes[i].value == mode) + break; + } + if (i >= SIZEOF(modes)) + i = SIZEOF(modes) - 1; + proto_tree_add_text(pt, *offset, 1, "Filter mode: %s", modes[i].strptr); + proto_tree_add_text(pt, *offset+1, 3, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +resp_events (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + int i; + proto_tree *tree; + proto_item *item; + + i = 1; + while (*data < dataend) { + item = proto_tree_add_text(pt, *offset, 20, "Event %d:", i); + tree = proto_item_add_subtree (item, ett_gryphon_cmd_events_data); + proto_tree_add_text(tree, *offset, 1, "Event ID: %hd", **data); + proto_tree_add_text(tree, *offset+1, 19, "Event name: %s", (*data)+1); + BUMP (*offset, *data, 20); + i++; + } +} + +void +cmd_register (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + char string[33]; + + MEMCPY (string, *data, 16); + proto_tree_add_text(pt, *offset, 16, "Username: %s", string); + BUMP (*offset, *data, 16); + MEMCPY (string, *data, 32); + proto_tree_add_text(pt, *offset, 32, "Password: %s", string); + BUMP (*offset, *data, 32); +} + +void +resp_register (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + + proto_tree_add_text(pt, *offset, 1, "Client ID: %hd", (*data)[0]); + proto_tree_add_text(pt, *offset+1, 1, "Privileges: %hd", (*data)[1]); + proto_tree_add_text(pt, *offset+2, 2, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +resp_config (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + proto_item *pi; + proto_tree *ft; + char string[33]; + int devices; + int i, j, x; + + static const value_string protocol_types[] = { + {GDUMMY * 256 + GDGDMARKONE, "Dummy device driver"}, + {GCAN * 256 + G82527, "CAN, 82527 subtype"}, + {GCAN * 256 + GSJA1000, "CAN, SJA1000 subtype"}, + {GCAN * 256 + G82527SW, "CAN, 82527 single wire subtype"}, + {GJ1850 * 256 + GHBCCPAIR, "J1850, HBCC subtype"}, + {GJ1850 * 256 + GDLC, "J1850, GM DLC subtype"}, + {GJ1850 * 256 + GCHRYSLER, "J1850, Chrysler subtype"}, + {GJ1850 * 256 + GDEHC12, "J1850, DE HC12 KWP/BDLC subtype"}, + {GKWP2000, "Keyword protocol 2000"}, + {GHONDA * 256 + GDGHC08, "Honda UART, DG HC08 subtype"}, + {GFORDUBP * 256 + GDGUBP08, "Ford UBP, DG HC08 subtype"}, + {-1, "- unknown -"}, + }; + + + + + MEMCPY (string, *data, 20); + proto_tree_add_text(pt, *offset, 20, "Device name: %s", string); + BUMP (*offset, *data, 20); + + MEMCPY (string, *data, 8); + proto_tree_add_text(pt, *offset, 8, "Device version: %s", string); + BUMP (*offset, *data, 8); + + MEMCPY (string, *data, 20); + proto_tree_add_text(pt, *offset, 20, "Device serial number: %s", string); + BUMP (*offset, *data, 20); + + devices = **data; + proto_tree_add_text(pt, *offset, 1, "Number of channels: %d", devices); + proto_tree_add_text(pt, *offset+1, 15, "reserved", NULL); + BUMP (*offset, *data, 16); + for (i = 1; i <= devices; i++) { + pi = proto_tree_add_text(pt, *offset, 80, "Channel %d:", i); + ft = proto_item_add_subtree(pi, ett_gryphon_cmd_config_device); + MEMCPY (string, *data, 20); + proto_tree_add_text(ft, *offset, 20, "Driver name: %s", string); + BUMP (*offset, *data, 20); + + MEMCPY (string, *data, 8); + proto_tree_add_text(ft, *offset, 8, "Driver version: %s", string); + BUMP (*offset, *data, 8); + + MEMCPY (string, *data, 24); + proto_tree_add_text(ft, *offset, 24, "device security string: %s", string); + BUMP (*offset, *data, 24); + + MEMCPY (string, *data, 20); + proto_tree_add_text(ft, *offset, 20, "Hardware serial number: %s", string); + BUMP (*offset, *data, 20); + + x = pntohs ((unsigned short *)*data); + for (j = 0; j < SIZEOF(protocol_types); j++) { + if (protocol_types[j].value == x) + break; + } + if (j >= SIZEOF(protocol_types)) + j = SIZEOF(protocol_types) -1; + proto_tree_add_text(ft, *offset, 2, "Protocol type & subtype: %s", protocol_types[j].strptr); + BUMP (*offset, *data, 2); + + proto_tree_add_text(ft, *offset, 1, "Channel ID: %hd", **data); + proto_tree_add_text(ft, *offset+1, 5, "reserved", NULL); + BUMP (*offset, *data, 6); + } +} + +void +cmd_sched (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + proto_item *item, *item1; + proto_tree *tree, *tree1; + unsigned int i, x, length; + unsigned char def_chan = *((*data)-9); + char *ptr; + char crit[] = ".... ...1 = Critical scheduler"; + char norm[] = ".... ...0 = Normal scheduler"; + + x = pntohl ((unsigned int *)*data); + if (x == 0xFFFFFFFF) + proto_tree_add_text(pt, *offset, 4, "Number of iterations: infinite", NULL); + else + proto_tree_add_text(pt, *offset, 4, "Number of iterations: %d", x); + BUMP (*offset, *data, 4); + x = pntohl ((unsigned int *)*data); + item = proto_tree_add_text(pt, *offset, 4, "Flags", NULL); + tree = proto_item_add_subtree (item, ett_gryphon_flags); + ptr = x & 1 ? crit : norm; + proto_tree_add_text(tree, *offset, 4, ptr, NULL); + BUMP (*offset, *data, 4); + i = 1; + while (*data < dataend) { + length = 16 + (*data)[16] + pntohs ((unsigned short *)((*data)+18)) + (*data)[20] + 16; + length += 3 - (length + 3) % 4; + item = proto_tree_add_text(pt, *offset, length, "Message %d", i); + tree = proto_item_add_subtree (item, ett_gryphon_cmd_sched_data); + x = pntohl ((unsigned int *)*data); + proto_tree_add_text(tree, *offset, 4, "Sleep: %d milliseconds", x); + BUMP (*offset, *data, 4); + x = pntohl ((unsigned int *)*data); + proto_tree_add_text(tree, *offset, 4, "Transmit count: %d", x); + BUMP (*offset, *data, 4); + x = pntohl ((unsigned int *)*data); + proto_tree_add_text(tree, *offset, 4, "Transmit period: %d milliseconds", x); + BUMP (*offset, *data, 4); + proto_tree_add_text(tree, *offset, 2, "reserved flags", NULL); + x = *((*data)+2); + if (x == 0) + x = def_chan; + proto_tree_add_text(tree, *offset+2, 1, "Channel: %d", x); + proto_tree_add_text(tree, *offset+3, 1, "reserved", NULL); + BUMP (*offset, *data, 4); + item1 = proto_tree_add_text(tree, *offset, length, "Message", NULL); + tree1 = proto_item_add_subtree (item1, ett_gryphon_cmd_sched_cmd); + decode_data (src, data, dataend, offset, msglen, tree1); + i++; + } +} + +void +resp_blm_data (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + int hours, minutes, seconds, fraction, i, x, fract; + unsigned long timestamp; + char *fields[] = { + "Bus load average: %d.%02d%%", + "Current bus load: %d.%02d%%", + "Peak bus load: %d.%02d%%", + "Historic peak bus load: %d.%02d%%" + }; + + timestamp = pntohl ((unsigned long *)(*data)); + hours = timestamp /(100000 * 60 *60); + minutes = (timestamp / (100000 * 60)) % 60; + seconds = (timestamp / 100000) % 60; + fraction = timestamp % 100000; + proto_tree_add_text(pt, *offset, 4, "Timestamp: %d:%02d:%02d.%05d", hours, minutes, seconds, fraction); + BUMP (*offset, *data, 4); + for (i = 0; i < SIZEOF(fields); i++){ + x = pntohs ((unsigned short *)(*data)); + fract = x % 100; + x /= 100; + proto_tree_add_text(pt, *offset, 2, fields[i], x, fract); + BUMP (*offset, *data, 2); + } +} + +void +resp_blm_stat (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + unsigned int x, i; + char *fields[] = { + "Receive frame count: %d", + "Transmit frame count: %d", + "Receive dropped frame count: %d", + "Transmit dropped frame count: %d", + "Receive error count: %d", + "Transmit error count: %d", + }; + + resp_blm_data (src, data, dataend, offset, msglen, pt); + for (i = 0; i < SIZEOF(fields); i++){ + x = pntohl ((unsigned int *)(*data)); + proto_tree_add_text(pt, *offset, 4, fields[i], x); + BUMP (*offset, *data, 4); + } +} + +void +cmd_addresp (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + proto_item *item; + proto_tree *tree; + int blocks, responses, old_handle, i, length; + int action, actionType, actionValue; + char *ptr; + char active[] = ".... ..1. = The response is active"; + char inactive[] = ".... ..0. = The response is inactive"; + + actionType = 0; + item = proto_tree_add_text(pt, *offset, 1, "Flags", NULL); + tree = proto_item_add_subtree (item, ett_gryphon_flags); + if (**data & FILTER_ACTIVE_FLAG) + ptr = active; + else + ptr = inactive; + proto_tree_add_text(tree, *offset, 1, ptr, NULL); + BUMP (*offset, *data, 1); + blocks = **data; + proto_tree_add_text(pt, *offset, 1, "Number of filter blocks = %d", blocks); + BUMP (*offset, *data, 1); + responses = **data; + proto_tree_add_text(pt, *offset, 1, "Number of response blocks = %d", responses); + BUMP (*offset, *data, 1); + old_handle = **data; + proto_tree_add_text(pt, *offset, 1, "Old handle = %d", old_handle); + BUMP (*offset, *data, 1); + action = **data; + switch (action & 7) { + case FR_RESP_AFTER_EVENT: + ptr = "Send response(s) for each conforming message"; + break; + case FR_RESP_AFTER_PERIOD: + ptr = "Send response(s) after the specified period expires following a conforming message"; + break; + case FR_IGNORE_DURING_PER: + ptr = "Send response(s) for a conforming message and ignore\nfurther messages until the specified period expires"; + break; + default: + ptr = "- unknown -"; + } + item = proto_tree_add_text(pt, *offset, 1, "Action = %s", ptr); + tree = proto_item_add_subtree (item, ett_gryphon_flags); + if (action & FR_DEACT_AFTER_PER && !(action & FR_DELETE)){ + proto_tree_add_text(tree, *offset, 1, + "1.0. .... Deactivate this response after the specified period following a conforming message", NULL); + } + if (action & FR_DEACT_ON_EVENT && !(action & FR_DELETE)){ + proto_tree_add_text(tree, *offset, 1, + ".10. .... Deactivate this response for a conforming message", NULL); + } + if (action & FR_DEACT_AFTER_PER && action & FR_DELETE){ + proto_tree_add_text(tree, *offset, 1, + "1.1. .... Delete this response after the specified period following a conforming message", NULL); + } + if (action & FR_DEACT_ON_EVENT && action & FR_DELETE){ + proto_tree_add_text(tree, *offset, 1, + ".11. .... Delete this response for a conforming message", NULL); + } + actionValue = pntohs ((unsigned short *)((*data)+2)); + if (actionValue) { + if (action & FR_PERIOD_MSGS){ + ptr = "...1 .... The period is in frames"; + actionType = 1; + } else { + ptr = "...0 .... The period is in 0.01 seconds"; + actionType = 0; + } + proto_tree_add_text(tree, *offset, 1, ptr, NULL); + } + BUMP (*offset, *data, 1); + proto_tree_add_text(pt, *offset, 1, "reserved", NULL); + BUMP (*offset, *data, 1); + if (actionValue) { + if (actionType == 1) { + proto_tree_add_text(tree, *offset, 2, "Period: %d messages", actionValue); + } else { + proto_tree_add_text(tree, *offset, 2, "Period: %d.%02d seconds", actionValue/100, actionValue%100); + } + } + BUMP (*offset, *data, 2); + for (i = 1; i <= blocks; i++) { + length = pntohs ((unsigned short *)((*data)+2)) * 2 + 8; + length += 3 - (length + 3) % 4; + item = proto_tree_add_text(pt, *offset, length, "Filter block %d", i); + tree = proto_item_add_subtree (item, ett_gryphon_cmd_filter_block); + filter_block (src, data, dataend, offset, msglen, tree); + } + for (i = 1; i <= responses; i++) { + length = pntohs ((unsigned short *)((*data)+4)) + 8; + length += 3 - (length + 3) % 4; + item = proto_tree_add_text(pt, *offset, length, "Response block %d", i); + tree = proto_item_add_subtree (item, ett_gryphon_cmd_response_block); + dissector((*data)-*offset, *offset, NULL, tree); + BUMP (*offset, *data, length); + } +} + +void +resp_addresp (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + if (*data < dataend) { + proto_tree_add_text(pt, *offset, 1, "Response handle: %hd", **data); + proto_tree_add_text(pt, *offset+1, 3, "reserved", NULL); + BUMP (*offset, *data, 4); + } +} + +void +cmd_modresp (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + unsigned char action; + unsigned char dest = *((*data)-5); + int i; + + if (**data) + proto_tree_add_text(pt, *offset, 1, "Response handle: %hd", **data); + else if (dest) + proto_tree_add_text(pt, *offset, 1, "Response handles: all on channel %hd", dest); + else + proto_tree_add_text(pt, *offset, 1, "Response handles: all", NULL); + action = *((*data) + 1); + for (i = 0; i < SIZEOF(filtacts); i++) { + if (filtacts[i].value == action) + break; + } + if (i >= SIZEOF(filtacts)) + i = SIZEOF(filtacts) - 1; + proto_tree_add_text(pt, *offset+1, 1, "Action: %s response", filtacts[i].strptr); + proto_tree_add_text(pt, *offset+2, 2, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +resp_resphan (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + int handles = **data; + int i, padding; + + proto_tree_add_text(pt, *offset, 1, "Number of response handles: %d", handles); + for (i = 1; i <= handles; i++){ + proto_tree_add_text(pt, *offset+i, 1, "Handle %d: %hd", i, *(*data+i)); + } + padding = 3 - (handles + 1 + 3) % 4; + if (padding) + proto_tree_add_text(pt, *offset+1+handles, padding, "padding", NULL); + BUMP (*offset, *data, 1+handles+padding); +} + +void +resp_sched (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + unsigned int id = pntohl ((unsigned int *)(*data)); + proto_tree_add_text(pt, *offset, 4, "Transmit schedule ID: %d", id); + BUMP (*offset, *data, 4); +} + +void +cmd_desc (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + u_char string[81]; + + proto_tree_add_text(pt, *offset, 4, "Program size: %d bytes", pntohl ((unsigned int *)(*data))); + BUMP (*offset, *data, 4); + strncpy (string, *data, 32); + string[32] = 0; + proto_tree_add_text(pt, *offset, 32, "Program name: %s", string); + BUMP (*offset, *data, 32); + strncpy (string, *data, 80); + string[80] = 0; + proto_tree_add_text(pt, *offset, 80, "Program description: %s", string); + BUMP (*offset, *data, 80); +} + +void +resp_desc (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) +{ + proto_item *item; + proto_tree *tree; + char *ptr; + char missing[] = ".... ...0 = The program is not present"; + char present[] = ".... ...1 = The program is already present"; + + item = proto_tree_add_text(pt, *offset, 1, "Flags", NULL); + tree = proto_item_add_subtree (item, ett_gryphon_flags); + if (**data & 1) + ptr = present; + else + ptr = missing; + proto_tree_add_text(tree, *offset, 1, ptr, NULL); + proto_tree_add_text(pt, *offset+1, 1, "Handle: %hd", (*data)[1]); + proto_tree_add_text(pt, *offset+2, 2, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +cmd_upload (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + unsigned int length; + + proto_tree_add_text(pt, *offset, 2, "Block number: %d", pntohs ((unsigned short *)(*data))); + BUMP (*offset, *data, 4); + proto_tree_add_text(pt, *offset+2, 1, "Handle: %hd", (*data)[2]); + BUMP (*offset, *data, 3); + length = *data - dataend; + proto_tree_add_text(pt, *offset, length, "Data (%d bytes)", length); + BUMP (*offset, *data, length); + length = 3 - (length + 3) % 4; + if (length) { + proto_tree_add_text(pt, *offset, length, "padding", NULL); + BUMP (*offset, *data, length); + } +} + +void +cmd_delete (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + u_char string[33]; + + strncpy (string, *data, 32); + string[32] = 0; + proto_tree_add_text(pt, *offset, 32, "Program name: %s", string); + BUMP (*offset, *data, 32); +} + +void +cmd_list (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + + proto_tree_add_text(pt, *offset, 1, "Block number: %hd", (*data)[0]); + proto_tree_add_text(pt, *offset+1, 3, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +resp_list (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + proto_item *item; + proto_tree *tree; + u_char string[81]; + unsigned int i, count; + + count = (*data)[0]; + proto_tree_add_text(pt, *offset, 1, "Number of programs in this response: %d", count); + proto_tree_add_text(pt, *offset+1, 1, "reserved", NULL); + BUMP (*offset, *data, 2); + proto_tree_add_text(pt, *offset, 2, "Number of remaining programs: %d", pntohs ((unsigned short *)(*data))); + BUMP (*offset, *data, 2); + for (i = 1; i <= count; i++) { + item = proto_tree_add_text(pt, *offset, 112, "Program %d", i); + tree = proto_item_add_subtree (item, ett_gryphon_pgm_list); + strncpy (string, *data, 32); + string[32] = 0; + proto_tree_add_text(tree, *offset, 32, "Name: %s", string); + BUMP (*offset, *data, 32); + strncpy (string, *data, 80); + string[80] = 0; + proto_tree_add_text(tree, *offset, 80, "Description: %s", string); + BUMP (*offset, *data, 80); + } +} + +void +cmd_start (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + u_char string[120]; + unsigned int length; + + cmd_delete (src, data, dataend, offset, msglen, pt); + strncpy (string, *data, 119); + string[119] = 0; + length = strlen (string) + 1; + proto_tree_add_text(pt, *offset, length, "Arguments: %s", string); + BUMP (*offset, *data, length); + length = 3 - (length + 3) % 4; + if (length) { + proto_tree_add_text(pt, *offset, length, "padding", NULL); + BUMP (*offset, *data, length); + } +} + +void +resp_start (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + + proto_tree_add_text(pt, *offset, 1, "Channel (Client) number: %hd", (*data)[0]); + proto_tree_add_text(pt, *offset+1, 3, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +resp_status (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + proto_item *item; + proto_tree *tree; + unsigned int i, copies, length; + + copies = (*data)[0]; + item = proto_tree_add_text(pt, *offset, 1, "Number of running copies: %d", copies); + tree = proto_item_add_subtree (item, ett_gryphon_pgm_status); + BUMP (*offset, *data, 1); + if (copies) { + for (i = 1; i <= copies; i++) { + proto_tree_add_text(tree, *offset, 1, "Program %d channel (client) number %hd", i, (*data)[0]); + BUMP (*offset, *data, 1); + } + } + length = 3 - (copies + 1 + 3) % 4; + if (length) { + proto_tree_add_text(pt, *offset, length, "padding", NULL); + BUMP (*offset, *data, length); + } +} + +void +cmd_options (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + proto_item *item; + proto_tree *tree; + unsigned int i, size, padding, option, option_length, option_value; + unsigned char *string, *string1; + + item = proto_tree_add_text(pt, *offset, 1, "Handle: %hd", **data); + item = proto_tree_add_text(pt, *offset+1, 3, "reserved", NULL); + BUMP (*offset, *data, 4); + for (i = 1; *data <= dataend; i++) { + size = (*data)[1] + 2; + padding = 3 - ((size + 3) %4); + item = proto_tree_add_text(pt, *offset, size + padding, "Option number %d", i); + tree = proto_item_add_subtree (item, ett_gryphon_pgm_options); + option = **data; + option_length = (*data)[1]; + switch (option_length) { + case 1: + option_value = (*data)[2]; + break; + case 2: + option_value = pntohs ((unsigned short *)((*data)+2)); + break; + case 4: + option_value = pntohl ((unsigned int *)((*data)+2)); + break; + default: + option_value = 0; + } + string = "unknown option"; + string1 = "unknown option data"; + switch (option) { + case PGM_CONV: + string = "Type of data in the file"; + switch (option_value) { + case PGM_BIN: + string1 = "Binary - Don't modify"; + break; + case PGM_ASCII: + string1 = "ASCII - Remove CR's"; + break; + } + break; + case PGM_TYPE: + string = "Type of file"; + switch (option_value) { + case PGM_PGM: + string1 = "Executable"; + break; + case PGM_DATA: + string1 = "Data"; + break; + } + break; + } + proto_tree_add_text(tree, *offset, 1, "%s", string); + proto_tree_add_text(tree, *offset+2, option_length, "%s", string1); + if (padding) + proto_tree_add_text(tree, *offset+option_length+2, padding, "padding", NULL); + BUMP (*offset, *data, size + padding); + } +} + +void +speed (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + + proto_tree_add_text(pt, *offset, 1, "Baud rate index: %hd", (*data)[0]); + proto_tree_add_text(pt, *offset+1, 3, "reserved", NULL); + BUMP (*offset, *data, 4); +} + +void +filter_block (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + int length, type, i, operator, padding; + + proto_tree_add_text(pt, *offset, 2, "Filter field starts at byte %d", pntohs ((unsigned short *)(*data))); + length = pntohs ((unsigned short *)((*data)+2)); + proto_tree_add_text(pt, *offset+2, 2, "Filter field is %d bytes long", length); + type = *((*data)+4); + for (i = 0; i < SIZEOF(filter_data_types); i++) { + if (filter_data_types[i].value == type) + break; + } + if (i >= SIZEOF(filter_data_types)) + i = SIZEOF(filter_data_types) - 1; + proto_tree_add_text(pt, *offset+4, 1, "Filtering on %s", filter_data_types[i].strptr); + + operator = *((*data)+5); + for (i = 0; i < SIZEOF(operators); i++) { + if (operators[i].value == operator) + break; + } + if (i >= SIZEOF(operators)) + i = SIZEOF(operators) - 1; + proto_tree_add_text(pt, *offset+5, 1, "Type of comparison: %s", operators[i].strptr); + proto_tree_add_text(pt, *offset+6, 2, "reserved" ,NULL); + BUMP (*offset, *data, 8); + + if (operator == BIT_FIELD_CHECK) { + proto_tree_add_text(pt, *offset, length, "Pattern" ,NULL); + proto_tree_add_text(pt, *offset+length, length, "Mask" ,NULL); + } else { + switch (length) { + case 1: + proto_tree_add_text(pt, *offset, 1, "Value: %hd", **data); + break; + case 2: + proto_tree_add_text(pt, *offset, 2, "Value: %d", pntohs ((unsigned short *)(*data))); + break; + case 4: + proto_tree_add_text(pt, *offset, 4, "Value: %dl", pntohl ((unsigned long *)(*data))); + break; + default: + proto_tree_add_text(pt, *offset, length, "Value", NULL); + } + } + BUMP (*offset, *data, length * 2); + padding = 3 - (length * 2 + 3) % 4; + if (padding) { + proto_tree_add_text(pt, *offset, padding, "padding", NULL); + BUMP (*offset, *data, padding); + } +} + +void +blm_mode (int src, const u_char **data, const u_char *dataend, int *offset, int msglen, proto_tree *pt) { + + char *mode, line[50]; + int x, y, seconds; + + x = pntohl ((unsigned long *)(*data)); + y = pntohl ((unsigned long *)((*data)+4)); + switch (x) { + case 0: + mode = "Off"; + sprintf (line, "reserved"); + break; + case 1: + mode = "Average over time"; + seconds = y / 1000; + y = y % 1000; + sprintf (line, "Averaging period: %d.%03d seconds", seconds, y); + break; + case 2: + mode = "Average over frame count"; + sprintf (line, "Averaging period: %d frames", y); + break; + default: + mode = "- unknown -"; + sprintf (line, "reserved"); + } + proto_tree_add_text(pt, *offset, 4, "Mode: %s", mode); + BUMP (*offset, *data, 4); + proto_tree_add_text(pt, *offset, 4, line, NULL); + BUMP (*offset, *data, 4); +} + +void +proto_init(void) +{ + static hf_register_info hf[] = { + { &hf_gryph_src, + { "Source", "gryph.src", FT_UINT8, BASE_DEC, NULL, 0x0, + "" }}, + { &hf_gryph_srcchan, + { "Source channel", "gryph.srcchan", FT_UINT8, BASE_DEC, NULL, 0x0, + "" }}, + { &hf_gryph_dest, + { "Destination", "gryph.dest", FT_UINT8, BASE_DEC, NULL, 0x0, + "" }}, + { &hf_gryph_destchan, + { "Destination channel", "gryph.dstchan", FT_UINT8, BASE_DEC, NULL, 0x0, + "" }}, + { &hf_gryph_type, + { "Frame type", "gryph.type", FT_UINT8, BASE_DEC, NULL, 0x0, + "" }}, + { &hf_gryph_cmd, + { "Command", "gryph.cmd.cmd", FT_UINT8, BASE_DEC, NULL, 0x0, + "" }}, + }; + + static gint *ett[] = { + &ett_gryphon, + &ett_gryphon_header, + &ett_gryphon_body, + &ett_gryphon_command_data, + &ett_gryphon_response_data, + &ett_gryphon_data_header, + &ett_gryphon_flags, + &ett_gryphon_data_body, + &ett_gryphon_cmd_filter_block, + &ett_gryphon_cmd_events_data, + &ett_gryphon_cmd_config_device, + &ett_gryphon_cmd_sched_data, + &ett_gryphon_cmd_sched_cmd, + &ett_gryphon_cmd_response_block, + &ett_gryphon_pgm_list, + &ett_gryphon_pgm_status, + &ett_gryphon_pgm_options, + }; + + dfilter_cleanup(); + proto_gryphon = proto_register_protocol("DG Gryphon Protocol", "gryphon"); + proto_register_field_array(proto_gryphon, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + dfilter_init(); +} diff --git a/plugins/gryphon/packet-gryphon.h b/plugins/gryphon/packet-gryphon.h new file mode 100644 index 0000000000..4e15bc77d2 --- /dev/null +++ b/plugins/gryphon/packet-gryphon.h @@ -0,0 +1,398 @@ +/* packet-gryphon.c + * Definitions for Gryphon packet disassembly structures and routines + * + * $Id: packet-gryphon.h,v 1.1 1999/12/15 06:53:36 gram Exp $ + * + * Ethereal - Network traffic analyzer + * By Steve Limkemann <stevelim@dgtech.com> + * Copyright 1998 Steve Limkemann + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * + */ + +#define MSG_HDR_SZ 8 + +/* source/destinations: */ + +#define SD_CARD 0x01 /* (vehicle) network interface */ +#define SD_SERVER 0x02 +#define SD_CLIENT 0x03 +#define SD_KNOWN 0x10 /* Client ID >= are well known */ +#define SD_SCHED 0x10 /* scheduler */ +#define SD_SCRIPT 0x20 /* script processor */ +#define SD_PGM 0x21 /* Program loader */ +#define SD_USDT 0x22 /* USDT (Unacknowledged Segmented Data Transfer) */ +#define SD_BLM 0x23 /* Bus Load Monitoring */ +#define SD_FLIGHT 0x25 /* Flight Recorder */ +#define SD_RESP 0x26 /* Message Response */ + + + +/* frame types: */ +#define GY_FT_CMD 0x01 /* command to initiate some action */ +#define GY_FT_RESP 0x02 /* response to a command */ +#define GY_FT_DATA 0x03 /* (vehicle) network data */ +#define GY_FT_EVENT 0x04 /* notification of an event */ +#define GY_FT_MISC 0x05 /* misc data */ +#define GY_FT_TEXT 0x06 /* null-terminated ASCII strings */ + + + +/* generic (all SD type) commands: values 0x00 to 0x3f */ + +#define CMD_INIT 0x01 /* initialize target */ +#define CMD_GET_STAT 0x02 /* request status */ +#define CMD_GET_CONFIG 0x03 /* request configuration info */ +#define CMD_EVENT_ENABLE 0x04 /* Enable event type */ +#define CMD_EVENT_DISABLE 0x05 /* Disable event type */ +#define CMD_GET_TIME 0x06 /* Get current value of timestamp */ +#define CMD_GET_RXDROP 0x07 /* Get count of Rx msgs dropped */ +#define CMD_RESET_RXDROP 0x08 /* Set count of Rx msgs dropped to zero */ +#define CMD_BCAST_ON 0x09 /* broadcasts on */ +#define CMD_BCAST_OFF 0x0a /* broadcasts off */ + +/* SD-type specific commands: should start at 0x40, global uniqueness */ +/* is prefered, but not mandatory. */ + +/* SD_CARD command types: */ + +#define CMD_CARD_SET_SPEED (SD_CARD * 256 + 0x40) /* set peripheral speed */ +#define CMD_CARD_GET_SPEED (SD_CARD * 256 + 0x41) /* get peripheral speed */ +#define CMD_CARD_SET_FILTER (SD_CARD * 256 + 0x42) /* set filter to pass or block all */ +#define CMD_CARD_GET_FILTER (SD_CARD * 256 + 0x43) /* get a pass/block filter */ +#define CMD_CARD_TX (SD_CARD * 256 + 0x44) /* transmit message */ +#define CMD_CARD_TX_LOOP_ON (SD_CARD * 256 + 0x45) /* set transmit loopback on */ +#define CMD_CARD_TX_LOOP_OFF (SD_CARD * 256 + 0x46) /* set transmit loopback off */ +#define CMD_CARD_IOCTL (SD_CARD * 256 + 0x47) /* device driver ioctl pass-through */ +#define CMD_CARD_ADD_FILTER (SD_CARD * 256 + 0x48) /* add a pass/block filter */ +#define CMD_CARD_MODIFY_FILTER (SD_CARD * 256 + 0x49) /* modify a pass/block filter */ +#define CMD_CARD_GET_FILTER_HANDLES (SD_CARD * 256 + 0x4A)/* get a list of filters */ +#define CMD_CARD_SET_DEFAULT_FILTER (SD_CARD * 256 + 0x4B)/* set the default action */ +#define CMD_CARD_GET_DEFAULT_FILTER (SD_CARD * 256 + 0x4C)/* get the defautl action */ +#define CMD_CARD_SET_FILTER_MODE (SD_CARD * 256 + 0x4D) /* set the client data mode */ +#define CMD_CARD_GET_FILTER_MODE (SD_CARD * 256 + 0x4E) /* get the client data mode */ +#define CMD_CARD_GET_EVNAMES (SD_CARD * 256 + 0x4f) /* get event names */ +#define CMD_CARD_GET_SPEEDS (SD_CARD * 256 + 0x50) /* get speed definitions */ + +/* SD_SERVER command types: */ + +#define CMD_SERVER_REG (SD_SERVER * 256 + 0x50) /* register connection */ + +/* SD_CLIENT command types: */ + +#define CMD_CLIENT_GET_ID (SD_CLIENT * 256 + 0x60) /* get the ID (channel field) of this client? */ +#define CMD_CLIENT_SET_ID (SD_CLIENT * 256 + 0x61) /* set the ID (channel field) of this client? */ +#define CMD_CLIENT_SHUTDOWN (SD_CLIENT * 256 + 0x62) /* tell client to die ? */ + +/* Bus load monitor (SD_BLM) commands: */ + +#define CMD_BLM_SET_MODE (SD_BLM * 256 + 0xA0) +#define CMD_BLM_GET_MODE (SD_BLM * 256 + 0xA1) +#define CMD_BLM_GET_DATA (SD_BLM * 256 + 0xA2) +#define CMD_BLM_GET_STATS (SD_BLM * 256 + 0xA3) + +/* Flight recorder (SD_FLIGHT) commands */ + +#define CMD_FLIGHT_GET_CONFIG (SD_FLIGHT * 256 + 0x50) /* get flight recorder channel info */ +#define CMD_FLIGHT_START_MON (SD_FLIGHT * 256 + 0x51) /* start flight recorder monitoring */ +#define CMD_FLIGHT_STOP_MON (SD_FLIGHT * 256 + 0x52) /* stop flight recorder monitoring */ + +/* Message responder (SD_RESP) commands: */ +#define CMD_MSGRESP_ADD (SD_RESP * 256 + 0xB0) +#define CMD_MSGRESP_GET (SD_RESP * 256 + 0xB1) +#define CMD_MSGRESP_MODIFY (SD_RESP * 256 + 0xB2) +#define CMD_MSGRESP_GET_HANDLES (SD_RESP * 256 + 0xB3) + +/* Program loader (SD_PGM) commands: */ + +#define CMD_PGM_DESC (SD_PGM * 256 + 0x90) /* Describe a program to to uploaded */ +#define CMD_PGM_UPLOAD (SD_PGM * 256 + 0x91) /* Upload a program to the Gryphon */ +#define CMD_PGM_DELETE (SD_PGM * 256 + 0x92) /* Delete an uploaded program */ +#define CMD_PGM_LIST (SD_PGM * 256 + 0x93) /* Get a list of uploaded programs */ +#define CMD_PGM_START (SD_PGM * 256 + 0x94) /* Start an uploaded program */ +#define CMD_PGM_STOP (SD_PGM * 256 + 0x95) /* Stop an uploaded program */ +#define CMD_PGM_STATUS (SD_PGM * 256 + 0x96) /* Get the status of an uploaded program */ +#define CMD_PGM_OPTIONS (SD_PGM * 256 + 0x97) /* Set the upload options */ + +/* Scheduler (SD_SCHED) target commands: */ + +#define CMD_SCHED_TX (SD_SCHED * 256 + 0x70) /* schedule transmission list */ +#define CMD_SCHED_KILL_TX (SD_SCHED * 256 + 0x71) /* stop and destroy job */ +#define CMD_SCHED_STOP_TX (SD_SCHED * 256 + 0x71) /* deprecated */ + +/* response frame (FT_RESP) response field definitions: */ + +#define RESP_OK 0x00 /* no error */ +#define RESP_UNKNOWN_ERR 0x01 /* unknown error */ +#define RESP_UNKNOWN_CMD 0x02 /* unrecognised command */ +#define RESP_UNSUPPORTED 0x03 /* unsupported command */ +#define RESP_INVAL_CHAN 0x04 /* invalid channel specified */ +#define RESP_INVAL_DST 0x05 /* invalid destination */ +#define RESP_INVAL_PARAM 0x06 /* invalid parameters */ +#define RESP_INVAL_MSG 0x07 /* invalid message */ +#define RESP_INVAL_LEN 0x08 /* invalid length field */ +#define RESP_TX_FAIL 0x09 /* transmit failed */ +#define RESP_RX_FAIL 0x0a /* receive failed */ +#define RESP_AUTH_FAIL 0x0b +#define RESP_MEM_ALLOC_ERR 0x0c /* memory allocation error */ +#define RESP_TIMEOUT 0x0d /* command timed out */ +#define RESP_UNAVAILABLE 0x0e +#define RESP_BUF_FULL 0x0f /* buffer full */ +#define RESP_NO_SUCH_JOB 0x10 + +/* Flight recorder (SD_FLIGHT) target definitions */ + +#define FR_RESP_AFTER_EVENT 0 +#define FR_RESP_AFTER_PERIOD 1 +#define FR_IGNORE_DURING_PER 2 +#define FR_DEACT_AFTER_PER 128 +#define FR_DEACT_ON_EVENT 64 +#define FR_DELETE 32 +#define FR_PERIOD_MSGS 16 + +/* Filter data types */ + +#define FILTER_DATA_TYPE_HEADER_FRAME 0x00 +#define FILTER_DATA_TYPE_HEADER 0x01 +#define FILTER_DATA_TYPE_DATA 0x02 +#define FILTER_DATA_TYPE_EXTRA_DATA 0x03 + +/* filter flags */ + +#define FILTER_PASS_FLAG 0x01 +#define FILTER_ACTIVE_FLAG 0x02 + +/* Filter and Frame Responder Condition operators */ + +#define BIT_FIELD_CHECK 0 +#define SVALUE_GT 1 +#define SVALUE_GE 2 +#define SVALUE_LT 3 +#define SVALUE_LE 4 +#define VALUE_EQ 5 +#define VALUE_NE 6 +#define UVALUE_GT 7 +#define UVALUE_GE 8 +#define UVALUE_LT 9 +#define UVALUE_LE 10 +#define DIG_LOW_TO_HIGH 11 +#define DIG_HIGH_TO_LOW 12 +#define DIG_TRANSITION 13 + +/* Modes available via CMD_CARD_SET_FILTERING_MODE */ +#define FILTER_OFF_PASS_ALL 3 +#define FILTER_OFF_BLOCK_ALL 4 +#define FILTER_ON 5 + +/* Modes available via CMD_CARD_SET_DEFAULT_FILTER */ +#define DEFAULT_FILTER_BLOCK 0 +#define DEFAULT_FILTER_PASS 1 + +/* Actions available via CMD_CARD_MODIFY_FILTER */ +#define DELETE_FILTER 0 +#define ACTIVATE_FILTER 1 +#define DEACTIVATE_FILTER 2 + +/* Program loader options */ +#define PGM_CONV 1 /* Type of data conversion to perform */ +#define PGM_TYPE 2 /* Type of file */ +#define PGM_BIN 11 /* Binary, no conversion */ +#define PGM_ASCII 12 /* ASCII, convert CR LF to LF */ +#define PGM_PGM 21 /* Executable */ +#define PGM_DATA 22 /* Data */ + + + + +/* IOCTL definitions - comments indicate data size */ + +#define GINIT 0x11100001 +#define GLOOPON 0x11100002 +#define GLOOPOFF 0x11100003 +#define GGETHWTYPE 0x11100004 +#define GGETREG 0x11100005 +#define GSETREG 0x11100006 +#define GGETRXCOUNT 0x11100007 +#define GSETRXCOUNT 0x11100008 +#define GGETTXCOUNT 0x11100009 +#define GSETTXCOUNT 0x1110000a +#define GGETRXDROP 0x1110000b +#define GSETRXDROP 0x1110000c +#define GGETTXDROP 0x1110000d +#define GSETTXDROP 0x1110000e +#define GGETRXBAD 0x1110000f +#define GGETTXBAD 0x11100011 +#define GGETCOUNTS 0x11100013 +#define GGETBLMON 0x11100014 +#define GSETBLMON 0x11100015 +#define GGETERRLEV 0x11100016 +#define GSETERRLEV 0x11100017 +#define GGETBITRATE 0x11100018 +#define GGETRAM 0x11100019 +#define GSETRAM 0x1110001a + +#define GCANGETBTRS 0x11200001 +#define GCANSETBTRS 0x11200002 +#define GCANGETBC 0x11200003 +#define GCANSETBC 0x11200004 +#define GCANGETMODE 0x11200005 +#define GCANSETMODE 0x11200006 +#define GCANGETTRANS 0x11200009 +#define GCANSETTRANS 0x1120000a +#define GCANSENDERR 0x1120000b +#define GCANRGETOBJ 0x11210001 +#define GCANRSETSTDID 0x11210002 +#define GCANRSETEXTID 0x11210003 +#define GCANRSETDATA 0x11210004 +#define GCANRENABLE 0x11210005 +#define GCANRDISABLE 0x11210006 +#define GCANRGETMASKS 0x11210007 +#define GCANRSETMASKS 0x11210008 +#define GCANSWGETMODE 0x11220001 +#define GCANSWSETMODE 0x11220002 + +#define GDLCGETFOURX 0x11400001 +#define GDLCSETFOURX 0x11400002 +#define GDLCGETLOAD 0x11400003 +#define GDLCSETLOAD 0x11400004 +#define GDLCSENDBREAK 0x11400005 +#define GDLCABORTTX 0x11400006 +#define GDLCGETHDRMODE 0x11400007 +#define GDLCSETHDRMODE 0x11400008 + +#define GHONSLEEP 0x11600001 +#define GHONSILENCE 0x11600002 + +#define GKWPSETPTIMES 0x11700011 +#define GKWPSETWTIMES 0x11700010 +#define GKWPDOWAKEUP 0x11700008 +#define GKWPGETBITTIME 0x11700101 +#define GKWPSETBITTIME 0x11700102 +#define GKWPSETNODEADDR 0x11700104 +#define GKWPGETNODETYPE 0x11700105 +#define GKWPSETNODETYPE 0x11700106 +#define GKWPSETWAKETYPE 0x11700108 +#define GKWPSETTARGADDR 0x1170010a +#define GKWPSETKEYBYTES 0x1170010c +#define GKWPSETSTARTREQ 0x1170010e +#define GKWPSETSTARTRESP 0x11700110 +#define GKWPSETPROTOCOL 0x11700112 +#define GKWPGETLASTKEYBYTES 0x11700201 +#define GKWPSETLASTKEYBYTES 0x11700202 + +#define GSCPGETBBR 0x11300001 +#define GSCPSETBBR 0x11300002 +#define GSCPGETID 0x11300003 +#define GSCPSETID 0x11300004 +#define GSCPADDFUNCID 0x11300005 +#define GSCPCLRFUNCID 0x11300006 + +#define GUBPGETBITRATE 0x11800001 +#define GUBPSETBITRATE 0x11800002 +#define GUBPGETINTERBYTE 0x11800003 +#define GUBPSETINTERBYTE 0x11800004 +#define GUBPGETNACKMODE 0x11800005 +#define GUBPSETNACKMODE 0x11800006 + + + + +/* Hardware / driver TYPE and SUBTYPE definitions */ + +#define GDUMMY 0x01 /* Dummy device driver TYPE */ +#define GDGDMARKONE 0x01 /* Dummy device driver SUBTYPE */ + +#define GCAN 0x02 /* CAN TYPE */ +#define G82527 0x01 /* 82527 SUBTYPE */ +#define GSJA1000 0x02 /* SJA1000 SUBTYPE */ +#define G82527SW 0x03 /* 82527 single wire subtype */ + +#define GJ1850 0x03 /* 1850 TYPE */ +#define GHBCCPAIR 0x01 /* HBCC SUBTYPE */ +#define GDLC 0x02 /* GM DLC SUBTYPE */ +#define GCHRYSLER 0x03 /* Chrysler SUBTYPE */ +#define GDEHC12 0x04 /* DE HC12 KWP/BDLC SUBTYPE */ + +#define GKWP2000 0x04 /* Keyword protocol 2000 TYPE */ + +#define GHONDA 0x05 /* Honda UART TYPE */ +#define GDGHC08 0x01 /* DG HC08 SUBTYPE */ + +#define GFORDUBP 0x06 /* FORD UBP TYPE */ +#define GDGUBP08 0x01 /* DG HC08 SUBTYPE */ + + +#define SIZEOF(x) (sizeof(x)/sizeof(x[0])) + +#define MEMCPY(dest, src, size) \ + memcpy (dest, src, size); \ + *((dest)+size) = 0; + +#define BUMP(ptr1, ptr2, size) \ + ptr1 += size; \ + ptr2 += size; + + + +typedef struct val_str_dsp { + int value; + char *strptr; + void (*cmd_fnct) (int, const u_char**, const u_char*, int*, int, proto_tree*); + void (*rsp_fnct) (int, const u_char**, const u_char*, int*, int, proto_tree*); +} val_str_dsp; + +void decode_command (int, const u_char**, const u_char*, int*, int, proto_tree*); +void decode_response (int, const u_char**, const u_char*, int*, int, proto_tree*); +void decode_data (int, const u_char**, const u_char*, int*, int, proto_tree*); +void decode_event (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_init (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_time (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_setfilt (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_ioctl (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_addfilt (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_addfilt (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_modfilt (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_filthan (int, const u_char**, const u_char*, int*, int, proto_tree*); +void dfiltmode (int, const u_char**, const u_char*, int*, int, proto_tree*); +void filtmode (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_events (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_register (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_register (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_config (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_sched (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_blm_data (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_blm_stat (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_addresp (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_addresp (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_modresp (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_resphan (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_sched (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_desc (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_desc (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_upload (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_delete (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_list (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_list (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_start (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_start (int, const u_char**, const u_char*, int*, int, proto_tree*); +void resp_status (int, const u_char**, const u_char*, int*, int, proto_tree*); +void cmd_options (int, const u_char**, const u_char*, int*, int, proto_tree*); +void eventnum (int, const u_char**, const u_char*, int*, int, proto_tree*); +void speed (int, const u_char**, const u_char*, int*, int, proto_tree*); +void filter_block (int, const u_char**, const u_char*, int*, int, proto_tree*); +void blm_mode (int, const u_char**, const u_char*, int*, int, proto_tree*); |