netwerk/wifi/nsWifiAccessPoint.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/wifi/nsWifiAccessPoint.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "nsWifiMonitor.h"
     1.9 +#include "nsIWifiAccessPoint.h"
    1.10 +
    1.11 +#include "nsString.h"
    1.12 +#include "nsCOMArray.h"
    1.13 +#include "mozilla/ArrayUtils.h" // ArrayLength
    1.14 +#include "mozilla/Attributes.h"
    1.15 +
    1.16 +#ifndef __nsWifiAccessPoint__
    1.17 +#define __nsWifiAccessPoint__
    1.18 +
    1.19 +class nsWifiAccessPoint MOZ_FINAL : public nsIWifiAccessPoint
    1.20 +{
    1.21 +public:
    1.22 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.23 +  NS_DECL_NSIWIFIACCESSPOINT
    1.24 +
    1.25 +  nsWifiAccessPoint();
    1.26 +  ~nsWifiAccessPoint();
    1.27 +
    1.28 +  char mMac[18];
    1.29 +  int  mSignal;
    1.30 +  char mSsid[33];
    1.31 +  int  mSsidLen;
    1.32 +
    1.33 +  void setSignal(int signal)
    1.34 +  {
    1.35 +    mSignal = signal;
    1.36 +  }
    1.37 +
    1.38 +  void setMacRaw(const char* aString)
    1.39 +  {
    1.40 +    memcpy(mMac, aString, mozilla::ArrayLength(mMac));
    1.41 +  }
    1.42 +
    1.43 +  void setMac(const unsigned char mac_as_int[6])
    1.44 +  {
    1.45 +    // mac_as_int is big-endian. Write in byte chunks.
    1.46 +    // Format is XX-XX-XX-XX-XX-XX.
    1.47 +
    1.48 +    const unsigned char holder[6] = {0};
    1.49 +    if (!mac_as_int) {
    1.50 +      mac_as_int = holder;
    1.51 +    }
    1.52 +
    1.53 +    static const char *kMacFormatString = ("%02x-%02x-%02x-%02x-%02x-%02x");
    1.54 +
    1.55 +    sprintf(mMac, kMacFormatString,
    1.56 +            mac_as_int[0], mac_as_int[1], mac_as_int[2],
    1.57 +            mac_as_int[3], mac_as_int[4], mac_as_int[5]);
    1.58 +
    1.59 +    mMac[17] = 0;
    1.60 +  }
    1.61 +
    1.62 +  void setSSIDRaw(const char* aSSID, unsigned long len) {
    1.63 +    memcpy(mSsid, aSSID, mozilla::ArrayLength(mSsid));
    1.64 +    mSsidLen = PR_MIN(len, mozilla::ArrayLength(mSsid));
    1.65 +  }
    1.66 +
    1.67 +  void setSSID(const char* aSSID, unsigned long len) {
    1.68 +    if (aSSID && (len < sizeof(mSsid))) {
    1.69 +        strncpy(mSsid, aSSID, len);
    1.70 +        mSsid[len] = 0;
    1.71 +        mSsidLen = len;
    1.72 +    }
    1.73 +    else
    1.74 +    {
    1.75 +      mSsid[0] = 0;
    1.76 +      mSsidLen = 0;
    1.77 +    }
    1.78 +  }
    1.79 +};
    1.80 +
    1.81 +
    1.82 +
    1.83 +// Helper functions
    1.84 +
    1.85 +bool AccessPointsEqual(nsCOMArray<nsWifiAccessPoint>& a, nsCOMArray<nsWifiAccessPoint>& b);
    1.86 +void ReplaceArray(nsCOMArray<nsWifiAccessPoint>& a, nsCOMArray<nsWifiAccessPoint>& b);
    1.87 +
    1.88 +
    1.89 +#endif

mercurial