net: samples: Fix packet socket sample iface index

Patch (3206568e43) changed network
interface numbering starts from 1. The index 0 is reserved.
So use api to get default interface index for packet socket sample.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This commit is contained in:
Ravi kumar Veeramally 2019-03-11 12:11:07 +02:00 committed by Andrew Boie
parent d042d628b6
commit 718dd56d38

View file

@ -77,7 +77,7 @@ static int start_packet_socket(void)
return -errno;
}
dst.sll_ifindex = 0;
dst.sll_ifindex = net_if_get_by_iface(net_if_get_default());
dst.sll_family = AF_PACKET;
ret = bind(packet.sock, (const struct sockaddr *)&dst,
@ -102,7 +102,7 @@ static void send_packet(void)
u8_t send = 100;
int ret;
dst.sll_ifindex = 0;
dst.sll_ifindex = net_if_get_by_iface(net_if_get_default());
/* Sending dummy data */
ret = sendto(packet.sock, lorem_ipsum, send, 0,