Bug: UDP bind always fails — comboBoxNetworkIF populated with interface names but bind() expects IP address
- Dominant language
- C++
- Stars
- 552
- Forks
- 285
- Avg merge
- 9d 6h
- Merged PRs (30d)
- 5
Description
## Description
When configuring a UDP connection to receive DLT logs, the connection always fails with "Binding failed", regardless of the port or interface selected. The root cause is an inconsistency between how the network interface combo box is populated and how its value is consumed during bind().
## Root Cause
The ethIF field is documented as "identify interface via IP address" ([project.h#L113](https://github.com/COVESA/dlt-viewer/blob/master/src/project.h#L113)):
QString ethIF; /* needed for UDP multicast, identify interface via IP address */
However, EcuDialog::setNetworkIFList() populates the combo box with human-readable interface names (e.g. "以太网", "Ethernet", "WLAN") via humanReadableName() ([ecudialog.cpp#L313](https://github.com/COVESA/dlt-viewer/blob/master/src/ecudialog.cpp#L313)):
ui->comboBoxNetworkIF->addItem(interfaces[num].humanReadableName());
When connecting, the selected value is passed directly to QHostAddress() which expects an IP address string ([mainwindow.cpp#L4240-L4261](https://github.com/COVESA/dlt-viewer/blob/master/src/mainwindow.cpp#L4240-L4261)):
QString connectIPaddress = ecuitem->getEthIF(); // returns e.g. "以太网"
bindstate = ecuitem->socket->bind(QHostAddress(connectIPaddress), ecuitem->getUdpport(), QUdpSocket::ShareAddress);
// QHostAddress("以太网") → QHostAddress::Null → bind() fails
QHostAddress cannot parse a human-readable interface name, resulting in a null/invalid address and a guaranteed bind failure.
## Steps to Reproduce
### Open DLT Viewer
Add a new ECU → set Interface Type to UDP
Select any network interface from the "Receiving interface" dropdown
Set any UDP port (e.g. 1111 or the default 3490)
### Click Connect
Result: Binding failed
## Workaround
Manually type an IPv4 address (e.g. 192.168.1.100) or AnyIP into the "Receiving interface" combo box instead of selecting from the dropdown list.
## Suggested Fix
Either:
Option A: Change setNetworkIFList() to populate the combo box with IP addresses (consistent with MainWindow::getAvailableNetworkInterfaces() which already does this correctly), or
Option B: Keep the human-readable names for display, but resolve the selected interface name to its IP address before calling bind().
## Environment
DLT Viewer version: 2.30.0 unstable
OS: Windows 11 22H2
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with EcuDialog::setNetworkIFList() in ecudialog.cpp and compare it with MainWindow::getAvailableNetworkInterfaces(). Then trace the selected value through project.h and the bind path in mainwindow.cpp around lines 4240-4261. Done means selecting an interface from the dropdown supplies a valid address and UDP binding no longer fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100