Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
FolderOrigin-RevId: /usr/local/google/home/gdennis/copybara/temp/folder-destination15452520251719964447/.
  • Loading branch information
GGN Engprod Team authored and greg-dennis committed Apr 14, 2023
1 parent 707c5ac commit f2668de
Show file tree
Hide file tree
Showing 23 changed files with 57,147 additions and 47,269 deletions.
2,510 changes: 1,899 additions & 611 deletions gnmi/oc/acl/acl-0.go

Large diffs are not rendered by default.

529 changes: 529 additions & 0 deletions gnmi/oc/enum.go

Large diffs are not rendered by default.

250 changes: 250 additions & 0 deletions gnmi/oc/enum_map.go

Large diffs are not rendered by default.

2,764 changes: 2,571 additions & 193 deletions gnmi/oc/networkinstance/networkinstance-0.go

Large diffs are not rendered by default.

2,510 changes: 1,899 additions & 611 deletions gnmi/oc/qos/qos-0.go

Large diffs are not rendered by default.

92,503 changes: 47,122 additions & 45,381 deletions gnmi/oc/schema.go

Large diffs are not rendered by default.

1,014 changes: 1,006 additions & 8 deletions gnmi/oc/structs-0.go

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions gnmi/oc/union.go
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,38 @@ func (t *NetworkInstance_Protocol_Isis_Interface_Level_Af_SegmentRouting_PrefixS
return nil, fmt.Errorf("cannot convert %v to NetworkInstance_Protocol_Isis_Interface_Level_Af_SegmentRouting_PrefixSid_SidId_Union, unknown union type, got: %T, want any of [E_PrefixSid_SidId, string, uint32]", i, i)
}

// NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union is an interface that is implemented by valid types for the union
// for the leaf /openconfig-network-instance/network-instances/network-instance/protocols/protocol/isis/interfaces/interface/weighted-ecmp/state/load-balancing-weight within the YANG schema.
// Union type can be one of [E_WeightedEcmp_LoadBalancingWeight, UnionUint32].
type NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union interface {
// Union type can be one of [E_WeightedEcmp_LoadBalancingWeight, UnionUint32]
Documentation_for_NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union()
}

// Documentation_for_NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union ensures that E_WeightedEcmp_LoadBalancingWeight
// implements the NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union interface.
func (E_WeightedEcmp_LoadBalancingWeight) Documentation_for_NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union() {
}

// Documentation_for_NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union ensures that UnionUint32
// implements the NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union interface.
func (UnionUint32) Documentation_for_NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union() {
}

// To_NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union takes an input interface{} and attempts to convert it to a struct
// which implements the NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union union. It returns an error if the interface{} supplied
// cannot be converted to a type within the union.
func (t *NetworkInstance_Protocol_Isis_Interface_WeightedEcmp) To_NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union(i interface{}) (NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union, error) {
if v, ok := i.(NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union); ok {
return v, nil
}
switch v := i.(type) {
case uint32:
return UnionUint32(v), nil
}
return nil, fmt.Errorf("cannot convert %v to NetworkInstance_Protocol_Isis_Interface_WeightedEcmp_LoadBalancingWeight_Union, unknown union type, got: %T, want any of [E_WeightedEcmp_LoadBalancingWeight, uint32]", i, i)
}

