Attention is currently required from: pespin.

fixeria has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594?usp=email )

Change subject: Asterisk: Initial AMI support
......................................................................


Patch Set 2:

(1 comment)

File asterisk/AMI_Functions.ttcn:

https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594/comment/fbca309d_39ffd603
PS2, Line 109: var integer pos := f_strstr(str, ": ", 0);
Looks like you could use TITAN's TEXT encoder for doing this:

```
type record AMI_Field {
        charstring      key,
        charstring      val
} with {
        encode "TEXT"
        variant "SEPARATOR(':')"
};

type set of AMI_Field AMI_Msg with {
        encode "TEXT"
        variant "SEPARATOR('\r\n')"
        variant "END('\r\n')"
};

external function enc_AMI_Msg(in AMI_Msg msg) return charstring
        with { extension "prototype(convert) encode(TEXT)" }
external function dec_AMI_Msg(in charstring stream) return AMI_Msg
        with { extension "prototype(convert) decode(TEXT)" }
```

See 
https://gitlab.eclipse.org/eclipse/titan/titan.core/-/blob/master/usrguide/referenceguide/4-ttcn3_language_extensions.adoc?ref_type=heads#user-content-text-encoder-and-decoder.

Not saying you have to do it this way, but if we can offload some work to TITAN 
- why not.

I have a small self-test:

```
private type component dummy_CT {  };

testcase TC_tuwat() runs on dummy_CT {
        var AMI_Msg msg := {
                { "field1", "value1" },
                { "field2", "value2" },                                         
                                                                                
                                                                
                { "field3", "value3" }
        };

        var charstring text := enc_AMI_Msg(msg);
        log("AMI msg encoded: ", text);

        var AMI_Msg msg_dec := dec_AMI_Msg(text);
        log("AMI msg decoded: ", msg_dec);
}
```

and here is the output it produces:

```
MTC@LEGION: AMI msg encoded: 
"field1:value1\r\nfield2:value2\r\nfield3:value3\r\n"
MTC@LEGION: AMI msg decoded: { { key := "field1", val := "value1" }, { key := 
"field2", val := "value2" }, { key := "field3", val := "value3" } }
```



--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36594?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I2c570e4d04e7ab8c44962cf484e4bbc946209aee
Gerrit-Change-Number: 36594
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: jolly <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-Attention: pespin <[email protected]>
Gerrit-Comment-Date: Thu, 18 Apr 2024 16:31:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

Reply via email to