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

Draft: Add SST options for security in federated executions. #1828

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions core/src/main/java/org/lflang/TargetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ public TargetConfig(Properties cliArgs, TargetDecl target, MessageReporter messa
/** Indicate whether HMAC authentication is used. */
public boolean auth = false;

/** Path to sst configuration files. */
public boolean sst = false;

/** Indicate whether the runtime should use multithreaded execution. */
public boolean threading = true;

Expand Down
10 changes: 10 additions & 0 deletions core/src/main/java/org/lflang/TargetProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,16 @@ public enum TargetProperty {
(config, value, err) -> {
config.singleFileProject = ASTUtils.toBoolean(value);
}),

/** Directive to specify the path of the sst configuration file. */
SST(
"sst",
PrimitiveType.BOOLEAN,
Arrays.asList(Target.C, Target.CCPP),
(config) -> ASTUtils.toElement(config.sst),
(config, value, err) -> {
config.sst = ASTUtils.toBoolean(value);
}),

/** Directive to indicate whether the runtime should use multi-threading. */
THREADING(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ public static void handleCompileDefinitions(
if (federate.targetConfig.auth) {
federate.targetConfig.compileDefinitions.put("FEDERATED_AUTHENTICATED", "");
}
if (federate.targetConfig.sst) {
federate.targetConfig.compileDefinitions.put("FEDERATED_AUTHENTICATED_SST", "");
}
federate.targetConfig.compileDefinitions.put(
"NUMBER_OF_FEDERATES", String.valueOf(numOfFederates));
federate.targetConfig.compileDefinitions.put("EXECUTABLE_PREAMBLE", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ public void doGenerate(List<FederateInstance> federates, RtiConfig rtiConfig) {

shCode.append("#### Host is ").append(host);

// Launch sst settings.
if(targetConfig.sst) {
//Add sst settings
// TODO:
// 1. Key generation
// 2. Config generation.
}

// Launch the RTI in the foreground.
if (host.equals("localhost") || host.equals("0.0.0.0")) {
// FIXME: the paths below will not work on Windows
Expand Down Expand Up @@ -337,6 +345,11 @@ private String getRtiCommand(List<FederateInstance> federates, boolean isRemote)
if (targetConfig.auth) {
commands.add(" -a \\");
}
if (targetConfig.sst) {
// commands.add(" -sst " + args + " \\"); //TODO: get config from args.
// Should be something like this.
// RTI -sst test/C/fed-gen/SimpleFederated/src-gen/RTI/sst/RTI.config
}
if (targetConfig.tracing != null) {
commands.add(" -t \\");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ CodeBuilder generateCMakeCode(
cMakeCode.pr("pico_enable_stdio_uart(${LF_MAIN_TARGET} " + (uart ? 1 : 0) + ")");
break;
}


if (targetConfig.auth || targetConfig.sst) {
// If security is requested, add the auth option or sst option.
}
if (targetConfig.auth) {
// If security is requested, add the auth option.
var osName = System.getProperty("os.name").toLowerCase();
Expand Down
19 changes: 19 additions & 0 deletions test/C/src/federated/SimpleFederatedSST.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* This simple test checks if federate authentication works by adding `auth`
* target property.
*/
target C {
timeout: 2 secs,
build-type: RelWithDebInfo,
sst: true,
logging: DEBUG
}

reactor Fed {
input in: int
output out: int
}

federated reactor {
fed1 = new Fed()
}
Loading