blob: 35aeab88f8b2c2691c1461ae8f80d572fb446594 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
21#ifndef _CCNX_HEADER_HELPER_H_
22#define _CCNX_HEADER_HELPER_H_
23
24#include "ns3/ptr.h"
25
26namespace ns3
27{
28
29class Header;
30class Packet;
31
32/**
33 * Class implementing functionality to detect CCNx packet type and
34 * create the corresponding object
35 *
36 * CCNx doesn't really have a header, so we need this class to
37 * determine type of CCNx packet and return corresponent header class,
38 * CcnxInterestHeader or CcnxContentObjectHeader
39 *
40 * Throws CcnxUnknownHeaderException if header type couldn't be determined
41 */
42class CcnxHeaderHelper
43{
44public:
45
46 /**
47 * Static function to create an appropriate CCNx header
48 *
49 * It peeks first 2 bytes of a packet.
50 *
51 * All interests start with
52 * +-----------------+ +---+---------+-------+
53 * | 0 0 0 0 0 0 0 1 | | 1 | 1 0 1 0 | 0 1 0 | (0x01 0xD2)
54 * +-----------------+ +---+---------+-------+
55 *
56 * All content objects start with
57 * +-----------------+ +---+---------+-------+
58 * | 0 0 0 0 0 1 0 0 | | 1 | 0 0 0 0 | 0 1 0 | (0x04 0x82)
59 * +-----------------+ +---+---------+-------+
60 * ^ ^^^^^
61 * | |
62 * terminator DTAG (Dictionary TAG)
63 *
64 * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
65 */
66
67 static Ptr<Header>
68 CreateCorrectCcnxHeader (Ptr<const Packet> packet);
69};
70
71class CcnxUnknownHeaderException {};
72
73} // namespace ns3
74
75#endif // _CCNX_HEADER_HELPER_H_