russelltg/srt-rs

ipv6 support

lu-zero opened this issue · 3 comments

I saw that the current master has at least a TODO about it in srt-protocol/src/packet/control.rs:

                // TODO: this is probably really wrong, so fix it
                let peer_addr = if ip_buf[4..] == [0; 12][..] {
                    IpAddr::from(Ipv4Addr::new(ip_buf[3], ip_buf[2], ip_buf[1], ip_buf[0]))
                } else {
                    IpAddr::from(ip_buf)
                };

Is there anything else to be addressed?

Yeah, so I'm pretty sure the "correct" way to do this the packet needs to know if it's being send/received from an ipv6 socket, so it will require a bit of reorganization (right now it just "guesses" by the lower bytes in the ipv6 address)

For anyone who would want to take this issue:

  • Look at the reference implementation's treatment of this, make sure my assumption is correct
  • Allow packet parsing to know if it's IPV4 or IPV6 (or, alternatively, just store the IP buffer in the packet and rely on the implementation to know), I'm willing to be convinced either way. I'd prefer the first if it's not too messy, to keep the packet structure "pure"
  • Add tests using IPv6

I can confirm that the it seem so:

// in srtcore/core.cpp
    CIPAddress::pton((m_parent->m_SelfAddr), m_piSelfIP, agent.family(), peer);