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.
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.