option.rs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive)]
  2. #[allow(non_camel_case_types)]
  3. pub enum Options {
  4. DEBUG = 1,
  5. REUSEADDR = 2,
  6. TYPE = 3,
  7. ERROR = 4,
  8. DONTROUTE = 5,
  9. BROADCAST = 6,
  10. SNDBUF = 7,
  11. RCVBUF = 8,
  12. SNDBUFFORCE = 32,
  13. RCVBUFFORCE = 33,
  14. KEEPALIVE = 9,
  15. OOBINLINE = 10,
  16. NO_CHECK = 11,
  17. PRIORITY = 12,
  18. LINGER = 13,
  19. BSDCOMPAT = 14,
  20. REUSEPORT = 15,
  21. PASSCRED = 16,
  22. PEERCRED = 17,
  23. RCVLOWAT = 18,
  24. SNDLOWAT = 19,
  25. RCVTIMEO_OLD = 20,
  26. SNDTIMEO_OLD = 21,
  27. SECURITY_AUTHENTICATION = 22,
  28. SECURITY_ENCRYPTION_TRANSPORT = 23,
  29. SECURITY_ENCRYPTION_NETWORK = 24,
  30. BINDTODEVICE = 25,
  31. /// 与GET_FILTER相同
  32. ATTACH_FILTER = 26,
  33. DETACH_FILTER = 27,
  34. PEERNAME = 28,
  35. ACCEPTCONN = 30,
  36. PEERSEC = 31,
  37. PASSSEC = 34,
  38. MARK = 36,
  39. PROTOCOL = 38,
  40. DOMAIN = 39,
  41. RXQ_OVFL = 40,
  42. /// 与SCM_WIFI_STATUS相同
  43. WIFI_STATUS = 41,
  44. PEEK_OFF = 42,
  45. /* Instruct lower device to use last 4-bytes of skb data as FCS */
  46. NOFCS = 43,
  47. LOCK_FILTER = 44,
  48. SELECT_ERR_QUEUE = 45,
  49. BUSY_POLL = 46,
  50. MAX_PACING_RATE = 47,
  51. BPF_EXTENSIONS = 48,
  52. INCOMING_CPU = 49,
  53. ATTACH_BPF = 50,
  54. // DETACH_BPF = DETACH_FILTER,
  55. ATTACH_REUSEPORT_CBPF = 51,
  56. ATTACH_REUSEPORT_EBPF = 52,
  57. CNX_ADVICE = 53,
  58. SCM_TIMESTAMPING_OPT_STATS = 54,
  59. MEMINFO = 55,
  60. INCOMING_NAPI_ID = 56,
  61. COOKIE = 57,
  62. SCM_TIMESTAMPING_PKTINFO = 58,
  63. PEERGROUPS = 59,
  64. ZEROCOPY = 60,
  65. /// 与SCM_TXTIME相同
  66. TXTIME = 61,
  67. BINDTOIFINDEX = 62,
  68. TIMESTAMP_OLD = 29,
  69. TIMESTAMPNS_OLD = 35,
  70. TIMESTAMPING_OLD = 37,
  71. TIMESTAMP_NEW = 63,
  72. TIMESTAMPNS_NEW = 64,
  73. TIMESTAMPING_NEW = 65,
  74. RCVTIMEO_NEW = 66,
  75. SNDTIMEO_NEW = 67,
  76. DETACH_REUSEPORT_BPF = 68,
  77. PREFER_BUSY_POLL = 69,
  78. BUSY_POLL_BUDGET = 70,
  79. NETNS_COOKIE = 71,
  80. BUF_LOCK = 72,
  81. RESERVE_MEM = 73,
  82. TXREHASH = 74,
  83. RCVMARK = 75,
  84. }
  85. impl TryFrom<u32> for Options {
  86. type Error = system_error::SystemError;
  87. fn try_from(x: u32) -> Result<Self, Self::Error> {
  88. use num_traits::FromPrimitive;
  89. return <Self as FromPrimitive>::from_u32(x).ok_or(system_error::SystemError::EINVAL);
  90. }
  91. }