mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
fix: encode ip in network byte order for udp announce (#6126)
This commit is contained in:
@@ -160,35 +160,32 @@ public:
|
||||
|
||||
void add_uint16(uint16_t hs)
|
||||
{
|
||||
uint16_t const ns = htons(hs);
|
||||
add(&ns, sizeof(ns));
|
||||
add_uint16_n(htons(hs));
|
||||
}
|
||||
|
||||
void add_hton16(uint16_t hs)
|
||||
void add_uint16_n(uint16_t ns)
|
||||
{
|
||||
add_uint16(hs);
|
||||
add(&ns, sizeof(ns));
|
||||
}
|
||||
|
||||
void add_uint32(uint32_t hl)
|
||||
{
|
||||
uint32_t const nl = htonl(hl);
|
||||
add(&nl, sizeof(nl));
|
||||
add_uint32_n(htonl(hl));
|
||||
}
|
||||
|
||||
void eadd_hton32(uint32_t hl)
|
||||
void add_uint32_n(uint32_t nl)
|
||||
{
|
||||
add_uint32(hl);
|
||||
add(&nl, sizeof(nl));
|
||||
}
|
||||
|
||||
void add_uint64(uint64_t hll)
|
||||
{
|
||||
uint64_t const nll = tr_htonll(hll);
|
||||
add(&nll, sizeof(nll));
|
||||
add_uint64_n(tr_htonll(hll));
|
||||
}
|
||||
|
||||
void add_hton64(uint64_t hll)
|
||||
void add_uint64_n(uint64_t nll)
|
||||
{
|
||||
add_uint64(hll);
|
||||
add(&nll, sizeof(nll));
|
||||
}
|
||||
|
||||
void add_port(tr_port port)
|
||||
@@ -197,6 +194,22 @@ public:
|
||||
add(&nport, sizeof(nport));
|
||||
}
|
||||
|
||||
void add_address(tr_address const& addr)
|
||||
{
|
||||
switch (addr.type)
|
||||
{
|
||||
case TR_AF_INET:
|
||||
add(&addr.addr.addr4.s_addr, sizeof(addr.addr.addr4.s_addr));
|
||||
break;
|
||||
case TR_AF_INET6:
|
||||
add(&addr.addr.addr6.s6_addr, sizeof(addr.addr.addr6.s6_addr));
|
||||
break;
|
||||
default:
|
||||
TR_ASSERT_MSG(false, "invalid type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
size_t add_socket(tr_socket_t sockfd, size_t n_bytes, tr_error** error = nullptr)
|
||||
{
|
||||
auto const [buf, buflen] = reserve_space(n_bytes);
|
||||
|
||||
Reference in New Issue
Block a user