Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AlternatePath and Device Prefix need charset restriction #578

Open
sbernard31 opened this issue Jun 7, 2024 · 2 comments
Open

AlternatePath and Device Prefix need charset restriction #578

sbernard31 opened this issue Jun 7, 2024 · 2 comments

Comments

@sbernard31
Copy link

LWM2M specification define Alternate Path (see LWM2M-v1.2.1@transport§6.4.1. Alternate Path)

And also Device Prefix when LWM2M Gateway is used (see Lightweight Machine to Machine Gateway Technical Specification)

Both can be find in a LWM2M path.
E.g. :

  • alternate path : /lwm2m/3/0/1
  • device prefix : /d01/3/0/1
  • or both : /lwm2m/d01/3/0/1

AFIAK, there is only 1 restriction about how Alternate Path should looks like :

This link MUST NOT contain numerical URI segment.

And nothing about Device Prefix (but I maybe missed something)

I think it would be wiser to clearly define how path/prefix MUST look like else we risk to face some issue between different content format.

Currently this value can be see with different constraint in :

In Link format, absolute path should follow :

path-absolute = "/" [ segment-nz *( "/" segment ) ]
segment       = *pchar
segment-nz    = 1*pchar

pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
pct-encoded   = "%" HEXDIG HEXDIG
unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
            / "*" / "+" / "," / ";" / "="

And in SenML :

name    = firstchat *nextchar
firstchar  = ALPHA / DIGIT
nextchat = ALPHA / DIGIT / "-" /  ":" /  "." /  "/" / "_"

I propose some very restrictive constraint to avoid that kind of issues :

alternatePath  = "/" segment *(  "/" segment)
prefix = "/" segment
segment = ALPHA * (ALPHA / DIGIT) // force segment to start by ALPHA making LWM2M path parsing easier
                                  // no need to parse whole segment to know 
                                  // IF we are in the prefix/alternatePath OR in the Id of a LWM2M node
ALPHA  =  %x41-5A / %x61-7A     ; A-Z / a-z
DIGIT  =  %x30-39       ; 0-9

Any opinion ?

@dnav
Copy link
Member

dnav commented Jun 10, 2024

As an individual, not an OMA representative:

The Alternate path being a part of an URI path, I think it follows the format defined in RFC 3986:

   path          = path-abempty    ; begins with "/" or is empty
                 / path-absolute   ; begins with "/" but not "//"
                 / path-noscheme   ; begins with a non-colon segment
                 / path-rootless   ; begins with a segment
                 / path-empty      ; zero characters

   path-abempty  = *( "/" segment )
   path-absolute = "/" [ segment-nz *( "/" segment ) ]
   path-noscheme = segment-nz-nc *( "/" segment )
   path-rootless = segment-nz *( "/" segment )
   path-empty    = 0<pchar>

   segment       = *pchar
   segment-nz    = 1*pchar
   segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
                 ; non-zero-length segment without any colon ":"

   pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"

   query         = *( pchar / "/" / "?" )

   fragment      = *( pchar / "/" / "?" )

   pct-encoded   = "%" HEXDIG HEXDIG

   unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"

@sbernard31
Copy link
Author

Thx @dnav,

Don't you think that it lead to some issues ?

As it is very permissive , this could lead to situation where alternate path can not be express in given content format.
E.g. You can use characters which are not allowed by SenML 😬

And with grammar you propose you can have an alternate path which looks like : /120 and so don't follow : This link MUST NOT contain numerical URI segment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants