X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=sim%2Fe2-interface.git;a=blobdiff_plain;f=e2sim%2Fprevious%2Fsrc%2FASN1%2Fasn%2Fper%2Fostring.hpp;fp=e2sim%2Fprevious%2Fsrc%2FASN1%2Fasn%2Fper%2Fostring.hpp;h=0000000000000000000000000000000000000000;hp=4d601bb029b17345f8c2114f1196f590ec52d54f;hb=f86662b5b6481f27e18313a36355871f3a947193;hpb=a9f02a2b5886990fd81e64f7c218c5d4844f18a3 diff --git a/e2sim/previous/src/ASN1/asn/per/ostring.hpp b/e2sim/previous/src/ASN1/asn/per/ostring.hpp deleted file mode 100755 index 4d601bb..0000000 --- a/e2sim/previous/src/ASN1/asn/per/ostring.hpp +++ /dev/null @@ -1,209 +0,0 @@ -#pragma once -/****************************************************************************** -* -* Copyright (c) 2019 AT&T Intellectual Property. -* Copyright (c) 2018-2019 Nokia. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -******************************************************************************/ - -// Standard Includes: ANSI C/C++, MSA, and Third-Party Libraries - -// Local Includes: Application specific classes, functions, and libraries -#include "asn/per/common.hpp" - -namespace asn { -namespace per { - -template < class IE, class Enable = void> -struct Octetstring; - -//16.8 Default -template -struct OctetstringNoExt -{ - static void inline run(IE const& ie, EncoderCtx& ctx) - { - bound_t size = ie.get().size(); - LengthDeterminant::run(ctx, size); - Tools::bit_accessor::padByte(ctx.refBuffer()); - ctx.refBuffer().putBytes(ie.get().data(), size); - } - static void inline run(IE& ie, DecoderCtx& ctx) - { - size_t len = LengthDeterminant::run(ctx, false); - Tools::bit_accessor::padByte(ctx.refBuffer()); - u8 const* data_in = ctx.refBuffer().getBytes(len); - - if (data_in) - { - ie.set(len, data_in); - } - - } -}; - -//16.5 Zero length -template -struct OctetstringNoExt > -{ - static void inline run(IE const& ie, EncoderCtx& ctx) {/* do nothing */ } - static void inline run(IE& ie, DecoderCtx& ctx) { ie.setpresent(true); } -}; - -//16.6 Up to two octets, fixed length -template -struct OctetstringNoExt> -{ - static void inline run(IE const& ie, EncoderCtx& ctx) - { - Tools::bit_accessor::put(static_cast(ie.get().data()[0]), 8, ctx.refBuffer()); - } - static void inline run(IE& ie, DecoderCtx& ctx) - { - u8 data_in = Tools::bit_accessor::get(8, ctx.refBuffer()); - u8* data_out = ctx.refAllocator().alloc_bytes(1); - if (data_out) { - data_out[0] = data_in; - ie.set(1, data_out); - } - else - ctx.refErrorCtx().allocatorNoMem(0, 1); - } -}; - -template -struct OctetstringNoExt> -{ - static void inline run(IE const& ie, EncoderCtx& ctx) - { - Tools::bit_accessor::put(static_cast(ie.get().data()[0]), 8, ctx.refBuffer()); - Tools::bit_accessor::put(static_cast(ie.get().data()[1]), 8, ctx.refBuffer()); - } - static void inline run(IE& ie, DecoderCtx& ctx) - { - u8 data_in[2]; - data_in[0] = Tools::bit_accessor::get(8, ctx.refBuffer()); - data_in[1] = Tools::bit_accessor::get(8, ctx.refBuffer()); - u8* data_out = ctx.refAllocator().alloc_bytes(sizeof(data_in)); - if (data_out) { - data_out[0] = data_in[0]; - data_out[1] = data_in[1]; - ie.set(sizeof(data_in), data_out); - } - else - ctx.refErrorCtx().allocatorNoMem(0, sizeof(data_in)); - } -}; - -//16.7 More than 2 octets, up to 64K, fixed length -template -struct OctetstringNoExt 2)) ->> -{ - static void inline run(IE const& ie, EncoderCtx& ctx) - { - Tools::bit_accessor::padByte(ctx.refBuffer()); - ctx.refBuffer().putBytes(ie.get().data(), ie.get().size()); - } - static void inline run(IE& ie, DecoderCtx& ctx) - { - Tools::bit_accessor::padByte(ctx.refBuffer()); - const size_t len = (size_t)IE::constraint_t::upper_bound; - u8 const* data_in = ctx.refBuffer().getBytes(len); - if (data_in) - { - ie.set(len, data_in); - } - } -}; - -/**************************************************/ - -//16.3 : Extension present -template -struct Octetstring > -{ - static void inline run(IE const& ie, EncoderCtx& ctx) - { - bound_t size = ie.get().size(); - if (size <= IE::constraint_t::upper_bound && size >= IE::constraint_t::lower_bound) - { - Tools::bit_accessor::put(0, 1, ctx.refBuffer()); - OctetstringNoExt::run(ie, ctx); - } - else - { - Tools::bit_accessor::put(1, 1, ctx.refBuffer()); - Tools::bit_accessor::padByte(ctx.refBuffer()); - LengthDeterminant::run(ctx, size); - Tools::bit_accessor::padByte(ctx.refBuffer()); - ctx.refBuffer().putBytes(ie.get().data(), size); - } - } - static void inline run(IE& ie, DecoderCtx& ctx) - { - u8 ext = Tools::bit_accessor::get(1, ctx.refBuffer()); - if (ext) - { - Tools::bit_accessor::padByte(ctx.refBuffer()); - size_t len = LengthDeterminant::run(ctx, true); - Tools::bit_accessor::padByte(ctx.refBuffer()); - u8 const* data_in = ctx.refBuffer().getBytes(len); - if (data_in) - { - ie.set(len, data_in); - } - } - else - OctetstringNoExt::run(ie, ctx); - } -}; - -//16.4 : No extension -template -struct Octetstring > -{ - static void inline run(IE const& ie, EncoderCtx& ctx) - { - if ( ie.get().size() > size_t(IE::constraint_t::upper_bound) || - (IE::constraint_t::lower_bound >= 0 && ie.get().size() < size_t(IE::constraint_t::lower_bound))) - { - ctx.refErrorCtx().sizeRangeError(ie.get().size(), size_t(IE::constraint_t::lower_bound), - size_t(IE::constraint_t::upper_bound)); - } - else - { - OctetstringNoExt::run(ie, ctx); - } - } - static void inline run(IE& ie, DecoderCtx& ctx) - { - OctetstringNoExt::run(ie, ctx); - if ( ie.get().size() > size_t(IE::constraint_t::upper_bound) || - (IE::constraint_t::lower_bound >= 0 && ie.get().size() < size_t(IE::constraint_t::lower_bound))) - { - ctx.refErrorCtx().sizeRangeError(ie.get().size(), size_t(IE::constraint_t::lower_bound), - size_t(IE::constraint_t::upper_bound)); - } - } -}; - -} //namespace per -} //namespace asn