Skip to content

Commit

Permalink
fix: correlation-tag option number to be non-critical
Browse files Browse the repository at this point in the history
  • Loading branch information
szysas committed Sep 24, 2024
1 parent d1b7b98 commit 2d05518
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 10 additions & 1 deletion coap-core/src/main/java/com/mbed/coap/packet/HeaderOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
* - RFC 7959 (Block-Wise Transfers)
* - draft-ietf-core-observe-09
* - RFC 9175 (Echo, Request-Tag, and Token Processing)
* <p/>
* And custom:
* <pre>
* +-----+---+---+---+---+----------------+--------+--------+----------+
* | No. | C | U | N | R | Name | Format | Length | Default |
* +-----+---+---+---+---+----------------+--------+--------+----------+
* |29644| | | | | Correlation-tag| opaque | 0-36 | (none) |
* +-----+---+---+---+---+----------------+--------+--------+----------+
* </pre>
*/
public class HeaderOptions extends BasicHeaderOptions {

Expand All @@ -34,7 +43,7 @@ public class HeaderOptions extends BasicHeaderOptions {
private static final byte SIZE_2_RES = 28;
private static final int ECHO = 252;
private static final int REQUEST_TAG = 292;
private static final int OPEN_COAP_CORRELATION_TAG = 29643; // open-coap specific option for request tracing
public static final int OPEN_COAP_CORRELATION_TAG = 29644; // open-coap specific option for request tracing
private Integer observe;
private BlockOption block1Req;
private BlockOption block2Res;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,13 @@ void shouldUseQueryWithoutValue() throws CoapException, IOException {
assertEquals("?param1=val1&q&param2=val2 Loc:?q", h2.toString());
}

@Test
void correlationOptionShouldBeElectiveAndSafeToForward() {
assertFalse(isCritical(HeaderOptions.OPEN_COAP_CORRELATION_TAG));
assertFalse(isUnsave(HeaderOptions.OPEN_COAP_CORRELATION_TAG));
assertFalse(hasNoCacheKey(HeaderOptions.OPEN_COAP_CORRELATION_TAG));
}

private static byte[] serialize(BasicHeaderOptions hdr) throws IOException, CoapException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
hdr.serialize(baos);
Expand Down

0 comments on commit 2d05518

Please sign in to comment.