_switch

package
v0.0.0-...-04092ee Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DhcpBin = "dnsmasq"
	DhcpDir = "/var/openlan/dhcp"
)
View Source
const (
	TLsToTun     = 2  // From a switch include border to tunnels.
	TTunToLs     = 4  // From tunnels to a switch.
	TSourceLearn = 10 // Learning source mac.
	TUcastToTun  = 20 // Forwarding by fdb.
	TFloodToTun  = 30 // Flooding to tunnels or patch by flags.
	TFloodToBor  = 31 // Flooding to border in a switch.
	TFloodLoop   = 32 // Flooding to patch in a switch from border.
)
View Source
const (
	FFromLs  = 2 // In a logical switch.
	FFromTun = 4 // From peer tunnels.
)
View Source
const (
	MatchRegFlag = "reg10"
	NxmRegFlag   = "NXM_NX_REG10[0..31]"
	NxmRegEthDst = "NXM_OF_ETH_DST[]"
	NxmRegEthSrc = "NXM_OF_ETH_SRC[]"
	NxmRegTunId  = "NXM_NX_TUN_ID[0..31]"
	NxmRegInPort = "NXM_OF_IN_PORT[]"
)
View Source
const (
	L2TPBin = "xl2tpd"
	L2TPDir = "/var/openlan/l2tp"
)
View Source
const (
	OlapBin = "openlan-point"
	OlapDir = "/var/openlan/point"
)
View Source
const (
	OpenVPNBin    = "openvpn"
	DefaultCurDir = "/var/openlan/openvpn/default"
)
View Source
const (
	UDPBin = "openudp"
)

Variables

This section is empty.

Functions

func GetRoutes

func GetRoutes(result *[]database.PrefixRoute, device string) error

func GetSocketServer

func GetSocketServer(s *co.Switch) libol.SocketServer

func GetStateEncap

func GetStateEncap(mode string, sport, dport int) *nl.XfrmStateEncap

func ListWorker

func ListWorker(call func(w Networker))

func PeerName

func PeerName(name, prefix string) (string, string)

Types

type Apps

type Apps struct {
	Auth     *app.Access
	Request  *app.Request
	Neighbor *app.Neighbors
	OnLines  *app.Online
}

type ConfD

type ConfD struct {
	// contains filtered or unexported fields
}

func NewConfd

func NewConfd(api api.Switcher) *ConfD

func (*ConfD) Add

func (c *ConfD) Add(table string, model model.Model)
func (c *ConfD) AddLink(obj *database.VirtualLink)

func (*ConfD) AddRoute

func (c *ConfD) AddRoute(obj *database.PrefixRoute)
func (c *ConfD) DelLink(obj *database.VirtualLink)

func (*ConfD) DelRoute

func (c *ConfD) DelRoute(obj *database.PrefixRoute)

func (*ConfD) Delete

func (c *ConfD) Delete(table string, model model.Model)
func (c *ConfD) DiffLink(old *database.VirtualLink, new *database.VirtualLink) bool

func (*ConfD) Initialize

func (c *ConfD) Initialize()

func (*ConfD) Start

func (c *ConfD) Start()

func (*ConfD) Stop

func (c *ConfD) Stop()

func (*ConfD) Update

func (c *ConfD) Update(table string, old model.Model, new model.Model)

func (*ConfD) UpdateName

func (c *ConfD) UpdateName(obj *database.NameCache)

type Dhcp

type Dhcp struct {
	// contains filtered or unexported fields
}

func NewDhcp

func NewDhcp(cfg *co.Dhcp) *Dhcp

func (*Dhcp) Clean

func (d *Dhcp) Clean()

func (*Dhcp) Conf

func (d *Dhcp) Conf() *co.Dhcp

func (*Dhcp) ConfFile

func (d *Dhcp) ConfFile() string

func (*Dhcp) Initialize

func (d *Dhcp) Initialize()

func (*Dhcp) LeaseFile

func (d *Dhcp) LeaseFile() string

func (*Dhcp) LogFile

func (d *Dhcp) LogFile() string

func (*Dhcp) Path

func (d *Dhcp) Path() string

func (*Dhcp) PidFile

func (d *Dhcp) PidFile() string

func (*Dhcp) SaveConf

func (d *Dhcp) SaveConf()

func (*Dhcp) Start

func (d *Dhcp) Start()

func (*Dhcp) Stop

func (d *Dhcp) Stop()

func (*Dhcp) Tmpl

func (d *Dhcp) Tmpl() string

