Brandon Kim | dab96f1 | 2021-02-18 11:21:37 -0800 | [diff] [blame^] | 1 | // Copyright 2021 Google LLC |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
William A. Kennington III | 7d6fa42 | 2021-02-08 17:04:02 -0800 | [diff] [blame] | 15 | #include "net_iface_mock.h" |
| 16 | |
| 17 | namespace mock |
| 18 | { |
| 19 | |
| 20 | int IFace::bind_sock(int sockfd, struct sockaddr_ll*) const |
| 21 | { |
| 22 | bound_socks.push_back(sockfd); |
| 23 | return 0; |
| 24 | } |
| 25 | |
| 26 | int IFace::ioctl_sock(int, int request, struct ifreq* ifr) const |
| 27 | { |
| 28 | return ioctl(request, ifr); |
| 29 | } |
| 30 | |
| 31 | int IFace::ioctl(int request, struct ifreq* ifr) const |
| 32 | { |
| 33 | int ret = 0; |
| 34 | switch (request) |
| 35 | { |
| 36 | case SIOCGIFINDEX: |
| 37 | ifr->ifr_ifindex = index; |
| 38 | break; |
| 39 | case SIOCGIFFLAGS: |
| 40 | ifr->ifr_flags = flags; |
| 41 | break; |
| 42 | case SIOCSIFFLAGS: |
| 43 | flags = ifr->ifr_flags; |
| 44 | break; |
| 45 | default: |
| 46 | ret = -1; |
| 47 | } |
| 48 | |
| 49 | return ret; |
| 50 | } |
| 51 | |
| 52 | } // namespace mock |