Junxiao Shi | d6dcd2c | 2014-02-16 14:49:54 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_FACE_NDNLP_PARSE_HPP |
| 8 | #define NFD_FACE_NDNLP_PARSE_HPP |
| 9 | |
| 10 | #include "common.hpp" |
| 11 | #include "ndnlp-tlv.hpp" |
| 12 | |
| 13 | namespace nfd { |
| 14 | namespace ndnlp { |
| 15 | |
| 16 | struct ParseError : public std::runtime_error |
| 17 | { |
| 18 | ParseError(const std::string& what) |
| 19 | : std::runtime_error(what) |
| 20 | { |
| 21 | } |
| 22 | }; |
| 23 | |
| 24 | /** \brief represents a NdnlpData packet |
| 25 | * |
| 26 | * NdnlpData ::= NDNLP-DATA-TYPE TLV-LENGTH |
| 27 | * NdnlpSequence |
| 28 | * NdnlpFragIndex? |
| 29 | * NdnlpFragCount? |
| 30 | * NdnlpPayload |
| 31 | */ |
| 32 | class NdnlpData |
| 33 | { |
| 34 | public: |
| 35 | /** \brief parse a NdnlpData packet |
| 36 | * |
| 37 | * \exception ParseError packet is malformated |
| 38 | */ |
| 39 | void |
| 40 | wireDecode(const Block& wire); |
| 41 | |
| 42 | public: |
| 43 | uint64_t m_seq; |
| 44 | uint16_t m_fragIndex; |
| 45 | uint16_t m_fragCount; |
| 46 | Block m_payload; |
| 47 | }; |
| 48 | |
| 49 | } // namespace ndnlp |
| 50 | } // namespace nfd |
| 51 | |
| 52 | #endif // NFD_FACE_NDNLP_PARSE_HPP |