mirror of
https://github.com/vishvananda/netlink
synced 2025-01-16 20:13:32 +00:00
Add String() method to user structures (#116)
Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
parent
cb0b035c41
commit
e361359783
@ -46,6 +46,11 @@ type XfrmPolicyTmpl struct {
|
||||
Reqid int
|
||||
}
|
||||
|
||||
func (t XfrmPolicyTmpl) String() string {
|
||||
return fmt.Sprintf("{Dst: %v, Src: %v, Proto: %s, Mode: %s, Reqid: 0x%x}",
|
||||
t.Dst, t.Src, t.Proto, t.Mode, t.Reqid)
|
||||
}
|
||||
|
||||
// XfrmPolicy represents an ipsec policy. It represents the overlay network
|
||||
// and has a list of XfrmPolicyTmpls representing the base addresses of
|
||||
// the policy.
|
||||
@ -61,3 +66,8 @@ type XfrmPolicy struct {
|
||||
Mark *XfrmMark
|
||||
Tmpls []XfrmPolicyTmpl
|
||||
}
|
||||
|
||||
func (p XfrmPolicy) String() string {
|
||||
return fmt.Sprintf("{Dst: %v, Src: %v, Proto: %s, DstPort: %d, SrcPort: %d, Dir: %s, Priority: %d, Index: %d, Mark: %s, Tmpls: %s}",
|
||||
p.Dst, p.Src, p.Proto, p.DstPort, p.SrcPort, p.Dir, p.Priority, p.Index, p.Mark, p.Tmpls)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package netlink
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
@ -11,6 +12,10 @@ type XfrmStateAlgo struct {
|
||||
TruncateLen int // Auth only
|
||||
}
|
||||
|
||||
func (a XfrmStateAlgo) String() string {
|
||||
return fmt.Sprintf("{Name: %s, Key: 0x%x, TruncateLen: %d}", a.Name, a.Key, a.TruncateLen)
|
||||
}
|
||||
|
||||
// EncapType is an enum representing an ipsec template direction.
|
||||
type EncapType uint8
|
||||
|
||||
@ -37,6 +42,11 @@ type XfrmStateEncap struct {
|
||||
OriginalAddress net.IP
|
||||
}
|
||||
|
||||
func (e XfrmStateEncap) String() string {
|
||||
return fmt.Sprintf("{Type: %s, Srcport: %d, DstPort: %d, OriginalAddress: %v}",
|
||||
e.Type, e.SrcPort, e.DstPort, e.OriginalAddress)
|
||||
}
|
||||
|
||||
// XfrmState represents the state of an ipsec policy. It optionally
|
||||
// contains an XfrmStateAlgo for encryption and one for authentication.
|
||||
type XfrmState struct {
|
||||
@ -52,3 +62,8 @@ type XfrmState struct {
|
||||
Crypt *XfrmStateAlgo
|
||||
Encap *XfrmStateEncap
|
||||
}
|
||||
|
||||
func (sa XfrmState) String() string {
|
||||
return fmt.Sprintf("Dst: %v, Src: %v, Proto: %s, Mode: %s, SPI: 0x%x, ReqID: 0x%x, ReplayWindow: %d, Mark: %v, Auth: %v, Crypt: %v, Encap: %v",
|
||||
sa.Dst, sa.Src, sa.Proto, sa.Mode, sa.Spi, sa.Reqid, sa.ReplayWindow, sa.Mark, sa.Auth, sa.Crypt, sa.Encap)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user