ETSI STF525 / Internal Testing test suite
This project provides an internal testing test suite and its associated Test Adapter/Codec
per_code.t.hh
Go to the documentation of this file.
1 #include <TTCN3.hh>
2 
3 template<class TPDU>
4 int per_code<TPDU>::_decode (const TTCN_Typedescriptor_t& ttcn, const asn_TYPE_descriptor_s & td, const BITSTRING& p_data, TPDU& msg) {
5  TTCN_Buffer buf(bit2oct(p_data));
6  TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);
7  int rc = per2ber (td, buf);
8  if (rc > 0) {
9  msg.decode(ttcn, buf, TTCN_EncDec::CT_BER, BER_ACCEPT_ALL);
10  rc = buf.get_len();
11  }
12  return rc;
13 }
14 
15 template<class TPDU>
16 int per_code<TPDU>::_encode (const TTCN_Typedescriptor_t& ttcn, const asn_TYPE_descriptor_s & td, const TPDU& msg, BITSTRING& p_data) {
17  int rc = -1;
18  TTCN_Buffer buf;
19  TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);
20  msg.encode(ttcn, buf, TTCN_EncDec::CT_BER, BER_ENCODE_DER);
21  if (buf.get_len() > 0) {
22  rc = ber2per (td, buf);
23  if (rc > 0) {
24  p_data = oct2bit(OCTETSTRING(buf.get_len(), buf.get_data()));
25  }
26  }
27  return rc;
28 }
int _encode(const TTCN_Typedescriptor_t &ttcn, const asn_TYPE_descriptor_s &td, const TPDU &msg, BITSTRING &p_data)
Definition: per_code.t.hh:16
int _decode(const TTCN_Typedescriptor_t &ttcn, const asn_TYPE_descriptor_s &td, const BITSTRING &p_data, TPDU &msg)
Definition: per_code.t.hh:4