| #ifndef CCNX_TUNNEL_H |
| #define CCNX_TUNNEL_H |
| |
| #include <ccnx-wrapper.h> |
| #include <string> |
| #include <boost/function.hpp> |
| #include <boost/variant.hpp> |
| #include <boost/thread/locks.hpp> |
| #include <utility> |
| #include <map> |
| |
| using namespace Sync; |
| using namespace std; |
| |
| // Eventually, Sync::CcnxWrapper should be moved to this namespace. |
| // It has nothing to do with Sync. |
| namespace Ccnx |
| { |
| |
| class CcnxTunnel : public CcnxWrapper |
| { |
| public: |
| typedef boost::variant<StringDataCallback, RawDataCallback> DataCallback; |
| typedef multimap<string, InterestCallback> RegisteredInterestTable; |
| typedef multimap<string, InterestCallback>iterator RitIter; |
| typedef boost::shared_mutex Lock; |
| typedef boost::unique_lock<Lock> WriteLock; |
| typedef boost::shared_lock<Lock> ReadLock; |
| |
| |
| CcnxTunnel(); |
| virtual ~CcnxTunnel(); |
| |
| // name is topology-independent |
| virtual int |
| publishRawData(const string &name, const char *buf, size_t len, int freshness); |
| |
| // prefix is topology-independent |
| virtual int |
| setInterestFilter(const string &prefix, const InterestCallback &interestCallback); |
| |
| // prefix is topology-independent |
| // this clears all entries with key equal to prefix |
| virtual void |
| clearInterestFilter(const string &prefix); |
| |
| // subclass should provide translation service from topology-independent name |
| // to routable name |
| virtual string |
| queryRoutableName(string &name) = 0; |
| |
| // subclass should implement the function to store ContentObject with topoloy-independent |
| // name to the permanent storage; default does nothing |
| virtual void |
| storeContentObject(string &name, ContentObjectPtr co) {} |
| |
| // should be called when connect to a different network |
| void |
| refreshLocalPrefix(); |
| |
| static bool |
| isPrefix(string &prefix, string &name); |
| |
| protected: |
| void |
| handleTunneledInterest(string tunneldInterest); |
| |
| virtual int |
| sendInterest (const std::string &strInterest, void *dataPass); |
| |
| protected: |
| // need a way to update local prefix, perhaps using macports trick, but eventually we need something more portable |
| string m_localPrefix; |
| RegisteredInterestTable m_rit; |
| Lock m_ritLock; |
| }; |
| |
| }; |
| |
| #endif |