sender.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2012 Tobias Brunner
  3. * Copyright (C) 2005-2007 Martin Willi
  4. * Copyright (C) 2005 Jan Hutter
  5. * HSR Hochschule fuer Technik Rapperswil
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
  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 MERCHANTABILITY
  14. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  15. * for more details.
  16. */
  17. /**
  18. * @defgroup sender sender
  19. * @{ @ingroup network
  20. */
  21. #ifndef SENDER_H_
  22. #define SENDER_H_
  23. typedef struct sender_t sender_t;
  24. #include <library.h>
  25. #include <networking/packet.h>
  26. /**
  27. * Callback job responsible for sending IKE packets over the socket.
  28. */
  29. struct sender_t {
  30. /**
  31. * Send a packet over the network.
  32. *
  33. * This function is non blocking and adds the packet to a queue.
  34. * Whenever the sender thread thinks it's good to send the packet,
  35. * it'll do so.
  36. *
  37. * @param packet packet to send
  38. */
  39. void (*send) (sender_t *this, packet_t *packet);
  40. /**
  41. * The same as send() but does not add Non-ESP markers automatically.
  42. *
  43. * @param packet packet to send
  44. */
  45. void (*send_no_marker) (sender_t *this, packet_t *packet);
  46. /**
  47. * Enforce a flush of the send queue.
  48. *
  49. * This function blocks until all queued packets have been sent.
  50. */
  51. void (*flush)(sender_t *this);
  52. /**
  53. * Destroys a sender object.
  54. */
  55. void (*destroy) (sender_t *this);
  56. };
  57. /**
  58. * Create the sender thread.
  59. *
  60. * The thread will start to work, getting packets
  61. * from its queue and sends them out.
  62. *
  63. * @return created sender object
  64. */
  65. sender_t * sender_create(void);
  66. #endif /** SENDER_H_ @}*/