"SERVER-SIDE LOW-LEVEL API CALL FLOW"
When implementing the server side of the lightweight resolver protocol using the lwres library, a sequence of actions like the following is typically involved in processing each request packet.
Note that the same lwres_packet_t is used in both the _parse() and _render() calls, with only a few modifications made to the packet headers contents between uses. This method is recommended as it keeps the serial, opcode, and other fields correct.
(1) When a packet is received, call lwres_*request_parse() to unmarshall it. This returns a lwres_packet_t (also called pkt, below) as well as a data specific type, such as lwres_gabnrequest_t.
(2) Process the request in the data specific type.
(3) Set the pkt.result, pkt.recvlength as above. All other fields can be left untouched since they were filled in by the *_parse() call above. If using lwres_*response_render(), pkt.pktflags will be set up properly. Otherwise, the LWRES_LWPACKETFLAG_RESPONSE bit should be set.
(4) Call the data specific rendering function, such as lwres_gabnresponse_render().
(5) Send the resulting packet to the client.
"SEE ALSO"
lwres_gethostent(3), lwres_getipnode(3), lwres_getnameinfo(3), lwres_noop(3), lwres_gabn(3), lwres_gnba(3), lwres_context(3), lwres_config(3), resolver(5), lwresd(8).