|
-
September 23rd, 2002, 10:49 PM
#1
object model for dns message
I'm having a little trouble in translating a dns resource record into an object.
The problem lies in the fact that depending on the type of message being received, the format of the data contained within the resource record is different and so I would need to design multiple objects or structs to represent each format. For example an A type record is stored as a 32 bit value, an MX type record is stored as a 16bit preference value and a variable length label, while a third format that I want to represent is just a variable length label.
All resource records share 5 common fields (domain name, type, class, ttl, resource data length).
The abbreviated version of the object I would like to create is something like:
public class ResourceRecord {
property string DomainName;
property ResourceRecordType RRType; // an enum
property ResourceRecordClass RRClass; // an enum
property int TTL;
property short RRDataLen;
// here is the problem
property ResourceData RRData;
}
Is this something that the ClassFactory design pattern is meant to deal with?
I was also thinking about just leaving the RRData field as a byte[]
and giving static methods to a DNSMessage class to generate objects of the appropriate type from the byte array. A third solution was just to return everything as a . seperated string.
Any ideas on how to deal with this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|