PacketRecvInterface.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * @file PacketRecvInterface.c
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * This file is part of BadVPN.
  8. *
  9. * BadVPN is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * BadVPN is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  21. */
  22. #include <flow/PacketRecvInterface.h>
  23. void _PacketRecvInterface_job_operation (PacketRecvInterface *i)
  24. {
  25. ASSERT(i->d_user_busy)
  26. ASSERT(i->handler_done)
  27. DebugObject_Access(&i->d_obj);
  28. #ifndef NDEBUG
  29. DebugIn_AmOut(&i->d_in_operation);
  30. DebugIn_AmOut(&i->d_in_done);
  31. #endif
  32. // call operation handler
  33. #ifndef NDEBUG
  34. DebugIn_GoIn(&i->d_in_operation);
  35. DEAD_ENTER(i->d_dead)
  36. #endif
  37. i->handler_operation(i->user_provider, i->buf);
  38. #ifndef NDEBUG
  39. if (DEAD_LEAVE(i->d_dead)) {
  40. return;
  41. }
  42. DebugIn_GoOut(&i->d_in_operation);
  43. #endif
  44. }
  45. void _PacketRecvInterface_job_done (PacketRecvInterface *i)
  46. {
  47. ASSERT(i->d_user_busy)
  48. ASSERT(i->done_len >= 0)
  49. ASSERT(i->done_len <= i->mtu)
  50. ASSERT(i->handler_done)
  51. DebugObject_Access(&i->d_obj);
  52. #ifndef NDEBUG
  53. DebugIn_AmOut(&i->d_in_operation);
  54. DebugIn_AmOut(&i->d_in_done);
  55. #endif
  56. #ifndef NDEBUG
  57. i->d_user_busy = 0;
  58. #endif
  59. // call done handler
  60. #ifndef NDEBUG
  61. DebugIn_GoIn(&i->d_in_done);
  62. DEAD_ENTER(i->d_dead)
  63. #endif
  64. i->handler_done(i->user_user, i->done_len);
  65. #ifndef NDEBUG
  66. if (DEAD_LEAVE(i->d_dead)) {
  67. return;
  68. }
  69. DebugIn_GoOut(&i->d_in_done);
  70. #endif
  71. }