00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2006 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #include "capability-information.h" 00021 00022 namespace ns3 { 00023 00024 CapabilityInformation::CapabilityInformation () 00025 : m_capability (0) 00026 {} 00027 00028 void 00029 CapabilityInformation::SetEss (void) 00030 { 00031 Set (0); 00032 Clear (1); 00033 } 00034 void 00035 CapabilityInformation::SetIbss (void) 00036 { 00037 Clear (0); 00038 Set (1); 00039 } 00040 00041 bool 00042 CapabilityInformation::IsEss (void) const 00043 { 00044 return Is (0); 00045 } 00046 bool 00047 CapabilityInformation::IsIbss (void) const 00048 { 00049 return Is (1); 00050 } 00051 00052 void 00053 CapabilityInformation::Set (uint8_t n) 00054 { 00055 uint32_t mask = 1<<n; 00056 m_capability |= mask; 00057 } 00058 00059 void 00060 CapabilityInformation::Clear (uint8_t n) 00061 { 00062 uint32_t mask = 1<<n; 00063 m_capability &= ~mask; 00064 } 00065 00066 bool 00067 CapabilityInformation::Is (uint8_t n) const 00068 { 00069 uint32_t mask = 1<<n; 00070 return (m_capability & mask) == mask; 00071 } 00072 00073 00074 uint32_t 00075 CapabilityInformation::GetSerializedSize (void) const 00076 { 00077 return 2; 00078 } 00079 Buffer::Iterator 00080 CapabilityInformation::Serialize (Buffer::Iterator start) const 00081 { 00082 start.WriteHtonU16 (m_capability); 00083 return start; 00084 } 00085 Buffer::Iterator 00086 CapabilityInformation::Deserialize (Buffer::Iterator start) 00087 { 00088 m_capability = start.ReadNtohU16 (); 00089 return start; 00090 } 00091 00092 00093 } // namespace ns3