gnl2go

package module
v0.0.0-...-101b5c6 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2016 License: BSD-3-Clause Imports: 8 Imported by: 10

README

About:

This is go based lib to work with generic netlink socket's. The lib was writen under heave influenc of FB's gnlpy (so all kudos goes to FB's team and all the blame to me)

in gnl2go.go you can find generic routines to work with gnetlink

in ipvs.go: lib to work with IPVS

in example/: few commands, which shows how to work with ipvs's lib

####TODOs: bugfixes etc (i do know about incorrect ipv6struct to ipv6string conversion) i dont use it (lib for ipvs) in production yet. not sure when i would. prob till that time i'd only fix problem with ipv6 to string and any other minor bugs, which i'd bump into

####Output from example in example/:

sudo ipvsadm -C
sudo ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn

sudo ./main
hi there
[]gnl2go.Pool(nil)
[]gnl2go.Pool{gnl2go.Pool{Service:gnl2go.Service{Proto:0x6, VIP:"2a020000:0:0:33:", Port:0x50, Sched:"wlc", FWMark:0x0, AF:0xa}, Dests:[]gnl2go.Dest(nil)}, gnl2go.Pool{Service:gnl2go.Service{Proto:0x6, VIP:"192.168.1.1", Port:0x50, Sched:"wrr", FWMark:0x0, AF:0x2}, Dests:[]gnl2go.Dest{gnl2go.Dest{IP:"127.0.0.11", Weight:10, Port:0x50, AF:0x2}}}, gnl2go.Pool{Service:gnl2go.Service{Proto:0x0, VIP:"", Port:0x0, Sched:"rr", FWMark:0x2, AF:0x0}, Dests:[]gnl2go.Dest(nil)}, gnl2go.Pool{Service:gnl2go.Service{Proto:0x0, VIP:"", Port:0x0, Sched:"wrr", FWMark:0x1, AF:0x0}, Dests:[]gnl2go.Dest(nil)}}
done

sudo ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.1.1:80 wrr
  -> 127.0.0.11:80                Tunnel  10     0          0         
  -> 127.0.0.13:80                Tunnel  20     0          0         
FWM  1 IPv6 wrr
  -> [fc00:1::12]:0               Tunnel  10     0          0         
  -> [fc00:2:3::12]:0             Tunnel  33     0          0         

Documentation

Index

Constants

View Source
const (
	REQUEST   = 1
	MULTI     = 2
	ACK       = 4
	ECHO      = 8
	DUMP_INTR = 16

	ROOT   = 0x100
	MATCH  = 0x200
	ATOMIC = 0x400
	DUMP   = (ROOT | MATCH)

	REPLACE = 0x100
	EXCL    = 0x200
	CREATE  = 0x400
	APPEND  = 0x800

	NETLINK_GENERIC = 16

	ACK_REQUEST        = (REQUEST | ACK)
	MATCH_ROOT_REQUEST = (MATCH | ROOT | REQUEST)
)
View Source
const (
	ControlMessageType = 16
	ErrorMessageType   = 2
	DoneMessageType    = 3
)
View Source
const (
	IPVS_MASQUERADING = 0
	IPVS_TUNNELING    = 2
	IPVS_DIRECTROUTE  = 3
)
View Source
const (
	NO_FLAGS               = 0x0    /* no flags */
	IP_VS_SVC_F_PERSISTENT = 0x0001 /* persistent port */
	IP_VS_SVC_F_HASHED     = 0x0002 /* hashed entry */
	IP_VS_SVC_F_ONEPACKET  = 0x0004 /* one-packet scheduling */
	IP_VS_SVC_F_SCHED1     = 0x0008 /* scheduler flag 1 */
	IP_VS_SVC_F_SCHED2     = 0x0010 /* scheduler flag 2 */
	IP_VS_SVC_F_SCHED3     = 0x0020 /* scheduler flag 3 */

	IP_VS_SVC_F_SCHED_SH_FALLBACK = IP_VS_SVC_F_SCHED1
	IP_VS_SVC_F_SCHED_SH_PORT     = IP_VS_SVC_F_SCHED2
)

Variables

View Source
var (
	CtrlOpsAttrList = CreateAttrListDefinition("CtrlOpsAttrList",
		[]AttrTuple{
			AttrTuple{Name: "ID", Type: "U32Type"},
			AttrTuple{Name: "FLAGS", Type: "U32Type"},
		})

	CtrlMcastGroupAttrList = CreateAttrListDefinition("CtrlMcastGroupAttrList",
		[]AttrTuple{
			AttrTuple{Name: "NAME", Type: "NulStringType"},
			AttrTuple{Name: "ID", Type: "U32Type"},
		})

	CtrlAttrList = CreateAttrListDefinition("CtrlAttrList",
		[]AttrTuple{
			AttrTuple{Name: "FAMILY_ID", Type: "U16Type"},
			AttrTuple{Name: "FAMILY_NAME", Type: "NulStringType"},
			AttrTuple{Name: "VERSION", Type: "U32Type"},
			AttrTuple{Name: "HDRSIZE", Type: "U32Type"},
			AttrTuple{Name: "MAXATTR", Type: "U32Type"},
			AttrTuple{Name: "OPS", Type: "IgnoreType"},
			AttrTuple{Name: "MCAST_GROUPS", Type: "CtrlMcastGroupAttrList"},
		})

	NoneAttrList = []AttrTuple{}

	CtrlMessageInitList = []AttrListTuple{
		AttrListTuple{Name: "NEWFAMILY", AttrList: CreateAttrListType(CtrlAttrList)},
		AttrListTuple{Name: "DELFAMILY", AttrList: CreateAttrListType(NoneAttrList)},
		AttrListTuple{Name: "GETFAMILY", AttrList: CreateAttrListType(CtrlAttrList)},
		AttrListTuple{Name: "NEWOPS", AttrList: CreateAttrListType(NoneAttrList)},
		AttrListTuple{Name: "DELOPS", AttrList: CreateAttrListType(NoneAttrList)},
		AttrListTuple{Name: "GETOPS", AttrList: CreateAttrListType(NoneAttrList)},
		AttrListTuple{Name: "NEWMCAST_GRP", AttrList: CreateAttrListType(NoneAttrList)},
		AttrListTuple{Name: "DELMCAST_GRP", AttrList: CreateAttrListType(NoneAttrList)},
		AttrListTuple{Name: "GETMCAST_GRP", AttrList: CreateAttrListType(NoneAttrList)},
	}
	ErrorMessageInitList = []AttrListTuple{}
	DoneMessageInitList  = []AttrListTuple{}
	CtrlMessage          = CreateMsgType(CtrlMessageInitList, 16)
	ErrorMessage         = CreateMsgType(ErrorMessageInitList, 2)
	DoneMessage          = CreateMsgType(DoneMessageInitList, 3)
)
View Source
var (
	Family2MT       = make(map[uint16]*MessageType)
	LookupOnStartup = make(map[string][]AttrListTuple)
	MT2Family       = make(map[string]uint16)
	ATLName2ATL     = make(map[string][]AttrTuple)
)
View Source
var (
	BIN_NO_FLAGS                      = []byte{0, 0, 0, 0, 0, 0, 0, 0}        /* no flags */
	BIN_IP_VS_SVC_F_PERSISTENT        = U32ToBinFlags(IP_VS_SVC_F_PERSISTENT) /* persistent port */
	BIN_IP_VS_SVC_F_HASHED            = U32ToBinFlags(IP_VS_SVC_F_HASHED)     /* hashed entry */
	BIN_IP_VS_SVC_F_ONEPACKET         = U32ToBinFlags(IP_VS_SVC_F_ONEPACKET)  /* one-packet scheduling */
	BIN_IP_VS_SVC_F_SCHED1            = U32ToBinFlags(IP_VS_SVC_F_SCHED1)     /* scheduler flag 1 */
	BIN_IP_VS_SVC_F_SCHED2            = U32ToBinFlags(IP_VS_SVC_F_SCHED2)     /* scheduler flag 2 */
	BIN_IP_VS_SVC_F_SCHED3            = U32ToBinFlags(IP_VS_SVC_F_SCHED3)     /* scheduler flag 3 */
	BIN_IP_VS_SVC_F_SCHED_SH_FALLBACK = BIN_IP_VS_SVC_F_SCHED1
	BIN_IP_VS_SVC_F_SCHED_SH_PORT     = BIN_IP_VS_SVC_F_SCHED2
)
View Source
var (
	IpvsStatsAttrList = CreateAttrListDefinition("IpvsStatsAttrList",
		[]AttrTuple{
			AttrTuple{Name: "CONNS", Type: "U32Type"},
			AttrTuple{Name: "INPKTS", Type: "U32Type"},
			AttrTuple{Name: "OUTPKTS", Type: "U32Type"},
			AttrTuple{Name: "INBYTES", Type: "U64Type"},
			AttrTuple{Name: "OUTBYTES", Type: "U64Type"},
			AttrTuple{Name: "CPS", Type: "U32Type"},
			AttrTuple{Name: "INPPS", Type: "U32Type"},
			AttrTuple{Name: "OUTPPS", Type: "U32Type"},
			AttrTuple{Name: "INBPS", Type: "U32Type"},
			AttrTuple{Name: "OUTBPS", Type: "U32Type"},
		})

	IpvsStats64AttrList = CreateAttrListDefinition("IpvsStats64AttrList",
		[]AttrTuple{
			AttrTuple{Name: "CONNS", Type: "U64Type"},
			AttrTuple{Name: "INPKTS", Type: "U64Type"},
			AttrTuple{Name: "OUTPKTS", Type: "U64Type"},
			AttrTuple{Name: "INBYTES", Type: "U64Type"},
			AttrTuple{Name: "OUTBYTES", Type: "U64Type"},
			AttrTuple{Name: "CPS", Type: "U64Type"},
			AttrTuple{Name: "INPPS", Type: "U64Type"},
			AttrTuple{Name: "OUTPPS", Type: "U64Type"},
			AttrTuple{Name: "INBPS", Type: "U64Type"},
			AttrTuple{Name: "OUTBPS", Type: "U64Type"},
		})

	IpvsServiceAttrList = CreateAttrListDefinition("IpvsServiceAttrList",
		[]AttrTuple{
			AttrTuple{Name: "AF", Type: "U16Type"},
			AttrTuple{Name: "PROTOCOL", Type: "U16Type"},
			AttrTuple{Name: "ADDR", Type: "BinaryType"},
			AttrTuple{Name: "PORT", Type: "Net16Type"},
			AttrTuple{Name: "FWMARK", Type: "U32Type"},
			AttrTuple{Name: "SCHED_NAME", Type: "NulStringType"},
			AttrTuple{Name: "FLAGS", Type: "BinaryType"},
			AttrTuple{Name: "TIMEOUT", Type: "U32Type"},
			AttrTuple{Name: "NETMASK", Type: "U32Type"},
			AttrTuple{Name: "STATS", Type: "IpvsStatsAttrList"},
			AttrTuple{Name: "PE_NAME", Type: "NulStringType"},
			AttrTuple{Name: "STATS64", Type: "IpvsStats64AttrList"},
		})

	IpvsDestAttrList = CreateAttrListDefinition("IpvsDestAttrList",
		[]AttrTuple{
			AttrTuple{Name: "ADDR", Type: "BinaryType"},
			AttrTuple{Name: "PORT", Type: "Net16Type"},
			AttrTuple{Name: "FWD_METHOD", Type: "U32Type"},
			AttrTuple{Name: "WEIGHT", Type: "I32Type"},
			AttrTuple{Name: "U_THRESH", Type: "U32Type"},
			AttrTuple{Name: "L_THRESH", Type: "U32Type"},
			AttrTuple{Name: "ACTIVE_CONNS", Type: "U32Type"},
			AttrTuple{Name: "INACT_CONNS", Type: "U32Type"},
			AttrTuple{Name: "PERSIST_CONNS", Type: "U32Type"},
			AttrTuple{Name: "STATS", Type: "IpvsStatsAttrList"},
			AttrTuple{Name: "ADDR_FAMILY", Type: "U16Type"},
			AttrTuple{Name: "STATS64", Type: "IpvsStats64AttrList"},
		})

	IpvsDaemonAttrList = CreateAttrListDefinition("IpvsDaemonAttrList",
		[]AttrTuple{
			AttrTuple{Name: "STATE", Type: "U32Type"},
			AttrTuple{Name: "MCAST_IFN", Type: "NulStringType"},
			AttrTuple{Name: "SYNC_ID", Type: "U32Type"},
		})

	IpvsInfoAttrList = CreateAttrListDefinition("IpvsInfoAttrList",
		[]AttrTuple{
			AttrTuple{Name: "VERSION", Type: "U32Type"},
			AttrTuple{Name: "CONN_TAB_SIZE", Type: "U32Type"},
		})

	IpvsCmdAttrList = CreateAttrListDefinition("IpvsCmdAttrList",
		[]AttrTuple{
			AttrTuple{Name: "SERVICE", Type: "IpvsServiceAttrList"},
			AttrTuple{Name: "DEST", Type: "IpvsDestAttrList"},
			AttrTuple{Name: "DAEMON", Type: "IpvsDaemonAttrList"},
			AttrTuple{Name: "TIMEOUT_TCP", Type: "U32Type"},
			AttrTuple{Name: "TIMEOUT_TCP_FIN", Type: "U32Type"},
			AttrTuple{Name: "TIMEOUT_UDP", Type: "U32Type"},
		})

	IpvsMessageInitList = []AttrListTuple{
		AttrListTuple{Name: "NEW_SERVICE", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "SET_SERVICE", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "DEL_SERVICE", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "GET_SERVICE", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "NEW_DEST", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "SET_DEST", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "DEL_DEST", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "GET_DEST", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "NEW_DAEMON", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "DEL_DAEMON", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "GET_DAEMON", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "SET_CONFIG", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "GET_CONFIG", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "SET_INFO", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "GET_INFO", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "ZERO", AttrList: CreateAttrListType(IpvsCmdAttrList)},
		AttrListTuple{Name: "FLUSH", AttrList: CreateAttrListType(IpvsCmdAttrList)},
	}
)

Functions

func IPv4ToUint32

func IPv4ToUint32(ipv4 string) (uint32, error)

func IPv6AddrToString

func IPv6AddrToString(ipv6addr IPv6Addr) string

func LookupTypeOnStartup

func LookupTypeOnStartup(alist []AttrListTuple, familyName string)

Routine, which helps us to resolve family's name to ID on startup

func SerializeNLMsg

func SerializeNLMsg(mt *MessageType, msg GNLMessage, portId, Seq uint32) ([]byte, error)

func U32ToBinFlags

func U32ToBinFlags(flags uint32) []byte

func Uint32IPv4ToString

func Uint32IPv4ToString(ipv4 uint32) string

Types

type AttrHdr

type AttrHdr struct {
	Len uint16
	Num uint16
}

type AttrListTuple

type AttrListTuple struct {
	Name     string
	AttrList AttrListType
}

type AttrListType

type AttrListType struct {
	Key2name map[int]string
	Name2key map[string]int
	Key2Type map[int]string
	Amap     map[string]SerDes
}

Struct describes how we encode (which netlink's msg type number coresponds to which type) Amap contains dict of SerDes types, which we can serialize or where we will deserialize incoming msg.

func CreateAttrListType

func CreateAttrListType(attrListMap []AttrTuple) AttrListType

func (*AttrListType) Deserialize

func (al *AttrListType) Deserialize(list []byte) error

func (*AttrListType) Serialize

func (al *AttrListType) Serialize() ([]byte, error)

func (*AttrListType) Set

func (al *AttrListType) Set(amap map[string]SerDes)

func (*AttrListType) Val

func (al *AttrListType) Val()

type AttrTuple

type AttrTuple struct {
	Name string
	Type string
}

This struct has been used for describing and constructing netlink's attributes lists.

func CreateAttrListDefinition

func CreateAttrListDefinition(listName string, atl []AttrTuple) []AttrTuple

Routine which helps us to create global attributelists definition dict.

type BinaryType

type BinaryType []byte

func (*BinaryType) Deserialize

func (bt *BinaryType) Deserialize(buf []byte) error

func (*BinaryType) Serialize

func (bt *BinaryType) Serialize() ([]byte, error)

func (*BinaryType) Val

func (bt *BinaryType) Val()

type Dest

type Dest struct {
	IP     string
	Weight int32
	Port   uint16
	AF     uint16
}

func (*Dest) InitFromAttrList

func (d *Dest) InitFromAttrList(list map[string]SerDes) error

func (*Dest) IsEqual

func (d *Dest) IsEqual(od *Dest) bool

type GNLMessage

type GNLMessage struct {
	Hdr     GNLMsgHdr
	AttrMap map[string]SerDes
	Family  uint16
	Flags   uint16
	MT      *MessageType
}

func DeserializeNLMsg

func DeserializeNLMsg(sMsg []byte) (GNLMessage, []byte, error)

func (*GNLMessage) GetAttrList

func (msg *GNLMessage) GetAttrList(name string) SerDes

func (*GNLMessage) Init

func (msg *GNLMessage) Init(hdr GNLMsgHdr, amap map[string]SerDes,
	family, flags uint16)

func (*GNLMessage) SetAttrList

func (msg *GNLMessage) SetAttrList(name string, val SerDes)

type GNLMsgHdr

type GNLMsgHdr struct {
	Cmnd    uint8
	Version uint8
}

GNL - generic netlink msg. NL msg contains NLmsgHdr + GNLMsg

type I32Type

type I32Type int32

func (*I32Type) Deserialize

func (i32 *I32Type) Deserialize(buf []byte) error

func (*I32Type) Serialize

func (i32 *I32Type) Serialize() ([]byte, error)

func (*I32Type) Val

func (i32 *I32Type) Val()

type IPv6Addr

type IPv6Addr [4]uint32

func IPv6StringToAddr

func IPv6StringToAddr(ipv6 string) (IPv6Addr, error)

type IgnoreType

type IgnoreType bool

func (*IgnoreType) Deserialize

func (it *IgnoreType) Deserialize(buf []byte) error

func (*IgnoreType) Serialize

func (it *IgnoreType) Serialize() ([]byte, error)

func (*IgnoreType) Val

func (it *IgnoreType) Val()

type IpvsClient

type IpvsClient struct {
	Sock NLSocket
	// contains filtered or unexported fields
}

func (*IpvsClient) AddDest

func (ipvs *IpvsClient) AddDest(vip string, port uint16, rip string,
	protocol uint16, weight int32) error

func (*IpvsClient) AddDestPort

func (ipvs *IpvsClient) AddDestPort(vip string, vport uint16, rip string,
	rport uint16, protocol uint16, weight int32, fwd uint32) error

func (*IpvsClient) AddFWMDest

func (ipvs *IpvsClient) AddFWMDest(fwmark uint32, rip string, vaf uint16,
	port uint16, weight int32) error

func (*IpvsClient) AddFWMDestFWD

func (ipvs *IpvsClient) AddFWMDestFWD(fwmark uint32, rip string, vaf uint16,
	port uint16, weight int32, fwd uint32) error

func (*IpvsClient) AddFWMService

func (ipvs *IpvsClient) AddFWMService(fwmark uint32,
	sched string, af uint16) error

func (*IpvsClient) AddFWMServiceWithFlags

func (ipvs *IpvsClient) AddFWMServiceWithFlags(fwmark uint32,
	sched string, af uint16, flags []byte) error

func (*IpvsClient) AddService

func (ipvs *IpvsClient) AddService(vip string,
	port uint16, protocol uint16, sched string) error

func (*IpvsClient) AddServiceWithFlags

func (ipvs *IpvsClient) AddServiceWithFlags(vip string,
	port uint16, protocol uint16, sched string, flags []byte) error

func (*IpvsClient) DelDest

func (ipvs *IpvsClient) DelDest(vip string, port uint16, rip string,
	protocol uint16) error

func (*IpvsClient) DelDestPort

func (ipvs *IpvsClient) DelDestPort(vip string, vport uint16, rip string,
	rport uint16, protocol uint16) error

func (*IpvsClient) DelFWMDest

func (ipvs *IpvsClient) DelFWMDest(fwmark uint32, rip string, vaf uint16,
	port uint16) error

func (*IpvsClient) DelFWMService

func (ipvs *IpvsClient) DelFWMService(fwmark uint32, af uint16) error

func (*IpvsClient) DelService

func (ipvs *IpvsClient) DelService(vip string,
	port uint16, protocol uint16) error

func (*IpvsClient) Exit

func (ipvs *IpvsClient) Exit()

func (*IpvsClient) Flush

func (ipvs *IpvsClient) Flush() error

func (*IpvsClient) GetAllStatsBrief

func (ipvs *IpvsClient) GetAllStatsBrief() (map[string]StatsIntf, error)

func (*IpvsClient) GetPoolForService

func (ipvs *IpvsClient) GetPoolForService(svc Service) (Pool, error)

func (*IpvsClient) GetPools

func (ipvs *IpvsClient) GetPools() ([]Pool, error)

func (*IpvsClient) Init

func (ipvs *IpvsClient) Init() error

func (*IpvsClient) UpdateDest

func (ipvs *IpvsClient) UpdateDest(vip string, port uint16, rip string,
	protocol uint16, weight int32) error

func (*IpvsClient) UpdateDestPort

func (ipvs *IpvsClient) UpdateDestPort(vip string, vport uint16, rip string,
	rport uint16, protocol uint16, weight int32, fwd uint32) error

func (*IpvsClient) UpdateFWMDest

func (ipvs *IpvsClient) UpdateFWMDest(fwmark uint32, rip string, vaf uint16,
	port uint16, weight int32) error

func (*IpvsClient) UpdateFWMDestFWD

func (ipvs *IpvsClient) UpdateFWMDestFWD(fwmark uint32, rip string, vaf uint16,
	port uint16, weight int32, fwd uint32) error

type MessageType

type MessageType struct {
	Name2key         map[string]int
	Key2name         map[int]string
	Key2attrListType map[int]AttrListType
	Family           uint16
}

Struct, which describes how generic netlink message for particular family could looks like

func CreateMsgType

func CreateMsgType(alist []AttrListTuple, familyId uint16) MessageType

Routine, which helps us to create global dict of msg types

func (*MessageType) DeserializeGNLMsg

func (mt *MessageType) DeserializeGNLMsg(sMsg []byte) (GNLMessage, error)

func (*MessageType) InitGNLMessageStr

func (mt *MessageType) InitGNLMessageStr(cmnd string, flags uint16) (GNLMessage, error)

func (*MessageType) InitMessageType

func (mt *MessageType) InitMessageType(alist []AttrListTuple, familyId uint16)

func (*MessageType) SerializeGNLMsg

func (mt *MessageType) SerializeGNLMsg(msg GNLMessage) ([]byte, error)

type NLMsgHdr

type NLMsgHdr struct {
	TotalLen uint32
	Family   uint16
	Flags    uint16
	Seq      uint32
	PortID   uint32
}

type NLSocket

type NLSocket struct {
	Sd      int
	Seq     uint32
	PortID  uint32
	Lock    *sync.Mutex
	Verbose bool
}

func (*NLSocket) Close

func (nlSock *NLSocket) Close()

func (*NLSocket) Execute

func (nlSock *NLSocket) Execute(msg GNLMessage) error

func (*NLSocket) Init

func (nlSock *NLSocket) Init() error

func (*NLSocket) Query

func (nlSock *NLSocket) Query(msg GNLMessage) ([]GNLMessage, error)

func (*NLSocket) ResolveFamily

func (nlSock *NLSocket) ResolveFamily(family NulStringType) (*U16Type, error)

type Net16Type

type Net16Type uint16

func (*Net16Type) Deserialize

func (n16 *Net16Type) Deserialize(buf []byte) error

func (*Net16Type) Serialize

func (n16 *Net16Type) Serialize() ([]byte, error)

func (*Net16Type) Val

func (n16 *Net16Type) Val()

type Net32Type

type Net32Type uint32

func (*Net32Type) Deserialize

func (n32 *Net32Type) Deserialize(buf []byte) error

func (*Net32Type) Serialize

func (n32 *Net32Type) Serialize() ([]byte, error)

func (*Net32Type) Val

func (n32 *Net32Type) Val()

type NulStringType

type NulStringType string

func FromProtoNum

func FromProtoNum(pnum U16Type) NulStringType

func (*NulStringType) Deserialize

func (ns *NulStringType) Deserialize(buf []byte) error

func (NulStringType) Serialize

func (ns NulStringType) Serialize() ([]byte, error)

func (*NulStringType) Val

func (ns *NulStringType) Val()

type Pool

type Pool struct {
	Service Service
	Dests   []Dest
}

func (*Pool) InitFromAttrList

func (p *Pool) InitFromAttrList(list map[string]SerDes)

type SerDes

type SerDes interface {
	Serialize() ([]byte, error)
	Deserialize([]byte) error
	Val()
}

Interface for abstraction over native generic netlink types

func DeserializeSerDes

func DeserializeSerDes(serdesType string, list []byte) (SerDes, error)

Routine which helps to deserialize. used in AttrList Deserialize()

type Service

type Service struct {
	Proto  uint16
	VIP    string
	Port   uint16
	Sched  string
	FWMark uint32
	AF     uint16
	Flags  []byte
}

func (*Service) CreateAttrList

func (s *Service) CreateAttrList() (map[string]SerDes, error)

func (*Service) InitFromAttrList

func (s *Service) InitFromAttrList(list map[string]SerDes) error

func (*Service) IsEqual

func (s *Service) IsEqual(os Service) bool

func (*Service) ToString

func (s *Service) ToString() string

type Stats

type Stats struct {
	Conns    uint32
	Inpkts   uint32
	Outpkts  uint32
	Inbytes  uint64
	Outbytes uint64
	Cps      uint32
	Inpps    uint32
	Outpps   uint32
	Inbps    uint32
	Outbps   uint32
}

func (Stats) GetStats

func (stats Stats) GetStats() map[string]uint64

func (*Stats) InitFromAttrList

func (stats *Stats) InitFromAttrList(list map[string]SerDes)

type Stats64

type Stats64 struct {
	Conns    uint64
	Inpkts   uint64
	Outpkts  uint64
	Inbytes  uint64
	Outbytes uint64
	Cps      uint64
	Inpps    uint64
	Outpps   uint64
	Inbps    uint64
	Outbps   uint64
}

func (Stats64) GetStats

func (stats Stats64) GetStats() map[string]uint64

func (*Stats64) InitFromAttrList

func (stats *Stats64) InitFromAttrList(list map[string]SerDes)

type StatsIntf

type StatsIntf interface {
	GetStats() map[string]uint64
}

func GetStatsFromAttrList

func GetStatsFromAttrList(attrList *AttrListType) StatsIntf

type U16Type

type U16Type uint16

func ToProtoNum

func ToProtoNum(proto NulStringType) U16Type

func (*U16Type) Deserialize

func (u16 *U16Type) Deserialize(buf []byte) error

func (*U16Type) Serialize

func (u16 *U16Type) Serialize() ([]byte, error)

func (*U16Type) Val

func (u16 *U16Type) Val()

type U32Type

type U32Type uint32

func (*U32Type) Deserialize

func (u32 *U32Type) Deserialize(buf []byte) error

func (*U32Type) Serialize

func (u32 *U32Type) Serialize() ([]byte, error)

func (*U32Type) Val

func (u32 *U32Type) Val()

type U64Type

type U64Type uint64

func (*U64Type) Deserialize

func (u64 *U64Type) Deserialize(buf []byte) error

func (*U64Type) Serialize

func (u64 *U64Type) Serialize() ([]byte, error)

func (*U64Type) Val

func (u64 *U64Type) Val()

type U8Type

type U8Type uint8

func (*U8Type) Deserialize

func (u8 *U8Type) Deserialize(buf []byte) error

func (*U8Type) Serialize

func (u8 *U8Type) Serialize() ([]byte, error)

func (*U8Type) Val

func (u8 *U8Type) Val()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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