remove extra code
This commit is contained in:
1 parent
554cb205f4
commit
b77c4b2bdd
21 files changed
-1792
No files matched your search
-18
@@ -530,32 +530,21 @@ common.add_deps (['core', 'simulator'])
|
||||
ns3.add (common)
|
||||
common.add_sources ([
|
||||
'buffer.cc',
|
||||
'mac-address-factory.cc',
|
||||
'chunk.cc',
|
||||
'mac-network-interface.cc',
|
||||
'chunk-constant-data.cc',
|
||||
'packet.cc',
|
||||
'tags.cc',
|
||||
'chunk-llc-snap.cc',
|
||||
'packet-logger.cc',
|
||||
'chunk-utils.cc',
|
||||
'pcap-writer.cc',
|
||||
'trace-container.cc',
|
||||
'traced-variable-test.cc',
|
||||
'ipv4-address.cc',
|
||||
'trace-stream-test.cc',
|
||||
'ipv4-network-interface.cc',
|
||||
'utils.cc',
|
||||
'llc-snap-encapsulation.cc',
|
||||
'mac-address.cc'
|
||||
])
|
||||
common.add_inst_headers ([
|
||||
'ipv4-address.h',
|
||||
'buffer.h',
|
||||
'chunk.h',
|
||||
'tags.h',
|
||||
'packet.h',
|
||||
'ipv4-network-interface.h',
|
||||
'count-ptr-holder.tcc',
|
||||
'ui-traced-variable.tcc',
|
||||
'si-traced-variable.tcc',
|
||||
@@ -564,17 +553,10 @@ common.add_inst_headers ([
|
||||
'trace-container.h',
|
||||
'packet-logger.h',
|
||||
'chunk-constant-data.h',
|
||||
'mac-address.h',
|
||||
'chunk-utils.h',
|
||||
'llc-snap-encapsulation.h',
|
||||
'mac-network-interface.h',
|
||||
'trace-stream.h',
|
||||
'pcap-writer.h',
|
||||
'mac-address-factory.h',
|
||||
'utils.h'
|
||||
])
|
||||
common.add_headers ([
|
||||
'chunk-llc-snap.h',
|
||||
'ref-ptr.h',
|
||||
])
|
||||
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "chunk-llc-snap.h"
|
||||
#include <cassert>
|
||||
|
||||
#define noTRACE_CHUNK_LLC_SNAP 1
|
||||
|
||||
#ifdef TRACE_CHUNK_LLC_SNAP
|
||||
#include <iostream>
|
||||
#include "simulator.h"
|
||||
# define TRACE(x) \
|
||||
std::cout << "CHUNK LLCSNAP TRACE " << Simulator::now_s () << " " << x << std::endl;
|
||||
#else /* TRACE_CHUNK_LLC_SNAP */
|
||||
# define TRACE(format,...)
|
||||
#endif /* TRACE_CHUNK_LLC_SNAP */
|
||||
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
ChunkLlcSnap::ChunkLlcSnap ()
|
||||
{}
|
||||
|
||||
ChunkLlcSnap::~ChunkLlcSnap ()
|
||||
{}
|
||||
void
|
||||
ChunkLlcSnap::set_type (enum Type type)
|
||||
{
|
||||
m_ether_type = type;
|
||||
}
|
||||
enum ChunkLlcSnap::Type
|
||||
ChunkLlcSnap::get_type (void)
|
||||
{
|
||||
return (enum ChunkLlcSnap::Type) m_ether_type;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ChunkLlcSnap::get_size (void) const
|
||||
{
|
||||
return 1 + 1 + 1 + 3 + 2;
|
||||
}
|
||||
void
|
||||
ChunkLlcSnap::print (std::ostream *os) const
|
||||
{
|
||||
*os << "(mac)"
|
||||
<< " EtherType: ";
|
||||
os->setf (std::ios::hex, std::ios::basefield);
|
||||
*os << m_ether_type;
|
||||
os->setf (std::ios::dec, std::ios::basefield);
|
||||
}
|
||||
|
||||
void
|
||||
ChunkLlcSnap::add_to (Buffer *buffer) const
|
||||
{
|
||||
buffer->add_at_start (get_size ());
|
||||
Buffer::Iterator i = buffer->begin ();
|
||||
uint8_t buf[] = {0xaa, 0xaa, 0x03, 0, 0, 0};
|
||||
i.write (buf, 6);
|
||||
i.write_hton_u16 (m_ether_type);
|
||||
}
|
||||
void
|
||||
ChunkLlcSnap::peek_from (Buffer const *buffer)
|
||||
{
|
||||
Buffer::Iterator i = buffer->begin ();
|
||||
i.next (5+1);
|
||||
m_ether_type = i.read_ntoh_u16 ();
|
||||
}
|
||||
void
|
||||
ChunkLlcSnap::remove_from (Buffer *buffer)
|
||||
{
|
||||
buffer->remove_at_start (get_size ());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -1,55 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef CHUNK_LLC_SNAP_H
|
||||
#define CHUNK_LLC_SNAP_H
|
||||
|
||||
#include "chunk.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class ChunkLlcSnap : public Chunk {
|
||||
public:
|
||||
ChunkLlcSnap ();
|
||||
virtual ~ChunkLlcSnap ();
|
||||
|
||||
enum Type {
|
||||
TYPE_IPV4 = 0x0800,
|
||||
TYPE_ARP = 0x0806
|
||||
};
|
||||
|
||||
void set_type (enum Type type);
|
||||
enum Type get_type (void);
|
||||
|
||||
uint32_t get_size (void) const;
|
||||
|
||||
private:
|
||||
virtual void print (std::ostream *os) const;
|
||||
virtual void add_to (Buffer *buffer) const;
|
||||
virtual void peek_from (Buffer const *buffer);
|
||||
virtual void remove_from (Buffer *buffer);
|
||||
uint16_t m_ether_type;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* CHUNK_LLC_SNAP_H */
|
||||
@@ -1,49 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "chunk-utils.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
void write_to (Buffer::Iterator &i, Ipv4Address ad)
|
||||
{
|
||||
i.write_hton_u32 (ad.get_host_order ());
|
||||
}
|
||||
void write_to (Buffer::Iterator &i, MacAddress ad)
|
||||
{
|
||||
uint8_t mac[6];
|
||||
ad.peek (mac);
|
||||
i.write (mac, 6);
|
||||
}
|
||||
|
||||
void read_from (Buffer::Iterator &i, Ipv4Address &ad)
|
||||
{
|
||||
ad.set_host_order (i.read_ntoh_u32 ());
|
||||
}
|
||||
void read_from (Buffer::Iterator &i, MacAddress &ad)
|
||||
{
|
||||
uint8_t mac[6];
|
||||
i.read (mac, 6);
|
||||
ad.set (mac);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -1,38 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef CHUNK_UTILS_H
|
||||
#define CHUNK_UTILS_H
|
||||
|
||||
#include "buffer.h"
|
||||
#include "ipv4-address.h"
|
||||
#include "mac-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
void write_to (Buffer::Iterator &i, Ipv4Address ad);
|
||||
void write_to (Buffer::Iterator &i, MacAddress ad);
|
||||
|
||||
void read_from (Buffer::Iterator &i, Ipv4Address &ad);
|
||||
void read_from (Buffer::Iterator &i, MacAddress &ad);
|
||||
|
||||
};
|
||||
|
||||
#endif /* CHUNK_UTILS_H */
|
||||
@@ -1,203 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
#include "ipv4-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Ipv4Mask::Ipv4Mask ()
|
||||
: m_mask (0x66666666)
|
||||
{}
|
||||
|
||||
Ipv4Mask::Ipv4Mask (uint32_t mask)
|
||||
: m_mask (mask)
|
||||
{}
|
||||
Ipv4Mask::Ipv4Mask (char const *mask)
|
||||
{
|
||||
m_mask = ascii_to_ipv4_host (mask);
|
||||
}
|
||||
|
||||
bool
|
||||
Ipv4Mask::is_equal (Ipv4Mask other) const
|
||||
{
|
||||
if (other.m_mask == m_mask) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Ipv4Mask::is_match (Ipv4Address a, Ipv4Address b) const
|
||||
{
|
||||
if ((a.get_host_order () & m_mask) == (b.get_host_order () & m_mask)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Ipv4Mask::get_host_order (void) const
|
||||
{
|
||||
return m_mask;
|
||||
}
|
||||
void
|
||||
Ipv4Mask::set_host_order (uint32_t value)
|
||||
{
|
||||
m_mask = value;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Mask::print (std::ostream *os) const
|
||||
{
|
||||
*os << ((m_mask >> 24) & 0xff) << "."
|
||||
<< ((m_mask >> 16) & 0xff) << "."
|
||||
<< ((m_mask >> 8) & 0xff) << "."
|
||||
<< ((m_mask >> 0) & 0xff);
|
||||
}
|
||||
|
||||
|
||||
Ipv4Mask
|
||||
Ipv4Mask::get_loopback (void)
|
||||
{
|
||||
static Ipv4Mask loopback = Ipv4Mask ("255.0.0.0");
|
||||
return loopback;
|
||||
}
|
||||
Ipv4Mask
|
||||
Ipv4Mask::get_zero (void)
|
||||
{
|
||||
static Ipv4Mask zero = Ipv4Mask ("0.0.0.0");
|
||||
return zero;
|
||||
}
|
||||
|
||||
Ipv4Address::Ipv4Address ()
|
||||
: m_address (0x66666666)
|
||||
{}
|
||||
Ipv4Address::Ipv4Address (uint32_t address)
|
||||
{
|
||||
m_address = address;
|
||||
}
|
||||
Ipv4Address::Ipv4Address (char const *address)
|
||||
{
|
||||
m_address = ascii_to_ipv4_host (address);
|
||||
}
|
||||
|
||||
bool
|
||||
Ipv4Address::is_equal (Ipv4Address other) const
|
||||
{
|
||||
if (other.m_address == m_address) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Ipv4Address::is_multicast (void)
|
||||
{
|
||||
// XXX
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Ipv4Address::get_host_order (void) const
|
||||
{
|
||||
return m_address;
|
||||
}
|
||||
void
|
||||
Ipv4Address::set_host_order (uint32_t ip)
|
||||
{
|
||||
m_address = ip;
|
||||
}
|
||||
void
|
||||
Ipv4Address::serialize (uint8_t buf[4]) const
|
||||
{
|
||||
buf[0] = (m_address >> 24) & 0xff;
|
||||
buf[1] = (m_address >> 16) & 0xff;
|
||||
buf[2] = (m_address >> 8) & 0xff;
|
||||
buf[3] = (m_address >> 0) & 0xff;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4Address::print (std::ostream *os) const
|
||||
{
|
||||
*os << ((m_address >> 24) & 0xff) << "."
|
||||
<< ((m_address >> 16) & 0xff) << "."
|
||||
<< ((m_address >> 8) & 0xff) << "."
|
||||
<< ((m_address >> 0) & 0xff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ipv4Address
|
||||
Ipv4Address::get_zero (void)
|
||||
{
|
||||
static Ipv4Address zero ("0.0.0.0");
|
||||
return zero;
|
||||
}
|
||||
Ipv4Address
|
||||
Ipv4Address::get_any (void)
|
||||
{
|
||||
static Ipv4Address any ("0.0.0.0");
|
||||
return any;
|
||||
}
|
||||
Ipv4Address
|
||||
Ipv4Address::get_broadcast (void)
|
||||
{
|
||||
static Ipv4Address broadcast ("255.255.255.255");
|
||||
return broadcast;
|
||||
}
|
||||
Ipv4Address
|
||||
Ipv4Address::get_loopback (void)
|
||||
{
|
||||
Ipv4Address loopback ("127.0.0.1");
|
||||
return loopback;
|
||||
}
|
||||
|
||||
bool operator == (Ipv4Address const &a, Ipv4Address const &b)
|
||||
{
|
||||
return a.is_equal (b);
|
||||
}
|
||||
bool operator != (Ipv4Address const &a, Ipv4Address const &b)
|
||||
{
|
||||
return !a.is_equal (b);
|
||||
}
|
||||
size_t Ipv4AddressHash::operator()(Ipv4Address const &x) const
|
||||
{
|
||||
return x.get_host_order ();
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Address const& address)
|
||||
{
|
||||
address.print (&os);
|
||||
return os;
|
||||
}
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Mask const& mask)
|
||||
{
|
||||
mask.print (&os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -1,107 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef IPV4_ADDRESS_H
|
||||
#define IPV4_ADDRESS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ostream>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/* Ipv4 addresses are stored in host order in
|
||||
* this class.
|
||||
*/
|
||||
class Ipv4Address {
|
||||
public:
|
||||
Ipv4Address ();
|
||||
/* input address is in host order. */
|
||||
Ipv4Address (uint32_t address);
|
||||
/* input address is in format:
|
||||
* hhh.xxx.xxx.lll
|
||||
* where h is the high byte and l the
|
||||
* low byte
|
||||
*/
|
||||
Ipv4Address (char const *address);
|
||||
|
||||
bool is_equal (Ipv4Address other) const;
|
||||
|
||||
/* Using this method is frowned upon.
|
||||
* Please, do _not_ use this method.
|
||||
* It is there only for chunk-ipv4.
|
||||
*/
|
||||
uint32_t get_host_order (void) const;
|
||||
void set_host_order (uint32_t ip);
|
||||
void serialize (uint8_t buf[4]) const;
|
||||
|
||||
void print (std::ostream *os) const;
|
||||
|
||||
bool is_broadcast (void);
|
||||
bool is_multicast (void);
|
||||
|
||||
static Ipv4Address get_zero (void);
|
||||
static Ipv4Address get_any (void);
|
||||
static Ipv4Address get_broadcast (void);
|
||||
static Ipv4Address get_loopback (void);
|
||||
private:
|
||||
uint32_t m_address;
|
||||
};
|
||||
|
||||
|
||||
class Ipv4Mask {
|
||||
public:
|
||||
Ipv4Mask ();
|
||||
Ipv4Mask (uint32_t mask);
|
||||
Ipv4Mask (char const *mask);
|
||||
|
||||
bool is_match (Ipv4Address a, Ipv4Address b) const;
|
||||
|
||||
bool is_equal (Ipv4Mask other) const;
|
||||
|
||||
|
||||
/* Using this method is frowned upon.
|
||||
* Please, do _not_ use this method.
|
||||
*/
|
||||
uint32_t get_host_order (void) const;
|
||||
void set_host_order (uint32_t value);
|
||||
|
||||
void print (std::ostream *os) const;
|
||||
|
||||
static Ipv4Mask get_loopback (void);
|
||||
static Ipv4Mask get_zero (void);
|
||||
private:
|
||||
uint32_t m_mask;
|
||||
};
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Address const& address);
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Mask const& mask);
|
||||
|
||||
bool operator == (Ipv4Address const &a, Ipv4Address const &b);
|
||||
bool operator != (Ipv4Address const &a, Ipv4Address const &b);
|
||||
class Ipv4AddressHash : public std::unary_function<Ipv4Address, size_t> {
|
||||
public:
|
||||
size_t operator()(Ipv4Address const &x) const;
|
||||
};
|
||||
bool operator != (Ipv4Address const &a, Ipv4Address const &b);
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* IPV4_ADDRESS_H */
|
||||
@@ -1,82 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "ipv4-network-interface.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
Ipv4NetworkInterface::~Ipv4NetworkInterface ()
|
||||
{}
|
||||
|
||||
void
|
||||
Ipv4NetworkInterface::set_address (Ipv4Address ad)
|
||||
{
|
||||
m_address = ad;
|
||||
}
|
||||
void
|
||||
Ipv4NetworkInterface::set_mask (Ipv4Mask mask)
|
||||
{
|
||||
m_mask = mask;
|
||||
}
|
||||
uint16_t
|
||||
Ipv4NetworkInterface::get_mtu (void) const
|
||||
{
|
||||
return real_get_mtu ();
|
||||
}
|
||||
Ipv4Mask
|
||||
Ipv4NetworkInterface::get_mask (void) const
|
||||
{
|
||||
return m_mask;
|
||||
}
|
||||
Ipv4Address
|
||||
Ipv4NetworkInterface::get_address (void) const
|
||||
{
|
||||
return m_address;
|
||||
}
|
||||
Ipv4Address
|
||||
Ipv4NetworkInterface::get_broadcast (void) const
|
||||
{
|
||||
uint32_t mask = m_mask.get_host_order ();
|
||||
uint32_t address = m_address.get_host_order ();
|
||||
Ipv4Address broadcast = Ipv4Address (address | (~mask));
|
||||
return broadcast;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4NetworkInterface::send (Packet packet, Ipv4Address to)
|
||||
{
|
||||
real_send (packet, to);
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4NetworkInterface::set_rx_callback (RxCallback callback)
|
||||
{
|
||||
m_rx_callback = callback;
|
||||
}
|
||||
|
||||
void
|
||||
Ipv4NetworkInterface::forward_up (Packet packet)
|
||||
{
|
||||
m_rx_callback (packet, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -1,59 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef IPV4_NETWORK_INTERFACE
|
||||
#define IPV4_NETWORK_INTERFACE
|
||||
|
||||
#include "ipv4-address.h"
|
||||
#include "ns3/callback.h"
|
||||
#include "packet.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Packet;
|
||||
|
||||
class Ipv4NetworkInterface {
|
||||
public:
|
||||
typedef Callback<void, Packet , Ipv4NetworkInterface *> RxCallback;
|
||||
virtual ~Ipv4NetworkInterface () = 0;
|
||||
|
||||
void set_address (Ipv4Address ad);
|
||||
void set_mask (Ipv4Mask mask);
|
||||
|
||||
uint16_t get_mtu (void) const;
|
||||
Ipv4Mask get_mask (void) const;
|
||||
Ipv4Address get_address (void) const;
|
||||
Ipv4Address get_broadcast (void) const;
|
||||
|
||||
void send (Packet packet, Ipv4Address to);
|
||||
void set_rx_callback (RxCallback callback);
|
||||
protected:
|
||||
void forward_up (Packet packet);
|
||||
private:
|
||||
virtual uint16_t real_get_mtu (void) const = 0;
|
||||
virtual void real_send (Packet packet, Ipv4Address to) = 0;
|
||||
RxCallback m_rx_callback;
|
||||
Ipv4Address m_address;
|
||||
Ipv4Mask m_mask;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* IPV4_NETWORK_INTERFACE */
|
||||
@@ -1,89 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "llc-snap-encapsulation.h"
|
||||
#include "chunk-llc-snap.h"
|
||||
#include "packet.h"
|
||||
#include "chunk.h"
|
||||
#include "mac-network-interface.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
uint32_t
|
||||
LlcSnapEncapsulation::get_overhead (void) const
|
||||
{
|
||||
ChunkLlcSnap llc;
|
||||
return llc.get_size ();
|
||||
}
|
||||
void
|
||||
LlcSnapEncapsulation::set_ipv4_callback (RxCallback callback)
|
||||
{
|
||||
m_ipv4_callback = callback;
|
||||
}
|
||||
void
|
||||
LlcSnapEncapsulation::set_arp_callback (RxCallback callback)
|
||||
{
|
||||
m_arp_callback = callback;
|
||||
}
|
||||
void
|
||||
LlcSnapEncapsulation::set_mac_interface (MacNetworkInterface *interface)
|
||||
{
|
||||
m_interface = interface;
|
||||
}
|
||||
void
|
||||
LlcSnapEncapsulation::send_ipv4 (Packet packet, MacAddress to)
|
||||
{
|
||||
ChunkLlcSnap llc;
|
||||
llc.set_type (ChunkLlcSnap::TYPE_IPV4);
|
||||
packet.add (&llc);
|
||||
m_interface->send (packet, to);
|
||||
}
|
||||
void
|
||||
LlcSnapEncapsulation::send_arp (Packet packet, MacAddress to)
|
||||
{
|
||||
ChunkLlcSnap llc;
|
||||
llc.set_type (ChunkLlcSnap::TYPE_ARP);
|
||||
packet.add (&llc);
|
||||
m_interface->send (packet, to);
|
||||
}
|
||||
|
||||
void
|
||||
LlcSnapEncapsulation::receive (Packet packet, MacNetworkInterface *interface)
|
||||
{
|
||||
assert (interface == m_interface);
|
||||
ChunkLlcSnap llc;
|
||||
packet.peek (&llc);
|
||||
packet.remove (&llc);
|
||||
switch (llc.get_type ()) {
|
||||
case ChunkLlcSnap::TYPE_IPV4:
|
||||
m_ipv4_callback (packet);
|
||||
break;
|
||||
case ChunkLlcSnap::TYPE_ARP:
|
||||
m_arp_callback (packet);
|
||||
break;
|
||||
default:
|
||||
assert (false);
|
||||
//NOT REACHED
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -1,52 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef LLC_SNAP_ENCAPSULATION
|
||||
#define LLC_SNAP_ENCAPSULATION
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ns3/callback.h"
|
||||
#include "mac-address.h"
|
||||
#include "packet.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class MacNetworkInterface;
|
||||
|
||||
class LlcSnapEncapsulation {
|
||||
public:
|
||||
typedef Callback<void, Packet > RxCallback;
|
||||
|
||||
uint32_t get_overhead (void) const;
|
||||
void set_ipv4_callback (RxCallback callback);
|
||||
void set_arp_callback (RxCallback callback);
|
||||
void set_mac_interface (MacNetworkInterface *interface);
|
||||
void send_ipv4 (Packet packet, MacAddress to);
|
||||
void send_arp (Packet packet, MacAddress to);
|
||||
void receive (Packet packet, MacNetworkInterface *interface);
|
||||
private:
|
||||
RxCallback m_ipv4_callback;
|
||||
RxCallback m_arp_callback;
|
||||
MacNetworkInterface *m_interface;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* LLC_SNAP_ENCAPSULATION */
|
||||
@@ -1,46 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "mac-address-factory.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
MacAddressFactory::MacAddressFactory ()
|
||||
{
|
||||
m_addr[0] = 0;
|
||||
m_addr[1] = 0;
|
||||
m_addr[2] = 0;
|
||||
m_addr[3] = 0;
|
||||
m_addr[4] = 0;
|
||||
m_addr[5] = 0;
|
||||
m_index = 0;
|
||||
}
|
||||
|
||||
MacAddress
|
||||
MacAddressFactory::get_next (void)
|
||||
{
|
||||
m_addr[m_index]++;
|
||||
if (m_addr[m_index] == 0) {
|
||||
m_index++;
|
||||
}
|
||||
return MacAddress (m_addr);
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -1,40 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef MAC_ADDRESS_FACTORY_H
|
||||
#define MAC_ADDRESS_FACTORY_H
|
||||
|
||||
#include "mac-address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class MacAddressFactory {
|
||||
public:
|
||||
MacAddressFactory ();
|
||||
MacAddress get_next (void);
|
||||
private:
|
||||
uint8_t m_addr[6];
|
||||
uint8_t m_cur;
|
||||
uint8_t m_index;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* MAC_ADDRESS_FACTORY_H */
|
||||
@@ -1,187 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "mac-address.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
MacAddress::MacAddress ()
|
||||
{
|
||||
m_address[0] = 0;
|
||||
m_address[1] = 0;
|
||||
m_address[2] = 0;
|
||||
m_address[3] = 0;
|
||||
m_address[4] = 0;
|
||||
m_address[5] = 0;
|
||||
}
|
||||
|
||||
MacAddress::MacAddress (uint8_t const address[6])
|
||||
{
|
||||
m_address[0] = address[0];
|
||||
m_address[1] = address[1];
|
||||
m_address[2] = address[2];
|
||||
m_address[3] = address[3];
|
||||
m_address[4] = address[4];
|
||||
m_address[5] = address[5];
|
||||
}
|
||||
MacAddress::MacAddress (char const *address)
|
||||
{
|
||||
ascii_to_mac_network (address, m_address);
|
||||
}
|
||||
MacAddress::MacAddress (uint32_t ip_multicast_address)
|
||||
{
|
||||
m_address[0] = 1 | ((ip_multicast_address & 0x7f) << 1);
|
||||
m_address[1] = (ip_multicast_address >> 7) & 0xff;
|
||||
m_address[2] = (ip_multicast_address >> 16) & 0xff;
|
||||
m_address[3] = 0x5e;
|
||||
m_address[4] = 0;
|
||||
m_address[5] = 0;
|
||||
}
|
||||
MacAddress::~MacAddress ()
|
||||
{}
|
||||
|
||||
bool
|
||||
MacAddress::is_equal (MacAddress other) const
|
||||
{
|
||||
if (m_address[0] == other.m_address[0] &&
|
||||
m_address[1] == other.m_address[1] &&
|
||||
m_address[2] == other.m_address[2] &&
|
||||
m_address[3] == other.m_address[3] &&
|
||||
m_address[4] == other.m_address[4] &&
|
||||
m_address[5] == other.m_address[5]) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool
|
||||
MacAddress::is_broadcast (void) const
|
||||
{
|
||||
if (m_address[0] == 0xff &&
|
||||
m_address[1] == 0xff &&
|
||||
m_address[2] == 0xff &&
|
||||
m_address[3] == 0xff &&
|
||||
m_address[4] == 0xff &&
|
||||
m_address[5] == 0xff) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool
|
||||
MacAddress::is_multicast (void) const
|
||||
{
|
||||
if (m_address[0] & 0x1) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool
|
||||
MacAddress::is_multicast_equal (MacAddress other) const
|
||||
{
|
||||
if (get_multicast_part () == other.get_multicast_part ()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
MacAddress::get_multicast_part (void) const
|
||||
{
|
||||
uint32_t part = 0;
|
||||
part |= m_address[0] >> 1;
|
||||
part |= m_address[1] << 7;
|
||||
part |= (m_address[1] << 15);
|
||||
return part;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MacAddress::peek (uint8_t ad[6]) const
|
||||
{
|
||||
memcpy (ad, m_address, 6);
|
||||
}
|
||||
void
|
||||
MacAddress::set (uint8_t const ad[6])
|
||||
{
|
||||
memcpy (m_address, ad, 6);
|
||||
}
|
||||
|
||||
void
|
||||
MacAddress::print (std::ostream *os) const
|
||||
{
|
||||
os->setf (std::ios::hex, std::ios::basefield);
|
||||
*os << (uint32_t)m_address[0] << ":"
|
||||
<< (uint32_t)m_address[1] << ":"
|
||||
<< (uint32_t)m_address[2] << ":"
|
||||
<< (uint32_t)m_address[3] << ":"
|
||||
<< (uint32_t)m_address[4] << ":"
|
||||
<< (uint32_t)m_address[5];
|
||||
os->setf (std::ios::dec, std::ios::basefield);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
MacAddress
|
||||
MacAddress::get_broadcast (void)
|
||||
{
|
||||
static MacAddress broadcast = MacAddress ("ff:ff:ff:ff:ff:ff");
|
||||
return broadcast;
|
||||
}
|
||||
|
||||
bool operator == (MacAddress const&a, MacAddress const&b)
|
||||
{
|
||||
return a.is_equal (b);
|
||||
}
|
||||
|
||||
bool operator != (MacAddress const&a, MacAddress const&b)
|
||||
{
|
||||
return !a.is_equal (b);
|
||||
}
|
||||
|
||||
bool operator < (MacAddress const&a, MacAddress const&b)
|
||||
{
|
||||
uint8_t a_p[6];
|
||||
uint8_t b_p[6];
|
||||
a.peek (a_p);
|
||||
b.peek (b_p);
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
if (a_p[i] < b_p[i]) {
|
||||
return true;
|
||||
} else if (a_p[i] > b_p[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, MacAddress const& address)
|
||||
{
|
||||
address.print (&os);
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -1,72 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef MAC_ADDRESS_H
|
||||
#define MAC_ADDRESS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <ostream>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class MacAddress {
|
||||
public:
|
||||
MacAddress (void);
|
||||
/* low byte should be first.
|
||||
*/
|
||||
MacAddress (uint8_t const address[6]);
|
||||
/* The string should look like this:
|
||||
* hh-xx-xx-xx-xx-ll
|
||||
* where hh is the high byte and ll is
|
||||
* the low byte.
|
||||
*/
|
||||
MacAddress (char const *address);
|
||||
/* create the mac address associated to
|
||||
* this multicast ip address.
|
||||
*/
|
||||
MacAddress (uint32_t multicast_ip_address);
|
||||
~MacAddress ();
|
||||
|
||||
bool is_equal (MacAddress other) const;
|
||||
bool is_broadcast (void) const;
|
||||
bool is_multicast (void) const;
|
||||
bool is_multicast_equal (MacAddress other) const;
|
||||
|
||||
void print (std::ostream *os) const;
|
||||
|
||||
void peek (uint8_t ad[6]) const;
|
||||
void set (uint8_t const ad[6]);
|
||||
|
||||
static MacAddress get_broadcast (void);
|
||||
private:
|
||||
uint32_t get_multicast_part (void) const;
|
||||
uint8_t m_address[6];
|
||||
};
|
||||
|
||||
bool operator == (MacAddress const&a, MacAddress const&b);
|
||||
bool operator != (MacAddress const&a, MacAddress const&b);
|
||||
bool operator < (MacAddress const&a, MacAddress const&b);
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, MacAddress const& address);
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* MAC_ADDRESS_H */
|
||||
@@ -1,96 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "mac-network-interface.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
MacNetworkInterface::MacNetworkInterface (MacAddress self, uint16_t max_mtu)
|
||||
: m_self (self), m_max_mtu (max_mtu), m_mtu (max_mtu)
|
||||
{}
|
||||
MacNetworkInterface::~MacNetworkInterface ()
|
||||
{}
|
||||
|
||||
MacAddress
|
||||
MacNetworkInterface::get_mac_address (void) const
|
||||
{
|
||||
return m_self;
|
||||
}
|
||||
void
|
||||
MacNetworkInterface::set_mtu (uint16_t mtu)
|
||||
{
|
||||
if (mtu > m_max_mtu ) {
|
||||
m_mtu = m_max_mtu;
|
||||
} else {
|
||||
m_mtu = mtu;
|
||||
}
|
||||
}
|
||||
uint16_t
|
||||
MacNetworkInterface::get_mtu (void) const
|
||||
{
|
||||
return m_mtu;
|
||||
}
|
||||
bool
|
||||
MacNetworkInterface::is_down (void) const
|
||||
{
|
||||
return m_is_down;
|
||||
}
|
||||
void
|
||||
MacNetworkInterface::set_up (void)
|
||||
{
|
||||
m_is_down = false;
|
||||
notify_up ();
|
||||
}
|
||||
void
|
||||
MacNetworkInterface::set_down (void)
|
||||
{
|
||||
m_is_down = true;
|
||||
notify_down ();
|
||||
}
|
||||
|
||||
void
|
||||
MacNetworkInterface::set_status_change_callback (StatusChangeCallback callback)
|
||||
{
|
||||
m_status_change_callback = callback;
|
||||
}
|
||||
|
||||
void
|
||||
MacNetworkInterface::set_rx_callback (RxCallback callback)
|
||||
{
|
||||
m_rx_callback = callback;
|
||||
}
|
||||
void
|
||||
MacNetworkInterface::send (Packet packet, MacAddress to)
|
||||
{
|
||||
real_send (packet, to);
|
||||
}
|
||||
void
|
||||
MacNetworkInterface::forward_up (Packet packet)
|
||||
{
|
||||
m_rx_callback (packet, this);
|
||||
}
|
||||
|
||||
void
|
||||
MacNetworkInterface::notify_status_change (void)
|
||||
{
|
||||
m_status_change_callback (this);
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -1,68 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef MAC_NETWORK_INTERFACE_H
|
||||
#define MAC_NETWORK_INTERFACE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ns3/callback.h"
|
||||
#include "mac-address.h"
|
||||
#include "packet.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class MacNetworkInterface {
|
||||
public:
|
||||
typedef Callback<void, Packet , MacNetworkInterface *> RxCallback;
|
||||
typedef Callback<void,MacNetworkInterface *> StatusChangeCallback;
|
||||
|
||||
MacNetworkInterface (MacAddress self, uint16_t max_mtu);
|
||||
virtual ~MacNetworkInterface () = 0;
|
||||
|
||||
MacAddress get_mac_address (void) const;
|
||||
void set_mtu (uint16_t mtu);
|
||||
uint16_t get_mtu (void) const;
|
||||
|
||||
bool is_down (void) const;
|
||||
void set_up (void);
|
||||
void set_down (void);
|
||||
|
||||
void set_status_change_callback (StatusChangeCallback callback);
|
||||
void set_rx_callback (RxCallback callback);
|
||||
void send (Packet packet, MacAddress to);
|
||||
protected:
|
||||
void forward_up (Packet packet);
|
||||
void notify_status_change (void);
|
||||
private:
|
||||
virtual void notify_up (void) = 0;
|
||||
virtual void notify_down (void) = 0;
|
||||
virtual void real_send (Packet packet, MacAddress to) = 0;
|
||||
|
||||
StatusChangeCallback m_status_change_callback;
|
||||
RxCallback m_rx_callback;
|
||||
MacAddress m_self;
|
||||
uint16_t m_max_mtu;
|
||||
uint16_t m_mtu;
|
||||
bool m_is_down;
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* MAC_NETWORK_INTERFACE_H */
|
||||
@@ -1,61 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "seed-generator.h"
|
||||
#include "rng-mrg32k3a.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class SeedGeneratorPrivate {
|
||||
public:
|
||||
static void destroy (void);
|
||||
static void reset (uint32_t seed);
|
||||
static uint32_t get (void);
|
||||
private:
|
||||
static RngMrg32k3a m_generator;
|
||||
};
|
||||
|
||||
RngMrg32k3a SeedGeneratorPrivate::m_generator;
|
||||
|
||||
void
|
||||
SeedGeneratorPrivate::reset (uint32_t seed)
|
||||
{
|
||||
m_generator.reset (seed);
|
||||
}
|
||||
uint32_t
|
||||
SeedGeneratorPrivate::get (void)
|
||||
{
|
||||
return m_generator.get_uint ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
SeedGenerator::reset (uint32_t seed)
|
||||
{
|
||||
SeedGeneratorPrivate::reset (seed);
|
||||
}
|
||||
uint32_t
|
||||
SeedGenerator::get (void)
|
||||
{
|
||||
return SeedGeneratorPrivate::get ();
|
||||
}
|
||||
|
||||
}; // namespace ns3
|
||||
@@ -1,40 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2006 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef SEED_GENERATOR_H
|
||||
#define SEED_GENERATOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class SeedGeneratorPrivate;
|
||||
|
||||
class SeedGenerator {
|
||||
public:
|
||||
static void reset (uint32_t seed);
|
||||
static uint32_t get (void);
|
||||
private:
|
||||
SeedGenerator ();
|
||||
};
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* SEED_GENERATOR_H */
|
||||
@@ -1,293 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
uint16_t
|
||||
utils_hton_16 (uint16_t v)
|
||||
{
|
||||
uint8_t array[2];
|
||||
array[0] = (v >> 8) & 0xff;
|
||||
array[1] = (v >> 0) & 0xff;
|
||||
return *((uint16_t *)array);
|
||||
}
|
||||
uint32_t
|
||||
utils_hton_32 (uint32_t v)
|
||||
{
|
||||
uint8_t array[4];
|
||||
array[0] = (v >> 24) & 0xff;
|
||||
array[1] = (v >> 16) & 0xff;
|
||||
array[2] = (v >> 8) & 0xff;
|
||||
array[3] = (v >> 0) & 0xff;
|
||||
return *((uint32_t *)array);
|
||||
}
|
||||
uint16_t
|
||||
utils_ntoh_16 (uint16_t v)
|
||||
{
|
||||
uint16_t val;
|
||||
uint8_t *array;
|
||||
array = (uint8_t *)&v;
|
||||
val = (array[0] << 8) | (array[1] << 0);
|
||||
return val;
|
||||
}
|
||||
uint32_t
|
||||
utils_ntoh_32 (uint32_t v)
|
||||
{
|
||||
uint32_t val = 0;
|
||||
uint8_t *array = (uint8_t *)&v;
|
||||
val |= array[0] << 24;
|
||||
val |= array[1] << 16;
|
||||
val |= array[2] << 8;
|
||||
val |= array[3] << 0;
|
||||
return val;
|
||||
}
|
||||
|
||||
#define ASCII_DOT (0x2e)
|
||||
#define ASCII_ZERO (0x30)
|
||||
#define ASCII_A (0x41)
|
||||
#define ASCII_Z (0x5a)
|
||||
#define ASCII_a (0x61)
|
||||
#define ASCII_z (0x7a)
|
||||
#define ASCII_COLON (0x3a)
|
||||
|
||||
|
||||
uint32_t
|
||||
ascii_to_ipv4_host (char const *address)
|
||||
{
|
||||
uint32_t host = 0;
|
||||
while (true) {
|
||||
uint8_t byte = 0;
|
||||
while (*address != ASCII_DOT &&
|
||||
*address != 0) {
|
||||
byte *= 10;
|
||||
byte += *address - ASCII_ZERO;
|
||||
address++;
|
||||
}
|
||||
host <<= 8;
|
||||
host |= byte;
|
||||
if (*address == 0) {
|
||||
break;
|
||||
}
|
||||
address++;
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
|
||||
char
|
||||
ascii_to_low_case (char c)
|
||||
{
|
||||
if (c >= ASCII_a && c <= ASCII_z) {
|
||||
return c;
|
||||
} else if (c >= ASCII_A && c <= ASCII_Z) {
|
||||
return c + (ASCII_a - ASCII_A);
|
||||
} else {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
void
|
||||
ascii_to_mac_network (char const *str, uint8_t address[6])
|
||||
{
|
||||
uint8_t i = 0;
|
||||
while (*str != 0 && i < 6) {
|
||||
uint8_t byte = 0;
|
||||
while (*str != ASCII_COLON && *str != 0) {
|
||||
byte <<= 4;
|
||||
char low = ascii_to_low_case (*str);
|
||||
if (low >= ASCII_a) {
|
||||
byte |= low - ASCII_a + 10;
|
||||
} else {
|
||||
byte |= low - ASCII_ZERO;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
address[i] = byte;
|
||||
str++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t
|
||||
utils_checksum_calculate (uint16_t checksum, uint8_t *buffer, uint16_t size)
|
||||
{
|
||||
/* see RFC 1071 to understand this code. */
|
||||
uint32_t sum = checksum;
|
||||
uint16_t *data = (uint16_t *) buffer;
|
||||
for (uint16_t i = 0; i < (size/2); i++) {
|
||||
sum += data[i];
|
||||
}
|
||||
if ((size % 2) != 0) {
|
||||
uint8_t tmp_buf[2];
|
||||
tmp_buf[0] = buffer[size-1];
|
||||
tmp_buf[1] = 0;
|
||||
data = (uint16_t *)tmp_buf;
|
||||
sum += *data;
|
||||
}
|
||||
while (sum >> 16) {
|
||||
sum = (sum & 0xffff) + (sum >> 16);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
utils_checksum_complete (uint16_t checksum)
|
||||
{
|
||||
return ~checksum;
|
||||
}
|
||||
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
|
||||
#ifdef RUN_SELF_TESTS
|
||||
#include "ns3/test.h"
|
||||
namespace ns3 {
|
||||
|
||||
class UtilsTest : public Test {
|
||||
public:
|
||||
UtilsTest ();
|
||||
virtual bool run_tests (void);
|
||||
private:
|
||||
bool test_ipv4_ascii_to_host (char const *str, uint32_t expected);
|
||||
bool test_mac_ascii (char const *str, uint8_t expected[6]);
|
||||
bool test_hton_16 (uint16_t v, uint8_t expected[2]);
|
||||
};
|
||||
bool
|
||||
UtilsTest::test_ipv4_ascii_to_host (char const *str, uint32_t expected)
|
||||
{
|
||||
if (ascii_to_ipv4_host (str) != expected) {
|
||||
failure () << "Utils ascii to host --"
|
||||
<< " for: \"" << str << "\""
|
||||
<< " expected: " << expected
|
||||
<< " got: " << ascii_to_ipv4_host (str)
|
||||
<< std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
UtilsTest::test_mac_ascii (char const *str, uint8_t expected[6])
|
||||
{
|
||||
uint8_t got[6];
|
||||
ascii_to_mac_network (str, got);
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
if (got[i] != expected[i]) {
|
||||
failure () << "Utils ascii to mac --"
|
||||
<< " for: \"" << str << "\""
|
||||
<< " expected: ";
|
||||
failure ().setf (std::ios::hex, std::ios::basefield);
|
||||
failure () << (uint32_t)expected[0] << ":"
|
||||
<< (uint32_t)expected[1] << ":"
|
||||
<< (uint32_t)expected[2] << ":"
|
||||
<< (uint32_t)expected[3] << ":"
|
||||
<< (uint32_t)expected[4] << ":"
|
||||
<< (uint32_t)expected[5];
|
||||
failure ().setf (std::ios::dec, std::ios::basefield);
|
||||
failure () << " got: ";
|
||||
failure ().setf (std::ios::hex, std::ios::basefield);
|
||||
failure () << (uint32_t)got[0] << ":"
|
||||
<< (uint32_t)got[1] << ":"
|
||||
<< (uint32_t)got[2] << ":"
|
||||
<< (uint32_t)got[3] << ":"
|
||||
<< (uint32_t)got[4] << ":"
|
||||
<< (uint32_t)got[5];
|
||||
failure ().setf (std::ios::dec, std::ios::basefield);
|
||||
failure () << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
UtilsTest::test_hton_16 (uint16_t v, uint8_t expected[2])
|
||||
{
|
||||
uint16_t result = utils_hton_16 (v);
|
||||
uint8_t *got = (uint8_t *)&result;
|
||||
if (got[0] != expected[0] ||
|
||||
got[1] != expected[1]) {
|
||||
failure () << "Utils hton 16 --"
|
||||
<< " for: \"" << v << "\""
|
||||
<< " expected: ";
|
||||
failure ().setf (std::ios::hex, std::ios::basefield);
|
||||
failure () << (uint32_t)expected[0] << ":"
|
||||
<< (uint32_t)expected[1];
|
||||
failure () << " got: ";
|
||||
failure () << (uint32_t)got[0] << ":"
|
||||
<< (uint32_t)got[1];
|
||||
failure ().setf (std::ios::dec, std::ios::basefield);
|
||||
failure () << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#define TEST_IPV4_ASCII_TO_HOST(a,b) \
|
||||
if (!test_ipv4_ascii_to_host (a,b)) { \
|
||||
ok = false; \
|
||||
}
|
||||
|
||||
#define TEST_MAC_ASCII(ad, a, b, c, d, e, f) \
|
||||
{ \
|
||||
uint8_t expected[6] = {a, b, c, d, e, f}; \
|
||||
if (!test_mac_ascii (ad, expected)) { \
|
||||
ok = false; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define TEST_HTON_16(v, a, b) \
|
||||
{ \
|
||||
uint8_t expected[2] = {a, b}; \
|
||||
if (!test_hton_16 (v, expected)) { \
|
||||
ok = false; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
UtilsTest::UtilsTest ()
|
||||
: Test ("Utils") {}
|
||||
|
||||
bool
|
||||
UtilsTest::run_tests (void)
|
||||
{
|
||||
bool ok = true;
|
||||
TEST_IPV4_ASCII_TO_HOST ("255.255.255.255", 0xffffffff);
|
||||
TEST_IPV4_ASCII_TO_HOST ("255.255.255.0", 0xffffff00);
|
||||
TEST_IPV4_ASCII_TO_HOST ("255.255.255.00", 0xffffff00);
|
||||
TEST_IPV4_ASCII_TO_HOST ("255.255.255.000", 0xffffff00);
|
||||
TEST_IPV4_ASCII_TO_HOST ("255.255.255.0000", 0xffffff00);
|
||||
TEST_IPV4_ASCII_TO_HOST ("255.255.0.255", 0xffff00ff);
|
||||
TEST_IPV4_ASCII_TO_HOST ("192.168.0.1", 0xc0a80001);
|
||||
TEST_IPV4_ASCII_TO_HOST ("0.168.0.1", 0x00a80001);
|
||||
TEST_MAC_ASCII ("00:00:00:00:00:00", 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
TEST_MAC_ASCII ("00:00:00:00:00:01", 0x00, 0x00, 0x00, 0x00, 0x00, 0x01);
|
||||
TEST_MAC_ASCII ("01:00:00:00:00:01", 0x01, 0x00, 0x00, 0x00, 0x00, 0x01);
|
||||
TEST_MAC_ASCII ("ff:00:00:ff:00:01", 0xff, 0x00, 0x00, 0xff, 0x00, 0x01);
|
||||
TEST_MAC_ASCII ("f0:00:00:00:5d:01", 0xf0, 0x00, 0x00, 0x00, 0x5d, 0x01);
|
||||
TEST_HTON_16 (0xf00f, 0xf0, 0x0f);
|
||||
return ok;
|
||||
}
|
||||
static UtilsTest g_utils_test;
|
||||
}; //namespace ns3
|
||||
#endif /* RUN_SELF_TESTS */
|
||||
@@ -1,43 +0,0 @@
|
||||
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
|
||||
/*
|
||||
* Copyright (c) 2005 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
uint16_t utils_hton_16 (uint16_t v);
|
||||
uint32_t utils_hton_32 (uint32_t v);
|
||||
uint16_t utils_ntoh_16 (uint16_t v);
|
||||
uint32_t utils_ntoh_32 (uint32_t v);
|
||||
|
||||
uint32_t ascii_to_ipv4_host (char const *address);
|
||||
void ascii_to_mac_network (char const *str, uint8_t address[6]);
|
||||
|
||||
/* call with checksum = 0 the first time. */
|
||||
uint16_t utils_checksum_calculate (uint16_t checksum, uint8_t *buffer, uint16_t size);
|
||||
uint16_t utils_checksum_complete (uint16_t checksum);
|
||||
|
||||
}; // namespace ns3
|
||||
|
||||
#endif /* UTILS_H */
|
||||
Reference in new issue
Block a user