Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions plugins/inputs/ah_trap/ah_trap.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,22 @@ func (t *TrapPlugin) Gather_Ah_send_trap(trapType uint32, trapBuf [256]byte, acc
"systemId_faMvlanTrap": fmt.Sprintf("%X", mvlan.SystemID),
}, nil)

case AH_MSG_TRAP_DHCP_OPTION55:
var dhcp AhDhcpOption55Trap
copy((*[unsafe.Sizeof(dhcp)]byte)(unsafe.Pointer(&dhcp))[:], trapBuf[:unsafe.Sizeof(dhcp)])
optLen := int(dhcp.Opt55Len)
if optLen < 0 {
optLen = 0
}
if optLen > len(dhcp.Data) {
optLen = len(dhcp.Data)
}
acc.AddFields("TrapEvent", map[string]interface{}{
"trapId_dhcpOption55Trap": dhcp.TrapId,
"staMac_dhcpOption55Trap": ahutil.FormatMac(dhcp.StaMac),
"option55_dhcpOption55Trap": ahutil.CleanCString(dhcp.Data[:optLen]),
}, nil)

case AH_MSG_TRAP_DFS_BANG:
var dfs AhTgrafDfsTrap
copy((*[unsafe.Sizeof(dfs)]byte)(unsafe.Pointer(&dfs))[:], trapBuf[:unsafe.Sizeof(dfs)])
Expand Down Expand Up @@ -543,6 +559,20 @@ func (t *TrapPlugin) trapListener(conn net.PacketConn) {
if err := t.Ah_send_sta_leave_trap(trapType, trapBuf, t.acc); err != nil {
log.Printf("[ah_trap] Error gathering STA LEAVE STATS trap: %v", err)
}

case AH_MSG_TRAP_DHCP_OPTION55:
var dhcp AhDhcpOption55Trap
expected := int(unsafe.Sizeof(dhcp))
if len(payload) < expected {
log.Printf("[ah_trap] Invalid DHCP OPTION55 size: got %d, expected at least %d", len(payload), expected)
continue
}
var trapBuf [256]byte
copy(trapBuf[:expected], payload[:expected])
if err := t.Gather_Ah_send_trap(trapType, trapBuf, t.acc); err != nil {
log.Printf("[ah_trap] Error gathering DHCP OPTION55 trap: %v", err)
}

case AH_MSG_TRAP_SSID_BIND_UNBIND:
var SsidBindUnbind AhTgrafSsidBindUnbindTrap
expected := int(unsafe.Sizeof(SsidBindUnbind))
Expand Down
9 changes: 9 additions & 0 deletions plugins/inputs/ah_trap/ah_trap_defines_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
TRAP_DCRPT_LEN = 96
AH_MSG_TRAP_DFS_BANG = 12
AH_MSG_TRAP_STA_LEAVE_STATS = 6
AH_MSG_TRAP_DHCP_OPTION55 = 123
MACADDR_LEN = 6
MAX_DESCRIBLE_LEN = 128
AH_CAPWAP_STAT_NAME_MAX_LEN = 32
Expand Down Expand Up @@ -76,6 +77,14 @@ type AhTgrafSsidBindUnbindTrap struct {
State uint8
}

type AhDhcpOption55Trap struct {
TrapId uint8
DataLen uint16
StaMac [6]uint8
Opt55Len uint8
Data [0]uint8
}

type AhTgrafBSSIDSpoofingTrap struct {
TrapID uint8
IfName [AH_MAX_TRAP_OBJ_NAME + 1]byte
Expand Down