// NetworkInstance_Protocol_Isis_Level_Lsp_Tlv_Capability_Subtlv_SegmentRoutingCapability_SrgbDescriptor_Label_Union is an interface that is implemented by valid types for the union
// for the leaf /openconfig-network-instance/network-instances/network-instance/protocols/protocol/isis/levels/level/link-state-database/lsp/tlvs/tlv/router-capabilities/capability/subtlvs/subtlv/segment-routing-capability/srgb-descriptors/srgb-descriptor/state/label within the YANG schema.
// Union type can be one of [E_SrgbDescriptor_Label, UnionUint32].
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/golang/glog v1.0.0
github.com/google/go-cmp v0.5.9
github.com/jstemmer/go-junit-report/v2 v2.0.1-0.20220823220451-7b10b4285462
github.com/open-traffic-generator/snappi/gosnappi v0.11.1
github.com/open-traffic-generator/snappi/gosnappi v0.11.6
github.com/openconfig/gnmi v0.9.1
github.com/openconfig/gnoi v0.0.0-20230221223856-1727ed932554
github.com/openconfig/gocloser v0.0.0-20220310182203-c6c950ed3b0b
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,8 @@ github.com/onsi/ginkgo/v2 v2.6.0 h1:9t9b9vRUbFq3C4qKFCGkVuq/fIHji802N1nrtkh1mNc=
github.com/onsi/gomega v1.24.1 h1:KORJXNNTzJXzu4ScJWssJfJMnJ+2QJqhoQSRwNlze9E=
github.com/open-traffic-generator/ixia-c-operator v0.3.0 h1:DFINZYbM9MLNnKvi2+BgQgrwXZvXFG3Y7jRm+Qv/4mQ=
github.com/open-traffic-generator/ixia-c-operator v0.3.0/go.mod h1:Q+ZXCinXxUKcnrJf5PJC1Q7JxUQc5ZPZA85jwVAqIRQ=
github.com/open-traffic-generator/snappi/gosnappi v0.11.1 h1:WmnP5x24VzxFyvX3wpnu2/2VO9QS2Tcg7fIT6Qkx7uw=
github.com/open-traffic-generator/snappi/gosnappi v0.11.1/go.mod h1:fn1cKH3d4otb4jqmMzNEKIff12aKDBPVv5oU322loDs=
github.com/open-traffic-generator/snappi/gosnappi v0.11.6 h1:fdodQjjYzWa+KWtnzdBRXKt64YfyHsDs/voVa4pvkbo=
github.com/open-traffic-generator/snappi/gosnappi v0.11.6/go.mod h1:qANKzg3A2ywyGUpDEEDAAMEAkBoGuSWraPThyagli+4=
github.com/openconfig/gnmi v0.0.0-20200414194230-1597cc0f2600/go.mod h1:M/EcuapNQgvzxo1DDXHK4tx3QpYM/uG4l591v33jG2A=
github.com/openconfig/gnmi v0.0.0-20200508230933-d19cebf5e7be/go.mod h1:M/EcuapNQgvzxo1DDXHK4tx3QpYM/uG4l591v33jG2A=
github.com/openconfig/gnmi v0.9.1 h1:hVOdLTaRjdy68oCGJbkf2vrmnUoQ5xbINqBOAMix4xM=
Expand Down Expand Up @@ -880,6 +880,7 @@ golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458/go.mod h1:YDH+HFinaLZZlnHAfS
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -996,12 +997,14 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -1016,6 +1019,7 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down Expand Up @@ -1307,7 +1311,6 @@ google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD
google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww=
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag=
google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
Expand All @@ -1326,7 +1329,6 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
61 changes: 61 additions & 0 deletions headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,67 @@ func (h *MACsecHeader) asPB() *opb.Header {
return &opb.Header{Type: &opb.Header_Macsec{h.pb}}
}

// NewESP returns a new ESP header.
func NewESP() *ESPHeader {
return &ESPHeader{&opb.EspHeader{}}
}

// ESPHeader is an ESP packet header.
type ESPHeader struct {
pb *opb.EspHeader
}

func (h *ESPHeader) asPB() *opb.Header {
return &opb.Header{Type: &opb.Header_Esp{h.pb}}
}

// WithSecurityParametersIndex sets the SPI of the ESP header.
func (h *ESPHeader) WithSecurityParametersIndex(spi uint32) *ESPHeader {
h.pb.SecurityParametersIndex = spi
return h
}

// WithSequenceNumber sets the sequence number of the ESP header.
func (h *ESPHeader) WithSequenceNumber(sn uint32) *ESPHeader {
h.pb.SequenceNumber = intRangeSingle(sn)
return h
}

// NewESPOverMACSec returns a new ESP-over-MACSec header.
func NewESPOverMACSec() *ESPOverMACSecHeader {
return &ESPOverMACSecHeader{&opb.EspOverMacSecHeader{}}
}

// ESPOverMACSecHeader is an ESP-over-MACSec packet header.
type ESPOverMACSecHeader struct {
pb *opb.EspOverMacSecHeader
}

func (h *ESPOverMACSecHeader) asPB() *opb.Header {
return &opb.Header{Type: &opb.Header_EspOverMacsec{h.pb}}
}

// WithSecurityParametersIndex sets the SPI of the ESP-over-MAC header.
func (h *ESPOverMACSecHeader) WithSecurityParametersIndex(spi uint32) *ESPOverMACSecHeader {
h.pb.SecurityParametersIndex = spi
return h
}

// WithSequenceNumber sets the sequence number of the ESP-over-MACSec header.
func (h *ESPOverMACSecHeader) WithSequenceNumber(sn uint32) *ESPOverMACSecHeader {
h.pb.SequenceNumber = intRangeSingle(sn)
return h
}

// SequenceNumberRange sets the sequence number of the ESP-over-MACSec header
// to a range of values (defaulting to 1) and returns the range.
func (h *ESPOverMACSecHeader) SequenceNumberRange() *ixnet.UIntRange {
if h.pb.SequenceNumber == nil {
h.pb.SequenceNumber = intRangeSingle(1)
}
return ixnet.NewUIntRange(h.pb.SequenceNumber)
}

