5 COLOR_SCHEME = 'pastel19' # see http://www.graphviz.org/doc/info/colors.html
6 NETEMU = ["InterfaceAnnotater" , "PacketMonitor" , "PacketTypeChecker"]
11 node [shape=Mrecord, fontsize=8, fontname="Helvetica"];
19 if opt in ("-p","--packet"):
22 for line in sys.stdin:
26 elif mode == "MODULE":
27 moduleid, module = line.split(' ',1);
28 moduleid = moduleid[1:]
29 connectorid = type = peerid = None
30 modules[moduleid] = (module, []);
33 connectorid, type = line.split(' ',1);
34 connectorid = connectorid[1:]
36 packet = type.rsplit('<',1)[1]
37 packet = packet.rsplit('::',1)[-1]
38 packet = packet.split('>',1)[0]
41 elts = type.rsplit(' ', 1);
42 if elts[-1].startswith('0x'):
43 type, peerid = elts[0], elts[1][1:]
45 if elts[-1] == ('throttled'):
47 elts = elts[0].rsplit(' ', 1)
48 type, peerid = elts[0], elts[1][1:]
51 modules[moduleid][1].append((connectorid, type, peerid, packet))
52 connectors[connectorid] = (moduleid, throttled)
54 for moduleid, (module, cs) in modules.iteritems():
55 module = module.split('<',1)[0]
56 if module.rsplit('::',1)[-1] in NETEMU or module.startswith("senf::emu"):
58 elif module.endswith("Source") or module.endswith("Sink"):
60 elif "senf" not in module.split('::',1)[0]:
64 module = module.rsplit('::',1)[-1]
67 for connectorid, type, peerid, packet in cs:
68 if 'Input' in type: inputs.append("<%s>%s" % (connectorid,connectorid))
69 else: outputs.append("<%s>%s" % (connectorid,connectorid))
71 if inputs: rows.append("{%s}" % "|".join(inputs))
72 rows.append("%s" % (module))
73 if outputs: rows.append("{%s}" % "|".join(outputs))
74 sys.stdout.write('%s [label="{%s}" style="filled" fillcolor="/%s/%s" ]\n'
75 % (moduleid, "|".join(rows),COLOR_SCHEME, color ))
79 for moduleid, (type, cs) in modules.iteritems():
80 for connectorid, type, peerid, packet in cs:
82 if "Passive" in type: opts.append("arrowtail=odot");
83 if "Output" in type and peerid is not None:
84 if "Active" in type and connectors[peerid][1]:
85 opts.append("arrowhead=tee")
86 opts.append('headlabel="!"')
87 if "Passive" in type and connectors[connectorid][1]:
88 opts.append("arrowtail=tee")
89 opts.append('taillabel="!"')
91 if opts: opts = " [%s]" % opts
92 if "Output" in type and peerid is not None:
93 if "Packet" in packet and p is 1:
94 sys.stdout.write('%s:%s -> %s:%s%s [label=" %s", fontsize=8, fontname="Helvetica"]\n'
95 % (moduleid, connectorid, connectors[peerid][0], peerid, opts,packet))
97 sys.stdout.write('%s:%s -> %s:%s%s\n'
98 % (moduleid, connectorid, connectors[peerid][0], peerid, opts))
100 sys.stdout.write('anon%d [label="", shape=point, height=.05];\n' % anonid)
102 sys.stdout.write('%s:%s -> anon%d%s;\n' % (moduleid, connectorid, anonid, opts))
104 sys.stdout.write('anon%d -> %s:%s%s;\n' % (anonid, moduleid, connectorid, opts))
107 sys.stdout.write("}\n")