Minor style fixes.

This commit is contained in:
Tom Wambold
2009-08-21 16:23:41 -04:00
parent afe998d27d
commit 5ee5fd9c8c
3 changed files with 694 additions and 599 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* vim: set ts=2 sw=2 expandtab: */
/* vim: set ts=2 sw=2 sta expandtab ai si cin: */
/*
* Copyright (c) 2009 Drexel University
*
@@ -156,7 +156,9 @@ public:
uint8_t GetVersion (void) const;
void SetSequenceNumber (uint16_t number);
uint16_t GetSequenceNumber (void) const throw (PacketBBError);
/* Calling this while HasSequenceNumber is False is undefined, make sure you
* check first! */
uint16_t GetSequenceNumber (void) const;
bool HasSequenceNumber (void) const;
/* Manipulating Packet TLVs */
@@ -216,6 +218,8 @@ public:
virtual TypeId GetInstanceTypeId (void) const;
virtual uint32_t GetSerializedSize (void) const;
virtual void Serialize (Buffer::Iterator start) const;
/* If this returns a number smaller than the total number of bytes in the
* buffer, there was an error. */
virtual uint32_t Deserialize (Buffer::Iterator start);
virtual void Print (std::ostream &os) const;
@@ -251,19 +255,27 @@ public:
uint8_t GetType (void) const;
void SetOriginatorAddress (Address address);
Address GetOriginatorAddress (void) const throw (PacketBBError);
/* Calling this while HasOriginatorAddress is False is undefined, make sure
* you check first! */
Address GetOriginatorAddress (void) const;
bool HasOriginatorAddress (void) const;
void SetHopLimit (uint8_t hoplimit);
uint8_t GetHopLimit (void) const throw (PacketBBError);
/* Calling this while HasHopLimit is False is undefined, make sure
* you check first! */
uint8_t GetHopLimit (void) const;
bool HasHopLimit (void) const;
void SetHopCount (uint8_t hopcount);
uint8_t GetHopCount (void) const throw (PacketBBError);
/* Calling this while HasHopCount is False is undefined, make sure
* you check first! */
uint8_t GetHopCount (void) const;
bool HasHopCount (void) const;
void SetSequenceNumber (uint16_t seqnum);
uint16_t GetSequenceNumber (void) const throw (PacketBBError);
/* Calling this while HasSequenceNumber is False is undefined, make sure
* you check first! */
uint16_t GetSequenceNumber (void) const;
bool HasSequenceNumber (void) const;
/* Manipulating Message TLVs */
@@ -319,7 +331,8 @@ public:
void Ref (void) const;
void Unref (void) const;
static Ptr<Message> DeserializeMessage (Buffer::Iterator &start) throw (PacketBBError);
/* Returns 0 on error */
static Ptr<Message> DeserializeMessage (Buffer::Iterator &start);
uint32_t GetSerializedSize (void) const;
void Serialize (Buffer::Iterator &start) const;
void Deserialize (Buffer::Iterator &start);
@@ -543,12 +556,16 @@ public:
uint8_t GetType (void) const;
void SetTypeExt (uint8_t type);
uint8_t GetTypeExt (void) const throw (PacketBBError);
/* Calling this while HasTypeExt is False is undefined, make sure
* you check first! */
uint8_t GetTypeExt (void) const;
bool HasTypeExt (void) const;
void SetValue (Buffer start);
void SetValue (const uint8_t * buffer, uint32_t size);
Buffer GetValue (void) const throw (PacketBBError);
/* Calling this while HasValue is False is undefined, make sure
* you check first! */
Buffer GetValue (void) const;
bool HasValue (void) const;
/* Smart pointer methods */
@@ -566,11 +583,11 @@ public:
protected:
void SetIndexStart (uint8_t index);
uint8_t GetIndexStart (void) const throw (PacketBBError);
uint8_t GetIndexStart (void) const;
bool HasIndexStart (void) const;
void SetIndexStop (uint8_t index);
uint8_t GetIndexStop (void) const throw (PacketBBError);
uint8_t GetIndexStop (void) const;
bool HasIndexStop (void) const;
void SetMultivalue (bool isMultivalue);
@@ -599,11 +616,15 @@ class AddressTlv : public Tlv
{
public:
void SetIndexStart (uint8_t index);
uint8_t GetIndexStart (void) const throw (PacketBBError);
/* Calling this while HasIndexStart is False is undefined, make sure
* you check first! */
uint8_t GetIndexStart (void) const;
bool HasIndexStart (void) const;
void SetIndexStop (uint8_t index);
uint8_t GetIndexStop (void) const throw (PacketBBError);
/* Calling this while HasIndexStop is False is undefined, make sure
* you check first! */
uint8_t GetIndexStop (void) const;
bool HasIndexStop (void) const;
void SetMultivalue (bool isMultivalue);

View File

@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/* vim: set ts=2 sw=2 expandtab: */
/* vim: set ts=2 sw=2 sta expandtab ai si cin: */
/*
* Copyright (c) 2009 Drexel University
*
@@ -47,71 +47,42 @@ public:
void Test (void)
{
if (TestSerialize ())
cout << "Serialize Pass, ";
{
cout << "Serialize Pass, ";
}
else
cout << "Serialize Fail, ";
{
cout << "Serialize Fail, ";
}
if (TestDeserialize ())
cout << "Deserialize Pass, ";
{
cout << "Deserialize Pass, ";
}
else
cout << "Deserialize Fail, ";
if (TestConsistency ())
cout << "Consistency Pass" << endl;
else
cout << "Consistency Fail" << endl;
{
cout << "Deserialize Fail, ";
}
}
bool TestSerialize (void)
{
Buffer newBuffer;
try
{
newBuffer.AddAtStart (m_refPacket.GetSerializedSize ());
m_refPacket.Serialize (newBuffer.Begin ());
}
catch (PacketBBError &e)
{
cout << endl << "Exception: " << e.what () << endl;
return false;
}
newBuffer.AddAtStart (m_refPacket.GetSerializedSize ());
m_refPacket.Serialize (newBuffer.Begin ());
return CompareBuffers (m_refBuffer, newBuffer);
}
bool TestDeserialize (void)
{
PacketBB newPacket;
try
{
newPacket.Deserialize (m_refBuffer.Begin ());
}
catch (PacketBBError &e)
{
cout << endl << "Exception: " << e.what () << endl;
return false;
}
if (newPacket.Deserialize (m_refBuffer.Begin ()) != m_refBuffer.GetSize ())
{
return false;
}
return m_refPacket == newPacket;
}
bool TestConsistency (void)
{
Buffer newBuffer;
PacketBB newPacket;
try
{
newBuffer.AddAtStart (m_refPacket.GetSerializedSize ());
m_refPacket.Serialize (newBuffer.Begin ());
newPacket.Deserialize (newBuffer.Begin ());
}
catch (PacketBBError &e)
{
cout << endl << "Exception: " << e.what () << endl;
return false;
}
return m_refPacket == newPacket;
}
private:
static bool CompareBuffers (Buffer a, Buffer b)
{
@@ -119,21 +90,23 @@ private:
const uint8_t * bbuf = b.PeekData ();
for (unsigned int i = 0; i < a.GetSize (); i++)
{
if (abuf[i] != bbuf[i])
cout << "Difference - [" << i << "] - " << (int)abuf[i] << " - " << (int)bbuf[i] << endl;
}
{
if (abuf[i] != bbuf[i])
{
cout << "Difference - [" << i << "] - " << (int)abuf[i] << " - " << (int)bbuf[i] << endl;
}
}
if (a.GetSize () != b.GetSize ())
{
cout << "Buffers differ in size: " << a.GetSize () << ", " << b.GetSize() << endl;
return false;
}
{
cout << "Buffers differ in size: " << a.GetSize () << ", " << b.GetSize() << endl;
return false;
}
if (memcmp (a.PeekData (), b.PeekData (), a.GetSize ()) != 0)
{
return false;
}
{
return false;
}
return true;
}