Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnnotatedField ¶
type Data ¶
type Data interface { SetSeq(uint32) Raw() *api.GadgetData // contains filtered or unexported methods }
type DataFunc ¶
type DataFunc func(DataSource, Data) error
DataFunc is the callback that will be called for Data emitted by a DataSource. Data has to be consumed synchronously and may not be accessed after returning - make a copy if you need to hold on to Data.
type DataSource ¶
type DataSource interface { // Name returns the name of the data source Name() string // Type returns the type of the data source Type() Type // AddStaticFields adds fields inside a container that has a fixed size; use it to directly map for example // eBPF structs AddStaticFields(totalSize uint32, fields []StaticField) (FieldAccessor, error) // AddField adds a field as a new payload AddField(fieldName string, options ...FieldOption) (FieldAccessor, error) // NewData builds a new data structure that can be written to NewData() Data GetField(fieldName string) FieldAccessor GetFieldsWithTag(tag ...string) []FieldAccessor // EmitAndRelease sends data through the operator chain and releases it afterward; // Data may not be used after calling this. This should only be used in the running phase of the gadget, not // in the initialization phase. EmitAndRelease(Data) error // Release releases the memory of Data; Data may not be used after calling this Release(Data) // ReportLostData reports a number of lost data cases ReportLostData(lostSampleCount uint64) // Dump dumps the content of Data to a writer for debugging purposes Dump(Data, io.Writer) // Subscribe makes sure that events emitted from this DataSource are passed to DataFunc; subscribers will be // sorted by priority and handed over data in that order (lower numbers = earlier). Subscriptions to // DataSources should only happen in the initialization phase. Data sent to dataFn has to be consumed synchronously // and must not be accessed after returning. Subscribe(dataFn DataFunc, priority int) Parser() (parser.Parser, error) Fields() []*api.Field Accessors(rootOnly bool) []FieldAccessor IsRequested() bool // ByteOrder returns a binary accessor using the byte order of the creator of the DataSource ByteOrder() binary.ByteOrder AddAnnotation(key, value string) AddTag(tag string) Annotations() map[string]string Tags() []string }
DataSource is an interface that represents a data source of a gadget. Usually, it represents a map in eBPF and some tooling around handling it in Go. An eBPF program can have multiple DataSources, each one representing a different map.
func New ¶
func New(t Type, name string) DataSource
func NewFromAPI ¶
func NewFromAPI(in *api.DataSource) (DataSource, error)
type DataTuple ¶
type DataTuple struct {
// contains filtered or unexported fields
}
func NewDataTuple ¶
func NewDataTuple(ds DataSource, d Data) *DataTuple
type FieldAccessor ¶
type FieldAccessor interface { Name() string // Size returns the expected size of the underlying field or zero, if the field has a dynamic size Size() uint32 // Get returns the underlying memory of the field Get(data Data) []byte // Set sets value as the new reference for the field; if the FieldAccessor is used for the member of a // statically sized payload (for example a member of an eBPF struct), value will be copied to the existing // memory instead. Set(data Data, value []byte) error // IsRequested returns whether the consumer is interested in this field; if not, operators are not required // to fill them out IsRequested() bool // AddSubField adds a new field as member of the current field; be careful when doing this on an existing // non-empty field, as that might be dropped on serialization // TODO AddSubField(name string, opts ...FieldOption) (FieldAccessor, error) // GetSubFieldsWithTag returns all SubFields matching any given tag GetSubFieldsWithTag(tag ...string) []FieldAccessor // Parent returns the parent of this field, if this field is a SubField Parent() FieldAccessor // SubFields returns all existing SubFields of the current field SubFields() []FieldAccessor // SetHidden marks a field as hidden (by default) - it can still be requested SetHidden(hidden bool, recurse bool) // Type returns the underlying type of the field Type() api.Kind // Flags returns the flags of the field Flags() uint32 // Annotations returns stored annotations of the field Annotations() map[string]string // RemoveReference removes the reference by name from the hierarchy, effectively freeing the name // tbd: name RemoveReference(recurse bool) // Rename changes the name of the field. Currently it's not supported for subfields. Rename(string) error Uint8(Data) uint8 Uint16(Data) uint16 Uint32(Data) uint32 Uint64(Data) uint64 Int8(Data) int8 Int16(Data) int16 Int32(Data) int32 Int64(Data) int64 Float32(Data) float32 Float64(Data) float64 PutUint8(Data, uint8) PutUint16(Data, uint16) PutUint32(Data, uint32) PutUint64(Data, uint64) PutInt8(Data, int8) PutInt16(Data, int16) PutInt32(Data, int32) PutInt64(Data, int64) String(Data) string CString(Data) string }
FieldAccessor grants access to the underlying buffer of a field
type FieldFlag ¶
type FieldFlag uint32
const ( // FieldFlagEmpty means the field cannot have a value FieldFlagEmpty FieldFlag = 1 << iota // FieldFlagContainer means that the field is statically sized and can have multiple statically sized members; // AddStaticFields() will return the container for all given fields, and it is assumed, that the creator will // always assign the full container using Set() FieldFlagContainer // FieldFlagHidden sets a field to invisible FieldFlagHidden // FieldFlagHasParent means that the field is not directly attached to the root of DataSource, but instead to // another field that is referenced to in the Parent field FieldFlagHasParent // FieldFlagStaticMember means that the field is part of a container and is statically sized FieldFlagStaticMember // FieldFlagUnreferenced means that a field is no longer referenced by its name in the DataSource FieldFlagUnreferenced )
func (FieldFlag) RemoveFrom ¶
type FieldOption ¶
type FieldOption func(*field)
func WithAnnotations ¶
func WithAnnotations(annotations map[string]string) FieldOption
func WithFlags ¶
func WithFlags(flags FieldFlag) FieldOption
func WithKind ¶
func WithKind(kind api.Kind) FieldOption
func WithOrder ¶
func WithOrder(order int32) FieldOption
func WithTags ¶
func WithTags(tags ...string) FieldOption
type FlaggedField ¶
type FlaggedField interface {
FieldFlags() FieldFlag
}
type ParentedField ¶
type ParentedField interface { // FieldParent should return an index to the parent of the field, -1 for no parent FieldParent() int }
type StaticField ¶
type TaggedField ¶
type TaggedField interface {
FieldTags() []string
}
type TypedField ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.