@@ -378,11 +378,56 @@ func (t *TrapPlugin) Gather_Ah_send_trap(trapType uint32, trapBuf [256]byte, acc
378378 "powerMode_poeTrap" : powerModeToString (poe .PowerMode ),
379379 }, nil )
380380
381+ case AH_MSG_TRAP_BOOTOS :
382+ var bootos AhTgrafBootOsTrap
383+ copy ((* [unsafe .Sizeof (bootos )]byte )(unsafe .Pointer (& bootos ))[:], trapBuf [:unsafe .Sizeof (bootos )])
384+
385+ acc .AddFields ("TrapEvent" , map [string ]interface {}{
386+ "trapId_bootosTrap" : bootos .TrapID ,
387+ "osType_bootosTrap" : osTypeToString (bootos .OsType ),
388+ "status_bootosTrap" : bootosStatusToString (bootos .Status ),
389+ "description_bootosTrap" : ahutil .CleanCString (bootos .Description [:]),
390+ }, nil )
391+
381392 }
382393
383394 return nil
384395}
385396
397+ /*
398+ Helper function to convert osType value to string for bootos trap
399+ */
400+ func osTypeToString (osType uint8 ) string {
401+ switch osType {
402+ case 0 :
403+ return "HOS"
404+ case 1 :
405+ return "WiNG"
406+ case 2 :
407+ return "WiNG-CAMP"
408+ case 3 :
409+ return "WiNG-DIST"
410+ default :
411+ return fmt .Sprintf ("UNKNOWN(%d)" , osType )
412+ }
413+ }
414+
415+ /*
416+ Helper function to convert bootos status value to string
417+ */
418+ func bootosStatusToString (status uint8 ) string {
419+ switch status {
420+ case 0 :
421+ return "Success"
422+ case 1 :
423+ return "Failed"
424+ case 2 :
425+ return "Legacy HW"
426+ default :
427+ return fmt .Sprintf ("UNKNOWN(%d)" , status )
428+ }
429+ }
430+
386431/*
387432Helper function to convert powerMode value to string
388433*/
@@ -565,7 +610,19 @@ func (t *TrapPlugin) trapListener(conn net.PacketConn) {
565610 if err := t .Gather_Ah_send_trap (trapType , trapBuf , t .acc ); err != nil {
566611 log .Printf ("[ah_trap] Error gathering Poe trap: %v" , err )
567612 }
568- }
613+ case AH_MSG_TRAP_BOOTOS :
614+ var bootos AhTgrafBootOsTrap
615+ expected := int (unsafe .Sizeof (bootos ))
616+ if len (payload ) != expected {
617+ log .Printf ("[ah_trap] Invalid Bootos size: got %d, expected %d" , len (payload ), expected )
618+ continue
619+ }
620+ var trapBuf [AH_TRAP_SIZE_256 ]byte
621+ copy (trapBuf [:expected ], payload )
622+ if err := t .Gather_Ah_send_trap (trapType , trapBuf , t .acc ); err != nil {
623+ log .Printf ("[ah_trap] Error gathering Bootos trap: %v" , err )
624+ }
625+ }
569626 }
570627}
571628
0 commit comments