Move flags to their own modules

This commit is contained in:
Pim van Pelt
2025-06-09 18:18:38 +02:00
parent fb3c545e11
commit b6cdcd16ba
4 changed files with 23 additions and 17 deletions

View File

@ -11,6 +11,7 @@ import (
"go.fd.io/govpp/api"
"govpp-snmp-example/logger"
"govpp-snmp-example/vppstats"
)
// IF-MIB OID bases:
@ -65,14 +66,12 @@ type InterfaceMIB struct {
ifEntrySession *agentx.Session
ifXTableSession *agentx.Session
stats map[uint32]*api.InterfaceCounters // indexed by interface index
indexOffset int
}
func NewInterfaceMIB(indexOffset int) *InterfaceMIB {
func NewInterfaceMIB() *InterfaceMIB {
return &InterfaceMIB{
handler: &agentx.ListHandler{},
stats: make(map[uint32]*api.InterfaceCounters),
indexOffset: indexOffset,
handler: &agentx.ListHandler{},
stats: make(map[uint32]*api.InterfaceCounters),
}
}
@ -110,7 +109,7 @@ func (m *InterfaceMIB) UpdateStats(interfaceStats *api.InterfaceStats) {
}
func (m *InterfaceMIB) addInterfaceToMIB(iface *api.InterfaceCounters) {
idx := int(iface.InterfaceIndex) + m.indexOffset
idx := int(iface.InterfaceIndex) + *vppstats.IfIndexOffset
// Add ifEntry (classic interface table) entries
m.addIfEntry(iface, idx)