Commit 231012ac authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Implemented CSN.1 L/H values for the RAW codec (bug 548969)



Change-Id: I0992e8d327b9aab1b01f03697e0499ae0bc6f1a5
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 38293e9e
......@@ -2150,6 +2150,22 @@ namespace Common {
}
}
}
if (rawattrib->csn1lh){ // CSN.1 L/H
for (size_t i = 0; i < get_nof_comps(); i++) {
CompField* cfield = get_comp_byIndex(i);
RawAST* field_rawattr = cfield->get_type()->rawattrib;
if (field_rawattr == NULL) {
// create the field's RAW structure if it doesn't have one
Type* t = cfield->get_type();
if (t->is_ref()) t = t->get_type_refd();
while (t->rawattrib == NULL && t->is_ref()) t = t->get_type_refd();
cfield->get_type()->rawattrib = new RawAST(t->rawattrib,
cfield->get_type()->get_default_raw_fieldlength());
field_rawattr = cfield->get_type()->rawattrib;
}
field_rawattr->csn1lh = true;
}
}
}
break;
case T_SEQ_T:
......@@ -2265,7 +2281,7 @@ namespace Common {
}
}
}
if(rawattrib->fieldorder!=XDEFDEFAULT){ // FIELDORDER
if(rawattrib->fieldorder!=XDEFDEFAULT || rawattrib->csn1lh){ // FIELDORDER or CSN.1 L/H
for(size_t i = 0; i < get_nof_comps(); i++) {
CompField *cfield=get_comp_byIndex(i);
RawAST *field_rawattr=cfield->get_type()->rawattrib;
......@@ -2276,8 +2292,12 @@ namespace Common {
cfield->get_type()->rawattrib= new RawAST(t->rawattrib,cfield->get_type()->get_default_raw_fieldlength());
field_rawattr=cfield->get_type()->rawattrib;
}
if(field_rawattr->fieldorder==XDEFDEFAULT)
if(rawattrib->fieldorder!=XDEFDEFAULT &&
field_rawattr->fieldorder==XDEFDEFAULT)
field_rawattr->fieldorder=rawattrib->fieldorder;
if (rawattrib->csn1lh) {
field_rawattr->csn1lh = true;
}
}
}
}
......
......@@ -791,11 +791,12 @@ void Type::generate_code_rawdescriptor(output_struct *target)
gennameown_str, rawattrib->forceomit.nElements, gennameown_str);
target->source.global_vars = mputstr(target->source.global_vars, force_omit_str);
Free(force_omit_str);
str = mputprintf(str, "&%s_raw_force_omit", gennameown_str);
str = mputprintf(str, "&%s_raw_force_omit,", gennameown_str);
}
else {
str = mputstr(str, "NULL");
str = mputstr(str, "NULL,");
}
str = mputstr(str, rawattrib->csn1lh ? "true" : "false");
str = mputstr(str, "};\n");
target->source.global_vars = mputstr(target->source.global_vars, str);
Free(str);
......
......@@ -69,6 +69,7 @@ RawAST::RawAST(RawAST *other, int default_length){
length_restrition=other->length_restrition;
intx = other->intx;
stringformat = other->stringformat;
csn1lh = other->csn1lh;
}
else init_rawast(default_length);
}
......@@ -112,6 +113,7 @@ void RawAST::init_rawast(int default_length){
topleveleind=0;
intx = false;
stringformat = CharCoding::UNKNOWN;
csn1lh = false;
}
RawAST::~RawAST(){
......@@ -215,6 +217,7 @@ void RawAST::print_RawAST(){
printf("%sIntX encoding\n\r", intx ? "" : "not ");
printf("String format: %s\n\r", stringformat == CharCoding::UTF_8 ? "UTF-8" :
(stringformat == CharCoding::UTF16 ? "UTF-16" : "unknown"));
printf("%susing CSN.1 L/H values\n\r", csn1lh ? "" : "not ");
}
void copy_rawAST_to_struct(RawAST *from, raw_attrib_struct *to, bool copy_presences){
......@@ -324,5 +327,7 @@ int compare_raw_attrib(RawAST *a, RawAST *b){
a->ptroffset!=b->ptroffset ||
a->repeatable!=b->repeatable ||
a->unit!=b->unit ||
a->intx != b->intx;
a->intx != b->intx ||
a->stringformat != b->stringformat ||
a->csn1lh != b->csn1lh;
}
......@@ -128,6 +128,7 @@ public:
bool intx; /**< IntX encoding for integers */
CharCoding::CharCodingType stringformat; /**< String serialization type for
* universal charstrings */
bool csn1lh; /**< use CSN.1 L/H values */
/** Default constructor.
* Calls \c init_rawast(false).
* \todo should be merged with the next one */
......
......@@ -308,6 +308,7 @@ unsigned { RETURN(XUnsignedKeyword); }
"UTF-16" { RETURN(XUTF16Keyword); }
"IEEE754 float" { RETURN(XIEEE754FloatKeyword); }
"IEEE754 double" { RETURN(XIEEE754DoubleKeyword); }
"CSN.1 L/H" { RETURN(XCsn1LHKeyword); }
<rawcodec>{
yes { yylval.enumval = XDEFYES; RETURN(XYes); }
......
......@@ -177,6 +177,7 @@ static void yyprint(FILE *file, int type, const YYSTYPE& value);
%token XUTF16Keyword
%token XIEEE754FloatKeyword
%token XIEEE754DoubleKeyword
%token XCsn1LHKeyword "CSN.1 L/H"
/* XER attributes */
%token XKWall "all"
......@@ -522,6 +523,8 @@ XSingleEncodingDef : XPaddingDef
{ raw_f = true; }
| XIEEE754Def
{ raw_f = true; }
| XCsn1LHDef
{ raw_f = true; }
/* TEXT encoder keywords */
| XBeginDef
{ text_f=true; }
......@@ -990,6 +993,9 @@ XIEEE754Def:
XIEEE754FloatKeyword { rawstruct->fieldlength = 32; }
| XIEEE754DoubleKeyword { rawstruct->fieldlength = 64; }
XCsn1LHDef:
XCsn1LHKeyword { rawstruct->csn1lh = true; }
/* Text encoder */
XBeginDef:
XBeginKeyword '(' XEncodeToken ')' {
......
......@@ -1019,6 +1019,7 @@ int BITSTRING::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& mylea
if (p_td.raw->bitorderinoctet == ORDER_MSB) orders = TRUE;
if (p_td.raw->bitorderinfield == ORDER_LSB) orders = !orders;
myleaf.coding_par.bitorder = orders ? ORDER_MSB : ORDER_LSB;
myleaf.coding_par.csn1lh = p_td.raw->csn1lh;
if (p_td.raw->endianness == ORDER_MSB) myleaf.align = align_length;
else myleaf.align = -align_length;
......@@ -1055,6 +1056,7 @@ int BITSTRING::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
cp.byteorder = orders ? ORDER_MSB : ORDER_LSB;
cp.fieldorder = p_td.raw->fieldorder;
cp.hexorder = ORDER_LSB;
cp.csn1lh = p_td.raw->csn1lh;
buff.get_b((size_t) decode_length, val_ptr->bits_ptr, cp, top_bit_ord);
if (p_td.raw->length_restrition != -1 &&
decode_length > p_td.raw->length_restrition) {
......
......@@ -570,6 +570,7 @@ int BOOLEAN::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf)
// remove the extra ones from the last octet
bc[length - 1] &= BitMaskTable[loc_length % 8];
}
myleaf.coding_par.csn1lh = p_td.raw->csn1lh;
return myleaf.length = loc_length;
}
......@@ -610,6 +611,7 @@ int BOOLEAN::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
cp.byteorder = orders ? ORDER_MSB : ORDER_LSB;
cp.fieldorder = p_td.raw->fieldorder;
cp.hexorder = ORDER_LSB;
cp.csn1lh = p_td.raw->csn1lh;
int length = (decode_length + 7) / 8;
unsigned char *data = (unsigned char*)Malloc(length*sizeof(unsigned char));
buff.get_b((size_t)decode_length, data, cp, top_bit_ord);
......
......@@ -1551,6 +1551,7 @@ int CHARSTRING::RAW_encode(const TTCN_Typedescriptor_t& p_td,
}
if (p_td.raw->endianness == ORDER_MSB) myleaf.align = -align_length;
else myleaf.align = align_length;
myleaf.coding_par.csn1lh = p_td.raw->csn1lh;
return myleaf.length = bl + align_length;
}
......@@ -1581,6 +1582,7 @@ int CHARSTRING::RAW_decode(const TTCN_Typedescriptor_t& p_td,
cp.byteorder = orders ? ORDER_MSB : ORDER_LSB;
cp.fieldorder = p_td.raw->fieldorder;
cp.hexorder = ORDER_LSB;
cp.csn1lh = p_td.raw->csn1lh;
if(p_td.raw->fieldlength >= 0){
clean_up();
init_struct(decode_length / 8);
......
......@@ -95,6 +95,8 @@ TTCN_EncDec::error_behavior[TTCN_EncDec::ET_ALL] = {
TTCN_EncDec::error_type_t TTCN_EncDec::last_error_type=ET_NONE;
char *TTCN_EncDec::error_str=NULL;
static const unsigned char CSN1_L_H_Mask = 0x2B; // 00101011
static TTCN_EncDec::error_type_t& operator++(TTCN_EncDec::error_type_t& eb)
{
return eb
......@@ -833,6 +835,11 @@ local_fieldorder==ORDER_MSB?"M":"L"
(REVERSE_BITS(s[0]&BitMaskTable[len])>>bit_pos);
}
}
if (coding_par.csn1lh) {
data_ptr[new_size-1] ^= CSN1_L_H_Mask & (local_fieldorder == ORDER_LSB ?
(BitMaskTable[bit_pos + len] & ~BitMaskTable[bit_pos]) :
(~BitMaskTable[8 - bit_pos - len] & BitMaskTable[8 - bit_pos]));
}
}
else if(bit_pos==0 && (len%8)==0){ // octet aligned data
if(coding_par.byteorder==ORDER_LSB){
......@@ -854,6 +861,12 @@ local_fieldorder==ORDER_MSB?"M":"L"
for(size_t a=0,b=len/8-1;a<len/8;a++,b--) prt[a]=REVERSE_BITS(s[b]);
}
}
if (coding_par.csn1lh) {
unsigned char* ptr = data_ptr + buf_len;
for (size_t a = 0; a < len / 8; ++a) {
ptr[a] ^= CSN1_L_H_Mask;
}
}
}
else{
size_t maxindex=new_size-1;
......@@ -987,6 +1000,18 @@ local_fieldorder==ORDER_MSB?"M":"L"
data_ptr[new_size-1]<<=(8-new_bit_pos);
}
}
if (coding_par.csn1lh) {
unsigned char *ptr = data_ptr + (buf_len == 0 ? 0 : buf_len - 1);
ptr[0] ^= CSN1_L_H_Mask & (local_fieldorder == ORDER_LSB ?
~BitMaskTable[bit_pos] : BitMaskTable[8 - bit_pos]);
for (unsigned int a = 1; a < (len + bit_pos) / 8; ++a) {
ptr[a] ^= CSN1_L_H_Mask;
}
if (new_bit_pos != 0) {
data_ptr[new_size - 1] ^= CSN1_L_H_Mask & (local_fieldorder == ORDER_LSB ?
BitMaskTable[new_bit_pos] : ~BitMaskTable[8 - new_bit_pos]);
}
}
}
if(st) Free(st);
if(st2) Free(st2);
......@@ -1028,8 +1053,13 @@ void TTCN_Buffer::get_b(size_t len, unsigned char *s,
if(local_fieldorder==ORDER_LSB) local_fieldorder=ORDER_MSB;
else local_fieldorder=ORDER_LSB;
}
const unsigned char *data_ptr = buf_ptr != NULL ? buf_ptr->data_ptr : NULL;
unsigned char *data_ptr = buf_ptr != NULL ? buf_ptr->data_ptr : NULL;
if(bit_pos+len<=8){ // the data is within 1 octet
if (coding_par.csn1lh) {
data_ptr[buf_pos] ^= CSN1_L_H_Mask & (local_fieldorder == ORDER_LSB ?
(BitMaskTable[bit_pos + len] & ~BitMaskTable[bit_pos]) :
(~BitMaskTable[8 - bit_pos - len] & BitMaskTable[8 - bit_pos]));
}
if(local_bitorder==ORDER_LSB){
if(local_fieldorder==ORDER_LSB){
s[0]=data_ptr[buf_pos]>>bit_pos;
......@@ -1046,6 +1076,12 @@ void TTCN_Buffer::get_b(size_t len, unsigned char *s,
}
}
else if(bit_pos==0 && (len%8)==0){ // octet aligned data
if (coding_par.csn1lh) {
unsigned char* ptr = data_ptr + buf_pos;
for (size_t a = 0; a < len / 8; ++a) {
ptr[a] ^= CSN1_L_H_Mask;
}
}
if(coding_par.byteorder==ORDER_LSB){
if(local_bitorder==ORDER_LSB){
memcpy(s, data_ptr+buf_pos, len/8*sizeof(unsigned char));
......@@ -1067,6 +1103,18 @@ void TTCN_Buffer::get_b(size_t len, unsigned char *s,
}
}
else{ // unaligned
if (coding_par.csn1lh) {
unsigned char *ptr = data_ptr + buf_pos;
ptr[0] ^= CSN1_L_H_Mask & (local_fieldorder == ORDER_LSB ?
~BitMaskTable[bit_pos] : BitMaskTable[8 - bit_pos]);
for (unsigned int a = 1; a < (len + bit_pos) / 8; ++a) {
ptr[a] ^= CSN1_L_H_Mask;
}
if (new_bit_pos != 0) {
data_ptr[buf_len - 1] ^= CSN1_L_H_Mask & (local_fieldorder == ORDER_LSB ?
BitMaskTable[new_bit_pos] : ~BitMaskTable[8 - new_bit_pos]);
}
}
size_t num_bytes = (len + 7) / 8;
if(coding_par.byteorder==ORDER_LSB){
if(local_bitorder==ORDER_LSB){
......
......@@ -760,6 +760,7 @@ int FLOAT::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) c
else
TTCN_EncDec_ErrorContext::error_internal("Invalid FLOAT length %d", length);
myleaf.coding_par.csn1lh = p_td.raw->csn1lh;
return myleaf.length = p_td.raw->fieldlength;
}
......@@ -795,6 +796,7 @@ int FLOAT::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
cp.byteorder = orders ? ORDER_MSB : ORDER_LSB;
cp.fieldorder = p_td.raw->fieldorder;
cp.hexorder = ORDER_LSB;
cp.csn1lh = p_td.raw->csn1lh;
buff.get_b((size_t) decode_length, data, cp, top_bit_ord);
if (decode_length == 64) {
unsigned char *dv = (unsigned char *) &tmp;
......
......@@ -784,6 +784,7 @@ int HEXSTRING::RAW_encode(const TTCN_Typedescriptor_t& p_td,
myleaf.align = -align_length;
else
myleaf.align = align_length;
myleaf.coding_par.csn1lh = p_td.raw->csn1lh;
return myleaf.length = nbits + align_length;
}
......@@ -814,6 +815,7 @@ int HEXSTRING::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
cp.byteorder = orders ? ORDER_MSB : ORDER_LSB;
cp.fieldorder = p_td.raw->fieldorder;
cp.hexorder = p_td.raw->hexorder;
cp.csn1lh = p_td.raw->csn1lh;
clean_up();
init_struct(decode_length / 4);
buff.get_b((size_t) decode_length, val_ptr->nibbles_ptr, cp, top_bit_ord);
......
......@@ -1251,6 +1251,7 @@ int INTEGER::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf)
}
myleaf.length = p_td.raw->fieldlength;
}
myleaf.coding_par.csn1lh = p_td.raw->csn1lh;
return myleaf.length;
}
......@@ -1399,6 +1400,7 @@ int INTEGER::RAW_encode_openssl(const TTCN_Typedescriptor_t& p_td,
BN_free(D);
myleaf.length = p_td.raw->fieldlength;
}
myleaf.coding_par.csn1lh = p_td.raw->csn1lh;
return myleaf.length;
}
......@@ -1420,6 +1422,7 @@ int INTEGER::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
cp.byteorder = orders ? ORDER_MSB : ORDER_LSB;
cp.fieldorder = p_td.raw->fieldorder;
cp.hexorder = ORDER_LSB;
cp.csn1lh = p_td.raw->csn1lh;
int decode_length = 0;
int len_bits = 0; // only for IntX (amount of bits used to store the length)
unsigned char len_data = 0; // only for IntX (an octet used to store the length)
......
......@@ -1227,6 +1227,7 @@ int OCTETSTRING::RAW_encode(const TTCN_Typedescriptor_t& p_td,
else myleaf.body.leaf.data_ptr = val_ptr->octets_ptr;
if (p_td.raw->endianness == ORDER_MSB) myleaf.align = align_length;
else myleaf.align = -align_length;
myleaf.coding_par.csn1lh = p_td.raw->csn1lh;
return myleaf.length = bl + align_length;
}
......@@ -1256,6 +1257,7 @@ int OCTETSTRING::RAW_decode(const TTCN_Typedescriptor_t& p_td,
cp.byteorder = orders ? ORDER_MSB : ORDER_LSB;
cp.fieldorder = p_td.raw->fieldorder;
cp.hexorder = ORDER_LSB;
cp.csn1lh = p_td.raw->csn1lh;
if (p_td.raw->extension_bit != EXT_BIT_NO) {
const unsigned char* data = buff.get_read_data();
int count = 1;
......
......@@ -423,6 +423,7 @@ int RAW_encode_enum_type(const TTCN_Typedescriptor_t& p_td,
my_raw.prepadding = p_td.raw->prepadding;
my_raw.ptroffset = p_td.raw->ptroffset;
my_raw.unit = p_td.raw->unit;
my_raw.csn1lh = p_td.raw->csn1lh;
TTCN_Typedescriptor_t my_descr = { p_td.name, 0, &my_raw, NULL, NULL, NULL, NULL,
NULL, TTCN_Typedescriptor_t::DONTCARE };
INTEGER i(integer_value);
......@@ -452,6 +453,7 @@ int RAW_decode_enum_type(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff,
my_raw.prepadding = p_td.raw->prepadding;
my_raw.ptroffset = p_td.raw->ptroffset;
my_raw.unit = p_td.raw->unit;
my_raw.csn1lh = p_td.raw->csn1lh;
TTCN_Typedescriptor_t my_descr = { p_td.name, 0, &my_raw, NULL, NULL, NULL, NULL,
NULL, TTCN_Typedescriptor_t::DONTCARE };
INTEGER i;
......@@ -509,13 +511,13 @@ int min_of_ints(unsigned int num_of_int,...)
* | unit
* | | padding_pattern_length
* | | padding_pattern
* | | length_restriction
* length,comp ,byteorder,align ,ord_field,ord_octet,ext_bit ,hexorder,fieldorder,top_bit, | | | stringformat, forceomit */
const TTCN_RAWdescriptor_t INTEGER_raw_= {8,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
const TTCN_RAWdescriptor_t BOOLEAN_raw_= {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
const TTCN_RAWdescriptor_t BITSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
const TTCN_RAWdescriptor_t OCTETSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
const TTCN_RAWdescriptor_t HEXSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
const TTCN_RAWdescriptor_t CHARSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
const TTCN_RAWdescriptor_t FLOAT_raw_= {64,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
const TTCN_RAWdescriptor_t UNIVERSAL_CHARSTRING_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL};
* | | length_restriction forceomit
* length,comp ,byteorder,align ,ord_field,ord_octet,ext_bit ,hexorder,fieldorder,top_bit, | | | stringformat, | csn1lh */
const TTCN_RAWdescriptor_t INTEGER_raw_= {8,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
const TTCN_RAWdescriptor_t BOOLEAN_raw_= {1,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
const TTCN_RAWdescriptor_t BITSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
const TTCN_RAWdescriptor_t OCTETSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_MSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
const TTCN_RAWdescriptor_t HEXSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
const TTCN_RAWdescriptor_t CHARSTRING_raw_= {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
const TTCN_RAWdescriptor_t FLOAT_raw_= {64,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
const TTCN_RAWdescriptor_t UNIVERSAL_CHARSTRING_raw_ = {0,SG_NO,ORDER_LSB,ORDER_LSB,ORDER_LSB,ORDER_LSB,EXT_BIT_NO,ORDER_LSB,ORDER_LSB,TOP_BIT_INHERITED,0,0,0,8,0,NULL,-1,CharCoding::UNKNOWN,NULL,false};
......@@ -95,6 +95,7 @@ struct RAW_coding_par{
raw_order_t byteorder;
raw_order_t hexorder;
raw_order_t fieldorder;
bool csn1lh;
};
/** A list of field indexes, that identify the optional field to be omitted */
......@@ -155,6 +156,7 @@ struct TTCN_RAWdescriptor_t{
int length_restrition;
CharCoding::CharCodingType stringformat;
const RAW_Force_Omit* forceomit;
bool csn1lh; /**< use CSN.1 L/H terminals */
};
enum calc_type {
......
......@@ -2391,6 +2391,7 @@ int UNIVERSAL_CHARSTRING::RAW_encode(const TTCN_Typedescriptor_t& p_td,
myleaf.data_ptr_used = TRUE;
if (p_td.raw->endianness == ORDER_MSB) myleaf.align = -align_length;
else myleaf.align = align_length;
myleaf.coding_par.csn1lh = p_td.raw->csn1lh;
return myleaf.length = bl + align_length;
}
......
CSN1_LH
CSN1_LH.exe
CSN1_LH*.cc
CSN1_LH*.hh
*.o
compile
CSN1_LH*.log
###############################################################################
# Copyright (c) 2000-2019 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
#
# Contributors:
# Baranyi, Botond
#
###############################################################################
[LOGGING]
LogFile := "CSN1_LH.log"
FileMask := LOG_ALL
ConsoleMask := TTCN_ERROR | TTCN_TESTCASE | TTCN_STATISTICS
LogSourceInfo := Yes
[EXECUTE]
CSN1_LH.control
/******************************************************************************
* Copyright (c) 2000-2019 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Baranyi, Botond
*
******************************************************************************/
// this module contains tests for the RAW coding instruction 'CSN.1 L/H'
module CSN1_LH {
type bitstring BIT1
with { variant "FIELDLENGTH(1)" }
type integer uint2_t
with { variant "FIELDLENGTH(2)" }
type integer uint3_t
with { variant "FIELDLENGTH(3)" }
type integer uint5_t
with { variant "FIELDLENGTH(5)" }
type integer uint6_t
with { variant "FIELDLENGTH(6)" }
type integer uint16_t
with { variant "FIELDLENGTH(16)" variant "CSN.1 L/H" }
type record RecLsb {
uint3_t a,
uint2_t b,
uint16_t c
}
with {
variant "FIELDORDER(lsb)";
variant (a) "CSN.1 L/H";
variant (b) "CSN.1 L/H";
}
type record RecMsb {
uint3_t a,
uint2_t b,
uint16_t c
}
with {
variant "FIELDORDER(msb)";
variant (a, b) "CSN.1 L/H";
}
type record RecMixed {
uint3_t a,
uint2_t b,
uint16_t c
}
with {
variant "FIELDORDER(msb)";
}
type record Si3RestOctets {
BIT1 sel_params_present,
SelectionParams sel_params optional,
BIT1 power_offset_present,
uint2_t power_offset optional,
BIT1 si2ter_indicator,
BIT1 ealy_cm_sending_control,
BIT1 where_present,
uint3_t where optional,
BIT1 gprs_ind_present,
GprsIndicator gprs_ind optional
}
with {
variant "FIELDORDER(msb)";
variant "CSN.1 L/H";
variant (sel_params) "PRESENCE(sel_params_present = '1'B)"
variant (power_offset) "PRESENCE(power_offset_present = '1'B)"
variant (where) "PRESENCE(where_present = '1'B)"
variant (gprs_ind) "PRESENCE(gprs_ind_present = '1'B)"
}
type record SelectionParams {
boolean cbq,
uint6_t cell_reselect_offset,
uint3_t temporary_offset,
uint5_t penalty_time
}
with {
variant "FIELDORDER(msb)";
variant "CSN.1 L/H";
}
type record GprsIndicator {
uint3_t ra_colour,
BIT1 si13_position
}
with {
variant "FIELDORDER(msb)";
variant "CSN.1 L/H";
}
type record OtherTypes {
float a,
hexstring b,
octetstring c,
charstring d,
universal charstring e,
enumerated { val(4080) } f
}
with {
variant "FIELDORDER(msb)";
variant "CSN.1 L/H";
variant (a) "FORMAT(IEEE754 float)";
variant (b) "FIELDLENGTH(4)";
variant (c, d, e) "FIELDLENGTH(2)";
variant (f) "FIELDLENGTH(16)";
}
type component CT {}
testcase tc_CSN1LH_uint16() runs on CT {
var uint16_t val := 4080;
var bitstring enc := encvalue(val);
var bitstring enc_exp := '11011011 00100100'B;
if (enc != enc_exp) {
setverdict(fail, "Encoding failed. Expected: ", enc_exp, ", got: ", enc);
}
var uint16_t dec;
var integer res := decvalue(enc_exp, dec);
if (res != 0) {
setverdict(fail, "Decoding failed. Result: ", res);
}
else if (dec != val) {
setverdict(fail, "Decoding failed. Expected: ", val, ", got: ", dec);
}
setverdict(pass);
}
testcase tc_CSN1LH_record_LSB() runs on CT {
var RecLsb val := { a := 7, b := 0, c := 4080 };
var bitstring enc := encvalue(val);