Fixes for peer review feedback.
parent
aa701a77d3
commit
1bb931cf4d
|
@ -1,6 +1,6 @@
|
||||||
/* btle-sim.c
|
/* btle-sim.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 wolfSSL Inc.
|
* Copyright (C) 2006-2022 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
*
|
*
|
||||||
|
@ -19,6 +19,10 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* This is a BTLE simulator to demonstrate communications between devices.
|
||||||
|
* The simulator uses IPC (pipes) to communicate between threads.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
|
@ -24,9 +24,9 @@
|
||||||
#define BTLE_BLOCK_SIZE 16
|
#define BTLE_BLOCK_SIZE 16
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <string.h> /* for strcasestr */
|
#include <string.h> /* for strnstr */
|
||||||
|
|
||||||
#define EXIT_STRING "EXIT"
|
#define EXIT_STRING "exit"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BTLE_PKT_TYPE_NULL,
|
BTLE_PKT_TYPE_NULL,
|
|
@ -1,7 +1,7 @@
|
||||||
# BTLE Examples Makefile
|
# BTLE Examples Makefile
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LIB_PATH = /usr/local
|
LIB_PATH = /usr/local
|
||||||
CFLAGS = -Wall -I$(LIB_PATH)/include
|
CFLAGS = -Wall -I ../common -I$(LIB_PATH)/include
|
||||||
LIBS = -L$(LIB_PATH)/lib
|
LIBS = -L$(LIB_PATH)/lib
|
||||||
|
|
||||||
# Flags
|
# Flags
|
||||||
|
@ -31,10 +31,10 @@ debug: all
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
gcc -c $< -o $@ $(CFLAGS)
|
gcc -c $< -o $@ $(CFLAGS)
|
||||||
|
|
||||||
ecc-server: ecc-server.o ../btle-sim.o $(STATIC_LIB)
|
ecc-server: ecc-server.o ../common/btle-sim.o $(STATIC_LIB)
|
||||||
$(CC) $^ -o $@ $(LIBS)
|
$(CC) $^ -o $@ $(LIBS)
|
||||||
|
|
||||||
ecc-client: ecc-client.o ../btle-sim.o $(STATIC_LIB)
|
ecc-client: ecc-client.o ../common/btle-sim.o $(STATIC_LIB)
|
||||||
$(CC) $^ -o $@ $(LIBS)
|
$(CC) $^ -o $@ $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../btle-sim.h"
|
#include "btle-sim.h"
|
||||||
|
|
||||||
#ifndef WOLFSSL_USER_SETTINGS
|
#ifndef WOLFSSL_USER_SETTINGS
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
|
@ -201,7 +201,7 @@ int main(int argc, char** argv)
|
||||||
printf("Recv %d: %s\n", plainSz, plain);
|
printf("Recv %d: %s\n", plainSz, plain);
|
||||||
|
|
||||||
/* check for exit flag */
|
/* check for exit flag */
|
||||||
if (strcasestr((char*)plain, EXIT_STRING)) {
|
if (strncmp((char*)plain, EXIT_STRING, strlen(EXIT_STRING)) == 0) {
|
||||||
printf("Exit, closing connection\n");
|
printf("Exit, closing connection\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../btle-sim.h"
|
#include "btle-sim.h"
|
||||||
|
|
||||||
#ifndef WOLFSSL_USER_SETTINGS
|
#ifndef WOLFSSL_USER_SETTINGS
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
|
@ -191,7 +191,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for exit flag */
|
/* check for exit flag */
|
||||||
if (strcasestr((char*)plain, EXIT_STRING)) {
|
if (strncmp((char*)plain, EXIT_STRING, strlen(EXIT_STRING)) == 0) {
|
||||||
printf("Exit, closing connection\n");
|
printf("Exit, closing connection\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# BTLE Examples Makefile
|
# BTLE Examples Makefile
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LIB_PATH = /usr/local
|
LIB_PATH = /usr/local
|
||||||
CFLAGS = -Wall -I$(LIB_PATH)/include
|
CFLAGS = -Wall -I ../common -I $(LIB_PATH)/include
|
||||||
LIBS = -L$(LIB_PATH)/lib
|
LIBS = -L$(LIB_PATH)/lib
|
||||||
|
|
||||||
# Flags
|
# Flags
|
||||||
|
@ -31,10 +31,10 @@ debug: all
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
gcc -c $< -o $@ $(CFLAGS)
|
gcc -c $< -o $@ $(CFLAGS)
|
||||||
|
|
||||||
server-tls13-btle: server-tls13-btle.o ../btle-sim.o $(STATIC_LIB)
|
server-tls13-btle: server-tls13-btle.o ../common/btle-sim.o $(STATIC_LIB)
|
||||||
$(CC) $^ -o $@ $(LIBS)
|
$(CC) $^ -o $@ $(LIBS)
|
||||||
|
|
||||||
client-tls13-btle: client-tls13-btle.o ../btle-sim.o $(STATIC_LIB)
|
client-tls13-btle: client-tls13-btle.o ../common/btle-sim.o $(STATIC_LIB)
|
||||||
$(CC) $^ -o $@ $(LIBS)
|
$(CC) $^ -o $@ $(LIBS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
* Example TLSv1.3 client over BTLE
|
* Example TLSv1.3 client over BTLE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../btle-sim.h"
|
#include "btle-sim.h"
|
||||||
|
|
||||||
#ifndef WOLFSSL_USER_SETTINGS
|
#ifndef WOLFSSL_USER_SETTINGS
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
|
@ -189,7 +189,7 @@ int main(int argc, char** argv)
|
||||||
printf("Read (%d): %s\n", ret, plain);
|
printf("Read (%d): %s\n", ret, plain);
|
||||||
|
|
||||||
/* check for exit flag */
|
/* check for exit flag */
|
||||||
if (strcasestr((char*)plain, EXIT_STRING)) {
|
if (strncmp((char*)plain, EXIT_STRING, strlen(EXIT_STRING)) == 0) {
|
||||||
printf("Exit, closing connection\n");
|
printf("Exit, closing connection\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
* Example TLS v1.3 server over BTLE
|
* Example TLS v1.3 server over BTLE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../btle-sim.h"
|
#include "btle-sim.h"
|
||||||
|
|
||||||
#ifndef WOLFSSL_USER_SETTINGS
|
#ifndef WOLFSSL_USER_SETTINGS
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
|
@ -177,7 +177,7 @@ int main(int argc, char** argv)
|
||||||
printf("Sent (%d): %s\n", ret, echoBuffer);
|
printf("Sent (%d): %s\n", ret, echoBuffer);
|
||||||
|
|
||||||
/* check for exit flag */
|
/* check for exit flag */
|
||||||
if (strcasestr((char*)echoBuffer, EXIT_STRING)) {
|
if (strncmp((char*)echoBuffer, EXIT_STRING, strlen(EXIT_STRING)) == 0) {
|
||||||
printf("Exit, closing connection\n");
|
printf("Exit, closing connection\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue