Skip to content

Commit

Permalink
Introduce useOldContentFormat parameter for sifis-home server
Browse files Browse the repository at this point in the history
  • Loading branch information
actyp committed Dec 30, 2024
1 parent 7b6a7ca commit 2a14f0b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions experiments/args/sifis-home/server_phase_1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ v22
-combinedMessageVersion
v07

-useOldContentFormat

## Mapper Auth ##

-mapCredType
Expand Down
2 changes: 2 additions & 0 deletions experiments/args/sifis-home/server_phase_2
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ v22
-combinedMessageVersion
v07

-useOldContentFormat

## Mapper Auth ##

-mapCredType
Expand Down
2 changes: 2 additions & 0 deletions experiments/args/sifis-home/server_phase_3
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ v22
-combinedMessageVersion
v07

-useOldContentFormat

## Mapper Auth ##

-mapCredType
Expand Down
2 changes: 2 additions & 0 deletions experiments/args/sifis-home/server_phase_4
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ v22
-combinedMessageVersion
v07

-useOldContentFormat

## Mapper Auth ##

-mapCredType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public EdhocProtocolMessage(MessageProcessorPersistent messageProcessorPersisten
contentFormat = Constants.APPLICATION_EDHOC_CBOR_SEQ;
}
}

public byte[] getPayload() {
return payload;
}
Expand All @@ -48,7 +49,15 @@ public int getMessageCode() {
return messageCode;
}

public int getContentFormat() {
public int getContentFormat(boolean oldVersion) {
if (oldVersion) {
return switch (contentFormat) {
case Constants.APPLICATION_EDHOC_CBOR_SEQ -> 65000;
case Constants.APPLICATION_CID_EDHOC_CBOR_SEQ -> 65001;
default -> contentFormat;
};
}

return contentFormat;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public class EdhocMapperConfig extends MapperConfigStandard {
@Parameter(names = "-disableContentFormat", description = "Do not add CoAP Content-Format in sending messages")
protected boolean disableContentFormat = false;

@Parameter(names = "-useOldContentFormat", description = "Use the old CoAP Content-Format (6500x) in sending messages")
protected boolean useOldContentFormat = false;

@Parameter(names = "-enableSessionReset", description = "Reset to default old session data, when Initiator mapper "
+ "sends a message to start a new session. Reset does not affect a Responder mapper")
protected boolean enableSessionReset = false;
Expand Down Expand Up @@ -156,6 +159,10 @@ public boolean useContentFormat() {
return !disableContentFormat;
}

public boolean useOldContentFormat() {
return useOldContentFormat;
}

public boolean useSessionReset() {
return enableSessionReset;
}
Expand Down Expand Up @@ -248,6 +255,7 @@ public void printRunDescriptionSelf(PrintWriter printWriter) {
printWriter.println("App Message Payload To Coap Client: " + getAppMessagePayloadToCoapClient());
printWriter.println("Coap Error As Edhoc Error: " + isCoapErrorAsEdhocError());
printWriter.println("use Content Format: " + useContentFormat());
printWriter.println("use Old Content Format: " + useOldContentFormat());
printWriter.println("use Session Reset: " + useSessionReset());
printWriter.println("use CX Correlation: " + useCXCorrelation());
printWriter.println("Own Connection Id: " + this.ownConnectionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ protected void sendMessage(ProtocolMessage message, ExecutionContext context) {

// enable or disable content format
EdhocMapperConfig edhocMapperConfig = (EdhocMapperConfig) mapperConfig;
int contentFormat = edhocMapperConfig.useContentFormat() ? edhocProtocolMessage.getContentFormat() : MediaTypeRegistry.UNDEFINED;
int contentFormat = edhocMapperConfig.useContentFormat() ?
edhocProtocolMessage.getContentFormat(edhocMapperConfig.useOldContentFormat()) :
MediaTypeRegistry.UNDEFINED;

edhocMapperConnector.send(edhocProtocolMessage.getPayload(), edhocProtocolMessage.getPayloadType(),
edhocProtocolMessage.getMessageCode(), contentFormat);
Expand Down

0 comments on commit 2a14f0b

Please sign in to comment.