(a *api.Peer)
| 1002 | } |
| 1003 | |
| 1004 | func newNeighborFromAPIStruct(a *api.Peer) (*oc.Neighbor, error) { |
| 1005 | pconf := &oc.Neighbor{} |
| 1006 | if a.Conf != nil { |
| 1007 | var err error |
| 1008 | pconf.Config.PeerAs = a.Conf.PeerAsn |
| 1009 | pconf.Config.LocalAs = a.Conf.LocalAsn |
| 1010 | pconf.Config.AuthPassword = a.Conf.AuthPassword |
| 1011 | pconf.Config.RouteFlapDamping = a.Conf.RouteFlapDamping |
| 1012 | pconf.Config.Description = a.Conf.Description |
| 1013 | pconf.Config.PeerGroup = a.Conf.PeerGroup |
| 1014 | pconf.Config.PeerType, err = PeerTypeFromApi(a.Conf.Type) |
| 1015 | if err != nil { |
| 1016 | return nil, err |
| 1017 | } |
| 1018 | if addr, err := netip.ParseAddr(a.Conf.NeighborAddress); err == nil { |
| 1019 | pconf.Config.NeighborAddress = addr |
| 1020 | } |
| 1021 | pconf.Config.AdminDown = a.Conf.AdminDown |
| 1022 | pconf.Config.NeighborInterface = a.Conf.NeighborInterface |
| 1023 | pconf.Config.Vrf = a.Conf.Vrf |
| 1024 | pconf.AsPathOptions.Config.AllowOwnAs = uint8(a.Conf.AllowOwnAsn) |
| 1025 | pconf.AsPathOptions.Config.ReplacePeerAs = a.Conf.ReplacePeerAsn |
| 1026 | pconf.AsPathOptions.Config.AllowAsPathLoopLocal = a.Conf.AllowAspathLoopLocal |
| 1027 | pconf.Config.SendSoftwareVersion = a.Conf.SendSoftwareVersion |
| 1028 | |
| 1029 | switch a.Conf.RemovePrivate { |
| 1030 | case api.RemovePrivate_REMOVE_PRIVATE_ALL: |
| 1031 | pconf.Config.RemovePrivateAs = oc.REMOVE_PRIVATE_AS_OPTION_ALL |
| 1032 | case api.RemovePrivate_REMOVE_PRIVATE_REPLACE: |
| 1033 | pconf.Config.RemovePrivateAs = oc.REMOVE_PRIVATE_AS_OPTION_REPLACE |
| 1034 | } |
| 1035 | |
| 1036 | if a.State != nil { |
| 1037 | localCaps, err := apiutil.UnmarshalCapabilities(a.State.LocalCap) |
| 1038 | if err != nil { |
| 1039 | return nil, err |
| 1040 | } |
| 1041 | remoteCaps, err := apiutil.UnmarshalCapabilities(a.State.RemoteCap) |
| 1042 | if err != nil { |
| 1043 | return nil, err |
| 1044 | } |
| 1045 | pconf.State.LocalCapabilityList = localCaps |
| 1046 | pconf.State.RemoteCapabilityList = remoteCaps |
| 1047 | |
| 1048 | if addr, err := netip.ParseAddr(a.State.RouterId); err == nil { |
| 1049 | pconf.State.RemoteRouterId = addr |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | for _, af := range a.AfiSafis { |
| 1054 | afiSafi := oc.AfiSafi{} |
| 1055 | readMpGracefulRestartFromAPIStruct(&afiSafi.MpGracefulRestart, af.MpGracefulRestart) |
| 1056 | readAfiSafiConfigFromAPIStruct(&afiSafi.Config, af.Config) |
| 1057 | readAfiSafiStateFromAPIStruct(&afiSafi.State, af.Config) |
| 1058 | readApplyPolicyFromAPIStruct(&afiSafi.ApplyPolicy, af.ApplyPolicy) |
| 1059 | readRouteSelectionOptionsFromAPIStruct(&afiSafi.RouteSelectionOptions, af.RouteSelectionOptions) |
| 1060 | readUseMultiplePathsFromAPIStruct(&afiSafi.UseMultiplePaths, af.UseMultiplePaths) |
| 1061 | readPrefixLimitFromAPIStruct(&afiSafi.PrefixLimit, af.PrefixLimits) |
no test coverage detected
searching dependent graphs…