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-destination14858067647571122187/.
  • Loading branch information
GGN Engprod Team authored and greg-dennis committed Jun 9, 2022
1 parent d76c2ca commit d3150cc
Show file tree
Hide file tree
Showing 44 changed files with 143,867 additions and 143,825 deletions.
86 changes: 56 additions & 30 deletions headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,62 @@ type IPv4Header struct {
pb *opb.Ipv4Header
}

// WithDSCP sets the DSCP field of the IPv4 header.
func (h *IPv4Header) WithDSCP(dscp uint8) *IPv4Header {
h.pb.Dscp = uint32(dscp)
return h
}

// WithECN sets the ECN field of the IPv4 header.
func (h *IPv4Header) WithECN(ecn uint8) *IPv4Header {
h.pb.Ecn = uint32(ecn)
return h
}

// WithIdentification set identification field of IPv4 Header
func (h *IPv4Header) WithIdentification(identification int) *IPv4Header {
h.pb.Identification = uint32(identification)
return h
}

// WithDontFragment sets the "don't fragment" bit of the IPv4 header.
func (h *IPv4Header) WithDontFragment(dontFragment bool) *IPv4Header {
h.pb.DontFragment = dontFragment
return h
}

// WithMoreFragments sets the "more fragments" bit of the IPv4 Header
func (h *IPv4Header) WithMoreFragments(moreFragments bool) *IPv4Header {
h.pb.MoreFragments = moreFragments
return h
}

// WithFragmentOffset sets the fragment offset field of the IPv4 header.
func (h *IPv4Header) WithFragmentOffset(fragmentOffset int) *IPv4Header {
h.pb.FragmentOffset = uint32(fragmentOffset)
return h
}

// WithTTL sets the TTL of the IPv4 header.
func (h *IPv4Header) WithTTL(ttl uint8) *IPv4Header {
h.pb.Ttl = uint32(ttl)
return h
}

// WithProtocol sets the protocol field of the IPv4 header.
// If left unspecified, it will be inferred from the next header in the flow.
func (h *IPv4Header) WithProtocol(protocol int) *IPv4Header {
p := uint32(protocol)
h.pb.Protocol = &p
return h
}

// WithHeaderChecksum sets the header checksum field of the IPv4 header.
func (h *IPv4Header) WithHeaderChecksum(checksum uint16) *IPv4Header {
h.pb.Checksum = uint32(checksum)
return h
}

// WithSrcAddress sets the source IP address of the IPv4 header to the specified value.
// To generate a range of source addresses, use SrcAddressRange() instead.
func (h *IPv4Header) WithSrcAddress(addr string) *IPv4Header {
Expand Down Expand Up @@ -159,36 +215,6 @@ func (h *IPv4Header) DstAddressRange() *AddressRange {
return &AddressRange{AddressIncRange{pb: h.pb.DstAddr}}
}

// WithDontFragment sets the "don't fragment" bit of the IPv4 header.
func (h *IPv4Header) WithDontFragment(dontFragment bool) *IPv4Header {
h.pb.DontFragment = dontFragment
return h
}

// WithTTL sets the TTL of the IPv4 header.
func (h *IPv4Header) WithTTL(ttl uint8) *IPv4Header {
h.pb.Ttl = uint32(ttl)
return h
}

// WithDSCP sets the DSCP value of the IPv4 header.
func (h *IPv4Header) WithDSCP(dscp uint8) *IPv4Header {
h.pb.Dscp = uint32(dscp)
return h
}

// WithECN sets the ECN value of the IPv4 header.
func (h *IPv4Header) WithECN(ecn uint8) *IPv4Header {
h.pb.Ecn = uint32(ecn)
return h
}

// WithHeaderChecksum sets the header checksum value of the IPv4 header.
func (h *IPv4Header) WithHeaderChecksum(checksum uint16) *IPv4Header {
h.pb.Checksum = uint32(checksum)
return h
}

func (h *IPv4Header) asPB() *opb.Header {
return &opb.Header{Type: &opb.Header_Ipv4{h.pb}}
}
Expand Down
15 changes: 10 additions & 5 deletions internal/ate/ixate.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,9 @@ func (vw *viewWrapper) FetchTable(ctx context.Context, drilldowns ...string) (ix

// IPv4/6 route tables specified by local path.
type routeTables struct {
format routeTableFormat
ipv4, ipv6 string
format routeTableFormat
ipv4, ipv6 string
overwriteNexthop bool
}

type intf struct {
Expand Down Expand Up @@ -418,6 +419,10 @@ func importBgpRoutes(ctx context.Context, ix *ixATE, node ixconfig.IxiaCfgNode,
pools = "ipv6PrefixPools"
rp = "bgpV6IPRouteProperty"
}
nextHop := "preserveFromFile"
if rt.overwriteNexthop {
nextHop = "overwriteTestersAddress"
}

nodeID, err := ix.c.NodeID(node)
if err != nil {
Expand All @@ -426,9 +431,9 @@ func importBgpRoutes(ctx context.Context, ix *ixATE, node ixconfig.IxiaCfgNode,
importPath := fmt.Sprintf("topology/deviceGroup/networkGroup/%s/%s/operations/importbgproutes", pools, rp)
return ix.c.Session().Post(ctx, importPath, ixweb.OpArgs{
nodeID,
"replicate", // Replicate routes on each configured peer.
false, // Import all routes, not just the 'best' routes.
"overwriteTestersAddress", // Overwrite next hops in the file to use the device group's IPv4 address.
"replicate", // Replicate routes on each configured peer.
false, // Import all routes, not just the 'best' routes.
nextHop,
rt.format,
ix.routeTableToIxFile[rtFile],
}, nil)
Expand Down
8 changes: 7 additions & 1 deletion internal/ate/ixate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1661,7 +1661,13 @@ func TestStartTraffic(t *testing.T) {
t.Errorf("StartTraffic: unexpected error result, got err: %v, want err? %t", gotErr, test.wantErr)
}

if !test.wantErr && test.wantCfgFile != "" {
if !test.wantErr {
if test.wantCfgFile == "" {
if fc.lastImportCfg != nil {
t.Fatalf("StartTraffic: Did not want traffic config pushed, got\n%v", fc.lastImportCfg)
}
return
}
wantCfg := toTrafficCfg(t, test.wantCfgFile)
if diff := jsonCfgDiff(t, wantCfg, fc.lastImportCfg); diff != "" {
t.Fatalf("StartTraffic: Unexpected traffic config pushed, diff (-want, +got)\n%s", diff)
Expand Down
Loading

0 comments on commit d3150cc

Please sign in to comment.