src/devices/wifi/status-code.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 29 Oct 2007 16:34:26 +0100
changeset 2051 83f33d9b66cb
parent 2013 4a5335c67eac
child 2077 8ff95ff1ed2e
permissions -rw-r--r--
port to new Channel API.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1937
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
/*
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
 * Copyright (c) 2006 INRIA
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
 *
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as 
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
 *
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
 * GNU General Public License for more details.
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
 *
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
 *
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
 */
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
#include "status-code.h"
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
namespace ns3 {
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
StatusCode::StatusCode ()
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
{}
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    27
void 
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    28
StatusCode::SetSuccess (void)
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
{
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
  m_code = 0;
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
}
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
void 
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
StatusCode::SetFailure (void)
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
{
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
  m_code = 1;
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
}
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
bool 
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
StatusCode::IsSuccess (void) const
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
{
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
  return (m_code == 0)?true:false;
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
}
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
uint32_t 
1939
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    44
StatusCode::GetSerializedSize (void) const
1937
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
{
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
  return 2;
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
}
1939
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    48
Buffer::Iterator 
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    49
StatusCode::Serialize (Buffer::Iterator start) const
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    50
{
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    51
  start.WriteHtonU16 (m_code);
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    52
  return start;
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    53
}
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    54
Buffer::Iterator 
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    55
StatusCode::Deserialize (Buffer::Iterator start)
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    56
{
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    57
  m_code = start.ReadNtohU16 ();
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    58
  return start;
40af0232df83 add management frame implementations
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1937
diff changeset
    59
}
1937
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
2013
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    61
std::ostream &
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    62
operator << (std::ostream &os, const StatusCode &code)
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    63
{
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    64
  if (code.IsSuccess ())
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    65
    {
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    66
      os << "success";
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    67
    }
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    68
  else
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    69
    {
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    70
      os << "failure";
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    71
    }
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    72
  return os;
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    73
}
4a5335c67eac add printing support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1939
diff changeset
    74
1937
996383a87ae3 add new code to build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
} // namespace ns3