shell.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. /*shell.c
  2. *
  3. * Copyright (C) 2006-2023 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. /*** tiny Shell for wolfSSL apps ***/
  22. #ifdef HAVE_CONFIG_H
  23. #include <config.h>
  24. #endif
  25. #include "wolfssl/internal.h"
  26. #include <wolfssl/wolfcrypt/logging.h>
  27. #if defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET)
  28. #include <stdio.h>
  29. #include <string.h>
  30. #include <stdlib.h>
  31. #if defined(WOLFSSL_MDK5) || defined(WOLFSSL_KEIL_TCP_NET)
  32. #include "cmsis_os.h"
  33. #include "rl_fs.h"
  34. #else
  35. #include <rtl.h>
  36. #endif
  37. #endif
  38. #ifdef WOLFSSL_KEIL_TCP_NET
  39. #include "wolfssl/test.h"
  40. #else
  41. typedef struct func_args {
  42. int argc;
  43. char** argv;
  44. int return_code;
  45. } func_args;
  46. #endif
  47. #if defined(WOLFSSL_CMSIS_RTOS)
  48. #define HAVE_KEIL_RTX
  49. #endif
  50. #ifdef NO_ECHOCLIENT
  51. #define echoclient_test command_not_found
  52. #endif
  53. #ifdef NO_ECHOSERVER
  54. #define echoserver_test command_not_found
  55. #endif
  56. #ifdef NO_SIMPLE_CLIENT
  57. #define client_test command_not_found
  58. #endif
  59. #ifdef NO_SIMPLE_SERVER
  60. #define server_test command_not_found
  61. #endif
  62. #ifdef NO_CRYPT_BENCHMARK
  63. #define benchmark_test command_not_found
  64. #endif
  65. #ifdef NO_CRYPT_TEST
  66. #define ctaocrypt_test command_not_found
  67. #endif
  68. #ifndef WOLFSSL_KEIL_TCP_NET
  69. #define ipaddr_comm command_not_found
  70. #endif
  71. #if !defined(HAVE_KEIL_RTX)
  72. #define stack_comm command_not_found
  73. #endif
  74. #if !defined(DEBUG_WOLFSSL)
  75. #define dbg_comm command_not_found
  76. #endif
  77. void command_not_found(void *argv) {
  78. printf("Command not found\n") ;
  79. }
  80. extern void echoclient_test(void *args) ;
  81. extern void echoserver_test(void *args) ;
  82. extern void benchmark_test(void *args) ;
  83. extern void wolfcrypt_test(void *args) ;
  84. extern void client_test(void *args) ;
  85. extern void server_test(void *args) ;
  86. extern void kill_task(void *args) ;
  87. extern void ipaddr_comm(void *args) ;
  88. extern void stack_comm(void *args) ;
  89. extern void for_command(void *args) ;
  90. extern void dbg_comm(void *arg) ;
  91. extern void help_comm(void *arg) ;
  92. #if !defined(NO_CRYPT_TEST)
  93. #ifndef NO_MD5
  94. extern void md5_test(void *arg) ;
  95. #endif
  96. #ifdef WOLFSSL_MD2
  97. extern void md2_test(void *arg) ;
  98. #endif
  99. #ifndef NO_MD4
  100. extern void md4_test(void *arg) ;
  101. #endif
  102. extern void sha_test(void *arg) ;
  103. #ifndef NO_SHA256
  104. extern void sha256_test(void *arg) ;
  105. #endif
  106. #ifdef WOLFSSL_SHA384
  107. extern void sha384_test(void *arg) ;
  108. #endif
  109. #ifdef WOLFSSL_SHA512
  110. extern void sha512_test(void *arg) ;
  111. #endif
  112. #ifdef WOLFSSL_RIPEMD
  113. extern void ripemd_test(void *arg) ;
  114. #endif
  115. #ifndef NO_HMAC
  116. #ifndef NO_MD5
  117. extern void hmac_md5_test(void *arg) ;
  118. #endif
  119. extern void hmac_sha_test(void *arg) ;
  120. #ifndef NO_SHA256
  121. extern void hmac_sha256_test(void *arg) ;
  122. #endif
  123. #ifdef WOLFSSL_SHA384
  124. extern void hmac_sha384_test(void *arg) ;
  125. #endif
  126. #endif
  127. #ifndef NO_RC4
  128. extern void arc4_test(void *arg) ;
  129. #endif
  130. #ifndef NO_DES3
  131. extern void des_test(void *arg) ;
  132. extern void des3_test(void *arg) ;
  133. #endif
  134. #ifndef NO_AES
  135. extern void aes_test(void *arg) ;
  136. #ifdef HAVE_AESGCM
  137. extern void aesgcm_test(void *arg) ;
  138. #endif
  139. #ifdef HAVE_AESCCM
  140. extern void aesccm_test(void *arg) ;
  141. #endif
  142. #endif
  143. #ifdef HAVE_CAMELLIA
  144. extern void camellia_test(void *arg) ;
  145. #endif
  146. extern void random_test(void *arg) ;
  147. #ifndef NO_RSA
  148. extern void rsa_test(void *arg) ;
  149. #endif
  150. #ifndef NO_DH
  151. extern void dh_test(void *arg) ;
  152. #endif
  153. #ifndef NO_DSA
  154. extern void dsa_test(void *arg) ;
  155. #endif
  156. #ifndef NO_PWDBASED
  157. extern void pwdbased_test(void *arg) ;
  158. #endif
  159. #ifdef OPENSSL_EXTRA
  160. extern void openssl_test(void *arg) ;
  161. #endif
  162. #ifdef HAVE_ECC
  163. extern void ecc_test(void *arg) ;
  164. #endif
  165. #endif /* NO_CRYPT_TEST */
  166. static struct {
  167. const char *command ;
  168. void (*func)(void *args) ;
  169. } commandTable[] = {
  170. "echoclient", echoclient_test,
  171. "echoserver", echoserver_test,
  172. "benchmark", benchmark_test,
  173. "test", wolfcrypt_test,
  174. "client", client_test,
  175. "server", server_test,
  176. "ipaddr", ipaddr_comm, /* TBD */
  177. "stack", stack_comm, /* On/Off check stack size */
  178. "for", for_command, /* iterate next command X times */
  179. "debug", dbg_comm, /* On/Off debug message */
  180. "help", help_comm, /* Brief description about the commands */
  181. /** short name **/
  182. "ec", echoclient_test,
  183. "es", echoserver_test,
  184. "bm", benchmark_test,
  185. "te", wolfcrypt_test,
  186. "cl", client_test,
  187. "sv", server_test,
  188. "ip", ipaddr_comm,
  189. "st", stack_comm,
  190. "dbg", dbg_comm,
  191. "?", help_comm,
  192. /*** test suites ****/
  193. #if !defined(NO_CRYPT_TEST)
  194. #ifndef NO_MD5
  195. "md5", md5_test,
  196. #endif
  197. #ifdef WOLFSSL_MD2
  198. "md2", md2_test,
  199. #endif
  200. #ifndef NO_MD4
  201. "md4", md4_test,
  202. #endif
  203. "sha", sha_test,
  204. #ifndef NO_SHA256
  205. "sha256", sha256_test,
  206. #endif
  207. #ifdef WOLFSSL_SHA384
  208. "sha384", sha384_test,
  209. #endif
  210. #ifdef WOLFSSL_SHA512
  211. "sha512", sha512_test,
  212. #endif
  213. #ifdef WOLFSSL_RIPEMD
  214. "ripemd", ripemd_test,
  215. #endif
  216. #ifndef NO_HMAC
  217. #ifndef NO_MD5
  218. "hmac_md5", hmac_md5_test,
  219. #endif
  220. "hmac_sha", hmac_sha_test,
  221. #ifndef NO_SHA256
  222. "hmac_sha256", hmac_sha256_test,
  223. #endif
  224. #ifdef WOLFSSL_SHA384
  225. "hmac_sha384", hmac_sha384_test,
  226. #endif
  227. #endif
  228. #ifndef NO_RC4
  229. "arc4", arc4_test,
  230. #endif
  231. #ifndef NO_DES3
  232. "des", des_test,
  233. "des3", des3_test,
  234. #endif
  235. #ifndef NO_AES
  236. "aes", aes_test,
  237. #ifdef HAVE_AESGCM
  238. "aesgcm", aesgcm_test,
  239. #endif
  240. #ifdef HAVE_AESCCM
  241. "aesccm", aesccm_test,
  242. #endif
  243. #endif
  244. #ifdef HAVE_CAMELLIA
  245. "camellia", camellia_test,
  246. #endif
  247. "random", random_test,
  248. #ifndef NO_RSA
  249. "rsa", rsa_test,
  250. #endif
  251. #ifndef NO_DH
  252. "dh", dh_test,
  253. #endif
  254. #ifndef NO_DSA
  255. "dsa", dsa_test,
  256. #endif
  257. #ifndef NO_PWDBASED
  258. "pwdbased", pwdbased_test,
  259. #endif
  260. #ifdef OPENSSL_EXTRA
  261. "openssl", openssl_test,
  262. #endif
  263. #ifdef HAVE_ECC
  264. "ecc", ecc_test,
  265. #endif
  266. #endif /* NO_CRYPT_TEST */
  267. "", NULL
  268. } ;
  269. enum jobtype { FOREGROUND, BACKGROUND } ;
  270. #define IF_DELIMITER(ch) ((ch) == ' ' || (ch) == '\n')
  271. static int BackGround = 0 ; /* 1: background job is running */
  272. char * wolfssl_fgets ( char * str, int num, FILE * f )
  273. {
  274. int i ;
  275. for(i = 0 ; i< num ; i++) {
  276. while((str[i] = getchar()) == 0) {
  277. #if defined (HAVE_KEIL_RTX) && !defined(WOLFSSL_CMSIS_RTOS)
  278. os_tsk_pass ();
  279. #else
  280. osThreadYield ();
  281. #endif
  282. }
  283. if(str[i] == '\n' || str[i] == '\012' || str[i] == '\015') {
  284. putchar('\n') ;
  285. str[i++] = '\n' ;
  286. str[i] = '\0' ;
  287. break ;
  288. } else if(str[i] == '\010') { /* BS */
  289. if(i) { /* erace one char */
  290. putchar('\010') ; putchar(' ') ; putchar('\010') ;
  291. i = (i>0 ? (i-2) : -1 ) ;
  292. continue ;
  293. }
  294. } else if(str[i] == '\033' || str[i] == '\004' ) { /* ESC or ^D */
  295. str[i] = '\0' ;
  296. return(0) ;
  297. }
  298. putchar(str[i]) ;
  299. }
  300. return(str) ;
  301. }
  302. /******* Get Command Line *****************************/
  303. static int getline(char * line, int sz, func_args *args, int*bf_flg)
  304. {
  305. char * ret ;
  306. int i ;
  307. #define MAXARGS 10
  308. #define MAXARGLEN 30
  309. static char *argv[MAXARGS] ;
  310. args->argv = argv ;
  311. putchar('>') ;
  312. fflush(stdout) ;
  313. ret = wolfssl_fgets(line, sz, stdin) ;
  314. #define SHELL_ERROR_FGETS -102
  315. if(ret != line) return(SHELL_ERROR_FGETS) ;
  316. if(line[strlen(line)-2] == '&') {
  317. (*bf_flg) = BACKGROUND ;
  318. line[strlen(line)-2] = '\n' ;
  319. } else {
  320. (*bf_flg) = FOREGROUND ;
  321. }
  322. args->argc = 0 ;
  323. for(i=0; i<sz; i++) {
  324. args->argv[args->argc] = &(line[i]) ;
  325. while(!IF_DELIMITER(line[i])) i++ ;
  326. args->argc++ ;
  327. if(line[i] == '\n') {
  328. line[i] = '\0' ;
  329. break ;
  330. } else {
  331. line[i] = '\0' ;
  332. }
  333. }
  334. return i ;
  335. }
  336. /************* Embedded Shell Commands **********************************/
  337. #define IP_SIZE 16
  338. #ifdef WOLFSSL_KEIL_TCP_NET
  339. static void ipaddr_comm(void *args)
  340. {
  341. if(((func_args *)args)->argc == 1) {
  342. printf("IP addr: %s, port %d\n", wolfSSLIP, wolfSSLPort) ;
  343. } else {
  344. if(BackGround != 0) {
  345. printf("Cannot change IP addr while background server is running\n") ;
  346. } else if(((func_args *)args)->argc == 3 &&
  347. ((func_args *)args)->argv[1][0] == '-'&&
  348. ((func_args *)args)->argv[1][1] == 'a' ) {
  349. /* strcpy(yasslIP, ((func_args *)args)->argv[2]) ; */
  350. } else if(((func_args *)args)->argc == 3 &&
  351. ((func_args *)args)->argv[1][0] == '-' &&
  352. ((func_args *)args)->argv[1][1] == 'p' ) {
  353. /* yasslPort = atoi(((func_args *)args)->argv[2]) ; */
  354. } else printf("Invalid argument\n") ;
  355. }
  356. }
  357. #endif
  358. #if defined(HAVE_KEIL_RTX)
  359. static int stack_ck = 0 ;
  360. void stack_comm(void *args)
  361. {
  362. if(stack_ck) {
  363. printf("Stack Check: Off\n") ;
  364. stack_ck = 0 ;
  365. } else {
  366. printf("Stack Check: On\n") ;
  367. stack_ck = 1 ;
  368. }
  369. }
  370. #define FILL_PATTERN 0xa596695a
  371. void stack_fill(char * stack, int size)
  372. {
  373. int i ;
  374. if(stack_ck == 0)return ;
  375. for(i=1; i<size/4-10; i++)
  376. ((int *)stack)[i] = FILL_PATTERN ;
  377. }
  378. void stack_check(char * stack, int size)
  379. {
  380. int i ;
  381. if(stack_ck == 0)return ;
  382. if(stack_ck == 1) {
  383. stack_ck ++ ; return ;
  384. }
  385. for(i=1; i<size/4 ; i++) {
  386. if(((int *)stack)[i] != FILL_PATTERN) break ;
  387. }
  388. if(i < size/4) {
  389. printf("Stack is used %d bytes out of %d\n", size - i*4, size) ;
  390. } else {
  391. printf("Stack overflow. Stack size: %d\n", size) ;
  392. }
  393. }
  394. #endif /* HAVE_KEIL_RTX */
  395. static int for_iteration = 1 ;
  396. static void for_command(void *args)
  397. {
  398. if( args == NULL || ((func_args *)args)->argc == 1) {
  399. printf("For %d times\n", for_iteration) ;
  400. } else if(((func_args *)args)->argc == 2) {
  401. for_iteration = atoi(((func_args *)args)->argv[1]) ;
  402. } else printf("Invalid argument\n") ;
  403. }
  404. #if defined(DEBUG_WOLFSSL)
  405. static int wolfsslDebug = 1 ;
  406. static void dbg_comm(void *args)
  407. {
  408. if(wolfsslDebug == 1) {
  409. wolfsslDebug = 0 ;
  410. printf("Turning OFF Debug message\n") ;
  411. wolfSSL_Debugging_OFF() ;
  412. } else {
  413. wolfasslDebug = 1 ;
  414. printf("Turning ON Debug message\n") ;
  415. wolfSSL_Debugging_ON() ;
  416. }
  417. }
  418. #endif
  419. static void help_comm(void *args)
  420. {
  421. static char *commands[] = {
  422. "test",
  423. "benchmark",
  424. "echoserver& : simple echo server in background mode",
  425. "echoclient : simple echo client followed by any input string, or \"quit\", \"break\"",
  426. "server& : simple server in background mode",
  427. "client : simple client",
  428. "client -g -v [0123] -h xxx.xxx.xxx.xxx -p 443 : usage example",
  429. "server/client -h : help for server/client command",
  430. "help",
  431. ""
  432. } ;
  433. int i ;
  434. printf("Commands:\n") ;
  435. for(i=0; commands[i][0] ; i++)
  436. printf(" %s\n", commands[i]) ;
  437. }
  438. #define BG_JOB_STACK_SIZE 16000
  439. #if (!defined(NO_SIMPLE_SERVER) && !defined(NO_ECHOSERVER)) && \
  440. defined(HAVE_KEIL_RTX)
  441. #if !defined(WOLFSSL_CMSIS_RTOS)
  442. static char bg_job_stack[BG_JOB_STACK_SIZE] ;
  443. #endif
  444. #endif
  445. #define COMMAND_STACK_SIZE 24000
  446. #if defined(HAVE_KEIL_RTX) && !defined(WOLFSSL_CMSIS_RTOS)
  447. static char command_stack[COMMAND_STACK_SIZE] ;
  448. #endif
  449. #if defined(HAVE_KEIL_RTX) || defined(WOLFSSL_CMSIS_RTOS)
  450. static wolfSSL_Mutex command_mutex ;
  451. #endif
  452. void exit_command(void) {
  453. printf("Command Aborted\n") ;
  454. #ifdef WOLFSSL_CMSIS_RTOS
  455. osThreadTerminate(osThreadGetId()) ;
  456. #else
  457. os_tsk_delete_self() ;
  458. #endif
  459. }
  460. /*********** Invoke Foreground Command *********************/
  461. static void command_invoke(void const *args)
  462. {
  463. void (*func)(void const * ) ;
  464. int i,iteration ;
  465. func = (void(*)(void const *))((func_args *)args)->argv[0] ;
  466. #if defined(HAVE_KEIL_RTX)
  467. wc_LockMutex((wolfSSL_Mutex *)&command_mutex) ;
  468. #endif
  469. iteration = for_iteration ;
  470. for(i=0; i< iteration; i++) {
  471. if(iteration > 1) printf("--- Start for %d ---->\n", i) ;
  472. #if defined(HAVE_KEIL_RTX) && !defined(WOLFSSL_CMSIS_RTOS)
  473. stack_fill(command_stack, COMMAND_STACK_SIZE) ;
  474. #endif
  475. func(args) ; /* invoke command */
  476. #if defined(HAVE_KEIL_RTX)&& !defined(WOLFSSL_CMSIS_RTOS)
  477. stack_check(command_stack, COMMAND_STACK_SIZE) ;
  478. #endif
  479. }
  480. if(iteration > 1)
  481. for_iteration = 1 ;
  482. osDelay(20000) ;
  483. #ifdef HAVE_KEIL_RTX
  484. wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
  485. #ifdef WOLFSSL_CMSIS_RTOS
  486. osThreadTerminate(osThreadGetId()) ;
  487. #else
  488. os_tsk_delete_self() ;
  489. #endif
  490. #endif
  491. }
  492. #if defined(HAVE_KEIL_RTX) || defined(WOLFSSL_CMSIS_RTOS)
  493. /******* Invoke Background Job *******************************/
  494. static void bg_job_invoke(void const *args)
  495. {
  496. void (*func)(void const * ) ;
  497. BackGround = 1 ;
  498. #if defined(HAVE_KEIL_RTX)&& !defined(WOLFSSL_CMSIS_RTOS)
  499. stack_fill(bg_job_stack, BG_JOB_STACK_SIZE) ;
  500. #endif
  501. func = (void(*)(void const *))((func_args *)args)->argv[0] ;
  502. func(args) ; /* invoke command */
  503. #if defined(HAVE_KEIL_RTX) && !defined(WOLFSSL_CMSIS_RTOS)
  504. stack_check(bg_job_stack, BG_JOB_STACK_SIZE) ;
  505. #endif
  506. osDelay(20000) ;
  507. BackGround = 0 ;
  508. #ifdef WOLFSSL_CMSIS_RTOS
  509. osThreadTerminate(osThreadGetId()) ;
  510. #else
  511. os_tsk_delete_self() ; ;
  512. #endif
  513. }
  514. #endif
  515. #define LINESIZE 100
  516. static char line[LINESIZE] ;
  517. #if defined(WOLFSSL_CMSIS_RTOS)
  518. osThreadDef (command_invoke, osPriorityAboveNormal , 1, COMMAND_STACK_SIZE) ;
  519. osThreadDef (bg_job_invoke, osPriorityNormal , 1 , BG_JOB_STACK_SIZE) ;
  520. #endif
  521. /********* SHEULL MAIN LOOP ***********************************/
  522. void shell_main(void *arg) {
  523. int i ;
  524. func_args args ;
  525. int bf_flg ;
  526. #if defined(WOLFSSL_CMSIS_RTOS)
  527. osThreadId cmd ;
  528. #endif
  529. i = BackGround ;
  530. /* Dummy for avoiding warning: BackGround is defined but not used. */
  531. #if defined(HAVE_KEIL_RTX)
  532. wc_InitMutex(&command_mutex) ;
  533. #endif
  534. help_comm(NULL) ;
  535. printf("Starting Shell\n") ;
  536. while(1) {
  537. if(getline(line, LINESIZE, &args, &bf_flg) > 0) {
  538. for(i=0; commandTable[i].func != NULL; i++) {
  539. if(strcmp(commandTable[i].command, args.argv[0]) == 0) {
  540. args.argv[0] = (char *) commandTable[i].func ;
  541. if(bf_flg == FOREGROUND) {
  542. #if defined(HAVE_KEIL_RTX) && !defined(WOLFSSL_CMSIS_RTOS)
  543. wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
  544. os_tsk_create_user_ex( (void(*)(void *))&command_invoke, 7,
  545. command_stack, COMMAND_STACK_SIZE, &args) ;
  546. os_tsk_pass ();
  547. #else
  548. #if defined(WOLFSSL_CMSIS_RTOS)
  549. wc_UnLockMutex((wolfSSL_Mutex *)&command_mutex) ;
  550. cmd = osThreadCreate (osThread (command_invoke) , &args);
  551. if(cmd == NULL) {
  552. printf("Cannon create command thread\n") ;
  553. }
  554. osThreadYield ();
  555. #else
  556. command_invoke(&args) ;
  557. #endif
  558. #endif
  559. #ifdef HAVE_KEIL_RTX
  560. wc_LockMutex((wolfSSL_Mutex *)&command_mutex) ;
  561. #endif
  562. } else {
  563. #if (!defined(NO_SIMPLE_SERVER) && \
  564. !defined(NO_ECHOSERVER)) && \
  565. defined(HAVE_KEIL_RTX)
  566. if(BackGround != 0) {
  567. printf("Multiple background servers not supported.\n") ;
  568. } else {
  569. printf("\"%s\" is running with the background mode.\n",
  570. commandTable[i].command) ;
  571. #if defined(HAVE_KEIL_RTX) && !defined(WOLFSSL_CMSIS_RTOS)
  572. os_tsk_create_user_ex( (void(*)(void *))&bg_job_invoke,
  573. 6, bg_job_stack, BG_JOB_STACK_SIZE, &args) ;
  574. #else
  575. osThreadCreate (osThread (bg_job_invoke), &args);
  576. osDelay (500) ;
  577. #endif
  578. }
  579. #else
  580. printf("Invalid Command: no background job\n") ;
  581. #endif
  582. }
  583. break ;
  584. }
  585. }
  586. if(commandTable[i].func == NULL)
  587. printf("Command not found\n") ;
  588. }
  589. }
  590. }