[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 ) {

                                                fsm->dnsAnswerRecordCount--;

                                                fgoto dnsAnswer; } else {

                                                fret; }

                }

                );

 

 

 

Regards,

 

Peter J. Gervais 

President, Simtree Information Systems 

17621 Island Rd, 

RR#2 , Martintown, 

Martintown,Ont

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
http://www.complang.org/mailman/listinfo/ragel-users


More information about the ragel-users mailing list