blob: c73ecb18135ed5b571c5bcaa4f91bc9c150ec834 [file] [log] [blame]
Zack Williams9731cdc2019-11-22 15:42:30 -07001# Copyright 2017-present Open Networking Foundation
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"""
15Common utility functions
16"""
17
18from loxi.pp import PrettyPrinter
19
Andrea Campanella4461a582020-02-20 15:05:19 +010020# ReservedVlan Transparent Vlan (Masked Vlan, VLAN_ANY in ONOS Flows)
21
22RESERVED_TRANSPARENT_VLAN = 4096
Zack Williams9731cdc2019-11-22 15:42:30 -070023
24def pp(obj):
25 pp = PrettyPrinter(maxwidth=80)
26 pp.pp(obj)
27 return str(pp)
28
29def mac_str_to_tuple(mac):
30 """
31 Convert 'xx:xx:xx:xx:xx:xx' MAC address string to a tuple of integers.
32 Example: mac_str_to_tuple('00:01:02:03:04:05') == (0, 1, 2, 3, 4, 5)
33 """
34 return tuple(int(d, 16) for d in mac.split(':'))