1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef ANDROID_LOWPAN_IDENTITY_H 18#define ANDROID_LOWPAN_IDENTITY_H 19 20#include <binder/Parcelable.h> 21#include <utils/String16.h> 22#include <utils/StrongPointer.h> 23#include <string> 24 25namespace android { 26 27namespace net { 28 29namespace lowpan { 30 31/* 32 * C++ implementation of the Java class android.net.lowpan.LowpanIdentity 33 */ 34class LowpanIdentity : public Parcelable { 35public: 36 class Builder; 37 static const int32_t UNSPECIFIED_PANID = 0xFFFFFFFF; 38 static const int32_t UNSPECIFIED_CHANNEL = -1; 39 40 LowpanIdentity(); 41 virtual ~LowpanIdentity() = default; 42 LowpanIdentity(const LowpanIdentity& x) = default; 43 44 bool operator==(const LowpanIdentity& rhs); 45 bool operator!=(const LowpanIdentity& rhs) { return !(*this == rhs); } 46 47 bool getName(std::string* value) const; 48 bool getType(std::string* value) const; 49 bool getXpanid(std::vector<uint8_t>* value) const; 50 int32_t getPanid(void) const; 51 int32_t getChannel(void) const; 52 53public: 54 // Overrides 55 status_t writeToParcel(Parcel* parcel) const override; 56 status_t readFromParcel(const Parcel* parcel) override; 57 58private: 59 // Data 60 std::string mName; 61 std::string mType; 62 std::vector<uint8_t> mXpanid; 63 int32_t mPanid; 64 int32_t mChannel; 65}; 66 67class LowpanIdentity::Builder { 68public: 69 Builder(); 70 Builder& setName(const std::string& value); 71 Builder& setType(const std::string& value); 72 Builder& setType(const ::android::String16& value); 73 Builder& setXpanid(const std::vector<uint8_t>& value); 74 Builder& setXpanid(const uint8_t* valuePtr, int32_t valueLen); 75 Builder& setPanid(int32_t value); 76 Builder& setChannel(int32_t value); 77 Builder& setLowpanIdentity(const LowpanIdentity& value); 78 79 LowpanIdentity build(void) const; 80private: 81 LowpanIdentity mIdentity; 82}; 83 84} // namespace lowpan 85 86} // namespace net 87 88} // namespace android 89 90#endif // ANDROID_LOWPAN_IDENTITY_H 91