blob: 4c72ef2590a0cef7e6ba855aa71cd68a4c9d188d [file] [log] [blame]
William A. Kennington III7d6fa422021-02-08 17:04:02 -08001#include "net_iface_mock.h"
2
3namespace mock
4{
5
6int IFace::bind_sock(int sockfd, struct sockaddr_ll*) const
7{
8 bound_socks.push_back(sockfd);
9 return 0;
10}
11
12int IFace::ioctl_sock(int, int request, struct ifreq* ifr) const
13{
14 return ioctl(request, ifr);
15}
16
17int IFace::ioctl(int request, struct ifreq* ifr) const
18{
19 int ret = 0;
20 switch (request)
21 {
22 case SIOCGIFINDEX:
23 ifr->ifr_ifindex = index;
24 break;
25 case SIOCGIFFLAGS:
26 ifr->ifr_flags = flags;
27 break;
28 case SIOCSIFFLAGS:
29 flags = ifr->ifr_flags;
30 break;
31 default:
32 ret = -1;
33 }
34
35 return ret;
36}
37
38} // namespace mock