33 memset(
static_cast<void *
>(&
_addr), 0,
sizeof(sockaddr_ll));
34 _addr.sll_family = AF_PACKET;
35 _addr.sll_protocol = htons(ETH_P_ALL);
36 _addr.sll_ifindex =
static_cast<int>(if_nametoindex(
_iFace.c_str()));
37 if (
_addr.sll_ifindex == 0)
39 throw std::ios_base::failure(std::string(
"Can't find interface: ") +
getErrnoString(errno));
44 memset(
static_cast<void *
>(&ifr), 0,
sizeof(ifreq));
45 memcpy(std::addressof(ifr.ifr_name),
_iFace.c_str(),
50 init(PF_PACKET, SOCK_RAW, IPPROTO_RAW);
51 if (setsockopt(
_sockFd, SOL_SOCKET, SO_BINDTODEVICE,
static_cast<void *
>(&ifr),
sizeof(ifr)) < 0)
53 throw std::ios_base::failure(std::string(
"Can't set socket options: ") +
getErrnoString(errno));
58 init(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));