From: Miek Gieben Date: Tue, 23 Aug 2005 19:15:56 +0000 (+0000) Subject: more lua stuff X-Git-Tag: release-1.0.0~256 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f20c5a3cc2a4eecf861de55d694f18baebb9a6df;p=thirdparty%2Fldns.git more lua stuff dig now says (when I ancount++ in a pkt): dig @localhost -p 5353 any miek.nl ;; Warning: Message parser reports malformed message packet. --- diff --git a/lua/Makefile.in b/lua/Makefile.in index b482008b..f7d6edf4 100644 --- a/lua/Makefile.in +++ b/lua/Makefile.in @@ -14,6 +14,9 @@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ +LINT = splint +LINTFLAGS = +quiet -weak -warnposix -unrecog -Din_addr_t=uint32_t -Du_int=unsigned -Du_char=uint8_t + COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) LINK = $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) @@ -44,3 +47,6 @@ realclean: clean rm -f config.log config.status aclocal.m4 config.h.in configure Makefile rm -f config.h +lint: + $(LINT) $(LINTFLAGS) -I$(srcdir)/.. lua-rns.c ; \ + if [ $$? -ne 0 ] ; then exit 1 ; fi diff --git a/lua/lua-rns.c b/lua/lua-rns.c index 78e41ec6..cd058b19 100644 --- a/lua/lua-rns.c +++ b/lua/lua-rns.c @@ -379,8 +379,11 @@ l_pkt_arcount(lua_State *L) } static int -l_pkt_set_qdcount(lua_State *L) +l_pkt_set_ancount(lua_State *L) { + ldns_pkt *p = (ldns_pkt*)lua_touserdata(L, 1); + uint16_t count = (uint16_t) lua_tonumber(L, 2); + (void)ldns_pkt_set_ancount(p, count); return 0; } @@ -555,9 +558,9 @@ register_ldns_functions(void) {"ancount", l_pkt_ancount}, {"nscount", l_pkt_nscount}, {"arcount", l_pkt_arcount}, + {"set_ancount", l_pkt_set_ancount}, #if 0 {"set_qdcount", l_pkt_set_qdcount}, - {"set_ancount", l_pkt_set_ancount}, {"set_nscount", l_pkt_set_nscount}, {"set_arcount", l_pkt_set_arcount}, #endif diff --git a/lua/rns.lua b/lua/rns.lua index fc8e5951..2547cce8 100644 --- a/lua/rns.lua +++ b/lua/rns.lua @@ -22,6 +22,7 @@ socket = udp.open(rdf_ip, 5353) wirebuf, sockaddr_from, fromlen = udp_read(socket) -- this works --wirebuf, sockaddr_from, fromlen = udp.read(socket) -- this doesn't +-- wrap this in new functions if wirebuf == nil then lua_debug("nothing received") else @@ -35,6 +36,8 @@ else -- set the id on the outgoing packet packet.set_id(pkt, id) + packet.set_ancount(pkt, + packet.ancount(pkt) + 1) wirebuf2 = packet.to_buf(pkt) rdf_listen, port_listen = rdf.sockaddr_to_rdf(sockaddr_from)