1999-10-31 19:34:46 +00:00
|
|
|
%{
|
1999-09-23 05:26:18 +00:00
|
|
|
/* ascend-grammar.y
|
|
|
|
*
|
2000-11-12 04:57:39 +00:00
|
|
|
* $Id: ascend-grammar.y,v 1.17 2000/11/12 04:57:39 guy Exp $
|
1999-09-23 05:26:18 +00:00
|
|
|
*
|
|
|
|
* Wiretap Library
|
2000-01-22 06:22:44 +00:00
|
|
|
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
|
1999-09-23 05:26:18 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-09-11 04:53:26 +00:00
|
|
|
/*
|
|
|
|
Example 'wandsess' output data:
|
|
|
|
|
|
|
|
RECV-iguana:241:(task: B02614C0, time: 1975432.85) 49 octets @ 8003BD94
|
|
|
|
[0000]: FF 03 00 3D C0 06 CA 22 2F 45 00 00 28 6A 3B 40
|
|
|
|
[0010]: 00 3F 03 D7 37 CE 41 62 12 CF 00 FB 08 20 27 00
|
|
|
|
[0020]: 50 E4 08 DD D7 7C 4C 71 92 50 10 7D 78 67 C8 00
|
|
|
|
[0030]: 00
|
|
|
|
XMIT-iguana:241:(task: B04E12C0, time: 1975432.85) 53 octets @ 8009EB16
|
|
|
|
[0000]: FF 03 00 3D C0 09 1E 31 21 45 00 00 2C 2D BD 40
|
|
|
|
[0010]: 00 7A 06 D8 B1 CF 00 FB 08 CE 41 62 12 00 50 20
|
|
|
|
[0020]: 29 7C 4C 71 9C 9A 6A 93 A4 60 12 22 38 3F 10 00
|
|
|
|
[0030]: 00 02 04 05 B4
|
1999-09-13 03:49:04 +00:00
|
|
|
|
|
|
|
Example 'wdd' output data:
|
|
|
|
|
|
|
|
Date: 01/12/1990. Time: 12:22:33
|
|
|
|
Cause an attempt to place call to 14082750382
|
|
|
|
WD_DIALOUT_DISP: chunk 2515EE type IP.
|
|
|
|
(task: 251790, time: 994953.28) 44 octets @ 2782B8
|
|
|
|
[0000]: 00 C0 7B 71 45 6C 00 60 08 16 AA 51 08 00 45 00
|
|
|
|
[0010]: 00 2C 66 1C 40 00 80 06 53 F6 AC 14 00 18 CC 47
|
|
|
|
[0020]: C8 45 0A 31 00 50 3B D9 5B 75 00 00
|
|
|
|
|
|
|
|
|
1999-09-11 04:53:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2000-05-19 23:07:04 +00:00
|
|
|
#include "wtap-int.h"
|
1999-09-11 04:53:26 +00:00
|
|
|
#include "buffer.h"
|
|
|
|
#include "ascend.h"
|
1999-10-08 07:41:33 +00:00
|
|
|
#include "ascend-int.h"
|
1999-09-11 04:53:26 +00:00
|
|
|
|
|
|
|
#define NFH_PATH "/dev/null"
|
|
|
|
|
|
|
|
extern int at_eof;
|
|
|
|
|
|
|
|
int yyparse(void);
|
|
|
|
void yyerror(char *);
|
|
|
|
|
|
|
|
int bcur = 0, bcount;
|
2000-11-11 03:15:07 +00:00
|
|
|
guint32 start_time, secs, usecs, caplen, wirelen;
|
1999-09-11 22:36:38 +00:00
|
|
|
ascend_pkthdr *header;
|
|
|
|
struct ascend_phdr *pseudo_header;
|
1999-09-11 04:53:26 +00:00
|
|
|
char *pkt_data;
|
|
|
|
FILE *nfh = NULL;
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
%union {
|
|
|
|
gchar *s;
|
|
|
|
guint32 d;
|
|
|
|
char b;
|
|
|
|
}
|
|
|
|
|
2000-11-12 04:57:39 +00:00
|
|
|
%token <s> STRING KEYWORD WDD_DATE WDD_CHUNK COUNTER
|
1999-09-13 03:49:04 +00:00
|
|
|
%token <d> WDS_PREFIX DECNUM HEXNUM
|
2000-01-10 17:33:17 +00:00
|
|
|
%token <b> HEXBYTE
|
1999-09-11 04:53:26 +00:00
|
|
|
|
1999-09-13 03:49:04 +00:00
|
|
|
%type <s> string dataln datagroup
|
|
|
|
%type <d> wds_prefix decnum hexnum
|
1999-09-11 04:53:26 +00:00
|
|
|
%type <b> byte bytegroup
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
data_packet:
|
1999-09-13 03:49:04 +00:00
|
|
|
| wds_hdr datagroup
|
2000-11-12 04:57:39 +00:00
|
|
|
| wdd_date wdd_hdr datagroup
|
1999-09-13 03:49:04 +00:00
|
|
|
| wdd_hdr datagroup
|
1999-09-11 04:53:26 +00:00
|
|
|
;
|
|
|
|
|
1999-09-13 03:49:04 +00:00
|
|
|
wds_prefix: WDS_PREFIX;
|
1999-09-11 04:53:26 +00:00
|
|
|
|
1999-09-13 03:49:04 +00:00
|
|
|
string: STRING;
|
1999-09-11 04:53:26 +00:00
|
|
|
|
1999-09-13 03:49:04 +00:00
|
|
|
decnum: DECNUM;
|
1999-09-11 04:53:26 +00:00
|
|
|
|
|
|
|
hexnum: HEXNUM;
|
|
|
|
|
1999-09-13 03:49:04 +00:00
|
|
|
/* 1 2 3 4 5 6 7 8 9 10 11 */
|
|
|
|
wds_hdr: wds_prefix string decnum KEYWORD hexnum KEYWORD decnum decnum decnum KEYWORD HEXNUM {
|
1999-09-11 04:53:26 +00:00
|
|
|
wirelen = $9;
|
|
|
|
caplen = ($9 < ASCEND_MAX_PKT_LEN) ? $9 : ASCEND_MAX_PKT_LEN;
|
Add some comments, and fix one comment.
Remove what appear to be a pair of dangling "else"s.
Before calling "mktime()" on a "struct tm", you have to set "tm_isdst",
so it knows what to do about daylight savings time; set it to -1, so it
picks the appropriate time (except, presumably, for those times that
don't exist, when the clock is moved forward, where there is no
appropriate time, and those times that exist twice, when the clock is
moved backward, where there are *two* times and you can't tell which is
appropriate).
svn path=/trunk/; revision=2604
2000-11-11 01:44:05 +00:00
|
|
|
/* If we don't have as many bytes of data as the octet count in
|
|
|
|
the header, make the capture length the number of bytes we
|
|
|
|
actually have. */
|
1999-09-11 04:53:26 +00:00
|
|
|
if (bcount > 0 && bcount <= caplen)
|
|
|
|
caplen = bcount;
|
|
|
|
secs = $7;
|
|
|
|
usecs = $8;
|
1999-09-11 22:36:38 +00:00
|
|
|
if (pseudo_header != NULL) {
|
|
|
|
/* pseudo_header->user is set in ascend-scanner.l */
|
|
|
|
pseudo_header->type = $1;
|
|
|
|
pseudo_header->sess = $3;
|
1999-09-13 03:49:04 +00:00
|
|
|
pseudo_header->call_num[0] = '\0';
|
|
|
|
pseudo_header->chunk = 0;
|
1999-09-11 22:36:38 +00:00
|
|
|
pseudo_header->task = $5;
|
|
|
|
}
|
1999-09-11 04:53:26 +00:00
|
|
|
|
|
|
|
bcur = 0;
|
|
|
|
}
|
|
|
|
;
|
2000-11-12 04:57:39 +00:00
|
|
|
|
1999-09-13 03:49:04 +00:00
|
|
|
/*
|
|
|
|
Date: 01/12/1990. Time: 12:22:33
|
|
|
|
Cause an attempt to place call to 14082750382
|
|
|
|
*/
|
2000-11-12 04:57:39 +00:00
|
|
|
/* 1 2 3 4 5 6 7 8 9 10*/
|
|
|
|
wdd_date: WDD_DATE decnum decnum decnum KEYWORD decnum decnum decnum KEYWORD string {
|
2000-11-11 03:15:07 +00:00
|
|
|
/*
|
|
|
|
* Supply the date/time value to the code above us; it will use the
|
|
|
|
* first date/time value supplied as the capture start date/time.
|
|
|
|
*/
|
|
|
|
struct tm wddt;
|
|
|
|
|
|
|
|
wddt.tm_sec = $8;
|
|
|
|
wddt.tm_min = $7;
|
|
|
|
wddt.tm_hour = $6;
|
|
|
|
wddt.tm_mday = $3;
|
|
|
|
wddt.tm_mon = $2 - 1;
|
|
|
|
wddt.tm_year = ($4 > 1970) ? $4 - 1900 : 70;
|
Add some comments, and fix one comment.
Remove what appear to be a pair of dangling "else"s.
Before calling "mktime()" on a "struct tm", you have to set "tm_isdst",
so it knows what to do about daylight savings time; set it to -1, so it
picks the appropriate time (except, presumably, for those times that
don't exist, when the clock is moved forward, where there is no
appropriate time, and those times that exist twice, when the clock is
moved backward, where there are *two* times and you can't tell which is
appropriate).
svn path=/trunk/; revision=2604
2000-11-11 01:44:05 +00:00
|
|
|
wddt.tm_isdst = -1;
|
1999-09-13 03:49:04 +00:00
|
|
|
|
2000-11-11 03:15:07 +00:00
|
|
|
start_time = mktime(&wddt);
|
2000-11-12 04:57:39 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
/*
|
|
|
|
WD_DIALOUT_DISP: chunk 2515EE type IP.
|
|
|
|
(task: 251790, time: 994953.28) 44 octets @ 2782B8
|
|
|
|
*/
|
|
|
|
/* 1 2 3 4 5 6 7 8 9 10 11*/
|
|
|
|
wdd_hdr: WDD_CHUNK hexnum KEYWORD KEYWORD hexnum KEYWORD decnum decnum decnum KEYWORD HEXNUM {
|
|
|
|
wirelen = $9;
|
|
|
|
caplen = ($9 < ASCEND_MAX_PKT_LEN) ? $9 : ASCEND_MAX_PKT_LEN;
|
Add some comments, and fix one comment.
Remove what appear to be a pair of dangling "else"s.
Before calling "mktime()" on a "struct tm", you have to set "tm_isdst",
so it knows what to do about daylight savings time; set it to -1, so it
picks the appropriate time (except, presumably, for those times that
don't exist, when the clock is moved forward, where there is no
appropriate time, and those times that exist twice, when the clock is
moved backward, where there are *two* times and you can't tell which is
appropriate).
svn path=/trunk/; revision=2604
2000-11-11 01:44:05 +00:00
|
|
|
/* If we don't have as many bytes of data as the octet count in
|
|
|
|
the header, make the capture length the number of bytes we
|
|
|
|
actually have. */
|
1999-09-13 03:49:04 +00:00
|
|
|
if (bcount > 0 && bcount <= caplen)
|
|
|
|
caplen = bcount;
|
2000-11-12 04:57:39 +00:00
|
|
|
secs = $7;
|
|
|
|
usecs = $8;
|
1999-09-13 03:49:04 +00:00
|
|
|
if (pseudo_header != NULL) {
|
|
|
|
/* pseudo_header->call_num is set in ascend-scanner.l */
|
|
|
|
pseudo_header->type = ASCEND_PFX_WDD;
|
|
|
|
pseudo_header->user[0] = '\0';
|
|
|
|
pseudo_header->sess = 0;
|
2000-11-12 04:57:39 +00:00
|
|
|
pseudo_header->chunk = $2;
|
|
|
|
pseudo_header->task = $5;
|
1999-09-13 03:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bcur = 0;
|
|
|
|
}
|
|
|
|
;
|
1999-09-11 04:53:26 +00:00
|
|
|
|
2000-01-10 17:33:17 +00:00
|
|
|
byte: HEXBYTE {
|
1999-09-11 04:53:26 +00:00
|
|
|
if (bcur < caplen) {
|
1999-09-11 22:36:38 +00:00
|
|
|
pkt_data[bcur] = $1;
|
1999-09-11 04:53:26 +00:00
|
|
|
bcur++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bcur >= caplen) {
|
1999-09-11 22:36:38 +00:00
|
|
|
if (header != NULL) {
|
2000-11-11 03:15:07 +00:00
|
|
|
header->start_time = start_time;
|
1999-09-11 22:36:38 +00:00
|
|
|
header->secs = secs;
|
|
|
|
header->usecs = usecs;
|
|
|
|
header->caplen = caplen;
|
|
|
|
header->len = wirelen;
|
|
|
|
}
|
1999-09-11 04:53:26 +00:00
|
|
|
YYACCEPT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
1999-09-13 03:49:04 +00:00
|
|
|
/* XXX There must be a better way to do this... */
|
1999-09-11 04:53:26 +00:00
|
|
|
bytegroup: byte
|
|
|
|
| byte byte
|
|
|
|
| byte byte byte
|
|
|
|
| byte byte byte byte
|
|
|
|
| byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte byte byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte byte byte byte byte byte byte byte byte
|
|
|
|
| byte byte byte byte byte byte byte byte byte byte byte byte byte byte byte byte
|
|
|
|
;
|
|
|
|
|
|
|
|
dataln: COUNTER bytegroup;
|
|
|
|
|
|
|
|
datagroup: dataln
|
|
|
|
| dataln dataln
|
|
|
|
| dataln dataln dataln
|
|
|
|
| dataln dataln dataln dataln
|
|
|
|
| dataln dataln dataln dataln dataln
|
|
|
|
| dataln dataln dataln dataln dataln dataln
|
|
|
|
| dataln dataln dataln dataln dataln dataln dataln
|
|
|
|
| dataln dataln dataln dataln dataln dataln dataln dataln
|
|
|
|
;
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
void
|
|
|
|
init_parse_ascend()
|
|
|
|
{
|
|
|
|
bcur = 0;
|
|
|
|
at_eof = 0;
|
2000-11-11 03:15:07 +00:00
|
|
|
start_time = 0; /* we haven't see a date/time yet */
|
1999-09-11 04:53:26 +00:00
|
|
|
|
|
|
|
/* In order to keep flex from printing a lot of newlines while reading
|
|
|
|
the capture data, we open up /dev/null and point yyout at the null
|
|
|
|
file handle. */
|
|
|
|
if (! nfh) {
|
|
|
|
nfh = fopen(NFH_PATH, "r");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse the capture file. Return the offset of the next packet, or zero
|
|
|
|
if there is none. */
|
|
|
|
int
|
2000-05-19 08:18:17 +00:00
|
|
|
parse_ascend(FILE_T fh, void *pd, struct ascend_phdr *phdr,
|
1999-09-11 22:36:38 +00:00
|
|
|
ascend_pkthdr *hdr, int len)
|
1999-09-11 04:53:26 +00:00
|
|
|
{
|
|
|
|
/* yydebug = 1; */
|
|
|
|
|
|
|
|
ascend_init_lexer(fh, nfh);
|
|
|
|
pkt_data = pd;
|
1999-09-11 22:36:38 +00:00
|
|
|
pseudo_header = phdr;
|
|
|
|
header = hdr;
|
1999-09-11 04:53:26 +00:00
|
|
|
bcount = len;
|
|
|
|
|
2000-11-12 04:57:39 +00:00
|
|
|
/*
|
|
|
|
* Not all packets in a "wdd" dump necessarily have a "Cause an
|
|
|
|
* attempt to place call to" header (I presume this can happen if
|
|
|
|
* there was a call in progress when the packet was sent or
|
|
|
|
* received), so we won't necessarily have the phone number for
|
|
|
|
* the packet.
|
|
|
|
*
|
|
|
|
* XXX - we could assume, in the sequential pass, that it's the
|
|
|
|
* phone number from the last call, and remember that for use
|
|
|
|
* when doing random access.
|
|
|
|
*/
|
|
|
|
pseudo_header->call_num[0] = '\0';
|
|
|
|
|
1999-09-11 04:53:26 +00:00
|
|
|
if (yyparse())
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
yyerror (char *s)
|
|
|
|
{
|
|
|
|
/* fprintf (stderr, "%s\n", s); */
|
|
|
|
}
|