@@ -35,44 +35,53 @@ const (
35
35
36
36
// Constants of full Match names.
37
37
const (
38
- arpOp = "arp_op"
39
- arpSHA = "arp_sha"
40
- arpSPA = "arp_spa"
41
- arpTHA = "arp_tha"
42
- arpTPA = "arp_tpa"
43
- conjID = "conj_id"
44
- ctMark = "ct_mark"
45
- ctState = "ct_state"
46
- ctZone = "ct_zone"
47
- dlSRC = "dl_src"
48
- dlDST = "dl_dst"
49
- dlType = "dl_type"
50
- dlVLAN = "dl_vlan"
51
- dlVLANPCP = "dl_vlan_pcp"
52
- icmpType = "icmp_type"
53
- icmpCode = "icmp_code"
54
- icmp6Type = "icmpv6_type"
55
- icmp6Code = "icmpv6_code"
56
- ipv6DST = "ipv6_dst"
57
- ipv6SRC = "ipv6_src"
58
- ipv6Label = "ipv6_label"
59
- ipFrag = "ip_frag"
60
- metadata = "metadata"
61
- ndSLL = "nd_sll"
62
- ndTLL = "nd_tll"
63
- ndTarget = "nd_target"
64
- nwECN = "nw_ecn"
65
- nwDST = "nw_dst"
66
- nwProto = "nw_proto"
67
- nwTOS = "nw_tos"
68
- nwTTL = "nw_ttl"
69
- nwSRC = "nw_src"
70
- tcpFlags = "tcp_flags"
71
- tpDST = "tp_dst"
72
- tpSRC = "tp_src"
73
- tunID = "tun_id"
74
- vlanTCI = "vlan_tci"
75
- vlanTCI1 = "vlan_tci1"
38
+ arpOp = "arp_op"
39
+ arpSHA = "arp_sha"
40
+ arpSPA = "arp_spa"
41
+ arpTHA = "arp_tha"
42
+ arpTPA = "arp_tpa"
43
+ conjID = "conj_id"
44
+ ctMark = "ct_mark"
45
+ ctState = "ct_state"
46
+ ctZone = "ct_zone"
47
+ dlDST = "dl_dst"
48
+ dlSRC = "dl_src"
49
+ dlType = "dl_type"
50
+ dlVLAN = "dl_vlan"
51
+ dlVLANPCP = "dl_vlan_pcp"
52
+ icmp6Code = "icmpv6_code"
53
+ icmp6Type = "icmpv6_type"
54
+ icmpCode = "icmp_code"
55
+ icmpType = "icmp_type"
56
+ ipFrag = "ip_frag"
57
+ ipv6DST = "ipv6_dst"
58
+ ipv6Label = "ipv6_label"
59
+ ipv6SRC = "ipv6_src"
60
+ metadata = "metadata"
61
+ ndSLL = "nd_sll"
62
+ ndTarget = "nd_target"
63
+ ndTLL = "nd_tll"
64
+ nwDST = "nw_dst"
65
+ nwECN = "nw_ecn"
66
+ nwProto = "nw_proto"
67
+ nwSRC = "nw_src"
68
+ nwTOS = "nw_tos"
69
+ nwTTL = "nw_ttl"
70
+ tcpFlags = "tcp_flags"
71
+ tpDST = "tp_dst"
72
+ tpSRC = "tp_src"
73
+ tunDST = "tun_dst"
74
+ tunFlags = "tun_flags"
75
+ tunGbpFlags = "tun_gbp_flags"
76
+ tunGbpID = "tun_gbp_id"
77
+ tunID = "tun_id"
78
+ tunSRC = "tun_src"
79
+ tunTOS = "tun_tos"
80
+ tunTTL = "tun_ttl"
81
+ tunv6DST = "tun_ipv6_dst"
82
+ tunv6SRC = "tun_ipv6_src"
83
+ vlanTCI1 = "vlan_tci1"
84
+ vlanTCI = "vlan_tci"
76
85
)
77
86
78
87
// A Match is a type which can be marshaled into an OpenFlow packet matching
@@ -336,6 +345,78 @@ func (t *networkTOS) GoString() string {
336
345
return fmt .Sprintf ("ovs.NetworkTOS(%d)" , t .tos )
337
346
}
338
347
348
+ // TunnelGBP returns a new tunnelGBP
349
+ func TunnelGBP (gbp int ) Match {
350
+ return & tunnelGBP {
351
+ gbp : gbp ,
352
+ }
353
+ }
354
+
355
+ var _ Match = & tunnelGBP {}
356
+
357
+ // tunnelGBP is a match for tunnel GBP
358
+ type tunnelGBP struct {
359
+ gbp int
360
+ }
361
+
362
+ // MarshalText implements Match.
363
+ func (t * tunnelGBP ) MarshalText () ([]byte , error ) {
364
+ return bprintf ("tun_gbp_id=%d" , t .gbp ), nil
365
+ }
366
+
367
+ // GoString implements Match.
368
+ func (t * tunnelGBP ) GoString () string {
369
+ return fmt .Sprintf ("ovs.TunnelGBP(%d)" , t .gbp )
370
+ }
371
+
372
+ // TunnelGbpFlags returns a new tunnelFlags
373
+ func TunnelGbpFlags (gbpFlags int ) Match {
374
+ return & tunnelGbpFlags {
375
+ gbpFlags : gbpFlags ,
376
+ }
377
+ }
378
+
379
+ var _ Match = & tunnelGbpFlags {}
380
+
381
+ // tunnelGbpFlags is a match for tunnel Flags
382
+ type tunnelGbpFlags struct {
383
+ gbpFlags int
384
+ }
385
+
386
+ // MarshalText implements Match.
387
+ func (t * tunnelGbpFlags ) MarshalText () ([]byte , error ) {
388
+ return bprintf ("tun_gbp_flags=%d" , t .gbpFlags ), nil
389
+ }
390
+
391
+ // GoString implements Match.
392
+ func (t * tunnelGbpFlags ) GoString () string {
393
+ return fmt .Sprintf ("ovs.TunnelGbpFlags(%d)" , t .gbpFlags )
394
+ }
395
+
396
+ // TunnelFlags returns a new tunnelFlags
397
+ func TunnelFlags (flags int ) Match {
398
+ return & tunnelFlags {
399
+ flags : flags ,
400
+ }
401
+ }
402
+
403
+ var _ Match = & tunnelFlags {}
404
+
405
+ // tunnelFlags is a match for tunnel Flags
406
+ type tunnelFlags struct {
407
+ flags int
408
+ }
409
+
410
+ // MarshalText implements Match.
411
+ func (t * tunnelFlags ) MarshalText () ([]byte , error ) {
412
+ return bprintf ("tun_flags=%d" , t .flags ), nil
413
+ }
414
+
415
+ // GoString implements Match.
416
+ func (t * tunnelFlags ) GoString () string {
417
+ return fmt .Sprintf ("ovs.TunnelFlags(%d)" , t .flags )
418
+ }
419
+
339
420
// NetworkTTL returns a new networkTTL
340
421
func NetworkTTL (ttl int ) Match {
341
422
return & networkTTL {
@@ -360,6 +441,30 @@ func (t *networkTTL) GoString() string {
360
441
return fmt .Sprintf ("ovs.NetworkTTL(%d)" , t .ttl )
361
442
}
362
443
444
+ // TunnelTTL returns a new tunnelTTL
445
+ func TunnelTTL (ttl int ) Match {
446
+ return & tunnelTTL {
447
+ ttl : ttl ,
448
+ }
449
+ }
450
+
451
+ var _ Match = & tunnelTTL {}
452
+
453
+ // tunnelTTL is a match for a tunnel time to live
454
+ type tunnelTTL struct {
455
+ ttl int
456
+ }
457
+
458
+ // MarshalText implements Match.
459
+ func (t * tunnelTTL ) MarshalText () ([]byte , error ) {
460
+ return bprintf ("tun_ttl=%d" , t .ttl ), nil
461
+ }
462
+
463
+ // GoString implements Match.
464
+ func (t * tunnelTTL ) GoString () string {
465
+ return fmt .Sprintf ("ovs.TunnelTTL(%d)" , t .ttl )
466
+ }
467
+
363
468
// ConjunctionID matches flows that have matched all dimension of a conjunction
364
469
// inside of the openflow table.
365
470
func ConjunctionID (id uint32 ) Match {
@@ -368,6 +473,30 @@ func ConjunctionID(id uint32) Match {
368
473
}
369
474
}
370
475
476
+ // TunnelTOS returns a new tunnelTOS
477
+ func TunnelTOS (tos int ) Match {
478
+ return & tunnelTOS {
479
+ tos : tos ,
480
+ }
481
+ }
482
+
483
+ var _ Match = & tunnelTOS {}
484
+
485
+ // tunnelTOS is a match for a tunnel type of service
486
+ type tunnelTOS struct {
487
+ tos int
488
+ }
489
+
490
+ // MarshalText implements Match.
491
+ func (t * tunnelTOS ) MarshalText () ([]byte , error ) {
492
+ return bprintf ("tun_tos=%d" , t .tos ), nil
493
+ }
494
+
495
+ // GoString implements Match.
496
+ func (t * tunnelTOS ) GoString () string {
497
+ return fmt .Sprintf ("ovs.TunnelTOS(%d)" , t .tos )
498
+ }
499
+
371
500
// A conjunctionIDMatch is a Match returned by ConjunctionID
372
501
type conjunctionIDMatch struct {
373
502
id uint32
@@ -1214,6 +1343,44 @@ func (m *tunnelIDMatch) MarshalText() ([]byte, error) {
1214
1343
return bprintf ("%s=%#x/%#x" , tunID , m .id , m .mask ), nil
1215
1344
}
1216
1345
1346
+ // TunnelSrc returns a Match with specified Tunnel Source.
1347
+ func TunnelSrc (addr string ) Match {
1348
+ return & tunnelMatch {
1349
+ srcdst : source ,
1350
+ ip : addr ,
1351
+ }
1352
+ }
1353
+
1354
+ // TunnelDst returns a Match with specified Tunnel Destination.
1355
+ func TunnelDst (addr string ) Match {
1356
+ return & tunnelMatch {
1357
+ srcdst : destination ,
1358
+ ip : addr ,
1359
+ }
1360
+ }
1361
+
1362
+ var _ Match = & tunnelMatch {}
1363
+
1364
+ // A tunnelMatch is a Match against a tunnel {source|destination}.
1365
+ type tunnelMatch struct {
1366
+ srcdst string
1367
+ ip string
1368
+ }
1369
+
1370
+ // GoString implements Match.
1371
+ func (m * tunnelMatch ) GoString () string {
1372
+ if m .srcdst == source {
1373
+ return fmt .Sprintf ("ovs.TunnelSrc(%q)" , m .ip )
1374
+ }
1375
+
1376
+ return fmt .Sprintf ("ovs.TunnelDst(%q)" , m .ip )
1377
+ }
1378
+
1379
+ // MarshalText implements Match.
1380
+ func (m * tunnelMatch ) MarshalText () ([]byte , error ) {
1381
+ return matchIPv4AddressOrCIDR (fmt .Sprintf ("tun_%s" , m .srcdst ), m .ip )
1382
+ }
1383
+
1217
1384
// Metadata returns a Match that matches the given metadata value.
1218
1385
func Metadata (m uint64 ) Match {
1219
1386
return & metadataMatch {
0 commit comments