2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2009-03-17 03:30:58 +03:00
|
|
|
|
|
|
|
#include "nsWifiMonitor.h"
|
|
|
|
#include "nsIWifiAccessPoint.h"
|
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsCOMArray.h"
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h" // ArrayLength
|
2012-06-06 07:18:25 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2009-03-17 03:30:58 +03:00
|
|
|
|
|
|
|
#ifndef __nsWifiAccessPoint__
|
|
|
|
#define __nsWifiAccessPoint__
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsWifiAccessPoint final : public nsIWifiAccessPoint
|
2009-03-17 03:30:58 +03:00
|
|
|
{
|
2014-06-24 20:36:44 +04:00
|
|
|
~nsWifiAccessPoint();
|
|
|
|
|
2009-03-17 03:30:58 +03:00
|
|
|
public:
|
2013-07-19 06:24:13 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2009-03-17 03:30:58 +03:00
|
|
|
NS_DECL_NSIWIFIACCESSPOINT
|
|
|
|
|
|
|
|
nsWifiAccessPoint();
|
|
|
|
|
|
|
|
char mMac[18];
|
|
|
|
int mSignal;
|
|
|
|
char mSsid[33];
|
|
|
|
int mSsidLen;
|
|
|
|
|
|
|
|
void setSignal(int signal)
|
|
|
|
{
|
|
|
|
mSignal = signal;
|
2012-07-10 20:55:08 +04:00
|
|
|
}
|
2009-03-17 03:30:58 +03:00
|
|
|
|
2012-10-10 05:40:11 +04:00
|
|
|
void setMacRaw(const char* aString)
|
|
|
|
{
|
|
|
|
memcpy(mMac, aString, mozilla::ArrayLength(mMac));
|
|
|
|
}
|
|
|
|
|
2009-09-17 00:08:15 +04:00
|
|
|
void setMac(const unsigned char mac_as_int[6])
|
2009-03-17 03:30:58 +03:00
|
|
|
{
|
|
|
|
// mac_as_int is big-endian. Write in byte chunks.
|
|
|
|
// Format is XX-XX-XX-XX-XX-XX.
|
|
|
|
|
2011-05-10 23:44:17 +04:00
|
|
|
const unsigned char holder[6] = {0};
|
|
|
|
if (!mac_as_int) {
|
|
|
|
mac_as_int = holder;
|
|
|
|
}
|
|
|
|
|
2009-03-17 03:30:58 +03:00
|
|
|
static const char *kMacFormatString = ("%02x-%02x-%02x-%02x-%02x-%02x");
|
2009-09-17 00:08:15 +04:00
|
|
|
|
2009-03-17 03:30:58 +03:00
|
|
|
sprintf(mMac, kMacFormatString,
|
|
|
|
mac_as_int[0], mac_as_int[1], mac_as_int[2],
|
|
|
|
mac_as_int[3], mac_as_int[4], mac_as_int[5]);
|
2009-09-17 00:08:15 +04:00
|
|
|
|
2009-03-17 03:30:58 +03:00
|
|
|
mMac[17] = 0;
|
2012-07-10 20:55:08 +04:00
|
|
|
}
|
2009-03-17 03:30:58 +03:00
|
|
|
|
2012-10-10 05:40:11 +04:00
|
|
|
void setSSIDRaw(const char* aSSID, unsigned long len) {
|
|
|
|
memcpy(mSsid, aSSID, mozilla::ArrayLength(mSsid));
|
|
|
|
mSsidLen = PR_MIN(len, mozilla::ArrayLength(mSsid));
|
|
|
|
}
|
|
|
|
|
2009-03-17 03:30:58 +03:00
|
|
|
void setSSID(const char* aSSID, unsigned long len) {
|
2011-05-10 23:44:17 +04:00
|
|
|
if (aSSID && (len < sizeof(mSsid))) {
|
2009-03-17 03:30:58 +03:00
|
|
|
strncpy(mSsid, aSSID, len);
|
|
|
|
mSsid[len] = 0;
|
|
|
|
mSsidLen = len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mSsid[0] = 0;
|
|
|
|
mSsidLen = 0;
|
|
|
|
}
|
2012-07-10 20:55:08 +04:00
|
|
|
}
|
2009-03-17 03:30:58 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Helper functions
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool AccessPointsEqual(nsCOMArray<nsWifiAccessPoint>& a, nsCOMArray<nsWifiAccessPoint>& b);
|
2009-03-17 03:30:58 +03:00
|
|
|
void ReplaceArray(nsCOMArray<nsWifiAccessPoint>& a, nsCOMArray<nsWifiAccessPoint>& b);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|