X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=e2sim%2FASN1c%2FANY.h;fp=e2sim%2FASN1c%2FANY.h;h=fbdfec63d75857773386207d7270c0b495d0776b;hb=1f1098ad65c5d27ab5aae14d55c5159dd1e8e01b;hp=0000000000000000000000000000000000000000;hpb=d09fbb9e5157cc0d30da61b79fd85cad314817ce;p=sim%2Fe2-interface.git diff --git a/e2sim/ASN1c/ANY.h b/e2sim/ASN1c/ANY.h new file mode 100644 index 0000000..fbdfec6 --- /dev/null +++ b/e2sim/ASN1c/ANY.h @@ -0,0 +1,83 @@ +/***************************************************************************** +# * +# Copyright 2019 AT&T Intellectual Property * +# * +# 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. * +# * +******************************************************************************/ + +/*- + * Copyright (c) 2004-2017 Lev Walkin . All rights reserved. + * Redistribution and modifications are permitted subject to BSD license. + */ +#ifndef ASN_TYPE_ANY_H +#define ASN_TYPE_ANY_H + +#include /* Implemented via OCTET STRING type */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ANY { + uint8_t *buf; /* BER-encoded ANY contents */ + int size; /* Size of the above buffer */ + + asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */ +} ANY_t; + +extern asn_TYPE_descriptor_t asn_DEF_ANY; +extern asn_TYPE_operation_t asn_OP_ANY; +extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs; + +asn_struct_free_f ANY_free; +asn_struct_print_f ANY_print; +ber_type_decoder_f ANY_decode_ber; +der_type_encoder_f ANY_encode_der; +xer_type_encoder_f ANY_encode_xer; +per_type_decoder_f ANY_decode_uper; +per_type_encoder_f ANY_encode_uper; +per_type_decoder_f ANY_decode_aper; +per_type_encoder_f ANY_encode_aper; + +#define ANY_free OCTET_STRING_free +#define ANY_print OCTET_STRING_print +#define ANY_compare OCTET_STRING_compare +#define ANY_constraint asn_generic_no_constraint +#define ANY_decode_ber OCTET_STRING_decode_ber +#define ANY_encode_der OCTET_STRING_encode_der +#define ANY_decode_xer OCTET_STRING_decode_xer_hex + +/****************************** + * Handy conversion routines. * + ******************************/ + +/* Convert another ASN.1 type into the ANY. This implies DER encoding. */ +int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr); +int ANY_fromType_aper(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr); +ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr); +ANY_t *ANY_new_fromType_aper(asn_TYPE_descriptor_t *td, void *sptr); + +/* Convert the contents of the ANY type into the specified type. */ +int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr); +int ANY_to_type_aper(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr); + +#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size)) +#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \ + &asn_DEF_ANY, (buf), (size)) + +#ifdef __cplusplus +} +#endif + +#endif /* ASN_TYPE_ANY_H */