MCPcopy
hub / github.com/osrg/gobgp / newGlobalFromAPIStruct

Function newGlobalFromAPIStruct

pkg/server/grpc_server.go:2408–2490  ·  view source on GitHub ↗
(a *api.Global)

Source from the content-addressed store, hash-verified

2406}
2407
2408func newGlobalFromAPIStruct(a *api.Global) *oc.Global {
2409 families := make([]oc.AfiSafi, 0, len(a.Families))
2410 for _, f := range a.Families {
2411 name := oc.IntToAfiSafiTypeMap[int(f)]
2412 rf, _ := bgp.GetFamily(string(name))
2413 families = append(families, oc.AfiSafi{
2414 Config: oc.AfiSafiConfig{
2415 AfiSafiName: name,
2416 Enabled: true,
2417 },
2418 State: oc.AfiSafiState{
2419 AfiSafiName: name,
2420 Enabled: true,
2421 Family: rf,
2422 },
2423 })
2424 }
2425
2426 l := make([]netip.Addr, 0, len(a.ListenAddresses))
2427 for _, addr := range a.ListenAddresses {
2428 l = append(l, netip.MustParseAddr(addr))
2429 }
2430
2431 global := &oc.Global{
2432 Config: oc.GlobalConfig{
2433 As: a.Asn,
2434 RouterId: netip.MustParseAddr(a.RouterId),
2435 Port: a.ListenPort,
2436 LocalAddressList: l,
2437 BindToDevice: a.BindToDevice,
2438 },
2439 AfiSafis: families,
2440 UseMultiplePaths: oc.UseMultiplePaths{
2441 Config: oc.UseMultiplePathsConfig{
2442 Enabled: a.UseMultiplePaths,
2443 },
2444 },
2445 }
2446 if a.RouteSelectionOptions != nil {
2447 global.RouteSelectionOptions = oc.RouteSelectionOptions{
2448 Config: oc.RouteSelectionOptionsConfig{
2449 AlwaysCompareMed: a.RouteSelectionOptions.AlwaysCompareMed,
2450 IgnoreAsPathLength: a.RouteSelectionOptions.IgnoreAsPathLength,
2451 ExternalCompareRouterId: a.RouteSelectionOptions.ExternalCompareRouterId,
2452 AdvertiseInactiveRoutes: a.RouteSelectionOptions.AdvertiseInactiveRoutes,
2453 EnableAigp: a.RouteSelectionOptions.EnableAigp,
2454 IgnoreNextHopIgpMetric: a.RouteSelectionOptions.IgnoreNextHopIgpMetric,
2455 DisableBestPathSelection: a.RouteSelectionOptions.DisableBestPathSelection,
2456 },
2457 }
2458 }
2459 if a.DefaultRouteDistance != nil {
2460 global.DefaultRouteDistance = oc.DefaultRouteDistance{
2461 Config: oc.DefaultRouteDistanceConfig{
2462 ExternalRouteDistance: uint8(a.DefaultRouteDistance.ExternalRouteDistance),
2463 InternalRouteDistance: uint8(a.DefaultRouteDistance.InternalRouteDistance),
2464 },
2465 }

Callers 1

StartBgpMethod · 0.85

Calls 1

GetFamilyFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…