github.com/haraldrudell/parl@v0.4.176/pnet/action.go (about) 1 /* 2 © 2023-present Harald Rudell <haraldrudell@proton.me> (https://haraldrudell.github.io/haraldrudell/) 3 All rights reserved 4 */ 5 6 package pnet 7 8 import "github.com/haraldrudell/parl/sets" 9 10 const ( 11 AddRoute Action = iota + 1 // AddRoute describes a new route added to the routing table 12 DeleteRoute // DeleteRoute describes a deleted route 13 RouteReport // RouteReport describes an existing route 14 Partition // Partition describes an existing route that may be overridden 15 AddHost // AddHost is a host added to the routing table 16 DeleteHost // DeleteHost is a deleted host 17 HostReport // HostReport is an existing host 18 IfAddAddr // IfAddAddr Add address to interface 19 IfDeleteAddr // IfDeleteAddr Delete address from interface 20 IfStatus // network-interface upDownStatus or down string 21 AddMulticast // AddMulticast annouces a multicast address 22 DeleteMulticast // DeleteMulticast annouces a multicast address disappearing 23 ) 24 25 // Action describes the message action 26 type Action uint8 27 28 func (a Action) Description() (s string) { 29 return actionSet.Description(a) 30 } 31 32 func (a Action) IsValid() (isValid bool) { 33 var invalidAction Action 34 return a != invalidAction 35 } 36 37 func (a Action) String() (s string) { 38 return actionSet.StringT(a) 39 } 40 41 var actionSet = sets.NewSet[Action]([]sets.SetElementFull[Action]{ 42 {ValueV: AddHost, Name: "addHost", Full: "new host"}, 43 {ValueV: DeleteHost, Name: "delHost", Full: "delete host"}, 44 {ValueV: HostReport, Name: "host", Full: "host"}, 45 {ValueV: IfAddAddr, Name: "ifAddr", Full: "address"}, 46 {ValueV: IfDeleteAddr, Name: "ifDelAddr", Full: "delete address"}, 47 {ValueV: IfStatus, Name: "ifStatus", Full: "if status"}, 48 {ValueV: AddMulticast, Name: "ifAddM", Full: "add multicast"}, 49 {ValueV: DeleteMulticast, Name: "ifDelM", Full: "delete multicast"}, 50 {ValueV: AddRoute, Name: "addRoute", Full: "add route"}, 51 {ValueV: DeleteRoute, Name: "delRoute", Full: "delete route"}, 52 {ValueV: Partition, Name: "demoted", Full: "demoted"}, 53 {ValueV: RouteReport, Name: "report", Full: "report"}, // a route does not have a prefix other than 0/0 or 192.168.1.21/32 54 })