PeerChat.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * @file PeerChat.h
  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. #ifndef BADVPN_PEERCHAT_H
  23. #define BADVPN_PEERCHAT_H
  24. #include <protocol/packetproto.h>
  25. #include <protocol/scproto.h>
  26. #include <misc/debug.h>
  27. #include <base/DebugObject.h>
  28. #include <base/BPending.h>
  29. #include <flow/SinglePacketSender.h>
  30. #include <flow/PacketProtoEncoder.h>
  31. #include <flow/PacketCopier.h>
  32. #include <client/SCOutmsgEncoder.h>
  33. typedef void (*PeerChat_handler_error) (void *user);
  34. typedef void (*PeerChat_handler_message) (void *user, uint8_t *data, int data_len);
  35. typedef struct {
  36. void *user;
  37. PeerChat_handler_error handler_error;
  38. PeerChat_handler_message handler_message;
  39. PacketProtoEncoder pp_encoder;
  40. SCOutmsgEncoder sc_encoder;
  41. PacketCopier copier;
  42. BPending received_job;
  43. uint8_t *received_data;
  44. int received_data_len;
  45. DebugObject d_obj;
  46. } PeerChat;
  47. int PeerChat_Init (PeerChat *o, peerid_t peer_id, BPendingGroup *pg, void *user, PeerChat_handler_error handler_error,
  48. PeerChat_handler_message handler_message) WARN_UNUSED;
  49. void PeerChat_Free (PeerChat *o);
  50. PacketPassInterface * PeerChat_GetSendInput (PeerChat *o);
  51. PacketRecvInterface * PeerChat_GetSendOutput (PeerChat *o);
  52. void PeerChat_InputReceived (PeerChat *o, uint8_t *data, int data_len);
  53. #endif