Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Introduction of error handling mechanisms in the ACN encoding and decoding logic, specifically for external fields and octet strings containing external field functions.
Additionally, there's a minor update in the `CheckAsn1.fs` file related to the handling of the `MarkPresent` case for choice types.
  • Loading branch information
usr3-1415 committed May 7, 2024
1 parent e1f6ca1 commit 8f608f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion FrontEndAst/CheckAsn1.fs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ let rec isConstraintValid (t:Asn1Type) (c:Asn1Constraint) ast =
| Some(Optional opt), MarkAbsent,false when opt.defaultValue.IsSome-> raise(SemanticError (loc, sprintf "Component %s has default value and therefore it cannot be constraint to ABSENT" conName))
| None, MarkAbsent,false
| None, MarkPresent,false -> raise(SemanticError (loc, sprintf "Component %s is not optional. So, it cannot be constraint to ABSENT or PRESENT" conName))
| _, MarkPresent, true
| _, MarkPresent, true -> ()
| _, MarkOptional, true -> raise(SemanticError (loc, sprintf "Choice alternative %s cannot be constraint to PRESENT or OPTIONAL" conName))
| _ -> ()
namedCons |> Seq.iter checkNamedConstraint
Expand Down
3 changes: 3 additions & 0 deletions StgC/acn_c.stg
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ ret = (<if(noSizeMin)>(<noSizeMin>\<=<sExtFld>) && <endif>(<sExtFld>\<=<nSizeMax
if (ret) {
<p><sAcc>nCount = (int)<sExtFld>;
ret = BitStream_DecodeOctetString_no_length(pBitStrm, <p><sAcc>arr, <p><sAcc>nCount);
<A(sErrCode)>
}
>>

Expand All @@ -582,6 +583,7 @@ oct_external_field_fix_size_decode(sTypedefName, p, sAcc, noSizeMin, nSizeMax, s
ret = (<if(noSizeMin)>(<noSizeMin>\<=<sExtFld>) && <endif>(<sExtFld>\<=<nSizeMax>));
if (ret) {
ret = BitStream_DecodeOctetString_no_length(pBitStrm, <p><sAcc>arr, <nSizeMax>);
<A(sErrCode)>
}
>>

Expand Down Expand Up @@ -1129,6 +1131,7 @@ octet_string_containing_ext_field_func_decode(p, sFuncName, sReqBytesForUperEnco
*pErrCode = ret ? 0 : <sErrCode>;
if (ret) {
ret = BitStream_DecodeOctetString_no_length(pBitStrm, arr, (int)<sExtField>);
<A(sErrCode)>
if (ret) {
pBitStrm = &bitStrm;
<soInner>
Expand Down

0 comments on commit 8f608f3

Please sign in to comment.