SCKeepaliveSource.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * @file SCKeepaliveSource.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 <protocol/scproto.h>
  23. #include <misc/byteorder.h>
  24. #include <flow/SCKeepaliveSource.h>
  25. static int output_handler_recv (SCKeepaliveSource *o, uint8_t *data, int *data_len)
  26. {
  27. struct sc_header *header = (struct sc_header *)data;
  28. header->type = SCID_KEEPALIVE;
  29. *data_len = sizeof(struct sc_header);
  30. return 1;
  31. }
  32. void SCKeepaliveSource_Init (SCKeepaliveSource *o)
  33. {
  34. // init output
  35. PacketRecvInterface_Init(&o->output, sizeof(struct sc_header), (PacketRecvInterface_handler_recv)output_handler_recv, o);
  36. // init debug object
  37. DebugObject_Init(&o->d_obj);
  38. }
  39. void SCKeepaliveSource_Free (SCKeepaliveSource *o)
  40. {
  41. // free debug object
  42. DebugObject_Free(&o->d_obj);
  43. // free output
  44. PacketRecvInterface_Free(&o->output);
  45. }
  46. PacketRecvInterface * SCKeepaliveSource_GetOutput (SCKeepaliveSource *o)
  47. {
  48. return &o->output;
  49. }