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

CodecOer.hh
Go to the documentation of this file.
1 #ifndef CODECOER_H
2 #define CODECOER_H
3
4 #include "Params.hh"
5
6 class OCTETSTRING;
7 class CHARSTRING;
8 class BITSTRING;
9
10 struct asn_TYPE_descriptor_s;
11 class ASN1RecodeOer
12 {
13 protected:
14 int xer2oer (const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf);
15 int oer2xer (const asn_TYPE_descriptor_s & td, TTCN_Buffer & buf);
16 int recode (const asn_TYPE_descriptor_s & td, int from, int to, TTCN_Buffer & buf);
17 };
18
19 template<typename TPDU> class OERCodec : public ASN1RecodeOer
20 {
21 public:
22 virtual int encode(const TPDU& msg, BITSTRING& bits) = 0;
23 virtual int decode(const BITSTRING& bits, TPDU& msg) = 0;
24
25 protected:
26 inline int _decode (const TTCN_Typedescriptor_t& ttcn, const asn_TYPE_descriptor_s & td, const BITSTRING& p_data, TPDU& msg) {
27 TTCN_Buffer buf(bit2oct(p_data));
28 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);
29 int rc = oer2xer (td, buf);
30 if (rc > 0) {
31 msg.decode(ttcn, buf, TTCN_EncDec::CT_BER, BER_ACCEPT_ALL);
32 rc = buf.get_len();
33 }
34 return rc;
35 }
36 inline int _encode (const TTCN_Typedescriptor_t& ttcn, const asn_TYPE_descriptor_s & td, const TPDU& msg, BITSTRING& p_data) {
37 int rc = -1;
38 TTCN_Buffer buf;
39 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);
40 msg.encode(ttcn, buf, TTCN_EncDec::CT_BER, BER_ENCODE_DER);
41 if (buf.get_len() > 0) {
42 rc = xer2oer (td, buf);
43 if (rc > 0) {
44 p_data = oct2bit(OCTETSTRING(buf.get_len(), buf.get_data()));
45 }
46 }
47 return rc;
48 }
49 };
50
51 #endif
OERCodec::_encode
int _encode(const TTCN_Typedescriptor_t &ttcn, const asn_TYPE_descriptor_s &td, const TPDU &msg, BITSTRING &p_data)
Definition: CodecOer.hh:36
ASN1RecodeOer
Definition: CodecOer.hh:11
ASN1RecodeOer::xer2oer
int xer2oer(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf)
Params.hh
Header file for the parameter dictionary.
ASN1RecodeOer::recode
int recode(const asn_TYPE_descriptor_s &td, int from, int to, TTCN_Buffer &buf)
OERCodec::_decode
int _decode(const TTCN_Typedescriptor_t &ttcn, const asn_TYPE_descriptor_s &td, const BITSTRING &p_data, TPDU &msg)
Definition: CodecOer.hh:26
ASN1RecodeOer::oer2xer
int oer2xer(const asn_TYPE_descriptor_s &td, TTCN_Buffer &buf)
OERCodec
Definition: CodecOer.hh:19