swos_client

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

This is a library to interact with Mikrotik managed switches running SwOS

There is no official documentation for this API so it may not work for other versions or hardware.

It was tested with CSS106-1G-4P-1S running SwOs 2.18

Current status of implementation:

Page in UI Page in API Status
Link LinkPage (link.b) Implemented
System SysPage (sys.b) Implemented
SFP SfpPage (sfp.b) Implemented
RSTP SysPage (sfp.b) Implemented
RSTP RstpPage (rstp.b) Implemented
Forwarding FwdPage (fwd.b) Implemented
VLAN FwdPage (fwd.b) Implemented
VLANs VlanPage (vlan.b) Implemented
Hosts HostPage (host.b) Missing
Hosts HostPage (!dhost.b) Missing
IGMP Groups IgmpPage (!igmp.b) Missing
SNMP SnpPage (!snmp.b) Missing
ACL AclPage (!acl.b) Missing
Statistics StatsPage (!stats.b) Missing
Errors StatsPage (!stats.b) Missing

Status description:

  • Missing - No implementation
  • Implemented - Implemented but not tested
  • Complete - Tested and documented

Documentation

Index

Constants

View Source
const (
	VlanModeDisabled VlanMode = 0
	VlanModeOptional          = 1
	VlanModeEnabled           = 2
	VlanModeStrict            = 2
)
View Source
const (
	VlanHeaderLeaveAsIs  VlanHeader = 0
	VlanHeaderStrip                 = 1
	VlanHeaderAddMissing            = 2
)
View Source
const (
	VlanReceiveAny      VlanReceive = 0
	VlanReceiveTagged               = 1
	VlanReceiveUntagged             = 2
)
View Source
const (
	Off   PoeMode = 0
	Auto          = 1
	On            = 2
	Calib         = 3
)
View Source
const (
	Unavailable    PoeStatus = 0
	Disabled                 = 1
	WaitingForLoad           = 2
	Active                   = 3
)
View Source
const (
	VlanPortModeLeaveAsIs    VlanPortMode = 0
	VlanPortModeAlwaysStrip               = 1
	VlanPortModeAddIfMissing              = 2
	VlanPortModeNotAMember                = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FwdPage

type FwdPage struct {
	PortForward []PortForward
	MirrorTo    int
	// contains filtered or unexported fields
}
type Link struct {
	Name            string
	Enabled         bool
	LinkUp          bool
	Duplex          bool
	DuplexControl   bool
	FlowControl     bool
	AutoNegotiation bool
	PoeMode         PoeMode
	PoePrio         int
	PoeStatus       PoeStatus
	SpeedControl    int
	Power           int
	Current         int
}

type LinkPage

type LinkPage struct {
	Links []*Link
}

type PoeMode

type PoeMode int

type PoeStatus

type PoeStatus int

type PortForward added in v0.0.2

type PortForward struct {
	PortLock      bool
	LockOnFirst   bool
	MirrorIngress bool
	MirrorEgress  bool
	ForwardTable  []bool
	VlanMode      VlanMode
	ForceVlanId   bool
	VlanHeader    VlanHeader
	DefaultVlanId int
	VlanReceive   VlanReceive
	EgressRate    int
}

type RstpPage

type RstpPage struct {
	RstpEnabled   []bool
	Mode          int
	Role          []int
	RootPathCoast []int
	Type          []int
	State         int
	// contains filtered or unexported fields
}

type SfpPage

type SfpPage struct {
	Vendor      string
	PartNumber  string
	Revision    string
	Serial      string
	Date        string
	Type        string
	Temperature int
	Voltage     int
	TxBias      int
	TxPower     int
	RxPower     int
}

type SwOsClient

type SwOsClient struct {
	Links LinkPage
	Sfp   SfpPage
	Sys   SysPage
	Rstp  RstpPage
	Fwd   FwdPage
	Vlan  VlanPage
	// contains filtered or unexported fields
}

func NewSwOsClient

func NewSwOsClient(url string, user string, password string) (*SwOsClient, error)

func (*SwOsClient) Fetch

func (client *SwOsClient) Fetch() error

func (*SwOsClient) Save

func (client *SwOsClient) Save() error

type SysPage

type SysPage struct {
	Mac                       net.HardwareAddr
	SerialNumber              string
	Identity                  string
	Version                   string
	BoardName                 string
	RootBridgeMac             net.HardwareAddr
	Uptime                    int64
	Ip                        net.IP
	Build                     int // FIXME: wtf?
	Dsc                       int // FIXME: wtf?
	Wdt                       int // FIXME: wtf?
	MikrotikDiscoveryProtocol []bool
	IndependentVlanLookup     bool
	AllowFrom                 net.IP
	Allm                      int // WTF
	AllowFromPorts            []bool
	AllowFromVlan             int
	IgmpSnooping              bool
	IgmpQuerier               bool
	LongPoeCable              bool
	IgmpFastLeave             []bool
	IgmpVersion               int //TODO: enum
	Voltage                   int
	Temperature               int
	BridgePriority            int
	PortCostMode              int //TODO: enum
	ForwardReservedMulticast  bool
	AddressAquisition         int // TODO: enum 0 dhcp+fb, 1 static, 2 dhcp only
	StaticIpAddress           net.IP
	// contains filtered or unexported fields
}

type Vlan

type Vlan struct {
	Id                    int
	IndependentVlanLookup bool
	IgmpSnooping          bool
	PortMode              []VlanPortMode
}

type VlanHeader

type VlanHeader int

type VlanMode

type VlanMode int

type VlanPage

type VlanPage struct {
	Vlans []Vlan
	// contains filtered or unexported fields
}

func (*VlanPage) AddVlan

func (v *VlanPage) AddVlan(id int) (*Vlan, error)

func (*VlanPage) DeleteVlan

func (v *VlanPage) DeleteVlan(id int)

func (*VlanPage) GetVlan

func (v *VlanPage) GetVlan(id int) (*Vlan, error)

type VlanPortMode

type VlanPortMode int

type VlanReceive

type VlanReceive int

Jump to

Keyboard shortcuts

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