blob: 553beb35ed6b238da0209cfe18781882132cdacb [file] [log] [blame]
Alexander Afanasyev834f35c2011-08-16 17:13:50 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author:
19 */
20
21#include "ccnx-decoding-helper.h"
22
Alexander Afanasyev8b379052011-08-21 16:58:20 -070023// #include "ns3/ccnx-interest-header.h"
24// #include "ns3/ccnx-content-object-header.h"
Alexander Afanasyev834f35c2011-08-16 17:13:50 -070025
26namespace ns3 {
27
Alexander Afanasyev834f35c2011-08-16 17:13:50 -070028size_t
29CcnxDecodingHelper::Deserialize (Buffer::Iterator start, const CcnxInterestHeader &interest)
30{
Alexander Afanasyev8b379052011-08-21 16:58:20 -070031 static InterestVisitor interestVisitor;
32
Alexander Afanasyev834f35c2011-08-16 17:13:50 -070033 Buffer::Iterator i = start;
34 Ptr<CcnxParser::Block> root = CcnxParser::Block::ParseBlock (i);
Alexander Afanasyev8b379052011-08-21 16:58:20 -070035 root->accept (interestVisitor, interest);
Alexander Afanasyev834f35c2011-08-16 17:13:50 -070036
37 return i.GetDistanceFrom (start);
38}
39
40size_t
41CcnxDecodingHelper::Deserialize (Buffer::Iterator start, const CcnxContentObjectHeader &contentObject)
42{
Alexander Afanasyev8b379052011-08-21 16:58:20 -070043 static ContentObjectVisitor contentObjectVisitor;
44
Alexander Afanasyev834f35c2011-08-16 17:13:50 -070045 Buffer::Iterator i = start;
46 Ptr<CcnxParser::Block> root = CcnxParser::Block::ParseBlock (i);
Alexander Afanasyev8b379052011-08-21 16:58:20 -070047 root->accept (contentObjectVisitor, contentObject);
Alexander Afanasyev834f35c2011-08-16 17:13:50 -070048
49 return i.GetDistanceFrom (start);
50}
51
Alexander Afanasyev834f35c2011-08-16 17:13:50 -070052} // namespace ns3