mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-14 15:29:43 +08:00
wpa_supplicant: Move forking command into own file.
The malloc wrapper must not be disabled. Therefore the command that uses malloc without a wrapper has to live in another file.
This commit is contained in:
parent
ce2262ee28
commit
ee0c369cdd
@ -22,8 +22,6 @@
|
|||||||
#ifdef __rtems__
|
#ifdef __rtems__
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
#define RTEMS_BSD_PROGRAM_NO_MALLOC_WRAP
|
|
||||||
#define RTEMS_BSD_PROGRAM_NO_STRDUP_WRAP
|
|
||||||
#include <machine/rtems-bsd-program.h>
|
#include <machine/rtems-bsd-program.h>
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
@ -176,69 +174,6 @@ int rtems_bsd_command_wpa_supplicant(int argc, char **argv)
|
|||||||
|
|
||||||
return exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct myparams {
|
|
||||||
int argc;
|
|
||||||
char ** argv;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
|
||||||
new_wpa_supplicant_task(rtems_task_argument arg)
|
|
||||||
{
|
|
||||||
int argc;
|
|
||||||
char ** argv;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
struct myparams *params = (struct myparams *)arg;
|
|
||||||
argc = params->argc;
|
|
||||||
argv = params->argv;
|
|
||||||
|
|
||||||
rtems_bsd_command_wpa_supplicant(argc, argv);
|
|
||||||
|
|
||||||
for (i = 0; i < params->argc; i++) {
|
|
||||||
free(params->argv[i]);
|
|
||||||
}
|
|
||||||
free(params->argv);
|
|
||||||
free(params);
|
|
||||||
|
|
||||||
rtems_task_delete( RTEMS_SELF );
|
|
||||||
}
|
|
||||||
|
|
||||||
int rtems_bsd_command_wpa_supplicant_fork(int argc, char **argv)
|
|
||||||
{
|
|
||||||
rtems_status_code sc;
|
|
||||||
rtems_id id;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
struct myparams *params = malloc(sizeof(struct myparams));
|
|
||||||
if (params == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
params->argc = argc;
|
|
||||||
params->argv = malloc((argc + 1) * sizeof(argv[0]));
|
|
||||||
if (params->argv == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
|
||||||
params->argv[i] = strdup(argv[i]);
|
|
||||||
if (params->argv[i] == NULL)
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
params->argv[argc] = NULL;
|
|
||||||
|
|
||||||
sc = rtems_task_create(
|
|
||||||
rtems_build_name('W', 'P', 'A', 'S'),
|
|
||||||
RTEMS_MAXIMUM_PRIORITY - 1,
|
|
||||||
8 * RTEMS_MINIMUM_STACK_SIZE,
|
|
||||||
RTEMS_DEFAULT_MODES,
|
|
||||||
RTEMS_FLOATING_POINT,
|
|
||||||
&id
|
|
||||||
);
|
|
||||||
assert(sc == RTEMS_SUCCESSFUL);
|
|
||||||
|
|
||||||
sc = rtems_task_start(id, new_wpa_supplicant_task, params);
|
|
||||||
assert(sc == RTEMS_SUCCESSFUL);
|
|
||||||
}
|
|
||||||
#endif /* __rtems__ */
|
#endif /* __rtems__ */
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -27,6 +27,70 @@
|
|||||||
|
|
||||||
#include <rtems/netcmds-config.h>
|
#include <rtems/netcmds-config.h>
|
||||||
#include <machine/rtems-bsd-commands.h>
|
#include <machine/rtems-bsd-commands.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
struct myparams {
|
||||||
|
int argc;
|
||||||
|
char ** argv;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
new_wpa_supplicant_task(rtems_task_argument arg)
|
||||||
|
{
|
||||||
|
int argc;
|
||||||
|
char ** argv;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
struct myparams *params = (struct myparams *)arg;
|
||||||
|
argc = params->argc;
|
||||||
|
argv = params->argv;
|
||||||
|
|
||||||
|
rtems_bsd_command_wpa_supplicant(argc, argv);
|
||||||
|
|
||||||
|
for (i = 0; i < params->argc; i++) {
|
||||||
|
free(params->argv[i]);
|
||||||
|
}
|
||||||
|
free(params->argv);
|
||||||
|
free(params);
|
||||||
|
|
||||||
|
rtems_task_delete( RTEMS_SELF );
|
||||||
|
}
|
||||||
|
|
||||||
|
int rtems_bsd_command_wpa_supplicant_fork(int argc, char **argv)
|
||||||
|
{
|
||||||
|
rtems_status_code sc;
|
||||||
|
rtems_id id;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
struct myparams *params = malloc(sizeof(struct myparams));
|
||||||
|
if (params == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
params->argc = argc;
|
||||||
|
params->argv = malloc((argc + 1) * sizeof(argv[0]));
|
||||||
|
if (params->argv == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < argc; i++) {
|
||||||
|
params->argv[i] = strdup(argv[i]);
|
||||||
|
if (params->argv[i] == NULL)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
params->argv[argc] = NULL;
|
||||||
|
|
||||||
|
sc = rtems_task_create(
|
||||||
|
rtems_build_name('W', 'P', 'A', 'S'),
|
||||||
|
RTEMS_MAXIMUM_PRIORITY - 1,
|
||||||
|
8 * RTEMS_MINIMUM_STACK_SIZE,
|
||||||
|
RTEMS_DEFAULT_MODES,
|
||||||
|
RTEMS_FLOATING_POINT,
|
||||||
|
&id
|
||||||
|
);
|
||||||
|
assert(sc == RTEMS_SUCCESSFUL);
|
||||||
|
|
||||||
|
sc = rtems_task_start(id, new_wpa_supplicant_task, params);
|
||||||
|
assert(sc == RTEMS_SUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
rtems_shell_cmd_t rtems_shell_WPA_SUPPLICANT_FORK_Command = {
|
rtems_shell_cmd_t rtems_shell_WPA_SUPPLICANT_FORK_Command = {
|
||||||
.name = "wpa_supplicant_fork",
|
.name = "wpa_supplicant_fork",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user