aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/gryphon/packet-gryphon.h
blob: f6d947da9358c14897afde9f5ca2c4781e8d3286 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/* packet-gryphon.c
 * Definitions for Gryphon packet disassembly structures and routines
 *
 * $Id: packet-gryphon.h,v 1.6 2002/05/01 06:56:16 guy 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
#define CMD_HDR_SZ  	    4

/* 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 */
#define CMD_SERVER_SET_SORT 	(SD_SERVER * 256 + 0x51)	/* set sorting behavior */
#define CMD_SERVER_SET_OPT  	(SD_SERVER * 256 + 0x52)    	/* set type of optimization */

/* 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 */
#define CMD_PGM_FILES	    	(SD_PGM * 256 + 0x98)	/* Get a list of files & directories */

/* 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 */

/* USDT (SD_USDT) target commands: */

#define	CMD_USDT_IOCTL		(SD_USDT * 256 + 0x47)	/* Register/Unregister with USDT */


/* 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    	    0x80
#define FR_DEACT_ON_EVENT     	    0x40
#define FR_DELETE   	    	    0x20
#define FR_PERIOD_MSGS 	    	    0x10

/* 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
#define FILTER_EVENT_TYPE_HEADER 	0x04
#define FILTER_EVENT_TYPE_DATA 	    	0x05

/* 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

/* Flags to modify how FT_CMD (command) messages are handled	    	*/
/* These values are ORed with FT_CMD and stored in the Frame Header's	*/
/* Frame Type field for each response. 	    	    	    	    	*/
#define DONT_WAIT_FOR_RESP  	0x80
#define WAIT_FOR_PREV_RESP  	0x40
#define RESPONSE_FLAGS  	(DONT_WAIT_FOR_RESP | WAIT_FOR_PREV_RESP)


/* 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 GDEHC12KWP	0x01		/* DE HC12 KWP/BDLC card SUBTYPE */

#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;


typedef struct val_str_dsp {
    int     value;
    char    *strptr;
    int     (*cmd_fnct)(tvbuff_t *, int, proto_tree*);
    int     (*rsp_fnct)(tvbuff_t *, int, proto_tree*);
} val_str_dsp;