diff options
author | JINMEI Tatuya <jinmei@isc.org> | 2012-11-30 23:28:52 +0100 |
---|---|---|
committer | JINMEI Tatuya <jinmei@isc.org> | 2012-12-01 04:40:59 +0100 |
commit | 3ae13a89a2f238602d5dd7e3dc12da963de21ec8 (patch) | |
tree | 762b734735bfb3d380f708e1ba56e7c6eb4d3744 /src/lib | |
parent | [2382] unrelated fix to lexer: support empty qstring and nul termination. (diff) | |
download | kea-3ae13a89a2f238602d5dd7e3dc12da963de21ec8.tar.xz kea-3ae13a89a2f238602d5dd7e3dc12da963de21ec8.zip |
[2382] added from-lexer ctor for AAAA RDATA.
not directly related to this task, but I found we need one real (non wrapper)
example to test some of the feature of generic createRdata().
also updated RDATA template including with-lexer constructor.
Diffstat (limited to 'src/lib')
-rwxr-xr-x | src/lib/dns/gen-rdatacode.py.in | 29 | ||||
-rw-r--r-- | src/lib/dns/rdata/in_1/aaaa_28.cc | 27 | ||||
-rw-r--r-- | src/lib/dns/rdata/template.cc | 5 |
3 files changed, 48 insertions, 13 deletions
diff --git a/src/lib/dns/gen-rdatacode.py.in b/src/lib/dns/gen-rdatacode.py.in index 9f2258206a..6a9ff8aca5 100755 --- a/src/lib/dns/gen-rdatacode.py.in +++ b/src/lib/dns/gen-rdatacode.py.in @@ -28,7 +28,7 @@ re_typecode = re.compile('([\da-z]+)_(\d+)') classcode2txt = {} typecode2txt = {} typeandclass = [] -new_rdatafactory_users = [] +new_rdatafactory_users = ['aaaa'] generic_code = 65536 # something larger than any code value rdata_declarations = '' class_definitions = '' @@ -117,6 +117,9 @@ class AbstractMessageRenderer;\n\n''' explicit ''' + type_utxt + '''(const std::string& type_str); ''' + type_utxt + '''(isc::util::InputBuffer& buffer, size_t rdata_len); ''' + type_utxt + '''(const ''' + type_utxt + '''& other); + ''' + type_utxt + '''( + MasterLexer& lexer, const Name* name, + MasterLoader::Options options, MasterLoaderCallbacks& callbacks); virtual std::string toText() const; virtual void toWire(isc::util::OutputBuffer& buffer) const; virtual void toWire(AbstractMessageRenderer& renderer) const; @@ -204,17 +207,33 @@ def generate_rdatadef(file, basemtime): rdata_deffile.write(class_definitions) rdata_deffile.close() -def generate_rdatahdr(file, declarations, basemtime): +def generate_rdatahdr(file, heading, declarations, basemtime): if not need_generate(file, basemtime): print('skip generating ' + file); return + heading += ''' +#ifndef DNS_RDATACLASS_H +#define DNS_RDATACLASS_H 1 + +#include <dns/master_loader.h> + +namespace isc { +namespace dns { +class Name; +class MasterLexer; +class MasterLoaderCallbacks; +} +} +''' declarations += ''' +#endif // DNS_RDATACLASS_H + // Local Variables: // mode: c++ // End: ''' rdata_header = open(file, 'w') - rdata_header.write(heading_txt) + rdata_header.write(heading) rdata_header.write(declarations) rdata_header.close() @@ -306,8 +325,8 @@ if __name__ == "__main__": try: import_definitions(classcode2txt, typecode2txt, typeandclass) generate_rdatadef('@builddir@/rdataclass.cc', rdatadef_mtime) - generate_rdatahdr('@builddir@/rdataclass.h', rdata_declarations, - rdatahdr_mtime) + generate_rdatahdr('@builddir@/rdataclass.h', heading_txt, + rdata_declarations, rdatahdr_mtime) generate_typeclasscode('rrtype', rdatahdr_mtime, typecode2txt, 'Type') generate_typeclasscode('rrclass', classdir_mtime, classcode2txt, 'Class') diff --git a/src/lib/dns/rdata/in_1/aaaa_28.cc b/src/lib/dns/rdata/in_1/aaaa_28.cc index ce49a04c51..0466f1a445 100644 --- a/src/lib/dns/rdata/in_1/aaaa_28.cc +++ b/src/lib/dns/rdata/in_1/aaaa_28.cc @@ -12,6 +12,15 @@ // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR // PERFORMANCE OF THIS SOFTWARE. +#include <exceptions/exceptions.h> +#include <util/buffer.h> +#include <dns/exceptions.h> +#include <dns/messagerenderer.h> +#include <dns/rdata.h> +#include <dns/rdataclass.h> +#include <dns/master_lexer.h> +#include <dns/master_loader.h> + #include <stdint.h> #include <string.h> @@ -20,14 +29,6 @@ #include <arpa/inet.h> // XXX: for inet_pton/ntop(), not exist in C++ standards #include <sys/socket.h> // for AF_INET/AF_INET6 -#include <exceptions/exceptions.h> - -#include <util/buffer.h> -#include <dns/exceptions.h> -#include <dns/messagerenderer.h> -#include <dns/rdata.h> -#include <dns/rdataclass.h> - using namespace std; using namespace isc::util; @@ -42,6 +43,16 @@ AAAA::AAAA(const std::string& addrstr) { } } +AAAA::AAAA(MasterLexer& lexer, const Name*, + MasterLoader::Options, MasterLoaderCallbacks&) +{ + const MasterToken& token = lexer.getNextToken(MasterToken::STRING); + if (inet_pton(AF_INET6, token.getStringRegion().beg, &addr_) != 1) { + isc_throw(InvalidRdataText, "Failed to convert '" + << token.getString() << "' to IN/AAAA RDATA"); + } +} + AAAA::AAAA(InputBuffer& buffer, size_t rdata_len) { if (rdata_len != sizeof(addr_)) { isc_throw(DNSMessageFORMERR, diff --git a/src/lib/dns/rdata/template.cc b/src/lib/dns/rdata/template.cc index ee1097e7f6..6486e6a51a 100644 --- a/src/lib/dns/rdata/template.cc +++ b/src/lib/dns/rdata/template.cc @@ -34,6 +34,11 @@ using namespace isc::util; // If you added member functions specific to this derived class, you'll need // to implement them here, of course. +MyType::MyType(MasterLexer& lexer, const Name* origin, + MasterLoader::Options options, MasterLoaderCallbacks& callbacks) +{ +} + MyType::MyType(const string& type_str) { } |