Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,12 @@ void ContextImpl::tickSearch(SearchKind kind, bool poked)
// flags and reserved.
// initially flags[7] is cleared (bcast)
auto pflags = M.save();
to_wire(M, uint8_t(kind == SearchKind::discover ?
pva_search_flags::MustReply : 0u)); // must-reply to discovery, ignore regular negative search
to_wire(M, uint8_t(
// must-reply to discovery, ignore regular negative search
(kind == SearchKind::discover ? pva_search_flags::MustReply : 0u)
| pva_search_flags::ReplySrcPort
)
);
to_wire(M, uint8_t(0u));
to_wire(M, uint16_t(0u));

Expand Down
5 changes: 3 additions & 2 deletions src/pvaproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ void from_wire(Buffer& buf, shared_array<const void>& varr)

struct pva_version {
enum {
client = 2,
server = 2,
client = 3,
server = 3,
};
};

Expand Down Expand Up @@ -643,6 +643,7 @@ enum pva_app_msg_t : uint8_t {
struct pva_search_flags {
enum type_t : uint8_t {
MustReply = 0x01,
ReplySrcPort = 0x02,
Unicast = 0x80,
};
};
Expand Down
10 changes: 9 additions & 1 deletion src/udp_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ void UDPCollector::process_one(const uint8_t *buf, size_t nrx, origin_t origin,
} else {
replyDest = server;
}
if((origin==Broadcast || origin==Forwarding)
&& peerVersion >= 3
&& (flags&pva_search_flags::ReplySrcPort))
{
// peer requests reply to (apparent) sender port
port = origSrc.port();
}
replyDest.setPort(port);

if(!M.good())
Expand All @@ -391,8 +398,9 @@ void UDPCollector::process_one(const uint8_t *buf, size_t nrx, origin_t origin,
*save_flags &= ~pva_search_flags::Unicast;
// recipient of forwarded message must use, and trust, replyAddr in body :(
{
FixedBuf R(M.be, save_replyAddr, 16u);
FixedBuf R(M.be, save_replyAddr, 16u + 2u);
to_wire(R, replyDest);
to_wire(R, port);
assert(R.good());
}
forwardM(buf, nrx);
Expand Down
Loading