func (*Dhcp) UUID

func (d *Dhcp) UUID() string

type EspWorker

type EspWorker struct {
	*WorkerImpl
	// contains filtered or unexported fields
}

func NewESPWorker

func NewESPWorker(c *co.Network) *EspWorker

func (*EspWorker) AddRoute

func (w *EspWorker) AddRoute(device, src, remote string) error

func (*EspWorker) DownDummy

func (w *EspWorker) DownDummy(name string) error

func (*EspWorker) Initialize

func (w *EspWorker) Initialize()

func (*EspWorker) Reload

func (w *EspWorker) Reload(v api.Switcher)

func (*EspWorker) Start

func (w *EspWorker) Start(v api.Switcher)

func (*EspWorker) Stop

func (w *EspWorker) Stop()

func (*EspWorker) UpDummy

func (w *EspWorker) UpDummy(name, addr, peer string) error

type FabricWorker

type FabricWorker struct {
	*WorkerImpl
	// contains filtered or unexported fields
}

func NewFabricWorker

func NewFabricWorker(c *co.Network) *FabricWorker

func (*FabricWorker) AddNetwork

func (w *FabricWorker) AddNetwork(cfg *co.Network)

func (*FabricWorker) AddTunnel

func (w *FabricWorker) AddTunnel(cfg co.FabricTunnel)

func (*FabricWorker) Addr2Port

func (w *FabricWorker) Addr2Port(addr, pre string) string

func (*FabricWorker) DelNetwork

func (w *FabricWorker) DelNetwork(bridge string, vni uint32)

func (*FabricWorker) DelTunnel

func (w *FabricWorker) DelTunnel(name string)

func (*FabricWorker) Initialize

func (w *FabricWorker) Initialize()

func (*FabricWorker) IsSlave

func (w *FabricWorker) IsSlave(n Networker) bool

func (*FabricWorker) Reload

func (w *FabricWorker) Reload(v api.Switcher)

func (*FabricWorker) Start

func (w *FabricWorker) Start(v api.Switcher)

func (*FabricWorker) Stop

func (w *FabricWorker) Stop()

func (*FabricWorker) TcpMss

func (w *FabricWorker) TcpMss() int
func (w *FabricWorker) UpLink(bridge string, vni uint32, addr string) *ovs.PortStats

type Fabricer

type Fabricer interface {
	AddNetwork(cfg *co.Network)
	DelNetwork(bridge string, vni uint32)
	TcpMss() int
}

func GetFabricer

func GetFabricer(name string) Fabricer

type Hook

type Hook func(client libol.SocketClient, frame *libol.FrameMessage) error

type Http

type Http struct {
	// contains filtered or unexported fields
}

func NewHttp

func NewHttp(switcher api.Switcher) (h *Http)

func (*Http) GetIndex

func (h *Http) GetIndex(w http.ResponseWriter, r *http.Request)

func (*Http) IndexHtml

func (h *Http) IndexHtml(w http.ResponseWriter, r *http.Request)

func (*Http) Initialize

func (h *Http) Initialize()

func (*Http) IsAuth

func (h *Http) IsAuth(w http.ResponseWriter, r *http.Request) bool

func (*Http) LoadRouter

func (h *Http) LoadRouter()

func (*Http) LoadToken

func (h *Http) LoadToken()

func (*Http) Middleware

func (h *Http) Middleware(next http.Handler) http.Handler

func (*Http) PProf

func (h *Http) PProf(r *mux.Router)

func (*Http) ParseFiles

func (h *Http) ParseFiles(w http.ResponseWriter, name string, data interface{}) error

func (*Http) PubFile

func (h *Http) PubFile(w http.ResponseWriter, r *http.Request)

func (*Http) Router

func (h *Http) Router() *mux.Router

func (*Http) SaveToken

func (h *Http) SaveToken()

func (*Http) SetToken

func (h *Http) SetToken(value string)

func (*Http) Shutdown

func (h *Http) Shutdown()

func (*Http) Start

func (h *Http) Start()

type L2TP

type L2TP struct {
	// contains filtered or unexported fields
}

func NewL2TP

func NewL2TP(cfg *co.L2TP) *L2TP

func (*L2TP) Clean

func (d *L2TP) Clean()

func (*L2TP) Conf

func (d *L2TP) Conf() *co.L2TP

func (*L2TP) ConfFile

func (d *L2TP) ConfFile() string

func (*L2TP) Initialize

func (d *L2TP) Initialize()

func (*L2TP) OptionsFile

