Documentation
¶
Index ¶
- Constants
- Variables
- func CalcXMitSize(rate uint64, ticks uint32) (uint32, error)
- func CalcXMitTime(rate uint64, size uint32) (uint32, error)
- func GetHz() (int, error)
- func GetInfoFromPrefAndProto(hostPref, netProto uint16) uint32
- func GetPrefFromInfo(info uint32) uint16
- func GetProtoFromInfo(info uint32) uint16
- func HFSCGetSC(args []string) (*tc.ServiceCurve, error)
- func HToNL(hostLong uint32) uint32
- func HToNS(hostShort uint16) uint16
- func NToHL(netLong uint32) uint32
- func NToHS(netShort uint16) uint16
- func ParseActionGAT(out io.Writer, args []string) (*[]*tc.Action, error)
- func ParseBasicParams(out io.Writer, params []string) (*tc.Object, error)
- func ParseClassID(p string) (uint32, error)
- func ParseCodelArgs(out io.Writer, args []string) (*tc.Object, error)
- func ParseHFSCClassArgs(out io.Writer, args []string) (*tc.Object, error)
- func ParseHFSCQDiscArgs(stdout io.Writer, args []string) (*tc.Object, error)
- func ParseHTBClassArgs(out io.Writer, args []string) (*tc.Object, error)
- func ParseHTBQDiscArgs(out io.Writer, args []string) (*tc.Object, error)
- func ParseHandle(h string) (uint32, error)
- func ParseLinkLayer(l string) (uint8, error)
- func ParseProto(prot string) (uint16, error)
- func ParseQFQArgs(out io.Writer, args []string) (*tc.Object, error)
- func ParseRate(arg string) (uint64, error)
- func ParseSize(s string) (uint64, error)
- func ParseU32Params(out io.Writer, params []string) (*tc.Object, error)
- func RenderClassID(classID uint32, printParent bool) string
- func RenderProto(proto uint16) string
- type Args
- type FArgs
- type Tctl
- type Trafficctl
- func (t *Trafficctl) AddClass(stdout io.Writer, args *Args) error
- func (t *Trafficctl) AddFilter(stdout io.Writer, fArgs *FArgs) error
- func (t *Trafficctl) AddQdisc(stdout io.Writer, args *Args) error
- func (t *Trafficctl) ChangeClass(stdout io.Writer, args *Args) error
- func (t *Trafficctl) ChangeFilter(stdout io.Writer, fArgs *FArgs) error
- func (t *Trafficctl) ChangeQdisc(stdout io.Writer, args *Args) error
- func (t *Trafficctl) DeleteClass(stdout io.Writer, args *Args) error
- func (t *Trafficctl) DeleteFilter(stdout io.Writer, fArgs *FArgs) error
- func (t *Trafficctl) DeleteQdisc(stdout io.Writer, args *Args) error
- func (t *Trafficctl) GetFilter(stdout io.Writer, fArgs *FArgs) error
- func (t *Trafficctl) ReplaceClass(stdout io.Writer, args *Args) error
- func (t *Trafficctl) ReplaceFilter(stdout io.Writer, fArgs *FArgs) error
- func (t *Trafficctl) ReplaceQdisc(stdout io.Writer, args *Args) error
- func (t *Trafficctl) ShowClass(stdout io.Writer, args *Args) error
- func (t *Trafficctl) ShowFilter(stdout io.Writer, fArgs *FArgs) error
- func (t *Trafficctl) ShowQdisc(stdout io.Writer, args *Args) error
Constants ¶
const ( GActUnspec = -1 GActOk = 0 GActReclass = 1 GActShot = 2 GActPipe = 3 GActTrap = 8 GActJump = 1 << 28 GActGoTo = 2 << 28 )
const BasicHelp = `Usage: ... basic [ action ACTION_SPEC ] [ classid CLASSID | flowid CLASSID ]
`
const ClassHelp = `` /* 288-byte string literal not displayed */
const CodelHelp = `Usage: ... codel [ limit PACKETS ] [ target TIME ]
[ interval TIME ] [ ecn | noecn ]
[ ce_threshold TIME ]
`
const FilterHelp = `` /* 231-byte string literal not displayed */
const HFSCHelp = `Usage: ... hfsc [ default CLASSID ]
default: default class for unclassified packets
`
const HTBHelp = `` /* 979-byte string literal not displayed */
const QFQHelp = `Usage: ... qfq [ weight N ] [ maxpkt N ]
`
const QdiscHelp = `` /* 399-byte string literal not displayed */
const TCU32Terminal = 1
const (
TimeUnitsPerSecs = 1000000
)
const U32Help = `` /* 150-byte string literal not displayed */
Variables ¶
var ( ErrNotEnoughArgs = errors.New("not enough arguments") ErrInvalidArg = errors.New("invalid argument in list") ErrNotImplemented = errors.New("not implemented") ErrOutOfBounds = errors.New("integer argument out of bounds") ErrExitAfterHelp = errors.New("exit after help message") )
var ErrInvalidActionControl = errors.New("invalid action control parameter")
var ErrInvalidFilterType = errors.New("invalid filtertype")
var ErrNoDevice = errors.New("no such device")
var ErrNoValidProto = errors.New("invalid protocol name")
var ErrUnknownLinkLayer = errors.New("unknown linklayer value provided")
Functions ¶
func CalcXMitSize ¶
CalcXMitSize is the inverse of CalcXMitTime
func CalcXMitTime ¶
CalcXMitTime takes a rate and size of uint64 and calculates the XMitTime.
func GetInfoFromPrefAndProto ¶
GetInfoFromPrefAndProto combines the uint16 preference/priority value (in host byte order) and the uint16 EtherType protocol value (in network byte order) such that the combined value can be stored in the Info field of tc.Object.
func GetPrefFromInfo ¶
GetPrefFromInfo takes the uint32 representation of the Info field of tc.Object and returns the preference/priority value as uint16.
func GetProtoFromInfo ¶
GetProtoFromInfo extracts the uint16 EtherType protocol value (in network byte order) from the tc.Object's Info field.
func HToNL ¶
HToNL converts a uint32 value from host (native) byte order to network (big endian) byte order.
func HToNS ¶
HToNS converts a uint16 value from host (native) byte order to network (big endian) byte order.
func NToHL ¶
NToHL converts a uint32 value from network (big endian) byte order to host (native) byte order.
func NToHS ¶
NToHS converts a uint16 value from network (big endian) byte order to host (native) byte order.
func ParseActionGAT ¶
ParseActionGAT parses options of the filter action category and returns a pointer to a slice of []*tc.Action
func ParseBasicParams ¶
ParseBasicParams parses the cmdline arguments for `tc filter ... basic ...` and returns a *tc.Object.
func ParseClassID ¶
ParseClassID takes a string which can have three forms: Form 1: "root", which returns tc.HandleRoot Form 2: "none", which returns 0 as classid Form 3: "XXXX:XXXX" (Major:Minor), will return uint32(major<<16)|uint32(minor)
func ParseCodelArgs ¶
ParseCodelArgs parses a []string from the commandline for the codel qdisc. and returns an *tc.Object accordingly.
func ParseHFSCClassArgs ¶
ParseHFSCClassArgs parses the cmdline arguments for `tc class add ... hfsc ...` and returns a *tc.Object.
func ParseHFSCQDiscArgs ¶
ParseHFSCQDiscArgs parses a []string from the commandline for the HFSC qdisc via `tc qdisc ... hfsc ...` and returns an *tc.Object accordingly.
func ParseHTBClassArgs ¶
ParseHTBClassArgs parses the cmdline arguments for `tc class add ... htb ...` and returns a *tc.Object.
func ParseHTBQDiscArgs ¶
ParseHTBQDiscArgs parses a []string from the commandline for the HTB qdisc via `tc qdisc ... htb ...` and returns an *tc.Object accordingly.
func ParseHandle ¶
ParseHandle takes a string in the form of XXXX: and returns the XXXX value as uint32 type shifted left by 16 bits.
func ParseLinkLayer ¶
ParseLinkLayer takes a string of LinkLayer name and returns the equivalent uint8 representation.
func ParseProto ¶
ParseProto takes an EtherType protocol string and returns the equivalent uint16 representation in network byte order.
func ParseQFQArgs ¶
ParseQFQArgs parses a []string from the commandline for the qfq qdisc via `tc qdisc ... qfq ...` and returns an *tc.Object accordingly.
func ParseRate ¶
ParseRate takes a string of the form `0123456789bBgGKkMmTitps` and returns the equivalent rate as uint64.
func ParseSize ¶
ParseSize takes a string of the form `0123456789gkmbit` and returns the equivalent size as uint64.
func ParseU32Params ¶
ParseU32Params parses the cmdline arguments for `tc filter ... u32 ...` and returns a *tc.Object. ParseU32Params recognizes a limited sub-language of the language that "tc" of iproute2 recognizes. Reference: <https://linux-tc-notes.sourceforge.net/tc/doc/cls_u32.txt>.
func RenderClassID ¶
RenderClassID is the inverse of ParseClassID.
func RenderProto ¶
RenderProto takes the uint16 representation of an EtherType protocol in network byte order and returns the equivalent string.
Types ¶
type Args ¶
type Args struct {
// contains filtered or unexported fields
}
Args holds all possible args for qdisc subcommand tc qdisc [ add | del | replace | change | show ] dev STRING [ handle QHANDLE ] [ root | ingress | clsact | parent CLASSID ] [ estimator INTERVAL TIME_CONSTANT ] [ stab [ help | STAB_OPTIONS] ] [ ingress_block BLOCK_INDEX ] [ egress_block BLOCK_INDEX ] [ [ QDISC_KIND ] [ help | OPTIONS ] ]
func ParseClassArgs ¶
ParseClassArgs takes an io.Writer for output operation and a []string with the provided arguments to parse. It builds a struct of type Args for further operation. Further more it selects the class and calls into the class related parsing function.
type FArgs ¶
type FArgs struct {
// contains filtered or unexported fields
}
FArgs hold all possible args for qdisc subcommand tc filter [ add | del | change | replace | show ] [ dev STRING ] tc filter [ add | del | change | replace | show ] [ block BLOCK_INDEX ] tc filter get dev STRING parent CLASSID protocol PROTO handle FILTERID pref PRIO FILTER_TYPE tc filter get block BLOCK_INDEX protocol PROTO handle FILTERID pref PRIO FILTER_TYPE [ pref PRIO ] protocol PROTO [ chain CHAIN_INDEX ] [ estimator INTERVAL TIME_CONSTANT ] [ root | ingress | egress | parent CLASSID ] [ handle FILTERID ] [ [ FILTER_TYPE ] [ help | OPTIONS ] ] tc filter show [ dev STRING ] [ root | ingress | egress | parent CLASSID ] tc filter show [ block BLOCK_INDEX ]
type Tctl ¶
type Tctl interface {
ShowQdisc(io.Writer, *Args) error
AddQdisc(io.Writer, *Args) error
DeleteQdisc(io.Writer, *Args) error
ReplaceQdisc(io.Writer, *Args) error
ChangeQdisc(io.Writer, *Args) error
ShowClass(io.Writer, *Args) error
AddClass(io.Writer, *Args) error
DeleteClass(io.Writer, *Args) error
ReplaceClass(io.Writer, *Args) error
ChangeClass(io.Writer, *Args) error
ShowFilter(io.Writer, *FArgs) error
AddFilter(io.Writer, *FArgs) error
DeleteFilter(io.Writer, *FArgs) error
ReplaceFilter(io.Writer, *FArgs) error
ChangeFilter(io.Writer, *FArgs) error
GetFilter(io.Writer, *FArgs) error
}
type Trafficctl ¶
func (*Trafficctl) AddClass ¶
func (t *Trafficctl) AddClass(stdout io.Writer, args *Args) error
AddClass realizes the `tc class add dev <DEV> ... ` functionality
func (*Trafficctl) AddFilter ¶
func (t *Trafficctl) AddFilter(stdout io.Writer, fArgs *FArgs) error
AddFilter implements the functionality of `tc filter add ...`
func (*Trafficctl) AddQdisc ¶
func (t *Trafficctl) AddQdisc(stdout io.Writer, args *Args) error
AddQdisc implements the functionality of `tc qdisc add ... `
func (*Trafficctl) ChangeClass ¶
func (t *Trafficctl) ChangeClass(stdout io.Writer, args *Args) error
ChangeClass implements the changing of a classful qdisc with `tc class change ...`
func (*Trafficctl) ChangeFilter ¶
func (t *Trafficctl) ChangeFilter(stdout io.Writer, fArgs *FArgs) error
ChangeFilter implements the functionality of `tc filter change ... ` Note: Not implemented yet
func (*Trafficctl) ChangeQdisc ¶
func (t *Trafficctl) ChangeQdisc(stdout io.Writer, args *Args) error
ChangeQdisc implements the functionality of `tc qdisc change ... `
func (*Trafficctl) DeleteClass ¶
func (t *Trafficctl) DeleteClass(stdout io.Writer, args *Args) error
DeleteClass realizes the `tc class del dev <DEV> ...` functionality
func (*Trafficctl) DeleteFilter ¶
func (t *Trafficctl) DeleteFilter(stdout io.Writer, fArgs *FArgs) error
DeleteFilter implements the functionality of `tc filter del ... `
func (*Trafficctl) DeleteQdisc ¶
func (t *Trafficctl) DeleteQdisc(stdout io.Writer, args *Args) error
DeleteQdisc implements the functionality of `tc qdisc del ... `
func (*Trafficctl) GetFilter ¶
func (t *Trafficctl) GetFilter(stdout io.Writer, fArgs *FArgs) error
GetFilter implements the functionality of `tc filter get ... ` Note: Not implemented yet
func (*Trafficctl) ReplaceClass ¶
func (t *Trafficctl) ReplaceClass(stdout io.Writer, args *Args) error
ReplaceClass implements the replacement of a classful qdisc with `tc class replace ...`
func (*Trafficctl) ReplaceFilter ¶
func (t *Trafficctl) ReplaceFilter(stdout io.Writer, fArgs *FArgs) error
ReplaceFilter implements the functionality of `tc filter replace ... ` Note: Not implemented yet
func (*Trafficctl) ReplaceQdisc ¶
func (t *Trafficctl) ReplaceQdisc(stdout io.Writer, args *Args) error
ReplaceQdisc implements the functionality of `tc qdisc replace ... `
func (*Trafficctl) ShowClass ¶
func (t *Trafficctl) ShowClass(stdout io.Writer, args *Args) error
ShowClass realizes the `tc class show dev <DEV>` functionality
func (*Trafficctl) ShowFilter ¶
func (t *Trafficctl) ShowFilter(stdout io.Writer, fArgs *FArgs) error
ShowFilter implements the functionality of `tc filter show ...`