Skip to content
Snippets Groups Projects
Commit e0b63db1 authored by takt's avatar takt
Browse files

Add prefix dedup function that also dedups IPs

parent 59e01a4b
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,12 @@ func (p *Prefix) Dedup() *Prefix { ...@@ -22,6 +22,12 @@ func (p *Prefix) Dedup() *Prefix {
return pfxc.get(p) return pfxc.get(p)
} }
// DedupWithIP gets a copy of Prefix from the cache and dedups the IP part
func (p *Prefix) DedupWithIP() *Prefix {
p.addr = p.addr.Dedup()
return pfxc.get(p)
}
// NewPrefixFromProtoPrefix creates a Prefix from a proto Prefix // NewPrefixFromProtoPrefix creates a Prefix from a proto Prefix
func NewPrefixFromProtoPrefix(pfx api.Prefix) *Prefix { func NewPrefixFromProtoPrefix(pfx api.Prefix) *Prefix {
return &Prefix{ return &Prefix{
...@@ -54,10 +60,10 @@ func PrefixFromString(s string) (*Prefix, error) { ...@@ -54,10 +60,10 @@ func PrefixFromString(s string) (*Prefix, error) {
} }
// ToProto converts prefix to proto prefix // ToProto converts prefix to proto prefix
func (pfx *Prefix) ToProto() *api.Prefix { func (p *Prefix) ToProto() *api.Prefix {
return &api.Prefix{ return &api.Prefix{
Address: pfx.addr.ToProto(), Address: p.addr.ToProto(),
Pfxlen: uint32(pfx.pfxlen), Pfxlen: uint32(p.pfxlen),
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment