main.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* main.c
  2. *
  3. * Copyright (C) 2006-2014 wolfSSL Inc.
  4. *
  5. * This file is part of CyaSSL.
  6. *
  7. * CyaSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * CyaSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <cyassl/ctaocrypt/visibility.h>
  25. #include <cyassl/ctaocrypt/logging.h>
  26. #include "cmsis_os.h"
  27. #include "rl_fs.h"
  28. #include "rl_net.h"
  29. #include <stdio.h>
  30. #include "cyassl_MDK_ARM.h"
  31. #include <cyassl/ssl.h>
  32. /*-----------------------------------------------------------------------------
  33. * Initialize a Flash Memory Card
  34. *----------------------------------------------------------------------------*/
  35. static void init_filesystem (void) {
  36. int32_t retv;
  37. retv = finit ("M0:");
  38. if (retv == 0) {
  39. retv = fmount ("M0:");
  40. if (retv == 0) {
  41. printf ("Drive M0 ready!\n");
  42. }
  43. else {
  44. printf ("Drive M0 mount failed!\n");
  45. }
  46. } else {
  47. printf ("Drive M0 initialization failed!\n");
  48. }
  49. }
  50. /*-----------------------------------------------------------------------------
  51. * TCP/IP tasks
  52. *----------------------------------------------------------------------------*/
  53. void tcp_poll (void const *arg)
  54. {
  55. CYASSL_MSG("TCP polling started.\n") ;
  56. while (1) {
  57. net_main ();
  58. osDelay(100) ;
  59. }
  60. }
  61. typedef struct func_args {
  62. int argc;
  63. char** argv;
  64. } func_args;
  65. extern void client_test(func_args * args) ;
  66. osThreadDef (tcp_poll, osPriorityHigh , 1, 0) ;
  67. /*-----------------------------------------------------------------------------
  68. * mian entry
  69. *----------------------------------------------------------------------------*/
  70. int myoptind = 0;
  71. char* myoptarg = NULL;
  72. #include "config-SimpleClient.h"
  73. int main()
  74. {
  75. static char *argv[] =
  76. { "client", "-h", CYASSL_CALLEE_IP, "-p", CYASSL_CALLEE_PORT,
  77. "-v", CYASSL_SSL_VER, CYASSL_HTTP_GET } ;
  78. static func_args args =
  79. { 7 + CYASSL_HTTP_GET_COUNT, argv } ;
  80. init_filesystem ();
  81. net_initialize() ;
  82. osThreadCreate (osThread (tcp_poll), NULL);
  83. osDelay(50000) ; /* wait for DHCP */
  84. #if defined(DEBUG_CYASSL)
  85. printf("Turning ON Debug message\n") ;
  86. CyaSSL_Debugging_ON() ;
  87. #endif
  88. if(args.argc == 7)
  89. printf("Simple SSL/TLS, ") ;
  90. else
  91. printf("HTTP GET, ") ;
  92. printf("Callee IP: %s, Port: %s, Version:%s\n", argv[2], argv[4], argv[6]) ;
  93. while(1) {
  94. client_test(&args) ;
  95. printf("Enter any key to iterate.\n") ;
  96. getchar() ;
  97. }
  98. }