Ethereal-dev: [ethereal-dev] A PERL script to generate a prototype dissector file

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Richard Sharpe <sharpe@xxxxxxxxxx>
Date: Fri, 25 Aug 2000 13:10:20 +0900
Hi,

Attached is a PERL script that builds a prototype dissector.

If we suggets that people who write dissectors use this to generate their
initial dissector, we have a number of advantages ...

BTW, it is uuencoded ...
begin 766 build-dissector.pl
M(R$O=7-R+V)I;B]P97)L"B,@0G5I;&0@=&AE('-K96QA=&]N(&]F(&$@9&ES
M<V5C=&]R("XN+@HC"B,@5V4@=V]U;&0@86-C97!T('-O;64@9FQA9W,@979E
M;G1U86QL>2P@8G5T(&9O<B!N;W<@=V4@86-C97!T(&]N92!A<F=U;65N="`*
M(R!T:&%T(&=I=F5S('1H92!N86UE(&]F('1H92!D:7-S96-T;W(*(PID:64@
M(EEO=2!M=7-T('-P96-I9GD@=&AE(&YA;64@;V8@82!D:7-S96-T;W(A(B!U
M;FQE<W,@*"0C05)'5B`^/3`I.PH*(R!(;6UM+"!W92!S:&]U;&0@8VAE8VL@
M=VAE=&AE<B!O<B!N;W0@<W5C:"!A(&1I<W-E8W1O<B!E>&ES=',_"@IP<FEN
M="`B0W)E871I;F<@82!D:7-S96-T;W(@<VME;&%T;VX@9F]R('1H92`D05)'
M5ELP72!P<F]T;V-O;%QN(CL*"F1I92`B0V]U;&0@;F]T(&]P96X@<VME;&%T
M;VX@9FEL93H@)#\B('5N;&5S<R!O<&5N($]55"P@(CXN+W!A8VME="TD05)'
M5ELP72YC+G-K96PB.PH*<')I;G0@3U54("(O*B!P86-K970M)$%21U9;,%TN
M8UQN(B`N"B(@*B!2;W5T:6YE<R!F;W(@)$%21U9;,%T@<&%C:V5T(&1I<V%S
M<V5M8FQY7&XB("X*(B`J7&XB("X*(B`J(%PD260Z(%PD7&XB("X*(B`J(%QN
M(B`N"B(@*B!#;W!Y<FEG:'0@*&,I(#(P,#`@8GD@64]54B!.04U%($A%4D4@
M/%E/55(@14U!24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!R969S7VEN:71I86QI
M>F5D*2![7&XB("X*(EQN(B`N"B(@("`@;VQD7V1I<W-E8W1O<E]D96QE=&4H
M7")T8W`N<&]R=%PB+"!T8W!?<&]R="P@9&ES<V5C=%\D05)'5ELP72D[7&XB
M("X*(EQN(B`N"B(@('U<;B(@+@HB("!E;'-E('M<;B(@+@HB7&XB("X*(B`@
M("`D05)'5ELP75]P<F5F<U]I;FET:6%L:7IE9"`](%12544[7&XB("X*(EQN
M(B`N"B(@('U<;B(@+@HB7&XB("X*(B`@+RH@4V5T(&]U<B!P;W)T(&YU;6)E
M<B!F;W(@9G5T=7)E('5S92`J+UQN(B`N"B)<;B(@+@HB("!T8W!?<&]R="`]
M(&=L;V)A;%\D05)'5ELP75]T8W!?<&]R=#M<;B(@+@HB7&XB("X*(B`@;VQD
M7V1I<W-E8W1O<E]A9&0H7")T8W`N<&]R=%PB+"!G;&]B86Q?)$%21U9;,%U?
M=&-P7W!O<G0L(&1I<W-E8W1?)$%21U9;,%TI.UQN(B`N"B)<;B(@+@HB?5QN
%7&XB.PH`
`
end

Regards
-------
Richard Sharpe, sharpe@xxxxxxxxxx
Samba (Team member, www.samba.org), Ethereal (Team member, www.zing.org)
Contributing author, SAMS Teach Yourself Samba in 24 Hours
Author, Special Edition, Using Samba