QNetworkDatagram::setSender (Qt 5.13.1) not working on Windows 10
-
Hi
I have a small application as part of my MSc. that is receiving UDP packets from a requestor and essentially proxy'ing it out to the destination. The header of the UDP packet should get modified so that at the receiving end it sees the IP and port as the original values from the requestor so that we can reply directly back. I've been doing this currently by just modifying the sender field (setSender) in the QNetworkDatagram that we are sending but it would seem on Windows 10 that this doesn't do anything (the sender IP and port are still the middleman application and not the newly set values)? I haven't been able to find any existing issue like this so if there is a pre-existing post or weblink please fire it my way!
Below are some extracts of code snippets (Using Qt 5.13.1 libraries, building with MSCV 2019)
//UDP socket creation QUdpSocket* m_pSocket; m_pSocket = new QUdpSocket(); m_pSocket->setSocketOption(QAbstractSocket::KeepAliveOption, true); m_pSocket->bind(QHostAddress::AnyIPv4, m_uServerPortNumber, QAbstractSocket::BindFlag::DontShareAddress) ... // Sending a request out QNetworkDatagram DirectReq; DirectReq.setDestination(QHostAddress(strTargetIP.c_str()), uTargetPort); DirectReq.setData(QByteArray(strPayload.c_str())); DirectReq.setSender(QHostAddress(strBypassedSourceIP.c_str()), uBypassedSourcePort); int result = m_pSocket->writeDatagram(DirectReq); m_pSocket->flush();
-
@skblackbeard
the docs say:For outgoing datagrams, this function can be used to set the address the datagram should carry. The address address must usually be one of the local addresses assigned to this machine, which can be obtained using QNetworkInterface.
-
Furthermore, what you are attempting to do is rewriting the UDP packet headers to forge a different sender. It is by design that this is a privileged function, and not normally done by user programs. It is possible, but may be outside of the intent of the Qt API.
-
For outgoing datagrams, this function can be used to set the address the datagram should carry. The address address must usually be one of the local addresses assigned to this machine, which can be obtained using QNetworkInterface.
Sigh I found this shortly after posting.
It is possible, but may be outside of the intent of the Qt API.
It would definitely seem so.Thanks so much for the replies
-
@skblackbeard so is your issue solved? Please don't forget to mark your post as such!