Skip to content

Commit

Permalink
[core] Moved mh_crtl_buf declaration to the correct place.
Browse files Browse the repository at this point in the history
  • Loading branch information
yomnes0 committed Jan 9, 2024
1 parent fd5104b commit 009ee89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions srtcore/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,12 @@ int srt::CChannel::sendto(const sockaddr_any& addr, CPacket& packet, const socka
mh.msg_iov = (iovec*)packet.m_PacketVector;
mh.msg_iovlen = 2;
bool have_set_src = false;
char mh_crtl_buf[sizeof(CMSGNodeIPv4) + sizeof(CMSGNodeIPv6)];

#ifdef SRT_ENABLE_PKTINFO

// Note that even if PKTINFO is desired, the first caller's packet will be sent
// without ancillary info anyway because there's no "peer" yet to know where to send it.
char mh_crtl_buf[sizeof(CMSGNodeIPv4) + sizeof(CMSGNodeIPv6)];
if (m_bBindMasked && source_addr.family() != AF_UNSPEC && !source_addr.isany())
{
if (!setSourceAddress(mh, mh_crtl_buf, source_addr))
Expand Down Expand Up @@ -848,7 +848,6 @@ srt::EReadStatus srt::CChannel::recvfrom(sockaddr_any& w_addr, CPacket& w_packet

#ifndef _WIN32
msghdr mh; // will not be used on failure
char mh_crtl_buf[sizeof(CMSGNodeIPv4) + sizeof(CMSGNodeIPv6)];

if (select_ret > 0)
{
Expand All @@ -864,6 +863,7 @@ srt::EReadStatus srt::CChannel::recvfrom(sockaddr_any& w_addr, CPacket& w_packet
#ifdef SRT_ENABLE_PKTINFO
// Without m_bBindMasked, we don't need ancillary data - the source
// address will always be the bound address.
char mh_crtl_buf[sizeof(CMSGNodeIPv4) + sizeof(CMSGNodeIPv6)];
if (m_bBindMasked)
{
// Extract the destination IP address from the ancillary
Expand Down
4 changes: 2 additions & 2 deletions srtcore/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,14 @@ class CChannel
// IPv4 headers or IPv6 headers.
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO)
{
in_pktinfo dest_ip_ptr;// = (in_pktinfo*)CMSG_DATA(cmsg);
in_pktinfo dest_ip_ptr;
memcpy(&dest_ip_ptr, CMSG_DATA(cmsg), sizeof(struct in_pktinfo));
return sockaddr_any(dest_ip_ptr.ipi_addr, 0);
}

if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO)
{
in6_pktinfo dest_ip_ptr;// = (in6_pktinfo*)CMSG_DATA(cmsg);
in6_pktinfo dest_ip_ptr;
memcpy(&dest_ip_ptr, CMSG_DATA(cmsg), sizeof(struct in6_pktinfo));
return sockaddr_any(dest_ip_ptr.ipi6_addr, 0);
}
Expand Down

0 comments on commit 009ee89

Please sign in to comment.