Fixes for peer review feedback.

pull/293/head
David Garske 2022-02-15 15:58:25 -08:00
parent aa701a77d3
commit 1bb931cf4d
8 changed files with 21 additions and 17 deletions

View File

@ -1,6 +1,6 @@
/* 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)
*
@ -19,6 +19,10 @@
* 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/types.h>
#include <sys/select.h>

View File

@ -24,9 +24,9 @@
#define BTLE_BLOCK_SIZE 16
#define _GNU_SOURCE
#include <string.h> /* for strcasestr */
#include <string.h> /* for strnstr */
#define EXIT_STRING "EXIT"
#define EXIT_STRING "exit"
typedef enum {
BTLE_PKT_TYPE_NULL,

View File

@ -1,7 +1,7 @@
# BTLE Examples Makefile
CC = gcc
LIB_PATH = /usr/local
CFLAGS = -Wall -I$(LIB_PATH)/include
CFLAGS = -Wall -I ../common -I$(LIB_PATH)/include
LIBS = -L$(LIB_PATH)/lib
# Flags
@ -31,10 +31,10 @@ debug: all
%.o: %.c
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)
ecc-client: ecc-client.o ../btle-sim.o $(STATIC_LIB)
ecc-client: ecc-client.o ../common/btle-sim.o $(STATIC_LIB)
$(CC) $^ -o $@ $(LIBS)
clean:

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "../btle-sim.h"
#include "btle-sim.h"
#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
@ -201,7 +201,7 @@ int main(int argc, char** argv)
printf("Recv %d: %s\n", plainSz, plain);
/* 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");
break;
}

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "../btle-sim.h"
#include "btle-sim.h"
#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
@ -191,7 +191,7 @@ int main(int argc, char** argv)
}
/* 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");
break;
}

View File

@ -1,7 +1,7 @@
# BTLE Examples Makefile
CC = gcc
LIB_PATH = /usr/local
CFLAGS = -Wall -I$(LIB_PATH)/include
CFLAGS = -Wall -I ../common -I $(LIB_PATH)/include
LIBS = -L$(LIB_PATH)/lib
# Flags
@ -31,10 +31,10 @@ debug: all
%.o: %.c
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)
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)
clean:

View File

@ -23,7 +23,7 @@
* Example TLSv1.3 client over BTLE
*/
#include "../btle-sim.h"
#include "btle-sim.h"
#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
@ -189,7 +189,7 @@ int main(int argc, char** argv)
printf("Read (%d): %s\n", ret, plain);
/* 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");
break;
}

View File

@ -23,7 +23,7 @@
* Example TLS v1.3 server over BTLE
*/
#include "../btle-sim.h"
#include "btle-sim.h"
#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
@ -177,7 +177,7 @@ int main(int argc, char** argv)
printf("Sent (%d): %s\n", ret, echoBuffer);
/* 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");
break;
}