Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes from Nordic #5

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ROLE = dut
VERSION = "2.1.0.42"

OBJS = main.o eloop.o indigo_api.o indigo_packet.o utils.o wpa_ctrl.o
CFLAGS += -g
CFLAGS += -g -Wall -Wextra -Wpedantic -Werror

ifeq ($(TYPE),laptop)
CC = gcc
Expand Down Expand Up @@ -34,6 +34,10 @@ CFLAGS += -DCONFIG_CTRL_IFACE_UDP
CFLAGS += -D_TEST_PLATFORM_
endif

# Feature flags
# Enable by default
CFLAGS += -DCONFIG_P2P -DCONFIG_WNM -DCONFIG_HS20 -DCONFIG_AP -DCONFIG_WPS

# Define the package version
ifneq ($(VERSION),)
CFLAGS += -D_VERSION_='$(VERSION)'
Expand Down
23 changes: 12 additions & 11 deletions eloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ struct eloop_data {
static struct eloop_data eloop;


void eloop_init(void *user_data)
void qt_eloop_init(void *user_data)
{
memset(&eloop, 0, sizeof(eloop));
eloop.user_data = user_data;
}


int eloop_register_read_sock(int sock,
int qt_eloop_register_read_sock(int sock,
void (*handler)(int sock, void *eloop_ctx,
void *sock_ctx),
void *eloop_data, void *user_data)
Expand All @@ -103,7 +103,7 @@ int eloop_register_read_sock(int sock,
}


void eloop_unregister_read_sock(int sock)
void qt_eloop_unregister_read_sock(int sock)
{
int i;

Expand All @@ -125,7 +125,7 @@ void eloop_unregister_read_sock(int sock)
}


int eloop_register_timeout(unsigned int secs, unsigned int usecs,
int qt_eloop_register_timeout(unsigned int secs, unsigned int usecs,
void (*handler)(void *eloop_ctx, void *timeout_ctx),
void *eloop_data, void *user_data)
{
Expand Down Expand Up @@ -172,7 +172,7 @@ int eloop_register_timeout(unsigned int secs, unsigned int usecs,
}


int eloop_cancel_timeout(void (*handler)(void *eloop_ctx, void *sock_ctx),
int qt_eloop_cancel_timeout(void (*handler)(void *eloop_ctx, void *sock_ctx),
void *eloop_data, void *user_data)
{
struct eloop_timeout *timeout, *prev, *next;
Expand Down Expand Up @@ -207,6 +207,7 @@ int eloop_cancel_timeout(void (*handler)(void *eloop_ctx, void *sock_ctx),
#ifndef CONFIG_NATIVE_WINDOWS
static void eloop_handle_alarm(int sig)
{
(void) sig;
fprintf(stderr, "eloop: could not process SIGINT or SIGTERM in two "
"seconds. Looks like there\n"
"is a bug that ends up in a busy loop that "
Expand Down Expand Up @@ -268,7 +269,7 @@ static void eloop_process_pending_signals(void)
}


int eloop_register_signal(int sig,
int qt_eloop_register_signal(int sig,
void (*handler)(int sig, void *eloop_ctx,
void *signal_ctx),
void *user_data)
Expand All @@ -294,15 +295,15 @@ int eloop_register_signal(int sig,
}


void eloop_run(void)
void qt_eloop_run(void)
{
fd_set *rfds;
int i, res;
struct timeval tv, now;

rfds = malloc(sizeof(*rfds));
if (rfds == NULL) {
printf("eloop_run - malloc failed\n");
printf("qt_eloop_run - malloc failed\n");
return;
}

Expand Down Expand Up @@ -364,13 +365,13 @@ void eloop_run(void)
}


void eloop_terminate(void)
void qt_eloop_terminate(void)
{
eloop.terminate = 1;
}


void eloop_destroy(void)
void qt_eloop_destroy(void)
{
struct eloop_timeout *timeout, *prev;

Expand All @@ -385,7 +386,7 @@ void eloop_destroy(void)
}


int eloop_terminated(void)
int qt_eloop_terminated(void)
{
return eloop.terminate;
}
55 changes: 27 additions & 28 deletions eloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@
#ifndef ELOOP_H
#define ELOOP_H

/* Magic number for eloop_cancel_timeout() */
/* Magic number for qt_eloop_cancel_timeout() */
#define ELOOP_ALL_CTX (void *) -1

/**
* eloop_init() - Initialize global event loop data
* qt_eloop_init() - Initialize global event loop data
* @user_data: Pointer to global data passed as eloop_ctx to signal handlers
*
* This function must be called before any other eloop_* function. user_data
* can be used to configure a global (to the process) pointer that will be
* passed as eloop_ctx parameter to signal handlers.
*/
void eloop_init(void *user_data);
void qt_eloop_init(void *user_data);

/**
* eloop_register_read_sock - Register handler for read events
* qt_eloop_register_read_sock - Register handler for read events
* @sock: File descriptor number for the socket
* @handler: Callback function to be called when data is available for reading
* @eloop_data: Callback context data (eloop_ctx)
Expand All @@ -48,22 +48,22 @@ void eloop_init(void *user_data);
* function will be called whenever data is available for reading from the
* socket.
*/
int eloop_register_read_sock(int sock,
int qt_eloop_register_read_sock(int sock,
void (*handler)(int sock, void *eloop_ctx,
void *sock_ctx),
void *eloop_data, void *user_data);

/**
* eloop_unregister_read_sock - Unregister handler for read events
* qt_eloop_unregister_read_sock - Unregister handler for read events
* @sock: File descriptor number for the socket
*
* Unregister a read socket notifier that was previously registered with
* eloop_register_read_sock().
* qt_eloop_register_read_sock().
*/
void eloop_unregister_read_sock(int sock);
void qt_eloop_unregister_read_sock(int sock);

/**
* eloop_register_timeout - Register timeout
* qt_eloop_register_timeout - Register timeout
* @secs: Number of seconds to the timeout
* @usecs: Number of microseconds to the timeout
* @handler: Callback function to be called when timeout occurs
Expand All @@ -74,26 +74,26 @@ void eloop_unregister_read_sock(int sock);
* Register a timeout that will cause the handler function to be called after
* given time.
*/
int eloop_register_timeout(unsigned int secs, unsigned int usecs,
int qt_eloop_register_timeout(unsigned int secs, unsigned int usecs,
void (*handler)(void *eloop_ctx, void *timeout_ctx),
void *eloop_data, void *user_data);

/**
* eloop_cancel_timeout - Cancel timeouts
* qt_eloop_cancel_timeout - Cancel timeouts
* @handler: Matching callback function
* @eloop_data: Matching eloop_data or %ELOOP_ALL_CTX to match all
* @user_data: Matching user_data or %ELOOP_ALL_CTX to match all
* Returns: Number of cancelled timeouts
*
* Cancel matching <handler,eloop_data,user_data> timeouts registered with
* eloop_register_timeout(). ELOOP_ALL_CTX can be used as a wildcard for
* qt_eloop_register_timeout(). ELOOP_ALL_CTX can be used as a wildcard for
* cancelling all timeouts regardless of eloop_data/user_data.
*/
int eloop_cancel_timeout(void (*handler)(void *eloop_ctx, void *sock_ctx),
int qt_eloop_cancel_timeout(void (*handler)(void *eloop_ctx, void *sock_ctx),
void *eloop_data, void *user_data);

/**
* eloop_register_signal - Register handler for signals
* qt_eloop_register_signal - Register handler for signals
* @sig: Signal number (e.g., SIGHUP)
* @handler: Callback function to be called when the signal is received
* @user_data: Callback context data (signal_ctx)
Expand All @@ -106,47 +106,46 @@ int eloop_cancel_timeout(void (*handler)(void *eloop_ctx, void *sock_ctx),
*
* Signals are 'global' events and there is no local eloop_data pointer like
* with other handlers. The global user_data pointer registered with
* eloop_init() will be used as eloop_ctx for signal handlers.
* qt_eloop_init() will be used as eloop_ctx for signal handlers.
*/
int eloop_register_signal(int sig,
int qt_eloop_register_signal(int sig,
void (*handler)(int sig, void *eloop_ctx,
void *signal_ctx),
void *user_data);

/**
* eloop_run - Start the event loop
* qt_eloop_run - Start the event loop
*
* Start the event loop and continue running as long as there are any
* registered event handlers. This function is run after event loop has been
* initialized with event_init() and one or more events have been registered.
*/
void eloop_run(void);
void qt_eloop_run(void);

/**
* eloop_terminate - Terminate event loop
* qt_eloop_terminate - Terminate event loop
*
* Terminate event loop even if there are registered events. This can be used
* to request the program to be terminated cleanly.
*/
void eloop_terminate(void);
void qt_eloop_terminate(void);

/**
* eloop_destroy - Free any resources allocated for the event loop
* qt_eloop_destroy - Free any resources allocated for the event loop
*
* After calling eloop_destoy(), other eloop_* functions must not be called
* before re-running eloop_init().
* before re-running qt_eloop_init().
*/
void eloop_destroy(void);
void qt_eloop_destroy(void);

/**
* eloop_terminated - Check whether event loop has been terminated
* qt_eloop_terminated - Check whether event loop has been terminated
* Returns: 1 = event loop terminate, 0 = event loop still running
*
* This function can be used to check whether eloop_terminate() has been called
* This function can be used to check whether qt_eloop_terminate() has been called
* to request termination of the event loop. This is normally used to abort
* operations that may still be queued to be run when eloop_terminate() was
* operations that may still be queued to be run when qt_eloop_terminate() was
* called.
*/
int eloop_terminated(void);
int qt_eloop_terminated(void);

#endif /* ELOOP_H */
4 changes: 2 additions & 2 deletions hs2_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ struct tlv_to_profile hs2_profile[] = {
};

struct tlv_to_profile* find_tlv_hs2_profile(int tlv_id) {
int i;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(hs2_profile); i++) {
if (tlv_id == hs2_profile[i].tlv_id) {
return &hs2_profile[i];
Expand All @@ -190,7 +190,7 @@ struct tlv_to_profile* find_tlv_hs2_profile(int tlv_id) {
}

void attach_hs20_icons(char * buffer) {
int i;
unsigned int i;
for (i = 0; i < ARRAY_SIZE(hs20_icon); i++) {
strcat(buffer, hs20_icon[i]);
}
Expand Down
8 changes: 4 additions & 4 deletions indigo_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,12 @@ struct indigo_tlv indigo_tlv_list[] = {
{ TLV_CAPTURE_OUTFILE, "CAPTURE_OUTFILE" },
{ TLV_TP_IP_ADDRESS, "TP_IP_ADDRESS" },
{ TLV_WPS_ER_SUPPORT, "WPS_ER_SUPPORT" },
{ TLV_ADDITIONAL_TEST_PLATFORM_ID, "ADDITIONAL_TEST_PLATFORM_ID" },
{ TLV_ADDITIONAL_TEST_PLATFORM_ID, "ADDITIONAL_TEST_PLATFORM_ID" },
};

/* Find the type of the API stucture by the ID from the list */
char* get_api_type_by_id(int id) {
int i = 0;
unsigned int i = 0;
for (i = 0; i < sizeof(indigo_api_list)/sizeof(struct indigo_api); i++) {
if (id == indigo_api_list[i].type) {
return indigo_api_list[i].name;
Expand All @@ -288,7 +288,7 @@ char* get_api_type_by_id(int id) {

/* Find the API stucture by the ID from the list */
struct indigo_api* get_api_by_id(int id) {
int i = 0;
unsigned int i = 0;
for (i = 0; i < sizeof(indigo_api_list)/sizeof(struct indigo_api); i++) {
if (id == indigo_api_list[i].type) {
return &indigo_api_list[i];
Expand All @@ -299,7 +299,7 @@ struct indigo_api* get_api_by_id(int id) {

/* Find the TLV by the ID from the list */
struct indigo_tlv* get_tlv_by_id(int id) {
int i = 0;
unsigned int i = 0;

for (i = 0; i < sizeof(indigo_tlv_list)/sizeof(struct indigo_tlv); i++) {
if (id == indigo_tlv_list[i].id) {
Expand Down
2 changes: 1 addition & 1 deletion indigo_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ struct indigo_api {
#define TLV_VENUE_TYPE 0x00ad
#define TLV_HESSID 0x00ae
#define TLV_OSU_SSID 0x00af
#define TLV_ANQP_3GPP_CELL_NETWORK_INFO 0x00b0
#define TLV_ANQP_3GPP_CELL_NETWORK_INFO 0x00b0
#define TLV_PROXY_ARP 0x00b1
#define TLV_BSSLOAD_ENABLE 0x00b2
#define TLV_ROAMING_CONSORTIUM 0x00b3
Expand Down
Loading