jvermillard / leshan

OMA Lightweight M2M java implementation - LWM2M
40 stars 25 forks source link

Generic support for multiple CoAP Endpoints #17

Closed sophokles73 closed 10 years ago

sophokles73 commented 10 years ago

I have introduced generic support for an arbitrary set of CoAP endpoints leshan can serve its services on. A LWM2M Client may use any one of them to register with the server, e.g. the underlying Californium server may be configured with a non-secure endpoint on standard port 5683 and a secure one on 5684 (as Simon already added to LwM2mServer). However, the number of endpoints supported is not limited to two.

For the purposes of managing the client, the server does not really care whether the underlying CoAP stack uses DTLS or not. However, it will be important, that the server uses the same endpoint to issue requests to the client as the client initially used to register with the server. This is particularly important in cases where the client is behind a firewall that only forwards inbound UDP packets originating from the target of the client's initial outbound (registration) request.

In order for the RequestHandler to be able to find out, which Endpoint should be used to talk to the client, I have introduced the registrationEndpointAddress property to class Client which is used to store the address of the Endpoint through which the client's registration request came in. I have removed the secure flag from Client which seemed to serve a similar purpose but is no longer needed. The processing logic does not really care, whether the request's payload has been transmitted using DTLS or not. If at some point we need to be able to determine the client's identity (authenticated during DTLS handshake) we need to use some explicit API provided by the underlying Californium stack from my point of view - maybe something along the lines of the Servlet API, i.e. something like Request.getPrincipal()...

What do you think?