-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a95183
commit 828989b
Showing
7 changed files
with
69 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lfc/core/src/main/kotlin/org/lflang/generator/uc/UcEncryptionLayer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.lflang.generator.uc | ||
|
||
import org.lflang.AttributeUtils.getLinkAttribute | ||
import org.lflang.lf.Attribute | ||
|
||
enum class EncryptionLayerType { | ||
NoEncryption | ||
} | ||
|
||
abstract class UcEncryptionLayer(val type: EncryptionLayerType) { | ||
/** Generate code calling the constructor of the source endpoint */ | ||
abstract fun generateChannelCtorSrc(): String | ||
|
||
/** Generate code calling the constructor of the destination endpoint */ | ||
abstract fun generateChannelCtorDest(): String | ||
|
||
abstract val codeType: String | ||
|
||
companion object { | ||
fun createEncryptionLayerForBundle(bundle: UcFederatedConnectionBundle): UcEncryptionLayer { | ||
val attr: Attribute? = getLinkAttribute(bundle.groupedConnections.first().lfConn) | ||
|
||
if (attr == null) { | ||
return UcNoEncryptionLayer() | ||
} else { | ||
val encryption = attr.getParamString("encryption") | ||
|
||
when (encryption) { | ||
"no_encryption" -> return UcNoEncryptionLayer() | ||
} | ||
|
||
return UcNoEncryptionLayer() | ||
} | ||
} | ||
} | ||
} | ||
|
||
class UcNoEncryptionLayer : UcEncryptionLayer(EncryptionLayerType.NoEncryption) { | ||
override fun generateChannelCtorSrc(): String = | ||
"NoEncryptionLayer_ctor(&self->encryption_layer, (NetworkChannel*)self->channel);" | ||
|
||
override fun generateChannelCtorDest(): String = | ||
"NoEncryptionLayer_ctor(&self->encryption_layer, (NetworkChannel*)self->channel);" | ||
|
||
override val codeType: String | ||
get() = "NoEncryptionLayer" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters