Documentation
¶
Index ¶
- Constants
- func GenerateRouterID(nodeIPAware utils.NodeIPAware, configRouterID string) (string, error)
- func ParseNextHop(path *apiutil.Path) (net.IP, error)
- func ParsePath(path *apiutil.Path) (*net.IPNet, net.IP, error)
- func ValidateCommunity(arg string) error
- type PathBuilder
- type PeerConfig
- type PeerConfigs
Constants ¶
const ( CommunityMaxSize = 32 CommunityMaxPartSize = 16 )
Variables ¶
This section is empty.
Functions ¶
func GenerateRouterID ¶
func GenerateRouterID(nodeIPAware utils.NodeIPAware, configRouterID string) (string, error)
GenerateRouterID will generate a router ID based upon the user's configuration (or lack there of) and the node's primary IP address if the user has not specified. If the user has configured the router ID as "generate" then we will generate a router ID based upon fnv hashing the node's primary IP address.
func ParseNextHop ¶
ParseNextHop takes in a GoBGP Path and parses out the destination's next hop from its attributes. If it can't parse a next hop IP from the GoBGP Path, it returns an error.
func ParsePath ¶
ParsePath takes in a GoBGP Path and parses out the destination subnet and the next hop from its attributes. If successful, it will return the destination of the BGP path as a subnet form and the next hop. If it can't parse the destination or the next hop IP, it returns an error.
func ValidateCommunity ¶
ValidateCommunity takes in a string and attempts to parse a BGP community out of it in a way that is similar to gobgp (internal/pkg/table/policy.go:ParseCommunity()). If it is not able to parse the community information it returns an error.
Types ¶
type PathBuilder ¶ added in v2.7.0
type PathBuilder struct {
// contains filtered or unexported fields
}
PathBuilder helps construct BGP paths with native GoBGP v4 types. It automatically handles IPv4 vs IPv6 differences including: - Correct Family (AFI_IP/AFI_IP6 + SAFI_UNICAST) - NextHop attribute for IPv4 - MpReachNLRI attribute for IPv6
func NewPathBuilder ¶ added in v2.7.0
func NewPathBuilder(cidr string, nextHop string) (*PathBuilder, error)
NewPathBuilder creates a new PathBuilder for the given CIDR prefix and next-hop IP. It automatically detects IPv4 vs IPv6 from the CIDR and creates the appropriate BGP path attributes.
Example:
pb, err := bgp.NewPathBuilder("10.244.1.0/24", "192.168.1.1")
pb, err := bgp.NewPathBuilder("2001:db8::/64", "2001:db8::1")
func (*PathBuilder) Build ¶ added in v2.7.0
func (pb *PathBuilder) Build() (*apiutil.Path, error)
Build creates the final apiutil.Path ready to be sent to GoBGP.
func (*PathBuilder) WithWithdrawal ¶ added in v2.7.0
func (pb *PathBuilder) WithWithdrawal() *PathBuilder
WithWithdrawal marks this path as a withdrawal. Returns the builder for method chaining.
type PeerConfig ¶ added in v2.7.0
type PeerConfig struct {
// contains filtered or unexported fields
}
func NewPeerConfig ¶ added in v2.7.0
func NewPeerConfig(remoteIPStr string, remoteASN uint32, port *uint32, b64EncodedPassword utils.Base64String, localIP string, ) (PeerConfig, error)
func (PeerConfig) LocalIP ¶ added in v2.7.0
func (p PeerConfig) LocalIP() string
func (PeerConfig) Password ¶ added in v2.7.0
func (p PeerConfig) Password() string
func (PeerConfig) Port ¶ added in v2.7.0
func (p PeerConfig) Port() *uint32
func (PeerConfig) RemoteASN ¶ added in v2.7.0
func (p PeerConfig) RemoteASN() uint32
func (PeerConfig) RemoteIP ¶ added in v2.7.0
func (p PeerConfig) RemoteIP() net.IP
func (PeerConfig) String ¶ added in v2.7.0
func (p PeerConfig) String() string
Custom Stringer to prevent leaking passwords when printed
func (*PeerConfig) UnmarshalYAML ¶ added in v2.7.0
func (p *PeerConfig) UnmarshalYAML(raw []byte) error
type PeerConfigs ¶ added in v2.7.0
type PeerConfigs []PeerConfig
func NewPeerConfigs ¶ added in v2.7.0
func (PeerConfigs) RemoteIPStrings ¶ added in v2.7.0
func (p PeerConfigs) RemoteIPStrings() []string
func (PeerConfigs) String ¶ added in v2.7.0
func (p PeerConfigs) String() string
Prints the PeerConfigs without the passwords leaking