nsc: move nsc glue code from nsc-tcp-l4-protocol to node/nsc-glue.cc.
known problems:
- sim_interface.h is duplicated
- nsc-glue.cc adds hooks in node.cc, "hijacks" incoming packets
- nsc-glue exports NSCs INetStack (instead of wrapping it completely)
- nsc-tcp-l4-protocol and nsc-tcp-socket-impl make calls into nsc-glue
- nsc-tcp-socket-impl should really be "nsc-socket-core" (or something
like that)
needs fixing on nsc side:
- no support for multiple interfaces yet (also not yet supported
on nsc side)
- nsc initialisation still tied to IP (Adding an Interface and assigning the
IP address is a single step; it should be separate)
maybe there is more.
There is a NSC_NEXT define in nsc-glue.h, its main purpose is to flag
the places where the NSC API needs to be adapted to support multiple
interfaces in nsc.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2008 Florian Westphal
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;
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.
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
18 * Author: Florian Westphal <fw@strlen.de>
26 #include "ns3/callback.h"
28 #include "ns3/object.h"
29 #include "ns3/net-device.h"
30 #include "ns3/timer.h"
32 #include "nsc-sysctl.h"
34 #include "sim_interface.h"
37 * silly hack to switch betwwen NSC API revisions faster during development.
38 * should be removed before erging with upstream ns3-dev.
40 #if NSC_VERSION == 0x00500
49 // IInterruptCallback and ISendCallback are NSC interfaces.
50 class NscGlue : public Object, IInterruptCallback, ISendCallback
53 static TypeId GetTypeId (void);
57 void SetNode(Ptr<Node> n);
58 void SetNscLibrary(const std::string &soname);
59 std::string GetNscLibrary () const;
61 // returns true if l3 protocol number can be handled by NSC.
62 // currently only returns true for IPv4.
63 bool IsNscProtocol (uint16_t proto);
65 // passes packet on to NSC. NSC will see the packet arriving on
67 void PassPacketToNsc (Ptr<const Packet> packet, int ifindex);
69 // used to register the L4 wakeup call:
70 // maybe it should directly be used to register individual
72 void RegisterWakeupCallback (Callback<void> cb);
74 // HACK, make this private.
75 // Socket implementations should not use m_nscStack-> methods
77 INetStack* m_nscStack;
79 // IInterruptCallback methods: wakeup and gettime.
80 // wakeup is called by the NSC stack whenever something of interest
81 // has happened, e.g. when data arrives on a socket, a listen socket
82 // has a new connection pending, etc.
83 virtual void wakeup();
85 // This is called by the Linux stack RNG initialization.
86 // Its also used by the cradle code to add a timestamp to
87 // printk/printf/debug output.
88 virtual void gettime(unsigned int *, unsigned int *);
90 // send_callback is invoked by NSCs 'ethernet driver' to re-inject
91 // a packet (i.e. an octet soup consisting of an IP Header, TCP Header
92 // and user payload, if any), into ns-3.
94 void send_callback(int idx, const void* data, unsigned int datalen);
96 void send_callback(const void* data, unsigned int datalen);
98 // internal helper. adds ipv4 addresses.
99 // XXX: rethink. This really doesn't belong here.
100 // NSC should also split up interface creation and address assignment.
103 std::list<Callback<void> > m_wakeupCallbacks;
105 void *m_dlopenHandle;
107 // called by m_softTimer
108 void SoftRtcInterrupt (void);
110 std::string m_nscLibrary;
111 Ptr<Node> m_node; // sigh...
116 #endif /* NODE_NSC_H */