ethvlans

package
v0.0.0-...-5c98b36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2022 License: MulanPSL-2.0 Imports: 5 Imported by: 0

README

ethvlans 描述交换机端口的 VLAN 范围

交换机端口的VLAN描述规则一般为 1-10,500,100-2000,此包就是为了生成和解析这样的字符串的。

因为vlan的范围是 1-4094,所以此包自动忽略小于1和大于4094的数字。

Documentation

Overview

Package ethvlans 用于描述以太网交换机端口的 VLAN 范围

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EthVLANs

type EthVLANs map[int]empty.T

EthVLANs

func New

func New(vlans ...int) EthVLANs

New 创建一个 EthVLANs 实例 取值范围是 1-4094,在以太网帧中占位 12 比特

func Parse

func Parse(s string) EthVLANs

Parse 解析字符串表示的 VLAN 范围 格式:"1-100,102,500-520"

func (EthVLANs) Add

func (v EthVLANs) Add(vlans ...int)

Add 添加 VLANs 自动忽略小于 0 和大于 4094 的值

func (EthVLANs) AddFromParse

func (v EthVLANs) AddFromParse(s string) error

AddFromParse 从字符串中添加 VLAN

func (EthVLANs) IsExist

func (v EthVLANs) IsExist(vlan int) bool

IsExist 判断是否包含某个vlan

func (EthVLANs) Len

func (v EthVLANs) Len() int

Len 返回vlan的数量

func (EthVLANs) MarshalJSON

func (v EthVLANs) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (EthVLANs) Slice

func (v EthVLANs) Slice() []int

Slice 返回一个排序后的切片

func (EthVLANs) String

func (v EthVLANs) String() string

String 格式化为字符串

func (EthVLANs) UnmarshalJSON

func (v EthVLANs) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL