1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef __nsWifiAccessPoint__
6 #define __nsWifiAccessPoint__
9 #include "nsWifiMonitor.h"
10 #include "nsIWifiAccessPoint.h"
13 #include "nsCOMArray.h"
14 #include "mozilla/ArrayUtils.h" // ArrayLength
15 #include "mozilla/Attributes.h"
16 #include "mozilla/Sprintf.h"
18 class nsWifiAccessPoint final
: public nsIWifiAccessPoint
{
19 ~nsWifiAccessPoint() = default;
22 NS_DECL_THREADSAFE_ISUPPORTS
23 NS_DECL_NSIWIFIACCESSPOINT
32 void setSignal(int signal
) { mSignal
= signal
; }
34 void setMacRaw(const char* aString
) {
35 memcpy(mMac
, aString
, mozilla::ArrayLength(mMac
));
38 void setMac(const unsigned char mac_as_int
[6]) {
39 // mac_as_int is big-endian. Write in byte chunks.
40 // Format is XX-XX-XX-XX-XX-XX.
42 const unsigned char holder
[6] = {0};
47 static const char* kMacFormatString
= ("%02x-%02x-%02x-%02x-%02x-%02x");
49 SprintfLiteral(mMac
, kMacFormatString
, mac_as_int
[0], mac_as_int
[1],
50 mac_as_int
[2], mac_as_int
[3], mac_as_int
[4], mac_as_int
[5]);
55 void setSSIDRaw(const char* aSSID
, size_t len
) {
56 mSsidLen
= std::min(len
, mozilla::ArrayLength(mSsid
));
57 memcpy(mSsid
, aSSID
, mSsidLen
);
60 void setSSID(const char* aSSID
, unsigned long len
) {
61 if (aSSID
&& (len
< sizeof(mSsid
))) {
62 strncpy(mSsid
, aSSID
, len
);
74 bool AccessPointsEqual(nsCOMArray
<nsWifiAccessPoint
>& a
,
75 nsCOMArray
<nsWifiAccessPoint
>& b
);
76 void ReplaceArray(nsCOMArray
<nsWifiAccessPoint
>& a
,
77 nsCOMArray
<nsWifiAccessPoint
>& b
);