00001 /* 00002 * Copyright 2007 Intel Corporation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef _SESSION_H_ 00018 #define _SESSION_H_ 00019 00020 #include <oasys/debug/Formatter.h> 00021 #include <oasys/debug/Logger.h> 00022 00023 #include "Subscriber.h" 00024 #include "bundling/BundleList.h" 00025 #include "bundling/SequenceID.h" 00026 #include "naming/EndpointID.h" 00027 #include "routing/RouteEntry.h" 00028 00029 namespace oasys { 00030 class Timer; 00031 } 00032 00033 namespace dtn { 00034 00038 class Session : public oasys::Formatter, 00039 public oasys::Logger, 00040 public RouteEntryInfo 00041 { 00042 public: 00043 class ResubscribeTimer; 00044 00049 typedef enum { 00050 NONE = 0, 00051 SUBSCRIBE = 1<<1, 00052 RESUBSCRIBE = 1<<2, 00053 UNSUBSCRIBE = 1<<3, 00054 SUBSCRIPTION_ACK = 1<<4, 00055 PUBLISH = 1<<5, 00056 CUSTODY = 1<<6 00057 } flags_t; 00058 00062 static const char* flag_str(u_int flags); 00063 00064 Session(const EndpointID& eid); 00065 virtual ~Session(); 00066 00068 virtual int format(char* buf, size_t sz) const; 00069 00070 void set_upstream(const Subscriber& subscriber); 00071 void add_subscriber(const Subscriber& subscriber); 00072 void set_resubscribe_timer(oasys::Timer* t) { resubscribe_timer_ = t; } 00073 00074 u_int32_t id() const { return id_; } 00075 const EndpointID& eid() const { return eid_;} 00076 const Subscriber& upstream() const { return upstream_; } 00077 const SubscriberList& subscribers() const { return subscribers_; } 00078 BundleList* bundles() { return &bundles_; } 00079 SequenceID* sequence_id() { return &sequence_id_; } 00080 oasys::Timer* resubscribe_timer() { return resubscribe_timer_; } 00081 00082 protected: 00083 u_int32_t id_; 00084 EndpointID eid_; 00085 Subscriber upstream_; 00086 SubscriberList subscribers_; 00087 BundleList bundles_; 00088 SequenceID sequence_id_; 00089 oasys::Timer* resubscribe_timer_; 00090 }; 00091 00092 } // namespace dtn 00093 00094 #endif /* _SESSION_H_ */