func intRangeSingle(i uint32) *opb.UIntRange {
return &opb.UIntRange{Min: i, Max: i, Count: 1}
}
Expand Down
34 changes: 34 additions & 0 deletions internal/ate/stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ func headerStacks(hdr *opb.Header, idx int, hasSrcVLAN bool) ([]*ixconfig.Traffi
return nil, err
}
return []*ixconfig.TrafficTrafficItemConfigElementStack{s, ppts}, nil
case *opb.Header_Esp:
s, err := espStack(v.Esp, idx)
if err != nil {
return nil, err
}
return []*ixconfig.TrafficTrafficItemConfigElementStack{s}, nil
case *opb.Header_EspOverMacsec:
s, err := espOverMacsecStack(v.EspOverMacsec, idx)
if err != nil {
return nil, err
}
return []*ixconfig.TrafficTrafficItemConfigElementStack{s}, nil
default:
return nil, fmt.Errorf("unrecognized header type: %v", hdr)
}
Expand Down Expand Up @@ -677,3 +689,25 @@ func macsecStack(macsec *opb.MacsecHeader, idx int) (*ixconfig.TrafficTrafficIte
func payloadProtocolTypeStack(idx int) (*ixconfig.TrafficTrafficItemConfigElementStack, error) {
return ixconfig.NewPayloadProtocolTypeStack(idx).TrafficTrafficItemConfigElementStack(), nil
}

func espStack(esp *opb.EspHeader, idx int) (*ixconfig.TrafficTrafficItemConfigElementStack, error) {
stack := ixconfig.NewIpEncapsulatingSecurityPayloadStack(idx)
setSingleValue(stack.Spi(), uintToStr(esp.GetSecurityParametersIndex()))
if esp.GetSequenceNumber() != nil {
if err := setUintRangeField(stack.Sn(), esp.GetSequenceNumber()); err != nil {
return nil, fmt.Errorf("could not set sequence numbers: %w", err)
}
}
return stack.TrafficTrafficItemConfigElementStack(), nil
}

func espOverMacsecStack(esp *opb.EspOverMacSecHeader, idx int) (*ixconfig.TrafficTrafficItemConfigElementStack, error) {
stack := ixconfig.NewIpEspOverMACsecStack(idx)
setSingleValue(stack.Spi(), uintToStr(esp.GetSecurityParametersIndex()))
if esp.GetSequenceNumber() != nil {
if err := setUintRangeField(stack.Sn(), esp.GetSequenceNumber()); err != nil {
return nil, fmt.Errorf("could not set sequence numbers: %w", err)
}
}
return stack.TrafficTrafficItemConfigElementStack(), nil
}
50 changes: 50 additions & 0 deletions internal/ate/stacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,56 @@ func TestHeaderStacks(t *testing.T) {
},
},
wantFields: [][]wantField{{}, {}},
}, {
desc: "ESP header",
hdr: &opb.Header{
Type: &opb.Header_Esp{
&opb.EspHeader{
SecurityParametersIndex: 511,
SequenceNumber: &opb.UIntRange{Min: 1, Max: 1, Count: 1},
},
},
},
wantFields: [][]wantField{{{
name: "spi",
wantVal: ixconfig.String("511"),
toField: func(s *ixconfig.TrafficTrafficItemConfigElementStack) *ixconfig.TrafficTrafficItemConfigElementStackField {
i := ixconfig.IpEncapsulatingSecurityPayloadStack(*s)
return (&i).Spi()
},
}, {
name: "sequence numbers",
wantVal: ixconfig.String(strconv.Itoa(1)),
toField: func(s *ixconfig.TrafficTrafficItemConfigElementStack) *ixconfig.TrafficTrafficItemConfigElementStackField {
i := ixconfig.IpEncapsulatingSecurityPayloadStack(*s)
return (&i).Sn()
},
}}},
}, {
desc: "ESP over MACSec header",
hdr: &opb.Header{
Type: &opb.Header_EspOverMacsec{
&opb.EspOverMacSecHeader{
SecurityParametersIndex: 511,
SequenceNumber: &opb.UIntRange{Min: 1, Max: 1, Count: 1},
},
},
},
wantFields: [][]wantField{{{
name: "spi",
wantVal: ixconfig.String("511"),
toField: func(s *ixconfig.TrafficTrafficItemConfigElementStack) *ixconfig.TrafficTrafficItemConfigElementStackField {
i := ixconfig.IpEspOverMACsecStack(*s)
return (&i).Spi()
},
}, {
name: "sequence numbers",
wantVal: ixconfig.String(strconv.Itoa(1)),
toField: func(s *ixconfig.TrafficTrafficItemConfigElementStack) *ixconfig.TrafficTrafficItemConfigElementStackField {
i := ixconfig.IpEspOverMACsecStack(*s)
return (&i).Sn()
},
}}},
}}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
Expand Down
Loading

0 comments on commit f2668de

Please sign in to comment.