|
1 /* |
|
2 * Copyright 2005-2006 Intel Corporation |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 #ifndef _DTN_SCHEME_H_ |
|
18 #define _DTN_SCHEME_H_ |
|
19 |
|
20 #include "Scheme.h" |
|
21 #include <oasys/util/Singleton.h> |
|
22 |
|
23 namespace dtn { |
|
24 |
|
25 /** |
|
26 * This class implements the one default scheme as specified in the |
|
27 * bundle protocol. SSPs for this scheme take the canonical forms: |
|
28 * |
|
29 * <code> |
|
30 * dtn://<router identifier>[/<application tag>] |
|
31 * dtn:none |
|
32 * </code> |
|
33 * |
|
34 * Where "router identifier" is a DNS-style "hostname" string, however |
|
35 * not necessarily a valid internet hostname, and "application tag" is |
|
36 * any string of URI-valid characters. |
|
37 * |
|
38 * The special endpoint identifier "dtn:none" is used to represent the |
|
39 * null endpoint. |
|
40 * |
|
41 * This implementation also supports limited wildcard matching for |
|
42 * endpoint patterns. |
|
43 */ |
|
44 class DTNScheme : public Scheme, public oasys::Singleton<DTNScheme> { |
|
45 public: |
|
46 /** |
|
47 * Validate that the SSP in the given URI is legitimate for |
|
48 * this scheme. If the 'is_pattern' paraemeter is true, then |
|
49 * the ssp is being validated as an EndpointIDPattern. |
|
50 * |
|
51 * @return true if valid |
|
52 */ |
|
53 virtual bool validate(const URI& uri, bool is_pattern = false); |
|
54 |
|
55 /** |
|
56 * Match the pattern to the endpoint id in a scheme-specific |
|
57 * manner. |
|
58 */ |
|
59 virtual bool match(const EndpointIDPattern& pattern, |
|
60 const EndpointID& eid); |
|
61 |
|
62 /** |
|
63 * Append the given service tag to the uri in a scheme-specific |
|
64 * manner. |
|
65 * |
|
66 * @return true if this scheme is capable of service tags and the |
|
67 * tag is a legal one, false otherwise. |
|
68 */ |
|
69 virtual bool append_service_tag(URI* uri, const char* tag); |
|
70 |
|
71 /** |
|
72 * Append a wildcard tag to the uri in a scheme-specific |
|
73 * manner. |
|
74 * |
|
75 * @return true if this scheme is capable of wildcards and the |
|
76 * wildcard is appended, false otherwise. |
|
77 */ |
|
78 virtual bool append_service_wildcard(URI* uri); |
|
79 |
|
80 /** |
|
81 * Reduce URI to node ID in a scheme specific manner. The default |
|
82 * scheme is not capable of this. |
|
83 * |
|
84 * @return true if this scheme is capable of this reduction and |
|
85 * the reduction is successful, else false. |
|
86 */ |
|
87 virtual bool remove_service_tag(URI* uri); |
|
88 |
|
89 /** |
|
90 * Check if the given URI is a singleton EID. |
|
91 */ |
|
92 virtual singleton_info_t is_singleton(const URI& uri); |
|
93 |
|
94 private: |
|
95 friend class oasys::Singleton<DTNScheme>; |
|
96 DTNScheme() {} |
|
97 }; |
|
98 |
|
99 } |
|
100 |
|
101 #endif /* _DTN_SCHEME_H_ */ |