Home | History | Annotate | Download | only in net
      1 //
      2 // Copyright (C) 2013 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 #include "shill/net/control_netlink_attribute.h"
     18 
     19 #include <linux/genetlink.h>
     20 
     21 #include <utility>
     22 
     23 #include <base/logging.h>
     24 
     25 namespace shill {
     26 
     27 const int ControlAttributeFamilyId::kName = CTRL_ATTR_FAMILY_ID;
     28 const char ControlAttributeFamilyId::kNameString[] = "CTRL_ATTR_FAMILY_ID";
     29 
     30 const int ControlAttributeFamilyName::kName = CTRL_ATTR_FAMILY_NAME;
     31 const char ControlAttributeFamilyName::kNameString[] = "CTRL_ATTR_FAMILY_NAME";
     32 
     33 const int ControlAttributeVersion::kName = CTRL_ATTR_VERSION;
     34 const char ControlAttributeVersion::kNameString[] = "CTRL_ATTR_VERSION";
     35 
     36 const int ControlAttributeHdrSize::kName = CTRL_ATTR_HDRSIZE;
     37 const char ControlAttributeHdrSize::kNameString[] = "CTRL_ATTR_HDRSIZE";
     38 
     39 const int ControlAttributeMaxAttr::kName = CTRL_ATTR_MAXATTR;
     40 const char ControlAttributeMaxAttr::kNameString[] = "CTRL_ATTR_MAXATTR";
     41 
     42 const int ControlAttributeAttrOps::kName = CTRL_ATTR_OPS;
     43 const char ControlAttributeAttrOps::kNameString[] = "CTRL_ATTR_OPS";
     44 
     45 ControlAttributeAttrOps::ControlAttributeAttrOps()
     46     : NetlinkNestedAttribute(kName, kNameString) {
     47   NestedData array(kTypeNested, "FIRST", true);
     48   array.deeper_nesting.insert(AttrDataPair(
     49       CTRL_ATTR_OP_UNSPEC, NestedData(kTypeU32, "CTRL_ATTR_OP_UNSPEC", false)));
     50   array.deeper_nesting.insert(AttrDataPair(
     51       CTRL_ATTR_OP_ID, NestedData(kTypeU32, "CTRL_ATTR_OP_ID", false)));
     52   array.deeper_nesting.insert(AttrDataPair(
     53       CTRL_ATTR_OP_UNSPEC, NestedData(kTypeU32, "CTRL_ATTR_OP_UNSPEC", false)));
     54 
     55   nested_template_.insert(AttrDataPair(kArrayAttrEnumVal, array));
     56 }
     57 
     58 const int ControlAttributeMcastGroups::kName = CTRL_ATTR_MCAST_GROUPS;
     59 const char ControlAttributeMcastGroups::kNameString[] =
     60     "CTRL_ATTR_MCAST_GROUPS";
     61 
     62 ControlAttributeMcastGroups::ControlAttributeMcastGroups()
     63     : NetlinkNestedAttribute(kName, kNameString) {
     64   NestedData array(kTypeNested, "FIRST", true);
     65   array.deeper_nesting.insert(
     66       AttrDataPair(CTRL_ATTR_MCAST_GRP_UNSPEC,
     67                    NestedData(kTypeU32, "CTRL_ATTR_MCAST_GRP_UNSPEC", false)));
     68   array.deeper_nesting.insert(
     69       AttrDataPair(CTRL_ATTR_MCAST_GRP_NAME,
     70                    NestedData(kTypeString, "CTRL_ATTR_MCAST_GRP_NAME", false)));
     71   array.deeper_nesting.insert(
     72       AttrDataPair(CTRL_ATTR_MCAST_GRP_ID,
     73                    NestedData(kTypeU32, "CTRL_ATTR_MCAST_GRP_ID", false)));
     74 
     75   nested_template_.insert(AttrDataPair(kArrayAttrEnumVal, array));
     76 }
     77 
     78 }  // namespace shill
     79