blob: e0a6aedb006ad9d354c32e515f52b26956e52878 [file] [log] [blame]
Alexander Afanasyev08d984e2011-08-13 19:20:22 -07001// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
2//
3// Copyright (c) 2006 Georgia Tech Research Corporation
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#ifndef CCNX_L4_PROTOCOL_H
22#define CCNX_L4_PROTOCOL_H
23
24#include "ns3/object.h"
25#include "ns3/callback.h"
26#include "ns3/ccnx-interest-header.h"
27#include "ns3/ccnx-content-object-header.h"
28
29namespace ns3 {
30
31class Packet;
32class CcnxInterface;
33class CcnxRoute;
34
35/**
36 * \brief Actual implementation of CCNx protocol
37 */
38class CcnxL4Protocol : public Object
39{
40public:
41 enum RxStatus {
42 RX_OK,
43
44 // RX_CSUM_FAILED,
45 // RX_ENDPOINT_CLOSED,
46 // RX_ENDPOINT_UNREACH
47 };
48
49 static TypeId GetTypeId (void);
50
Alexander Afanasyev98256102011-08-14 01:00:02 -070051 CcnxL4Protocol ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070052 virtual ~CcnxL4Protocol ();
53
Alexander Afanasyev98256102011-08-14 01:00:02 -070054 void SetNode (Ptr<Node> node);
55
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070056 /**
57 * \param p packet to forward up
58 * \param header Ccnx Header information
59 * \param incomingInterface the CcnxInterface on which the packet arrived
60 *
61 * Called from lower-level layers to send the packet up
62 * in the stack.
63 */
64 virtual enum RxStatus Receive (Ptr<Packet> p,
65 CcnxHeader const &header,
Alexander Afanasyev98256102011-08-14 01:00:02 -070066 Ptr<CcnxInterface> incomingInterface);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070067
68 typedef Callback<void,Ptr<Packet>, Ptr<CcnxRoute> > DownTargetCallback;
69 /**
70 * This method allows a caller to set the current down target callback
71 * set for this L4 protocol
72 *
73 * \param cb current Callback for the L4 protocol
74 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070075 virtual void SetDownTarget (DownTargetCallback cb);
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070076 /**
77 * This method allows a caller to get the current down target callback
78 * set for this L4 protocol, for
79 *
80 * \return current Callback for the L4 protocol
81 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070082 virtual DownTargetCallback GetDownTarget (void) const;
83
84protected:
85 virtual void DoDispose (void);
86 /*
87 * This function will notify other components connected to the node that a new stack member is now connected
88 * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
89 */
90 virtual void NotifyNewAggregate ();
91
92private:
93 DownTargetCallback m_downTarget;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070094};
95
96} // Namespace ns3
97
98#endif // CCNX_L4_PROTOCOL_H