diff --git a/include/lokinet/lokinet_udp.h b/include/lokinet/lokinet_udp.h index 7c73e8049..b6a1ca955 100644 --- a/include/lokinet/lokinet_udp.h +++ b/include/lokinet/lokinet_udp.h @@ -50,8 +50,10 @@ extern "C" /// if srv is not NULL add an srv record for this port, the format being "thingservice" in which /// will add a srv record "_udp.thingservice.ouraddress.tld" that advertises this port provide /// localAddr to forward inbound udp packets to "ip:port" if localAddr is NULL then the resulting - /// socket MUST be drained by lokinet_udp_recvmmsg returns 0 on success returns nonzero on error - /// in which it is an errno value + /// socket MUST be drained by lokinet_udp_recvmmsg + /// + /// returns 0 on success + /// returns nonzero on error in which it is an errno value int lokinet_udp_bind( int exposedPort, @@ -61,10 +63,15 @@ extern "C" struct lokinet_context* ctx); /// poll many udp sockets for activity - /// each pollfd.fd should be set to the udp socket id /// returns 0 on sucess + /// + /// returns non zero errno on error int - lokinet_udp_poll(struct pollfd* poll, nfds_t numsockets, struct lokinet_context* ctx); + lokinet_udp_poll( + const int* socket_ids, + size_t numsockets, + const struct timespec* timeout, + struct lokinet_context* ctx); struct lokinet_udp_pkt { @@ -76,7 +83,10 @@ extern "C" /// analog to recvmmsg ssize_t lokinet_udp_recvmmsg( - int socket_id, struct lokinet_udp_pkt* pkts, size_t numevents, struct lokient_context* ctx); + int socket_id, + struct lokinet_udp_pkt* events, + size_t max_events, + struct lokient_context* ctx); #ifdef __cplusplus } diff --git a/llarp/lokinet_shared.cpp b/llarp/lokinet_shared.cpp index 03244e4b5..835133e41 100644 --- a/llarp/lokinet_shared.cpp +++ b/llarp/lokinet_shared.cpp @@ -126,13 +126,13 @@ namespace return -1; } - lokinet_srv_record + std::optional SRVFromData(const llarp::dns::SRVData& data, std::string name) { // TODO: implement me (void)data; (void)name; - return {}; + return std::nullopt; } } // namespace @@ -157,10 +157,11 @@ struct lokinet_srv_lookup_private return; } ep->LookupServiceAsync(host, service, [self, &promise, host](auto results) { - // for (const auto& result : results) - // { - // self->results.emplace_back(SRVFromData(result, host)); - // } + for (const auto& result : results) + { + if (auto maybe = SRVFromData(result, host)) + self->results.emplace_back(*maybe); + } promise.set_value(0); }); });