[ragel-users] Decoding DNS protocol

Pete Gervais pgervais at xplornet.com
Thu Jul 15 17:51:25 UTC 2010

I'm using ragel to decode protocols as a test of its capabilities.

One of the protocols is DNS. 

This protocol has a fixed set of fields followed by one or more optional
fields. The count  of these optional fields are encoded within the fixed
data field.


Would the code below be the best way to do this ?Initial the dnsAnswer
section called via fcall dnsAnswer.   It then sequentially processes all
fields in the order given. In the last field, dnsAnswerResourceDataField  ,
it gets the count of the number of answer fields included in the protocol,
then perform a series of fgoto's until the dnsRecordCount is 0 at which time
it returns. 



dnsAnswer := (

                                dnsAnswerNameField .

                                dnsAnswerTypeField .

                                dnsAnswerClassField .

                                dnsAnswerTimeToLiveField .

                                dnsAnswerResourceDataLengthField .

                                dnsAnswerResourceDataField  @{ cout << "In
dnsAnswer processing" << endl; if (fsm->getdnsAnswerRecordCount() > 0 ) {


                                                fgoto dnsAnswer; } else {

                                                fret; }








Peter J. Gervais 

President, Simtree Information Systems 

17621 Island Rd, 

RR#2 , Martintown, 


K0C 1S0


Business: 613-938-6549

Cell: 613-864-7370

E-mail: pgervais at xplornet.com


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20100715/4af75dbc/attachment-0001.html>
-------------- next part --------------
ragel-users mailing list
ragel-users at complang.org

More information about the ragel-users mailing list