]> granicus.if.org Git - pdns/commitdiff
make Lua getID() return a number in the right byte order
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 22 Feb 2018 23:56:32 +0000 (00:56 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 22 Feb 2018 23:56:32 +0000 (00:56 +0100)
pdns/lua-base4.cc

index eb37dd92aa054d882696ac283423306e7013302e..b514597ab443e8c58ae1324ab6d52e44df84b802 100644 (file)
@@ -43,7 +43,7 @@ void BaseLua4::prepareContext() {
   d_lw = std::unique_ptr<LuaContext>(new LuaContext);
 
   // dnsheader
-  d_lw->registerFunction<int(dnsheader::*)()>("getID", [](dnsheader& dh) { return dh.id; });
+  d_lw->registerFunction<int(dnsheader::*)()>("getID", [](dnsheader& dh) { return ntohs(dh.id); });
   d_lw->registerFunction<bool(dnsheader::*)()>("getCD", [](dnsheader& dh) { return dh.cd; });
   d_lw->registerFunction<bool(dnsheader::*)()>("getTC", [](dnsheader& dh) { return dh.tc; });
   d_lw->registerFunction<bool(dnsheader::*)()>("getRA", [](dnsheader& dh) { return dh.ra; });