diff --git a/headers/private/net/WPASupplicant.h b/headers/private/net/WPASupplicant.h new file mode 100644 index 0000000000..52251b358f --- /dev/null +++ b/headers/private/net/WPASupplicant.h @@ -0,0 +1,20 @@ +/* + * Copyright 2010, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, axeld@pinc-software.de + */ +#ifndef _WPA_SUPPLICANT_H +#define _WPA_SUPPLICANT_H + + +#define kWPASupplicantSignature "application/x-vnd.malinen-wpa_supplicant" + +#define kMsgWPAStartWatching 'WPAw' +#define kMsgWPAStopWatching 'WPAs' +#define kMsgWPAJoinNetwork 'WPAj' +#define kMsgWPALeaveNetwork 'WPAl' + + +#endif // _WPA_SUPPLICANT_H diff --git a/src/servers/net/NetServer.cpp b/src/servers/net/NetServer.cpp index 509c34d45a..3fd4f87e19 100644 --- a/src/servers/net/NetServer.cpp +++ b/src/servers/net/NetServer.cpp @@ -40,6 +40,7 @@ #include #include +#include #include "AutoconfigLooper.h" #include "Services.h" @@ -855,6 +856,8 @@ NetServer::_AutoJoinNetwork(const char* name) if (status == B_OK) { status = _JoinNetwork(message, network.name); + printf("auto join network \"%s\": %s\n", network.name, + strerror(status)); if (status == B_OK) return B_OK; } @@ -867,6 +870,8 @@ NetServer::_AutoJoinNetwork(const char* name) while (device.GetNextNetwork(cookie, network) == B_OK) { if ((network.flags & B_NETWORK_IS_ENCRYPTED) == 0) { status_t status = _JoinNetwork(message, network.name); + printf("auto join open network \"%s\": %s\n", network.name, + strerror(status)); if (status == B_OK) return status; } @@ -1016,9 +1021,28 @@ NetServer::_JoinNetwork(const BMessage& message, const char* name) return B_OK; } - // TODO: join via wpa_supplicant + // Join via wpa_supplicant - return B_ERROR; + status_t status = be_roster->Launch(kWPASupplicantSignature); + if (status != B_OK && status != B_ALREADY_RUNNING) + return status; + + // TODO: listen to notifications from the supplicant! + + BMessage join(kMsgWPAJoinNetwork); + status = join.AddString("device", deviceName); + if (status == B_OK) + status = join.AddString("name", network.name); + if (status == B_OK) + status = join.AddFlat("address", &network.address); + + BMessenger wpaSupplicant(kWPASupplicantSignature); + BMessage reply; + status = wpaSupplicant.SendMessage(&join, &reply); + if (status != B_OK) + return status; + + return reply.FindInt32("status"); }