After discovering the location of an RD, a registrant-EP or CT
MAY register the resources of the registrant-EP using the registration interface. This interface accepts a POST from an endpoint containing the list of resources to be added to the directory as the message payload in the CoRE Link Format [
RFC 6690] or other representations of web links, along with query parameters indicating the name of the endpoint and, optionally, the sector, lifetime, and base URI of the registration. It is expected that other specifications will define further parameters (see
Section 9.3). The RD then creates a new registration resource in the RD and returns its location. The receiving endpoint
MUST use that location when refreshing registrations using this interface. Registration resources in the RD are kept active for the period indicated by the lifetime parameter. The creating endpoint is responsible for refreshing the registration resource within this period, using either the registration or update interface. The registration interface
MUST be implemented to be idempotent, so that registering twice with the same endpoint parameters ep and d (sector) does not create multiple registration resources.
The following rules apply for a registration request targeting a given (ep, d) value pair:
-
When the (ep, d) value pair of the registration request is different from any existing registration, a new registration is generated.
-
When the (ep, d) value pair of the registration request is equal to an existing registration, the content and parameters of the existing registration are replaced with the content of the registration request. As with changes to registration resources, security policies (Section 7) usually require such requests to come from the same device.
The posted link-format document can (and typically does) contain relative references both in its link targets and in its anchors; it can also contain empty anchors. The RD server needs to resolve these references in order to faithfully represent them in lookups. They are resolved against the base URI of the registration, which is provided either explicitly in the
base parameter or constructed implicitly from the requester's URI, as constructed from its network address and scheme.
For media types to which
Appendix C applies (i.e., documents in
application/link-format), request bodies
MUST be expressed in Limited Link Format.
The registration request interface is specified as follows:
-
Interaction:
-
EP or CT -> RD
-
Method:
-
POST
-
URI Template:
-
{+rd}{?ep,d,lt,base,extra-attrs*}
-
URI Template Variables:
-
-
rd :=
-
RD registration URI (mandatory). This is the location of the RD, as obtained from discovery.
-
ep :=
-
Endpoint name (mostly mandatory). The endpoint name is an identifier that MUST be unique within a sector.
As the endpoint name is a Unicode string, it is encoded in UTF-8 (and possibly percent encoded) during variable expansion (see RFC 6570, Section 3.2.1). The endpoint name MUST NOT contain any character in the inclusive ranges 0-31 or 127-159.
The maximum length of this parameter is 63 bytes encoded in UTF-8.
If the RD is configured to recognize the endpoint that is to be authorized to use exactly one endpoint name, the RD assigns that name. In that case, giving the endpoint name becomes optional for the client; if the client gives any other endpoint name, it is not authorized to perform the registration.
-
d :=
-
Sector (optional). This is the sector to which this endpoint belongs. When this parameter is not present, the RD MAY associate the endpoint with a configured default sector (possibly based on the endpoint's authorization) or leave it empty.
The sector is encoded like the ep parameter and is limited to 63 bytes encoded in UTF-8 as well.
-
lt :=
-
Lifetime (optional). This is the lifetime of the registration in seconds, with a range of 1-4294967295. If no lifetime is included in the initial registration, a default value of 90000 (25 hours) SHOULD be assumed.
-
base :=
-
Base URI (optional). This parameter sets the base URI of the registration, under which the relative links in the payload are to be interpreted. The specified URI typically does not have a path component of its own and MUST be suitable as a base URI to resolve any relative references given in the registration. The parameter is therefore usually of the shape "scheme://authority" for HTTP and CoAP URIs. The URI SHOULD NOT have a query or fragment component, as any non-empty relative part in a reference would remove those parts from the resulting URI.
In the absence of this parameter, the scheme of the protocol, the source address, and the source port of the registration request are assumed. The base URI is consecutively constructed by concatenating the used protocol's scheme with the characters "://", the requester's source address as an address literal, and ":" followed by its port (if it was not the protocol's default one). This is analogous to the process described in RFC 7252, Section 6.5.
This parameter is mandatory when the directory is filled by a third party, such as a commissioning tool.
If the registrant-EP uses an ephemeral port to register with, it MUST include the base parameter in the registration to provide a valid network path.
A registrant that cannot be reached by potential lookup clients at the address it registers from (e.g., because it is behind some form of Network Address Translation (NAT)) MUST provide a reachable base address with its registration.
If the base URI contains a link-local IP literal, it MUST NOT contain a Zone Identifier and MUST be local to the link on which the registration request is received.
Endpoints that register with a base that contains a path component cannot efficiently express their registrations in Limited Link Format (Appendix C). Those applications should use different representations of links to which Appendix C is not applicable (e.g., [CORE-CORAL]).
-
extra-attrs :=
-
Additional registration attributes (optional). The endpoint can pass any parameter registered in Section 9.3 to the directory. If the RD is aware of the parameter's specified semantics, it processes the parameter accordingly. Otherwise, it MUST store the unknown key and its value(s) as an endpoint attribute for further lookup.
-
Content-Format:
-
application/link-format or any other indicated media type representing web links
The following response is expected on this interface:
-
Success:
-
2.01 (Created) or 201 (Created). The Location-Path option or Location header field MUST be included in the response. This location MUST be a stable identifier generated by the RD, as it is used for all subsequent operations on this registration resource. The registration resource location thus returned is for the purpose of updating the lifetime of the registration and for maintaining the content of the registered links, including updating and deleting links.
A registration with an already-registered ep and d value pair responds with the same success code and location as the original registration; the set of links registered with the endpoint is replaced with the links from the payload.
The location MUST NOT have a query or fragment component, as that could conflict with query parameters during the registration update operation. Therefore, the Location-Query option MUST NOT be present in a successful response.
If the registration fails, including request timeouts, or if delays from Service Unavailable responses with Max-Age or Retry-After accumulate to exceed the registrant's configured timeouts, it
SHOULD pick another registration URI from the "URI discovery" step of
Section 4.3, and, if there is only one or the list is exhausted, pick other choices from the "finding a resource directory" step of
Section 4.1. Care has to be taken to consider the freshness of results obtained earlier, e.g., the result of a
/.well-known/core response, the lifetime of an RDAO, and DNS responses. Any rate limits and persistent errors from the "finding a resource directory" step must be considered for the whole registration time, not only for a single operation.
The following example shows a registrant-EP with the name "node1" registering two resources to an RD using this interface. The location "/rd" is an example RD location discovered in a request similar to
Figure 5.
Req: POST coap://rd.example.com/rd?ep=node1
Content-Format: 40
Payload:
</sensors/temp>;rt=temperature-c;if=sensor,
<http://www.example.com/sensors/temp>;
anchor="/sensors/temp";rel=describedby
Res: 2.01 Created
Location-Path: /rd/4521
An RD may optionally support HTTP. Here is an example of almost the same registration operation above when done using HTTP.
Req:
POST /rd?ep=node1&base=http://[2001:db8:1::1] HTTP/1.1
Host: rd.example.com
Content-Type: application/link-format
</sensors/temp>;rt=temperature-c;if=sensor,
<http://www.example.com/sensors/temp>;
anchor="/sensors/temp";rel=describedby
Res:
HTTP/1.1 201 Created
Location: /rd/4521
Not all endpoints hosting resources are expected to know how to upload links to an RD, as described in
Section 5. Instead, simple endpoints can implement the simple registration approach described in this section. An RD implementing this specification
MUST implement simple registration. However, there may be security reasons why this form of directory discovery would be disabled.
This approach requires that the registrant-EP makes available the hosted resources that it wants to be discovered as links on its
/.well-known/core interface, as specified in [
RFC 6690]. The links in that document are subject to the same limitations as the payload of a registration (with respect to
Appendix C).
-
The registrant-EP finds one or more addresses of the directory server, as described in Section 4.1.
-
The registrant-EP sends (and regularly refreshes with) a POST request to the /.well-known/rd URI of the directory server of choice. The body of the POST request is empty and triggers the resource directory server to perform GET requests (redone before lifetime expiry) at the requesting registrant-EP's /.well-known/core to obtain the link-format payload to register.
The registrant-EP includes the same registration parameters in the POST request as it would with a regular registration, per Section 5. The registration base URI of the registration is taken from the registrant-EP's network address (as is default with regular registrations).
The following is an example request from the registrant-EP to the RD (unanswered until the next step):
Req: POST /.well-known/rd?lt=6000&ep=node1
(No payload)
-
The RD queries the registrant-EP's discovery resource to determine the success of the operation. It SHOULD keep a cache of the discovery resource and not query it again as long as it is fresh.
The following is an example request from the RD to the registrant-EP:
Req: GET /.well-known/core
Accept: 40
Res: 2.05 Content
Content-Format: 40
Payload:
</sen/temp>
With this response, the RD would answer the previous step's request:
The sequence of fetching the registration content before sending a successful response was chosen to make responses reliable, and the point about caching was chosen to still allow very constrained registrants. Registrants
MUST be able to serve a GET request to
/.well-known/core after having requested registration. Constrained devices
MAY regard the initial request as temporarily failed when they need RAM occupied by their own request to serve the RD's GET and retry later when the RD already has a cached representation of their discovery resources. Then, the RD can reply immediately, and the registrant can receive the response.
The simple registration request interface is specified as follows:
-
Interaction:
-
EP -> RD
-
Method:
-
POST
-
URI Template:
-
/.well-known/rd{?ep,d,lt,extra-attrs*}
URI Template Variables are the same as for registration in
Section 5. The base attribute is not accepted to keep the registration interface simple; that rules out registration over CoAP-over-TCP or HTTP that would need to specify one. For some time during this document's development, the URI Template
/.well-known/core{?ep,...} was in use instead.
The following response is expected on this interface:
For the second interaction triggered by the above, the registrant-EP takes the role of server and the RD takes the role of client. (Note that this is exactly the well-known interface of
RFC 6690,
Section 4):
-
Interaction:
-
RD -> EP
-
Method:
-
GET
-
URI Template:
-
/.well-known/core
The following response is expected on this interface:
When the RD uses any authorization credentials to access the endpoint's discovery resource or when it is deployed in a location where third parties might reach it but not the endpoint, it
SHOULD verify that the apparent registrant-EP intends to register with the given registration parameters before revealing the obtained discovery information to lookup clients. An easy way to do that is to verify the simple registration request's sender address using the Echo option, as described in
RFC 9175,
Section 2.4.
The RD
MUST delete registrations created by simple registration after the expiration of their lifetime. Additional operations on the registration resource cannot be executed because no registration location is returned.
For some applications, even simple registration may be too taxing for some very constrained devices, in particular, if the security requirements become too onerous.
In a controlled environment (e.g., building control), the RD can be filled by a third-party device, called a Commissioning Tool (CT). The CT can fill the RD from a database or other means. For that purpose scheme, the IP address and port of the URI of the registered device is the value of the "base" parameter of the registration described in
Section 5.
It should be noted that the value of the "base" parameter applies to all the links of the registration and has consequences for the anchor value of the individual links, as exemplified in
Appendix B. A potential (currently nonexistent) "base" attribute of the link is not affected by the value of "base" parameter in the registration.
This section describes how the registering endpoint can maintain the registrations that it created. The registering endpoint can be the registrant-EP or the CT. The registrations are resources of the RD.
An endpoint should not use this interface for registrations that it did not create. This is usually enforced by security policies, which, in general, require equivalent credentials for creation of and operations on a registration.
After the initial registration, the registering endpoint retains the returned location of the registration resource for further operations, including refreshing the registration in order to extend the lifetime and "keep-alive" the registration. When the lifetime of the registration has expired, the RD
SHOULD NOT respond to discovery queries concerning this endpoint. The RD
SHOULD continue to provide access to the registration resource after a registration timeout occurs in order to enable the registering endpoint to eventually refresh the registration. The RD
MAY eventually remove the registration resource for the purpose of garbage collection. If the registration resource is removed, the corresponding endpoint will need to be reregistered.
The registration resource may also be used to cancel the registration using DELETE and to perform further operations beyond the scope of this specification.
Operations on the registration resource are sensitive to reordering;
Section 5.3.4 describes how order is restored.
The operations on the registration resource are described below.
The update interface is used by the registering endpoint to refresh or update its registration with an RD. To use the interface, the registering endpoint sends a POST request to the registration resource returned by the initial registration operation.
An update
MAY update registration parameters, such as lifetime, base URI, or others. Parameters that are not being changed should not be included in an update. Adding parameters that have not changed increases the size of the message but does not have any other implications. Parameters are included as query parameters in an update operation, as in
Section 5.
A registration update resets the timeout of the registration to the (possibly updated) lifetime of the registration, independent of whether an
lt parameter was given.
If the base URI of the registration is changed in an update, relative references submitted in the original registration or later updates are resolved anew against the new base.
The registration update operation only describes the use of POST with an empty payload. Future standards might describe the semantics of using content formats and payloads with the POST method to update the links of a registration (see
Section 5.3.3).
The update registration request interface is specified as follows:
-
Interaction:
-
EP or CT -> RD
-
Method:
-
POST
-
URI Template:
-
{+location}{?lt,base,extra-attrs*}
-
URI Template Variables:
-
-
location :=
-
This is the location returned by the RD as a result of a successful earlier registration.
-
lt :=
-
Lifetime (optional). This is the lifetime of the registration in seconds, with a range of 1-4294967295. If no lifetime is included, the previous last lifetime set on a previous update or the original registration (falling back to 90000) SHOULD be used.
-
base :=
-
Base URI (optional). This parameter updates the base URI established in the original registration to a new value and is subject to the same restrictions as in the registration.
If the parameter is set in an update, it is stored by the RD as the new base URI under which to interpret the relative links present in the payload of the original registration.
If the parameter is not set in the request but was set before, the previous base URI value is kept unmodified.
If the parameter is not set in the request and was not set before either, the source address and source port of the update request are stored as the base URI.
-
extra-attrs :=
-
Additional registration attributes (optional). As with the registration, the RD processes them if it knows their semantics. Otherwise, unknown attributes are stored as endpoint attributes, overriding any previously stored endpoint attributes of the same key.
Note that this default behavior does not allow removing an endpoint attribute in an update. For attributes whose functionality depends on the endpoints' ability to remove them in an update, it can make sense to define a value whose presence is equivalent to the absence of a value. As an alternative, an extension can define different updating rules for their attributes. That necessitates either discovering whether the RD is aware of that extension or tolerating the default behavior.
-
Content-Format:
-
none (no payload)
The following responses are expected on this interface:
-
Success:
-
2.04 (Changed) or 204 (No Content) if the update was successfully processed.
-
Failure:
-
4.04 (Not Found) or 404 (Not Found). Registration does not exist (e.g., may have been removed).
If the registration update fails in any way, including "Not Found" and request timeouts, or if the time indicated in a Service Unavailable Max-Age/Retry-After exceeds the remaining lifetime, the registering endpoint
SHOULD attempt registration again.
The following example shows how the registering endpoint resets the timeout on its registration resource at an RD using this interface with the example location value /rd/4521:
Req: POST /rd/4521
Res: 2.04 Changed
The following example shows the registering endpoint updating its registration resource at an RD using this interface with the example location value /rd/4521. The initial registration by the registering endpoint set the following values:
-
endpoint name (ep)=endpoint1
-
lifetime (lt)=500
-
base URI (base)=coap://local-proxy-old.example.com
-
payload of Figure 8
The initial state of the RD is reflected in the following request:
Req: GET /rd-lookup/res?ep=endpoint1
Res: 2.05 Content
Payload:
<coap://local-proxy-old.example.com/sensors/temp>;
rt=temperature-c;if=sensor,
<http://www.example.com/sensors/temp>;
anchor="coap://local-proxy-old.example.com/sensors/temp";
rel=describedby
The following example shows the registering endpoint changing the base URI to
coaps://new.example.com:5684:
Req: POST /rd/4521?base=coaps://new.example.com
Res: 2.04 Changed
The consecutive query returns:
Req: GET /rd-lookup/res?ep=endpoint1
Res: 2.05 Content
Payload:
<coaps://new.example.com/sensors/temp>;
rt=temperature-c;if=sensor,
<http://www.example.com/sensors/temp>;
anchor="coaps://new.example.com/sensors/temp";
rel=describedby
Although RD registrations have soft state and will eventually time out after their lifetime, the registering endpoint
SHOULD explicitly remove an entry from the RD if it knows it will no longer be available (for example, on shutdown). This is accomplished using a removal interface on the RD by performing a DELETE on the endpoint resource.
The removal request interface is specified as follows:
-
Interaction:
-
EP or CT -> RD
-
Method:
-
DELETE
-
URI Template:
-
{+location}
-
URI Template Variables:
-
-
location :=
-
This is the location returned by the RD as a result of a successful earlier registration.
The following responses are expected on this interface:
-
Success:
-
2.02 (Deleted) or 204 (No Content) upon successful deletion.
-
Failure:
-
4.04 (Not Found) or 404 (Not Found). Registration does not exist (e.g., may already have been removed).
The following example shows successful removal of the endpoint from the RD with example location value /rd/4521:
Req: DELETE /rd/4521
Res: 2.02 Deleted
Additional operations on the registration can be specified in future documents, for example:
-
Send iPATCH (or PATCH) updates [RFC 8132] to add, remove, or change the links of a registration.
-
Use GET to read the currently stored set of links in a registration resource.
Those operations are out of scope of this document and will require media types suitable for modifying sets of links.
Some security mechanisms usable with an RD allow out-of-order request processing or do not even mandate replay protection at all. The RD needs to ensure that operations on the registration resource are executed in an order that does not distort the client's intentions.
This ordering of operations is expressed in terms of freshness, as defined in [
RFC 9175]. Requests that alter a resource's state need to be fresh relative to the latest request that altered that state in a conflicting way.
An RD
SHOULD determine a request's freshness and
MUST use the Echo option if it requires request freshness and cannot determine it in any other way. An endpoint
MUST support the use of the Echo option. (One reason why an RD would not require freshness is when no relevant registration properties are covered by its security policies.)
To keep latency and traffic added by the freshness requirements to a minimum, RDs should avoid naive (sufficient but inefficient) freshness criteria.
Some simple mechanisms the RD can employ are:
-
State counter. The RD can keep a monotonous counter that increments whenever a registration changes. For every registration resource, it stores the post-increment value of that resource's last change. Requests altering them need to have at least that value encoded in their Echo option and are otherwise rejected with a 4.01 (Unauthorized) and the current counter value as the Echo value. If other applications on the same server use Echo as well, that encoding may include a prefix indicating that it pertains to the RD's counter.
The value associated with a resource needs to be kept across the removal of registrations if the same registration resource is to be reused.
The counter can be reset (and the values of removed resources forgotten) when all previous security associations are reset.
This is the "Persistent Counter" method of RFC 9175, Appendix A.
-
Preemptive Echo values. The current state counter can be sent in an Echo option not only when requests are rejected with 4.01 (Unauthorized) but also with successful responses. Thus, clients can be provided with Echo values sufficient for their next request on a regular basis. This is also described in Section 2.3 of RFC 9175
While endpoints may discard received Echo values at leisure between requests, they are encouraged to retain these values for the next request to avoid additional round trips.
-
If the RD can ensure that only one security association has modifying access to any registration at any given time and that security association provides order on the requests, that order is sufficient to show request freshness.
Figure 18 shows the interactions of an endpoint that has forgotten the server's latest Echo value and temporarily reduces its registration lifetime:
Req: POST /rd/4521?lt=7200
Res: 4.01 Unauthorized
Echo: 0x0123
(EP tries again immediately.)
Req: POST /rd/4521?lt=7200
Echo: 0x0123
Res: 2.04 Changed
Echo: 0x0124
(Later, the EP regains its confidence in its long-term reachability.)
Req: POST /rd/4521?lt=90000
Echo: 0x0124
Res: 2.04 Changed
Echo: 0x0247
The other examples do not show Echo options for two reasons: (1) for simplicity and (2) because they lack the context for any example values to have meaning.