genetlink_linux.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package nl
  2. import (
  3. "unsafe"
  4. )
  5. const SizeofGenlmsg = 4
  6. const (
  7. GENL_ID_CTRL = 0x10
  8. GENL_CTRL_VERSION = 2
  9. GENL_CTRL_NAME = "nlctrl"
  10. )
  11. const (
  12. GENL_CTRL_CMD_GETFAMILY = 3
  13. )
  14. const (
  15. GENL_CTRL_ATTR_UNSPEC = iota
  16. GENL_CTRL_ATTR_FAMILY_ID
  17. GENL_CTRL_ATTR_FAMILY_NAME
  18. GENL_CTRL_ATTR_VERSION
  19. GENL_CTRL_ATTR_HDRSIZE
  20. GENL_CTRL_ATTR_MAXATTR
  21. GENL_CTRL_ATTR_OPS
  22. GENL_CTRL_ATTR_MCAST_GROUPS
  23. )
  24. const (
  25. GENL_CTRL_ATTR_OP_UNSPEC = iota
  26. GENL_CTRL_ATTR_OP_ID
  27. GENL_CTRL_ATTR_OP_FLAGS
  28. )
  29. const (
  30. GENL_ADMIN_PERM = 1 << iota
  31. GENL_CMD_CAP_DO
  32. GENL_CMD_CAP_DUMP
  33. GENL_CMD_CAP_HASPOL
  34. )
  35. const (
  36. GENL_CTRL_ATTR_MCAST_GRP_UNSPEC = iota
  37. GENL_CTRL_ATTR_MCAST_GRP_NAME
  38. GENL_CTRL_ATTR_MCAST_GRP_ID
  39. )
  40. const (
  41. GENL_GTP_VERSION = 0
  42. GENL_GTP_NAME = "gtp"
  43. )
  44. const (
  45. GENL_GTP_CMD_NEWPDP = iota
  46. GENL_GTP_CMD_DELPDP
  47. GENL_GTP_CMD_GETPDP
  48. )
  49. const (
  50. GENL_GTP_ATTR_UNSPEC = iota
  51. GENL_GTP_ATTR_LINK
  52. GENL_GTP_ATTR_VERSION
  53. GENL_GTP_ATTR_TID
  54. GENL_GTP_ATTR_PEER_ADDRESS
  55. GENL_GTP_ATTR_MS_ADDRESS
  56. GENL_GTP_ATTR_FLOW
  57. GENL_GTP_ATTR_NET_NS_FD
  58. GENL_GTP_ATTR_I_TEI
  59. GENL_GTP_ATTR_O_TEI
  60. GENL_GTP_ATTR_PAD
  61. )
  62. type Genlmsg struct {
  63. Command uint8
  64. Version uint8
  65. }
  66. func (msg *Genlmsg) Len() int {
  67. return SizeofGenlmsg
  68. }
  69. func DeserializeGenlmsg(b []byte) *Genlmsg {
  70. return (*Genlmsg)(unsafe.Pointer(&b[0:SizeofGenlmsg][0]))
  71. }
  72. func (msg *Genlmsg) Serialize() []byte {
  73. return (*(*[SizeofGenlmsg]byte)(unsafe.Pointer(msg)))[:]
  74. }