Skip to content

Commit 673ded7

Browse files
Support mpls_tc match (#20)
- Add MplsTc field - Support match mpls_tc Signed-off-by: XiaoYiXiaoYang <[email protected]>
1 parent 8bafd6c commit 673ded7

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.7.0
1+
v0.7.1

openflow13/match.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ func DecodeMatchField(class uint16, field uint8, length uint8, hasMask bool, dat
288288
case OXM_FIELD_MPLS_LABEL:
289289
val = new(MplsLabelField)
290290
case OXM_FIELD_MPLS_TC:
291+
val = new(MplsTcField)
291292
case OXM_FIELD_MPLS_BOS:
292293
val = new(MplsBosField)
293294
case OXM_FIELD_PBB_ISID:
@@ -873,6 +874,44 @@ func NewMplsBosField(mplsBos uint8) *MatchField {
873874
return f
874875
}
875876

877+
// MplsTc field
878+
type MplsTcField struct {
879+
MplsTc uint8
880+
}
881+
882+
func (m *MplsTcField) Len() uint16 {
883+
return 1
884+
}
885+
886+
func (m *MplsTcField) MarshalBinary() (data []byte, err error) {
887+
data = make([]byte, 1)
888+
data[0] = m.MplsTc
889+
return
890+
}
891+
892+
func (m *MplsTcField) UnmarshalBinary(data []byte) error {
893+
if len(data) < int(m.Len()) {
894+
return fmt.Errorf("the []byte is too short to unmarshal a full MplsTcField message")
895+
}
896+
897+
m.MplsTc = data[0]
898+
return nil
899+
}
900+
901+
// Return a MatchField for mpls Tc matching
902+
func NewMplsTcField(mplsTc uint8) *MatchField {
903+
f := new(MatchField)
904+
f.Class = OXM_CLASS_OPENFLOW_BASIC
905+
f.Field = OXM_FIELD_MPLS_TC
906+
f.HasMask = false
907+
908+
mplsTcField := new(MplsTcField)
909+
mplsTcField.MplsTc = mplsTc
910+
f.Value = mplsTcField
911+
f.Length = uint8(mplsTcField.Len())
912+
return f
913+
}
914+
876915
// IPV4_SRC field
877916
type Ipv4SrcField struct {
878917
Ipv4Src net.IP

0 commit comments

Comments
 (0)