Marco Hsu / WIFI_API
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cyntec_dns.h Source File

cyntec_dns.h

00001 #ifndef CYNTEC_DNS_H
00002 #define CYNTEC_DNS_H
00003 
00004 #include <stdint.h>
00005 
00006 class DnsClient
00007 {
00008 private:
00009 
00010 //    class Hander {
00011 //    private:
00012 
00013 //        uint16_t *handerMsg = 0;
00014 //        uint16_t *transactionId = 0;  //A 16 bit identifier assigned by the program that generates any kind of query.
00015 //        uint16_t *handerSecondRow = 0;
00016 //        uint16_t *qdCount = 0;
00017 //        uint16_t *anCount = 0;
00018 //        uint16_t *nsCount = 0;
00019 //        uint16_t *arCount = 0;
00020 
00021 //    public:
00022 //        Hander();
00023 //        Hander(uint16_t *msg);
00024 //        uint16_t getTransactionId();
00025 //        uint8_t getQueryOrRespone();
00026 //        uint8_t getOpCode();
00027 //        uint8_t getAuthoritativeAnswer();
00028 //        uint8_t getTrunCation();
00029 //        uint8_t getRecursionDesired();
00030 //        uint8_t getRecursionAvailable();
00031 //        uint8_t getZ();
00032 //        uint8_t getResponseCode();
00033 //        uint16_t *getQdCountget();
00034 //        uint16_t *getAnCount();
00035 //        uint16_t *getNsCount();
00036 //        uint16_t *getArCount();
00037 //    };
00038 
00039 //    class Question {
00040 //    private:
00041 //        Question(char *msg);
00042 //        char *questionMsg = 0;
00043 //        char *QName = 0; // a domain name represented as a sequence of labels.
00044 //        char *QType[2]; //a two octet code which specifies the type of the query.
00045 //        char *QClass[2]; //a two octet code that specifies the class of the query.
00046 //    public:
00047 //        const char* getQName();
00048 //        const char* getQType();
00049 //        const char* getQClass();
00050 //    };
00051 
00052 //    class RRecord{
00053 //    private:
00054 //        RRecord(char *msg);
00055 //        char *rRecordMsg;
00056 //        char *RRName; // a domain name to which this resource record pertains.
00057 //        char *RRType[2]; //two octets containing one of the RR type codes
00058 //        char *RRClass[2]; //two octets which specify the class of the data in the RDATA field.
00059 //        char *RRTll[4]; // a domain name represented as a sequence of labels.
00060 //        char *RdLength[2]; //an unsigned 16 bit integer that specifies the length in octets of the RDATA field.
00061 //        char *RData[2]; //a variable length string of octets that describes the resource.
00062 //    public:
00063 //        const char* getRRName();
00064 //        const char* getRRType();
00065 //        const char* getRRClass();
00066 //        const char* getRRTll();
00067 //        const char* getRdLength();
00068 //        const char* getRData();
00069 //    };
00070 
00071     const char *queryMsg;
00072     char *queryEcMsg;
00073     short queryId;
00074     int querySize;
00075 
00076     char *answerMsg;
00077     short answerId;
00078     int iPCounters;
00079     char **answerIPs;
00080 //    Hander *ptrHander = 0;
00081 //    Question *ptrQuestion = 0;
00082 //    RRecord *ptrRRcoed = 0;
00083 
00084     /**
00085      *      QR (1 bit)
00086      *  query (0), or a response (1).
00087      *
00088      *      OpCode (4 bits)
00089      *  0 a standard query (QUERY)
00090      *  1 an inverse query (IQUERY)
00091      *  2 a server status request (STATUS)
00092      *  3-15 reserved for future use
00093      *
00094      *      Authoritative Answer (1 bit)
00095      *  this bit is valid in responses,
00096      *  and specifies that the responding name server is an
00097      *  authority for the domain name in question section.
00098      *
00099      *      TrunCation (1 bit)
00100      *  specifies that this message was truncated
00101      *  due to length greater than that permitted on the
00102      *  transmission channel.
00103      *
00104      *      Recursion Desired (1 bit)
00105      *  this bit may be set in a query and is copied into the response.
00106      *
00107      *      Recursion Available (1 bit)
00108      *  this be is set or cleared in a
00109      *  response, and denotes whether recursive query support is
00110      *  available in the name server.
00111      *
00112      *      Z (3 bits)
00113      *   Reserved for future use.
00114      *
00115      *  Response code (4 bits)
00116      *  this 4 bit field is set as part of responses.
00117      */
00118 
00119     char *queryEncode();
00120     void queryAddHeader(char *startChar);
00121     void queryAddQuestion(char *startChar);
00122 //    void queryAddRRFrom(char *dst);
00123 
00124     short parseAnswerId(char *answerMsg);
00125     char **parseAnswerIPs(char *answerMsg);
00126 
00127 
00128 public:
00129     DnsClient(const char *msg);
00130     ~DnsClient();
00131 
00132     int getQuerySize();
00133     char *getQueryEncode();
00134     short getQueryID();
00135 
00136     void *answerDecode(char *msg);
00137     short getAnswerId();
00138     int getIpCounters();
00139     const char** getAnswerIPs();
00140 
00141 //    void *responseDecode();
00142 //    Hander *getHander();
00143 //    Question *getQuestion();
00144 //    RRecord *getRRecord();
00145 
00146 };
00147 
00148 #endif // CYNTEC_DNS_H
00149 
00150