seqtest.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * OpenConnect (SSL + DTLS) VPN client
  3. *
  4. * Copyright © 2016 Intel Corporation.
  5. *
  6. * Author: David Woodhouse <dwmw2@infradead.org>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * version 2.1, as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. */
  17. #include <config.h>
  18. #include <stdint.h>
  19. #include <stdio.h>
  20. #define __OPENCONNECT_INTERNAL_H__
  21. #define vpn_progress(v, d, ...) printf(__VA_ARGS__)
  22. #define _(x) x
  23. struct openconnect_info {
  24. int esp_replay_protect;
  25. };
  26. struct esp {
  27. uint64_t seq_backlog;
  28. uint64_t seq;
  29. };
  30. #include "../esp-seqno.c"
  31. int main(void)
  32. {
  33. struct esp esptest = { 0, 0 };
  34. struct openconnect_info vpninfo = { 1};
  35. if ( verify_packet_seqno(&vpninfo, &esptest, 0) ||
  36. verify_packet_seqno(&vpninfo, &esptest, 2) ||
  37. verify_packet_seqno(&vpninfo, &esptest, 1) ||
  38. !verify_packet_seqno(&vpninfo, &esptest, 0) ||
  39. verify_packet_seqno(&vpninfo, &esptest, 64) ||
  40. verify_packet_seqno(&vpninfo, &esptest, 65) ||
  41. !verify_packet_seqno(&vpninfo, &esptest, 65) ||
  42. verify_packet_seqno(&vpninfo, &esptest, 66) ||
  43. verify_packet_seqno(&vpninfo, &esptest, 67) ||
  44. verify_packet_seqno(&vpninfo, &esptest, 68) ||
  45. !verify_packet_seqno(&vpninfo, &esptest, 68) ||
  46. !verify_packet_seqno(&vpninfo, &esptest, 2) ||
  47. !verify_packet_seqno(&vpninfo, &esptest, 3) ||
  48. verify_packet_seqno(&vpninfo, &esptest, 4) ||
  49. verify_packet_seqno(&vpninfo, &esptest, 164) ||
  50. !verify_packet_seqno(&vpninfo, &esptest, 99) ||
  51. verify_packet_seqno(&vpninfo, &esptest, 100) ||
  52. verify_packet_seqno(&vpninfo, &esptest, 200) ||
  53. verify_packet_seqno(&vpninfo, &esptest, 264) ||
  54. !verify_packet_seqno(&vpninfo, &esptest, 199) ||
  55. !verify_packet_seqno(&vpninfo, &esptest, 200) ||
  56. verify_packet_seqno(&vpninfo, &esptest, 265) ||
  57. verify_packet_seqno(&vpninfo, &esptest, 210) ||
  58. verify_packet_seqno(&vpninfo, &esptest, 201) ||
  59. verify_packet_seqno(&vpninfo, &esptest, 270) ||
  60. verify_packet_seqno(&vpninfo, &esptest, 206) ||
  61. !verify_packet_seqno(&vpninfo, &esptest, 210) ||
  62. verify_packet_seqno(&vpninfo, &esptest, 333) ||
  63. !verify_packet_seqno(&vpninfo, &esptest, 268) ||
  64. verify_packet_seqno(&vpninfo, &esptest, 269) ||
  65. !verify_packet_seqno(&vpninfo, &esptest, 270) ||
  66. verify_packet_seqno(&vpninfo, &esptest, 0xfffffffd) ||
  67. !verify_packet_seqno(&vpninfo, &esptest, 1) ||
  68. verify_packet_seqno(&vpninfo, &esptest, 0xffffffc1) ||
  69. verify_packet_seqno(&vpninfo, &esptest, 0xfffffffc) ||
  70. verify_packet_seqno(&vpninfo, &esptest, 0xffffffff) ||
  71. !verify_packet_seqno(&vpninfo, &esptest, 0) ||
  72. !verify_packet_seqno(&vpninfo, &esptest, 0xffffffbe) ||
  73. verify_packet_seqno(&vpninfo, &esptest, 0xffffffbf) ||
  74. !verify_packet_seqno(&vpninfo, &esptest, 0xffffffc1) ||
  75. verify_packet_seqno(&vpninfo, &esptest, 0xffffffc0))
  76. return 1;
  77. return 0;
  78. }