PacketPassFifoQueue.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * @file PacketPassFifoQueue.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the author nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef BADVPN_PACKETPASSFIFOQUEUE_H
  30. #define BADVPN_PACKETPASSFIFOQUEUE_H
  31. #include <misc/debugcounter.h>
  32. #include <structure/LinkedList1.h>
  33. #include <base/DebugObject.h>
  34. #include <flow/PacketPassInterface.h>
  35. typedef void (*PacketPassFifoQueue_handler_busy) (void *user);
  36. struct PacketPassFifoQueueFlow_s;
  37. typedef struct {
  38. PacketPassInterface *output;
  39. BPendingGroup *pg;
  40. LinkedList1 waiting_flows_list;
  41. struct PacketPassFifoQueueFlow_s *sending_flow;
  42. BPending schedule_job;
  43. int freeing;
  44. DebugCounter d_flows_ctr;
  45. DebugObject d_obj;
  46. } PacketPassFifoQueue;
  47. typedef struct PacketPassFifoQueueFlow_s {
  48. PacketPassFifoQueue *queue;
  49. PacketPassInterface input;
  50. int is_waiting;
  51. LinkedList1Node waiting_flows_list_node;
  52. uint8_t *waiting_data;
  53. int waiting_len;
  54. PacketPassFifoQueue_handler_busy handler_busy;
  55. void *user;
  56. DebugObject d_obj;
  57. } PacketPassFifoQueueFlow;
  58. void PacketPassFifoQueue_Init (PacketPassFifoQueue *o, PacketPassInterface *output, BPendingGroup *pg);
  59. void PacketPassFifoQueue_Free (PacketPassFifoQueue *o);
  60. void PacketPassFifoQueue_PrepareFree (PacketPassFifoQueue *o);
  61. void PacketPassFifoQueueFlow_Init (PacketPassFifoQueueFlow *o, PacketPassFifoQueue *queue);
  62. void PacketPassFifoQueueFlow_Free (PacketPassFifoQueueFlow *o);
  63. void PacketPassFifoQueueFlow_AssertFree (PacketPassFifoQueueFlow *o);
  64. int PacketPassFifoQueueFlow_IsBusy (PacketPassFifoQueueFlow *o);
  65. void PacketPassFifoQueueFlow_SetBusyHandler (PacketPassFifoQueueFlow *o, PacketPassFifoQueue_handler_busy handler_busy, void *user);
  66. PacketPassInterface * PacketPassFifoQueueFlow_GetInput (PacketPassFifoQueueFlow *o);
  67. #endif