github.com/haraldrudell/parl@v0.4.176/pnet/route.go (about) 1 /* 2 © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/) 3 ISC License 4 */ 5 6 package pnet 7 8 // Route describes a routing table route with destination and next hop 9 type Route struct { 10 Destination 11 NextHop 12 } 13 14 // NewRoute instantiates Route 15 func NewRoute(d *Destination, nextHop *NextHop) *Route { 16 r := Route{} 17 if d != nil { 18 r.Destination = *d 19 } 20 if nextHop != nil { 21 r.NextHop = *nextHop 22 } 23 return &r 24 } 25 func (r *Route) Dump() (s string) { 26 return "rt_" + r.Destination.String() + "_" + r.NextHop.Dump() 27 } 28 29 func (r *Route) String() (s string) { 30 return r.Destination.String() + " via " + r.NextHop.String() 31 }