xfrm_state.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package netlink
  2. import (
  3. "net"
  4. )
  5. // XfrmStateAlgo represents the algorithm to use for the ipsec encryption.
  6. type XfrmStateAlgo struct {
  7. Name string
  8. Key []byte
  9. TruncateLen int // Auth only
  10. }
  11. // EncapType is an enum representing an ipsec template direction.
  12. type EncapType uint8
  13. const (
  14. XFRM_ENCAP_ESPINUDP_NONIKE EncapType = iota + 1
  15. XFRM_ENCAP_ESPINUDP
  16. )
  17. func (e EncapType) String() string {
  18. switch e {
  19. case XFRM_ENCAP_ESPINUDP_NONIKE:
  20. return "espinudp-nonike"
  21. case XFRM_ENCAP_ESPINUDP:
  22. return "espinudp"
  23. }
  24. return "unknown"
  25. }
  26. // XfrmEncap represents the encapsulation to use for the ipsec encryption.
  27. type XfrmStateEncap struct {
  28. Type EncapType
  29. SrcPort int
  30. DstPort int
  31. OriginalAddress net.IP
  32. }
  33. // XfrmState represents the state of an ipsec policy. It optionally
  34. // contains an XfrmStateAlgo for encryption and one for authentication.
  35. type XfrmState struct {
  36. Dst net.IP
  37. Src net.IP
  38. Proto Proto
  39. Mode Mode
  40. Spi int
  41. Reqid int
  42. ReplayWindow int
  43. Auth *XfrmStateAlgo
  44. Crypt *XfrmStateAlgo
  45. Encap *XfrmStateEncap
  46. }