2 * WPA Supplicant / main() function for Amiga-like OSes
3 * Copyright (c) 2003-2007, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2010-2011, Neil Cafferkey
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Alternatively, this software may be distributed under the terms of BSD
13 * See README and COPYING for more details.
19 #include "wpa_supplicant_i.h"
21 #include <exec/types.h>
24 #include <proto/dos.h>
37 static const TEXT
template[] = "DEVICE/A,UNIT/K/N,CONFIG/K,VERBOSE/S";
38 const TEXT version_string
[] = "$VER: WirelessManager 1.1 (24.9.2011)";
39 static const TEXT config_file_name
[] = "ENV:Wireless.prefs";
42 int main(int argc
, char *argv
[])
44 struct RDArgs
*read_args
;
45 LONG error
= 0, unit_no
= 0;
53 args
= {NULL
, &unit_no
, config_file_name
, FALSE
};
55 struct wpa_interface
*ifaces
, *iface
;
56 int iface_count
, exitcode
= RETURN_FAIL
;
57 struct wpa_params params
;
58 struct wpa_global
*global
;
61 if (os_program_init())
64 os_memset(¶ms
, 0, sizeof(params
));
65 params
.wpa_debug_level
= MSG_INFO
;
67 iface
= ifaces
= os_zalloc(sizeof(struct wpa_interface
));
73 read_args
= ReadArgs(template, (UPINT
*)&args
, NULL
);
80 iface
->ifname
= ifname
= os_malloc(strlen((const char *)args
.device
)
84 error
= ERROR_NO_FREE_STORE
;
88 sprintf(ifname
, "%s:%ld", args
.device
, (long int)*args
.unit
);
90 iface
->confname
= (char *) args
.config
;
93 params
.wpa_debug_level
-= 2;
96 global
= wpa_supplicant_init(¶ms
);
98 wpa_printf(MSG_ERROR
, "Failed to initialize WirelessManager");
99 exitcode
= RETURN_FAIL
;
103 for (i
= 0; exitcode
== 0 && i
< iface_count
; i
++) {
104 if ((ifaces
[i
].confname
== NULL
&&
105 ifaces
[i
].ctrl_interface
== NULL
) ||
106 ifaces
[i
].ifname
== NULL
) {
107 if (iface_count
== 1 && (params
.ctrl_interface
||
108 params
.dbus_ctrl_interface
))
110 error
= ERROR_REQUIRED_ARG_MISSING
;
111 exitcode
= RETURN_FAIL
;
114 if (wpa_supplicant_add_iface(global
, &ifaces
[i
]) == NULL
)
115 exitcode
= RETURN_FAIL
;
119 exitcode
= wpa_supplicant_run(global
);
121 wpa_supplicant_deinit(global
);
126 // os_program_deinit();
130 /* Print error message */
132 PrintFault(error
, NULL
);
135 exitcode
= RETURN_FAIL
;