Documentation
¶
Overview ¶
Package common is used for combining common functions from other packages which aren't connected with C language part
Index ¶
- Constants
- func GetDPDKLogLevel() string
- func GetDefaultCPUs(cpuNumber int) []int
- func HandleCPUList(s string, maxcpu int) ([]int, error)
- func LogDebug(logType LogType, v ...interface{})
- func LogDrop(logType LogType, v ...interface{})
- func LogError(logType LogType, v ...interface{}) string
- func LogFatal(logType LogType, v ...interface{})
- func LogFatalf(logType LogType, format string, v ...interface{})
- func LogTitle(logType LogType, v ...interface{})
- func LogWarning(logType LogType, v ...interface{})
- func SetLogType(logType LogType)
- func WrapWithNFError(err error, message string, code ErrorCode) error
- type ErrorCode
- type LogType
- type NFError
- type TCPFlags
Constants ¶
const ( EtherAddrLen = 6 IPv4AddrLen = 4 IPv6AddrLen = 16 )
Length of addresses.
const ( IPV4Number = 0x0800 ARPNumber = 0x0806 VLANNumber = 0x8100 MPLSNumber = 0x8847 IPV6Number = 0x86dd SwapIPV4Number = 0x0008 SwapARPNumber = 0x0608 SwapVLANNumber = 0x0081 SwapMPLSNumber = 0x4788 SwapIPV6Number = 0xdd86 )
Supported EtherType for L2
const ( ICMPNumber = 0x01 IPNumber = 0x04 TCPNumber = 0x06 UDPNumber = 0x11 ICMPv6Number = 0x3a NoNextHeader = 0x3b )
Supported L4 types
const ( ICMPTypeEchoRequest uint8 = 8 ICMPTypeEchoResponse uint8 = 0 ICMPv6TypeEchoRequest uint8 = 128 ICMPv6TypeEchoResponse uint8 = 129 ICMPv6NeighborSolicitation uint8 = 135 ICMPv6NeighborAdvertisement uint8 = 136 )
Supported ICMP Types
const ( EtherLen = 14 VLANLen = 4 MPLSLen = 4 IPv4MinLen = 20 IPv6Len = 40 ICMPLen = 8 TCPMinLen = 20 UDPLen = 8 ARPLen = 28 GTPMinLen = 8 )
These constants keep length of supported headers in bytes.
IPv6Len - minimum length of IPv6 header in bytes. It can be higher and it is not determined inside packet. Only default minimum size is used.
IPv4MinLen and TCPMinLen are used only in packet generation functions.
In parsing we take actual length of TCP header from DataOff field and length of IPv4 take from Ihl field.
const ( TCPMinDataOffset = 0x50 // minimal tcp data offset IPv4VersionIhl = 0x45 // IPv4, IHL = 5 (min header len) IPv6VtcFlow = 0x60 // IPv6 version )
const ( // No - no output even after fatal errors No LogType = 1 << iota // Initialization - output during system initialization Initialization = 2 // Debug - output during execution one time per time period (scheduler ticks) Debug = 4 // Verbose - output during execution as soon as something happens. Can influence performance Verbose = 8 )
const ( TCPFlagFin = 0x01 TCPFlagSyn = 0x02 TCPFlagRst = 0x04 TCPFlagPsh = 0x08 TCPFlagAck = 0x10 TCPFlagUrg = 0x20 TCPFlagEce = 0x40 TCPFlagCwr = 0x80 )
Constants for valuues of TCP flags.
const MaxLength = math.MaxInt32
Max array length for type conversions
Variables ¶
This section is empty.
Functions ¶
func GetDefaultCPUs ¶
GetDefaultCPUs returns default core list {0, 1, ..., NumCPU}
func HandleCPUList ¶
HandleCPUs parses cpu list string into array of valid core numbers. Removes duplicates
func LogDebug ¶
func LogDebug(logType LogType, v ...interface{})
LogDebug internal, used in all packages
func LogDrop ¶
func LogDrop(logType LogType, v ...interface{})
LogDrop internal, used in all packages
func LogFatal ¶
func LogFatal(logType LogType, v ...interface{})
LogFatal internal, used in all packages
func LogTitle ¶
func LogTitle(logType LogType, v ...interface{})
LogTitle internal, used in all packages
func LogWarning ¶
func LogWarning(logType LogType, v ...interface{})
LogWarning internal, used in all packages
Types ¶
type ErrorCode ¶
type ErrorCode int
ErrorCode type for codes of errors
const ( Fail ErrorCode ParseCPUListErr ReqTooManyPorts BadArgument UseNilFlowErr UseClosedFlowErr OpenedFlowAtTheEnd PortHasNoQueues NotAllQueuesUsed FailToInitPort ParseRuleJSONErr FileErr ParseRuleErr IncorrectArgInRules IncorrectRule AllocMbufErr PktMbufHeadRoomTooSmall NotEnoughCores CreatePortErr MaxCPUExceedErr PcapReadFail PcapWriteFail InvalidCPURangeErr SetAffinityErr MultipleReceivePort MultipleKNIPort WrongPort FailToInitDPDK FailToCreateKNI )
constants with error codes
func GetNFErrorCode ¶
GetNFErrorCode returns value of cCode field if err is NFError or pointer to it and -1 otherwise.
type NFError ¶
NFError is error type returned by nff-go functions
func GetNFError ¶
GetNFError if error is NFerror or pointer to int returns pointer to NFError, otherwise returns nil.
func (*NFError) Cause ¶
Cause returns the underlying cause of error, if possible. If not, returns err itself.