model/netlink-attribute.h
changeset 66 2fe1f3e576c9
parent 65 227f6347e4e1
child 67 fb900a594421
     1.1 --- a/model/netlink-attribute.h	Tue Apr 19 23:13:50 2011 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,124 +0,0 @@
     1.4 -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     1.5 -/*
     1.6 - * Copyright (c) 2008 Liu Jian
     1.7 - *
     1.8 - * This program is free software; you can redistribute it and/or modify
     1.9 - * it under the terms of the GNU General Public License version 2 as
    1.10 - * published by the Free Software Foundation;
    1.11 - *
    1.12 - * This program is distributed in the hope that it will be useful,
    1.13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 - * GNU General Public License for more details.
    1.16 - *
    1.17 - * You should have received a copy of the GNU General Public License
    1.18 - * along with this program; if not, write to the Free Software
    1.19 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.20 - *
    1.21 - * Author: Liu Jian <liujatp@gmail.com>
    1.22 - *         Hajime Tazaki <tazaki@sfc.wide.ad.jp>
    1.23 - */
    1.24 -
    1.25 -#ifndef NETLINK_ATTRIBUTE_H
    1.26 -#define NETLINK_ATTRIBUTE_H
    1.27 -
    1.28 -
    1.29 -#include <stdint.h>
    1.30 -#include <string>
    1.31 -#include <ostream>
    1.32 -#include "ns3/address.h"
    1.33 -#include "ns3/buffer.h"
    1.34 -
    1.35 -namespace ns3 {
    1.36 -
    1.37 -/**
    1.38 -* \brief The Netlink Attribute
    1.39 -*/
    1.40 -
    1.41 -typedef enum NetlinkAttributeValueType_e {
    1.42 -  UNSPEC, // invalid initial value.
    1.43 -  U8,
    1.44 -  U16,
    1.45 -  U32,
    1.46 -  U64,
    1.47 -  STRING,
    1.48 -  ADDRESS,
    1.49 -}NetlinkAttributeValueType;
    1.50 -
    1.51 -class NetlinkAttributeValue
    1.52 -{
    1.53 -public:
    1.54 -  NetlinkAttributeValue ();
    1.55 -  NetlinkAttributeValue (NetlinkAttributeValueType type, uint8_t v);
    1.56 -  NetlinkAttributeValue (NetlinkAttributeValueType type, uint16_t v);
    1.57 -  NetlinkAttributeValue (NetlinkAttributeValueType type, uint32_t v);
    1.58 -  NetlinkAttributeValue (NetlinkAttributeValueType type, uint64_t v);
    1.59 -  NetlinkAttributeValue (NetlinkAttributeValueType type, std::string v);
    1.60 -  NetlinkAttributeValue (NetlinkAttributeValueType type, Address v);
    1.61 -  
    1.62 -  void Serialize (Buffer::Iterator& start) const;
    1.63 -  uint32_t DeserializeWithType (Buffer::Iterator& start, NetlinkAttributeValueType type, uint16_t remaining);
    1.64 -  uint32_t GetSerializedSize (void) const;
    1.65 -  uint32_t GetSize (void) const;
    1.66 -  void Print (std::ostream &os) const;
    1.67 -
    1.68 -  void SetType (NetlinkAttributeValueType type);
    1.69 -  NetlinkAttributeValueType GetType (void) const;
    1.70 -  void SetAddress (Address value);
    1.71 -  void SetString (std::string value);
    1.72 -  void SetU64 (uint64_t value);
    1.73 -  void SetU32 (uint32_t value);
    1.74 -  void SetU16 (uint16_t value);
    1.75 -  void SetU8 (uint8_t value);
    1.76 -  Address GetAddress (void) const;
    1.77 -  std::string GetString (void) const;
    1.78 -  uint64_t GetU64 (void) const;
    1.79 -  uint32_t GetU32 (void) const;
    1.80 -  uint16_t GetU16 (void) const;
    1.81 -  uint8_t GetU8 (void) const;
    1.82 -
    1.83 -private:
    1.84 -  NetlinkAttributeValueType m_type;
    1.85 -  uint64_t m_u64;
    1.86 -  uint32_t m_u32;
    1.87 -  uint16_t m_u16;
    1.88 -  uint8_t m_u8;
    1.89 -  std::string m_string;
    1.90 -  Address m_address;
    1.91 -};
    1.92 -
    1.93 -struct NetlinkAttribute
    1.94 -{
    1.95 -public:
    1.96 -  NetlinkAttribute ();
    1.97 -  NetlinkAttribute (uint16_t type, NetlinkAttributeValueType payloadtype,  uint8_t payload);
    1.98 -  NetlinkAttribute (uint16_t type, NetlinkAttributeValueType payloadtype,  uint16_t payload);
    1.99 -  NetlinkAttribute (uint16_t type, NetlinkAttributeValueType payloadtype,  uint32_t payload);
   1.100 -  NetlinkAttribute (uint16_t type, NetlinkAttributeValueType payloadtype,  uint64_t payload);
   1.101 -  NetlinkAttribute (uint16_t type, NetlinkAttributeValueType payloadtype,  std::string payload);
   1.102 -  NetlinkAttribute (uint16_t type, NetlinkAttributeValueType payloadtype,  Address payload);
   1.103 -
   1.104 -  //static TypeId GetTypeId (void);
   1.105 -  //virtual TypeId GetInstanceTypeId (void) const;
   1.106 -  void Print (std::ostream &os) const;
   1.107 -  uint32_t GetSerializedSize (void) const;
   1.108 -  void Serialize (Buffer::Iterator& start) const;
   1.109 -  uint32_t Deserialize (Buffer::Iterator& start, NetlinkAttributeValueType vtypes[]);
   1.110 -
   1.111 -  void SetAttrLen (uint16_t v);
   1.112 -  void SetAttrType (uint16_t v);
   1.113 -  void SetAttrPayload (NetlinkAttributeValue v);
   1.114 -  uint16_t GetAttrLen () const;
   1.115 -  uint16_t GetAttrType () const;
   1.116 -  NetlinkAttributeValue GetAttrPayload () const;
   1.117 -
   1.118 -private:
   1.119 -  static const int NETLINK_MSG_ATTR_SIZE = 4; /* size of the nlattr field*/
   1.120 -  uint16_t m_len;
   1.121 -  uint16_t m_type; 
   1.122 -  NetlinkAttributeValue m_payload;
   1.123 -};
   1.124 -
   1.125 -}; // namespace ns3
   1.126 -
   1.127 -#endif /* NETLINK_ATTRIBUTE_H */