func (d *L2TP) OptionsFile() string

func (*L2TP) OptionsTmpl

func (d *L2TP) OptionsTmpl() string

func (*L2TP) Path

func (d *L2TP) Path() string

func (*L2TP) PidFile

func (d *L2TP) PidFile() string

func (*L2TP) Render

func (d *L2TP) Render(fp *os.File, tmpl string, data interface{})

func (*L2TP) SaveConf

func (d *L2TP) SaveConf()

func (*L2TP) SaveOptions

func (d *L2TP) SaveOptions()

func (*L2TP) Start

func (d *L2TP) Start()

func (*L2TP) Stop

func (d *L2TP) Stop()

func (*L2TP) Tmpl

func (d *L2TP) Tmpl() string

func (*L2TP) UUID

func (d *L2TP) UUID() string
type Link struct {
	// contains filtered or unexported fields
}
func NewLink(uuid string, cfg *co.Point) *Link

func (*Link) Clean

func (l *Link) Clean()

func (*Link) Conf

func (l *Link) Conf() *co.Point

func (*Link) ConfFile

func (l *Link) ConfFile() string

func (*Link) Initialize

func (l *Link) Initialize()

func (*Link) LogFile

func (l *Link) LogFile() string

func (*Link) Model

func (l *Link) Model() *models.Link

func (*Link) Path

func (l *Link) Path() string

func (*Link) PidFile

func (l *Link) PidFile() string

func (*Link) Start

func (l *Link) Start()

func (*Link) StatusFile

func (l *Link) StatusFile() string

func (*Link) Stop

func (l *Link) Stop()

func (*Link) UUID

func (l *Link) UUID() string

type LinkImpl

type LinkImpl struct {
	// contains filtered or unexported fields
}

func (*LinkImpl) Add

func (l *LinkImpl) Add(obj *database.VirtualLink)

func (*LinkImpl) Del

func (l *LinkImpl) Del(obj *database.VirtualLink)

func (*LinkImpl) Update

func (l *LinkImpl) Update(obj *database.VirtualLink)
type Links struct {
	// contains filtered or unexported fields
}
func NewLinks() *Links

func (*Links) Add

func (ls *Links) Add(l *Link)

func (*Links) Remove

func (ls *Links) Remove(addr string) *Link

type LinuxPort

type LinuxPort struct {
	// contains filtered or unexported fields
}
type MemberLink struct {
	LinkImpl
}

func (*MemberLink) Add

func (l *MemberLink) Add(obj *database.VirtualLink)

func (*MemberLink) Del

func (l *MemberLink) Del(obj *database.VirtualLink)

func (*MemberLink) Update

func (l *MemberLink) Update(obj *database.VirtualLink)

type Networker

type Networker interface {
	String() string
	ID() string
	Initialize()
	Start(v api.Switcher)
	Stop()
	Bridge() cn.Bridger
	Config() *co.Network
	Subnet() string
	Reload(v api.Switcher)
	Provider() string
}

func GetWorker

func GetWorker(name string) Networker

func NewNetworker

func NewNetworker(c *co.Network) Networker

type OpenLANWorker

type OpenLANWorker struct {
	*WorkerImpl
	// contains filtered or unexported fields
}

func NewOpenLANWorker

func NewOpenLANWorker(c *co.Network) *OpenLANWorker
func (w *OpenLANWorker) AddLink(c co.Point)

func (*OpenLANWorker) Bridge

func (w *OpenLANWorker) Bridge() cn.Bridger
func (w *OpenLANWorker) DelLink(addr string)

func (*OpenLANWorker) IfAddr

func (w *OpenLANWorker) IfAddr() string

func (*OpenLANWorker) Initialize

func (w *OpenLANWorker) Initialize()
func (w *OpenLANWorker) LoadLinks()

func (*OpenLANWorker) LoadRoutes

func (w *OpenLANWorker) LoadRoutes()

func (*OpenLANWorker) Reload

func (w *OpenLANWorker) Reload(v api.Switcher)

func (*OpenLANWorker) Start

func (w *OpenLANWorker) Start(v api.Switcher)

func (*OpenLANWorker) Stop

func (w *OpenLANWorker) Stop()

func (*OpenLANWorker) Subnet

func (w *OpenLANWorker) Subnet() string
func (w *OpenLANWorker) UnLoadLinks()

func (*OpenLANWorker) UnLoadRoutes

func (w *OpenLANWorker) UnLoadRoutes()

func (*OpenLANWorker) UpBridge

