1#!/usr/bin/env python3 2# 3# Copyright 2019 - The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17from acts.controllers.fuchsia_lib.base_lib import BaseLib 18 19 20class FuchsiaNetstackLib(BaseLib): 21 22 def __init__(self, addr: str) -> None: 23 super().__init__(addr, "netstack") 24 25 def netstackListInterfaces(self): 26 """ListInterfaces command 27 28 Returns: 29 List of interface paths 30 """ 31 test_cmd = "netstack_facade.ListInterfaces" 32 test_args = {} 33 34 return self.send_command(test_cmd, test_args) 35 36 def enableInterface(self, id): 37 """Enable Interface 38 39 Args: 40 id: The interface ID. 41 42 Returns: 43 Dictionary, None if success, error if error. 44 """ 45 test_cmd = "netstack_facade.EnableInterface" 46 test_args = {"identifier": id} 47 48 return self.send_command(test_cmd, test_args) 49 50 def disableInterface(self, id): 51 """Disable Interface 52 53 Args: 54 id: The interface ID. 55 56 Returns: 57 Dictionary, None if success, error if error. 58 """ 59 test_cmd = "netstack_facade.DisableInterface" 60 test_args = {"identifier": id} 61 62 return self.send_command(test_cmd, test_args) 63