common.rs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // Converted from the tests for uBPF <https://github.com/iovisor/ubpf>
  2. // Copyright 2015 Big Switch Networks, Inc
  3. // Copyright 2016 6WIND S.A. <quentin.monnet@6wind.com>
  4. //
  5. // Licensed under the Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0> or
  6. // the MIT license <http://opensource.org/licenses/MIT>, at your option. This file may not be
  7. // copied, modified, or distributed except according to those terms.
  8. // Assembly code and data for tcp_sack testcases.
  9. #[allow(dead_code)]
  10. pub const TCP_SACK_ASM: &'static str = "
  11. ldxb r2, [r1+12]
  12. ldxb r3, [r1+13]
  13. lsh r3, 0x8
  14. or r3, r2
  15. mov r0, 0x0
  16. jne r3, 0x8, +37
  17. ldxb r2, [r1+23]
  18. jne r2, 0x6, +35
  19. ldxb r2, [r1+14]
  20. add r1, 0xe
  21. and r2, 0xf
  22. lsh r2, 0x2
  23. add r1, r2
  24. mov r0, 0x0
  25. ldxh r4, [r1+12]
  26. add r1, 0x14
  27. rsh r4, 0x2
  28. and r4, 0x3c
  29. mov r2, r4
  30. add r2, 0xffffffec
  31. mov r5, 0x15
  32. mov r3, 0x0
  33. jgt r5, r4, +20
  34. mov r5, r3
  35. lsh r5, 0x20
  36. arsh r5, 0x20
  37. mov r4, r1
  38. add r4, r5
  39. ldxb r5, [r4]
  40. jeq r5, 0x1, +4
  41. jeq r5, 0x0, +12
  42. mov r6, r3
  43. jeq r5, 0x5, +9
  44. ja +2
  45. add r3, 0x1
  46. mov r6, r3
  47. ldxb r3, [r4+1]
  48. add r3, r6
  49. lsh r3, 0x20
  50. arsh r3, 0x20
  51. jsgt r2, r3, -18
  52. ja +1
  53. mov r0, 0x1
  54. exit";
  55. #[allow(dead_code)]
  56. pub const TCP_SACK_BIN: [u8;352] = [
  57. 0x71, 0x12, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
  58. 0x71, 0x13, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00,
  59. 0x67, 0x03, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
  60. 0x4f, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  61. 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  62. 0x55, 0x03, 0x25, 0x00, 0x08, 0x00, 0x00, 0x00,
  63. 0x71, 0x12, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00,
  64. 0x55, 0x02, 0x23, 0x00, 0x06, 0x00, 0x00, 0x00,
  65. 0x71, 0x12, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00,
  66. 0x07, 0x01, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
  67. 0x57, 0x02, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
  68. 0x67, 0x02, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
  69. 0x0f, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  70. 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  71. 0x69, 0x14, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
  72. 0x07, 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
  73. 0x77, 0x04, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
  74. 0x57, 0x04, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
  75. 0xbf, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  76. 0x07, 0x02, 0x00, 0x00, 0xec, 0xff, 0xff, 0xff,
  77. 0xb7, 0x05, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
  78. 0xb7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  79. 0x2d, 0x45, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00,
  80. 0xbf, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  81. 0x67, 0x05, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  82. 0xc7, 0x05, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  83. 0xbf, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  84. 0x0f, 0x54, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  85. 0x71, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  86. 0x15, 0x05, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00,
  87. 0x15, 0x05, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
  88. 0xbf, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  89. 0x15, 0x05, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00,
  90. 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
  91. 0x07, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  92. 0xbf, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  93. 0x71, 0x43, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  94. 0x0f, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  95. 0x67, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  96. 0xc7, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
  97. 0x6d, 0x32, 0xee, 0xff, 0x00, 0x00, 0x00, 0x00,
  98. 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
  99. 0xb7, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
  100. 0x95, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  101. ];
  102. #[allow(dead_code)]
  103. pub const TCP_SACK_MATCH: [u8;78] = [
  104. 0x00, 0x26, 0x62, 0x2f, 0x47, 0x87, 0x00, 0x1d,
  105. 0x60, 0xb3, 0x01, 0x84, 0x08, 0x00, 0x45, 0x00,
  106. 0x00, 0x40, 0xa8, 0xde, 0x40, 0x00, 0x40, 0x06,
  107. 0x9d, 0x58, 0xc0, 0xa8, 0x01, 0x03, 0x3f, 0x74,
  108. 0xf3, 0x61, 0xe5, 0xc0, 0x00, 0x50, 0xe5, 0x94,
  109. 0x3f, 0x77, 0xa3, 0xc4, 0xc4, 0x80, 0xb0, 0x10,
  110. 0x01, 0x3e, 0x34, 0xb6, 0x00, 0x00, 0x01, 0x01,
  111. 0x08, 0x0a, 0x00, 0x17, 0x95, 0x6f, 0x8d, 0x9d,
  112. 0x9e, 0x27, 0x01, 0x01, 0x05, 0x0a, 0xa3, 0xc4,
  113. 0xca, 0x28, 0xa3, 0xc4, 0xcf, 0xd0
  114. ];
  115. #[allow(dead_code)]
  116. pub const TCP_SACK_NOMATCH: [u8;66] = [
  117. 0x00, 0x26, 0x62, 0x2f, 0x47, 0x87, 0x00, 0x1d,
  118. 0x60, 0xb3, 0x01, 0x84, 0x08, 0x00, 0x45, 0x00,
  119. 0x00, 0x40, 0xa8, 0xde, 0x40, 0x00, 0x40, 0x06,
  120. 0x9d, 0x58, 0xc0, 0xa8, 0x01, 0x03, 0x3f, 0x74,
  121. 0xf3, 0x61, 0xe5, 0xc0, 0x00, 0x50, 0xe5, 0x94,
  122. 0x3f, 0x77, 0xa3, 0xc4, 0xc4, 0x80, 0x80, 0x10,
  123. 0x01, 0x3e, 0x34, 0xb6, 0x00, 0x00, 0x01, 0x01,
  124. 0x08, 0x0a, 0x00, 0x17, 0x95, 0x6f, 0x8d, 0x9d,
  125. 0x9e, 0x27
  126. ];