func (w *OpenLANWorker) UpBridge(cfg *co.Bridge)

func (*OpenLANWorker) UpTime

func (w *OpenLANWorker) UpTime() int64

type OpenVPN

type OpenVPN struct {
	Cfg *co.OpenVPN

	Protocol string
	Local    string
	Port     string
	// contains filtered or unexported fields
}

func NewOpenVPN

func NewOpenVPN(cfg *co.OpenVPN) *OpenVPN

func (*OpenVPN) Clean

func (o *OpenVPN) Clean()

func (*OpenVPN) Directory

func (o *OpenVPN) Directory() string

func (*OpenVPN) DirectoryClientConfig

func (o *OpenVPN) DirectoryClientConfig() string

func (*OpenVPN) FileCfg

func (o *OpenVPN) FileCfg(full bool) string

func (*OpenVPN) FileClient

func (o *OpenVPN) FileClient(full bool) string

func (*OpenVPN) FileIpp

func (o *OpenVPN) FileIpp(full bool) string

func (*OpenVPN) FileLog

func (o *OpenVPN) FileLog(full bool) string

func (*OpenVPN) FilePid

func (o *OpenVPN) FilePid(full bool) string

func (*OpenVPN) FileStats

func (o *OpenVPN) FileStats(full bool) string

func (*OpenVPN) ID

func (o *OpenVPN) ID() string

func (*OpenVPN) Initialize

func (o *OpenVPN) Initialize()

func (*OpenVPN) Path

func (o *OpenVPN) Path() string

func (*OpenVPN) Profile

func (o *OpenVPN) Profile() ([]byte, error)

func (*OpenVPN) ProfileTmpl

func (o *OpenVPN) ProfileTmpl() string

func (*OpenVPN) ServerTmpl

func (o *OpenVPN) ServerTmpl() string

func (*OpenVPN) Start

func (o *OpenVPN) Start()

func (*OpenVPN) Stop

func (o *OpenVPN) Stop()

func (*OpenVPN) ValidConf

func (o *OpenVPN) ValidConf() bool

func (*OpenVPN) WriteConf

func (o *OpenVPN) WriteConf(path string) error

type OpenVPNData

type OpenVPNData struct {
	Local           string
	Port            string
	CertNot         bool
	Ca              string
	Cert            string
	Key             string
	DhPem           string
	TlsAuth         string
	Cipher          string
	Server          string
	Device          string
	Protocol        string
	Script          string
	Routes          []string
	Renego          int
	Stats           string
	IpIp            string
	Push            []string
	ClientConfigDir string
}

func NewOpenVPNDataFromConf

func NewOpenVPNDataFromConf(obj *OpenVPN) *OpenVPNData

type OpenVPNProfile

type OpenVPNProfile struct {
	Server   string
	Port     string
	Ca       string
	Cert     string
	Key      string
	TlsAuth  string
	Cipher   string
	Device   string
	Protocol string
	Renego   int
}

func NewOpenVPNProfileFromConf

func NewOpenVPNProfileFromConf(obj *OpenVPN) *OpenVPNProfile

type OvsBridge

type OvsBridge struct {
	// contains filtered or unexported fields
}

func NewOvsBridge

func NewOvsBridge(name string) *OvsBridge

type OvsPort

type OvsPort struct {
	// contains filtered or unexported fields
}

type PolicyParameter

type PolicyParameter struct {
	// contains filtered or unexported fields
}

type RouterWorker

type RouterWorker struct {
	*WorkerImpl
	// contains filtered or unexported fields
}

func NewRouterWorker

func NewRouterWorker(c *co.Network) *RouterWorker

func (*RouterWorker) Forward

func (w *RouterWorker) Forward()

func (*RouterWorker) Initialize

func (w *RouterWorker) Initialize()

func (*RouterWorker) LoadRoutes

func (w *RouterWorker) LoadRoutes()

func (*RouterWorker) Reload

func (w *RouterWorker) Reload(v api.Switcher)

func (*RouterWorker) Start

func (w *RouterWorker) Start(v api.Switcher)

func (*RouterWorker) Stop

func (w *RouterWorker) Stop()

func (*RouterWorker) UnLoadRoutes

func (w *RouterWorker) UnLoadRoutes()

type StateParameters

type StateParameters struct {
	// contains filtered or unexported fields
}

type Switch

type Switch struct {
	// contains filtered or unexported fields
}

func NewSwitch

func NewSwitch(c *co.Switch) *Switch

func (*Switch) Alias

