samples: net: echo-server: Make sure to attach to correct tunnel
If there are multiple tunnels, then use the tunnel device name to select the correct one. Note that this tunnel is only used for network packet capture in this sample application. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
7fdebb5a91
commit
76290b052f
1 changed files with 8 additions and 1 deletions
|
@ -21,7 +21,9 @@ struct ud {
|
|||
|
||||
bool is_tunnel(struct net_if *iface)
|
||||
{
|
||||
if (net_if_l2(iface) == &NET_L2_GET_NAME(VIRTUAL)) {
|
||||
if (net_if_l2(iface) == &NET_L2_GET_NAME(VIRTUAL) &&
|
||||
strncmp(net_if_get_device(iface)->name, "IP_TUNNEL0",
|
||||
strlen(net_if_get_device(iface)->name)) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -134,6 +136,11 @@ int init_tunnel(void)
|
|||
|
||||
net_if_foreach(iface_cb, &ud);
|
||||
|
||||
if (ud.tunnel == NULL) {
|
||||
LOG_ERR("Tunnel interface not found.");
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ret = net_mgmt(NET_REQUEST_VIRTUAL_INTERFACE_SET_PEER_ADDRESS,
|
||||
ud.tunnel, ¶ms, sizeof(params));
|
||||
if (ret < 0 && ret != -ENOTSUP) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue