ETSI STF525 / Internal Testing test suite This project provides an internal testing test suite and its associated Test Adapter/Codec

Asn1cEncDec.hh
Go to the documentation of this file.
1 #ifndef ASN1CENCDEC_HH
2 #define ASN1CENCDEC_HH
3
4 // include titan headers
5 #include "TTCN3.hh"
6
7 // include ASN1C sceleton
8 #include "asn1c/INTEGER.h"
9 #include "asn1c/BOOLEAN.h"
10 #include "asn1c/OCTET_STRING.h"
11 #include "asn1c/BIT_STRING.h"
12
13 extern "C" {
14 int asn1c_collect_encoded_data(const void *buffer, size_t size, void *application_specific_key);
15 }
16
17 // OPTIONAL is defined somewhere in WIN32
18 #ifdef OPTIONAL
19 #undef OPTIONAL
20 #endif
21
22 template<typename TT, typename TA>
23 TT asn1c2titan(const TA& a) {
24 // default implementation:
25 return TT(a);
26 }
27
28 // basic types
29 void titan2asn1c(const INTEGER& t, long& a);
30 void titan2asn1c(const INTEGER& t, unsigned long& a);
31 void titan2asn1c(const INTEGER& t, INTEGER_t& a);
32 void titan2asn1c(const BOOLEAN& t, BOOLEAN_t& a);
33 void titan2asn1c(const OCTETSTRING& t, OCTET_STRING_t& a);
34 void titan2asn1c(const BITSTRING& t, BIT_STRING_t& a);
35
36 INTEGER asn1c2titan(const INTEGER_t&);
37 INTEGER asn1c2titan(long);
38 OCTETSTRING asn1c2titan(const OCTET_STRING_t&);
39 BITSTRING asn1c2titan(const BIT_STRING_t&);
40
41 // template for optional value
42 template <typename TT, typename TA>
43 OPTIONAL<TT> asn1c2titan_opt(const TA * pa) {
44 if(pa) {
45 return OPTIONAL<TT>(asn1c2titan(*pa));
46 }
47 return OPTIONAL<TT>(OMIT_VALUE);
48 }
49
50 template <typename TT, typename TA>
51 void titan2asn1c_opt(const OPTIONAL<TT> & ot, TA *& a){
52 if(ot.is_present()){
53 a = new TA;
54 titan2asn1c((const TT&)ot, *a);
55 }else{
56 a = NULL;
57 }
58 }
59
60 template<typename T, typename TS, typename TA>
61 void titan2asn1c_seq(const TS& t, TA& a){
62 a.list.array = (T**)calloc(t.n_elem(), sizeof(void*));
63 a.list.count = t.n_elem();
64 a.list.size = sizeof(void*)*a.list.count;
65 for (int i = 0; i < t.n_elem(); i++){
66 a.list.array[i] = (T*)malloc(sizeof(T));
67 titan2asn1c(t[i], *a.list.array[i]);
68 }
69 }
70
71 template<typename TS, typename TA>
72 TS asn1c2titan_seq(const TA& a)
73 {
74 TS t;
75 t.set_size(a.list.count);
76 for (int i = 0; i < a.list.count; i++){
77 t[i] = asn1c2titan(*a.list.array[i]);
78 }
79 return t;
80 }
81
82 int asn1c_per2ber(asn_TYPE_descriptor_t &td, const TTCN_Buffer & per, TTCN_Buffer & ber, void** ctx );
83 int asn1c_ber2per(asn_TYPE_descriptor_t &td, const TTCN_Buffer & ber, TTCN_Buffer & per, void** ctx );
84 // int asn1c_oer2xer(asn_TYPE_descriptor_t &td, const TTCN_Buffer & oer, TTCN_Buffer & xer, void** ctx );
85 // int asn1c_xer2oer(asn_TYPE_descriptor_t &td, const TTCN_Buffer & xer, TTCN_Buffer & oer, void** ctx );
86
87
88 #endif
OPTIONAL
Definition: BTPCodec.cc:9
titan2asn1c
void titan2asn1c(const INTEGER &t, long &a)
Definition: Asn1cEncDec.cc:5
asn1c2titan_seq
TS asn1c2titan_seq(const TA &a)
Definition: Asn1cEncDec.hh:72
asn1c2titan_opt
OPTIONAL< TT > asn1c2titan_opt(const TA *pa)
Definition: Asn1cEncDec.hh:43
asn1c_collect_encoded_data
int asn1c_collect_encoded_data(const void *buffer, size_t size, void *application_specific_key)
Definition: Asn1cEncDec.cc:108
asn1c2titan
TT asn1c2titan(const TA &a)
Definition: Asn1cEncDec.hh:23
asn1c_per2ber
int asn1c_per2ber(asn_TYPE_descriptor_t &td, const TTCN_Buffer &per, TTCN_Buffer &ber, void **ctx)
Definition: Asn1cEncDec.cc:122
titan2asn1c_seq
void titan2asn1c_seq(const TS &t, TA &a)
Definition: Asn1cEncDec.hh:61
asn1c_ber2per
int asn1c_ber2per(asn_TYPE_descriptor_t &td, const TTCN_Buffer &ber, TTCN_Buffer &per, void **ctx)
Definition: Asn1cEncDec.cc:147
titan2asn1c_opt
void titan2asn1c_opt(const OPTIONAL< TT > &ot, TA *&a)
Definition: Asn1cEncDec.hh:51