summaryrefslogtreecommitdiffstats
path: root/freebsd
diff options
context:
space:
mode:
authorSichen Zhao <1473996754@qq.com>2017-10-12 20:16:07 +0800
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-11-10 13:33:03 +0100
commit8f2267bbb90fb52751c3604ade87f353063846c0 (patch)
treea1f6f71bb34d95a3653c073f7161315e61f70010 /freebsd
parentImport wpa from FreeBSD (diff)
downloadrtems-libbsd-8f2267bbb90fb52751c3604ade87f353063846c0.tar.bz2
Port wpa supplicant to RTEMS.
Add wpa_supplicant lib support and shell command support in RTEMS.
Diffstat (limited to 'freebsd')
-rw-r--r--freebsd/contrib/wpa/src/utils/os_unix.c11
-rw-r--r--freebsd/contrib/wpa/wpa_supplicant/config.h3
-rw-r--r--freebsd/contrib/wpa/wpa_supplicant/main.c21
3 files changed, 34 insertions, 1 deletions
diff --git a/freebsd/contrib/wpa/src/utils/os_unix.c b/freebsd/contrib/wpa/src/utils/os_unix.c
index a3abce4c..7f101d71 100644
--- a/freebsd/contrib/wpa/src/utils/os_unix.c
+++ b/freebsd/contrib/wpa/src/utils/os_unix.c
@@ -25,6 +25,11 @@
#include <mach/mach_time.h>
#endif /* __MACH__ */
+#ifdef __rtems__
+#include <unistd.h>
+#endif /* __rtems__ */
+
+
#include "os.h"
#include "common.h"
@@ -225,7 +230,7 @@ static int os_daemon(int nochdir, int noclose)
int os_daemonize(const char *pid_file)
{
-#if defined(__uClinux__) || defined(__sun__)
+#if defined(__uClinux__) || defined(__sun__) || defined(__rtems__)
return -1;
#else /* defined(__uClinux__) || defined(__sun__) */
#ifdef __FreeBSD__
@@ -282,6 +287,9 @@ int os_get_random(unsigned char *buf, size_t len)
if (TEST_FAIL())
return -1;
+#ifdef __rtems__
+ return getentropy(buf, len);
+#else /* __rtems__ */
f = fopen("/dev/urandom", "rb");
if (f == NULL) {
printf("Could not open /dev/urandom.\n");
@@ -292,6 +300,7 @@ int os_get_random(unsigned char *buf, size_t len)
fclose(f);
return rc != len ? -1 : 0;
+#endif /* __rtems__ */
}
diff --git a/freebsd/contrib/wpa/wpa_supplicant/config.h b/freebsd/contrib/wpa/wpa_supplicant/config.h
index 627f38b6..9de7e704 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/config.h
+++ b/freebsd/contrib/wpa/wpa_supplicant/config.h
@@ -45,6 +45,9 @@
#include "common/ieee802_11_defs.h"
#include "common/ieee802_11_common.h"
+#ifdef __rtems__
+#include <machine/rtems-bsd-commands.h>
+#endif /* __rtems__ */
struct wpa_cred {
/**
diff --git a/freebsd/contrib/wpa/wpa_supplicant/main.c b/freebsd/contrib/wpa/wpa_supplicant/main.c
index 0e86b939..40950d2c 100644
--- a/freebsd/contrib/wpa/wpa_supplicant/main.c
+++ b/freebsd/contrib/wpa/wpa_supplicant/main.c
@@ -19,6 +19,11 @@
#include "driver_i.h"
#include "p2p_supplicant.h"
+#ifdef __rtems__
+#include <assert.h>
+#include <sys/mutex.h>
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
static void usage(void)
{
@@ -154,6 +159,22 @@ static void wpa_supplicant_fd_workaround(int start)
#endif /* __linux__ */
}
+#ifdef __rtems__
+#include <rtems/libio.h>
+
+static int
+main(int argc, char **argv);
+
+int rtems_bsd_command_wpa_supplicant(int argc, char **argv)
+{
+ int exit_code;
+ rtems_status_code sc;
+
+ exit_code = rtems_bsd_program_call_main("wpa_supplicant", main, argc, argv);
+
+ return exit_code;
+}
+#endif /* __rtems__ */
int main(int argc, char *argv[])
{