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 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 47 | string AttributeList::ToString() const { |
| 48 | string output; |
| 49 | map<int, AttributePointer>::const_iterator i; |
| 50 | |
| 51 | for (i = attributes_.begin(); i != attributes_.end(); ++i) { |
| 52 | string attribute_string; |
Wade Guthrie | 3af8b4d | 2013-01-10 08:39:30 -0800 | [diff] [blame] | 53 | if (i->second->has_a_value()) { |
| 54 | i->second->ToString(&attribute_string); |
| 55 | StringAppendF(&output, " Attr: %s(%d) Type: %s = %s\n", |
| 56 | i->second->id_string(), |
| 57 | i->second->id(), |
| 58 | i->second->datatype_string(), |
| 59 | attribute_string.c_str()); |
| 60 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 61 | } |
| 62 | return output; |
| 63 | } |
| 64 | |
repo sync | dc085c8 | 2012-12-28 08:54:41 -0800 | [diff] [blame] | 65 | ByteString AttributeList::Encode() const { |
| 66 | ByteString result; |
| 67 | map<int, AttributePointer>::const_iterator i; |
| 68 | |
| 69 | for (i = attributes_.begin(); i != attributes_.end(); ++i) { |
| 70 | result.Append(i->second->Encode()); |
| 71 | } |
| 72 | return result; |
| 73 | } |
| 74 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 75 | // U8 Attribute. |
| 76 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 77 | bool AttributeList::GetU8AttributeValue(int id, uint8_t *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 78 | Nl80211Attribute *attribute = GetAttribute(id); |
| 79 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 80 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 81 | return attribute->GetU8Value(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 82 | } |
| 83 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 84 | bool AttributeList::CreateU8Attribute(int id, const char *id_string) { |
| 85 | if (ContainsKey(attributes_, id)) { |
| 86 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 87 | return false; |
| 88 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 89 | attributes_[id] = AttributePointer( |
| 90 | new Nl80211U8Attribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 91 | return true; |
| 92 | } |
| 93 | |
| 94 | bool AttributeList::SetU8AttributeValue(int id, uint8_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->SetU8Value(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 102 | // U16 Attribute. |
| 103 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 104 | bool AttributeList::GetU16AttributeValue(int id, uint16_t *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 105 | Nl80211Attribute *attribute = GetAttribute(id); |
| 106 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 107 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 108 | return attribute->GetU16Value(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 109 | } |
| 110 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 111 | bool AttributeList::CreateU16Attribute(int id, const char *id_string) { |
| 112 | if (ContainsKey(attributes_, id)) { |
| 113 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 114 | return false; |
| 115 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 116 | attributes_[id] = AttributePointer( |
| 117 | new Nl80211U16Attribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 118 | return true; |
| 119 | } |
| 120 | |
| 121 | bool AttributeList::SetU16AttributeValue(int id, uint16_t value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 122 | Nl80211Attribute *attribute = GetAttribute(id); |
| 123 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 124 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 125 | return attribute->SetU16Value(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 126 | } |
| 127 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 128 | // U32 Attribute. |
| 129 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 130 | bool AttributeList::GetU32AttributeValue(int id, uint32_t *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 131 | Nl80211Attribute *attribute = GetAttribute(id); |
| 132 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 133 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 134 | return attribute->GetU32Value(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 135 | } |
| 136 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 137 | bool AttributeList::CreateU32Attribute(int id, const char *id_string) { |
| 138 | if (ContainsKey(attributes_, id)) { |
| 139 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 140 | return false; |
| 141 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 142 | attributes_[id] = AttributePointer( |
| 143 | new Nl80211U32Attribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 144 | return true; |
| 145 | } |
| 146 | |
| 147 | bool AttributeList::SetU32AttributeValue(int id, uint32_t value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 148 | Nl80211Attribute *attribute = GetAttribute(id); |
| 149 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 150 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 151 | return attribute->SetU32Value(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 152 | } |
| 153 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 154 | // U64 Attribute. |
| 155 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 156 | bool AttributeList::GetU64AttributeValue(int id, uint64_t *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 157 | Nl80211Attribute *attribute = GetAttribute(id); |
| 158 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 159 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 160 | return attribute->GetU64Value(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 161 | } |
| 162 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 163 | bool AttributeList::CreateU64Attribute(int id, const char *id_string) { |
| 164 | if (ContainsKey(attributes_, id)) { |
| 165 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 166 | return false; |
| 167 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 168 | attributes_[id] = AttributePointer( |
| 169 | new Nl80211U64Attribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 170 | return true; |
| 171 | } |
| 172 | |
| 173 | bool AttributeList::SetU64AttributeValue(int id, uint64_t value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 174 | Nl80211Attribute *attribute = GetAttribute(id); |
| 175 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 176 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 177 | return attribute->SetU64Value(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 178 | } |
| 179 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 180 | // Flag Attribute. |
| 181 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 182 | bool AttributeList::GetFlagAttributeValue(int id, bool *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 183 | Nl80211Attribute *attribute = GetAttribute(id); |
| 184 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 185 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 186 | return attribute->GetFlagValue(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 187 | } |
| 188 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 189 | bool AttributeList::CreateFlagAttribute(int id, const char *id_string) { |
| 190 | if (ContainsKey(attributes_, id)) { |
| 191 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 192 | return false; |
| 193 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 194 | attributes_[id] = AttributePointer( |
| 195 | new Nl80211FlagAttribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 196 | return true; |
| 197 | } |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 198 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 199 | bool AttributeList::SetFlagAttributeValue(int id, bool value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 200 | Nl80211Attribute *attribute = GetAttribute(id); |
| 201 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 202 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 203 | return attribute->SetFlagValue(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | bool AttributeList::IsFlagAttributeTrue(int id) const { |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 207 | bool flag; |
| 208 | if (!GetFlagAttributeValue(id, &flag)) { |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 209 | return false; |
| 210 | } |
| 211 | return flag; |
| 212 | } |
| 213 | |
| 214 | // String Attribute. |
| 215 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 216 | bool AttributeList::GetStringAttributeValue(int id, string *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 217 | Nl80211Attribute *attribute = GetAttribute(id); |
| 218 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 219 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 220 | return attribute->GetStringValue(value); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 221 | } |
| 222 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 223 | bool AttributeList::CreateStringAttribute(int id, const char *id_string) { |
| 224 | if (ContainsKey(attributes_, id)) { |
| 225 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 226 | return false; |
| 227 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 228 | attributes_[id] = AttributePointer( |
| 229 | new Nl80211StringAttribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 230 | return true; |
| 231 | } |
| 232 | |
| 233 | bool AttributeList::SetStringAttributeValue(int id, string 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->SetStringValue(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | // Nested Attribute. |
| 241 | |
| 242 | bool AttributeList::GetNestedAttributeValue( |
| 243 | int id, WeakPtr<AttributeList> *value) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 244 | Nl80211Attribute *attribute = GetAttribute(id); |
| 245 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 246 | return false; |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 247 | return attribute->GetNestedValue(value); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | bool AttributeList::CreateNestedAttribute(int id, const char *id_string) { |
| 251 | if (ContainsKey(attributes_, id)) { |
| 252 | LOG(ERROR) << "Trying to re-add attribute: " << id; |
| 253 | return false; |
| 254 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 255 | attributes_[id] = AttributePointer( |
| 256 | new Nl80211NestedAttribute(id, id_string)); |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 257 | return true; |
| 258 | } |
| 259 | |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 260 | // Raw Attribute. |
| 261 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 262 | bool AttributeList::GetRawAttributeValue(int id, |
| 263 | ByteString *output) const { |
| 264 | Nl80211Attribute *attribute = GetAttribute(id); |
| 265 | if (!attribute) |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 266 | return false; |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 267 | |
| 268 | ByteString raw_value; |
| 269 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 270 | if (!attribute->GetRawValue(&raw_value)) |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 271 | return false; |
| 272 | |
| 273 | if (output) { |
| 274 | const nlattr *const_data = |
| 275 | reinterpret_cast<const nlattr *>(raw_value.GetConstData()); |
| 276 | // nla_data and nla_len don't change their parameters but don't declare |
| 277 | // them to be const. Hence the cast. |
| 278 | nlattr *data_nlattr = const_cast<nlattr *>(const_data); |
| 279 | *output = ByteString( |
| 280 | reinterpret_cast<unsigned char *>(nla_data(data_nlattr)), |
| 281 | nla_len(data_nlattr)); |
| 282 | } |
| 283 | return true; |
| 284 | } |
| 285 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 286 | const Nl80211RawAttribute *AttributeList::GetRawAttribute( |
| 287 | int id) const { |
| 288 | if (!HasRawAttribute(id)) { |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 289 | LOG(ERROR) << "No attribute " << id << " of type kTypeRaw exists."; |
| 290 | return NULL; |
| 291 | } |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 292 | const Nl80211RawAttribute *attr = |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 293 | reinterpret_cast<const Nl80211RawAttribute *>(GetAttribute(id)); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 294 | return attr; |
| 295 | } |
| 296 | |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 297 | Nl80211Attribute *AttributeList::GetAttribute(int id) const { |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 298 | map<int, AttributePointer>::const_iterator i; |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 299 | i = attributes_.find(id); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 300 | if (i == attributes_.end()) { |
| 301 | return NULL; |
| 302 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 303 | return i->second.get(); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 304 | } |
| 305 | |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 306 | bool AttributeList::HasRawAttribute(int id) const { |
| 307 | map<int, AttributePointer>::const_iterator i; |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 308 | i = attributes_.find(id); |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 309 | if (i == attributes_.end()) { |
repo sync | 12cca80 | 2012-12-19 17:34:22 -0800 | [diff] [blame] | 310 | LOG(ERROR) << "FALSE - Didn't find id " << id; |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 311 | return false; |
| 312 | } |
repo sync | 1538d44 | 2012-12-20 15:24:35 -0800 | [diff] [blame] | 313 | return (i->second->datatype() == Nl80211Attribute::kTypeRaw) ? true : false; |
repo sync | 90ee0fa | 2012-12-18 10:08:08 -0800 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | |
| 317 | } // namespace shill |