Require Help in Parsing strings!!!!

Z

zoltan

I am supposed to implement a DNS Query. The Information to be processed

resides in RRs ( Resource Records). The header <arpa/nameser.h>
contains the following structure to store the data of these RRs as :


typedef struct __ns_rr {
char name[NS_MAXDNAME];
uint16_t type;
uint16_t rr_class;
uint32_t ttl;
uint16_t rdlength;
const uchar_t *rdata;


} ns_rr;


Now, the rdata part can have several fields depending on the specific
type of Record.
For instance, the SRV type has only the following fields : priority,
weight, port ( all of unsigned int type) and a target string ( the
hostname).


For my requirement, I have to use the data stored in a NAPTR record.
The "rdata" contains the following fields for this type of record :


order, preference ( unsigned int) and
flags, services, regexp and replacement ( all of type char *).


Now, because the definition of the rdata in the ns_rr structure is
generic, I have defined ( as I need to ) a structure as follows, to
store the actual data :


struct NAPTR
{
unsigned int order;
unsigned int preference;
char * flags;
char * services;
char * regexp;
char * replacement;


};


So my question is this : How can I extract the string fields from the
rdata portion of the ns_rr structure and store them into the respective

fields in my user-defined structure?


The integer fields ( order and preference ) are easy enough, being of
fixed size. What about the strings which can be of variable size?


I hope that is clear enough to elicit a suggestion or a positive
response in the least!


Regards,


Timmy Jose.
 
I

iftekhar

How can I extract the string fields from the
rdata portion of the ns_rr structure and store them into the respective
fields in my user-defined structure?
by parsing the string. the rdata should have some sort of delimeters
for seperating each field or it should have a length field before every
entry so that it can be parsed. It might also have a fixed length
reserved for each entyr. I dont know the specifics, just possibilites.

does it help you?

iftekhar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top