ncsid: Import from gBMC
This is the initial code drop from gBMC.
Google-Bug-Id: 179618516
Upstream: 1e71af914bc8c54d8b91d0a1cf377e2696713c2f
Change-Id: Ic653e8271dacd205e04f2bc713071ef2ec5936a4
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/ncsid/test/net_iface_mock.cpp b/ncsid/test/net_iface_mock.cpp
new file mode 100644
index 0000000..4c72ef2
--- /dev/null
+++ b/ncsid/test/net_iface_mock.cpp
@@ -0,0 +1,38 @@
+#include "net_iface_mock.h"
+
+namespace mock
+{
+
+int IFace::bind_sock(int sockfd, struct sockaddr_ll*) const
+{
+ bound_socks.push_back(sockfd);
+ return 0;
+}
+
+int IFace::ioctl_sock(int, int request, struct ifreq* ifr) const
+{
+ return ioctl(request, ifr);
+}
+
+int IFace::ioctl(int request, struct ifreq* ifr) const
+{
+ int ret = 0;
+ switch (request)
+ {
+ case SIOCGIFINDEX:
+ ifr->ifr_ifindex = index;
+ break;
+ case SIOCGIFFLAGS:
+ ifr->ifr_flags = flags;
+ break;
+ case SIOCSIFFLAGS:
+ flags = ifr->ifr_flags;
+ break;
+ default:
+ ret = -1;
+ }
+
+ return ret;
+}
+
+} // namespace mock