From fd5104b0dcd550f11d6eee29873f81cb5117da3e Mon Sep 17 00:00:00 2001 From: yomnes0 Date: Mon, 8 Jan 2024 10:34:50 +0100 Subject: [PATCH] [core] Fix indentation and removed useless code --- srtcore/channel.cpp | 1 - srtcore/channel.h | 19 +++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/srtcore/channel.cpp b/srtcore/channel.cpp index f0ab6d8e6..7631a2d14 100644 --- a/srtcore/channel.cpp +++ b/srtcore/channel.cpp @@ -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 diff --git a/srtcore/channel.h b/srtcore/channel.h index a0e948d33..a74914535 100644 --- a/srtcore/channel.h +++ b/srtcore/channel.h @@ -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)) @@ -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; @@ -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;