00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifdef HAVE_CONFIG_H
00018 # include <dtn-config.h>
00019 #endif
00020
00021 #include <ctype.h>
00022 #include <oasys/debug/Log.h>
00023 #include <oasys/util/Glob.h>
00024
00025 #include "SessionScheme.h"
00026 #include "EndpointID.h"
00027
00028 namespace dtn {
00029
00030 template <>
00031 SessionScheme* oasys::Singleton<SessionScheme>::instance_ = 0;
00032
00033
00034 bool
00035 SessionScheme::validate(const URI& uri, bool is_pattern)
00036 {
00037 (void)is_pattern;
00038
00039
00040 if (!uri.valid()) {
00041 log_debug_p("/dtn/scheme/session", "SessionScheme::validate: invalid URI");
00042 return false;
00043 }
00044
00045
00046 if (is_pattern) {
00047 return true;
00048 }
00049
00050
00051 URI sub_uri(uri.ssp());
00052 if (!sub_uri.valid()) {
00053 log_debug_p("/dtn/scheme/session", "SessionScheme::validate: invalid sub URI");
00054 return false;
00055 }
00056
00057 return true;
00058 }
00059
00060
00061 bool
00062 SessionScheme::match(const EndpointIDPattern& pattern, const EndpointID& eid)
00063 {
00064
00065 ASSERT(pattern.scheme() == this);
00066
00067
00068 if (!eid.known_scheme() || (eid.scheme() != this)) {
00069 return false;
00070 }
00071
00072
00073 if (oasys::Glob::fixed_glob(pattern.uri().ssp().c_str(),
00074 eid.uri().ssp().c_str()))
00075 {
00076 log_debug_p("/dtn/scheme/session", "match(%s, %s) success",
00077 eid.uri().c_str(), pattern.uri().c_str());
00078 return true;
00079 }
00080 else
00081 {
00082 log_debug_p("/dtn/scheme/session", "match(%s, %s) failed",
00083 eid.uri().c_str(), pattern.uri().c_str());
00084 return false;
00085 }
00086 }
00087
00088
00089 Scheme::singleton_info_t
00090 SessionScheme::is_singleton(const URI& uri)
00091 {
00092 (void)uri;
00093
00094 return EndpointID::SINGLETON;
00095 }
00096
00097 }