test_session.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Copyright (C) 2014 Mamadou DIOP.
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Lesser General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. *
  18. */
  19. #ifndef TEST_TINYBFCP_SESSION_H
  20. #define TEST_TINYBFCP_SESSION_H
  21. #include "tinybfcp.h"
  22. static void test_session_tcp()
  23. {
  24. }
  25. static void test_session_udp()
  26. {
  27. struct tbfcp_session_s* p_session = tsk_null;
  28. tbfcp_pkt_t* p_pkt = tsk_null;
  29. BAIL_IF_ERR(tbfcp_session_create(tnet_socket_type_udp_ipv4, kLocalIP, &p_session));
  30. BAIL_IF_ERR(tbfcp_session_set_remote(p_session, kRemoteIP, kRemotePort));
  31. BAIL_IF_ERR(tbfcp_session_prepare(p_session));
  32. BAIL_IF_ERR(tbfcp_session_start(p_session));
  33. TSK_DEBUG_INFO("PRESS ENTER to continue");
  34. getchar();
  35. BAIL_IF_ERR(tbfcp_pkt_create_FloorRequest_2(kConfId, kTransacId, kUserId, kFloorId, &p_pkt));
  36. BAIL_IF_ERR(tbfcp_session_send_pkt(p_session, p_pkt));
  37. TSK_DEBUG_INFO("PRESS ENTER to continue");
  38. getchar();
  39. TSK_OBJECT_SAFE_FREE(p_pkt);
  40. BAIL_IF_ERR(tbfcp_pkt_create_Hello(kConfId, kTransacId, kUserId, &p_pkt));
  41. BAIL_IF_ERR(tbfcp_session_send_pkt(p_session, p_pkt));
  42. TSK_DEBUG_INFO("PRESS ENTER to continue");
  43. getchar();
  44. bail:
  45. TSK_OBJECT_SAFE_FREE(p_pkt);
  46. TSK_OBJECT_SAFE_FREE(p_session);
  47. }
  48. static void test_session()
  49. {
  50. test_session_tcp();
  51. test_session_udp();
  52. }
  53. #endif /* TEST_TINYBFCP_SESSION_H */