Skip to content

Commit

Permalink
[core] Fix indentation and removed useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
yomnes0 committed Jan 8, 2024
1 parent 958dce4 commit fd5104b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
1 change: 0 additions & 1 deletion srtcore/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,6 @@ srt::EReadStatus srt::CChannel::recvfrom(sockaddr_any& w_addr, CPacket& w_packet
// the handshake and then addressed when sending during connection.
mh.msg_control = mh_crtl_buf;
mh.msg_controllen = (sizeof(mh_crtl_buf));

}
#endif

Expand Down
19 changes: 3 additions & 16 deletions srtcore/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,10 @@ class CChannel
cmsghdr hdr;
};

// This is 'mutable' because it's a utility buffer defined here
// to avoid unnecessary re-allocations.
// SRT_ATR_ALIGNAS(8) mutable char m_acCmsgRecvBuffer [sizeof (CMSGNodeIPv4) + sizeof (CMSGNodeIPv6)]; // Reserved space for ancillary data with pktinfo
// SRT_ATR_ALIGNAS(8) mutable char m_acCmsgSendBuffer [sizeof (CMSGNodeIPv4) + sizeof (CMSGNodeIPv6)]; // Reserved space for ancillary data with pktinfo

union m_acCmsgSendBufferv6 {
//char buf[CMSG_SPACE(sizeof(struct in6_pktinfo) + sizeof(struct in_pktinfo) + 2*sizeof(cmsghdr))];
char buf[sizeof(CMSGNodeIPv4) + sizeof(CMSGNodeIPv6)];
//struct cmsghdr align;
} ;

sockaddr_any getTargetAddress(const msghdr& msg) const
{
// Loop through IP header messages
cmsghdr* cmsg;// = CMSG_FIRSTHDR(&msg);
cmsghdr* cmsg;
for (cmsg = CMSG_FIRSTHDR(&msg);
cmsg != NULL;
cmsg = CMSG_NXTHDR(((msghdr*)&msg), cmsg))
Expand Down Expand Up @@ -264,12 +253,9 @@ class CChannel

if (adr.family() == AF_INET)
{


mh.msg_control = (void *) buf;
mh.msg_controllen = sizeof(struct in_pktinfo) + sizeof(cmsghdr);


cmsghdr* cmsg_send = CMSG_FIRSTHDR(&mh);
// after initializing msghdr & control data to CMSG_SPACE(sizeof(struct in_pktinfo))
cmsg_send->cmsg_level = IPPROTO_IP;
Expand All @@ -288,11 +274,12 @@ class CChannel
{
mh.msg_control = buf;
mh.msg_controllen = sizeof(struct in6_pktinfo) + sizeof(cmsghdr);
cmsghdr* cmsg_send = CMSG_FIRSTHDR(&mh);

cmsghdr* cmsg_send = CMSG_FIRSTHDR(&mh);
cmsg_send->cmsg_level = IPPROTO_IPV6;
cmsg_send->cmsg_type = IPV6_PKTINFO;
cmsg_send->cmsg_len = CMSG_LEN(sizeof(in6_pktinfo));

in6_pktinfo* pktinfo = (in6_pktinfo*) CMSG_DATA(cmsg_send);
pktinfo->ipi6_ifindex = 0;
pktinfo->ipi6_addr = adr.sin6.sin6_addr;
Expand Down

0 comments on commit fd5104b

Please sign in to comment.