- ResolvProtoResponse r(ResolvProtoResponse::R_A, 1500);
- r.ips.push_back(IPAddr("10.10.10.5"));
- r.ips.push_back(IPAddr("10.10.10.6"));
- return r;
+ if (!req_que.empty())
+ {
+ Dev::mac_type mac = 0;
+ ResolvProtoRequest req(req_que.receive(mac));
+#ifdef DEBUG_RESOLV
+ std::cout << "NameServer::send_loop() -> recibido " << req << "\n";
+#endif
+ ResolvProtoResponse res
+ = (req.query_type == RP_REQ_DIRECT)
+ ? resolv_direct(req.name)
+ : resolv_recursive(req.name);
+#ifdef DEBUG_RESOLV
+ std::cout << "NameServer::send_loop() -> respondo " << res << "\n";
+#endif
+ ipout.send(res, RESOLV_PROTO, IPAddr(mac));
+ }
+ else if (!snd_que.empty()) // Hay un request para enviar
+ {
+ Dev::mac_type mac = 0;
+ std::string buf = snd_que.receive(mac);
+#ifdef DEBUG_RESOLV
+ std::cout << "NameServer::send_loop() -> envío request "
+ << ResolvProtoRequest(buf) << "\n";
+#endif
+ ipout.send(buf, RESOLV_PROTO, IPAddr(mac));
+ }
+ else // No hay nada, esperamos un rato
+ {
+ usleep(10000);
+ }