Skip to content

Commit

Permalink
Add prefix dedup function that also dedups IPs
Browse files Browse the repository at this point in the history
  • Loading branch information
takt committed Oct 11, 2019
1 parent 59e01a4 commit e0b63db
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions net/prefix.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func (p *Prefix) Dedup() *Prefix {
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
func NewPrefixFromProtoPrefix(pfx api.Prefix) *Prefix {
return &Prefix{
Expand Down Expand Up @@ -54,10 +60,10 @@ func PrefixFromString(s string) (*Prefix, error) {
}

// ToProto converts prefix to proto prefix
func (pfx *Prefix) ToProto() *api.Prefix {
func (p *Prefix) ToProto() *api.Prefix {
return &api.Prefix{
Address: pfx.addr.ToProto(),
Pfxlen: uint32(pfx.pfxlen),
Address: p.addr.ToProto(),
Pfxlen: uint32(p.pfxlen),
}
}

Expand Down

0 comments on commit e0b63db

Please sign in to comment.