• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
19class FuchsiaNetstackLib(BaseLib):
20    def __init__(self, addr, tc, client_id):
21        self.address = addr
22        self.test_counter = tc
23        self.client_id = client_id
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        test_id = self.build_id(self.test_counter)
34        self.test_counter += 1
35
36        return self.send_command(test_id, test_cmd, test_args)
37
38    def init(self):
39        """ListInterfaces command
40
41        Returns:
42            Dictionary, None if success, error if error.
43        """
44        test_cmd = "netstack_facade.InitNetstack"
45        test_args = {}
46        test_id = self.build_id(self.test_counter)
47        self.test_counter += 1
48
49        return self.send_command(test_id, test_cmd, test_args)
50
51    def getInterfaceInfo(self, id):
52        """Get interface info.
53
54        Args:
55            id: The interface ID.
56
57        Returns:
58            Dictionary, None if success, error if error.
59        """
60        test_cmd = "netstack_facade.GetInterfaceInfo"
61        test_args = {
62            "identifier": id
63        }
64        test_id = self.build_id(self.test_counter)
65        self.test_counter += 1
66
67        return self.send_command(test_id, test_cmd, test_args)
68
69    def enableInterface(self, id):
70        """Enable Interface
71
72        Args:
73            id: The interface ID.
74
75        Returns:
76            Dictionary, None if success, error if error.
77        """
78        test_cmd = "netstack_facade.EnableInterface"
79        test_args = {
80            "identifier": id
81        }
82        test_id = self.build_id(self.test_counter)
83        self.test_counter += 1
84
85        return self.send_command(test_id, test_cmd, test_args)
86
87    def disableInterface(self, id):
88        """Disable Interface
89
90        Args:
91            id: The interface ID.
92
93        Returns:
94            Dictionary, None if success, error if error.
95        """
96        test_cmd = "netstack_facade.DisableInterface"
97        test_args = {
98            "identifier": id
99        }
100        test_id = self.build_id(self.test_counter)
101        self.test_counter += 1
102
103        return self.send_command(test_id, test_cmd, test_args)
104
105