main.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* main.c
  2. *
  3. * Copyright (C) 2006-2017 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL 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. * wolfSSL 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-1335, USA
  20. */
  21. #ifdef HAVE_CONFIG_H
  22. #include <config.h>
  23. #endif
  24. #include <wolfssl/wolfcrypt/visibility.h>
  25. #include <wolfssl/wolfcrypt/logging.h>
  26. #include "stm32f2xx_hal.h"
  27. #include "cmsis_os.h"
  28. #include "rl_net.h"
  29. #include <stdio.h>
  30. #include <wolfssl/ssl.h>
  31. /*-----------------------------------------------------------------------------
  32. * Initialize Clock Configuration
  33. *----------------------------------------------------------------------------*/
  34. void SystemClock_Config(void) {
  35. #warning "write MPU specific System Clock Set up\n"
  36. }
  37. /*-----------------------------------------------------------------------------
  38. * Initialize a Flash Memory Card
  39. *----------------------------------------------------------------------------*/
  40. #if !defined(NO_FILESYSTEM)
  41. #include "rl_fs.h"
  42. static void init_filesystem (void) {
  43. int32_t retv;
  44. retv = finit ("M0:");
  45. if (retv == 0) {
  46. retv = fmount ("M0:");
  47. if (retv == 0) {
  48. printf ("Drive M0 ready!\n");
  49. }
  50. else {
  51. printf ("Drive M0 mount failed!\n");
  52. }
  53. }
  54. else {
  55. printf ("Drive M0 initialization failed!\n");
  56. }
  57. }
  58. #endif
  59. typedef struct func_args {
  60. int argc;
  61. char** argv;
  62. } func_args;
  63. extern void client_test(func_args * args) ;
  64. #include "config-SimpleClient.h"
  65. int myoptind = 0;
  66. char* myoptarg = NULL;
  67. int main()
  68. {
  69. static char *argv[] =
  70. { "client", "-h", WOLFSSL_CALLEE_IP, "-p", WOLFSSL_CALLEE_PORT,
  71. "-v", WOLFSSL_SSL_VER, WOLFSSL_HTTP_GET } ;
  72. static func_args args =
  73. { 7 + WOLFSSL_HTTP_GET_COUNT, argv } ;
  74. SystemClock_Config ();
  75. #if !defined(NO_FILESYSTEM)
  76. init_filesystem ();
  77. #endif
  78. netInitialize() ;
  79. osDelay(300) ;
  80. #if defined(DEBUG_WOLFSSL)
  81. printf("Turning ON Debug message\n") ;
  82. wolfSSL_Debugging_ON() ;
  83. #endif
  84. if(args.argc == 7)
  85. printf("Simple SSL/TLS, ") ;
  86. else
  87. printf("HTTP GET, ") ;
  88. printf("Callee IP: %s, Port: %s, Version:%s\n", argv[2], argv[4], argv[6]) ;
  89. while(1) {
  90. client_test(&args) ;
  91. printf("Enter any key to iterate.\n") ;
  92. getchar() ;
  93. }
  94. }