tk

package
v0.0.0-...-015fee6 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RxBytes = iota
	RxPkts
	RxErrors
	RxDrops
	RxFifo
	RxFrame
	RxComp
	RxMcast
	TxBytes
	TxPkts
	TxErrors
	TxDrops
	TxFifo
	TxColls
	TxCarr
	TxComp
	MaxSidx
)

constants related to ifstats

View Source
const (
	TrieSuccess = -iota
	TrieErrGeneric
	TrieErrExists
	TrieErrNoEnt
	TrieErrNoMem
	TrieErrUnknown
	TrieErrPrefix
)

return codes

View Source
const (
	TrieJmpLength   = 8
	PrefixArrLenfth = (1 << (TrieJmpLength + 1)) - 1
	PrefixArrNbits  = ((PrefixArrLenfth + TrieJmpLength) & ^TrieJmpLength) / TrieJmpLength
	PtrArrLength    = (1 << TrieJmpLength)
	PtrArrNBits     = ((PtrArrLength + TrieJmpLength) & ^TrieJmpLength) / TrieJmpLength
)

constants

View Source
const (
	OsIfStatFile = "/proc/net/dev"
)

Variables

This section is empty.

Functions

func ArpPing

func ArpPing(DIP net.IP, SIP net.IP, ifName string) (int, error)

ArpPing - sends a arp request given the DIP, SIP and interface name

func CountAllSetBitsInArr

func CountAllSetBitsInArr(arr []uint8) int

CountAllSetBitsInArr - count set bits in an array of uint8

func CountSetBitsInArr

func CountSetBitsInArr(arr []uint8, bPos int) int

CountSetBitsInArr - count set bits in an array of uint8 from bPos

func Debug

func Debug(obj interface{})

func HTTPProber

func HTTPProber(urls string) bool

HTTPProber - Do a http probe for given url returns true/false depending on whether probing was successful

func Htonl

func Htonl(i uint32) uint32

Htonl - Host to network byte-order long

func Htons

func Htons(i uint16) uint16

Htons - Host to network byte-order short

func IPtonl

func IPtonl(ip net.IP) uint32

IPtonl - Convert net.IP to network byte-order long

func IsBitSetInArr

func IsBitSetInArr(arr []uint8, bPos int) bool

IsBitSetInArr - check given bPos bit is set in the array

func IsNetIPv4

func IsNetIPv4(address string) bool

IsNetIPv4 - Check if net.IP is ipv4 address

func IsNetIPv6

func IsNetIPv6(address string) bool

IsNetIPv6 - Check if net.IP is ipv6 address

func L4ServiceProber

func L4ServiceProber(sType string, sName string, sHint, req, resp string) bool

L4ServiceProber - Do a probe for L4 service end-points sType is "tcp" or "udp" or "sctp" sName is end-point IP address in string format sHint is source address hint if any req is the request to be made to server (empty for none) resp is the response expected from server (empty for none) returns true/false depending on whether probing was successful

func LogIt

func LogIt(l LogLevelT, format string, v ...interface{})

LogIt uses Printf format internally

func NetGetIfiStats

func NetGetIfiStats(ifName string, ifs *IfiStat) int

NetGetIfiStats - Get OS statistics for a given interface

func NltoIP

func NltoIP(addr uint32) net.IP

NltoIP - Convert network byte-order long to net.IP

func Ntohl

func Ntohl(i uint32) uint32

Ntohl - Network to host byte-order long

func Ntohs

func Ntohs(i uint16) uint16

Ntohs - Network to host byte-order short

func SetBitInArr

func SetBitInArr(arr []uint8, bPos int)

SetBitInArr - set bPos bit in the array

func UnSetBitInArr

func UnSetBitInArr(arr []uint8, bPos int)

UnSetBitInArr - unset bPos bit in the array

Types

type Counter

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

Counter - context container

func NewCounter

func NewCounter(begin uint64, length uint64) *Counter

NewCounter - Allocate a set of counters

func (*Counter) GetCounter

func (C *Counter) GetCounter() (uint64, error)

GetCounter - Get next available counter

func (*Counter) PutCounter

func (C *Counter) PutCounter(id uint64) error

PutCounter - Return a counter to the available list

func (*Counter) ReserveCounter

func (C *Counter) ReserveCounter(id uint64) error

ReserveCounter - Don't allocate this counter

type IfiStat

type IfiStat struct {
	Ifs [MaxSidx]uint64
}

IfiStat - Container of interface statistics

type LogLevelT

type LogLevelT int

LogLevelT - Current log-level

const (
	LogEmerg LogLevelT = iota
	LogAlert
	LogCritical
	LogError
	LogWarning
	LogNotice
	LogInfo
	LogDebug
)

Log levels

type Logger

type Logger struct {
	LogTTY       bool
	CurrLogLevel LogLevelT
	LogItEmer    *log.Logger
	LogItAlert   *log.Logger
	LogItCrit    *log.Logger
	LogItErr     *log.Logger
	LogItWarn    *log.Logger
	LogItNotice  *log.Logger
	LogItInfo    *log.Logger
	LogItDebug   *log.Logger
}
var (
	DefaultLogger *Logger
)

func LogItInit

func LogItInit(logFile string, logLevel LogLevelT, toTTY bool) *Logger

LogItInit - Initialize the logger logFile - name of the logfile logLevel - specify current loglevel toTTY - specify if logs need to be redirected to TTY as well or not

func (*Logger) Log

func (logger *Logger) Log(l LogLevelT, format string, v ...interface{})

Log uses Printf format internally Arguments are considered in-line with fmt.Printf.

func (*Logger) LogItSetLevel

func (logger *Logger) LogItSetLevel(logLevel LogLevelT) error

LogItSetLevel - Set level of the logger

type TrieData

type TrieData interface {
}

TrieData - Any user data to be associated with a trie node

type TrieIterIntf

type TrieIterIntf interface {
	TrieNodeWalker(b string)
	TrieData2String(d TrieData) string
}

TrieIterIntf - Interface implementation needed for trie users to traverse and convert data

type TrieRoot

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

TrieRoot - root of a trie data structure

func TrieInit

func TrieInit(v6 bool) *TrieRoot

TrieInit - Initialize a trie root

func (*TrieRoot) AddTrie

func (t *TrieRoot) AddTrie(cidr string, data TrieData) int

AddTrie - Add a trie entry cidr is the route in cidr format and data is any user-defined data returns 0 on success or non-zero error code on error

func (*TrieRoot) DelTrie

func (t *TrieRoot) DelTrie(cidr string) int

DelTrie - Delete a trie entry cidr is the route in cidr format returns 0 on success or non-zero error code on error

func (*TrieRoot) FindTrie

func (t *TrieRoot) FindTrie(IP string) (int, *net.IPNet, TrieData)

FindTrie - Lookup matching route as per longest prefix match IP is the IP address in string format returns the following : 1. 0 on success or non-zero error code on error 2. matching route in *net.IPNet form 3. user-defined data associated with the trie entry

func (*TrieRoot) Trie2String

func (t *TrieRoot) Trie2String(tf TrieIterIntf)

Trie2String - stringify the trie table

Jump to

Keyboard shortcuts

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