repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/attribute_list.h" |
| 6 | |
| 7 | #include <ctype.h> |
| 8 | #include <linux/nl80211.h> |
| 9 | #include <netlink/attr.h> |
| 10 | #include <netlink/netlink.h> |
| 11 | |
| 12 | #include <iomanip> |
| 13 | #include <map> |
| 14 | #include <string> |
| 15 | |
| 16 | #include <base/stl_util.h> |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 17 | #include <base/stringprintf.h> |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 18 | |
| 19 | #include "shill/logging.h" |
| 20 | #include "shill/nl80211_attribute.h" |
| 21 | #include "shill/scope_logger.h" |
| 22 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 23 | using base::StringAppendF; |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 24 | using base::WeakPtr; |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 25 | using std::map; |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 26 | using std::string; |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 27 | |
| 28 | namespace shill { |
| 29 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 30 | bool AttributeList::CreateAttribute(nl80211_attrs id) { |
| 31 | if (ContainsKey(attributes_, id)) { |
| 32 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 33 | return false; |
| 34 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 35 | attributes_[id] = AttributePointer(Nl80211Attribute::NewFromName(id)); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 36 | return true; |
| 37 | } |
| 38 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 39 | bool AttributeList::CreateAndInitFromNlAttr(nl80211_attrs id, |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 40 | const nlattr *data) { |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 41 | if (!CreateAttribute(id)) { |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 42 | return false; |
| 43 | } |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 44 | return attributes_[id]->InitFromNlAttr(data); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 45 | } |
| 46 | |
Wade Guthrie | 8e27861 | 2013-02-26 10:32:34 -0800 | [diff] [blame^] | 47 | void AttributeList::Print(int log_level, int indent) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 48 | map<int, AttributePointer>::const_iterator i; |
| 49 | |
| 50 | for (i = attributes_.begin(); i != attributes_.end(); ++i) { |
Wade Guthrie | 8e27861 | 2013-02-26 10:32:34 -0800 | [diff] [blame^] | 51 | i->second->Print(log_level, indent); |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 52 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 53 | } |
| 54 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 55 | ByteString AttributeList::Encode() const { |
| 56 | ByteString result; |
| 57 | map<int, AttributePointer>::const_iterator i; |
| 58 | |
| 59 | for (i = attributes_.begin(); i != attributes_.end(); ++i) { |
| 60 | result.Append(i->second->Encode()); |
| 61 | } |
| 62 | return result; |
| 63 | } |
| 64 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 65 | // U8 Attribute. |
| 66 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 67 | bool AttributeList::GetU8AttributeValue(int id, uint8_t *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 68 | Nl80211Attribute *attribute = GetAttribute(id); |
| 69 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 70 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 71 | return attribute->GetU8Value(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 72 | } |
| 73 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 74 | bool AttributeList::CreateU8Attribute(int id, const char *id_string) { |
| 75 | if (ContainsKey(attributes_, id)) { |
| 76 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 77 | return false; |
| 78 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 79 | attributes_[id] = AttributePointer( |
| 80 | new Nl80211U8Attribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 81 | return true; |
| 82 | } |
| 83 | |
| 84 | bool AttributeList::SetU8AttributeValue(int id, uint8_t value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 85 | Nl80211Attribute *attribute = GetAttribute(id); |
| 86 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 87 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 88 | return attribute->SetU8Value(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 92 | // U16 Attribute. |
| 93 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 94 | bool AttributeList::GetU16AttributeValue(int id, uint16_t *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 95 | Nl80211Attribute *attribute = GetAttribute(id); |
| 96 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 97 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 98 | return attribute->GetU16Value(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 99 | } |
| 100 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 101 | bool AttributeList::CreateU16Attribute(int id, const char *id_string) { |
| 102 | if (ContainsKey(attributes_, id)) { |
| 103 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 104 | return false; |
| 105 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 106 | attributes_[id] = AttributePointer( |
| 107 | new Nl80211U16Attribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 108 | return true; |
| 109 | } |
| 110 | |
| 111 | bool AttributeList::SetU16AttributeValue(int id, uint16_t value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 112 | Nl80211Attribute *attribute = GetAttribute(id); |
| 113 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 114 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 115 | return attribute->SetU16Value(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 116 | } |
| 117 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 118 | // U32 Attribute. |
| 119 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 120 | bool AttributeList::GetU32AttributeValue(int id, uint32_t *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 121 | Nl80211Attribute *attribute = GetAttribute(id); |
| 122 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 123 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 124 | return attribute->GetU32Value(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 125 | } |
| 126 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 127 | bool AttributeList::CreateU32Attribute(int id, const char *id_string) { |
| 128 | if (ContainsKey(attributes_, id)) { |
| 129 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 130 | return false; |
| 131 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 132 | attributes_[id] = AttributePointer( |
| 133 | new Nl80211U32Attribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 134 | return true; |
| 135 | } |
| 136 | |
| 137 | bool AttributeList::SetU32AttributeValue(int id, uint32_t value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 138 | Nl80211Attribute *attribute = GetAttribute(id); |
| 139 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 140 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 141 | return attribute->SetU32Value(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 142 | } |
| 143 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 144 | // U64 Attribute. |
| 145 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 146 | bool AttributeList::GetU64AttributeValue(int id, uint64_t *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 147 | Nl80211Attribute *attribute = GetAttribute(id); |
| 148 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 149 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 150 | return attribute->GetU64Value(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 151 | } |
| 152 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 153 | bool AttributeList::CreateU64Attribute(int id, const char *id_string) { |
| 154 | if (ContainsKey(attributes_, id)) { |
| 155 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 156 | return false; |
| 157 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 158 | attributes_[id] = AttributePointer( |
| 159 | new Nl80211U64Attribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 160 | return true; |
| 161 | } |
| 162 | |
| 163 | bool AttributeList::SetU64AttributeValue(int id, uint64_t value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 164 | Nl80211Attribute *attribute = GetAttribute(id); |
| 165 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 166 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 167 | return attribute->SetU64Value(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 168 | } |
| 169 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 170 | // Flag Attribute. |
| 171 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 172 | bool AttributeList::GetFlagAttributeValue(int id, bool *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 173 | Nl80211Attribute *attribute = GetAttribute(id); |
| 174 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 175 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 176 | return attribute->GetFlagValue(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 177 | } |
| 178 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 179 | bool AttributeList::CreateFlagAttribute(int id, const char *id_string) { |
| 180 | if (ContainsKey(attributes_, id)) { |
| 181 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 182 | return false; |
| 183 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 184 | attributes_[id] = AttributePointer( |
| 185 | new Nl80211FlagAttribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 186 | return true; |
| 187 | } |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 188 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 189 | bool AttributeList::SetFlagAttributeValue(int id, bool value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 190 | Nl80211Attribute *attribute = GetAttribute(id); |
| 191 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 192 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 193 | return attribute->SetFlagValue(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | bool AttributeList::IsFlagAttributeTrue(int id) const { |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 197 | bool flag; |
| 198 | if (!GetFlagAttributeValue(id, &flag)) { |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 199 | return false; |
| 200 | } |
| 201 | return flag; |
| 202 | } |
| 203 | |
| 204 | // String Attribute. |
| 205 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 206 | bool AttributeList::GetStringAttributeValue(int id, string *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 207 | Nl80211Attribute *attribute = GetAttribute(id); |
| 208 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 209 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 210 | return attribute->GetStringValue(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 211 | } |
| 212 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 213 | bool AttributeList::CreateStringAttribute(int id, const char *id_string) { |
| 214 | if (ContainsKey(attributes_, id)) { |
| 215 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 216 | return false; |
| 217 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 218 | attributes_[id] = AttributePointer( |
| 219 | new Nl80211StringAttribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 220 | return true; |
| 221 | } |
| 222 | |
| 223 | bool AttributeList::SetStringAttributeValue(int id, string value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 224 | Nl80211Attribute *attribute = GetAttribute(id); |
| 225 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 226 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 227 | return attribute->SetStringValue(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | // Nested Attribute. |
| 231 | |
| 232 | bool AttributeList::GetNestedAttributeValue( |
| 233 | int id, WeakPtr<AttributeList> *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 234 | Nl80211Attribute *attribute = GetAttribute(id); |
| 235 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 236 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 237 | return attribute->GetNestedValue(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | bool AttributeList::CreateNestedAttribute(int id, const char *id_string) { |
| 241 | if (ContainsKey(attributes_, id)) { |
| 242 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 243 | return false; |
| 244 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 245 | attributes_[id] = AttributePointer( |
| 246 | new Nl80211NestedAttribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 247 | return true; |
| 248 | } |
| 249 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 250 | // Raw Attribute. |
| 251 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 252 | bool AttributeList::GetRawAttributeValue(int id, |
| 253 | ByteString *output) const { |
| 254 | Nl80211Attribute *attribute = GetAttribute(id); |
| 255 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 256 | return false; |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 257 | |
| 258 | ByteString raw_value; |
| 259 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 260 | if (!attribute->GetRawValue(&raw_value)) |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 261 | return false; |
| 262 | |
| 263 | if (output) { |
| 264 | const nlattr *const_data = |
| 265 | reinterpret_cast<const nlattr *>(raw_value.GetConstData()); |
| 266 | // nla_data and nla_len don't change their parameters but don't declare |
| 267 | // them to be const. Hence the cast. |
| 268 | nlattr *data_nlattr = const_cast<nlattr *>(const_data); |
| 269 | *output = ByteString( |
| 270 | reinterpret_cast<unsigned char *>(nla_data(data_nlattr)), |
| 271 | nla_len(data_nlattr)); |
| 272 | } |
| 273 | return true; |
| 274 | } |
| 275 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 276 | const Nl80211RawAttribute *AttributeList::GetRawAttribute( |
| 277 | int id) const { |
| 278 | if (!HasRawAttribute(id)) { |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 279 | LOG(ERROR) << "No attribute " << id << " of type kTypeRaw exists."; |
| 280 | return NULL; |
| 281 | } |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 282 | const Nl80211RawAttribute *attr = |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 283 | reinterpret_cast<const Nl80211RawAttribute *>(GetAttribute(id)); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 284 | return attr; |
| 285 | } |
| 286 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 287 | Nl80211Attribute *AttributeList::GetAttribute(int id) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 288 | map<int, AttributePointer>::const_iterator i; |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 289 | i = attributes_.find(id); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 290 | if (i == attributes_.end()) { |
| 291 | return NULL; |
| 292 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 293 | return i->second.get(); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 294 | } |
| 295 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 296 | bool AttributeList::HasRawAttribute(int id) const { |
| 297 | map<int, AttributePointer>::const_iterator i; |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 298 | i = attributes_.find(id); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 299 | if (i == attributes_.end()) { |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 300 | LOG(ERROR) << "FALSE - Didn't find id " << id; |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 301 | return false; |
| 302 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 303 | return (i->second->datatype() == Nl80211Attribute::kTypeRaw) ? true : false; |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | |
| 307 | } // namespace shill |