blob: 72d030ce373e044788502438c830172102e9bd79 [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/**
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070033 * \ingroup ccnx-helpers
34 *
35 * \brief Class implementing functionality to detect CCNx packet type and
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070036 * create the corresponding object
37 *
38 * CCNx doesn't really have a header, so we need this class to
39 * determine type of CCNx packet and return corresponent header class,
40 * CcnxInterestHeader or CcnxContentObjectHeader
41 *
42 * Throws CcnxUnknownHeaderException if header type couldn't be determined
43 */
44class CcnxHeaderHelper
45{
46public:
47
48 /**
49 * Static function to create an appropriate CCNx header
50 *
51 * It peeks first 2 bytes of a packet.
52 *
53 * All interests start with
54 * +-----------------+ +---+---------+-------+
55 * | 0 0 0 0 0 0 0 1 | | 1 | 1 0 1 0 | 0 1 0 | (0x01 0xD2)
56 * +-----------------+ +---+---------+-------+
57 *
58 * All content objects start with
59 * +-----------------+ +---+---------+-------+
60 * | 0 0 0 0 0 1 0 0 | | 1 | 0 0 0 0 | 0 1 0 | (0x04 0x82)
61 * +-----------------+ +---+---------+-------+
62 * ^ ^^^^^
63 * | |
64 * terminator DTAG (Dictionary TAG)
65 *
66 * \see http://www.ccnx.org/releases/latest/doc/technical/BinaryEncoding.html
67 */
68
69 static Ptr<Header>
70 CreateCorrectCcnxHeader (Ptr<const Packet> packet);
71};
72
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070073 /**
74 * \ingroup ccnx
75 * \defgroup ccnx-exceptions Exceptions
76 */
77 /**
78 * \ingroup ccnx-exceptions
79 * \brief Exception thrown if CCNx stack receives unrecognized
80 * message type
81 */
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070082class CcnxUnknownHeaderException {};
83
84} // namespace ns3
85
86#endif // _CCNX_HEADER_HELPER_H_