func (v *Switch) Alias() string

func (*Switch) Config

func (v *Switch) Config() *co.Switch

func (*Switch) FreeTap

func (v *Switch) FreeTap(dev network.Taper) error

func (*Switch) GetBridge

func (v *Switch) GetBridge(tenant string) (network.Bridger, error)

func (*Switch) GetPort

func (v *Switch) GetPort(listen string) string

func (*Switch) Initialize

func (v *Switch) Initialize()

func (*Switch) LoadLDAP

func (v *Switch) LoadLDAP()

func (*Switch) LoadPass

func (v *Switch) LoadPass()

func (*Switch) NewTap

func (v *Switch) NewTap(tenant string) (network.Taper, error)

func (*Switch) OffClient

func (v *Switch) OffClient(client libol.SocketClient)

func (*Switch) OnClient

func (v *Switch) OnClient(client libol.SocketClient) error

func (*Switch) OnClose

func (v *Switch) OnClose(client libol.SocketClient) error

func (*Switch) Protocol

func (v *Switch) Protocol() string

func (*Switch) ReadClient

func (v *Switch) ReadClient(client libol.SocketClient, frame *libol.FrameMessage) error

func (*Switch) ReadTap

func (v *Switch) ReadTap(device network.Taper, readAt func(f *libol.FrameMessage) error)

func (*Switch) Reload

func (v *Switch) Reload()

func (*Switch) Save

func (v *Switch) Save()

func (*Switch) Server

func (v *Switch) Server() libol.SocketServer

func (*Switch) SetPass

func (v *Switch) SetPass(file string)

func (*Switch) SignIn

func (v *Switch) SignIn(client libol.SocketClient) error

func (*Switch) Start

func (v *Switch) Start()

func (*Switch) Stop

func (v *Switch) Stop()

func (*Switch) UUID

func (v *Switch) UUID() string

func (*Switch) UpTime

func (v *Switch) UpTime() int64
type TunnelLink struct {
	LinkImpl
}

func (*TunnelLink) Add

func (l *TunnelLink) Add(obj *database.VirtualLink)

func (*TunnelLink) Del

func (l *TunnelLink) Del(obj *database.VirtualLink)

type VxLANWorker

type VxLANWorker struct {
	*WorkerImpl
	// contains filtered or unexported fields
}

func NewVxLANWorker

func NewVxLANWorker(c *co.Network) *VxLANWorker

func (*VxLANWorker) Initialize

func (w *VxLANWorker) Initialize()

func (*VxLANWorker) Reload

func (w *VxLANWorker) Reload(v api.Switcher)

func (*VxLANWorker) Start

func (w *VxLANWorker) Start(v api.Switcher)

func (*VxLANWorker) Stop

func (w *VxLANWorker) Stop()

type WorkerImpl

type WorkerImpl struct {
	// contains filtered or unexported fields
}

func NewWorkerApi

func NewWorkerApi(c *co.Network) *WorkerImpl

func (*WorkerImpl) AddOutput

func (w *WorkerImpl) AddOutput(bridge string, port *LinuxPort)

func (*WorkerImpl) AddPhysical

func (w *WorkerImpl) AddPhysical(bridge string, vlan int, output string)

func (*WorkerImpl) Bridge

func (w *WorkerImpl) Bridge() cn.Bridger

func (*WorkerImpl) Config

func (w *WorkerImpl) Config() *co.Network

func (*WorkerImpl) DelOutput

func (w *WorkerImpl) DelOutput(bridge string, port *LinuxPort)

func (*WorkerImpl) DelPhysical

func (w *WorkerImpl) DelPhysical(bridge string, vlan int, output string)

func (*WorkerImpl) GetCfgs

func (w *WorkerImpl) GetCfgs() (*co.Network, *co.OpenVPN)

func (*WorkerImpl) ID

func (w *WorkerImpl) ID() string

func (*WorkerImpl) Initialize

func (w *WorkerImpl) Initialize()

func (*WorkerImpl) Provider

func (w *WorkerImpl) Provider() string

func (*WorkerImpl) Reload

func (w *WorkerImpl) Reload(v api.Switcher)

func (*WorkerImpl) Start

func (w *WorkerImpl) Start(v api.Switcher)

func (*WorkerImpl) Stop

func (w *WorkerImpl) Stop()

func (*WorkerImpl) String

func (w *WorkerImpl) String() string

func (*WorkerImpl) Subnet

func (w *WorkerImpl) Subnet() string

Jump to

Keyboard shortcuts

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