1.1 --- a/src/common/packet.h Mon Jun 02 10:38:19 2008 -0700
1.2 +++ b/src/common/packet.h Mon Jun 02 10:51:55 2008 -0700
1.3 @@ -42,7 +42,7 @@
1.4 {
1.5 public:
1.6 /**
1.7 - * Identifies a set tag and a set of bytes within a packet
1.8 + * Identifies a tag and a set of bytes within a packet
1.9 * to which the tag applies.
1.10 */
1.11 class Item
2.1 --- a/src/common/pcap-writer.h Mon Jun 02 10:38:19 2008 -0700
2.2 +++ b/src/common/pcap-writer.h Mon Jun 02 10:51:55 2008 -0700
2.3 @@ -51,17 +51,35 @@
2.4
2.5 /**
2.6 * Write a pcap header in the output file which specifies
2.7 - * that the content of the file will Packets with
2.8 + * that the content of the file will be Packets with
2.9 * Ethernet/LLC/SNAP encapsulation. This method should
2.10 * be invoked before ns3::PcapWriter::writePacket and after
2.11 * ns3::PcapWriter::open.
2.12 */
2.13 void WriteEthernetHeader (void);
2.14
2.15 + /**
2.16 + * Write a pcap header in the output file which specifies
2.17 + * that the content of the file will be IPv4 Packets. This
2.18 + * method should be invoked before ns3::PcapWriter::WritePacket
2.19 + * and after ns3::PcapWriter::Open.
2.20 + */
2.21 void WriteIpHeader (void);
2.22
2.23 + /**
2.24 + * Write a pcap header in the output file which specifies
2.25 + * that the content of the file will be 802.11 Packets. This
2.26 + * method should be invoked before ns3::PcapWriter::WritePacket
2.27 + * and after ns3::PcapWriter::Open.
2.28 + */
2.29 void WriteWifiHeader (void);
2.30
2.31 + /**
2.32 + * Write a pcap header in the output file which specifies
2.33 + * that the content of the file will be ppp Packets. This
2.34 + * method should be invoked before ns3::PcapWriter::WritePacket
2.35 + * and after ns3::PcapWriter::Open.
2.36 + */
2.37 void WritePppHeader (void);
2.38
2.39 /**
3.1 --- a/src/common/tag-buffer.h Mon Jun 02 10:38:19 2008 -0700
3.2 +++ b/src/common/tag-buffer.h Mon Jun 02 10:51:55 2008 -0700
3.3 @@ -38,28 +38,106 @@
3.4 * \brief read and write tag data
3.5 *
3.6 * This class allows subclasses of the ns3::Tag base class
3.7 - * to serialize and deserialize their data.
3.8 + * to serialize and deserialize their data through a stream-like
3.9 + * API. This class keeps track of the "current" point in the
3.10 + * buffer and advances that "current" point everytime data is
3.11 + * written. The in-memory format of the data written by
3.12 + * this class is unspecified.
3.13 + *
3.14 + * If the user attempts to write more data in the buffer than
3.15 + * he allocated with Tag::GetSerializedSize, he will trigger
3.16 + * an NS_ASSERT error.
3.17 */
3.18 class TagBuffer
3.19 {
3.20 public:
3.21 TagBuffer (uint8_t *start, uint8_t *end);
3.22 void TrimAtEnd (uint32_t trim);
3.23 + void CopyFrom (TagBuffer o);
3.24
3.25 + /**
3.26 + * \param v the value to write
3.27 + *
3.28 + * Write one byte and advance the "current" point by one.
3.29 + */
3.30 TAG_BUFFER_INLINE void WriteU8 (uint8_t v);
3.31 + /**
3.32 + * \param v the value to write
3.33 + *
3.34 + * Write two bytes and advance the "current" point by two.
3.35 + */
3.36 TAG_BUFFER_INLINE void WriteU16 (uint16_t v);
3.37 + /**
3.38 + * \param v the value to write
3.39 + *
3.40 + * Write four bytes and advance the "current" point by four.
3.41 + */
3.42 TAG_BUFFER_INLINE void WriteU32 (uint32_t v);
3.43 + /**
3.44 + * \param v the value to write
3.45 + *
3.46 + * Write eight bytes and advance the "current" point by eight.
3.47 + */
3.48 void WriteU64 (uint64_t v);
3.49 + /**
3.50 + * \param v the value to write
3.51 + *
3.52 + * Write a double and advance the "current" point by the size of the
3.53 + * data written.
3.54 + */
3.55 void WriteDouble (double v);
3.56 + /**
3.57 + * \param buffer a pointer to data to write
3.58 + * \param size the size of the data to write
3.59 + *
3.60 + * Write all the input data and advance the "current" point by the size of the
3.61 + * data written.
3.62 + */
3.63 void Write (const uint8_t *buffer, uint32_t size);
3.64 + /**
3.65 + * \returns the value read
3.66 + *
3.67 + * Read one byte, advance the "current" point by one,
3.68 + * and return the value read.
3.69 + */
3.70 TAG_BUFFER_INLINE uint8_t ReadU8 (void);
3.71 + /**
3.72 + * \returns the value read
3.73 + *
3.74 + * Read two bytes, advance the "current" point by two,
3.75 + * and return the value read.
3.76 + */
3.77 TAG_BUFFER_INLINE uint16_t ReadU16 (void);
3.78 + /**
3.79 + * \returns the value read
3.80 + *
3.81 + * Read four bytes, advance the "current" point by four,
3.82 + * and return the value read.
3.83 + */
3.84 TAG_BUFFER_INLINE uint32_t ReadU32 (void);
3.85 + /**
3.86 + * \returns the value read
3.87 + *
3.88 + * Read eight bytes, advance the "current" point by eight,
3.89 + * and return the value read.
3.90 + */
3.91 uint64_t ReadU64 (void);
3.92 + /**
3.93 + * \returns the value read
3.94 + *
3.95 + * Read a double, advance the "current" point by the size
3.96 + * of the data read, and, return the value read.
3.97 + */
3.98 double ReadDouble (void);
3.99 + /**
3.100 + * \param buffer a pointer to the buffer where data should be
3.101 + * written.
3.102 + * \param size the number of bytes to read.
3.103 + *
3.104 + * Read the number of bytes requested, advance the "current"
3.105 + * point by the number of bytes read, return.
3.106 + */
3.107 void Read (uint8_t *buffer, uint32_t size);
3.108 -
3.109 - void CopyFrom (TagBuffer o);
3.110 private:
3.111
3.112 uint8_t *m_current;
4.1 --- a/src/common/tag.h Mon Jun 02 10:38:19 2008 -0700
4.2 +++ b/src/common/tag.h Mon Jun 02 10:51:55 2008 -0700
4.3 @@ -49,12 +49,16 @@
4.4 * \param i the buffer to write data into.
4.5 *
4.6 * Write the content of the tag in the provided tag buffer.
4.7 + * DO NOT attempt to write more bytes than you requested
4.8 + * with Tag::GetSerializedSize.
4.9 */
4.10 virtual void Serialize (TagBuffer i) const = 0;
4.11 /**
4.12 * \param i the buffer to read data from.
4.13 *
4.14 * Read the content of the tag from the provided tag buffer.
4.15 + * DO NOT attempt to read more bytes than you wrote with
4.16 + * Tag::Serialize.
4.17 */
4.18 virtual void Deserialize (TagBuffer i) = 0;
4.19 };