1 #include "net_iface_mock.h" 2 3 namespace mock 4 { 5 6 int IFace::bind_sock(int sockfd, struct sockaddr_ll*) const 7 { 8 bound_socks.push_back(sockfd); 9 return 0; 10 } 11 12 int IFace::ioctl_sock(int, int request, struct ifreq* ifr) const 13 { 14 return ioctl(request, ifr); 15 } 16 17 int 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 39