From 625b13a0e527bc992df9158807e1bdd70dfb7ac7 Mon Sep 17 00:00:00 2001 From: g0dil <g0dil@wiback.org> Date: Fri, 30 Jan 2009 14:06:51 +0000 Subject: [PATCH] Packets: Add missing packet diagrams --- Packets/MPEGDVBBundle/GREPacket.hh | 1 + Packets/MPEGDVBBundle/MPESection.hh | 1 + Packets/MPEGDVBBundle/SNDUPacket.hh | 1 + Packets/MPEGDVBBundle/TransportPacket.hh | 1 + Packets/SConscript | 4 +++ doclib/pkgdraw | 37 +++++++++++++++++++----- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/Packets/MPEGDVBBundle/GREPacket.hh b/Packets/MPEGDVBBundle/GREPacket.hh index 446ef03d0..32b8c1118 100644 --- a/Packets/MPEGDVBBundle/GREPacket.hh +++ b/Packets/MPEGDVBBundle/GREPacket.hh @@ -74,6 +74,7 @@ namespace senf { \par Fields: \ref GREPacketParser + \image html GREPacket.png \ingroup protocolbundle_mpegdvb */ diff --git a/Packets/MPEGDVBBundle/MPESection.hh b/Packets/MPEGDVBBundle/MPESection.hh index 7b7879db3..e6176915e 100644 --- a/Packets/MPEGDVBBundle/MPESection.hh +++ b/Packets/MPEGDVBBundle/MPESection.hh @@ -113,6 +113,7 @@ namespace senf { \par Fields: \ref MPESectionParser + \image html MPESection.png \ingroup protocolbundle_mpegdvb */ diff --git a/Packets/MPEGDVBBundle/SNDUPacket.hh b/Packets/MPEGDVBBundle/SNDUPacket.hh index 4f296acf2..1b699128c 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.hh +++ b/Packets/MPEGDVBBundle/SNDUPacket.hh @@ -88,6 +88,7 @@ namespace senf { \par Fields: \ref SNDUPacketParser + \image html SNDUPacket.png \ingroup protocolbundle_mpegdvb */ diff --git a/Packets/MPEGDVBBundle/TransportPacket.hh b/Packets/MPEGDVBBundle/TransportPacket.hh index ae1f540b8..13eff46bd 100644 --- a/Packets/MPEGDVBBundle/TransportPacket.hh +++ b/Packets/MPEGDVBBundle/TransportPacket.hh @@ -117,6 +117,7 @@ namespace senf { \par Fields: \ref TransportPacketParser + \image html TransportPacket.png \ingroup protocolbundle_mpegdvb */ diff --git a/Packets/SConscript b/Packets/SConscript index 2850c5703..21b1900bd 100644 --- a/Packets/SConscript +++ b/Packets/SConscript @@ -46,6 +46,10 @@ SENFSCons.Doxygen(env, extra_sources = [ PKGDRAWPACKETS = "MIHPacketParser"), env.PkgDraw("80211Bundle/WLANPacket.hh"), env.PkgDraw("80211Bundle/RadiotapPacket.hh"), + env.PkgDraw("MPEGDVBBundle/GREPacket.hh"), + env.PkgDraw("MPEGDVBBundle/MPESection.hh"), + env.PkgDraw("MPEGDVBBundle/SNDUPacket.hh"), + env.PkgDraw("MPEGDVBBundle/TransportPacket.hh"), ]) SENFSCons.InstallIncludeFiles(env, includes) diff --git a/doclib/pkgdraw b/doclib/pkgdraw index 35a6b9249..ecadad788 100755 --- a/doclib/pkgdraw +++ b/doclib/pkgdraw @@ -158,7 +158,7 @@ def makeTex(rows): if sides == "lrtb" : sides = "" else : sides = "[%s]" % sides if area.get('filled', False): - line.append(r"\bitbox%s{%s}{\color[gray]{0.7}\rule{\width}{\height}}" % (sides, area['size'])) + line.append(r"\bitbox%s{%s}{\color[gray]{0.93}\rule{\width}{\height}}" % (sides, area['size'])) elif area.get('skip', False): line.append(r"\skippedwords") elif area.get('dots', False): @@ -355,17 +355,37 @@ PARSER_END_RE = re.compile(r"PKGDRAW_PARSER_FINALIZE\s*\(([^)]*)\)\s*;") PARSER_FIELD_RE = re.compile(r"(?:@@>pkgdraw:(.*)$\s*)?PKGDRAW_PARSER_([A-Z_]+)\s*\(([^;]*)\)\s*;(?:\s*@@<pkgdraw:(.*)$)?", re.M) def scanPackets(data): + global FIELD_TYPES + packets = {} + packetOrder = [] end = 0 while True: start = PARSER_START_RE.search(data, end) - if not start: return packets + if not start: return (packets, packetOrder) start = start.end(0) end = PARSER_END_RE.search(data, start) - if not end: return packets + if not end: return (packets, packetOrder) name=end.group(1).strip() end = end.start(0) packets[name] = scanFields(data[start:end]) + packetOrder.append(name) + minsize = maxsize = 0 + for field in packets[name]: + if field.get('size', None) is not None: + maxsize += field['size'] + elif field.get('minsize', None) is not None: + maxsize += field['maxsize'] + if not field.get('optional', False): + if field.get('size', None) is not None: + minsize += field['size'] + elif field.get('minsize', None) is not None: + minsize += field['minsize'] + if minsize is not None and maxsize is not None: + if minsize == maxsize: + FIELD_TYPES[name] = { 'size' : minsize } + else: + FIELD_TYPES[name] = { 'minsize' : minsize, 'maxsize' : maxsize } def scanFields(data): fields = [] @@ -411,7 +431,8 @@ names = [] gccopts = [] if len(args)<2 or args[0] == '--' or args[1] == '--': - sys.stderr.write("Usage: %s <header> <outfile> [<parser name>...] [ -- <cpp options>...]\n") + sys.stderr.write("Usage: %s <header> <outfile> [<parser names>...] [-- <cpp options>...]\n" + % sys.argv[0]) sys.exit(1) source = args.pop(0) @@ -420,15 +441,15 @@ target = args.pop(0) while args and args[0] != '--' : names.append(args.pop(0)) if args : gccopts = args[1:] -data = scanPackets(cppExpand(quoteMacros(stripComments(file(source).read())), - gccopts, os.path.dirname(source))) +data, order = scanPackets(cppExpand(quoteMacros(stripComments(file(source).read())), + gccopts, os.path.dirname(source))) texf = file(os.path.join(tmpdir, "fields.tex"),"w") texf.write(TEX_HEADER) if not names: - names = data.keys() - names.sort() + order.reverse() + names = order for name in names: texf.write("\\textbf{%s}\n\\bigskip\\par\n" % texquote(name)) -- GitLab