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: [email protected]

 

_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users

Reply via email to