interim commit go fmt stuff
Change-Id: I617a7d771b50c2b7999eabbbebbabef4e68d8713
diff --git a/openflow/utils.go b/openflow/utils.go
index 160b2ab..aba7400 100644
--- a/openflow/utils.go
+++ b/openflow/utils.go
@@ -17,9 +17,14 @@
package openflow
import (
+ "encoding/json"
"fmt"
+ "log"
"strings"
"sync"
+
+ ofp "github.com/donNewtonAlpha/goloxi/of13"
+ "github.com/opencord/voltha-protos/go/openflow_13"
)
var mu sync.Mutex
@@ -38,3 +43,73 @@
padded := strings.Repeat(null, nullsNeeded)
return fmt.Sprintf("%s%s", value, padded)
}
+
+func extractAction(action ofp.IAction) *openflow_13.OfpAction {
+ var ofpAction openflow_13.OfpAction
+ switch action.GetType() {
+ case ofp.OFPATOutput:
+ var outputAction openflow_13.OfpAction_Output
+ loxiOutputAction := action.(*ofp.ActionOutput)
+ var output openflow_13.OfpActionOutput
+ output.Port = uint32(loxiOutputAction.Port)
+ output.MaxLen = uint32(loxiOutputAction.MaxLen)
+ outputAction.Output = &output
+ ofpAction.Action = &outputAction
+ ofpAction.Type = openflow_13.OfpActionType_OFPAT_OUTPUT
+ case ofp.OFPATCopyTtlOut: //CopyTtltOut
+ case ofp.OFPATCopyTtlIn: //CopyTtlIn
+ case ofp.OFPATSetMplsTtl: //SetMplsTtl
+ case ofp.OFPATDecMplsTtl: //DecMplsTtl
+ case ofp.OFPATPushVLAN: //PushVlan
+ var pushVlan openflow_13.OfpAction_Push
+ loxiPushAction := action.(*ofp.ActionPushVlan)
+ fields := loxiPushAction.GetActionFields()
+ fieldsJS, _ := json.Marshal(fields)
+ log.Printf("\n\nPushVlan fields %s\n\n", fieldsJS)
+ var push openflow_13.OfpActionPush
+ push.Ethertype = uint32(loxiPushAction.Ethertype) //TODO This should be available in the fields
+ pushVlan.Push = &push
+ ofpAction.Type = openflow_13.OfpActionType_OFPAT_PUSH_VLAN
+ ofpAction.Action = &pushVlan
+ case ofp.OFPATPopVLAN: //PopVlan
+ ofpAction.Type = openflow_13.OfpActionType_OFPAT_POP_VLAN
+ case ofp.OFPATPushMpls: //PushMpls
+ case ofp.OFPATPopMpls: //PopMpls
+ case ofp.OFPATSetQueue: //SetQueue
+ case ofp.OFPATGroup: //ActionGroup
+ case ofp.OFPATSetNwTtl: //SetNwTtl
+ case ofp.OFPATDecNwTtl: //DecNwTtl
+ case ofp.OFPATSetField: //SetField
+ ofpAction.Type = openflow_13.OfpActionType_OFPAT_SET_FIELD
+ var ofpAction_SetField openflow_13.OfpAction_SetField
+ var ofpActionSetField openflow_13.OfpActionSetField
+ var ofpOxmField openflow_13.OfpOxmField
+ ofpOxmField.OxmClass = openflow_13.OfpOxmClass_OFPXMC_OPENFLOW_BASIC
+ var ofpOxmField_OfbField openflow_13.OfpOxmField_OfbField
+ var ofpOxmOfbField openflow_13.OfpOxmOfbField
+ loxiSetField := action.(*ofp.ActionSetField)
+ oxmName := loxiSetField.Field.GetOXMName()
+ switch oxmName {
+ case "vlan_vid":
+ ofpOxmOfbField.Type = openflow_13.OxmOfbFieldTypes_OFPXMT_OFB_VLAN_VID
+ var vlanVid openflow_13.OfpOxmOfbField_VlanVid
+ var VlanVid = loxiSetField.Field.GetOXMValue().(uint16)
+ vlanVid.VlanVid = uint32(VlanVid)
+
+ ofpOxmOfbField.Value = &vlanVid
+ default:
+ log.Printf("UNHANDLED SET FIELD %s", oxmName)
+ }
+ ofpOxmField_OfbField.OfbField = &ofpOxmOfbField
+ ofpOxmField.Field = &ofpOxmField_OfbField
+ ofpActionSetField.Field = &ofpOxmField
+ ofpAction_SetField.SetField = &ofpActionSetField
+ ofpAction.Action = &ofpAction_SetField
+ case ofp.OFPATPushPbb: //PushPbb
+ case ofp.OFPATPopPbb: //PopPbb
+ case ofp.OFPATExperimenter: //Experimenter
+
+ }
+ return &ofpAction
+
+}