|
From: <ma...@us...> - 2012-02-13 09:57:08
|
Revision: 1317
http://scstudio.svn.sourceforge.net/scstudio/?rev=1317&view=rev
Author: madzin
Date: 2012-02-13 09:56:57 +0000 (Mon, 13 Feb 2012)
Log Message:
-----------
Add IPv6 support into pcap transformation.
Modified Paths:
--------------
trunk/src/data/Z120/Z120.g
trunk/tools/pcap2z120/pcap2z120.py
Modified: trunk/src/data/Z120/Z120.g
===================================================================
--- trunk/src/data/Z120/Z120.g 2012-02-11 21:00:54 UTC (rev 1316)
+++ trunk/src/data/Z120/Z120.g 2012-02-13 09:56:57 UTC (rev 1317)
@@ -412,14 +412,18 @@
;
event_definition:
- NAME
+ instance_name
{
- set_instance_name_fun(context, (char*) ($NAME.text->chars));
+ set_instance_name_fun(context, (char*) ($instance_name.text->chars));
}
':' instance_event_list
| instance_name_list ':' multi_instance_event_list
;
+instance_name:
+ NAME | Character_String //Character_String is extra; Not supported in Z120 recommentation
+;
+
instance_event_list:
(instance_event)+
;
@@ -570,7 +574,7 @@
;
output_address:
- NAME | ('env' | reference_identification) ('via' NAME)?
+ instance_name | ('env' | reference_identification) ('via' NAME)?
;
reference_identification:
@@ -579,7 +583,7 @@
;
input_address:
- NAME | ('env' | reference_identification) ('via' NAME)?
+ instance_name | ('env' | reference_identification) ('via' NAME)?
;
Modified: trunk/tools/pcap2z120/pcap2z120.py
===================================================================
--- trunk/tools/pcap2z120/pcap2z120.py 2012-02-11 21:00:54 UTC (rev 1316)
+++ trunk/tools/pcap2z120/pcap2z120.py 2012-02-13 09:56:57 UTC (rev 1317)
@@ -46,24 +46,42 @@
messages = []
#accord Z120 recommendation
-z120 = True
+z120 = True
+ipv6_occurred = False
while True:
+ ipv6 = False
line = sharkout.readline()
# eof encountered
if len(line) == 0:
break
+ #IPv4 trafic
regex = re.compile('^ *(\d+) +(\d+\.\d+) +(\d+\.\d+\.\d+\.\d+) -> (\d+\.\d+\.\d+\.\d+) (.*?)$')
+ ret = regex.match(line)
- ret = regex.match(line)
+ #IPv6 trafic
+ if ret == None:
+ regex = re.compile('^ *(\d+) +(\d+\.\d+) +((\w+\:\:?)+\w+) -> ((\w+\:\:?)+\w+) (.*?)$')
+ ret = regex.match(line)
+ ipv6 = True
+
+ if ipv6_occurred == False:
+ print >> sys.stderr, "Warning: Instance name violates Z120 recomendation. IPv6 address includes ':' symbol."
+ ipv6_occurred = True;
+
if ret != None:
msg = {}
msg['num'] = ret.group(1)
msg['date'] = ret.group(2)
- msg['src'] = ret.group(3)
- msg['dst'] = ret.group(4)
+ if ipv6:
+ msg['src'] = "\'" + ret.group(3) + "\'"
+ msg['dst'] = "\'" + ret.group(4) + "\'"
+ else:
+ msg['src'] = ret.group(3)
+ msg['dst'] = ret.group(4)
+
mesg = ret.group(5).lstrip().rstrip()
if any([mesg.find(" ") != -1, mesg.find("\"") != -1,
@@ -77,6 +95,9 @@
mesg.find("<") != -1, mesg.find(">") != -1,
mesg.find("#") != -1, mesg.find(",") != -1,
mesg.find(";") != -1, mesg.find(":") != -1]):
+
+ mesg = "\'" + mesg + "\'"
+
if z120:
print >> sys.stderr, "Warning: Message lable violates Z120 recomendation. The label includes special symbol, e.g. space, ?, /, (, &, etc."
z120 = False
@@ -124,14 +145,9 @@
src = entities.index(msg['src'])
dst = entities.index(msg['dst'])
- if z120:
- print("%s: out %s,%d to %s;") % (entities[src], msg['msg'], identificator, entities[dst])
- print("%s: in %s,%d from %s;") % (entities[dst], msg['msg'], identificator, entities[src])
- identificator += 1
- else:
- print("%s: out \'%s\',%d to %s;") % (entities[src], msg['msg'], identificator, entities[dst])
- print("%s: in \'%s\',%d from %s;") % (entities[dst], msg['msg'], identificator, entities[src])
- identificator += 1
+ print("%s: out %s,%d to %s;") % (entities[src], mesg, identificator, entities[dst])
+ print("%s: in %s,%d from %s;") % (entities[dst], mesg, identificator, entities[src])
+ identificator += 1
#end all instances
line = ''
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|