@@ -1240,6 +1240,48 @@ func UnsetState(state CTState) string {
12401240 return fmt .Sprintf ("-%s" , state )
12411241}
12421242
1243+ // Metadata returns a Match that matches the given Metadata exactly.
1244+ func Metadata (id uint64 ) Match {
1245+ return & metadataMatch {
1246+ data : id ,
1247+ mask : 0 ,
1248+ }
1249+ }
1250+
1251+ // MetadataWithMask returns a Match with specified Metadata and mask.
1252+ func MetadataWithMask (id , mask uint64 ) Match {
1253+ return & metadataMatch {
1254+ data : id ,
1255+ mask : mask ,
1256+ }
1257+ }
1258+
1259+ var _ Match = & metadataMatch {}
1260+
1261+ // A metadataMatch is a Match against a Metadata field.
1262+ type metadataMatch struct {
1263+ data uint64
1264+ mask uint64
1265+ }
1266+
1267+ // GoString implements Match.
1268+ func (m * metadataMatch ) GoString () string {
1269+ if m .mask > 0 {
1270+ return fmt .Sprintf ("ovs.MetadataWithMask(%#x, %#x)" , m .data , m .mask )
1271+ }
1272+
1273+ return fmt .Sprintf ("ovs.Metadata(%#x)" , m .data )
1274+ }
1275+
1276+ // MarshalText implements Match.
1277+ func (m * metadataMatch ) MarshalText () ([]byte , error ) {
1278+ if m .mask == 0 {
1279+ return bprintf ("%s=%#x" , metadata , m .data ), nil
1280+ }
1281+
1282+ return bprintf ("%s=%#x/%#x" , metadata , m .data , m .mask ), nil
1283+ }
1284+
12431285// TCPFlags matches packets using their enabled TCP flags, when matching TCP
12441286// flags on a TCP segment. Use the SetTCPFlag and UnsetTCPFlag functions to
12451287// populate the parameter list for this function.
@@ -1381,30 +1423,6 @@ func (m *tunnelMatch) MarshalText() ([]byte, error) {
13811423 return matchIPv4AddressOrCIDR (fmt .Sprintf ("tun_%s" , m .srcdst ), m .ip )
13821424}
13831425
1384- // Metadata returns a Match that matches the given metadata value.
1385- func Metadata (m uint64 ) Match {
1386- return & metadataMatch {
1387- m : m ,
1388- }
1389- }
1390-
1391- var _ Match = & metadataMatch {}
1392-
1393- // A metadataMatch is a Match against a metadata value.
1394- type metadataMatch struct {
1395- m uint64
1396- }
1397-
1398- // GoString implements Match.
1399- func (m * metadataMatch ) GoString () string {
1400- return fmt .Sprintf ("ovs.Metadata(%#x)" , m .m )
1401- }
1402-
1403- // MarshalText implements Match.
1404- func (m * metadataMatch ) MarshalText () ([]byte , error ) {
1405- return bprintf ("%s=%#x" , metadata , m .m ), nil
1406- }
1407-
14081426// matchIPv4AddressOrCIDR attempts to create a Match using the specified key
14091427// and input string, which could be interpreted as an IPv4 address or IPv4
14101428// CIDR block.
0 commit comments