avpindexer

package module
v0.0.0-...-0e35924 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

avpindexer

Utility code working with gopacket diameter branch, allows easy navigation through an AVP graph.

AVPs in Diameter messages are a list of trees, or more specifically any other tree of AVPs can go under an AVP of type 'grouped'. As such your application will want an easy way to find and process AVPs of interest. All standard and derived Diameter types from RFC6733 are supported.

examples
pkt = gopacket.NewPacket(pktbuf, layers.LayerTypeDiameter, gopacket.Default)
dia = gpacket.Layer(layers.LayerTypeDiameter).(*layers.Diameter)

// create indexer; entire graph is scanned once
ai := NewAvpIndexer(dia)

vendor := 0
attrId := 485

// typed get method
v = ai.GetUint32(vendor, attrId)

// get net.IP from subgroup
v = ai.FromGroup(10415, 874).GetIPAddress(10415, 1228)

// add up numeric values from AVPs that may occur more than once
sum = ai.FromGroup(10415, 2040).AccumulateUint64(0, 364)

// visitor pattern
ai.VisitAvp(10415, 18, func(avp *layers.AVP) {
    // ...	
})

Ryan Mitchell rjm@tcl.net

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAvpDataToMap

func AddAvpDataToMap(avps []*layers.AVP, data map[string]string)

Copy AVP decoded (string) values into a flat map value only if the key (AVP name, per RFC) exists in same map. Clobbers previous values as found.

func JsonFromAvpFields

func JsonFromAvpFields(avps []*layers.AVP, includeFields []string) string

Create flat map json string similar to AddAvpDataToMap()

func PrintAvp

func PrintAvp(avp *layers.AVP, indent int)

Recursively prints AVP values to stdout, indenting with grouped sub-AVPs, starting at given indent level.

func PrintAvps

func PrintAvps(d *layers.Diameter)

Recursively prints AVP values to stdout, indenting with grouped sub-AVPs.

func VisitAvp

func VisitAvp(avp *layers.AVP, visitor func(*layers.AVP))

func VisitAvps

func VisitAvps(dmsg *layers.Diameter, visitor func(*layers.AVP))

Apply the visitor function to all AVPs contained in the diameter message.

Types

type AvpIndexer

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

Indexer that facilitates convenient path matching and typed retrieval of AVP values. Usage:

ai = NewAvpIndexer(diaMsg)
ai.GetUint32(vendorId,attrId)
ai.FromGroup(vendorId,attrId).FromGroup(attrId2, vendorId2).GetTime(vendorId,attrId)
ai.FromGroup(vendorId,attrId).AccumulateUint64(vendorId,attrId)
ai.FromGroup(vendorId,attrId).VisitAvp(vendorId, attrId, f)

func NewAvpIndexer

func NewAvpIndexer(d *layers.Diameter) AvpIndexer

Create a new instance of an AvpIndexer for the diameter message.

func (AvpIndexer) AccumulateUint64

func (ai AvpIndexer) AccumulateUint64(vendorId, attrId uint32) uint64

add up uint64 vales for all matching AVPs

func (AvpIndexer) FromGroup

func (ai AvpIndexer) FromGroup(vendorId, attrId uint32) avpIndexerWithPath

return indexer that starts all retrieval operations from the given id (may match multiple nodes)

func (AvpIndexer) GetEnumerated

func (ai AvpIndexer) GetEnumerated(vendorId, attrId uint32) uint32

retrieve first matching enumerated (uint32) value with given id, or the default/zero value for that type

func (AvpIndexer) GetFloat32

func (ai AvpIndexer) GetFloat32(vendorId, attrId uint32) float32

retrieve first matching float32 value with given id, or the default/zero value for that type

func (AvpIndexer) GetFloat64

func (ai AvpIndexer) GetFloat64(vendorId, attrId uint32) float64

retrieve first matching float64 value with given id, or the default/zero value for that type

func (AvpIndexer) GetIPAddress

func (ai AvpIndexer) GetIPAddress(vendorId, attrId uint32) net.IP

retrieve first matching net.IP value with given id, or the default/zero value for that type

func (AvpIndexer) GetInt32

func (ai AvpIndexer) GetInt32(vendorId, attrId uint32) int32

retrieve first matching int32 value with given id, or the default/zero value for that type

func (AvpIndexer) GetInt64

func (ai AvpIndexer) GetInt64(vendorId, attrId uint32) int64

retrieve first matching int64 value with given id, or the default/zero value for that type

func (AvpIndexer) GetTime

func (ai AvpIndexer) GetTime(vendorId, attrId uint32) time.Time

retrieve first matching time.Time value with given id, or the default/zero value for that type

func (AvpIndexer) GetUTF8String

func (ai AvpIndexer) GetUTF8String(vendorId, attrId uint32) string

retrieve first matching string value with given id, or the default/zero value for that type

func (AvpIndexer) GetUint32

func (ai AvpIndexer) GetUint32(vendorId, attrId uint32) uint32

retrieve first matching uint32 value with given id, or the default/zero value for that type

func (AvpIndexer) GetUint64

func (ai AvpIndexer) GetUint64(vendorId, attrId uint32) uint64

retrieve first matching uint64 value with given id, or the default/zero value for that type

func (AvpIndexer) VisitAvp

func (ai AvpIndexer) VisitAvp(vendorId, attrId uint32, f func(avp *layers.AVP)) int

invoke f for each matching AVP found. returns number of times f was invoked.

Jump to

Keyboard shortcuts

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