mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-22 23:17:03 +00:00
Add and apply readability-braces-around-statements check
This commit is contained in:
parent
61c22ed53b
commit
7126185515
@ -99,6 +99,7 @@ Checks: '-*,
|
|||||||
performance-unnecessary-copy-initialization,
|
performance-unnecessary-copy-initialization,
|
||||||
performance-unnecessary-value-param,
|
performance-unnecessary-value-param,
|
||||||
readability-avoid-const-params-in-decls,
|
readability-avoid-const-params-in-decls,
|
||||||
|
readability-braces-around-statements,
|
||||||
readability-container-size-empty,
|
readability-container-size-empty,
|
||||||
readability-identifier-naming,
|
readability-identifier-naming,
|
||||||
readability-inconsistent-declaration-parameter-name,
|
readability-inconsistent-declaration-parameter-name,
|
||||||
@ -194,8 +195,6 @@ CheckOptions:
|
|||||||
value: CamelCase
|
value: CamelCase
|
||||||
- key: modernize-pass-by-value.IncludeStyle
|
- key: modernize-pass-by-value.IncludeStyle
|
||||||
value: llvm
|
value: llvm
|
||||||
- key: modernize-pass-by-value.ValuesOnly
|
|
||||||
value: '0'
|
|
||||||
- key: modernize-raw-string-literal.ReplaceShorterLiterals
|
- key: modernize-raw-string-literal.ReplaceShorterLiterals
|
||||||
value: '0'
|
value: '0'
|
||||||
- key: modernize-replace-auto-ptr.IncludeStyle
|
- key: modernize-replace-auto-ptr.IncludeStyle
|
||||||
@ -248,6 +247,8 @@ CheckOptions:
|
|||||||
value: ''
|
value: ''
|
||||||
- key: performance-unnecessary-value-param.IncludeStyle
|
- key: performance-unnecessary-value-param.IncludeStyle
|
||||||
value: llvm
|
value: llvm
|
||||||
|
- key: readability-braces-around-statements.ShortStatementLines
|
||||||
|
value: '0'
|
||||||
- key: readability-identifier-naming.AbstractClassCase
|
- key: readability-identifier-naming.AbstractClassCase
|
||||||
value: CamelCase
|
value: CamelCase
|
||||||
- key: readability-identifier-naming.AbstractClassPrefix
|
- key: readability-identifier-naming.AbstractClassPrefix
|
||||||
|
@ -3661,28 +3661,28 @@ uint32_t Rtcm::msm_lock_time_indicator(uint32_t lock_time_period_s)
|
|||||||
uint32_t Rtcm::msm_extended_lock_time_indicator(uint32_t lock_time_period_s)
|
uint32_t Rtcm::msm_extended_lock_time_indicator(uint32_t lock_time_period_s)
|
||||||
{
|
{
|
||||||
// Table 3.5-75
|
// Table 3.5-75
|
||||||
if( lock_time_period_s < 64 ) return ( lock_time_period_s );
|
if( lock_time_period_s < 64 ) return ( lock_time_period_s ); // NOLINT
|
||||||
if( 64 <= lock_time_period_s && lock_time_period_s < 128 ) return ( 64 + (lock_time_period_s - 64 ) / 2 );
|
if( 64 <= lock_time_period_s && lock_time_period_s < 128 ) return ( 64 + (lock_time_period_s - 64 ) / 2 ); // NOLINT
|
||||||
if( 128 <= lock_time_period_s && lock_time_period_s < 256 ) return ( 96 + (lock_time_period_s - 128 ) / 4 );
|
if( 128 <= lock_time_period_s && lock_time_period_s < 256 ) return ( 96 + (lock_time_period_s - 128 ) / 4 ); // NOLINT
|
||||||
if( 256 <= lock_time_period_s && lock_time_period_s < 512 ) return (128 + (lock_time_period_s - 256 ) / 8 );
|
if( 256 <= lock_time_period_s && lock_time_period_s < 512 ) return (128 + (lock_time_period_s - 256 ) / 8 ); // NOLINT
|
||||||
if( 512 <= lock_time_period_s && lock_time_period_s < 1024 ) return (160 + (lock_time_period_s - 512 ) / 16 );
|
if( 512 <= lock_time_period_s && lock_time_period_s < 1024 ) return (160 + (lock_time_period_s - 512 ) / 16 ); // NOLINT
|
||||||
if( 1024 <= lock_time_period_s && lock_time_period_s < 2048 ) return (192 + (lock_time_period_s - 1024 ) / 32 );
|
if( 1024 <= lock_time_period_s && lock_time_period_s < 2048 ) return (192 + (lock_time_period_s - 1024 ) / 32 ); // NOLINT
|
||||||
if( 2048 <= lock_time_period_s && lock_time_period_s < 4096 ) return (224 + (lock_time_period_s - 2048 ) / 64 );
|
if( 2048 <= lock_time_period_s && lock_time_period_s < 4096 ) return (224 + (lock_time_period_s - 2048 ) / 64 ); // NOLINT
|
||||||
if( 4096 <= lock_time_period_s && lock_time_period_s < 8192 ) return (256 + (lock_time_period_s - 4096 ) / 128 );
|
if( 4096 <= lock_time_period_s && lock_time_period_s < 8192 ) return (256 + (lock_time_period_s - 4096 ) / 128 ); // NOLINT
|
||||||
if( 8192 <= lock_time_period_s && lock_time_period_s < 16384 ) return (288 + (lock_time_period_s - 8192 ) / 256 );
|
if( 8192 <= lock_time_period_s && lock_time_period_s < 16384 ) return (288 + (lock_time_period_s - 8192 ) / 256 ); // NOLINT
|
||||||
if( 16384 <= lock_time_period_s && lock_time_period_s < 32768 ) return (320 + (lock_time_period_s - 16384 ) / 512 );
|
if( 16384 <= lock_time_period_s && lock_time_period_s < 32768 ) return (320 + (lock_time_period_s - 16384 ) / 512 ); // NOLINT
|
||||||
if( 32768 <= lock_time_period_s && lock_time_period_s < 65536 ) return (352 + (lock_time_period_s - 32768 ) / 1024 );
|
if( 32768 <= lock_time_period_s && lock_time_period_s < 65536 ) return (352 + (lock_time_period_s - 32768 ) / 1024 ); // NOLINT
|
||||||
if( 65536 <= lock_time_period_s && lock_time_period_s < 131072 ) return (384 + (lock_time_period_s - 65536 ) / 2048 );
|
if( 65536 <= lock_time_period_s && lock_time_period_s < 131072 ) return (384 + (lock_time_period_s - 65536 ) / 2048 ); // NOLINT
|
||||||
if( 131072 <= lock_time_period_s && lock_time_period_s < 262144 ) return (416 + (lock_time_period_s - 131072 ) / 4096 );
|
if( 131072 <= lock_time_period_s && lock_time_period_s < 262144 ) return (416 + (lock_time_period_s - 131072 ) / 4096 ); // NOLINT
|
||||||
if( 262144 <= lock_time_period_s && lock_time_period_s < 524288 ) return (448 + (lock_time_period_s - 262144 ) / 8192 );
|
if( 262144 <= lock_time_period_s && lock_time_period_s < 524288 ) return (448 + (lock_time_period_s - 262144 ) / 8192 ); // NOLINT
|
||||||
if( 524288 <= lock_time_period_s && lock_time_period_s < 1048576 ) return (480 + (lock_time_period_s - 524288 ) / 16384 );
|
if( 524288 <= lock_time_period_s && lock_time_period_s < 1048576 ) return (480 + (lock_time_period_s - 524288 ) / 16384 ); // NOLINT
|
||||||
if( 1048576 <= lock_time_period_s && lock_time_period_s < 2097152 ) return (512 + (lock_time_period_s - 1048576 ) / 32768 );
|
if( 1048576 <= lock_time_period_s && lock_time_period_s < 2097152 ) return (512 + (lock_time_period_s - 1048576 ) / 32768 ); // NOLINT
|
||||||
if( 2097152 <= lock_time_period_s && lock_time_period_s < 4194304 ) return (544 + (lock_time_period_s - 2097152 ) / 65536 );
|
if( 2097152 <= lock_time_period_s && lock_time_period_s < 4194304 ) return (544 + (lock_time_period_s - 2097152 ) / 65536 ); // NOLINT
|
||||||
if( 4194304 <= lock_time_period_s && lock_time_period_s < 8388608 ) return (576 + (lock_time_period_s - 4194304 ) / 131072 );
|
if( 4194304 <= lock_time_period_s && lock_time_period_s < 8388608 ) return (576 + (lock_time_period_s - 4194304 ) / 131072 ); // NOLINT
|
||||||
if( 8388608 <= lock_time_period_s && lock_time_period_s < 16777216 ) return (608 + (lock_time_period_s - 8388608 ) / 262144 );
|
if( 8388608 <= lock_time_period_s && lock_time_period_s < 16777216 ) return (608 + (lock_time_period_s - 8388608 ) / 262144 ); // NOLINT
|
||||||
if( 16777216 <= lock_time_period_s && lock_time_period_s < 33554432 ) return (640 + (lock_time_period_s - 16777216) / 524288 );
|
if( 16777216 <= lock_time_period_s && lock_time_period_s < 33554432 ) return (640 + (lock_time_period_s - 16777216) / 524288 ); // NOLINT
|
||||||
if( 33554432 <= lock_time_period_s && lock_time_period_s < 67108864 ) return (672 + (lock_time_period_s - 33554432) / 1048576);
|
if( 33554432 <= lock_time_period_s && lock_time_period_s < 67108864 ) return (672 + (lock_time_period_s - 33554432) / 1048576); // NOLINT
|
||||||
if( 67108864 <= lock_time_period_s ) return (704 );
|
if( 67108864 <= lock_time_period_s ) return (704 ); // NOLINT
|
||||||
return 1023; // will never happen
|
return 1023; // will never happen
|
||||||
}
|
}
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -72,7 +72,10 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
|
|||||||
acq_parameters.fs_in = fs_in;
|
acq_parameters.fs_in = fs_in;
|
||||||
|
|
||||||
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
|
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
|
||||||
if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max;
|
if (FLAGS_doppler_max != 0)
|
||||||
|
{
|
||||||
|
doppler_max_ = FLAGS_doppler_max;
|
||||||
|
}
|
||||||
acq_parameters.doppler_max = doppler_max_;
|
acq_parameters.doppler_max = doppler_max_;
|
||||||
|
|
||||||
acquire_pilot_ = configuration_->property(role + ".acquire_pilot", false); // could be true in future versions
|
acquire_pilot_ = configuration_->property(role + ".acquire_pilot", false); // could be true in future versions
|
||||||
|
@ -69,7 +69,10 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf
|
|||||||
acq_parameters.fs_in = fs_in;
|
acq_parameters.fs_in = fs_in;
|
||||||
|
|
||||||
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
|
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
|
||||||
if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max;
|
if (FLAGS_doppler_max != 0)
|
||||||
|
{
|
||||||
|
doppler_max_ = FLAGS_doppler_max;
|
||||||
|
}
|
||||||
acq_parameters.doppler_max = doppler_max_;
|
acq_parameters.doppler_max = doppler_max_;
|
||||||
|
|
||||||
acq_pilot_ = configuration_->property(role + ".acquire_pilot", false);
|
acq_pilot_ = configuration_->property(role + ".acquire_pilot", false);
|
||||||
|
@ -71,7 +71,10 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
|
|||||||
|
|
||||||
acq_parameters.fs_in = fs_in;
|
acq_parameters.fs_in = fs_in;
|
||||||
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
|
doppler_max_ = configuration_->property(role + ".doppler_max", 5000);
|
||||||
if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max;
|
if (FLAGS_doppler_max != 0)
|
||||||
|
{
|
||||||
|
doppler_max_ = FLAGS_doppler_max;
|
||||||
|
}
|
||||||
acq_parameters.doppler_max = doppler_max_;
|
acq_parameters.doppler_max = doppler_max_;
|
||||||
auto code_length = static_cast<uint32_t>(std::round(static_cast<double>(fs_in) / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS)));
|
auto code_length = static_cast<uint32_t>(std::round(static_cast<double>(fs_in) / (GPS_L1_CA_CODE_RATE_CPS / GPS_L1_CA_CODE_LENGTH_CHIPS)));
|
||||||
acq_parameters.code_length = code_length;
|
acq_parameters.code_length = code_length;
|
||||||
|
@ -68,7 +68,10 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga(
|
|||||||
DLOG(INFO) << role << " satellite repeat = " << acq_parameters.repeat_satellite;
|
DLOG(INFO) << role << " satellite repeat = " << acq_parameters.repeat_satellite;
|
||||||
|
|
||||||
doppler_max_ = configuration->property(role + ".doppler_max", 5000);
|
doppler_max_ = configuration->property(role + ".doppler_max", 5000);
|
||||||
if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max;
|
if (FLAGS_doppler_max != 0)
|
||||||
|
{
|
||||||
|
doppler_max_ = FLAGS_doppler_max;
|
||||||
|
}
|
||||||
acq_parameters.doppler_max = doppler_max_;
|
acq_parameters.doppler_max = doppler_max_;
|
||||||
|
|
||||||
unsigned int code_length = std::round(static_cast<double>(fs_in_) / (GPS_L2_M_CODE_RATE_CPS / static_cast<double>(GPS_L2_M_CODE_LENGTH_CHIPS)));
|
unsigned int code_length = std::round(static_cast<double>(fs_in_) / (GPS_L2_M_CODE_RATE_CPS / static_cast<double>(GPS_L2_M_CODE_LENGTH_CHIPS)));
|
||||||
|
@ -73,7 +73,10 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
|
|||||||
|
|
||||||
acq_parameters.fs_in = fs_in;
|
acq_parameters.fs_in = fs_in;
|
||||||
doppler_max_ = configuration->property(role + ".doppler_max", 5000);
|
doppler_max_ = configuration->property(role + ".doppler_max", 5000);
|
||||||
if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max;
|
if (FLAGS_doppler_max != 0)
|
||||||
|
{
|
||||||
|
doppler_max_ = FLAGS_doppler_max;
|
||||||
|
}
|
||||||
acq_parameters.doppler_max = doppler_max_;
|
acq_parameters.doppler_max = doppler_max_;
|
||||||
|
|
||||||
// -- Find number of samples per spreading code -------------------------
|
// -- Find number of samples per spreading code -------------------------
|
||||||
|
@ -68,10 +68,16 @@ GpsL2MDllPllTrackingFpga::GpsL2MDllPllTrackingFpga(
|
|||||||
bool dump_mat = configuration->property(role + ".dump_mat", true);
|
bool dump_mat = configuration->property(role + ".dump_mat", true);
|
||||||
trk_param_fpga.dump_mat = dump_mat;
|
trk_param_fpga.dump_mat = dump_mat;
|
||||||
float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 2.0);
|
float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 2.0);
|
||||||
if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast<float>(FLAGS_pll_bw_hz);
|
if (FLAGS_pll_bw_hz != 0.0)
|
||||||
|
{
|
||||||
|
pll_bw_hz = static_cast<float>(FLAGS_pll_bw_hz);
|
||||||
|
}
|
||||||
trk_param_fpga.pll_bw_hz = pll_bw_hz;
|
trk_param_fpga.pll_bw_hz = pll_bw_hz;
|
||||||
float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.75);
|
float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.75);
|
||||||
if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast<float>(FLAGS_dll_bw_hz);
|
if (FLAGS_dll_bw_hz != 0.0)
|
||||||
|
{
|
||||||
|
dll_bw_hz = static_cast<float>(FLAGS_dll_bw_hz);
|
||||||
|
}
|
||||||
trk_param_fpga.dll_bw_hz = dll_bw_hz;
|
trk_param_fpga.dll_bw_hz = dll_bw_hz;
|
||||||
float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5);
|
float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5);
|
||||||
trk_param_fpga.early_late_space_chips = early_late_space_chips;
|
trk_param_fpga.early_late_space_chips = early_late_space_chips;
|
||||||
|
@ -1513,7 +1513,10 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un
|
|||||||
{
|
{
|
||||||
d_worker_is_done = false;
|
d_worker_is_done = false;
|
||||||
boost::mutex::scoped_lock lock(d_mutex);
|
boost::mutex::scoped_lock lock(d_mutex);
|
||||||
while (!d_worker_is_done) m_condition.wait(lock);
|
while (!d_worker_is_done)
|
||||||
|
{
|
||||||
|
m_condition.wait(lock);
|
||||||
|
}
|
||||||
|
|
||||||
// Signal alignment (skip samples until the incoming signal is aligned with local replica)
|
// Signal alignment (skip samples until the incoming signal is aligned with local replica)
|
||||||
int64_t acq_trk_diff_samples;
|
int64_t acq_trk_diff_samples;
|
||||||
|
@ -48,7 +48,9 @@ static void Accuracy_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void AlertFlag_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -49,7 +49,9 @@ static void AntiSpoofFlag_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void BCCHCarrier_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -80,7 +80,10 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
uint8_t *end;
|
uint8_t *end;
|
||||||
|
|
||||||
if (!st || !st->buf) _ASN_ENCODE_FAILED;
|
if (!st || !st->buf)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
er.encoded = 0;
|
er.encoded = 0;
|
||||||
|
|
||||||
@ -99,14 +102,20 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
er.encoded += p - scratch;
|
er.encoded += p - scratch;
|
||||||
_ASN_CALLBACK(scratch, p - scratch);
|
_ASN_CALLBACK(scratch, p - scratch);
|
||||||
p = scratch;
|
p = scratch;
|
||||||
if (nline) _i_ASN_TEXT_INDENT(1, ilevel);
|
if (nline)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
memcpy(p + 0, _bit_pattern[v >> 4], 4);
|
memcpy(p + 0, _bit_pattern[v >> 4], 4);
|
||||||
memcpy(p + 4, _bit_pattern[v & 0x0f], 4);
|
memcpy(p + 4, _bit_pattern[v & 0x0f], 4);
|
||||||
p += 8;
|
p += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xcan && ((buf - st->buf) % 8) == 0) _i_ASN_TEXT_INDENT(1, ilevel);
|
if (!xcan && ((buf - st->buf) % 8) == 0)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||||
|
}
|
||||||
er.encoded += p - scratch;
|
er.encoded += p - scratch;
|
||||||
_ASN_CALLBACK(scratch, p - scratch);
|
_ASN_CALLBACK(scratch, p - scratch);
|
||||||
p = scratch;
|
p = scratch;
|
||||||
@ -116,12 +125,18 @@ asn_enc_rval_t BIT_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
int v = *buf;
|
int v = *buf;
|
||||||
int ubits = st->bits_unused;
|
int ubits = st->bits_unused;
|
||||||
int i;
|
int i;
|
||||||
for (i = 7; i >= ubits; i--) *p++ = (v & (1 << i)) ? 0x31 : 0x30;
|
for (i = 7; i >= ubits; i--)
|
||||||
|
{
|
||||||
|
*p++ = (v & (1 << i)) ? 0x31 : 0x30;
|
||||||
|
}
|
||||||
er.encoded += p - scratch;
|
er.encoded += p - scratch;
|
||||||
_ASN_CALLBACK(scratch, p - scratch);
|
_ASN_CALLBACK(scratch, p - scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
if (!xcan)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
cb_failed:
|
cb_failed:
|
||||||
@ -143,7 +158,10 @@ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
|
|
||||||
(void)td; /* Unused argument */
|
(void)td; /* Unused argument */
|
||||||
|
|
||||||
if (!st || !st->buf) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
if (!st || !st->buf)
|
||||||
|
{
|
||||||
|
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
ilevel++;
|
ilevel++;
|
||||||
buf = st->buf;
|
buf = st->buf;
|
||||||
@ -158,7 +176,10 @@ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
{
|
{
|
||||||
_i_INDENT(1);
|
_i_INDENT(1);
|
||||||
/* Dump the string */
|
/* Dump the string */
|
||||||
if (cb(scratch, p - scratch, app_key) < 0) return -1;
|
if (cb(scratch, p - scratch, app_key) < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
p = scratch;
|
p = scratch;
|
||||||
}
|
}
|
||||||
*p++ = h2c[*buf >> 4];
|
*p++ = h2c[*buf >> 4];
|
||||||
@ -176,7 +197,10 @@ int BIT_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Dump the incomplete 16-bytes row */
|
/* Dump the incomplete 16-bytes row */
|
||||||
if (cb(scratch, p - scratch, app_key) < 0) return -1;
|
if (cb(scratch, p - scratch, app_key) < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -65,7 +65,10 @@ asn_dec_rval_t BOOLEAN_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
*/
|
*/
|
||||||
rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0,
|
rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0,
|
||||||
&length, 0);
|
&length, 0);
|
||||||
if (rval.code != RC_OK) return rval;
|
if (rval.code != RC_OK)
|
||||||
|
{
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Boolean length is %d bytes", (int)length);
|
ASN_DEBUG("Boolean length is %d bytes", (int)length);
|
||||||
|
|
||||||
@ -159,7 +162,9 @@ static enum xer_pbd_rval BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td,
|
|||||||
case XCT_UNKNOWN_BO:
|
case XCT_UNKNOWN_BO:
|
||||||
if (xer_check_tag(chunk_buf, chunk_size, "true") !=
|
if (xer_check_tag(chunk_buf, chunk_size, "true") !=
|
||||||
XCT_BOTH)
|
XCT_BOTH)
|
||||||
return XPBD_BROKEN_ENCODING;
|
{
|
||||||
|
return XPBD_BROKEN_ENCODING;
|
||||||
|
}
|
||||||
/* "<true/>" */
|
/* "<true/>" */
|
||||||
*st = 1; /* Or 0xff as in DER?.. */
|
*st = 1; /* Or 0xff as in DER?.. */
|
||||||
break;
|
break;
|
||||||
@ -171,9 +176,13 @@ static enum xer_pbd_rval BOOLEAN__xer_body_decode(asn_TYPE_descriptor_t *td,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (xer_is_whitespace(chunk_buf, chunk_size))
|
if (xer_is_whitespace(chunk_buf, chunk_size))
|
||||||
return XPBD_NOT_BODY_IGNORE;
|
{
|
||||||
|
return XPBD_NOT_BODY_IGNORE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return XPBD_BROKEN_ENCODING;
|
{
|
||||||
|
return XPBD_BROKEN_ENCODING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +206,10 @@ asn_enc_rval_t BOOLEAN_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
(void)ilevel;
|
(void)ilevel;
|
||||||
(void)flags;
|
(void)flags;
|
||||||
|
|
||||||
if (!st) _ASN_ENCODE_FAILED;
|
if (!st)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (*st)
|
if (*st)
|
||||||
{
|
{
|
||||||
@ -269,7 +281,10 @@ asn_dec_rval_t BOOLEAN_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (!st)
|
if (!st)
|
||||||
{
|
{
|
||||||
st = (BOOLEAN_t *)(*sptr = MALLOC(sizeof(*st)));
|
st = (BOOLEAN_t *)(*sptr = MALLOC(sizeof(*st)));
|
||||||
if (!st) _ASN_DECODE_FAILED;
|
if (!st)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -304,7 +319,10 @@ asn_enc_rval_t BOOLEAN_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
|
|
||||||
(void)constraints;
|
(void)constraints;
|
||||||
|
|
||||||
if (!st) _ASN_ENCODE_FAILED;
|
if (!st)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
per_put_few_bits(po, *st ? 1 : 0, 1);
|
per_put_few_bits(po, *st ? 1 : 0, 1);
|
||||||
|
|
||||||
|
@ -48,7 +48,9 @@ static void BSIC_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -50,8 +50,10 @@ static void BTSPosition_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_Ext_GeographicalInformation.uper_decoder;
|
td->uper_decoder = asn_DEF_Ext_GeographicalInformation.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_Ext_GeographicalInformation.uper_encoder;
|
td->uper_encoder = asn_DEF_Ext_GeographicalInformation.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints =
|
{
|
||||||
asn_DEF_Ext_GeographicalInformation.per_constraints;
|
td->per_constraints =
|
||||||
|
asn_DEF_Ext_GeographicalInformation.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_Ext_GeographicalInformation.elements;
|
td->elements = asn_DEF_Ext_GeographicalInformation.elements;
|
||||||
td->elements_count = asn_DEF_Ext_GeographicalInformation.elements_count;
|
td->elements_count = asn_DEF_Ext_GeographicalInformation.elements_count;
|
||||||
td->specifics = asn_DEF_Ext_GeographicalInformation.specifics;
|
td->specifics = asn_DEF_Ext_GeographicalInformation.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void BitNumber_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void CellID_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -49,13 +49,21 @@ asn_dec_rval_t ENUMERATED_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (!st)
|
if (!st)
|
||||||
{
|
{
|
||||||
st = (ENUMERATED_t *)(*sptr = CALLOC(1, sizeof(*st)));
|
st = (ENUMERATED_t *)(*sptr = CALLOC(1, sizeof(*st)));
|
||||||
if (!st) _ASN_DECODE_FAILED;
|
if (!st)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rval =
|
rval =
|
||||||
NativeEnumerated_decode_uper(opt_codec_ctx, td, constraints, &vptr, pd);
|
NativeEnumerated_decode_uper(opt_codec_ctx, td, constraints, &vptr, pd);
|
||||||
if (rval.code == RC_OK)
|
if (rval.code == RC_OK)
|
||||||
if (asn_long2INTEGER(st, value)) rval.code = RC_FAIL;
|
{
|
||||||
|
if (asn_long2INTEGER(st, value))
|
||||||
|
{
|
||||||
|
rval.code = RC_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +74,10 @@ asn_enc_rval_t ENUMERATED_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
ENUMERATED_t *st = (ENUMERATED_t *)sptr;
|
ENUMERATED_t *st = (ENUMERATED_t *)sptr;
|
||||||
int64_t value;
|
int64_t value;
|
||||||
|
|
||||||
if (asn_INTEGER2long(st, &value)) _ASN_ENCODE_FAILED;
|
if (asn_INTEGER2long(st, &value))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
return NativeEnumerated_encode_uper(td, constraints, &value, po);
|
return NativeEnumerated_encode_uper(td, constraints, &value, po);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,9 @@ static void EnvironmentCharacter_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -29,7 +29,9 @@ static void ErrorCodes_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -50,7 +50,9 @@ static void ExpOTDUncertainty_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void ExpectedOTD_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -51,7 +51,9 @@ static void Ext_GeographicalInformation_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder;
|
td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder;
|
td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_OCTET_STRING.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_OCTET_STRING.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_OCTET_STRING.elements;
|
td->elements = asn_DEF_OCTET_STRING.elements;
|
||||||
td->elements_count = asn_DEF_OCTET_STRING.elements_count;
|
td->elements_count = asn_DEF_OCTET_STRING.elements_count;
|
||||||
td->specifics = asn_DEF_OCTET_STRING.specifics;
|
td->specifics = asn_DEF_OCTET_STRING.specifics;
|
||||||
|
@ -31,7 +31,9 @@ static void ExtensionContainer_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_INTEGER.uper_decoder;
|
td->uper_decoder = asn_DEF_INTEGER.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_INTEGER.uper_encoder;
|
td->uper_encoder = asn_DEF_INTEGER.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_INTEGER.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_INTEGER.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_INTEGER.elements;
|
td->elements = asn_DEF_INTEGER.elements;
|
||||||
td->elements_count = asn_DEF_INTEGER.elements_count;
|
td->elements_count = asn_DEF_INTEGER.elements_count;
|
||||||
td->specifics = asn_DEF_INTEGER.specifics;
|
td->specifics = asn_DEF_INTEGER.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void FineRTD_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void FixType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void FrameDrift_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void FrameNumber_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -51,7 +51,9 @@ static void GANSSAssistanceData_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder;
|
td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder;
|
td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_OCTET_STRING.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_OCTET_STRING.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_OCTET_STRING.elements;
|
td->elements = asn_DEF_OCTET_STRING.elements;
|
||||||
td->elements_count = asn_DEF_OCTET_STRING.elements_count;
|
td->elements_count = asn_DEF_OCTET_STRING.elements_count;
|
||||||
td->specifics = asn_DEF_OCTET_STRING.specifics;
|
td->specifics = asn_DEF_OCTET_STRING.specifics;
|
||||||
|
@ -49,7 +49,9 @@ static void GANSSDataBit_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -60,7 +60,9 @@ static void GANSSPositioningMethod_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder;
|
td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder;
|
td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_BIT_STRING.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_BIT_STRING.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_BIT_STRING.elements;
|
td->elements = asn_DEF_BIT_STRING.elements;
|
||||||
td->elements_count = asn_DEF_BIT_STRING.elements_count;
|
td->elements_count = asn_DEF_BIT_STRING.elements_count;
|
||||||
td->specifics = asn_DEF_BIT_STRING.specifics;
|
td->specifics = asn_DEF_BIT_STRING.specifics;
|
||||||
|
@ -49,7 +49,9 @@ static void GANSSSignalID_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void GANSSTOD_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -50,7 +50,9 @@ static void GANSSTODUncertainty_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void GANSSTODm_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -51,7 +51,9 @@ static void GPSAssistanceData_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder;
|
td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder;
|
td->uper_encoder = asn_DEF_OCTET_STRING.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_OCTET_STRING.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_OCTET_STRING.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_OCTET_STRING.elements;
|
td->elements = asn_DEF_OCTET_STRING.elements;
|
||||||
td->elements_count = asn_DEF_OCTET_STRING.elements_count;
|
td->elements_count = asn_DEF_OCTET_STRING.elements_count;
|
||||||
td->specifics = asn_DEF_OCTET_STRING.specifics;
|
td->specifics = asn_DEF_OCTET_STRING.specifics;
|
||||||
|
@ -50,7 +50,9 @@ static void GPSReferenceTimeUncertainty_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void GPSTOW23b_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void GPSTOW24b_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void GPSWeek_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -72,10 +72,16 @@ asn_enc_rval_t INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
switch (*buf)
|
switch (*buf)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
if ((buf[1] & 0x80) == 0) continue;
|
if ((buf[1] & 0x80) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0xff:
|
case 0xff:
|
||||||
if ((buf[1] & 0x80)) continue;
|
if ((buf[1] & 0x80))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -91,7 +97,10 @@ asn_enc_rval_t INTEGER_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
st->size -= shift; /* New size, minus bad bytes */
|
st->size -= shift; /* New size, minus bad bytes */
|
||||||
end = nb + st->size;
|
end = nb + st->size;
|
||||||
|
|
||||||
for (; nb < end; nb++, buf++) *nb = *buf;
|
for (; nb < end; nb++, buf++)
|
||||||
|
{
|
||||||
|
*nb = *buf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* if(1) */
|
} /* if(1) */
|
||||||
@ -130,10 +139,16 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st,
|
|||||||
switch (*buf)
|
switch (*buf)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
if ((buf[1] & 0x80) == 0) continue;
|
if ((buf[1] & 0x80) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0xff:
|
case 0xff:
|
||||||
if ((buf[1] & 0x80) != 0) continue;
|
if ((buf[1] & 0x80) != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -153,7 +168,10 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
accum = (*buf & 0x80) ? -1LL : 0LL;
|
accum = (*buf & 0x80) ? -1LL : 0LL;
|
||||||
for (; buf < buf_end; buf++) accum = (accum * 256) | *buf;
|
for (; buf < buf_end; buf++)
|
||||||
|
{
|
||||||
|
accum = (accum * 256) | *buf;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
el = INTEGER_map_value2enum(specs, accum);
|
el = INTEGER_map_value2enum(specs, accum);
|
||||||
@ -162,10 +180,14 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st,
|
|||||||
scrsize = el->enum_len + 32;
|
scrsize = el->enum_len + 32;
|
||||||
scr = (char *)alloca(scrsize);
|
scr = (char *)alloca(scrsize);
|
||||||
if (plainOrXER == 0)
|
if (plainOrXER == 0)
|
||||||
ret = snprintf(scr, scrsize, "%+" PRId64 "(%s)", accum,
|
{
|
||||||
el->enum_name);
|
ret = snprintf(scr, scrsize, "%+" PRId64 "(%s)", accum,
|
||||||
|
el->enum_name);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ret = snprintf(scr, scrsize, "<%s/>", el->enum_name);
|
{
|
||||||
|
ret = snprintf(scr, scrsize, "<%s/>", el->enum_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (plainOrXER && specs && specs->strict_enumeration)
|
else if (plainOrXER && specs && specs->strict_enumeration)
|
||||||
{
|
{
|
||||||
@ -209,7 +231,10 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st,
|
|||||||
if ((p - scratch) >= (ssize_t)(sizeof(scratch) - 4))
|
if ((p - scratch) >= (ssize_t)(sizeof(scratch) - 4))
|
||||||
{
|
{
|
||||||
/* Flush buffer */
|
/* Flush buffer */
|
||||||
if (cb(scratch, p - scratch, app_key) < 0) return -1;
|
if (cb(scratch, p - scratch, app_key) < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
wrote += p - scratch;
|
wrote += p - scratch;
|
||||||
p = scratch;
|
p = scratch;
|
||||||
}
|
}
|
||||||
@ -217,7 +242,10 @@ static ssize_t INTEGER__dump(asn_TYPE_descriptor_t *td, const INTEGER_t *st,
|
|||||||
*p++ = h2c[*buf & 0x0F];
|
*p++ = h2c[*buf & 0x0F];
|
||||||
*p++ = 0x3a; /* ":" */
|
*p++ = 0x3a; /* ":" */
|
||||||
}
|
}
|
||||||
if (p != scratch) p--; /* Remove the last ":" */
|
if (p != scratch)
|
||||||
|
{
|
||||||
|
p--; /* Remove the last ":" */
|
||||||
|
}
|
||||||
|
|
||||||
wrote += p - scratch;
|
wrote += p - scratch;
|
||||||
return (cb(scratch, p - scratch, app_key) < 0) ? -1 : wrote;
|
return (cb(scratch, p - scratch, app_key) < 0) ? -1 : wrote;
|
||||||
@ -236,9 +264,13 @@ int INTEGER_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
(void)ilevel;
|
(void)ilevel;
|
||||||
|
|
||||||
if (!st || !st->buf)
|
if (!st || !st->buf)
|
||||||
ret = cb("<absent>", 8, app_key);
|
{
|
||||||
|
ret = cb("<absent>", 8, app_key);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ret = INTEGER__dump(td, st, cb, app_key, 0);
|
{
|
||||||
|
ret = INTEGER__dump(td, st, cb, app_key, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return (ret < 0) ? -1 : 0;
|
return (ret < 0) ? -1 : 0;
|
||||||
}
|
}
|
||||||
@ -266,8 +298,10 @@ static int INTEGER__compar_enum2value(const void *kp, const void *am)
|
|||||||
ptr++, name++)
|
ptr++, name++)
|
||||||
{
|
{
|
||||||
if (*ptr != *name)
|
if (*ptr != *name)
|
||||||
return *(const unsigned char *)ptr -
|
{
|
||||||
*(const unsigned char *)name;
|
return *(const unsigned char *)ptr -
|
||||||
|
*(const unsigned char *)name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return name[0] ? -1 : 0;
|
return name[0] ? -1 : 0;
|
||||||
}
|
}
|
||||||
@ -280,7 +314,10 @@ static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value(
|
|||||||
struct e2v_key key;
|
struct e2v_key key;
|
||||||
const char *lp;
|
const char *lp;
|
||||||
|
|
||||||
if (!count) return NULL;
|
if (!count)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Guaranteed: assert(lstart < lstop); */
|
/* Guaranteed: assert(lstart < lstop); */
|
||||||
/* Figure out the tag name */
|
/* Figure out the tag name */
|
||||||
@ -302,7 +339,10 @@ static const asn_INTEGER_enum_map_t *INTEGER_map_enum2value(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (lp == lstop) return NULL; /* No tag found */
|
if (lp == lstop)
|
||||||
|
{
|
||||||
|
return NULL; /* No tag found */
|
||||||
|
}
|
||||||
lstop = lp;
|
lstop = lp;
|
||||||
|
|
||||||
key.start = lstart;
|
key.start = lstart;
|
||||||
@ -326,18 +366,27 @@ static int INTEGER__compar_value2enum(const void *kp, const void *am)
|
|||||||
const asn_INTEGER_enum_map_t *el = (const asn_INTEGER_enum_map_t *)am;
|
const asn_INTEGER_enum_map_t *el = (const asn_INTEGER_enum_map_t *)am;
|
||||||
int64_t b = el->nat_value;
|
int64_t b = el->nat_value;
|
||||||
if (a < b)
|
if (a < b)
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
else if (a == b)
|
else if (a == b)
|
||||||
return 0;
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return 1;
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const asn_INTEGER_enum_map_t *INTEGER_map_value2enum(
|
const asn_INTEGER_enum_map_t *INTEGER_map_value2enum(
|
||||||
asn_INTEGER_specifics_t *specs, int64_t value)
|
asn_INTEGER_specifics_t *specs, int64_t value)
|
||||||
{
|
{
|
||||||
int count = specs ? specs->map_count : 0;
|
int count = specs ? specs->map_count : 0;
|
||||||
if (!count) return 0;
|
if (!count)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return (asn_INTEGER_enum_map_t *)bsearch(&value, specs->value2enum, count,
|
return (asn_INTEGER_enum_map_t *)bsearch(&value, specs->value2enum, count,
|
||||||
sizeof(specs->value2enum[0]),
|
sizeof(specs->value2enum[0]),
|
||||||
INTEGER__compar_value2enum);
|
INTEGER__compar_value2enum);
|
||||||
@ -387,8 +436,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td,
|
|||||||
} state = ST_SKIPSPACE;
|
} state = ST_SKIPSPACE;
|
||||||
|
|
||||||
if (chunk_size)
|
if (chunk_size)
|
||||||
ASN_DEBUG("INTEGER body %ld 0x%2x..0x%2x", (int64_t)chunk_size, *lstart,
|
{
|
||||||
lstop[-1]);
|
ASN_DEBUG("INTEGER body %ld 0x%2x..0x%2x", (int64_t)chunk_size, *lstart,
|
||||||
|
lstop[-1]);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We may have received a tag here. It will be processed inline.
|
* We may have received a tag here. It will be processed inline.
|
||||||
@ -468,8 +519,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td,
|
|||||||
{
|
{
|
||||||
int64_t new_value = value * 10;
|
int64_t new_value = value * 10;
|
||||||
|
|
||||||
if (new_value / 10 != value) /* Overflow */
|
if (new_value / 10 != value)
|
||||||
return XPBD_DECODER_LIMIT;
|
{ /* Overflow */
|
||||||
|
return XPBD_DECODER_LIMIT;
|
||||||
|
}
|
||||||
|
|
||||||
value = new_value + (lv - 0x30);
|
value = new_value + (lv - 0x30);
|
||||||
/* Check for two's complement overflow */
|
/* Check for two's complement overflow */
|
||||||
@ -524,7 +577,9 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td,
|
|||||||
ASN_DEBUG("INTEGER re-evaluate as hex form");
|
ASN_DEBUG("INTEGER re-evaluate as hex form");
|
||||||
if (INTEGER_st_prealloc(st,
|
if (INTEGER_st_prealloc(st,
|
||||||
(chunk_size / 3) + 1))
|
(chunk_size / 3) + 1))
|
||||||
return XPBD_SYSTEM_FAILURE;
|
{
|
||||||
|
return XPBD_SYSTEM_FAILURE;
|
||||||
|
}
|
||||||
state = ST_SKIPSPHEX;
|
state = ST_SKIPSPHEX;
|
||||||
lp = lstart - 1;
|
lp = lstart - 1;
|
||||||
continue;
|
continue;
|
||||||
@ -568,7 +623,9 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td,
|
|||||||
"INTEGER re-evaluate as hex form");
|
"INTEGER re-evaluate as hex form");
|
||||||
if (INTEGER_st_prealloc(
|
if (INTEGER_st_prealloc(
|
||||||
st, (chunk_size / 3) + 1))
|
st, (chunk_size / 3) + 1))
|
||||||
return XPBD_SYSTEM_FAILURE;
|
{
|
||||||
|
return XPBD_SYSTEM_FAILURE;
|
||||||
|
}
|
||||||
state = ST_SKIPSPHEX;
|
state = ST_SKIPSPHEX;
|
||||||
lp = lstart - 1;
|
lp = lstart - 1;
|
||||||
continue;
|
continue;
|
||||||
@ -599,7 +656,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td,
|
|||||||
default:
|
default:
|
||||||
if (xer_is_whitespace(lp, lstop - lp))
|
if (xer_is_whitespace(lp, lstop - lp))
|
||||||
{
|
{
|
||||||
if (state != ST_EXTRASTUFF) return XPBD_NOT_BODY_IGNORE;
|
if (state != ST_EXTRASTUFF)
|
||||||
|
{
|
||||||
|
return XPBD_NOT_BODY_IGNORE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -613,7 +673,10 @@ static enum xer_pbd_rval INTEGER__xer_body_decode(asn_TYPE_descriptor_t *td,
|
|||||||
|
|
||||||
value *= sign; /* Change sign, if needed */
|
value *= sign; /* Change sign, if needed */
|
||||||
|
|
||||||
if (asn_long2INTEGER(st, value)) return XPBD_SYSTEM_FAILURE;
|
if (asn_long2INTEGER(st, value))
|
||||||
|
{
|
||||||
|
return XPBD_SYSTEM_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
return XPBD_BODY_CONSUMED;
|
return XPBD_BODY_CONSUMED;
|
||||||
}
|
}
|
||||||
@ -638,10 +701,16 @@ asn_enc_rval_t INTEGER_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
(void)ilevel;
|
(void)ilevel;
|
||||||
(void)flags;
|
(void)flags;
|
||||||
|
|
||||||
if (!st || !st->buf) _ASN_ENCODE_FAILED;
|
if (!st || !st->buf)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
er.encoded = INTEGER__dump(td, st, cb, app_key, 1);
|
er.encoded = INTEGER__dump(td, st, cb, app_key, 1);
|
||||||
if (er.encoded < 0) _ASN_ENCODE_FAILED;
|
if (er.encoded < 0)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
}
|
}
|
||||||
@ -662,17 +731,29 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (!st)
|
if (!st)
|
||||||
{
|
{
|
||||||
st = (INTEGER_t *)(*sptr = CALLOC(1, sizeof(*st)));
|
st = (INTEGER_t *)(*sptr = CALLOC(1, sizeof(*st)));
|
||||||
if (!st) _ASN_DECODE_FAILED;
|
if (!st)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!constraints) constraints = td->per_constraints;
|
if (!constraints)
|
||||||
|
{
|
||||||
|
constraints = td->per_constraints;
|
||||||
|
}
|
||||||
ct = constraints ? &constraints->value : 0;
|
ct = constraints ? &constraints->value : 0;
|
||||||
|
|
||||||
if (ct && ct->flags & APC_EXTENSIBLE)
|
if (ct && ct->flags & APC_EXTENSIBLE)
|
||||||
{
|
{
|
||||||
int inext = per_get_few_bits(pd, 1);
|
int inext = per_get_few_bits(pd, 1);
|
||||||
if (inext < 0) _ASN_DECODE_STARVED;
|
if (inext < 0)
|
||||||
if (inext) ct = 0;
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
|
if (inext)
|
||||||
|
{
|
||||||
|
ct = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FREEMEM(st->buf);
|
FREEMEM(st->buf);
|
||||||
@ -683,14 +764,20 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (ct->flags & APC_SEMI_CONSTRAINED)
|
if (ct->flags & APC_SEMI_CONSTRAINED)
|
||||||
{
|
{
|
||||||
st->buf = (uint8_t *)CALLOC(1, 2);
|
st->buf = (uint8_t *)CALLOC(1, 2);
|
||||||
if (!st->buf) _ASN_DECODE_FAILED;
|
if (!st->buf)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
st->size = 1;
|
st->size = 1;
|
||||||
}
|
}
|
||||||
else if (ct->flags & APC_CONSTRAINED && ct->range_bits >= 0)
|
else if (ct->flags & APC_CONSTRAINED && ct->range_bits >= 0)
|
||||||
{
|
{
|
||||||
size_t size = (ct->range_bits + 7) >> 3;
|
size_t size = (ct->range_bits + 7) >> 3;
|
||||||
st->buf = (uint8_t *)MALLOC(1 + size + 1);
|
st->buf = (uint8_t *)MALLOC(1 + size + 1);
|
||||||
if (!st->buf) _ASN_DECODE_FAILED;
|
if (!st->buf)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
st->size = size;
|
st->size = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -707,15 +794,24 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
{
|
{
|
||||||
int64_t lhalf;
|
int64_t lhalf;
|
||||||
value = per_get_few_bits(pd, 16);
|
value = per_get_few_bits(pd, 16);
|
||||||
if (value < 0) _ASN_DECODE_STARVED;
|
if (value < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
lhalf = per_get_few_bits(pd, 16);
|
lhalf = per_get_few_bits(pd, 16);
|
||||||
if (lhalf < 0) _ASN_DECODE_STARVED;
|
if (lhalf < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
value = (value << 16) | lhalf;
|
value = (value << 16) | lhalf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = per_get_few_bits(pd, ct->range_bits);
|
value = per_get_few_bits(pd, ct->range_bits);
|
||||||
if (value < 0) _ASN_DECODE_STARVED;
|
if (value < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ASN_DEBUG("Got value %ld + low %ld", value,
|
ASN_DEBUG("Got value %ld + low %ld", value,
|
||||||
ct->lower_bound);
|
ct->lower_bound);
|
||||||
@ -723,7 +819,9 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if ((specs && specs->field_unsigned)
|
if ((specs && specs->field_unsigned)
|
||||||
? asn_ulong2INTEGER(st, value)
|
? asn_ulong2INTEGER(st, value)
|
||||||
: asn_long2INTEGER(st, value))
|
: asn_long2INTEGER(st, value))
|
||||||
_ASN_DECODE_FAILED;
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -741,14 +839,23 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
|
|
||||||
/* Get the PER length */
|
/* Get the PER length */
|
||||||
len = uper_get_length(pd, -1, &repeat);
|
len = uper_get_length(pd, -1, &repeat);
|
||||||
if (len < 0) _ASN_DECODE_STARVED;
|
if (len < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
|
|
||||||
p = REALLOC(st->buf, st->size + len + 1);
|
p = REALLOC(st->buf, st->size + len + 1);
|
||||||
if (!p) _ASN_DECODE_FAILED;
|
if (!p)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
st->buf = (uint8_t *)p;
|
st->buf = (uint8_t *)p;
|
||||||
|
|
||||||
ret = per_get_many_bits(pd, &st->buf[st->size], 0, 8 * len);
|
ret = per_get_many_bits(pd, &st->buf[st->size], 0, 8 * len);
|
||||||
if (ret < 0) _ASN_DECODE_STARVED;
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
st->size += len;
|
st->size += len;
|
||||||
}
|
}
|
||||||
while (repeat);
|
while (repeat);
|
||||||
@ -761,9 +868,14 @@ asn_dec_rval_t INTEGER_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
* TODO: replace by in-place arithmetics.
|
* TODO: replace by in-place arithmetics.
|
||||||
*/
|
*/
|
||||||
int64_t value;
|
int64_t value;
|
||||||
if (asn_INTEGER2long(st, &value)) _ASN_DECODE_FAILED;
|
if (asn_INTEGER2long(st, &value))
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
if (asn_long2INTEGER(st, value + ct->lower_bound))
|
if (asn_long2INTEGER(st, value + ct->lower_bound))
|
||||||
_ASN_DECODE_FAILED;
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
@ -781,9 +893,15 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
asn_per_constraint_t *ct;
|
asn_per_constraint_t *ct;
|
||||||
int64_t value = 0;
|
int64_t value = 0;
|
||||||
|
|
||||||
if (!st || st->size == 0) _ASN_ENCODE_FAILED;
|
if (!st || st->size == 0)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (!constraints) constraints = td->per_constraints;
|
if (!constraints)
|
||||||
|
{
|
||||||
|
constraints = td->per_constraints;
|
||||||
|
}
|
||||||
ct = constraints ? &constraints->value : 0;
|
ct = constraints ? &constraints->value : 0;
|
||||||
|
|
||||||
er.encoded = 0;
|
er.encoded = 0;
|
||||||
@ -794,17 +912,25 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
if (specs && specs->field_unsigned)
|
if (specs && specs->field_unsigned)
|
||||||
{
|
{
|
||||||
uint64_t uval;
|
uint64_t uval;
|
||||||
if (asn_INTEGER2ulong(st, &uval)) _ASN_ENCODE_FAILED;
|
if (asn_INTEGER2ulong(st, &uval))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
/* Check proper range */
|
/* Check proper range */
|
||||||
if (ct->flags & APC_SEMI_CONSTRAINED)
|
if (ct->flags & APC_SEMI_CONSTRAINED)
|
||||||
{
|
{
|
||||||
if (uval < (uint64_t)ct->lower_bound) inext = 1;
|
if (uval < (uint64_t)ct->lower_bound)
|
||||||
|
{
|
||||||
|
inext = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ct->range_bits >= 0)
|
else if (ct->range_bits >= 0)
|
||||||
{
|
{
|
||||||
if (uval < (uint64_t)ct->lower_bound ||
|
if (uval < (uint64_t)ct->lower_bound ||
|
||||||
uval > (uint64_t)ct->upper_bound)
|
uval > (uint64_t)ct->upper_bound)
|
||||||
inext = 1;
|
{
|
||||||
|
inext = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ASN_DEBUG("Value %lu (%02x/%d) lb %lu ub %lu %s", uval,
|
ASN_DEBUG("Value %lu (%02x/%d) lb %lu ub %lu %s", uval,
|
||||||
st->buf[0], st->size, ct->lower_bound,
|
st->buf[0], st->size, ct->lower_bound,
|
||||||
@ -813,17 +939,25 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (asn_INTEGER2long(st, &value)) _ASN_ENCODE_FAILED;
|
if (asn_INTEGER2long(st, &value))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
/* Check proper range */
|
/* Check proper range */
|
||||||
if (ct->flags & APC_SEMI_CONSTRAINED)
|
if (ct->flags & APC_SEMI_CONSTRAINED)
|
||||||
{
|
{
|
||||||
if (value < ct->lower_bound) inext = 1;
|
if (value < ct->lower_bound)
|
||||||
|
{
|
||||||
|
inext = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ct->range_bits >= 0)
|
else if (ct->range_bits >= 0)
|
||||||
{
|
{
|
||||||
if (value < ct->lower_bound ||
|
if (value < ct->lower_bound ||
|
||||||
value > ct->upper_bound)
|
value > ct->upper_bound)
|
||||||
inext = 1;
|
{
|
||||||
|
inext = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ASN_DEBUG("Value %ld (%02x/%d) lb %ld ub %ld %s", value,
|
ASN_DEBUG("Value %ld (%02x/%d) lb %ld ub %ld %s", value,
|
||||||
st->buf[0], st->size, ct->lower_bound,
|
st->buf[0], st->size, ct->lower_bound,
|
||||||
@ -831,8 +965,14 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
}
|
}
|
||||||
if (ct->flags & APC_EXTENSIBLE)
|
if (ct->flags & APC_EXTENSIBLE)
|
||||||
{
|
{
|
||||||
if (per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED;
|
if (per_put_few_bits(po, inext, 1))
|
||||||
if (inext) ct = 0;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
if (inext)
|
||||||
|
{
|
||||||
|
ct = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (inext)
|
else if (inext)
|
||||||
{
|
{
|
||||||
@ -851,13 +991,17 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
int64_t v = value - ct->lower_bound;
|
int64_t v = value - ct->lower_bound;
|
||||||
if (per_put_few_bits(po, v >> 1, 31) ||
|
if (per_put_few_bits(po, v >> 1, 31) ||
|
||||||
per_put_few_bits(po, v, 1))
|
per_put_few_bits(po, v, 1))
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (per_put_few_bits(po, value - ct->lower_bound,
|
if (per_put_few_bits(po, value - ct->lower_bound,
|
||||||
ct->range_bits))
|
ct->range_bits))
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
}
|
}
|
||||||
@ -872,8 +1016,14 @@ asn_enc_rval_t INTEGER_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
for (buf = st->buf, end = st->buf + st->size; buf < end;)
|
for (buf = st->buf, end = st->buf + st->size; buf < end;)
|
||||||
{
|
{
|
||||||
ssize_t mayEncode = uper_put_length(po, end - buf);
|
ssize_t mayEncode = uper_put_length(po, end - buf);
|
||||||
if (mayEncode < 0) _ASN_ENCODE_FAILED;
|
if (mayEncode < 0)
|
||||||
if (per_put_many_bits(po, buf, 8 * mayEncode)) _ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
if (per_put_many_bits(po, buf, 8 * mayEncode))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
buf += mayEncode;
|
buf += mayEncode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -914,10 +1064,16 @@ int asn_INTEGER2long(const INTEGER_t *iptr, int64_t *lptr)
|
|||||||
switch (*b)
|
switch (*b)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
if ((b[1] & 0x80) == 0) continue;
|
if ((b[1] & 0x80) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0xff:
|
case 0xff:
|
||||||
if ((b[1] & 0x80) != 0) continue;
|
if ((b[1] & 0x80) != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -942,12 +1098,19 @@ int asn_INTEGER2long(const INTEGER_t *iptr, int64_t *lptr)
|
|||||||
/* Perform the sign initialization */
|
/* Perform the sign initialization */
|
||||||
/* Actually l = -(*b >> 7); gains nothing, yet unreadable! */
|
/* Actually l = -(*b >> 7); gains nothing, yet unreadable! */
|
||||||
if ((*b >> 7))
|
if ((*b >> 7))
|
||||||
l = -1;
|
{
|
||||||
|
l = -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
l = 0;
|
{
|
||||||
|
l = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Conversion engine */
|
/* Conversion engine */
|
||||||
for (; b < end; b++) l = (l * 256) | *b;
|
for (; b < end; b++)
|
||||||
|
{
|
||||||
|
l = (l * 256) | *b;
|
||||||
|
}
|
||||||
|
|
||||||
*lptr = l;
|
*lptr = l;
|
||||||
return 0;
|
return 0;
|
||||||
@ -982,7 +1145,10 @@ int asn_INTEGER2ulong(const INTEGER_t *iptr, uint64_t *lptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Conversion engine */
|
/* Conversion engine */
|
||||||
for (l = 0; b < end; b++) l = (l << 8) | *b;
|
for (l = 0; b < end; b++)
|
||||||
|
{
|
||||||
|
l = (l << 8) | *b;
|
||||||
|
}
|
||||||
|
|
||||||
*lptr = l;
|
*lptr = l;
|
||||||
return 0;
|
return 0;
|
||||||
@ -995,17 +1161,28 @@ int asn_ulong2INTEGER(INTEGER_t *st, uint64_t value)
|
|||||||
uint8_t *b;
|
uint8_t *b;
|
||||||
int shr;
|
int shr;
|
||||||
|
|
||||||
if (value <= LONG_MAX) return asn_long2INTEGER(st, value);
|
if (value <= LONG_MAX)
|
||||||
|
{
|
||||||
|
return asn_long2INTEGER(st, value);
|
||||||
|
}
|
||||||
|
|
||||||
buf = (uint8_t *)MALLOC(1 + sizeof(value));
|
buf = (uint8_t *)MALLOC(1 + sizeof(value));
|
||||||
if (!buf) return -1;
|
if (!buf)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
end = buf + (sizeof(value) + 1);
|
end = buf + (sizeof(value) + 1);
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
for (b = buf + 1, shr = (sizeof(int64_t) - 1) * 8; b < end; shr -= 8, b++)
|
for (b = buf + 1, shr = (sizeof(int64_t) - 1) * 8; b < end; shr -= 8, b++)
|
||||||
*b = (uint8_t)(value >> shr);
|
{
|
||||||
|
*b = (uint8_t)(value >> shr);
|
||||||
|
}
|
||||||
|
|
||||||
if (st->buf) FREEMEM(st->buf);
|
if (st->buf)
|
||||||
|
{
|
||||||
|
FREEMEM(st->buf);
|
||||||
|
}
|
||||||
st->buf = buf;
|
st->buf = buf;
|
||||||
st->size = 1 + sizeof(value);
|
st->size = 1 + sizeof(value);
|
||||||
|
|
||||||
@ -1029,7 +1206,10 @@ int asn_long2INTEGER(INTEGER_t *st, int64_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf = (uint8_t *)MALLOC(8);
|
buf = (uint8_t *)MALLOC(8);
|
||||||
if (!buf) return -1;
|
if (!buf)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (*(char *)&littleEndian)
|
if (*(char *)&littleEndian)
|
||||||
{
|
{
|
||||||
@ -1055,18 +1235,30 @@ int asn_long2INTEGER(INTEGER_t *st, int64_t value)
|
|||||||
switch (*p)
|
switch (*p)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
if ((*(p + add) & 0x80) == 0) continue;
|
if ((*(p + add) & 0x80) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0xff:
|
case 0xff:
|
||||||
if ((*(p + add) & 0x80)) continue;
|
if ((*(p + add) & 0x80))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Copy the integer body */
|
/* Copy the integer body */
|
||||||
for (pstart = p, bp = buf, pend1 += add; p != pend1; p += add) *bp++ = *p;
|
for (pstart = p, bp = buf, pend1 += add; p != pend1; p += add)
|
||||||
|
{
|
||||||
|
*bp++ = *p;
|
||||||
|
}
|
||||||
|
|
||||||
if (st->buf) FREEMEM(st->buf);
|
if (st->buf)
|
||||||
|
{
|
||||||
|
FREEMEM(st->buf);
|
||||||
|
}
|
||||||
st->buf = buf;
|
st->buf = buf;
|
||||||
st->size = bp - buf;
|
st->size = bp - buf;
|
||||||
|
|
||||||
|
@ -48,7 +48,9 @@ static void LAC_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -30,7 +30,9 @@ static void LocErrorReason_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -50,7 +50,9 @@ static void MeasureResponseTime_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -49,7 +49,9 @@ static void ModuloTimeSlot_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -31,7 +31,9 @@ static void MoreAssDataToBeSent_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -29,7 +29,9 @@ static void MpathIndic_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -50,7 +50,9 @@ static void MultiFrameOffset_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -78,9 +78,13 @@ static enum xer_pbd_rval NULL__xer_body_decode(asn_TYPE_descriptor_t *td,
|
|||||||
(void)sptr;
|
(void)sptr;
|
||||||
|
|
||||||
if (xer_is_whitespace(chunk_buf, chunk_size))
|
if (xer_is_whitespace(chunk_buf, chunk_size))
|
||||||
return XPBD_BODY_CONSUMED;
|
{
|
||||||
|
return XPBD_BODY_CONSUMED;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return XPBD_BROKEN_ENCODING;
|
{
|
||||||
|
return XPBD_BROKEN_ENCODING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
asn_dec_rval_t NULL_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
asn_dec_rval_t NULL_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
||||||
|
@ -56,7 +56,10 @@ asn_enc_rval_t NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td,
|
|||||||
(void)ilevel;
|
(void)ilevel;
|
||||||
(void)flags;
|
(void)flags;
|
||||||
|
|
||||||
if (!native) _ASN_ENCODE_FAILED;
|
if (!native)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
el = INTEGER_map_value2enum(specs, *native);
|
el = INTEGER_map_value2enum(specs, *native);
|
||||||
if (el)
|
if (el)
|
||||||
@ -66,7 +69,10 @@ asn_enc_rval_t NativeEnumerated_encode_xer(asn_TYPE_descriptor_t *td,
|
|||||||
|
|
||||||
er.encoded = snprintf(src, srcsize, "<%s/>", el->enum_name);
|
er.encoded = snprintf(src, srcsize, "<%s/>", el->enum_name);
|
||||||
assert(er.encoded > 0 && (size_t)er.encoded < srcsize);
|
assert(er.encoded > 0 && (size_t)er.encoded < srcsize);
|
||||||
if (cb(src, er.encoded, app_key) < 0) _ASN_ENCODE_FAILED;
|
if (cb(src, er.encoded, app_key) < 0)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -92,17 +98,29 @@ asn_dec_rval_t NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
(void)opt_codec_ctx;
|
(void)opt_codec_ctx;
|
||||||
|
|
||||||
if (constraints)
|
if (constraints)
|
||||||
ct = &constraints->value;
|
{
|
||||||
|
ct = &constraints->value;
|
||||||
|
}
|
||||||
else if (td->per_constraints)
|
else if (td->per_constraints)
|
||||||
ct = &td->per_constraints->value;
|
{
|
||||||
|
ct = &td->per_constraints->value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_ASN_DECODE_FAILED; /* Mandatory! */
|
{
|
||||||
if (!specs) _ASN_DECODE_FAILED;
|
_ASN_DECODE_FAILED; /* Mandatory! */
|
||||||
|
}
|
||||||
|
if (!specs)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (!native)
|
if (!native)
|
||||||
{
|
{
|
||||||
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
|
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
|
||||||
if (!native) _ASN_DECODE_FAILED;
|
if (!native)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
|
ASN_DEBUG("Decoding %s as NativeEnumerated", td->name);
|
||||||
@ -110,28 +128,48 @@ asn_dec_rval_t NativeEnumerated_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (ct->flags & APC_EXTENSIBLE)
|
if (ct->flags & APC_EXTENSIBLE)
|
||||||
{
|
{
|
||||||
int inext = per_get_few_bits(pd, 1);
|
int inext = per_get_few_bits(pd, 1);
|
||||||
if (inext < 0) _ASN_DECODE_STARVED;
|
if (inext < 0)
|
||||||
if (inext) ct = 0;
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
|
if (inext)
|
||||||
|
{
|
||||||
|
ct = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ct && ct->range_bits >= 0)
|
if (ct && ct->range_bits >= 0)
|
||||||
{
|
{
|
||||||
value = per_get_few_bits(pd, ct->range_bits);
|
value = per_get_few_bits(pd, ct->range_bits);
|
||||||
if (value < 0) _ASN_DECODE_STARVED;
|
if (value < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
if (value >=
|
if (value >=
|
||||||
(specs->extension ? specs->extension - 1 : specs->map_count))
|
(specs->extension ? specs->extension - 1 : specs->map_count))
|
||||||
_ASN_DECODE_FAILED;
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!specs->extension) _ASN_DECODE_FAILED;
|
if (!specs->extension)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* X.691, #10.6: normally small non-negative whole number;
|
* X.691, #10.6: normally small non-negative whole number;
|
||||||
*/
|
*/
|
||||||
value = uper_get_nsnnwn(pd);
|
value = uper_get_nsnnwn(pd);
|
||||||
if (value < 0) _ASN_DECODE_STARVED;
|
if (value < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
value += specs->extension - 1;
|
value += specs->extension - 1;
|
||||||
if (value >= specs->map_count) _ASN_DECODE_FAILED;
|
if (value >= specs->map_count)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*native = specs->value2enum[value].nat_value;
|
*native = specs->value2enum[value].nat_value;
|
||||||
@ -144,8 +182,14 @@ static int NativeEnumerated__compar_value2enum(const void *ap, const void *bp)
|
|||||||
{
|
{
|
||||||
const asn_INTEGER_enum_map_t *a = ap;
|
const asn_INTEGER_enum_map_t *a = ap;
|
||||||
const asn_INTEGER_enum_map_t *b = bp;
|
const asn_INTEGER_enum_map_t *b = bp;
|
||||||
if (a->nat_value == b->nat_value) return 0;
|
if (a->nat_value == b->nat_value)
|
||||||
if (a->nat_value < b->nat_value) return -1;
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (a->nat_value < b->nat_value)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,22 +206,37 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
asn_INTEGER_enum_map_t key;
|
asn_INTEGER_enum_map_t key;
|
||||||
asn_INTEGER_enum_map_t *kf;
|
asn_INTEGER_enum_map_t *kf;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
if (!specs) _ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
if (!specs)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (constraints)
|
if (constraints)
|
||||||
ct = &constraints->value;
|
{
|
||||||
|
ct = &constraints->value;
|
||||||
|
}
|
||||||
else if (td->per_constraints)
|
else if (td->per_constraints)
|
||||||
ct = &td->per_constraints->value;
|
{
|
||||||
|
ct = &td->per_constraints->value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_ASN_ENCODE_FAILED; /* Mandatory! */
|
{
|
||||||
|
_ASN_ENCODE_FAILED; /* Mandatory! */
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
|
ASN_DEBUG("Encoding %s as NativeEnumerated", td->name);
|
||||||
|
|
||||||
er.encoded = 0;
|
er.encoded = 0;
|
||||||
|
|
||||||
native = *(long *)sptr;
|
native = *(long *)sptr;
|
||||||
if (native < 0) _ASN_ENCODE_FAILED;
|
if (native < 0)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
key.nat_value = native;
|
key.nat_value = native;
|
||||||
kf = bsearch(&key, specs->value2enum, specs->map_count, sizeof(key),
|
kf = bsearch(&key, specs->value2enum, specs->map_count, sizeof(key),
|
||||||
@ -193,12 +252,21 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
{
|
{
|
||||||
int cmpWith =
|
int cmpWith =
|
||||||
specs->extension ? specs->extension - 1 : specs->map_count;
|
specs->extension ? specs->extension - 1 : specs->map_count;
|
||||||
if (value >= cmpWith) inext = 1;
|
if (value >= cmpWith)
|
||||||
|
{
|
||||||
|
inext = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (ct->flags & APC_EXTENSIBLE)
|
if (ct->flags & APC_EXTENSIBLE)
|
||||||
{
|
{
|
||||||
if (per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED;
|
if (per_put_few_bits(po, inext, 1))
|
||||||
if (inext) ct = 0;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
if (inext)
|
||||||
|
{
|
||||||
|
ct = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (inext)
|
else if (inext)
|
||||||
{
|
{
|
||||||
@ -207,11 +275,17 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
|
|
||||||
if (ct && ct->range_bits >= 0)
|
if (ct && ct->range_bits >= 0)
|
||||||
{
|
{
|
||||||
if (per_put_few_bits(po, value, ct->range_bits)) _ASN_ENCODE_FAILED;
|
if (per_put_few_bits(po, value, ct->range_bits))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!specs->extension) _ASN_ENCODE_FAILED;
|
if (!specs->extension)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* X.691, #10.6: normally small non-negative whole number;
|
* X.691, #10.6: normally small non-negative whole number;
|
||||||
@ -220,7 +294,9 @@ asn_enc_rval_t NativeEnumerated_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
specs->extension, inext,
|
specs->extension, inext,
|
||||||
value - (inext ? (specs->extension - 1) : 0));
|
value - (inext ? (specs->extension - 1) : 0));
|
||||||
if (uper_put_nsnnwn(po, value - (inext ? (specs->extension - 1) : 0)))
|
if (uper_put_nsnnwn(po, value - (inext ? (specs->extension - 1) : 0)))
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,10 @@ asn_dec_rval_t NativeInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
*/
|
*/
|
||||||
rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0,
|
rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0,
|
||||||
&length, 0);
|
&length, 0);
|
||||||
if (rval.code != RC_OK) return rval;
|
if (rval.code != RC_OK)
|
||||||
|
{
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("%s length is %d bytes", td->name, (int)length);
|
ASN_DEBUG("%s length is %d bytes", td->name, (int)length);
|
||||||
|
|
||||||
@ -153,7 +156,9 @@ asn_enc_rval_t NativeInteger_encode_der(asn_TYPE_descriptor_t *sd, void *ptr,
|
|||||||
|
|
||||||
/* Prepare a fake INTEGER */
|
/* Prepare a fake INTEGER */
|
||||||
for (p = buf + sizeof(buf) - 1; p >= buf; p--, native >>= 8)
|
for (p = buf + sizeof(buf) - 1; p >= buf; p--, native >>= 8)
|
||||||
*p = (uint8_t)native;
|
{
|
||||||
|
*p = (uint8_t)native;
|
||||||
|
}
|
||||||
|
|
||||||
tmp.buf = buf;
|
tmp.buf = buf;
|
||||||
tmp.size = sizeof(buf);
|
tmp.size = sizeof(buf);
|
||||||
@ -186,7 +191,10 @@ asn_dec_rval_t NativeInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (!native)
|
if (!native)
|
||||||
{
|
{
|
||||||
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
|
native = (long *)(*sptr = CALLOC(1, sizeof(*native)));
|
||||||
if (!native) _ASN_DECODE_FAILED;
|
if (!native)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&st, 0, sizeof(st));
|
memset(&st, 0, sizeof(st));
|
||||||
@ -234,14 +242,19 @@ asn_enc_rval_t NativeInteger_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
(void)ilevel;
|
(void)ilevel;
|
||||||
(void)flags;
|
(void)flags;
|
||||||
|
|
||||||
if (!native) _ASN_ENCODE_FAILED;
|
if (!native)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
er.encoded =
|
er.encoded =
|
||||||
snprintf(scratch, sizeof(scratch),
|
snprintf(scratch, sizeof(scratch),
|
||||||
(specs && specs->field_unsigned) ? "%lu" : "%ld", *native);
|
(specs && specs->field_unsigned) ? "%lu" : "%ld", *native);
|
||||||
if (er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch) ||
|
if (er.encoded <= 0 || (size_t)er.encoded >= sizeof(scratch) ||
|
||||||
cb(scratch, er.encoded, app_key) < 0)
|
cb(scratch, er.encoded, app_key) < 0)
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
}
|
}
|
||||||
@ -263,7 +276,10 @@ asn_dec_rval_t NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (!native)
|
if (!native)
|
||||||
{
|
{
|
||||||
native = (int64_t *)(*sptr = CALLOC(1, sizeof(*native)));
|
native = (int64_t *)(*sptr = CALLOC(1, sizeof(*native)));
|
||||||
if (!native) _ASN_DECODE_FAILED;
|
if (!native)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&tmpint, 0, sizeof tmpint);
|
memset(&tmpint, 0, sizeof tmpint);
|
||||||
@ -273,9 +289,13 @@ asn_dec_rval_t NativeInteger_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if ((specs && specs->field_unsigned)
|
if ((specs && specs->field_unsigned)
|
||||||
? asn_INTEGER2ulong(&tmpint, (uint64_t *)native)
|
? asn_INTEGER2ulong(&tmpint, (uint64_t *)native)
|
||||||
: asn_INTEGER2long(&tmpint, native))
|
: asn_INTEGER2long(&tmpint, native))
|
||||||
rval.code = RC_FAIL;
|
{
|
||||||
|
rval.code = RC_FAIL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ASN_DEBUG("NativeInteger %s got value %ld", td->name, *native);
|
{
|
||||||
|
ASN_DEBUG("NativeInteger %s got value %ld", td->name, *native);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
|
||||||
|
|
||||||
@ -291,7 +311,10 @@ asn_enc_rval_t NativeInteger_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
long native;
|
long native;
|
||||||
INTEGER_t tmpint;
|
INTEGER_t tmpint;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
native = *(long *)sptr;
|
native = *(long *)sptr;
|
||||||
|
|
||||||
@ -300,7 +323,9 @@ asn_enc_rval_t NativeInteger_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
memset(&tmpint, 0, sizeof(tmpint));
|
memset(&tmpint, 0, sizeof(tmpint));
|
||||||
if ((specs && specs->field_unsigned) ? asn_ulong2INTEGER(&tmpint, native)
|
if ((specs && specs->field_unsigned) ? asn_ulong2INTEGER(&tmpint, native)
|
||||||
: asn_long2INTEGER(&tmpint, native))
|
: asn_long2INTEGER(&tmpint, native))
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
er = INTEGER_encode_uper(td, constraints, &tmpint, po);
|
er = INTEGER_encode_uper(td, constraints, &tmpint, po);
|
||||||
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
|
ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_INTEGER, &tmpint);
|
||||||
return er;
|
return er;
|
||||||
@ -336,7 +361,10 @@ int NativeInteger_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
|
|
||||||
void NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
|
void NativeInteger_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
|
||||||
{
|
{
|
||||||
if (!td || !ptr) return;
|
if (!td || !ptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", td->name, contents_only,
|
ASN_DEBUG("Freeing %s as INTEGER (%d, %p, Native)", td->name, contents_only,
|
||||||
ptr);
|
ptr);
|
||||||
|
@ -50,7 +50,9 @@ static void NumOfMeasurements_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -156,7 +156,10 @@ static struct _stack_el *OS__add_stack_el(struct _stack *st)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el));
|
nel = (struct _stack_el *)CALLOC(1, sizeof(struct _stack_el));
|
||||||
if (nel == NULL) return NULL;
|
if (nel == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (st->tail)
|
if (st->tail)
|
||||||
{
|
{
|
||||||
@ -209,7 +212,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (st == NULL)
|
if (st == NULL)
|
||||||
{
|
{
|
||||||
st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size));
|
st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size));
|
||||||
if (st == NULL) RETURN(RC_FAIL);
|
if (st == NULL)
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore parsing context */
|
/* Restore parsing context */
|
||||||
@ -223,7 +229,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
*/
|
*/
|
||||||
rval = ber_check_tags(opt_codec_ctx, td, ctx, buf_ptr, size,
|
rval = ber_check_tags(opt_codec_ctx, td, ctx, buf_ptr, size,
|
||||||
tag_mode, -1, &ctx->left, &tlv_constr);
|
tag_mode, -1, &ctx->left, &tlv_constr);
|
||||||
if (rval.code != RC_OK) return rval;
|
if (rval.code != RC_OK)
|
||||||
|
{
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
if (tlv_constr)
|
if (tlv_constr)
|
||||||
{
|
{
|
||||||
@ -247,7 +256,9 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
*/
|
*/
|
||||||
_CH_PHASE(ctx, 3);
|
_CH_PHASE(ctx, 3);
|
||||||
if (type_variant == ASN_OSUBV_ANY && tag_mode != 1)
|
if (type_variant == ASN_OSUBV_ANY && tag_mode != 1)
|
||||||
APPEND(buf_ptr, rval.consumed);
|
{
|
||||||
|
APPEND(buf_ptr, rval.consumed);
|
||||||
|
}
|
||||||
ADVANCE(rval.consumed);
|
ADVANCE(rval.consumed);
|
||||||
goto phase3;
|
goto phase3;
|
||||||
}
|
}
|
||||||
@ -286,12 +297,17 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (prev->left != -1)
|
if (prev->left != -1)
|
||||||
{
|
{
|
||||||
if (prev->left < sel->got)
|
if (prev->left < sel->got)
|
||||||
RETURN(RC_FAIL);
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
prev->left -= sel->got;
|
prev->left -= sel->got;
|
||||||
}
|
}
|
||||||
prev->got += sel->got;
|
prev->got += sel->got;
|
||||||
sel = stck->cur_ptr = prev;
|
sel = stck->cur_ptr = prev;
|
||||||
if (!sel) break;
|
if (!sel)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
tlv_constr = 1;
|
tlv_constr = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -344,7 +360,9 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
|
|
||||||
if (type_variant == ASN_OSUBV_ANY &&
|
if (type_variant == ASN_OSUBV_ANY &&
|
||||||
(tag_mode != 1 || sel->cont_level))
|
(tag_mode != 1 || sel->cont_level))
|
||||||
APPEND("\0\0", 2);
|
{
|
||||||
|
APPEND("\0\0", 2);
|
||||||
|
}
|
||||||
|
|
||||||
ADVANCE(2);
|
ADVANCE(2);
|
||||||
sel->got += 2;
|
sel->got += 2;
|
||||||
@ -430,7 +448,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
* Append a new expectation.
|
* Append a new expectation.
|
||||||
*/
|
*/
|
||||||
sel = OS__add_stack_el(stck);
|
sel = OS__add_stack_el(stck);
|
||||||
if (!sel) RETURN(RC_FAIL);
|
if (!sel)
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
|
|
||||||
sel->tag = tlv_tag;
|
sel->tag = tlv_tag;
|
||||||
|
|
||||||
@ -440,11 +461,17 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
/* Check that the parent frame is big enough */
|
/* Check that the parent frame is big enough */
|
||||||
if (sel->prev->left <
|
if (sel->prev->left <
|
||||||
tlvl + (tlv_len == -1 ? 0 : tlv_len))
|
tlvl + (tlv_len == -1 ? 0 : tlv_len))
|
||||||
RETURN(RC_FAIL);
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
if (tlv_len == -1)
|
if (tlv_len == -1)
|
||||||
sel->left = sel->prev->left - tlvl;
|
{
|
||||||
|
sel->left = sel->prev->left - tlvl;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
sel->left = tlv_len;
|
{
|
||||||
|
sel->left = tlv_len;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -452,7 +479,9 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
if (type_variant == ASN_OSUBV_ANY &&
|
if (type_variant == ASN_OSUBV_ANY &&
|
||||||
(tag_mode != 1 || sel->cont_level))
|
(tag_mode != 1 || sel->cont_level))
|
||||||
APPEND(buf_ptr, tlvl);
|
{
|
||||||
|
APPEND(buf_ptr, tlvl);
|
||||||
|
}
|
||||||
sel->got += tlvl;
|
sel->got += tlvl;
|
||||||
ADVANCE(tlvl);
|
ADVANCE(tlvl);
|
||||||
|
|
||||||
@ -526,7 +555,10 @@ asn_dec_rval_t OCTET_STRING_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
|
|
||||||
if (size < (size_t)ctx->left)
|
if (size < (size_t)ctx->left)
|
||||||
{
|
{
|
||||||
if (!size) RETURN(RC_WMORE);
|
if (!size)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
if (type_variant == ASN_OSUBV_BIT && !ctx->context)
|
if (type_variant == ASN_OSUBV_BIT && !ctx->context)
|
||||||
{
|
{
|
||||||
st->bits_unused = *(const uint8_t *)buf_ptr;
|
st->bits_unused = *(const uint8_t *)buf_ptr;
|
||||||
@ -638,7 +670,10 @@ asn_enc_rval_t OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
if (type_variant == ASN_OSUBV_BIT)
|
if (type_variant == ASN_OSUBV_BIT)
|
||||||
{
|
{
|
||||||
uint8_t b = st->bits_unused & 0x07;
|
uint8_t b = st->bits_unused & 0x07;
|
||||||
if (b && st->size) fix_last_byte = 1;
|
if (b && st->size)
|
||||||
|
{
|
||||||
|
fix_last_byte = 1;
|
||||||
|
}
|
||||||
_ASN_CALLBACK(&b, 1);
|
_ASN_CALLBACK(&b, 1);
|
||||||
er.encoded++;
|
er.encoded++;
|
||||||
}
|
}
|
||||||
@ -674,7 +709,10 @@ asn_enc_rval_t OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
uint8_t *end;
|
uint8_t *end;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED;
|
if (!st || (!st->buf && st->size))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
er.encoded = 0;
|
er.encoded = 0;
|
||||||
|
|
||||||
@ -721,7 +759,10 @@ asn_enc_rval_t OCTET_STRING_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
p--; /* Remove the tail space */
|
p--; /* Remove the tail space */
|
||||||
_ASN_CALLBACK(scratch, p - scratch); /* Dump the rest */
|
_ASN_CALLBACK(scratch, p - scratch); /* Dump the rest */
|
||||||
er.encoded += p - scratch;
|
er.encoded += p - scratch;
|
||||||
if (st->size > 16) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
if (st->size > 16)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -818,7 +859,9 @@ static int OS__check_escaped_control_char(const void *buf, int size)
|
|||||||
struct OCTET_STRING__xer_escape_table_s *el;
|
struct OCTET_STRING__xer_escape_table_s *el;
|
||||||
el = &OCTET_STRING__xer_escape_table[i];
|
el = &OCTET_STRING__xer_escape_table[i];
|
||||||
if (el->size == size && memcmp(buf, el->string, size) == 0)
|
if (el->size == size && memcmp(buf, el->string, size) == 0)
|
||||||
return i;
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -865,7 +908,10 @@ asn_enc_rval_t OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td,
|
|||||||
(void)ilevel; /* Unused argument */
|
(void)ilevel; /* Unused argument */
|
||||||
(void)flags; /* Unused argument */
|
(void)flags; /* Unused argument */
|
||||||
|
|
||||||
if (!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED;
|
if (!st || (!st->buf && st->size))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
buf = st->buf;
|
buf = st->buf;
|
||||||
end = buf + st->size;
|
end = buf + st->size;
|
||||||
@ -884,14 +930,19 @@ asn_enc_rval_t OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td,
|
|||||||
if (((buf - ss) && cb(ss, buf - ss, app_key) < 0) ||
|
if (((buf - ss) && cb(ss, buf - ss, app_key) < 0) ||
|
||||||
cb(OCTET_STRING__xer_escape_table[ch].string, s_len,
|
cb(OCTET_STRING__xer_escape_table[ch].string, s_len,
|
||||||
app_key) < 0)
|
app_key) < 0)
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
encoded_len += (buf - ss) + s_len;
|
encoded_len += (buf - ss) + s_len;
|
||||||
ss = buf + 1;
|
ss = buf + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
encoded_len += (buf - ss);
|
encoded_len += (buf - ss);
|
||||||
if ((buf - ss) && cb(ss, buf - ss, app_key) < 0) _ASN_ENCODE_FAILED;
|
if ((buf - ss) && cb(ss, buf - ss, app_key) < 0)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
er.encoded = encoded_len;
|
er.encoded = encoded_len;
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
@ -916,7 +967,10 @@ static ssize_t OCTET_STRING__convert_hexadecimal(void *sptr,
|
|||||||
/* Reallocate buffer according to high cap estimation */
|
/* Reallocate buffer according to high cap estimation */
|
||||||
ssize_t _ns = st->size + (chunk_size + 1) / 2;
|
ssize_t _ns = st->size + (chunk_size + 1) / 2;
|
||||||
void *nptr = REALLOC(st->buf, _ns + 1);
|
void *nptr = REALLOC(st->buf, _ns + 1);
|
||||||
if (!nptr) return -1;
|
if (!nptr)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
st->buf = (uint8_t *)nptr;
|
st->buf = (uint8_t *)nptr;
|
||||||
buf = st->buf + st->size;
|
buf = st->buf + st->size;
|
||||||
|
|
||||||
@ -1019,16 +1073,23 @@ static ssize_t OCTET_STRING__convert_binary(void *sptr, const void *chunk_buf,
|
|||||||
/* Reallocate buffer according to high cap estimation */
|
/* Reallocate buffer according to high cap estimation */
|
||||||
ssize_t _ns = st->size + (chunk_size + 7) / 8;
|
ssize_t _ns = st->size + (chunk_size + 7) / 8;
|
||||||
void *nptr = REALLOC(st->buf, _ns + 1);
|
void *nptr = REALLOC(st->buf, _ns + 1);
|
||||||
if (!nptr) return -1;
|
if (!nptr)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
st->buf = (uint8_t *)nptr;
|
st->buf = (uint8_t *)nptr;
|
||||||
buf = st->buf + st->size;
|
buf = st->buf + st->size;
|
||||||
|
|
||||||
(void)have_more;
|
(void)have_more;
|
||||||
|
|
||||||
if (bits_unused == 0)
|
if (bits_unused == 0)
|
||||||
bits_unused = 8;
|
{
|
||||||
|
bits_unused = 8;
|
||||||
|
}
|
||||||
else if (st->size)
|
else if (st->size)
|
||||||
buf--;
|
{
|
||||||
|
buf--;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Convert series of 0 and 1 into the octet string.
|
* Convert series of 0 and 1 into the octet string.
|
||||||
@ -1091,7 +1152,10 @@ static int OS__strtoent(int base, const char *buf, const char *end,
|
|||||||
int ch = *p;
|
int ch = *p;
|
||||||
|
|
||||||
/* Strange huge value */
|
/* Strange huge value */
|
||||||
if ((val * base + base) < 0) return -1;
|
if ((val * base + base) < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
switch (ch)
|
switch (ch)
|
||||||
{
|
{
|
||||||
@ -1149,7 +1213,10 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
|
|||||||
/* Reallocate buffer */
|
/* Reallocate buffer */
|
||||||
ssize_t _ns = st->size + chunk_size;
|
ssize_t _ns = st->size + chunk_size;
|
||||||
void *nptr = REALLOC(st->buf, _ns + 1);
|
void *nptr = REALLOC(st->buf, _ns + 1);
|
||||||
if (!nptr) return -1;
|
if (!nptr)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
st->buf = (uint8_t *)nptr;
|
st->buf = (uint8_t *)nptr;
|
||||||
buf = st->buf + st->size;
|
buf = st->buf + st->size;
|
||||||
|
|
||||||
@ -1171,18 +1238,28 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
|
|||||||
* Process entity reference.
|
* Process entity reference.
|
||||||
*/
|
*/
|
||||||
len = chunk_size - (p - (const char *)chunk_buf);
|
len = chunk_size - (p - (const char *)chunk_buf);
|
||||||
if (len == 1 /* "&" */) goto want_more;
|
if (len == 1 /* "&" */)
|
||||||
|
{
|
||||||
|
goto want_more;
|
||||||
|
}
|
||||||
if (p[1] == 0x23 /* '#' */)
|
if (p[1] == 0x23 /* '#' */)
|
||||||
{
|
{
|
||||||
const char *pval; /* Pointer to start of digits */
|
const char *pval; /* Pointer to start of digits */
|
||||||
int32_t val = 0; /* Entity reference value */
|
int32_t val = 0; /* Entity reference value */
|
||||||
int base;
|
int base;
|
||||||
|
|
||||||
if (len == 2 /* "&#" */) goto want_more;
|
if (len == 2 /* "&#" */)
|
||||||
|
{
|
||||||
|
goto want_more;
|
||||||
|
}
|
||||||
if (p[2] == 0x78 /* 'x' */)
|
if (p[2] == 0x78 /* 'x' */)
|
||||||
pval = p + 3, base = 16;
|
{
|
||||||
|
pval = p + 3, base = 16;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
pval = p + 2, base = 10;
|
{
|
||||||
|
pval = p + 2, base = 10;
|
||||||
|
}
|
||||||
len = OS__strtoent(base, pval, p + len, &val);
|
len = OS__strtoent(base, pval, p + len, &val);
|
||||||
if (len == -1)
|
if (len == -1)
|
||||||
{
|
{
|
||||||
@ -1190,7 +1267,10 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
|
|||||||
*buf++ = ch;
|
*buf++ = ch;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!len || pval[len - 1] != 0x3b) goto want_more;
|
if (!len || pval[len - 1] != 0x3b)
|
||||||
|
{
|
||||||
|
goto want_more;
|
||||||
|
}
|
||||||
assert(val > 0);
|
assert(val > 0);
|
||||||
p += (pval - p) + len - 1; /* Advance past entref */
|
p += (pval - p) + len - 1; /* Advance past entref */
|
||||||
|
|
||||||
@ -1240,7 +1320,10 @@ static ssize_t OCTET_STRING__convert_entrefs(void *sptr, const void *chunk_buf,
|
|||||||
* Ugly, limited parsing of & > <
|
* Ugly, limited parsing of & > <
|
||||||
*/
|
*/
|
||||||
char *sc = (char *)memchr(p, 0x3b, len > 5 ? 5 : len);
|
char *sc = (char *)memchr(p, 0x3b, len > 5 ? 5 : len);
|
||||||
if (!sc) goto want_more;
|
if (!sc)
|
||||||
|
{
|
||||||
|
goto want_more;
|
||||||
|
}
|
||||||
if ((sc - p) == 4 && p[1] == 0x61 /* 'a' */
|
if ((sc - p) == 4 && p[1] == 0x61 /* 'a' */
|
||||||
&& p[2] == 0x6d /* 'm' */
|
&& p[2] == 0x6d /* 'm' */
|
||||||
&& p[3] == 0x70 /* 'p' */)
|
&& p[3] == 0x70 /* 'p' */)
|
||||||
@ -1329,7 +1412,10 @@ static asn_dec_rval_t OCTET_STRING__decode_xer(
|
|||||||
{
|
{
|
||||||
st = (OCTET_STRING_t *)CALLOC(1, specs->struct_size);
|
st = (OCTET_STRING_t *)CALLOC(1, specs->struct_size);
|
||||||
*sptr = (void *)st;
|
*sptr = (void *)st;
|
||||||
if (!st) goto sta_failed;
|
if (!st)
|
||||||
|
{
|
||||||
|
goto sta_failed;
|
||||||
|
}
|
||||||
st_allocated = 1;
|
st_allocated = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1425,14 +1511,19 @@ static int OCTET_STRING_per_get_characters(asn_per_data_t *po, uint8_t *buf,
|
|||||||
else if (pc && pc->code2value)
|
else if (pc && pc->code2value)
|
||||||
{
|
{
|
||||||
if (unit_bits > 16)
|
if (unit_bits > 16)
|
||||||
return 1; /* FATAL: can't have constrained
|
{
|
||||||
|
return 1;
|
||||||
|
} /* FATAL: can't have constrained
|
||||||
* UniversalString with more than
|
* UniversalString with more than
|
||||||
* 16 million code points */
|
* 16 million code points */
|
||||||
for (; buf < end; buf += bpc)
|
for (; buf < end; buf += bpc)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
int code = per_get_few_bits(po, unit_bits);
|
int code = per_get_few_bits(po, unit_bits);
|
||||||
if (code < 0) return -1; /* WMORE */
|
if (code < 0)
|
||||||
|
{
|
||||||
|
return -1; /* WMORE */
|
||||||
|
}
|
||||||
value = pc->code2value(code);
|
value = pc->code2value(code);
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
{
|
{
|
||||||
@ -1472,7 +1563,10 @@ static int OCTET_STRING_per_get_characters(asn_per_data_t *po, uint8_t *buf,
|
|||||||
{
|
{
|
||||||
int code = per_get_few_bits(po, unit_bits);
|
int code = per_get_few_bits(po, unit_bits);
|
||||||
int ch = code + lb;
|
int ch = code + lb;
|
||||||
if (code < 0) return -1; /* WMORE */
|
if (code < 0)
|
||||||
|
{
|
||||||
|
return -1; /* WMORE */
|
||||||
|
}
|
||||||
if (ch > ub)
|
if (ch > ub)
|
||||||
{
|
{
|
||||||
ASN_DEBUG("Code %d is out of range (%ld..%ld)", ch, lb, ub);
|
ASN_DEBUG("Code %d is out of range (%ld..%ld)", ch, lb, ub);
|
||||||
@ -1546,7 +1640,10 @@ static int OCTET_STRING_per_put_characters(asn_per_outp_t *po,
|
|||||||
*buf, *buf, lb, ub);
|
*buf, *buf, lb, ub);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (per_put_few_bits(po, code, unit_bits)) return -1;
|
if (per_put_few_bits(po, code, unit_bits))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1584,7 +1681,10 @@ static int OCTET_STRING_per_put_characters(asn_per_outp_t *po,
|
|||||||
*buf, *buf, lb, ub + lb);
|
*buf, *buf, lb, ub + lb);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (per_put_few_bits(po, ch, unit_bits)) return -1;
|
if (per_put_few_bits(po, ch, unit_bits))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1640,17 +1740,26 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
break;
|
break;
|
||||||
case ASN_OSUBV_STR:
|
case ASN_OSUBV_STR:
|
||||||
canonical_unit_bits = unit_bits = 8;
|
canonical_unit_bits = unit_bits = 8;
|
||||||
if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits;
|
if (cval->flags & APC_CONSTRAINED)
|
||||||
|
{
|
||||||
|
unit_bits = cval->range_bits;
|
||||||
|
}
|
||||||
bpc = OS__BPC_CHAR;
|
bpc = OS__BPC_CHAR;
|
||||||
break;
|
break;
|
||||||
case ASN_OSUBV_U16:
|
case ASN_OSUBV_U16:
|
||||||
canonical_unit_bits = unit_bits = 16;
|
canonical_unit_bits = unit_bits = 16;
|
||||||
if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits;
|
if (cval->flags & APC_CONSTRAINED)
|
||||||
|
{
|
||||||
|
unit_bits = cval->range_bits;
|
||||||
|
}
|
||||||
bpc = OS__BPC_U16;
|
bpc = OS__BPC_U16;
|
||||||
break;
|
break;
|
||||||
case ASN_OSUBV_U32:
|
case ASN_OSUBV_U32:
|
||||||
canonical_unit_bits = unit_bits = 32;
|
canonical_unit_bits = unit_bits = 32;
|
||||||
if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits;
|
if (cval->flags & APC_CONSTRAINED)
|
||||||
|
{
|
||||||
|
unit_bits = cval->range_bits;
|
||||||
|
}
|
||||||
bpc = OS__BPC_U32;
|
bpc = OS__BPC_U32;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1661,7 +1770,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (!st)
|
if (!st)
|
||||||
{
|
{
|
||||||
st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size));
|
st = (BIT_STRING_t *)(*sptr = CALLOC(1, specs->struct_size));
|
||||||
if (!st) RETURN(RC_FAIL);
|
if (!st)
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASN_DEBUG("PER Decoding %s size %ld .. %ld bits %d",
|
ASN_DEBUG("PER Decoding %s size %ld .. %ld bits %d",
|
||||||
@ -1671,7 +1783,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (csiz->flags & APC_EXTENSIBLE)
|
if (csiz->flags & APC_EXTENSIBLE)
|
||||||
{
|
{
|
||||||
int inext = per_get_few_bits(pd, 1);
|
int inext = per_get_few_bits(pd, 1);
|
||||||
if (inext < 0) RETURN(RC_WMORE);
|
if (inext < 0)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
if (inext)
|
if (inext)
|
||||||
{
|
{
|
||||||
csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size;
|
csiz = &ASN_DEF_OCTET_STRING_CONSTRAINTS.size;
|
||||||
@ -1712,7 +1827,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
ret = OCTET_STRING_per_get_characters(
|
ret = OCTET_STRING_per_get_characters(
|
||||||
pd, st->buf, csiz->upper_bound, bpc, unit_bits,
|
pd, st->buf, csiz->upper_bound, bpc, unit_bits,
|
||||||
cval->lower_bound, cval->upper_bound, pc);
|
cval->lower_bound, cval->upper_bound, pc);
|
||||||
if (ret > 0) RETURN(RC_FAIL);
|
if (ret > 0)
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1721,7 +1839,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
ret = per_get_many_bits(pd, st->buf, 0,
|
ret = per_get_many_bits(pd, st->buf, 0,
|
||||||
unit_bits * csiz->upper_bound);
|
unit_bits * csiz->upper_bound);
|
||||||
}
|
}
|
||||||
if (ret < 0) RETURN(RC_WMORE);
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
consumed_myself += unit_bits * csiz->upper_bound;
|
consumed_myself += unit_bits * csiz->upper_bound;
|
||||||
st->buf[st->size] = 0;
|
st->buf[st->size] = 0;
|
||||||
if (bpc == 0)
|
if (bpc == 0)
|
||||||
@ -1743,7 +1864,10 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
|
|
||||||
/* Get the PER length */
|
/* Get the PER length */
|
||||||
raw_len = uper_get_length(pd, csiz->effective_bits, &repeat);
|
raw_len = uper_get_length(pd, csiz->effective_bits, &repeat);
|
||||||
if (raw_len < 0) RETURN(RC_WMORE);
|
if (raw_len < 0)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
raw_len += csiz->lower_bound;
|
raw_len += csiz->lower_bound;
|
||||||
|
|
||||||
ASN_DEBUG("Got PER length eb %ld, len %ld, %s (%s)",
|
ASN_DEBUG("Got PER length eb %ld, len %ld, %s (%s)",
|
||||||
@ -1758,11 +1882,17 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
{
|
{
|
||||||
len_bits = raw_len;
|
len_bits = raw_len;
|
||||||
len_bytes = (len_bits + 7) >> 3;
|
len_bytes = (len_bits + 7) >> 3;
|
||||||
if (len_bits & 0x7) st->bits_unused = 8 - (len_bits & 0x7);
|
if (len_bits & 0x7)
|
||||||
|
{
|
||||||
|
st->bits_unused = 8 - (len_bits & 0x7);
|
||||||
|
}
|
||||||
/* len_bits be multiple of 16K if repeat is set */
|
/* len_bits be multiple of 16K if repeat is set */
|
||||||
}
|
}
|
||||||
p = REALLOC(st->buf, st->size + len_bytes + 1);
|
p = REALLOC(st->buf, st->size + len_bytes + 1);
|
||||||
if (!p) RETURN(RC_FAIL);
|
if (!p)
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
st->buf = (uint8_t *)p;
|
st->buf = (uint8_t *)p;
|
||||||
|
|
||||||
if (bpc)
|
if (bpc)
|
||||||
@ -1770,14 +1900,20 @@ asn_dec_rval_t OCTET_STRING_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
ret = OCTET_STRING_per_get_characters(
|
ret = OCTET_STRING_per_get_characters(
|
||||||
pd, &st->buf[st->size], raw_len, bpc, unit_bits,
|
pd, &st->buf[st->size], raw_len, bpc, unit_bits,
|
||||||
cval->lower_bound, cval->upper_bound, pc);
|
cval->lower_bound, cval->upper_bound, pc);
|
||||||
if (ret > 0) RETURN(RC_FAIL);
|
if (ret > 0)
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret =
|
ret =
|
||||||
per_get_many_bits(pd, &st->buf[st->size], 0, len_bits);
|
per_get_many_bits(pd, &st->buf[st->size], 0, len_bits);
|
||||||
}
|
}
|
||||||
if (ret < 0) RETURN(RC_WMORE);
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
st->size += len_bytes;
|
st->size += len_bytes;
|
||||||
}
|
}
|
||||||
while (repeat);
|
while (repeat);
|
||||||
@ -1813,7 +1949,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
} bpc; /* Bytes per character */
|
} bpc; /* Bytes per character */
|
||||||
int ct_extensible;
|
int ct_extensible;
|
||||||
|
|
||||||
if (!st || (!st->buf && st->size)) _ASN_ENCODE_FAILED;
|
if (!st || (!st->buf && st->size))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (pc)
|
if (pc)
|
||||||
{
|
{
|
||||||
@ -1841,19 +1980,28 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
break;
|
break;
|
||||||
case ASN_OSUBV_STR:
|
case ASN_OSUBV_STR:
|
||||||
canonical_unit_bits = unit_bits = 8;
|
canonical_unit_bits = unit_bits = 8;
|
||||||
if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits;
|
if (cval->flags & APC_CONSTRAINED)
|
||||||
|
{
|
||||||
|
unit_bits = cval->range_bits;
|
||||||
|
}
|
||||||
bpc = OS__BPC_CHAR;
|
bpc = OS__BPC_CHAR;
|
||||||
sizeinunits = st->size;
|
sizeinunits = st->size;
|
||||||
break;
|
break;
|
||||||
case ASN_OSUBV_U16:
|
case ASN_OSUBV_U16:
|
||||||
canonical_unit_bits = unit_bits = 16;
|
canonical_unit_bits = unit_bits = 16;
|
||||||
if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits;
|
if (cval->flags & APC_CONSTRAINED)
|
||||||
|
{
|
||||||
|
unit_bits = cval->range_bits;
|
||||||
|
}
|
||||||
bpc = OS__BPC_U16;
|
bpc = OS__BPC_U16;
|
||||||
sizeinunits = st->size / 2;
|
sizeinunits = st->size / 2;
|
||||||
break;
|
break;
|
||||||
case ASN_OSUBV_U32:
|
case ASN_OSUBV_U32:
|
||||||
canonical_unit_bits = unit_bits = 32;
|
canonical_unit_bits = unit_bits = 32;
|
||||||
if (cval->flags & APC_CONSTRAINED) unit_bits = cval->range_bits;
|
if (cval->flags & APC_CONSTRAINED)
|
||||||
|
{
|
||||||
|
unit_bits = cval->range_bits;
|
||||||
|
}
|
||||||
bpc = OS__BPC_U32;
|
bpc = OS__BPC_U32;
|
||||||
sizeinunits = st->size / 4;
|
sizeinunits = st->size / 4;
|
||||||
break;
|
break;
|
||||||
@ -1880,7 +2028,9 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
inext = 1;
|
inext = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1891,7 +2041,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
if (ct_extensible)
|
if (ct_extensible)
|
||||||
{
|
{
|
||||||
/* Declare whether length is [not] within extension root */
|
/* Declare whether length is [not] within extension root */
|
||||||
if (per_put_few_bits(po, inext, 1)) _ASN_ENCODE_FAILED;
|
if (per_put_few_bits(po, inext, 1))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* X.691, #16.5: zero-length encoding */
|
/* X.691, #16.5: zero-length encoding */
|
||||||
@ -1903,7 +2056,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
sizeinunits - csiz->lower_bound, csiz->effective_bits);
|
sizeinunits - csiz->lower_bound, csiz->effective_bits);
|
||||||
ret = per_put_few_bits(po, sizeinunits - csiz->lower_bound,
|
ret = per_put_few_bits(po, sizeinunits - csiz->lower_bound,
|
||||||
csiz->effective_bits);
|
csiz->effective_bits);
|
||||||
if (ret) _ASN_ENCODE_FAILED;
|
if (ret)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
if (bpc)
|
if (bpc)
|
||||||
{
|
{
|
||||||
ret = OCTET_STRING_per_put_characters(
|
ret = OCTET_STRING_per_put_characters(
|
||||||
@ -1915,7 +2071,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
ret =
|
ret =
|
||||||
per_put_many_bits(po, st->buf, sizeinunits * unit_bits);
|
per_put_many_bits(po, st->buf, sizeinunits * unit_bits);
|
||||||
}
|
}
|
||||||
if (ret) _ASN_ENCODE_FAILED;
|
if (ret)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1923,7 +2082,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
|
|
||||||
if (sizeinunits == 0)
|
if (sizeinunits == 0)
|
||||||
{
|
{
|
||||||
if (uper_put_length(po, 0)) _ASN_ENCODE_FAILED;
|
if (uper_put_length(po, 0))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1931,7 +2093,10 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
while (sizeinunits)
|
while (sizeinunits)
|
||||||
{
|
{
|
||||||
ssize_t maySave = uper_put_length(po, sizeinunits);
|
ssize_t maySave = uper_put_length(po, sizeinunits);
|
||||||
if (maySave < 0) _ASN_ENCODE_FAILED;
|
if (maySave < 0)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Encoding %ld of %ld", (long)maySave, (long)sizeinunits);
|
ASN_DEBUG("Encoding %ld of %ld", (long)maySave, (long)sizeinunits);
|
||||||
|
|
||||||
@ -1945,12 +2110,19 @@ asn_enc_rval_t OCTET_STRING_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
{
|
{
|
||||||
ret = per_put_many_bits(po, buf, maySave * unit_bits);
|
ret = per_put_many_bits(po, buf, maySave * unit_bits);
|
||||||
}
|
}
|
||||||
if (ret) _ASN_ENCODE_FAILED;
|
if (ret)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (bpc)
|
if (bpc)
|
||||||
buf += maySave * bpc;
|
{
|
||||||
|
buf += maySave * bpc;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
buf += maySave >> 3;
|
{
|
||||||
|
buf += maySave >> 3;
|
||||||
|
}
|
||||||
sizeinunits -= maySave;
|
sizeinunits -= maySave;
|
||||||
assert(!(maySave & 0x07) || !sizeinunits);
|
assert(!(maySave & 0x07) || !sizeinunits);
|
||||||
}
|
}
|
||||||
@ -1972,7 +2144,9 @@ int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
(void)td; /* Unused argument */
|
(void)td; /* Unused argument */
|
||||||
|
|
||||||
if (!st || (!st->buf && st->size))
|
if (!st || (!st->buf && st->size))
|
||||||
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
{
|
||||||
|
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dump the contents of the buffer in hexadecimal.
|
* Dump the contents of the buffer in hexadecimal.
|
||||||
@ -1983,7 +2157,10 @@ int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
{
|
{
|
||||||
if (!(i % 16) && (i || st->size > 16))
|
if (!(i % 16) && (i || st->size > 16))
|
||||||
{
|
{
|
||||||
if (cb(scratch, p - scratch, app_key) < 0) return -1;
|
if (cb(scratch, p - scratch, app_key) < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
_i_INDENT(1);
|
_i_INDENT(1);
|
||||||
p = scratch;
|
p = scratch;
|
||||||
}
|
}
|
||||||
@ -1995,7 +2172,10 @@ int OCTET_STRING_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
if (p > scratch)
|
if (p > scratch)
|
||||||
{
|
{
|
||||||
p--; /* Remove the tail space */
|
p--; /* Remove the tail space */
|
||||||
if (cb(scratch, p - scratch, app_key) < 0) return -1;
|
if (cb(scratch, p - scratch, app_key) < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -2030,7 +2210,10 @@ void OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only)
|
|||||||
(asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
|
(asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
|
||||||
struct _stack *stck;
|
struct _stack *stck;
|
||||||
|
|
||||||
if (!td || !st) return;
|
if (!td || !st)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Freeing %s as OCTET STRING", td->name);
|
ASN_DEBUG("Freeing %s as OCTET STRING", td->name);
|
||||||
|
|
||||||
@ -2086,11 +2269,17 @@ int OCTET_STRING_fromBuf(OCTET_STRING_t *st, const char *str, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Determine the original string size, if not explicitly given */
|
/* Determine the original string size, if not explicitly given */
|
||||||
if (len < 0) len = strlen(str);
|
if (len < 0)
|
||||||
|
{
|
||||||
|
len = strlen(str);
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate and fill the memory */
|
/* Allocate and fill the memory */
|
||||||
buf = MALLOC(len + 1);
|
buf = MALLOC(len + 1);
|
||||||
if (buf == NULL) return -1;
|
if (buf == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(buf, str, len);
|
memcpy(buf, str, len);
|
||||||
((uint8_t *)buf)[len] = '\0'; /* Couldn't use memcpy(len+1)! */
|
((uint8_t *)buf)[len] = '\0'; /* Couldn't use memcpy(len+1)! */
|
||||||
|
@ -31,7 +31,9 @@ static void OTD_FirstSetMsrs_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_OTD_MeasurementWithID.uper_decoder;
|
td->uper_decoder = asn_DEF_OTD_MeasurementWithID.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_OTD_MeasurementWithID.uper_encoder;
|
td->uper_encoder = asn_DEF_OTD_MeasurementWithID.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_OTD_MeasurementWithID.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_OTD_MeasurementWithID.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_OTD_MeasurementWithID.elements;
|
td->elements = asn_DEF_OTD_MeasurementWithID.elements;
|
||||||
td->elements_count = asn_DEF_OTD_MeasurementWithID.elements_count;
|
td->elements_count = asn_DEF_OTD_MeasurementWithID.elements_count;
|
||||||
td->specifics = asn_DEF_OTD_MeasurementWithID.specifics;
|
td->specifics = asn_DEF_OTD_MeasurementWithID.specifics;
|
||||||
|
@ -52,7 +52,9 @@ static void OTD_MeasureInfo_5_Ext_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_SeqOfOTD_MsrElementRest.uper_decoder;
|
td->uper_decoder = asn_DEF_SeqOfOTD_MsrElementRest.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_SeqOfOTD_MsrElementRest.uper_encoder;
|
td->uper_encoder = asn_DEF_SeqOfOTD_MsrElementRest.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_SeqOfOTD_MsrElementRest.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_SeqOfOTD_MsrElementRest.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_SeqOfOTD_MsrElementRest.elements;
|
td->elements = asn_DEF_SeqOfOTD_MsrElementRest.elements;
|
||||||
td->elements_count = asn_DEF_SeqOfOTD_MsrElementRest.elements_count;
|
td->elements_count = asn_DEF_SeqOfOTD_MsrElementRest.elements_count;
|
||||||
td->specifics = asn_DEF_SeqOfOTD_MsrElementRest.specifics;
|
td->specifics = asn_DEF_SeqOfOTD_MsrElementRest.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void OTDValue_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -58,7 +58,9 @@ static void PositionData_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder;
|
td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder;
|
td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_BIT_STRING.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_BIT_STRING.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_BIT_STRING.elements;
|
td->elements = asn_DEF_BIT_STRING.elements;
|
||||||
td->elements_count = asn_DEF_BIT_STRING.elements_count;
|
td->elements_count = asn_DEF_BIT_STRING.elements_count;
|
||||||
td->specifics = asn_DEF_BIT_STRING.specifics;
|
td->specifics = asn_DEF_BIT_STRING.specifics;
|
||||||
|
@ -30,7 +30,9 @@ static void PositionMethod_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -48,7 +48,9 @@ static void RefQuality_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -31,7 +31,9 @@ static void ReferenceRelation_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -48,7 +48,9 @@ static void RelDistance_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void RelativeAlt_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -49,7 +49,9 @@ static void RequestIndex_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -50,7 +50,9 @@ static void RequiredResponseTime_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void RoughRTD_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void SVID_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -57,7 +57,9 @@ static void SVIDMASK_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder;
|
td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder;
|
td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_BIT_STRING.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_BIT_STRING.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_BIT_STRING.elements;
|
td->elements = asn_DEF_BIT_STRING.elements;
|
||||||
td->elements_count = asn_DEF_BIT_STRING.elements_count;
|
td->elements_count = asn_DEF_BIT_STRING.elements_count;
|
||||||
td->specifics = asn_DEF_BIT_STRING.specifics;
|
td->specifics = asn_DEF_BIT_STRING.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void SatelliteID_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -49,7 +49,9 @@ static void StdResolution_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -49,7 +49,9 @@ static void SystemInfoIndex_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void TA0_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void TA1_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void TA2_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -49,7 +49,9 @@ static void TLMReservedBits_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void TLMWord_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -48,7 +48,9 @@ static void TimeSlot_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
td->specifics = asn_DEF_NativeInteger.specifics;
|
td->specifics = asn_DEF_NativeInteger.specifics;
|
||||||
|
@ -30,7 +30,9 @@ static void TimeSlotScheme_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -30,7 +30,9 @@ static void UlPseudoSegInd_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -40,7 +40,9 @@ static void ephemE_17_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
/* td->specifics = asn_DEF_NativeInteger.specifics; // Defined
|
/* td->specifics = asn_DEF_NativeInteger.specifics; // Defined
|
||||||
@ -159,7 +161,9 @@ static void ephemAPowerHalf_19_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_NativeInteger.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_NativeInteger.elements;
|
td->elements = asn_DEF_NativeInteger.elements;
|
||||||
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
td->elements_count = asn_DEF_NativeInteger.elements_count;
|
||||||
/* td->specifics = asn_DEF_NativeInteger.specifics; // Defined
|
/* td->specifics = asn_DEF_NativeInteger.specifics; // Defined
|
||||||
|
@ -30,7 +30,9 @@ static void UseMultipleSets_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td)
|
|||||||
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
td->uper_decoder = asn_DEF_ENUMERATED.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
td->uper_encoder = asn_DEF_ENUMERATED.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_ENUMERATED.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_ENUMERATED.elements;
|
td->elements = asn_DEF_ENUMERATED.elements;
|
||||||
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
td->elements_count = asn_DEF_ENUMERATED.elements_count;
|
||||||
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
/* td->specifics = asn_DEF_ENUMERATED.specifics; // Defined
|
||||||
|
@ -31,7 +31,9 @@ static void VelocityEstimate_1_inherit_TYPE_descriptor(
|
|||||||
td->uper_decoder = asn_DEF_INTEGER.uper_decoder;
|
td->uper_decoder = asn_DEF_INTEGER.uper_decoder;
|
||||||
td->uper_encoder = asn_DEF_INTEGER.uper_encoder;
|
td->uper_encoder = asn_DEF_INTEGER.uper_encoder;
|
||||||
if (!td->per_constraints)
|
if (!td->per_constraints)
|
||||||
td->per_constraints = asn_DEF_INTEGER.per_constraints;
|
{
|
||||||
|
td->per_constraints = asn_DEF_INTEGER.per_constraints;
|
||||||
|
}
|
||||||
td->elements = asn_DEF_INTEGER.elements;
|
td->elements = asn_DEF_INTEGER.elements;
|
||||||
td->elements_count = asn_DEF_INTEGER.elements_count;
|
td->elements_count = asn_DEF_INTEGER.elements_count;
|
||||||
td->specifics = asn_DEF_INTEGER.specifics;
|
td->specifics = asn_DEF_INTEGER.specifics;
|
||||||
|
@ -17,7 +17,9 @@ void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (number < 0 || number >= as->count)
|
if (number < 0 || number >= as->count)
|
||||||
return; /* Nothing to delete */
|
{
|
||||||
|
return; /* Nothing to delete */
|
||||||
|
}
|
||||||
|
|
||||||
if (_do_free && as->free)
|
if (_do_free && as->free)
|
||||||
{
|
{
|
||||||
@ -33,12 +35,17 @@ void asn_sequence_del(void *asn_sequence_of_x, int number, int _do_free)
|
|||||||
*/
|
*/
|
||||||
--as->count;
|
--as->count;
|
||||||
for (n = number; n < as->count; n++)
|
for (n = number; n < as->count; n++)
|
||||||
as->array[n] = as->array[n + 1];
|
{
|
||||||
|
as->array[n] = as->array[n + 1];
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Invoke the third-party function only when the state
|
* Invoke the third-party function only when the state
|
||||||
* of the parent structure is consistent.
|
* of the parent structure is consistent.
|
||||||
*/
|
*/
|
||||||
if (ptr) as->free(ptr);
|
if (ptr)
|
||||||
|
{
|
||||||
|
as->free(ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,10 @@ void asn_set_del(void *asn_set_of_x, int number, int _do_free)
|
|||||||
if (as)
|
if (as)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
if (number < 0 || number >= as->count) return;
|
if (number < 0 || number >= as->count)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_do_free && as->free)
|
if (_do_free && as->free)
|
||||||
{
|
{
|
||||||
@ -68,7 +71,10 @@ void asn_set_del(void *asn_set_of_x, int number, int _do_free)
|
|||||||
* Invoke the third-party function only when the state
|
* Invoke the third-party function only when the state
|
||||||
* of the parent structure is consistent.
|
* of the parent structure is consistent.
|
||||||
*/
|
*/
|
||||||
if (ptr) as->free(ptr);
|
if (ptr)
|
||||||
|
{
|
||||||
|
as->free(ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +91,10 @@ void asn_set_empty(void *asn_set_of_x)
|
|||||||
{
|
{
|
||||||
if (as->free)
|
if (as->free)
|
||||||
{
|
{
|
||||||
while (as->count--) as->free(as->array[as->count]);
|
while (as->count--)
|
||||||
|
{
|
||||||
|
as->free(as->array[as->count]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FREEMEM(as->array);
|
FREEMEM(as->array);
|
||||||
as->array = 0;
|
as->array = 0;
|
||||||
|
@ -24,7 +24,10 @@ asn_dec_rval_t ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (st == NULL)
|
if (st == NULL)
|
||||||
{
|
{
|
||||||
st = (ASN__PRIMITIVE_TYPE_t *)CALLOC(1, sizeof(*st));
|
st = (ASN__PRIMITIVE_TYPE_t *)CALLOC(1, sizeof(*st));
|
||||||
if (st == NULL) _ASN_DECODE_FAILED;
|
if (st == NULL)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
*sptr = (void *)st;
|
*sptr = (void *)st;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +38,10 @@ asn_dec_rval_t ber_decode_primitive(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
*/
|
*/
|
||||||
rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0,
|
rval = ber_check_tags(opt_codec_ctx, td, 0, buf_ptr, size, tag_mode, 0,
|
||||||
&length, 0);
|
&length, 0);
|
||||||
if (rval.code != RC_OK) return rval;
|
if (rval.code != RC_OK)
|
||||||
|
{
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("%s length is %d bytes", td->name, (int)length);
|
ASN_DEBUG("%s length is %d bytes", td->name, (int)length);
|
||||||
|
|
||||||
@ -124,13 +130,22 @@ void ASN__PRIMITIVE_TYPE_free(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
{
|
{
|
||||||
ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr;
|
ASN__PRIMITIVE_TYPE_t *st = (ASN__PRIMITIVE_TYPE_t *)sptr;
|
||||||
|
|
||||||
if (!td || !sptr) return;
|
if (!td || !sptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Freeing %s as a primitive type", td->name);
|
ASN_DEBUG("Freeing %s as a primitive type", td->name);
|
||||||
|
|
||||||
if (st->buf) FREEMEM(st->buf);
|
if (st->buf)
|
||||||
|
{
|
||||||
|
FREEMEM(st->buf);
|
||||||
|
}
|
||||||
|
|
||||||
if (!contents_only) FREEMEM(st);
|
if (!contents_only)
|
||||||
|
{
|
||||||
|
FREEMEM(st);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -154,7 +169,9 @@ static int xer_decode__unexpected_tag(void *key, const void *chunk_buf,
|
|||||||
if (arg->decoded_something)
|
if (arg->decoded_something)
|
||||||
{
|
{
|
||||||
if (xer_is_whitespace(chunk_buf, chunk_size))
|
if (xer_is_whitespace(chunk_buf, chunk_size))
|
||||||
return 0; /* Skip it. */
|
{
|
||||||
|
return 0; /* Skip it. */
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Decoding was done once already. Prohibit doing it again.
|
* Decoding was done once already. Prohibit doing it again.
|
||||||
*/
|
*/
|
||||||
@ -188,7 +205,10 @@ static ssize_t xer_decode__body(void *key, const void *chunk_buf,
|
|||||||
|
|
||||||
if (arg->decoded_something)
|
if (arg->decoded_something)
|
||||||
{
|
{
|
||||||
if (xer_is_whitespace(chunk_buf, chunk_size)) return chunk_size;
|
if (xer_is_whitespace(chunk_buf, chunk_size))
|
||||||
|
{
|
||||||
|
return chunk_size;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Decoding was done once already. Prohibit doing it again.
|
* Decoding was done once already. Prohibit doing it again.
|
||||||
*/
|
*/
|
||||||
@ -244,7 +264,10 @@ asn_dec_rval_t xer_decode_primitive(
|
|||||||
if (!*sptr)
|
if (!*sptr)
|
||||||
{
|
{
|
||||||
*sptr = CALLOC(1, struct_size);
|
*sptr = CALLOC(1, struct_size);
|
||||||
if (!*sptr) _ASN_DECODE_FAILED;
|
if (!*sptr)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&s_ctx, 0, sizeof(s_ctx));
|
memset(&s_ctx, 0, sizeof(s_ctx));
|
||||||
@ -291,9 +314,13 @@ asn_dec_rval_t xer_decode_primitive(
|
|||||||
case RC_FAIL:
|
case RC_FAIL:
|
||||||
rc.consumed = 0;
|
rc.consumed = 0;
|
||||||
if (s_arg.want_more)
|
if (s_arg.want_more)
|
||||||
rc.code = RC_WMORE;
|
{
|
||||||
|
rc.code = RC_WMORE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
_ASN_DECODE_FAILED;
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -92,7 +92,10 @@ asn_dec_rval_t ber_check_tags(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
/*
|
/*
|
||||||
* Make sure we didn't exceed the maximum stack size.
|
* Make sure we didn't exceed the maximum stack size.
|
||||||
*/
|
*/
|
||||||
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) RETURN(RC_FAIL);
|
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* So what does all this implicit skip stuff mean?
|
* So what does all this implicit skip stuff mean?
|
||||||
@ -317,11 +320,18 @@ asn_dec_rval_t ber_check_tags(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt_tlv_form) *opt_tlv_form = tlv_constr;
|
if (opt_tlv_form)
|
||||||
|
{
|
||||||
|
*opt_tlv_form = tlv_constr;
|
||||||
|
}
|
||||||
if (expect_00_terminators)
|
if (expect_00_terminators)
|
||||||
*last_length = -expect_00_terminators;
|
{
|
||||||
|
*last_length = -expect_00_terminators;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*last_length = tlv_len;
|
{
|
||||||
|
*last_length = tlv_len;
|
||||||
|
}
|
||||||
|
|
||||||
RETURN(RC_OK);
|
RETURN(RC_OK);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,10 @@ ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size,
|
|||||||
const uint8_t *buf = (const uint8_t *)bufptr;
|
const uint8_t *buf = (const uint8_t *)bufptr;
|
||||||
unsigned oct;
|
unsigned oct;
|
||||||
|
|
||||||
if (size == 0) return 0; /* Want more */
|
if (size == 0)
|
||||||
|
{
|
||||||
|
return 0; /* Want more */
|
||||||
|
}
|
||||||
|
|
||||||
oct = *buf;
|
oct = *buf;
|
||||||
if ((oct & 0x80) == 0)
|
if ((oct & 0x80) == 0)
|
||||||
@ -90,13 +93,19 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed,
|
|||||||
/*
|
/*
|
||||||
* Make sure we didn't exceed the maximum stack size.
|
* Make sure we didn't exceed the maximum stack size.
|
||||||
*/
|
*/
|
||||||
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) return -1;
|
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine the size of L in TLV.
|
* Determine the size of L in TLV.
|
||||||
*/
|
*/
|
||||||
ll = ber_fetch_length(_is_constructed, ptr, size, &vlen);
|
ll = ber_fetch_length(_is_constructed, ptr, size, &vlen);
|
||||||
if (ll <= 0) return ll;
|
if (ll <= 0)
|
||||||
|
{
|
||||||
|
return ll;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Definite length.
|
* Definite length.
|
||||||
@ -104,7 +113,10 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed,
|
|||||||
if (vlen >= 0)
|
if (vlen >= 0)
|
||||||
{
|
{
|
||||||
skip = ll + vlen;
|
skip = ll + vlen;
|
||||||
if (skip > size) return 0; /* Want more */
|
if (skip > size)
|
||||||
|
{
|
||||||
|
return 0; /* Want more */
|
||||||
|
}
|
||||||
return skip;
|
return skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,11 +130,17 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed,
|
|||||||
|
|
||||||
/* Fetch the tag */
|
/* Fetch the tag */
|
||||||
tl = ber_fetch_tag(ptr, size, &tag);
|
tl = ber_fetch_tag(ptr, size, &tag);
|
||||||
if (tl <= 0) return tl;
|
if (tl <= 0)
|
||||||
|
{
|
||||||
|
return tl;
|
||||||
|
}
|
||||||
|
|
||||||
ll = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr),
|
ll = ber_skip_length(opt_codec_ctx, BER_TLV_CONSTRUCTED(ptr),
|
||||||
((const char *)ptr) + tl, size - tl);
|
((const char *)ptr) + tl, size - tl);
|
||||||
if (ll <= 0) return ll;
|
if (ll <= 0)
|
||||||
|
{
|
||||||
|
return ll;
|
||||||
|
}
|
||||||
|
|
||||||
skip += tl + ll;
|
skip += tl + ll;
|
||||||
|
|
||||||
@ -133,7 +151,9 @@ ssize_t ber_skip_length(asn_codec_ctx_t *opt_codec_ctx, int _is_constructed,
|
|||||||
*/
|
*/
|
||||||
if (((const uint8_t *)ptr)[0] == 0 &&
|
if (((const uint8_t *)ptr)[0] == 0 &&
|
||||||
((const uint8_t *)ptr)[1] == 0)
|
((const uint8_t *)ptr)[1] == 0)
|
||||||
return skip;
|
{
|
||||||
|
return skip;
|
||||||
|
}
|
||||||
|
|
||||||
ptr = ((const char *)ptr) + tl + ll;
|
ptr = ((const char *)ptr) + tl + ll;
|
||||||
size -= tl + ll;
|
size -= tl + ll;
|
||||||
@ -152,7 +172,10 @@ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size)
|
|||||||
if (len <= 127)
|
if (len <= 127)
|
||||||
{
|
{
|
||||||
/* Encoded in 1 octet */
|
/* Encoded in 1 octet */
|
||||||
if (size) *buf = (uint8_t)len;
|
if (size)
|
||||||
|
{
|
||||||
|
*buf = (uint8_t)len;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,12 +185,19 @@ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size)
|
|||||||
for (required_size = 1, i = 8; i < 8 * sizeof(len); i += 8)
|
for (required_size = 1, i = 8; i < 8 * sizeof(len); i += 8)
|
||||||
{
|
{
|
||||||
if (len >> i)
|
if (len >> i)
|
||||||
required_size++;
|
{
|
||||||
|
required_size++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
break;
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size <= required_size) return required_size + 1;
|
if (size <= required_size)
|
||||||
|
{
|
||||||
|
return required_size + 1;
|
||||||
|
}
|
||||||
|
|
||||||
*buf++ = (uint8_t)(0x80 | required_size); /* Length of the encoding */
|
*buf++ = (uint8_t)(0x80 | required_size); /* Length of the encoding */
|
||||||
|
|
||||||
@ -175,7 +205,10 @@ size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufp, size_t size)
|
|||||||
* Produce the len encoding, space permitting.
|
* Produce the len encoding, space permitting.
|
||||||
*/
|
*/
|
||||||
end = buf + required_size;
|
end = buf + required_size;
|
||||||
for (i -= 8; buf < end; i -= 8, buf++) *buf = (uint8_t)(len >> i);
|
for (i -= 8; buf < end; i -= 8, buf++)
|
||||||
|
{
|
||||||
|
*buf = (uint8_t)(len >> i);
|
||||||
|
}
|
||||||
|
|
||||||
return required_size + 1;
|
return required_size + 1;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,10 @@ ssize_t ber_fetch_tag(const void *ptr, size_t size, ber_tlv_tag_t *tag_r)
|
|||||||
ber_tlv_tag_t tclass;
|
ber_tlv_tag_t tclass;
|
||||||
size_t skipped;
|
size_t skipped;
|
||||||
|
|
||||||
if (size == 0) return 0;
|
if (size == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
val = *(const uint8_t *)ptr;
|
val = *(const uint8_t *)ptr;
|
||||||
tclass = (val >> 6);
|
tclass = (val >> 6);
|
||||||
@ -98,7 +101,10 @@ ssize_t ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = snprintf(buf, size, "[%s%u]", type, ((unsigned)tag) >> 2);
|
ret = snprintf(buf, size, "[%s%u]", type, ((unsigned)tag) >> 2);
|
||||||
if (ret <= 0 && size) buf[0] = '\0'; /* against broken libc's */
|
if (ret <= 0 && size)
|
||||||
|
{
|
||||||
|
buf[0] = '\0'; /* against broken libc's */
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -124,7 +130,10 @@ size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size)
|
|||||||
if (tval <= 30)
|
if (tval <= 30)
|
||||||
{
|
{
|
||||||
/* Encoded in 1 octet */
|
/* Encoded in 1 octet */
|
||||||
if (size) buf[0] = (tclass << 6) | tval;
|
if (size)
|
||||||
|
{
|
||||||
|
buf[0] = (tclass << 6) | tval;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (size)
|
else if (size)
|
||||||
@ -139,18 +148,28 @@ size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufp, size_t size)
|
|||||||
for (required_size = 1, i = 7; i < 8 * sizeof(tval); i += 7)
|
for (required_size = 1, i = 7; i < 8 * sizeof(tval); i += 7)
|
||||||
{
|
{
|
||||||
if (tval >> i)
|
if (tval >> i)
|
||||||
required_size++;
|
{
|
||||||
|
required_size++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
break;
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < required_size) return required_size + 1;
|
if (size < required_size)
|
||||||
|
{
|
||||||
|
return required_size + 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill in the buffer, space permitting.
|
* Fill in the buffer, space permitting.
|
||||||
*/
|
*/
|
||||||
end = buf + required_size - 1;
|
end = buf + required_size - 1;
|
||||||
for (i -= 7; buf < end; i -= 7, buf++) *buf = 0x80 | ((tval >> i) & 0x7F);
|
for (i -= 7; buf < end; i -= 7, buf++)
|
||||||
|
{
|
||||||
|
*buf = 0x80 | ((tval >> i) & 0x7F);
|
||||||
|
}
|
||||||
*buf = (tval & 0x7F); /* Last octet without high bit */
|
*buf = (tval & 0x7F); /* Last octet without high bit */
|
||||||
|
|
||||||
return required_size + 1;
|
return required_size + 1;
|
||||||
|
@ -92,11 +92,17 @@ static int _search4tag(const void *ap, const void *bp)
|
|||||||
ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag);
|
ber_tlv_tag_t b_value = BER_TAG_VALUE(b->el_tag);
|
||||||
|
|
||||||
if (a_value == b_value)
|
if (a_value == b_value)
|
||||||
return 0;
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
else if (a_value < b_value)
|
else if (a_value < b_value)
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return 1;
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (a_class < b_class)
|
else if (a_class < b_class)
|
||||||
{
|
{
|
||||||
@ -202,7 +208,10 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
switch (tag_len)
|
switch (tag_len)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!SIZE_VIOLATION) RETURN(RC_WMORE);
|
if (!SIZE_VIOLATION)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case -1:
|
case -1:
|
||||||
RETURN(RC_FAIL);
|
RETURN(RC_FAIL);
|
||||||
@ -251,7 +260,9 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!SIZE_VIOLATION)
|
if (!SIZE_VIOLATION)
|
||||||
RETURN(RC_WMORE);
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case -1:
|
case -1:
|
||||||
RETURN(RC_FAIL);
|
RETURN(RC_FAIL);
|
||||||
@ -366,7 +377,10 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
switch (tl)
|
switch (tl)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!SIZE_VIOLATION) RETURN(RC_WMORE);
|
if (!SIZE_VIOLATION)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case -1:
|
case -1:
|
||||||
RETURN(RC_FAIL);
|
RETURN(RC_FAIL);
|
||||||
@ -380,9 +394,13 @@ asn_dec_rval_t CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (LEFT < 2)
|
if (LEFT < 2)
|
||||||
{
|
{
|
||||||
if (SIZE_VIOLATION)
|
if (SIZE_VIOLATION)
|
||||||
RETURN(RC_FAIL);
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RETURN(RC_WMORE);
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (((const uint8_t *)ptr)[1] == 0)
|
else if (((const uint8_t *)ptr)[1] == 0)
|
||||||
{
|
{
|
||||||
@ -424,7 +442,10 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
size_t computed_size = 0;
|
size_t computed_size = 0;
|
||||||
int present;
|
int present;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name);
|
ASN_DEBUG("%s %s as CHOICE", cb ? "Encoding" : "Estimating", td->name);
|
||||||
|
|
||||||
@ -483,12 +504,18 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
/* Encode member with its tag */
|
/* Encode member with its tag */
|
||||||
erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode,
|
erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode,
|
||||||
elm->tag, 0, 0);
|
elm->tag, 0, 0);
|
||||||
if (erval.encoded == -1) return erval;
|
if (erval.encoded == -1)
|
||||||
|
{
|
||||||
|
return erval;
|
||||||
|
}
|
||||||
|
|
||||||
/* Encode CHOICE with parent or my own tag */
|
/* Encode CHOICE with parent or my own tag */
|
||||||
ret = der_write_tags(td, erval.encoded, tag_mode, 1, tag, cb,
|
ret = der_write_tags(td, erval.encoded, tag_mode, 1, tag, cb,
|
||||||
app_key);
|
app_key);
|
||||||
if (ret == -1) _ASN_ENCODE_FAILED;
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
computed_size += ret;
|
computed_size += ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +524,10 @@ asn_enc_rval_t CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
*/
|
*/
|
||||||
erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag,
|
erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag,
|
||||||
cb, app_key);
|
cb, app_key);
|
||||||
if (erval.encoded == -1) return erval;
|
if (erval.encoded == -1)
|
||||||
|
{
|
||||||
|
return erval;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Encoded CHOICE member in %ld bytes (+%ld)", (long)erval.encoded,
|
ASN_DEBUG("Encoded CHOICE member in %ld bytes (+%ld)", (long)erval.encoded,
|
||||||
(long)computed_size);
|
(long)computed_size);
|
||||||
@ -576,7 +606,10 @@ int CHOICE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
elm->memb_offset);
|
elm->memb_offset);
|
||||||
if (!memb_ptr)
|
if (!memb_ptr)
|
||||||
{
|
{
|
||||||
if (elm->optional) return 0;
|
if (elm->optional)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
_ASN_CTFAIL(app_key, td, sptr,
|
_ASN_CTFAIL(app_key, td, sptr,
|
||||||
"%s: mandatory CHOICE element %s "
|
"%s: mandatory CHOICE element %s "
|
||||||
"absent (%s:%d)",
|
"absent (%s:%d)",
|
||||||
@ -658,7 +691,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (st == 0)
|
if (st == 0)
|
||||||
{
|
{
|
||||||
st = *struct_ptr = CALLOC(1, specs->struct_size);
|
st = *struct_ptr = CALLOC(1, specs->struct_size);
|
||||||
if (st == 0) RETURN(RC_FAIL);
|
if (st == 0)
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -666,7 +702,9 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
*/
|
*/
|
||||||
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
|
ctx = (asn_struct_ctx_t *)((char *)st + specs->ctx_offset);
|
||||||
if (ctx->phase == 0 && !*xml_tag)
|
if (ctx->phase == 0 && !*xml_tag)
|
||||||
ctx->phase = 1; /* Skip the outer tag checking phase */
|
{
|
||||||
|
ctx->phase = 1; /* Skip the outer tag checking phase */
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Phases of XER/XML processing:
|
* Phases of XER/XML processing:
|
||||||
@ -714,7 +752,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
XER_ADVANCE(tmprval.consumed);
|
XER_ADVANCE(tmprval.consumed);
|
||||||
ASN_DEBUG("XER/CHOICE: itdf: [%s] code=%d", elm->type->name,
|
ASN_DEBUG("XER/CHOICE: itdf: [%s] code=%d", elm->type->name,
|
||||||
tmprval.code);
|
tmprval.code);
|
||||||
if (tmprval.code != RC_OK) RETURN(tmprval.code);
|
if (tmprval.code != RC_OK)
|
||||||
|
{
|
||||||
|
RETURN(tmprval.code);
|
||||||
|
}
|
||||||
assert(_fetch_present_idx(st, specs->pres_offset,
|
assert(_fetch_present_idx(st, specs->pres_offset,
|
||||||
specs->pres_size) == 0);
|
specs->pres_size) == 0);
|
||||||
/* Record what we've got */
|
/* Record what we've got */
|
||||||
@ -788,7 +829,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
case XCT_BOTH:
|
case XCT_BOTH:
|
||||||
break; /* No CHOICE? */
|
break; /* No CHOICE? */
|
||||||
case XCT_CLOSING:
|
case XCT_CLOSING:
|
||||||
if (ctx->phase != 3) break;
|
if (ctx->phase != 3)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
XER_ADVANCE(ch_size);
|
XER_ADVANCE(ch_size);
|
||||||
ctx->phase = 5; /* Phase out */
|
ctx->phase = 5; /* Phase out */
|
||||||
RETURN(RC_OK);
|
RETURN(RC_OK);
|
||||||
@ -803,7 +847,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
case XCT_UNKNOWN_OP:
|
case XCT_UNKNOWN_OP:
|
||||||
case XCT_UNKNOWN_BO:
|
case XCT_UNKNOWN_BO:
|
||||||
|
|
||||||
if (ctx->phase != 1) break; /* Really unexpected */
|
if (ctx->phase != 1)
|
||||||
|
{
|
||||||
|
break; /* Really unexpected */
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Search which inner member corresponds to this tag.
|
* Search which inner member corresponds to this tag.
|
||||||
@ -832,7 +879,10 @@ asn_dec_rval_t CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (edx != td->elements_count) continue;
|
if (edx != td->elements_count)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* It is expected extension */
|
/* It is expected extension */
|
||||||
if (specs->ext_start != -1)
|
if (specs->ext_start != -1)
|
||||||
@ -885,7 +935,10 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
asn_enc_rval_t er;
|
asn_enc_rval_t er;
|
||||||
int present;
|
int present;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
@ -907,7 +960,10 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
if (elm->flags & ATF_POINTER)
|
if (elm->flags & ATF_POINTER)
|
||||||
{
|
{
|
||||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||||
if (!memb_ptr) _ASN_ENCODE_FAILED;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -916,19 +972,28 @@ asn_enc_rval_t CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
|
|
||||||
er.encoded = 0;
|
er.encoded = 0;
|
||||||
|
|
||||||
if (!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel);
|
if (!(flags & XER_F_CANONICAL))
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||||
|
}
|
||||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||||
|
|
||||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1,
|
tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1,
|
||||||
flags, cb, app_key);
|
flags, cb, app_key);
|
||||||
if (tmper.encoded == -1) return tmper;
|
if (tmper.encoded == -1)
|
||||||
|
{
|
||||||
|
return tmper;
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||||
|
|
||||||
er.encoded += 5 + (2 * mlen) + tmper.encoded;
|
er.encoded += 5 + (2 * mlen) + tmper.encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & XER_F_CANONICAL)) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
if (!(flags & XER_F_CANONICAL))
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
cb_failed:
|
cb_failed:
|
||||||
@ -949,7 +1014,10 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
void *st = *sptr;
|
void *st = *sptr;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED;
|
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create the target structure if it is not present already.
|
* Create the target structure if it is not present already.
|
||||||
@ -957,42 +1025,75 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (!st)
|
if (!st)
|
||||||
{
|
{
|
||||||
st = *sptr = CALLOC(1, specs->struct_size);
|
st = *sptr = CALLOC(1, specs->struct_size);
|
||||||
if (!st) _ASN_DECODE_FAILED;
|
if (!st)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constraints)
|
if (constraints)
|
||||||
ct = &constraints->value;
|
{
|
||||||
|
ct = &constraints->value;
|
||||||
|
}
|
||||||
else if (td->per_constraints)
|
else if (td->per_constraints)
|
||||||
ct = &td->per_constraints->value;
|
{
|
||||||
|
ct = &td->per_constraints->value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ct = 0;
|
{
|
||||||
|
ct = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (ct && ct->flags & APC_EXTENSIBLE)
|
if (ct && ct->flags & APC_EXTENSIBLE)
|
||||||
{
|
{
|
||||||
value = per_get_few_bits(pd, 1);
|
value = per_get_few_bits(pd, 1);
|
||||||
if (value < 0) _ASN_DECODE_STARVED;
|
if (value < 0)
|
||||||
if (value) ct = 0; /* Not restricted */
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
ct = 0; /* Not restricted */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ct && ct->range_bits >= 0)
|
if (ct && ct->range_bits >= 0)
|
||||||
{
|
{
|
||||||
value = per_get_few_bits(pd, ct->range_bits);
|
value = per_get_few_bits(pd, ct->range_bits);
|
||||||
if (value < 0) _ASN_DECODE_STARVED;
|
if (value < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
ASN_DEBUG("CHOICE %s got index %d in range %d", td->name, value,
|
ASN_DEBUG("CHOICE %s got index %d in range %d", td->name, value,
|
||||||
ct->range_bits);
|
ct->range_bits);
|
||||||
if (value > ct->upper_bound) _ASN_DECODE_FAILED;
|
if (value > ct->upper_bound)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (specs->ext_start == -1) _ASN_DECODE_FAILED;
|
if (specs->ext_start == -1)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
value = uper_get_nsnnwn(pd);
|
value = uper_get_nsnnwn(pd);
|
||||||
if (value < 0) _ASN_DECODE_STARVED;
|
if (value < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
value += specs->ext_start;
|
value += specs->ext_start;
|
||||||
if (value >= td->elements_count) _ASN_DECODE_FAILED;
|
if (value >= td->elements_count)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Adjust if canonical order is different from natural order */
|
/* Adjust if canonical order is different from natural order */
|
||||||
if (specs->canonical_order) value = specs->canonical_order[value];
|
if (specs->canonical_order)
|
||||||
|
{
|
||||||
|
value = specs->canonical_order[value];
|
||||||
|
}
|
||||||
|
|
||||||
/* Set presence to be able to free it later */
|
/* Set presence to be able to free it later */
|
||||||
_set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
|
_set_present_idx(st, specs->pres_offset, specs->pres_size, value + 1);
|
||||||
@ -1022,8 +1123,10 @@ asn_dec_rval_t CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rv.code != RC_OK)
|
if (rv.code != RC_OK)
|
||||||
ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d", elm->name, td->name,
|
{
|
||||||
rv.code);
|
ASN_DEBUG("Failed to decode %s in %s (CHOICE) %d", elm->name, td->name,
|
||||||
|
rv.code);
|
||||||
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1037,16 +1140,25 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
void *memb_ptr;
|
void *memb_ptr;
|
||||||
int present;
|
int present;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Encoding %s as CHOICE", td->name);
|
ASN_DEBUG("Encoding %s as CHOICE", td->name);
|
||||||
|
|
||||||
if (constraints)
|
if (constraints)
|
||||||
ct = &constraints->value;
|
{
|
||||||
|
ct = &constraints->value;
|
||||||
|
}
|
||||||
else if (td->per_constraints)
|
else if (td->per_constraints)
|
||||||
ct = &td->per_constraints->value;
|
{
|
||||||
|
ct = &td->per_constraints->value;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ct = 0;
|
{
|
||||||
|
ct = 0;
|
||||||
|
}
|
||||||
|
|
||||||
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size);
|
||||||
|
|
||||||
@ -1055,12 +1167,19 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
* can't deduce what to encode in the choice type.
|
* can't deduce what to encode in the choice type.
|
||||||
*/
|
*/
|
||||||
if (present <= 0 || present > td->elements_count)
|
if (present <= 0 || present > td->elements_count)
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
present--;
|
{
|
||||||
|
present--;
|
||||||
|
}
|
||||||
|
|
||||||
/* Adjust if canonical order is different from natural order */
|
/* Adjust if canonical order is different from natural order */
|
||||||
if (specs->canonical_order) present = specs->canonical_order[present];
|
if (specs->canonical_order)
|
||||||
|
{
|
||||||
|
present = specs->canonical_order[present];
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present);
|
ASN_DEBUG("Encoding %s CHOICE element %d", td->name, present);
|
||||||
|
|
||||||
@ -1070,7 +1189,10 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
{
|
{
|
||||||
if (ct->flags & APC_EXTENSIBLE)
|
if (ct->flags & APC_EXTENSIBLE)
|
||||||
{
|
{
|
||||||
if (per_put_few_bits(po, 1, 1)) _ASN_ENCODE_FAILED;
|
if (per_put_few_bits(po, 1, 1))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1080,14 +1202,22 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ct && ct->flags & APC_EXTENSIBLE)
|
if (ct && ct->flags & APC_EXTENSIBLE)
|
||||||
if (per_put_few_bits(po, 0, 1)) _ASN_ENCODE_FAILED;
|
{
|
||||||
|
if (per_put_few_bits(po, 0, 1))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
elm = &td->elements[present];
|
elm = &td->elements[present];
|
||||||
if (elm->flags & ATF_POINTER)
|
if (elm->flags & ATF_POINTER)
|
||||||
{
|
{
|
||||||
/* Member is a pointer to another structure */
|
/* Member is a pointer to another structure */
|
||||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||||
if (!memb_ptr) _ASN_ENCODE_FAILED;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1097,7 +1227,9 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
if (ct && ct->range_bits >= 0)
|
if (ct && ct->range_bits >= 0)
|
||||||
{
|
{
|
||||||
if (per_put_few_bits(po, present, ct->range_bits))
|
if (per_put_few_bits(po, present, ct->range_bits))
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
return elm->type->uper_encoder(elm->type, elm->per_constraints,
|
return elm->type->uper_encoder(elm->type, elm->per_constraints,
|
||||||
memb_ptr, po);
|
memb_ptr, po);
|
||||||
@ -1105,12 +1237,19 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
asn_enc_rval_t rval;
|
asn_enc_rval_t rval;
|
||||||
if (specs->ext_start == -1) _ASN_ENCODE_FAILED;
|
if (specs->ext_start == -1)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
if (uper_put_nsnnwn(po, present - specs->ext_start))
|
if (uper_put_nsnnwn(po, present - specs->ext_start))
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
if (uper_open_type_put(elm->type, elm->per_constraints, memb_ptr,
|
if (uper_open_type_put(elm->type, elm->per_constraints, memb_ptr,
|
||||||
po))
|
po))
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
rval.encoded = 0;
|
rval.encoded = 0;
|
||||||
_ASN_ENCODED_OK(rval);
|
_ASN_ENCODED_OK(rval);
|
||||||
}
|
}
|
||||||
@ -1122,7 +1261,10 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
||||||
int present;
|
int present;
|
||||||
|
|
||||||
if (!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Figure out which CHOICE element is encoded.
|
* Figure out which CHOICE element is encoded.
|
||||||
@ -1142,7 +1284,9 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
memb_ptr = *(const void *const *)((const char *)sptr +
|
memb_ptr = *(const void *const *)((const char *)sptr +
|
||||||
elm->memb_offset);
|
elm->memb_offset);
|
||||||
if (!memb_ptr)
|
if (!memb_ptr)
|
||||||
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
{
|
||||||
|
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1155,7 +1299,9 @@ int CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
{
|
{
|
||||||
if (cb(elm->name, strlen(elm->name), app_key) < 0 ||
|
if (cb(elm->name, strlen(elm->name), app_key) < 0 ||
|
||||||
cb(": ", 2, app_key) < 0)
|
cb(": ", 2, app_key) < 0)
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return elm->type->print_struct(elm->type, memb_ptr, ilevel, cb,
|
return elm->type->print_struct(elm->type, memb_ptr, ilevel, cb,
|
||||||
@ -1172,7 +1318,10 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
|
|||||||
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
|
||||||
int present;
|
int present;
|
||||||
|
|
||||||
if (!td || !ptr) return;
|
if (!td || !ptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Freeing %s as CHOICE", td->name);
|
ASN_DEBUG("Freeing %s as CHOICE", td->name);
|
||||||
|
|
||||||
@ -1192,7 +1341,10 @@ void CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
|
|||||||
if (elm->flags & ATF_POINTER)
|
if (elm->flags & ATF_POINTER)
|
||||||
{
|
{
|
||||||
memb_ptr = *(void **)((char *)ptr + elm->memb_offset);
|
memb_ptr = *(void **)((char *)ptr + elm->memb_offset);
|
||||||
if (memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
if (memb_ptr)
|
||||||
|
{
|
||||||
|
ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -99,7 +99,10 @@ static int _t2e_cmp(const void *ap, const void *bp)
|
|||||||
|
|
||||||
if (a_value == b_value)
|
if (a_value == b_value)
|
||||||
{
|
{
|
||||||
if (a->el_no > b->el_no) return 1;
|
if (a->el_no > b->el_no)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Important: we do not check
|
* Important: we do not check
|
||||||
* for a->el_no <= b->el_no!
|
* for a->el_no <= b->el_no!
|
||||||
@ -107,9 +110,13 @@ static int _t2e_cmp(const void *ap, const void *bp)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (a_value < b_value)
|
else if (a_value < b_value)
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return 1;
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (a_class < b_class)
|
else if (a_class < b_class)
|
||||||
{
|
{
|
||||||
@ -187,7 +194,9 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->left >= 0)
|
if (ctx->left >= 0)
|
||||||
ctx->left += rval.consumed; /* ?Subtracted below! */
|
{
|
||||||
|
ctx->left += rval.consumed; /* ?Subtracted below! */
|
||||||
|
}
|
||||||
ADVANCE(rval.consumed);
|
ADVANCE(rval.consumed);
|
||||||
|
|
||||||
NEXT_PHASE(ctx);
|
NEXT_PHASE(ctx);
|
||||||
@ -217,7 +226,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
int use_bsearch;
|
int use_bsearch;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (ctx->step & 1) goto microphase2;
|
if (ctx->step & 1)
|
||||||
|
{
|
||||||
|
goto microphase2;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MICROPHASE 1: Synchronize decoding.
|
* MICROPHASE 1: Synchronize decoding.
|
||||||
@ -259,7 +271,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
switch (tag_len)
|
switch (tag_len)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!SIZE_VIOLATION) RETURN(RC_WMORE);
|
if (!SIZE_VIOLATION)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case -1:
|
case -1:
|
||||||
RETURN(RC_FAIL);
|
RETURN(RC_FAIL);
|
||||||
@ -270,9 +285,13 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (LEFT < 2)
|
if (LEFT < 2)
|
||||||
{
|
{
|
||||||
if (SIZE_VIOLATION)
|
if (SIZE_VIOLATION)
|
||||||
RETURN(RC_FAIL);
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RETURN(RC_WMORE);
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (((const uint8_t *)ptr)[1] == 0)
|
else if (((const uint8_t *)ptr)[1] == 0)
|
||||||
{
|
{
|
||||||
@ -306,7 +325,9 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
use_bsearch = 0;
|
use_bsearch = 0;
|
||||||
opt_edx_end = edx + elements[edx].optional + 1;
|
opt_edx_end = edx + elements[edx].optional + 1;
|
||||||
if (opt_edx_end > td->elements_count)
|
if (opt_edx_end > td->elements_count)
|
||||||
opt_edx_end = td->elements_count; /* Cap */
|
{
|
||||||
|
opt_edx_end = td->elements_count; /* Cap */
|
||||||
|
}
|
||||||
else if (opt_edx_end - edx > 8)
|
else if (opt_edx_end - edx > 8)
|
||||||
{
|
{
|
||||||
/* Limit the scope of linear search... */
|
/* Limit the scope of linear search... */
|
||||||
@ -372,8 +393,14 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
t2m_l = t2m + t2m->toff_last;
|
t2m_l = t2m + t2m->toff_last;
|
||||||
for (t2m = t2m_f; t2m <= t2m_l; t2m++)
|
for (t2m = t2m_f; t2m <= t2m_l; t2m++)
|
||||||
{
|
{
|
||||||
if (t2m->el_no > edx_max) break;
|
if (t2m->el_no > edx_max)
|
||||||
if (t2m->el_no < edx) continue;
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (t2m->el_no < edx)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
best = t2m;
|
best = t2m;
|
||||||
}
|
}
|
||||||
if (best)
|
if (best)
|
||||||
@ -428,7 +455,9 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!SIZE_VIOLATION)
|
if (!SIZE_VIOLATION)
|
||||||
RETURN(RC_WMORE);
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case -1:
|
case -1:
|
||||||
RETURN(RC_FAIL);
|
RETURN(RC_FAIL);
|
||||||
@ -524,7 +553,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
switch (tl)
|
switch (tl)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!SIZE_VIOLATION) RETURN(RC_WMORE);
|
if (!SIZE_VIOLATION)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case -1:
|
case -1:
|
||||||
RETURN(RC_FAIL);
|
RETURN(RC_FAIL);
|
||||||
@ -538,9 +570,13 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (LEFT < 2)
|
if (LEFT < 2)
|
||||||
{
|
{
|
||||||
if (SIZE_VIOLATION)
|
if (SIZE_VIOLATION)
|
||||||
RETURN(RC_FAIL);
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RETURN(RC_WMORE);
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (((const uint8_t *)ptr)[1] == 0)
|
else if (((const uint8_t *)ptr)[1] == 0)
|
||||||
{
|
{
|
||||||
@ -571,7 +607,10 @@ asn_dec_rval_t SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
switch (ll)
|
switch (ll)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!SIZE_VIOLATION) RETURN(RC_WMORE);
|
if (!SIZE_VIOLATION)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case -1:
|
case -1:
|
||||||
RETURN(RC_FAIL);
|
RETURN(RC_FAIL);
|
||||||
@ -612,7 +651,10 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||||
if (!memb_ptr)
|
if (!memb_ptr)
|
||||||
{
|
{
|
||||||
if (elm->optional) continue;
|
if (elm->optional)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
/* Mandatory element is missing */
|
/* Mandatory element is missing */
|
||||||
_ASN_ENCODE_FAILED;
|
_ASN_ENCODE_FAILED;
|
||||||
}
|
}
|
||||||
@ -623,7 +665,10 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
}
|
}
|
||||||
erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode,
|
erval = elm->type->der_encoder(elm->type, memb_ptr, elm->tag_mode,
|
||||||
elm->tag, 0, 0);
|
elm->tag, 0, 0);
|
||||||
if (erval.encoded == -1) return erval;
|
if (erval.encoded == -1)
|
||||||
|
{
|
||||||
|
return erval;
|
||||||
|
}
|
||||||
computed_size += erval.encoded;
|
computed_size += erval.encoded;
|
||||||
ASN_DEBUG("Member %d %s estimated %ld bytes", edx, elm->name,
|
ASN_DEBUG("Member %d %s estimated %ld bytes", edx, elm->name,
|
||||||
(long)erval.encoded);
|
(long)erval.encoded);
|
||||||
@ -634,10 +679,16 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
*/
|
*/
|
||||||
ret = der_write_tags(td, computed_size, tag_mode, 1, tag, cb, app_key);
|
ret = der_write_tags(td, computed_size, tag_mode, 1, tag, cb, app_key);
|
||||||
ASN_DEBUG("Wrote tags: %ld (+%ld)", (long)ret, (long)computed_size);
|
ASN_DEBUG("Wrote tags: %ld (+%ld)", (long)ret, (long)computed_size);
|
||||||
if (ret == -1) _ASN_ENCODE_FAILED;
|
if (ret == -1)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
erval.encoded = computed_size + ret;
|
erval.encoded = computed_size + ret;
|
||||||
|
|
||||||
if (!cb) _ASN_ENCODED_OK(erval);
|
if (!cb)
|
||||||
|
{
|
||||||
|
_ASN_ENCODED_OK(erval);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Encode all members.
|
* Encode all members.
|
||||||
@ -651,7 +702,10 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
if (elm->flags & ATF_POINTER)
|
if (elm->flags & ATF_POINTER)
|
||||||
{
|
{
|
||||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||||
if (!memb_ptr) continue;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -659,17 +713,22 @@ asn_enc_rval_t SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
}
|
}
|
||||||
tmperval = elm->type->der_encoder(
|
tmperval = elm->type->der_encoder(
|
||||||
elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key);
|
elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key);
|
||||||
if (tmperval.encoded == -1) return tmperval;
|
if (tmperval.encoded == -1)
|
||||||
|
{
|
||||||
|
return tmperval;
|
||||||
|
}
|
||||||
computed_size -= tmperval.encoded;
|
computed_size -= tmperval.encoded;
|
||||||
ASN_DEBUG("Member %d %s of SEQUENCE %s encoded in %ld bytes", edx,
|
ASN_DEBUG("Member %d %s of SEQUENCE %s encoded in %ld bytes", edx,
|
||||||
elm->name, td->name, (long)tmperval.encoded);
|
elm->name, td->name, (long)tmperval.encoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (computed_size != 0)
|
if (computed_size != 0)
|
||||||
/*
|
{
|
||||||
|
/*
|
||||||
* Encoded size is not equal to the computed size.
|
* Encoded size is not equal to the computed size.
|
||||||
*/
|
*/
|
||||||
_ASN_ENCODE_FAILED;
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_ENCODED_OK(erval);
|
_ASN_ENCODED_OK(erval);
|
||||||
}
|
}
|
||||||
@ -717,7 +776,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (st == 0)
|
if (st == 0)
|
||||||
{
|
{
|
||||||
st = *struct_ptr = CALLOC(1, specs->struct_size);
|
st = *struct_ptr = CALLOC(1, specs->struct_size);
|
||||||
if (st == 0) RETURN(RC_FAIL);
|
if (st == 0)
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -769,7 +831,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
memb_ptr2, elm->name,
|
memb_ptr2, elm->name,
|
||||||
buf_ptr, size);
|
buf_ptr, size);
|
||||||
XER_ADVANCE(tmprval.consumed);
|
XER_ADVANCE(tmprval.consumed);
|
||||||
if (tmprval.code != RC_OK) RETURN(tmprval.code);
|
if (tmprval.code != RC_OK)
|
||||||
|
{
|
||||||
|
RETURN(tmprval.code);
|
||||||
|
}
|
||||||
ctx->phase = 1; /* Back to body processing */
|
ctx->phase = 1; /* Back to body processing */
|
||||||
ctx->step = ++edx;
|
ctx->step = ++edx;
|
||||||
ASN_DEBUG("XER/SEQUENCE phase => %d, step => %d",
|
ASN_DEBUG("XER/SEQUENCE phase => %d, step => %d",
|
||||||
@ -827,7 +892,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
switch (tcv)
|
switch (tcv)
|
||||||
{
|
{
|
||||||
case XCT_CLOSING:
|
case XCT_CLOSING:
|
||||||
if (ctx->phase == 0) break;
|
if (ctx->phase == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
ctx->phase = 0;
|
ctx->phase = 0;
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case XCT_BOTH:
|
case XCT_BOTH:
|
||||||
@ -879,7 +947,9 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
*/
|
*/
|
||||||
edx_end = edx + elements[edx].optional + 1;
|
edx_end = edx + elements[edx].optional + 1;
|
||||||
if (edx_end > td->elements_count)
|
if (edx_end > td->elements_count)
|
||||||
edx_end = td->elements_count;
|
{
|
||||||
|
edx_end = td->elements_count;
|
||||||
|
}
|
||||||
for (n = edx; n < edx_end; n++)
|
for (n = edx; n < edx_end; n++)
|
||||||
{
|
{
|
||||||
elm = &td->elements[n];
|
elm = &td->elements[n];
|
||||||
@ -904,7 +974,10 @@ asn_dec_rval_t SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (n != edx_end) continue;
|
if (n != edx_end)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -965,7 +1038,10 @@ asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
int xcan = (flags & XER_F_CANONICAL);
|
int xcan = (flags & XER_F_CANONICAL);
|
||||||
int edx;
|
int edx;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
er.encoded = 0;
|
er.encoded = 0;
|
||||||
|
|
||||||
@ -982,7 +1058,10 @@ asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||||
if (!memb_ptr)
|
if (!memb_ptr)
|
||||||
{
|
{
|
||||||
if (elm->optional) continue;
|
if (elm->optional)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
/* Mandatory element is missing */
|
/* Mandatory element is missing */
|
||||||
_ASN_ENCODE_FAILED;
|
_ASN_ENCODE_FAILED;
|
||||||
}
|
}
|
||||||
@ -992,19 +1071,28 @@ asn_enc_rval_t SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
memb_ptr = (void *)((char *)sptr + elm->memb_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
|
if (!xcan)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||||
|
}
|
||||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||||
|
|
||||||
/* Print the member itself */
|
/* Print the member itself */
|
||||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1,
|
tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1,
|
||||||
flags, cb, app_key);
|
flags, cb, app_key);
|
||||||
if (tmper.encoded == -1) return tmper;
|
if (tmper.encoded == -1)
|
||||||
|
{
|
||||||
|
return tmper;
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
_ASN_CALLBACK3("</", 2, mname, mlen, ">", 1);
|
||||||
er.encoded += 5 + (2 * mlen) + tmper.encoded;
|
er.encoded += 5 + (2 * mlen) + tmper.encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
if (!xcan)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
cb_failed:
|
cb_failed:
|
||||||
@ -1017,12 +1105,17 @@ int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
int edx;
|
int edx;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Dump preamble */
|
/* Dump preamble */
|
||||||
if (cb(td->name, strlen(td->name), app_key) < 0 ||
|
if (cb(td->name, strlen(td->name), app_key) < 0 ||
|
||||||
cb(" ::= {", 6, app_key) < 0)
|
cb(" ::= {", 6, app_key) < 0)
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (edx = 0; edx < td->elements_count; edx++)
|
for (edx = 0; edx < td->elements_count; edx++)
|
||||||
{
|
{
|
||||||
@ -1035,7 +1128,10 @@ int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
elm->memb_offset);
|
elm->memb_offset);
|
||||||
if (!memb_ptr)
|
if (!memb_ptr)
|
||||||
{
|
{
|
||||||
if (elm->optional) continue;
|
if (elm->optional)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
/* Print <absent> line */
|
/* Print <absent> line */
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
}
|
}
|
||||||
@ -1052,12 +1148,17 @@ int SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
/* Print the member's name and stuff */
|
/* Print the member's name and stuff */
|
||||||
if (cb(elm->name, strlen(elm->name), app_key) < 0 ||
|
if (cb(elm->name, strlen(elm->name), app_key) < 0 ||
|
||||||
cb(": ", 2, app_key) < 0)
|
cb(": ", 2, app_key) < 0)
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Print the member itself */
|
/* Print the member itself */
|
||||||
ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb,
|
ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb,
|
||||||
app_key);
|
app_key);
|
||||||
if (ret) return ret;
|
if (ret)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ilevel--;
|
ilevel--;
|
||||||
@ -1070,7 +1171,10 @@ void SEQUENCE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only)
|
|||||||
{
|
{
|
||||||
int edx;
|
int edx;
|
||||||
|
|
||||||
if (!td || !sptr) return;
|
if (!td || !sptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Freeing %s as SEQUENCE", td->name);
|
ASN_DEBUG("Freeing %s as SEQUENCE", td->name);
|
||||||
|
|
||||||
@ -1081,7 +1185,10 @@ void SEQUENCE_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only)
|
|||||||
if (elm->flags & ATF_POINTER)
|
if (elm->flags & ATF_POINTER)
|
||||||
{
|
{
|
||||||
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
memb_ptr = *(void **)((char *)sptr + elm->memb_offset);
|
||||||
if (memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
if (memb_ptr)
|
||||||
|
{
|
||||||
|
ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1122,7 +1229,10 @@ int SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
elm->memb_offset);
|
elm->memb_offset);
|
||||||
if (!memb_ptr)
|
if (!memb_ptr)
|
||||||
{
|
{
|
||||||
if (elm->optional) continue;
|
if (elm->optional)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
_ASN_CTFAIL(
|
_ASN_CTFAIL(
|
||||||
app_key, td, sptr,
|
app_key, td, sptr,
|
||||||
"%s: mandatory element %s absent (%s:%d)",
|
"%s: mandatory element %s absent (%s:%d)",
|
||||||
@ -1140,13 +1250,19 @@ int SEQUENCE_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
{
|
{
|
||||||
int ret = elm->memb_constraints(elm->type, memb_ptr,
|
int ret = elm->memb_constraints(elm->type, memb_ptr,
|
||||||
ctfailcb, app_key);
|
ctfailcb, app_key);
|
||||||
if (ret) return ret;
|
if (ret)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int ret = elm->type->check_constraints(elm->type, memb_ptr,
|
int ret = elm->type->check_constraints(elm->type, memb_ptr,
|
||||||
ctfailcb, app_key);
|
ctfailcb, app_key);
|
||||||
if (ret) return ret;
|
if (ret)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Cannot inherit it earlier:
|
* Cannot inherit it earlier:
|
||||||
* need to make sure we get the updated version.
|
* need to make sure we get the updated version.
|
||||||
@ -1173,12 +1289,18 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
|
|
||||||
(void)constraints;
|
(void)constraints;
|
||||||
|
|
||||||
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED;
|
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (!st)
|
if (!st)
|
||||||
{
|
{
|
||||||
st = *sptr = CALLOC(1, specs->struct_size);
|
st = *sptr = CALLOC(1, specs->struct_size);
|
||||||
if (!st) _ASN_DECODE_FAILED;
|
if (!st)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Decoding %s as SEQUENCE (UPER)", td->name);
|
ASN_DEBUG("Decoding %s as SEQUENCE (UPER)", td->name);
|
||||||
@ -1187,7 +1309,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (specs->ext_before >= 0)
|
if (specs->ext_before >= 0)
|
||||||
{
|
{
|
||||||
extpresent = per_get_few_bits(pd, 1);
|
extpresent = per_get_few_bits(pd, 1);
|
||||||
if (extpresent < 0) _ASN_DECODE_STARVED;
|
if (extpresent < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1199,7 +1324,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (specs->roms_count)
|
if (specs->roms_count)
|
||||||
{
|
{
|
||||||
opres = (uint8_t *)MALLOC(((specs->roms_count + 7) >> 3) + 1);
|
opres = (uint8_t *)MALLOC(((specs->roms_count + 7) >> 3) + 1);
|
||||||
if (!opres) _ASN_DECODE_FAILED;
|
if (!opres)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
/* Get the presence map */
|
/* Get the presence map */
|
||||||
if (per_get_many_bits(pd, opres, 0, specs->roms_count))
|
if (per_get_many_bits(pd, opres, 0, specs->roms_count))
|
||||||
{
|
{
|
||||||
@ -1225,7 +1353,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
void *memb_ptr; /* Pointer to the member */
|
void *memb_ptr; /* Pointer to the member */
|
||||||
void **memb_ptr2; /* Pointer to that pointer */
|
void **memb_ptr2; /* Pointer to that pointer */
|
||||||
|
|
||||||
if (IN_EXTENSION_GROUP(specs, edx)) continue;
|
if (IN_EXTENSION_GROUP(specs, edx))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Fetch the pointer to this member */
|
/* Fetch the pointer to this member */
|
||||||
if (elm->flags & ATF_POINTER)
|
if (elm->flags & ATF_POINTER)
|
||||||
@ -1289,12 +1420,18 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
asn_per_data_t epmd;
|
asn_per_data_t epmd;
|
||||||
|
|
||||||
bmlength = uper_get_nslength(pd);
|
bmlength = uper_get_nslength(pd);
|
||||||
if (bmlength < 0) _ASN_DECODE_STARVED;
|
if (bmlength < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Extensions %d present in %s", bmlength, td->name);
|
ASN_DEBUG("Extensions %d present in %s", bmlength, td->name);
|
||||||
|
|
||||||
epres = (uint8_t *)MALLOC((bmlength + 15) >> 3);
|
epres = (uint8_t *)MALLOC((bmlength + 15) >> 3);
|
||||||
if (!epres) _ASN_DECODE_STARVED;
|
if (!epres)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the extensions map */
|
/* Get the extensions map */
|
||||||
if (per_get_many_bits(pd, epres, 0, bmlength))
|
if (per_get_many_bits(pd, epres, 0, bmlength))
|
||||||
@ -1338,7 +1475,10 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
present = per_get_few_bits(&epmd, 1);
|
present = per_get_few_bits(&epmd, 1);
|
||||||
if (present <= 0)
|
if (present <= 0)
|
||||||
{
|
{
|
||||||
if (present < 0) break; /* No more extensions */
|
if (present < 0)
|
||||||
|
{
|
||||||
|
break; /* No more extensions */
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1385,13 +1525,19 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
asn_TYPE_member_t *elm = &td->elements[edx];
|
asn_TYPE_member_t *elm = &td->elements[edx];
|
||||||
void **memb_ptr2; /* Pointer to member pointer */
|
void **memb_ptr2; /* Pointer to member pointer */
|
||||||
|
|
||||||
if (!elm->default_value) continue;
|
if (!elm->default_value)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Fetch the pointer to this member */
|
/* Fetch the pointer to this member */
|
||||||
if (elm->flags & ATF_POINTER)
|
if (elm->flags & ATF_POINTER)
|
||||||
{
|
{
|
||||||
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
|
memb_ptr2 = (void **)((char *)st + elm->memb_offset);
|
||||||
if (*memb_ptr2) continue;
|
if (*memb_ptr2)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1418,7 +1564,10 @@ static int SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
int exts_count = 0;
|
int exts_count = 0;
|
||||||
int edx;
|
int edx;
|
||||||
|
|
||||||
if (specs->ext_before < 0) return 0;
|
if (specs->ext_before < 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Find out which extensions are present */
|
/* Find out which extensions are present */
|
||||||
for (edx = specs->ext_after + 1; edx < td->elements_count; edx++)
|
for (edx = specs->ext_after + 1; edx < td->elements_count; edx++)
|
||||||
@ -1454,12 +1603,17 @@ static int SEQUENCE_handle_extensions(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
exts_present += present;
|
exts_present += present;
|
||||||
|
|
||||||
/* Encode as presence marker */
|
/* Encode as presence marker */
|
||||||
if (po1 && per_put_few_bits(po1, present, 1)) return -1;
|
if (po1 && per_put_few_bits(po1, present, 1))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
/* Encode as open type field */
|
/* Encode as open type field */
|
||||||
if (po2 && present &&
|
if (po2 && present &&
|
||||||
uper_open_type_put(elm->type, elm->per_constraints, *memb_ptr2,
|
uper_open_type_put(elm->type, elm->per_constraints, *memb_ptr2,
|
||||||
po2))
|
po2))
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return exts_present ? exts_count : 0;
|
return exts_present ? exts_count : 0;
|
||||||
@ -1477,7 +1631,10 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
|
|
||||||
(void)constraints;
|
(void)constraints;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
er.encoded = 0;
|
er.encoded = 0;
|
||||||
|
|
||||||
@ -1524,13 +1681,18 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
/* Eliminate default values */
|
/* Eliminate default values */
|
||||||
if (present && elm->default_value &&
|
if (present && elm->default_value &&
|
||||||
elm->default_value(0, memb_ptr2) == 1)
|
elm->default_value(0, memb_ptr2) == 1)
|
||||||
present = 0;
|
{
|
||||||
|
present = 0;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Element %s %s %s->%s is %s",
|
ASN_DEBUG("Element %s %s %s->%s is %s",
|
||||||
elm->flags & ATF_POINTER ? "ptr" : "inline",
|
elm->flags & ATF_POINTER ? "ptr" : "inline",
|
||||||
elm->default_value ? "def" : "wtv", td->name, elm->name,
|
elm->default_value ? "def" : "wtv", td->name, elm->name,
|
||||||
present ? "present" : "absent");
|
present ? "present" : "absent");
|
||||||
if (per_put_few_bits(po, present, 1)) _ASN_ENCODE_FAILED;
|
if (per_put_few_bits(po, present, 1))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1546,7 +1708,10 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
void *memb_ptr; /* Pointer to the member */
|
void *memb_ptr; /* Pointer to the member */
|
||||||
void **memb_ptr2; /* Pointer to that pointer */
|
void **memb_ptr2; /* Pointer to that pointer */
|
||||||
|
|
||||||
if (IN_EXTENSION_GROUP(specs, edx)) continue;
|
if (IN_EXTENSION_GROUP(specs, edx))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("About to encode %s", elm->type->name);
|
ASN_DEBUG("About to encode %s", elm->type->name);
|
||||||
|
|
||||||
@ -1558,7 +1723,10 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
{
|
{
|
||||||
ASN_DEBUG("Element %s %d not present", elm->name,
|
ASN_DEBUG("Element %s %d not present", elm->name,
|
||||||
edx);
|
edx);
|
||||||
if (elm->optional) continue;
|
if (elm->optional)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
/* Mandatory element is missing */
|
/* Mandatory element is missing */
|
||||||
_ASN_ENCODE_FAILED;
|
_ASN_ENCODE_FAILED;
|
||||||
}
|
}
|
||||||
@ -1571,31 +1739,46 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
|
|
||||||
/* Eliminate default values */
|
/* Eliminate default values */
|
||||||
if (elm->default_value && elm->default_value(0, memb_ptr2) == 1)
|
if (elm->default_value && elm->default_value(0, memb_ptr2) == 1)
|
||||||
continue;
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Encoding %s->%s", td->name, elm->name);
|
ASN_DEBUG("Encoding %s->%s", td->name, elm->name);
|
||||||
er = elm->type->uper_encoder(elm->type, elm->per_constraints,
|
er = elm->type->uper_encoder(elm->type, elm->per_constraints,
|
||||||
*memb_ptr2, po);
|
*memb_ptr2, po);
|
||||||
if (er.encoded == -1) return er;
|
if (er.encoded == -1)
|
||||||
|
{
|
||||||
|
return er;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No extensions to encode */
|
/* No extensions to encode */
|
||||||
if (!n_extensions) _ASN_ENCODED_OK(er);
|
if (!n_extensions)
|
||||||
|
{
|
||||||
|
_ASN_ENCODED_OK(er);
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Length of %d bit-map", n_extensions);
|
ASN_DEBUG("Length of %d bit-map", n_extensions);
|
||||||
/* #18.8. Write down the presence bit-map length. */
|
/* #18.8. Write down the presence bit-map length. */
|
||||||
if (uper_put_nslength(po, n_extensions)) _ASN_ENCODE_FAILED;
|
if (uper_put_nslength(po, n_extensions))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Bit-map of %d elements", n_extensions);
|
ASN_DEBUG("Bit-map of %d elements", n_extensions);
|
||||||
/* #18.7. Encoding the extensions presence bit-map. */
|
/* #18.7. Encoding the extensions presence bit-map. */
|
||||||
/* TODO: act upon NOTE in #18.7 for canonical PER */
|
/* TODO: act upon NOTE in #18.7 for canonical PER */
|
||||||
if (SEQUENCE_handle_extensions(td, sptr, po, 0) != n_extensions)
|
if (SEQUENCE_handle_extensions(td, sptr, po, 0) != n_extensions)
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Writing %d extensions", n_extensions);
|
ASN_DEBUG("Writing %d extensions", n_extensions);
|
||||||
/* #18.9. Encode extensions as open type fields. */
|
/* #18.9. Encode extensions as open type fields. */
|
||||||
if (SEQUENCE_handle_extensions(td, sptr, 0, po) != n_extensions)
|
if (SEQUENCE_handle_extensions(td, sptr, 0, po) != n_extensions)
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,16 @@ asn_enc_rval_t SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
for (edx = 0; edx < list->count; edx++)
|
for (edx = 0; edx < list->count; edx++)
|
||||||
{
|
{
|
||||||
void *memb_ptr = list->array[edx];
|
void *memb_ptr = list->array[edx];
|
||||||
if (!memb_ptr) continue;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
erval =
|
erval =
|
||||||
elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, 0, 0);
|
elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, 0, 0);
|
||||||
if (erval.encoded == -1) return erval;
|
if (erval.encoded == -1)
|
||||||
|
{
|
||||||
|
return erval;
|
||||||
|
}
|
||||||
computed_size += erval.encoded;
|
computed_size += erval.encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +71,16 @@ asn_enc_rval_t SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
for (edx = 0; edx < list->count; edx++)
|
for (edx = 0; edx < list->count; edx++)
|
||||||
{
|
{
|
||||||
void *memb_ptr = list->array[edx];
|
void *memb_ptr = list->array[edx];
|
||||||
if (!memb_ptr) continue;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
erval = elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, cb,
|
erval = elm->type->der_encoder(elm->type, memb_ptr, 0, elm->tag, cb,
|
||||||
app_key);
|
app_key);
|
||||||
if (erval.encoded == -1) return erval;
|
if (erval.encoded == -1)
|
||||||
|
{
|
||||||
|
return erval;
|
||||||
|
}
|
||||||
encoding_size += erval.encoded;
|
encoding_size += erval.encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +120,10 @@ asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
int xcan = (flags & XER_F_CANONICAL);
|
int xcan = (flags & XER_F_CANONICAL);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
er.encoded = 0;
|
er.encoded = 0;
|
||||||
|
|
||||||
@ -116,22 +131,34 @@ asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
{
|
{
|
||||||
asn_enc_rval_t tmper;
|
asn_enc_rval_t tmper;
|
||||||
void *memb_ptr = list->array[i];
|
void *memb_ptr = list->array[i];
|
||||||
if (!memb_ptr) continue;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (mname)
|
if (mname)
|
||||||
{
|
{
|
||||||
if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
|
if (!xcan)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||||
|
}
|
||||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1,
|
tmper = elm->type->xer_encoder(elm->type, memb_ptr, ilevel + 1,
|
||||||
flags, cb, app_key);
|
flags, cb, app_key);
|
||||||
if (tmper.encoded == -1) return tmper;
|
if (tmper.encoded == -1)
|
||||||
|
{
|
||||||
|
return tmper;
|
||||||
|
}
|
||||||
if (tmper.encoded == 0 && specs->as_XMLValueList)
|
if (tmper.encoded == 0 && specs->as_XMLValueList)
|
||||||
{
|
{
|
||||||
const char *name = elm->type->xml_tag;
|
const char *name = elm->type->xml_tag;
|
||||||
size_t len = strlen(name);
|
size_t len = strlen(name);
|
||||||
if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel + 1);
|
if (!xcan)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel + 1);
|
||||||
|
}
|
||||||
_ASN_CALLBACK3("<", 1, name, len, "/>", 2);
|
_ASN_CALLBACK3("<", 1, name, len, "/>", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +171,10 @@ asn_enc_rval_t SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
er.encoded += (2 * mlen) + tmper.encoded;
|
er.encoded += (2 * mlen) + tmper.encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
if (!xcan)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||||
|
}
|
||||||
|
|
||||||
_ASN_ENCODED_OK(er);
|
_ASN_ENCODED_OK(er);
|
||||||
cb_failed:
|
cb_failed:
|
||||||
@ -161,7 +191,10 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
asn_TYPE_member_t *elm = td->elements;
|
asn_TYPE_member_t *elm = td->elements;
|
||||||
int seq;
|
int seq;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
list = _A_SEQUENCE_FROM_VOID(sptr);
|
list = _A_SEQUENCE_FROM_VOID(sptr);
|
||||||
|
|
||||||
er.encoded = 0;
|
er.encoded = 0;
|
||||||
@ -169,11 +202,17 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
ASN_DEBUG("Encoding %s as SEQUENCE OF (%d)", td->name, list->count);
|
ASN_DEBUG("Encoding %s as SEQUENCE OF (%d)", td->name, list->count);
|
||||||
|
|
||||||
if (constraints)
|
if (constraints)
|
||||||
ct = &constraints->size;
|
{
|
||||||
|
ct = &constraints->size;
|
||||||
|
}
|
||||||
else if (td->per_constraints)
|
else if (td->per_constraints)
|
||||||
ct = &td->per_constraints->size;
|
{
|
||||||
|
ct = &td->per_constraints->size;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ct = 0;
|
{
|
||||||
|
ct = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* If extensible constraint, check if size is in root */
|
/* If extensible constraint, check if size is in root */
|
||||||
if (ct)
|
if (ct)
|
||||||
@ -186,11 +225,18 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
{
|
{
|
||||||
/* Declare whether size is in extension root */
|
/* Declare whether size is in extension root */
|
||||||
if (per_put_few_bits(po, not_in_root, 1))
|
if (per_put_few_bits(po, not_in_root, 1))
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
if (not_in_root) ct = 0;
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
if (not_in_root)
|
||||||
|
{
|
||||||
|
ct = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (not_in_root && ct->effective_bits >= 0)
|
else if (not_in_root && ct->effective_bits >= 0)
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ct && ct->effective_bits >= 0)
|
if (ct && ct->effective_bits >= 0)
|
||||||
@ -198,13 +244,18 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
/* X.691, #19.5: No length determinant */
|
/* X.691, #19.5: No length determinant */
|
||||||
if (per_put_few_bits(po, list->count - ct->lower_bound,
|
if (per_put_few_bits(po, list->count - ct->lower_bound,
|
||||||
ct->effective_bits))
|
ct->effective_bits))
|
||||||
_ASN_ENCODE_FAILED;
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (seq = -1; seq < list->count;)
|
for (seq = -1; seq < list->count;)
|
||||||
{
|
{
|
||||||
ssize_t mayEncode;
|
ssize_t mayEncode;
|
||||||
if (seq < 0) seq = 0;
|
if (seq < 0)
|
||||||
|
{
|
||||||
|
seq = 0;
|
||||||
|
}
|
||||||
if (ct && ct->effective_bits >= 0)
|
if (ct && ct->effective_bits >= 0)
|
||||||
{
|
{
|
||||||
mayEncode = list->count;
|
mayEncode = list->count;
|
||||||
@ -212,16 +263,25 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mayEncode = uper_put_length(po, list->count - seq);
|
mayEncode = uper_put_length(po, list->count - seq);
|
||||||
if (mayEncode < 0) _ASN_ENCODE_FAILED;
|
if (mayEncode < 0)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (mayEncode--)
|
while (mayEncode--)
|
||||||
{
|
{
|
||||||
void *memb_ptr = list->array[seq++];
|
void *memb_ptr = list->array[seq++];
|
||||||
if (!memb_ptr) _ASN_ENCODE_FAILED;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
er = elm->type->uper_encoder(
|
er = elm->type->uper_encoder(
|
||||||
elm->type, elm->per_constraints, memb_ptr, po);
|
elm->type, elm->per_constraints, memb_ptr, po);
|
||||||
if (er.encoded == -1) _ASN_ENCODE_FAILED;
|
if (er.encoded == -1)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,9 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->left >= 0)
|
if (ctx->left >= 0)
|
||||||
ctx->left += rval.consumed; /* ?Subtracted below! */
|
{
|
||||||
|
ctx->left += rval.consumed; /* ?Subtracted below! */
|
||||||
|
}
|
||||||
ADVANCE(rval.consumed);
|
ADVANCE(rval.consumed);
|
||||||
|
|
||||||
ASN_DEBUG(
|
ASN_DEBUG(
|
||||||
@ -160,7 +162,10 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
{
|
{
|
||||||
ssize_t tag_len; /* Length of TLV's T */
|
ssize_t tag_len; /* Length of TLV's T */
|
||||||
|
|
||||||
if (ctx->step & 1) goto microphase2;
|
if (ctx->step & 1)
|
||||||
|
{
|
||||||
|
goto microphase2;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MICROPHASE 1: Synchronize decoding.
|
* MICROPHASE 1: Synchronize decoding.
|
||||||
@ -184,7 +189,10 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
switch (tag_len)
|
switch (tag_len)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if (!SIZE_VIOLATION) RETURN(RC_WMORE);
|
if (!SIZE_VIOLATION)
|
||||||
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case -1:
|
case -1:
|
||||||
RETURN(RC_FAIL);
|
RETURN(RC_FAIL);
|
||||||
@ -195,9 +203,13 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (LEFT < 2)
|
if (LEFT < 2)
|
||||||
{
|
{
|
||||||
if (SIZE_VIOLATION)
|
if (SIZE_VIOLATION)
|
||||||
RETURN(RC_FAIL);
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RETURN(RC_WMORE);
|
{
|
||||||
|
RETURN(RC_WMORE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (((const uint8_t *)ptr)[1] == 0)
|
else if (((const uint8_t *)ptr)[1] == 0)
|
||||||
{
|
{
|
||||||
@ -255,9 +267,13 @@ asn_dec_rval_t SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
asn_anonymous_set_ *list =
|
asn_anonymous_set_ *list =
|
||||||
_A_SET_FROM_VOID(st);
|
_A_SET_FROM_VOID(st);
|
||||||
if (ASN_SET_ADD(list, ctx->ptr) != 0)
|
if (ASN_SET_ADD(list, ctx->ptr) != 0)
|
||||||
RETURN(RC_FAIL);
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ctx->ptr = 0;
|
{
|
||||||
|
ctx->ptr = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RC_WMORE: /* More data expected */
|
case RC_WMORE: /* More data expected */
|
||||||
@ -327,7 +343,10 @@ static int _el_addbytes(const void *buffer, size_t size, void *el_buf_ptr)
|
|||||||
{
|
{
|
||||||
struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr;
|
struct _el_buffer *el_buf = (struct _el_buffer *)el_buf_ptr;
|
||||||
|
|
||||||
if (el_buf->length + size > el_buf->size) return -1;
|
if (el_buf->length + size > el_buf->size)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(el_buf->buf + el_buf->length, buffer, size);
|
memcpy(el_buf->buf + el_buf->length, buffer, size);
|
||||||
|
|
||||||
@ -342,17 +361,25 @@ static int _el_buf_cmp(const void *ap, const void *bp)
|
|||||||
size_t common_len;
|
size_t common_len;
|
||||||
|
|
||||||
if (a->length < b->length)
|
if (a->length < b->length)
|
||||||
common_len = a->length;
|
{
|
||||||
|
common_len = a->length;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
common_len = b->length;
|
{
|
||||||
|
common_len = b->length;
|
||||||
|
}
|
||||||
|
|
||||||
ret = memcmp(a->buf, b->buf, common_len);
|
ret = memcmp(a->buf, b->buf, common_len);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
if (a->length < b->length)
|
if (a->length < b->length)
|
||||||
ret = -1;
|
{
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
else if (a->length > b->length)
|
else if (a->length > b->length)
|
||||||
ret = 1;
|
{
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -386,14 +413,22 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
for (edx = 0; edx < list->count; edx++)
|
for (edx = 0; edx < list->count; edx++)
|
||||||
{
|
{
|
||||||
void *memb_ptr = list->array[edx];
|
void *memb_ptr = list->array[edx];
|
||||||
if (!memb_ptr) continue;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
|
erval = der_encoder(elm_type, memb_ptr, 0, elm->tag, 0, 0);
|
||||||
if (erval.encoded == -1) return erval;
|
if (erval.encoded == -1)
|
||||||
|
{
|
||||||
|
return erval;
|
||||||
|
}
|
||||||
computed_size += erval.encoded;
|
computed_size += erval.encoded;
|
||||||
|
|
||||||
/* Compute maximum encoding's size */
|
/* Compute maximum encoding's size */
|
||||||
if (max_encoded_len < (size_t)erval.encoded)
|
if (max_encoded_len < (size_t)erval.encoded)
|
||||||
max_encoded_len = erval.encoded;
|
{
|
||||||
|
max_encoded_len = erval.encoded;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -441,7 +476,10 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
void *memb_ptr = list->array[edx];
|
void *memb_ptr = list->array[edx];
|
||||||
struct _el_buffer *encoded_el = &encoded_els[eels_count];
|
struct _el_buffer *encoded_el = &encoded_els[eels_count];
|
||||||
|
|
||||||
if (!memb_ptr) continue;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare space for encoding.
|
* Prepare space for encoding.
|
||||||
@ -454,7 +492,10 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (edx--; edx >= 0; edx--) FREEMEM(encoded_els[edx].buf);
|
for (edx--; edx >= 0; edx--)
|
||||||
|
{
|
||||||
|
FREEMEM(encoded_els[edx].buf);
|
||||||
|
}
|
||||||
FREEMEM(encoded_els);
|
FREEMEM(encoded_els);
|
||||||
erval.encoded = -1;
|
erval.encoded = -1;
|
||||||
erval.failed_type = td;
|
erval.failed_type = td;
|
||||||
@ -469,7 +510,10 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
encoded_el);
|
encoded_el);
|
||||||
if (erval.encoded == -1)
|
if (erval.encoded == -1)
|
||||||
{
|
{
|
||||||
for (; edx >= 0; edx--) FREEMEM(encoded_els[edx].buf);
|
for (; edx >= 0; edx--)
|
||||||
|
{
|
||||||
|
FREEMEM(encoded_els[edx].buf);
|
||||||
|
}
|
||||||
FREEMEM(encoded_els);
|
FREEMEM(encoded_els);
|
||||||
return erval;
|
return erval;
|
||||||
}
|
}
|
||||||
@ -493,7 +537,9 @@ asn_enc_rval_t SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
|
|||||||
/* Report encoded chunks to the application */
|
/* Report encoded chunks to the application */
|
||||||
if (ret == 0 &&
|
if (ret == 0 &&
|
||||||
cb(encoded_el->buf, encoded_el->length, app_key) < 0)
|
cb(encoded_el->buf, encoded_el->length, app_key) < 0)
|
||||||
ret = -1;
|
{
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
FREEMEM(encoded_el->buf);
|
FREEMEM(encoded_el->buf);
|
||||||
}
|
}
|
||||||
FREEMEM(encoded_els);
|
FREEMEM(encoded_els);
|
||||||
@ -558,7 +604,10 @@ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (st == 0)
|
if (st == 0)
|
||||||
{
|
{
|
||||||
st = *struct_ptr = CALLOC(1, specs->struct_size);
|
st = *struct_ptr = CALLOC(1, specs->struct_size);
|
||||||
if (st == 0) RETURN(RC_FAIL);
|
if (st == 0)
|
||||||
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Which tag is expected for the downstream */
|
/* Which tag is expected for the downstream */
|
||||||
@ -604,7 +653,9 @@ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
{
|
{
|
||||||
asn_anonymous_set_ *list = _A_SET_FROM_VOID(st);
|
asn_anonymous_set_ *list = _A_SET_FROM_VOID(st);
|
||||||
if (ASN_SET_ADD(list, ctx->ptr) != 0)
|
if (ASN_SET_ADD(list, ctx->ptr) != 0)
|
||||||
RETURN(RC_FAIL);
|
{
|
||||||
|
RETURN(RC_FAIL);
|
||||||
|
}
|
||||||
ctx->ptr = 0;
|
ctx->ptr = 0;
|
||||||
XER_ADVANCE(tmprval.consumed);
|
XER_ADVANCE(tmprval.consumed);
|
||||||
}
|
}
|
||||||
@ -646,7 +697,10 @@ asn_dec_rval_t SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
switch (tcv)
|
switch (tcv)
|
||||||
{
|
{
|
||||||
case XCT_CLOSING:
|
case XCT_CLOSING:
|
||||||
if (ctx->phase == 0) break;
|
if (ctx->phase == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
ctx->phase = 0;
|
ctx->phase = 0;
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case XCT_BOTH:
|
case XCT_BOTH:
|
||||||
@ -705,7 +759,10 @@ static int SET_OF_encode_xer_callback(const void *buffer, size_t size,
|
|||||||
{
|
{
|
||||||
size_t newsize = (t->size << 2) + size;
|
size_t newsize = (t->size << 2) + size;
|
||||||
void *p = REALLOC(t->buffer, newsize);
|
void *p = REALLOC(t->buffer, newsize);
|
||||||
if (!p) return -1;
|
if (!p)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
t->buffer = p;
|
t->buffer = p;
|
||||||
t->size = newsize;
|
t->size = newsize;
|
||||||
}
|
}
|
||||||
@ -719,12 +776,24 @@ static int SET_OF_xer_order(const void *aptr, const void *bptr)
|
|||||||
const xer_tmp_enc_t *b = (const xer_tmp_enc_t *)bptr;
|
const xer_tmp_enc_t *b = (const xer_tmp_enc_t *)bptr;
|
||||||
size_t minlen = a->offset;
|
size_t minlen = a->offset;
|
||||||
int ret;
|
int ret;
|
||||||
if (b->offset < minlen) minlen = b->offset;
|
if (b->offset < minlen)
|
||||||
|
{
|
||||||
|
minlen = b->offset;
|
||||||
|
}
|
||||||
/* Well-formed UTF-8 has this nice lexicographical property... */
|
/* Well-formed UTF-8 has this nice lexicographical property... */
|
||||||
ret = memcmp(a->buffer, b->buffer, minlen);
|
ret = memcmp(a->buffer, b->buffer, minlen);
|
||||||
if (ret != 0) return ret;
|
if (ret != 0)
|
||||||
if (a->offset == b->offset) return 0;
|
{
|
||||||
if (a->offset == minlen) return -1;
|
return ret;
|
||||||
|
}
|
||||||
|
if (a->offset == b->offset)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (a->offset == minlen)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -747,12 +816,18 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
asn_app_consume_bytes_f *original_cb = cb;
|
asn_app_consume_bytes_f *original_cb = cb;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!sptr) _ASN_ENCODE_FAILED;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
if (xcan)
|
if (xcan)
|
||||||
{
|
{
|
||||||
encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0]));
|
encs = (xer_tmp_enc_t *)MALLOC(list->count * sizeof(encs[0]));
|
||||||
if (!encs) _ASN_ENCODE_FAILED;
|
if (!encs)
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
cb = SET_OF_encode_xer_callback;
|
cb = SET_OF_encode_xer_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,7 +838,10 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
asn_enc_rval_t tmper;
|
asn_enc_rval_t tmper;
|
||||||
|
|
||||||
void *memb_ptr = list->array[i];
|
void *memb_ptr = list->array[i];
|
||||||
if (!memb_ptr) continue;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (encs)
|
if (encs)
|
||||||
{
|
{
|
||||||
@ -774,12 +852,17 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
|
|
||||||
if (mname)
|
if (mname)
|
||||||
{
|
{
|
||||||
if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel);
|
if (!xcan)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel);
|
||||||
|
}
|
||||||
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
_ASN_CALLBACK3("<", 1, mname, mlen, ">", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xcan && specs->as_XMLValueList == 1)
|
if (!xcan && specs->as_XMLValueList == 1)
|
||||||
_i_ASN_TEXT_INDENT(1, ilevel + 1);
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel + 1);
|
||||||
|
}
|
||||||
tmper = elm->type->xer_encoder(
|
tmper = elm->type->xer_encoder(
|
||||||
elm->type, memb_ptr, ilevel + (specs->as_XMLValueList != 2),
|
elm->type, memb_ptr, ilevel + (specs->as_XMLValueList != 2),
|
||||||
flags, cb, app_key);
|
flags, cb, app_key);
|
||||||
@ -805,7 +888,10 @@ asn_enc_rval_t SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
er.encoded += (2 * mlen) + tmper.encoded;
|
er.encoded += (2 * mlen) + tmper.encoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xcan) _i_ASN_TEXT_INDENT(1, ilevel - 1);
|
if (!xcan)
|
||||||
|
{
|
||||||
|
_i_ASN_TEXT_INDENT(1, ilevel - 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (encs)
|
if (encs)
|
||||||
{
|
{
|
||||||
@ -838,7 +924,9 @@ cleanup:
|
|||||||
while (encs_count-- > 0)
|
while (encs_count-- > 0)
|
||||||
{
|
{
|
||||||
if (encs[encs_count].buffer)
|
if (encs[encs_count].buffer)
|
||||||
FREEMEM(encs[encs_count].buffer);
|
{
|
||||||
|
FREEMEM(encs[encs_count].buffer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
FREEMEM(encs);
|
FREEMEM(encs);
|
||||||
}
|
}
|
||||||
@ -853,23 +941,34 @@ int SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel,
|
|||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!sptr) return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
if (!sptr)
|
||||||
|
{
|
||||||
|
return (cb("<absent>", 8, app_key) < 0) ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Dump preamble */
|
/* Dump preamble */
|
||||||
if (cb(td->name, strlen(td->name), app_key) < 0 ||
|
if (cb(td->name, strlen(td->name), app_key) < 0 ||
|
||||||
cb(" ::= {", 6, app_key) < 0)
|
cb(" ::= {", 6, app_key) < 0)
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < list->count; i++)
|
for (i = 0; i < list->count; i++)
|
||||||
{
|
{
|
||||||
const void *memb_ptr = list->array[i];
|
const void *memb_ptr = list->array[i];
|
||||||
if (!memb_ptr) continue;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
_i_INDENT(1);
|
_i_INDENT(1);
|
||||||
|
|
||||||
ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb,
|
ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, cb,
|
||||||
app_key);
|
app_key);
|
||||||
if (ret) return ret;
|
if (ret)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ilevel--;
|
ilevel--;
|
||||||
@ -895,7 +994,10 @@ void SET_OF_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only)
|
|||||||
for (i = 0; i < list->count; i++)
|
for (i = 0; i < list->count; i++)
|
||||||
{
|
{
|
||||||
void *memb_ptr = list->array[i];
|
void *memb_ptr = list->array[i];
|
||||||
if (memb_ptr) ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
if (memb_ptr)
|
||||||
|
{
|
||||||
|
ASN_STRUCT_FREE(*elm->type, memb_ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
list->count = 0; /* No meaningful elements left */
|
list->count = 0; /* No meaningful elements left */
|
||||||
|
|
||||||
@ -932,7 +1034,10 @@ int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
constr = elm->memb_constraints;
|
constr = elm->memb_constraints;
|
||||||
if (!constr) constr = elm->type->check_constraints;
|
if (!constr)
|
||||||
|
{
|
||||||
|
constr = elm->type->check_constraints;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iterate over the members of an array.
|
* Iterate over the members of an array.
|
||||||
@ -943,10 +1048,16 @@ int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
const void *memb_ptr = list->array[i];
|
const void *memb_ptr = list->array[i];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!memb_ptr) continue;
|
if (!memb_ptr)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ret = constr(elm->type, memb_ptr, ctfailcb, app_key);
|
ret = constr(elm->type, memb_ptr, ctfailcb, app_key);
|
||||||
if (ret) return ret;
|
if (ret)
|
||||||
|
{
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -954,7 +1065,9 @@ int SET_OF_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
|
|||||||
* need to make sure we get the updated version.
|
* need to make sure we get the updated version.
|
||||||
*/
|
*/
|
||||||
if (!elm->memb_constraints)
|
if (!elm->memb_constraints)
|
||||||
elm->memb_constraints = elm->type->check_constraints;
|
{
|
||||||
|
elm->memb_constraints = elm->type->check_constraints;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -973,7 +1086,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
int repeat = 0;
|
int repeat = 0;
|
||||||
ssize_t nelems;
|
ssize_t nelems;
|
||||||
|
|
||||||
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx)) _ASN_DECODE_FAILED;
|
if (_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create the target structure if it is not present already.
|
* Create the target structure if it is not present already.
|
||||||
@ -981,23 +1097,38 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
if (!st)
|
if (!st)
|
||||||
{
|
{
|
||||||
st = *sptr = CALLOC(1, specs->struct_size);
|
st = *sptr = CALLOC(1, specs->struct_size);
|
||||||
if (!st) _ASN_DECODE_FAILED;
|
if (!st)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
list = _A_SET_FROM_VOID(st);
|
list = _A_SET_FROM_VOID(st);
|
||||||
|
|
||||||
/* Figure out which constraints to use */
|
/* Figure out which constraints to use */
|
||||||
if (constraints)
|
if (constraints)
|
||||||
ct = &constraints->size;
|
{
|
||||||
|
ct = &constraints->size;
|
||||||
|
}
|
||||||
else if (td->per_constraints)
|
else if (td->per_constraints)
|
||||||
ct = &td->per_constraints->size;
|
{
|
||||||
|
ct = &td->per_constraints->size;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ct = 0;
|
{
|
||||||
|
ct = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (ct && ct->flags & APC_EXTENSIBLE)
|
if (ct && ct->flags & APC_EXTENSIBLE)
|
||||||
{
|
{
|
||||||
int value = per_get_few_bits(pd, 1);
|
int value = per_get_few_bits(pd, 1);
|
||||||
if (value < 0) _ASN_DECODE_STARVED;
|
if (value < 0)
|
||||||
if (value) ct = 0; /* Not restricted! */
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
ct = 0; /* Not restricted! */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ct && ct->effective_bits >= 0)
|
if (ct && ct->effective_bits >= 0)
|
||||||
@ -1006,7 +1137,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
nelems = per_get_few_bits(pd, ct->effective_bits);
|
nelems = per_get_few_bits(pd, ct->effective_bits);
|
||||||
ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s",
|
ASN_DEBUG("Preparing to fetch %ld+%ld elements from %s",
|
||||||
(long)nelems, ct->lower_bound, td->name);
|
(long)nelems, ct->lower_bound, td->name);
|
||||||
if (nelems < 0) _ASN_DECODE_STARVED;
|
if (nelems < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
nelems += ct->lower_bound;
|
nelems += ct->lower_bound;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1022,7 +1156,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
&repeat);
|
&repeat);
|
||||||
ASN_DEBUG("Got to decode %d elements (eff %d)", (int)nelems,
|
ASN_DEBUG("Got to decode %d elements (eff %d)", (int)nelems,
|
||||||
(long)ct ? ct->effective_bits : -1);
|
(long)ct ? ct->effective_bits : -1);
|
||||||
if (nelems < 0) _ASN_DECODE_STARVED;
|
if (nelems < 0)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_STARVED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ssize_t k = 0; k < nelems; k++)
|
for (ssize_t k = 0; k < nelems; k++)
|
||||||
@ -1036,7 +1173,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
elm->type->name, rv.code, ptr);
|
elm->type->name, rv.code, ptr);
|
||||||
if (rv.code == RC_OK)
|
if (rv.code == RC_OK)
|
||||||
{
|
{
|
||||||
if (ASN_SET_ADD(list, ptr) == 0) continue;
|
if (ASN_SET_ADD(list, ptr) == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
ASN_DEBUG("Failed to add element into %s",
|
ASN_DEBUG("Failed to add element into %s",
|
||||||
td->name);
|
td->name);
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
@ -1047,7 +1187,10 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
ASN_DEBUG("Failed decoding %s of %s (SET OF)",
|
ASN_DEBUG("Failed decoding %s of %s (SET OF)",
|
||||||
elm->type->name, td->name);
|
elm->type->name, td->name);
|
||||||
}
|
}
|
||||||
if (ptr) ASN_STRUCT_FREE(*elm->type, ptr);
|
if (ptr)
|
||||||
|
{
|
||||||
|
ASN_STRUCT_FREE(*elm->type, ptr);
|
||||||
|
}
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +20,15 @@ ber_tlv_tag_t asn_TYPE_outmost_tag(asn_TYPE_descriptor_t *type_descriptor,
|
|||||||
const void *struct_ptr, int tag_mode,
|
const void *struct_ptr, int tag_mode,
|
||||||
ber_tlv_tag_t tag)
|
ber_tlv_tag_t tag)
|
||||||
{
|
{
|
||||||
if (tag_mode) return tag;
|
if (tag_mode)
|
||||||
|
{
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
if (type_descriptor->tags_count) return type_descriptor->tags[0];
|
if (type_descriptor->tags_count)
|
||||||
|
{
|
||||||
|
return type_descriptor->tags[0];
|
||||||
|
}
|
||||||
|
|
||||||
return type_descriptor->outmost_tag(type_descriptor, struct_ptr, 0, 0);
|
return type_descriptor->outmost_tag(type_descriptor, struct_ptr, 0, 0);
|
||||||
}
|
}
|
||||||
@ -32,7 +38,10 @@ ber_tlv_tag_t asn_TYPE_outmost_tag(asn_TYPE_descriptor_t *type_descriptor,
|
|||||||
*/
|
*/
|
||||||
int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr)
|
int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr)
|
||||||
{
|
{
|
||||||
if (!stream) stream = stdout;
|
if (!stream)
|
||||||
|
{
|
||||||
|
stream = stdout;
|
||||||
|
}
|
||||||
if (!td || !struct_ptr)
|
if (!td || !struct_ptr)
|
||||||
{
|
{
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
@ -40,10 +49,16 @@ int asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Invoke type-specific printer */
|
/* Invoke type-specific printer */
|
||||||
if (td->print_struct(td, struct_ptr, 1, _print2fp, stream)) return -1;
|
if (td->print_struct(td, struct_ptr, 1, _print2fp, stream))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Terminate the output */
|
/* Terminate the output */
|
||||||
if (_print2fp("\n", 1, stream)) return -1;
|
if (_print2fp("\n", 1, stream))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return fflush(stream);
|
return fflush(stream);
|
||||||
}
|
}
|
||||||
@ -53,7 +68,10 @@ static int _print2fp(const void *buffer, size_t size, void *app_key)
|
|||||||
{
|
{
|
||||||
FILE *stream = (FILE *)app_key;
|
FILE *stream = (FILE *)app_key;
|
||||||
|
|
||||||
if (fwrite(buffer, 1, size, stream) != size) return -1;
|
if (fwrite(buffer, 1, size, stream) != size)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,10 @@ static void _asn_i_ctfailcb(void *key, asn_TYPE_descriptor_t *td,
|
|||||||
arg->failed_struct_ptr = sptr;
|
arg->failed_struct_ptr = sptr;
|
||||||
|
|
||||||
maxlen = arg->errlen;
|
maxlen = arg->errlen;
|
||||||
if (maxlen <= 0) return;
|
if (maxlen <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vlen = vsnprintf(arg->errbuf, maxlen, fmt, ap);
|
vlen = vsnprintf(arg->errbuf, maxlen, fmt, ap);
|
||||||
@ -91,7 +94,10 @@ int asn_check_constraints(asn_TYPE_descriptor_t *type_descriptor,
|
|||||||
|
|
||||||
ret = type_descriptor->check_constraints(type_descriptor, struct_ptr,
|
ret = type_descriptor->check_constraints(type_descriptor, struct_ptr,
|
||||||
_asn_i_ctfailcb, &arg);
|
_asn_i_ctfailcb, &arg);
|
||||||
if (ret == -1 && errlen) *errlen = arg.errlen;
|
if (ret == -1 && errlen)
|
||||||
|
{
|
||||||
|
*errlen = arg.errlen;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,10 @@ static void junk_bytes_with_probability(uint8_t *, size_t, double prob);
|
|||||||
static inline void DEBUG(const char *fmt, ...)
|
static inline void DEBUG(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
if (!opt_debug) return;
|
if (!opt_debug)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
fprintf(stderr, "AD: ");
|
fprintf(stderr, "AD: ");
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
@ -92,210 +95,222 @@ int main(int ac, char *av[])
|
|||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
/* Figure out if Unaligned PER needs to be default */
|
/* Figure out if Unaligned PER needs to be default */
|
||||||
if (pduType->uper_decoder) iform = INP_PER;
|
if (pduType->uper_decoder)
|
||||||
|
{
|
||||||
|
iform = INP_PER;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process the command-line arguments.
|
* Process the command-line arguments.
|
||||||
*/
|
*/
|
||||||
while ((ch = getopt(ac, av, "i:o:1b:cdn:p:hs:" JUNKOPT)) != -1) switch (ch)
|
while ((ch = getopt(ac, av, "i:o:1b:cdn:p:hs:" JUNKOPT)) != -1)
|
||||||
{
|
{
|
||||||
case 'i':
|
switch (ch)
|
||||||
if (optarg[0] == 'b')
|
{
|
||||||
{
|
case 'i':
|
||||||
iform = INP_BER;
|
if (optarg[0] == 'b')
|
||||||
break;
|
{
|
||||||
}
|
iform = INP_BER;
|
||||||
if (optarg[0] == 'x')
|
break;
|
||||||
{
|
}
|
||||||
iform = INP_XER;
|
if (optarg[0] == 'x')
|
||||||
break;
|
{
|
||||||
}
|
iform = INP_XER;
|
||||||
if (pduType->uper_decoder && optarg[0] == 'p')
|
break;
|
||||||
{
|
}
|
||||||
iform = INP_PER;
|
if (pduType->uper_decoder && optarg[0] == 'p')
|
||||||
break;
|
{
|
||||||
}
|
iform = INP_PER;
|
||||||
fprintf(stderr,
|
break;
|
||||||
"-i<format>: '%s': improper format selector\n",
|
}
|
||||||
optarg);
|
fprintf(stderr,
|
||||||
exit(EX_UNAVAILABLE);
|
"-i<format>: '%s': improper format selector\n",
|
||||||
case 'o':
|
optarg);
|
||||||
if (optarg[0] == 'd')
|
exit(EX_UNAVAILABLE);
|
||||||
{
|
case 'o':
|
||||||
oform = OUT_DER;
|
if (optarg[0] == 'd')
|
||||||
break;
|
{
|
||||||
}
|
oform = OUT_DER;
|
||||||
if (pduType->uper_encoder && optarg[0] == 'p')
|
break;
|
||||||
{
|
}
|
||||||
oform = OUT_PER;
|
if (pduType->uper_encoder && optarg[0] == 'p')
|
||||||
break;
|
{
|
||||||
}
|
oform = OUT_PER;
|
||||||
if (optarg[0] == 'x')
|
break;
|
||||||
{
|
}
|
||||||
oform = OUT_XER;
|
if (optarg[0] == 'x')
|
||||||
break;
|
{
|
||||||
}
|
oform = OUT_XER;
|
||||||
if (optarg[0] == 't')
|
break;
|
||||||
{
|
}
|
||||||
oform = OUT_TEXT;
|
if (optarg[0] == 't')
|
||||||
break;
|
{
|
||||||
}
|
oform = OUT_TEXT;
|
||||||
if (optarg[0] == 'n')
|
break;
|
||||||
{
|
}
|
||||||
oform = OUT_NULL;
|
if (optarg[0] == 'n')
|
||||||
break;
|
{
|
||||||
}
|
oform = OUT_NULL;
|
||||||
fprintf(stderr,
|
break;
|
||||||
"-o<format>: '%s': improper format selector\n",
|
}
|
||||||
optarg);
|
fprintf(stderr,
|
||||||
exit(EX_UNAVAILABLE);
|
"-o<format>: '%s': improper format selector\n",
|
||||||
case '1':
|
optarg);
|
||||||
opt_onepdu = 1;
|
exit(EX_UNAVAILABLE);
|
||||||
break;
|
case '1':
|
||||||
case 'b':
|
opt_onepdu = 1;
|
||||||
suggested_bufsize = atoi(optarg);
|
break;
|
||||||
if (suggested_bufsize < 1 ||
|
case 'b':
|
||||||
suggested_bufsize > 16 * 1024 * 1024)
|
suggested_bufsize = atoi(optarg);
|
||||||
{
|
if (suggested_bufsize < 1 ||
|
||||||
fprintf(stderr,
|
suggested_bufsize > 16 * 1024 * 1024)
|
||||||
"-b %s: Improper buffer size (1..16M)\n",
|
{
|
||||||
optarg);
|
fprintf(stderr,
|
||||||
exit(EX_UNAVAILABLE);
|
"-b %s: Improper buffer size (1..16M)\n",
|
||||||
}
|
optarg);
|
||||||
break;
|
exit(EX_UNAVAILABLE);
|
||||||
case 'c':
|
}
|
||||||
opt_check = 1;
|
break;
|
||||||
break;
|
case 'c':
|
||||||
case 'd':
|
opt_check = 1;
|
||||||
opt_debug++; /* Double -dd means ASN.1 debug */
|
break;
|
||||||
break;
|
case 'd':
|
||||||
case 'n':
|
opt_debug++; /* Double -dd means ASN.1 debug */
|
||||||
number_of_iterations = atoi(optarg);
|
break;
|
||||||
if (number_of_iterations < 1)
|
case 'n':
|
||||||
{
|
number_of_iterations = atoi(optarg);
|
||||||
fprintf(stderr,
|
if (number_of_iterations < 1)
|
||||||
"-n %s: Improper iterations count\n",
|
{
|
||||||
optarg);
|
fprintf(stderr,
|
||||||
exit(EX_UNAVAILABLE);
|
"-n %s: Improper iterations count\n",
|
||||||
}
|
optarg);
|
||||||
break;
|
exit(EX_UNAVAILABLE);
|
||||||
case 'p':
|
}
|
||||||
if (strcmp(optarg, "er-nopad") == 0)
|
break;
|
||||||
{
|
case 'p':
|
||||||
opt_nopad = 1;
|
if (strcmp(optarg, "er-nopad") == 0)
|
||||||
break;
|
{
|
||||||
}
|
opt_nopad = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
#ifdef ASN_PDU_COLLECTION
|
#ifdef ASN_PDU_COLLECTION
|
||||||
if (strcmp(optarg, "list") == 0)
|
if (strcmp(optarg, "list") == 0)
|
||||||
{
|
{
|
||||||
asn_TYPE_descriptor_t **pdu = asn_pdu_collection;
|
asn_TYPE_descriptor_t **pdu = asn_pdu_collection;
|
||||||
fprintf(stderr, "Available PDU types:\n");
|
fprintf(stderr, "Available PDU types:\n");
|
||||||
for (; *pdu; pdu++) printf("%s\n", (*pdu)->name);
|
for (; *pdu; pdu++) printf("%s\n", (*pdu)->name);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (optarg[0] >= 'A' && optarg[0] <= 'Z')
|
else if (optarg[0] >= 'A' && optarg[0] <= 'Z')
|
||||||
{
|
{
|
||||||
asn_TYPE_descriptor_t **pdu = asn_pdu_collection;
|
asn_TYPE_descriptor_t **pdu = asn_pdu_collection;
|
||||||
while (*pdu && strcmp((*pdu)->name, optarg)) pdu++;
|
while (*pdu && strcmp((*pdu)->name, optarg)) pdu++;
|
||||||
if (*pdu)
|
if (*pdu)
|
||||||
{
|
{
|
||||||
pduType = *pdu;
|
pduType = *pdu;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "-p %s: Unrecognized PDU\n",
|
fprintf(stderr, "-p %s: Unrecognized PDU\n",
|
||||||
optarg);
|
optarg);
|
||||||
}
|
}
|
||||||
#endif /* ASN_PDU_COLLECTION */
|
#endif /* ASN_PDU_COLLECTION */
|
||||||
fprintf(stderr, "-p %s: Unrecognized option\n", optarg);
|
fprintf(stderr, "-p %s: Unrecognized option\n", optarg);
|
||||||
exit(EX_UNAVAILABLE);
|
exit(EX_UNAVAILABLE);
|
||||||
case 's':
|
case 's':
|
||||||
opt_stack = atoi(optarg);
|
opt_stack = atoi(optarg);
|
||||||
if (opt_stack < 0)
|
if (opt_stack < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"-s %s: Non-negative value expected\n",
|
"-s %s: Non-negative value expected\n",
|
||||||
optarg);
|
optarg);
|
||||||
exit(EX_UNAVAILABLE);
|
exit(EX_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef JUNKTEST
|
#ifdef JUNKTEST
|
||||||
case 'J':
|
case 'J':
|
||||||
opt_jprob = strtod(optarg, 0);
|
opt_jprob = strtod(optarg, 0);
|
||||||
if (opt_jprob <= 0.0 || opt_jprob > 1.0)
|
if (opt_jprob <= 0.0 || opt_jprob > 1.0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"-J %s: Probability range 0..1 expected \n",
|
"-J %s: Probability range 0..1 expected \n",
|
||||||
optarg);
|
optarg);
|
||||||
exit(EX_UNAVAILABLE);
|
exit(EX_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* JUNKTEST */
|
#endif /* JUNKTEST */
|
||||||
case 'h':
|
case 'h':
|
||||||
default:
|
default:
|
||||||
#ifdef ASN_CONVERTER_TITLE
|
#ifdef ASN_CONVERTER_TITLE
|
||||||
#define _AXS(x) #x
|
#define _AXS(x) #x
|
||||||
#define _ASX(x) _AXS(x)
|
#define _ASX(x) _AXS(x)
|
||||||
fprintf(stderr, "%s\n", _ASX(ASN_CONVERTER_TITLE));
|
fprintf(stderr, "%s\n", _ASX(ASN_CONVERTER_TITLE));
|
||||||
#endif
|
#endif
|
||||||
fprintf(stderr, "Usage: %s [options] <data.ber> ...\n",
|
fprintf(stderr, "Usage: %s [options] <data.ber> ...\n",
|
||||||
av[0]);
|
av[0]);
|
||||||
fprintf(stderr, "Where options are:\n");
|
fprintf(stderr, "Where options are:\n");
|
||||||
if (pduType->uper_decoder)
|
if (pduType->uper_decoder)
|
||||||
fprintf(
|
{
|
||||||
stderr,
|
fprintf(
|
||||||
" -iper Input is in Unaligned PER (Packed "
|
stderr,
|
||||||
"Encoding Rules) (DEFAULT)\n");
|
" -iper Input is in Unaligned PER (Packed "
|
||||||
fprintf(stderr,
|
"Encoding Rules) (DEFAULT)\n");
|
||||||
" -iber Input is in BER (Basic Encoding "
|
}
|
||||||
"Rules)%s\n",
|
|
||||||
iform == INP_PER ? "" : " (DEFAULT)");
|
|
||||||
fprintf(stderr,
|
|
||||||
" -ixer Input is in XER (XML Encoding "
|
|
||||||
"Rules)\n");
|
|
||||||
if (pduType->uper_encoder)
|
|
||||||
fprintf(
|
|
||||||
stderr,
|
|
||||||
" -oper Output in Unaligned PER (Packed "
|
|
||||||
"Encoding "
|
|
||||||
"Rules)\n");
|
|
||||||
fprintf(
|
|
||||||
stderr,
|
|
||||||
" -oder Output in DER (Distinguished Encoding "
|
|
||||||
"Rules)\n"
|
|
||||||
" -oxer Output in XER (XML Encoding Rules) "
|
|
||||||
"(DEFAULT)\n"
|
|
||||||
" -otext Output in plain semi-structured text "
|
|
||||||
"(dump)\n"
|
|
||||||
" -onull Verify (decode) input, but do not "
|
|
||||||
"output\n");
|
|
||||||
if (pduType->uper_decoder)
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" -per-nopad Assume PER PDUs are not padded "
|
" -iber Input is in BER (Basic Encoding "
|
||||||
"(-iper)\n");
|
"Rules)%s\n",
|
||||||
|
iform == INP_PER ? "" : " (DEFAULT)");
|
||||||
|
fprintf(stderr,
|
||||||
|
" -ixer Input is in XER (XML Encoding "
|
||||||
|
"Rules)\n");
|
||||||
|
if (pduType->uper_encoder)
|
||||||
|
{
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
" -oper Output in Unaligned PER (Packed "
|
||||||
|
"Encoding "
|
||||||
|
"Rules)\n");
|
||||||
|
}
|
||||||
|
fprintf(
|
||||||
|
stderr,
|
||||||
|
" -oder Output in DER (Distinguished Encoding "
|
||||||
|
"Rules)\n"
|
||||||
|
" -oxer Output in XER (XML Encoding Rules) "
|
||||||
|
"(DEFAULT)\n"
|
||||||
|
" -otext Output in plain semi-structured text "
|
||||||
|
"(dump)\n"
|
||||||
|
" -onull Verify (decode) input, but do not "
|
||||||
|
"output\n");
|
||||||
|
if (pduType->uper_decoder)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
" -per-nopad Assume PER PDUs are not padded "
|
||||||
|
"(-iper)\n");
|
||||||
|
}
|
||||||
#ifdef ASN_PDU_COLLECTION
|
#ifdef ASN_PDU_COLLECTION
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" -p <PDU> Specify PDU type to decode\n"
|
" -p <PDU> Specify PDU type to decode\n"
|
||||||
" -p list List available PDUs\n");
|
" -p list List available PDUs\n");
|
||||||
#endif /* ASN_PDU_COLLECTION */
|
#endif /* ASN_PDU_COLLECTION */
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr,
|
stderr,
|
||||||
" -1 Decode only the first PDU in file\n"
|
" -1 Decode only the first PDU in file\n"
|
||||||
" -b <size> Set the i/o buffer size (default is "
|
" -b <size> Set the i/o buffer size (default is "
|
||||||
"%ld)\n"
|
"%ld)\n"
|
||||||
" -c Check ASN.1 constraints after "
|
" -c Check ASN.1 constraints after "
|
||||||
"decoding\n"
|
"decoding\n"
|
||||||
" -d Enable debugging (-dd is even better)\n"
|
" -d Enable debugging (-dd is even better)\n"
|
||||||
" -n <num> Process files <num> times\n"
|
" -n <num> Process files <num> times\n"
|
||||||
" -s <size> Set the stack usage limit (default is "
|
" -s <size> Set the stack usage limit (default is "
|
||||||
"%d)\n"
|
"%d)\n"
|
||||||
#ifdef JUNKTEST
|
#ifdef JUNKTEST
|
||||||
" -J <prob> Set random junk test bit garbaging "
|
" -J <prob> Set random junk test bit garbaging "
|
||||||
"probability\n"
|
"probability\n"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
(long)suggested_bufsize, _ASN_DEFAULT_STACK_MAX);
|
(long)suggested_bufsize, _ASN_DEFAULT_STACK_MAX);
|
||||||
exit(EX_USAGE);
|
exit(EX_USAGE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ac -= optind;
|
ac -= optind;
|
||||||
av += optind;
|
av += optind;
|
||||||
@ -423,7 +438,10 @@ int main(int ac, char *av[])
|
|||||||
ASN_STRUCT_FREE(*pduType, structure);
|
ASN_STRUCT_FREE(*pduType, structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file && file != stdin) fclose(file);
|
if (file && file != stdin)
|
||||||
|
{
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,7 +471,10 @@ static void buffer_dump()
|
|||||||
{
|
{
|
||||||
uint8_t *p = DynamicBuffer.data + DynamicBuffer.offset;
|
uint8_t *p = DynamicBuffer.data + DynamicBuffer.offset;
|
||||||
uint8_t *e = p + DynamicBuffer.length - (DynamicBuffer.unbits ? 1 : 0);
|
uint8_t *e = p + DynamicBuffer.length - (DynamicBuffer.unbits ? 1 : 0);
|
||||||
if (!opt_debug) return;
|
if (!opt_debug)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
DEBUG("Buffer: { d=%p, o=%ld, l=%ld, u=%ld, a=%ld, s=%ld }",
|
DEBUG("Buffer: { d=%p, o=%ld, l=%ld, u=%ld, a=%ld, s=%ld }",
|
||||||
DynamicBuffer.data, (long)DynamicBuffer.offset,
|
DynamicBuffer.data, (long)DynamicBuffer.offset,
|
||||||
(long)DynamicBuffer.length, (long)DynamicBuffer.unbits,
|
(long)DynamicBuffer.length, (long)DynamicBuffer.unbits,
|
||||||
@ -471,7 +492,9 @@ static void buffer_dump()
|
|||||||
unsigned int shift;
|
unsigned int shift;
|
||||||
fprintf(stderr, " ");
|
fprintf(stderr, " ");
|
||||||
for (shift = 7; shift >= DynamicBuffer.unbits; shift--)
|
for (shift = 7; shift >= DynamicBuffer.unbits; shift--)
|
||||||
fprintf(stderr, "%c", ((*p >> shift) & 1) ? '1' : '0');
|
{
|
||||||
|
fprintf(stderr, "%c", ((*p >> shift) & 1) ? '1' : '0');
|
||||||
|
}
|
||||||
fprintf(stderr, " %ld:%ld\n", (long)DynamicBuffer.length - 1,
|
fprintf(stderr, " %ld:%ld\n", (long)DynamicBuffer.length - 1,
|
||||||
(long)8 - DynamicBuffer.unbits);
|
(long)8 - DynamicBuffer.unbits);
|
||||||
}
|
}
|
||||||
@ -491,7 +514,10 @@ static void buffer_shift_left(size_t offset, int bits)
|
|||||||
uint8_t *end =
|
uint8_t *end =
|
||||||
DynamicBuffer.data + DynamicBuffer.offset + DynamicBuffer.length - 1;
|
DynamicBuffer.data + DynamicBuffer.offset + DynamicBuffer.length - 1;
|
||||||
|
|
||||||
if (!bits) return;
|
if (!bits)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG("Shifting left %d bits off %ld (o=%ld, u=%ld, l=%ld)", bits,
|
DEBUG("Shifting left %d bits off %ld (o=%ld, u=%ld, l=%ld)", bits,
|
||||||
(long)offset, (long)DynamicBuffer.offset, (long)DynamicBuffer.unbits,
|
(long)offset, (long)DynamicBuffer.offset, (long)DynamicBuffer.unbits,
|
||||||
@ -576,7 +602,10 @@ static void buffer_shift_left(size_t offset, int bits)
|
|||||||
*/
|
*/
|
||||||
static void add_bytes_to_buffer(const void *data2add, size_t bytes)
|
static void add_bytes_to_buffer(const void *data2add, size_t bytes)
|
||||||
{
|
{
|
||||||
if (bytes == 0) return;
|
if (bytes == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG("=> add_bytes(%ld) { o=%ld l=%ld u=%ld, s=%ld }", (long)bytes,
|
DEBUG("=> add_bytes(%ld) { o=%ld l=%ld u=%ld, s=%ld }", (long)bytes,
|
||||||
(long)DynamicBuffer.offset, (long)DynamicBuffer.length,
|
(long)DynamicBuffer.offset, (long)DynamicBuffer.length,
|
||||||
@ -733,13 +762,17 @@ static void *data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file,
|
|||||||
break;
|
break;
|
||||||
case INP_PER:
|
case INP_PER:
|
||||||
if (opt_nopad)
|
if (opt_nopad)
|
||||||
rval = uper_decode(opt_codec_ctx, pduType,
|
{
|
||||||
&structure, i_bptr, i_size, 0,
|
rval = uper_decode(opt_codec_ctx, pduType,
|
||||||
DynamicBuffer.unbits);
|
&structure, i_bptr, i_size, 0,
|
||||||
|
DynamicBuffer.unbits);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
rval = uper_decode_complete(opt_codec_ctx, pduType,
|
{
|
||||||
&structure, i_bptr,
|
rval = uper_decode_complete(opt_codec_ctx, pduType,
|
||||||
i_size);
|
&structure, i_bptr,
|
||||||
|
i_size);
|
||||||
|
}
|
||||||
switch (rval.code)
|
switch (rval.code)
|
||||||
{
|
{
|
||||||
case RC_OK:
|
case RC_OK:
|
||||||
@ -800,7 +833,10 @@ static void *data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file,
|
|||||||
switch (rval.code)
|
switch (rval.code)
|
||||||
{
|
{
|
||||||
case RC_OK:
|
case RC_OK:
|
||||||
if (ecbits) buffer_shift_left(0, ecbits);
|
if (ecbits)
|
||||||
|
{
|
||||||
|
buffer_shift_left(0, ecbits);
|
||||||
|
}
|
||||||
DEBUG("RC_OK, finishing up with %ld+%d",
|
DEBUG("RC_OK, finishing up with %ld+%d",
|
||||||
(long)rval.consumed, ecbits);
|
(long)rval.consumed, ecbits);
|
||||||
return structure;
|
return structure;
|
||||||
@ -813,7 +849,10 @@ static void *data_decode_from_file(asn_TYPE_descriptor_t *pduType, FILE *file,
|
|||||||
(long)DynamicBuffer.length,
|
(long)DynamicBuffer.length,
|
||||||
(long)DynamicBuffer.unbits,
|
(long)DynamicBuffer.unbits,
|
||||||
(long)DynamicBuffer.allocated);
|
(long)DynamicBuffer.allocated);
|
||||||
if (!rd) tolerate_eof--;
|
if (!rd)
|
||||||
|
{
|
||||||
|
tolerate_eof--;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
case RC_FAIL:
|
case RC_FAIL:
|
||||||
break;
|
break;
|
||||||
@ -889,9 +928,13 @@ static int argument_is_stdin(char *av[], int idx)
|
|||||||
{
|
{
|
||||||
/* This might be <stdin>, unless `./program -- -` */
|
/* This might be <stdin>, unless `./program -- -` */
|
||||||
if (strcmp(av[-1], "--") != 0)
|
if (strcmp(av[-1], "--") != 0)
|
||||||
return 1;
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,9 @@ static int encode_to_buffer_cb(const void *buffer, size_t size, void *key)
|
|||||||
enc_to_buf_arg *arg = (enc_to_buf_arg *)key;
|
enc_to_buf_arg *arg = (enc_to_buf_arg *)key;
|
||||||
|
|
||||||
if (arg->left < size)
|
if (arg->left < size)
|
||||||
return -1; /* Data exceeds the available buffer size */
|
{
|
||||||
|
return -1; /* Data exceeds the available buffer size */
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(arg->buffer, buffer, size);
|
memcpy(arg->buffer, buffer, size);
|
||||||
arg->buffer = ((char *)arg->buffer) + size;
|
arg->buffer = ((char *)arg->buffer) + size;
|
||||||
@ -114,7 +116,9 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length,
|
|||||||
tags[0] = tag;
|
tags[0] = tag;
|
||||||
stag_offset = -1 + ((tag_mode == -1) && sd->tags_count);
|
stag_offset = -1 + ((tag_mode == -1) && sd->tags_count);
|
||||||
for (i = 1; i < tags_count; i++)
|
for (i = 1; i < tags_count; i++)
|
||||||
tags[i] = sd->tags[i + stag_offset];
|
{
|
||||||
|
tags[i] = sd->tags[i + stag_offset];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -123,7 +127,10 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* No tags to write */
|
/* No tags to write */
|
||||||
if (tags_count == 0) return 0;
|
if (tags_count == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
lens = (ssize_t *)alloca(tags_count * sizeof(lens[0]));
|
lens = (ssize_t *)alloca(tags_count * sizeof(lens[0]));
|
||||||
if (!lens)
|
if (!lens)
|
||||||
@ -140,12 +147,18 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length,
|
|||||||
for (i = tags_count - 1; i >= 0; --i)
|
for (i = tags_count - 1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
lens[i] = der_write_TL(tags[i], overall_length, 0, 0, 0);
|
lens[i] = der_write_TL(tags[i], overall_length, 0, 0, 0);
|
||||||
if (lens[i] == -1) return -1;
|
if (lens[i] == -1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
overall_length += lens[i];
|
overall_length += lens[i];
|
||||||
lens[i] = overall_length - lens[i];
|
lens[i] = overall_length - lens[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cb) return overall_length - struct_length;
|
if (!cb)
|
||||||
|
{
|
||||||
|
return overall_length - struct_length;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("%s %s TL sequence (%d elements)", cb ? "Encoding" : "Estimating",
|
ASN_DEBUG("%s %s TL sequence (%d elements)", cb ? "Encoding" : "Estimating",
|
||||||
sd->name, tags_count);
|
sd->name, tags_count);
|
||||||
@ -162,7 +175,10 @@ ssize_t der_write_tags(asn_TYPE_descriptor_t *sd, size_t struct_length,
|
|||||||
_constr = (last_tag_form || i < (tags_count - 1));
|
_constr = (last_tag_form || i < (tags_count - 1));
|
||||||
|
|
||||||
len = der_write_TL(tags[i], lens[i], cb, app_key, _constr);
|
len = der_write_TL(tags[i], lens[i], cb, app_key, _constr);
|
||||||
if (len == -1) return -1;
|
if (len == -1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return overall_length - struct_length;
|
return overall_length - struct_length;
|
||||||
@ -179,24 +195,39 @@ static ssize_t der_write_TL(ber_tlv_tag_t tag, ber_tlv_len_t len,
|
|||||||
|
|
||||||
/* Serialize tag (T from TLV) into possibly zero-length buffer */
|
/* Serialize tag (T from TLV) into possibly zero-length buffer */
|
||||||
tmp = ber_tlv_tag_serialize(tag, buf, buf_size);
|
tmp = ber_tlv_tag_serialize(tag, buf, buf_size);
|
||||||
if (tmp == -1 || tmp > (ssize_t)sizeof(buf)) return -1;
|
if (tmp == -1 || tmp > (ssize_t)sizeof(buf))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
size += tmp;
|
size += tmp;
|
||||||
|
|
||||||
/* Serialize length (L from TLV) into possibly zero-length buffer */
|
/* Serialize length (L from TLV) into possibly zero-length buffer */
|
||||||
tmp = der_tlv_length_serialize(len, buf + size,
|
tmp = der_tlv_length_serialize(len, buf + size,
|
||||||
buf_size ? buf_size - size : 0);
|
buf_size ? buf_size - size : 0);
|
||||||
if (tmp == -1) return -1;
|
if (tmp == -1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
size += tmp;
|
size += tmp;
|
||||||
|
|
||||||
if (size > sizeof(buf)) return -1;
|
if (size > sizeof(buf))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If callback is specified, invoke it, and check its return value.
|
* If callback is specified, invoke it, and check its return value.
|
||||||
*/
|
*/
|
||||||
if (cb)
|
if (cb)
|
||||||
{
|
{
|
||||||
if (constructed) *buf |= 0x20;
|
if (constructed)
|
||||||
if (cb(buf, size, app_key) < 0) return -1;
|
{
|
||||||
|
*buf |= 0x20;
|
||||||
|
}
|
||||||
|
if (cb(buf, size, app_key) < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -58,7 +58,9 @@ asn_dec_rval_t uper_decode(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
|
|
||||||
if (skip_bits < 0 || skip_bits > 7 || unused_bits < 0 || unused_bits > 7 ||
|
if (skip_bits < 0 || skip_bits > 7 || unused_bits < 0 || unused_bits > 7 ||
|
||||||
(unused_bits > 0 && !size))
|
(unused_bits > 0 && !size))
|
||||||
_ASN_DECODE_FAILED;
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stack checker requires that the codec context
|
* Stack checker requires that the codec context
|
||||||
@ -85,12 +87,18 @@ asn_dec_rval_t uper_decode(asn_codec_ctx_t *opt_codec_ctx,
|
|||||||
pd.buffer = (const uint8_t *)buffer;
|
pd.buffer = (const uint8_t *)buffer;
|
||||||
pd.nboff = skip_bits;
|
pd.nboff = skip_bits;
|
||||||
pd.nbits = 8 * size - unused_bits; /* 8 is CHAR_BIT from <limits.h> */
|
pd.nbits = 8 * size - unused_bits; /* 8 is CHAR_BIT from <limits.h> */
|
||||||
if (pd.nboff > pd.nbits) _ASN_DECODE_FAILED;
|
if (pd.nboff > pd.nbits)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Invoke type-specific decoder.
|
* Invoke type-specific decoder.
|
||||||
*/
|
*/
|
||||||
if (!td->uper_decoder) _ASN_DECODE_FAILED; /* PER is not compiled in */
|
if (!td->uper_decoder)
|
||||||
|
{
|
||||||
|
_ASN_DECODE_FAILED; /* PER is not compiled in */
|
||||||
|
}
|
||||||
rval = td->uper_decoder(opt_codec_ctx, td, 0, sptr, &pd);
|
rval = td->uper_decoder(opt_codec_ctx, td, 0, sptr, &pd);
|
||||||
if (rval.code == RC_OK)
|
if (rval.code == RC_OK)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,9 @@ static int encode_to_buffer_cb(const void *buffer, size_t size, void *key)
|
|||||||
enc_to_buf_arg *arg = (enc_to_buf_arg *)key;
|
enc_to_buf_arg *arg = (enc_to_buf_arg *)key;
|
||||||
|
|
||||||
if (arg->left < size)
|
if (arg->left < size)
|
||||||
return -1; /* Data exceeds the available buffer size */
|
{
|
||||||
|
return -1; /* Data exceeds the available buffer size */
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(arg->buffer, buffer, size);
|
memcpy(arg->buffer, buffer, size);
|
||||||
arg->buffer = ((char *)arg->buffer) + size;
|
arg->buffer = ((char *)arg->buffer) + size;
|
||||||
@ -42,7 +44,10 @@ asn_enc_rval_t uper_encode_to_buffer(asn_TYPE_descriptor_t *td, void *sptr,
|
|||||||
key.buffer = buffer;
|
key.buffer = buffer;
|
||||||
key.left = buffer_size;
|
key.left = buffer_size;
|
||||||
|
|
||||||
if (td) ASN_DEBUG("Encoding \"%s\" using UNALIGNED PER", td->name);
|
if (td)
|
||||||
|
{
|
||||||
|
ASN_DEBUG("Encoding \"%s\" using UNALIGNED PER", td->name);
|
||||||
|
}
|
||||||
|
|
||||||
return uper_encode_internal(td, 0, sptr, encode_to_buffer_cb, &key);
|
return uper_encode_internal(td, 0, sptr, encode_to_buffer_cb, &key);
|
||||||
}
|
}
|
||||||
@ -117,7 +122,10 @@ static int _uper_encode_flush_outp(asn_per_outp_t *po)
|
|||||||
{
|
{
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
if (po->nboff == 0 && po->buffer == po->tmpspace) return 0;
|
if (po->nboff == 0 && po->buffer == po->tmpspace)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
buf = po->buffer + (po->nboff >> 3);
|
buf = po->buffer + (po->nboff >> 3);
|
||||||
/* Make sure we account for the last, partially filled */
|
/* Make sure we account for the last, partially filled */
|
||||||
@ -143,7 +151,9 @@ static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td,
|
|||||||
* Invoke type-specific encoder.
|
* Invoke type-specific encoder.
|
||||||
*/
|
*/
|
||||||
if (!td || !td->uper_encoder)
|
if (!td || !td->uper_encoder)
|
||||||
_ASN_ENCODE_FAILED; /* PER is not compiled in */
|
{
|
||||||
|
_ASN_ENCODE_FAILED; /* PER is not compiled in */
|
||||||
|
}
|
||||||
|
|
||||||
po.buffer = po.tmpspace;
|
po.buffer = po.tmpspace;
|
||||||
po.nboff = 0;
|
po.nboff = 0;
|
||||||
@ -162,7 +172,10 @@ static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td,
|
|||||||
/* Set number of bits encoded to a firm value */
|
/* Set number of bits encoded to a firm value */
|
||||||
er.encoded = (po.flushed_bytes << 3) + bits_to_flush;
|
er.encoded = (po.flushed_bytes << 3) + bits_to_flush;
|
||||||
|
|
||||||
if (_uper_encode_flush_outp(&po)) _ASN_ENCODE_FAILED;
|
if (_uper_encode_flush_outp(&po))
|
||||||
|
{
|
||||||
|
_ASN_ENCODE_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return er;
|
return er;
|
||||||
|
@ -40,19 +40,31 @@ int uper_open_type_put(asn_TYPE_descriptor_t *td,
|
|||||||
ASN_DEBUG("Open type put %s ...", td->name);
|
ASN_DEBUG("Open type put %s ...", td->name);
|
||||||
|
|
||||||
size = uper_encode_to_new_buffer(td, constraints, sptr, &buf);
|
size = uper_encode_to_new_buffer(td, constraints, sptr, &buf);
|
||||||
if (size <= 0) return -1;
|
if (size <= 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (bptr = buf, toGo = size; toGo;)
|
for (bptr = buf, toGo = size; toGo;)
|
||||||
{
|
{
|
||||||
ssize_t maySave = uper_put_length(po, toGo);
|
ssize_t maySave = uper_put_length(po, toGo);
|
||||||
if (maySave < 0) break;
|
if (maySave < 0)
|
||||||
if (per_put_many_bits(po, bptr, maySave * 8)) break;
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (per_put_many_bits(po, bptr, maySave * 8))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
bptr = (char *)bptr + maySave;
|
bptr = (char *)bptr + maySave;
|
||||||
toGo -= maySave;
|
toGo -= maySave;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREEMEM(buf);
|
FREEMEM(buf);
|
||||||
if (toGo) return -1;
|
if (toGo)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", td->name,
|
ASN_DEBUG("Open type put %s of length %d + overhead (1byte?)", td->name,
|
||||||
size);
|
size);
|
||||||
@ -241,7 +253,10 @@ static asn_dec_rval_t GCC_NOTUSED uper_open_type_get_complex(
|
|||||||
UPDRESTOREPD;
|
UPDRESTOREPD;
|
||||||
|
|
||||||
/* Skip data not consumed by the decoder */
|
/* Skip data not consumed by the decoder */
|
||||||
if (arg.unclaimed) ASN_DEBUG("Getting unclaimed %d", arg.unclaimed);
|
if (arg.unclaimed)
|
||||||
|
{
|
||||||
|
ASN_DEBUG("Getting unclaimed %d", arg.unclaimed);
|
||||||
|
}
|
||||||
if (arg.unclaimed)
|
if (arg.unclaimed)
|
||||||
{
|
{
|
||||||
switch (per_skip_bits(pd, arg.unclaimed))
|
switch (per_skip_bits(pd, arg.unclaimed))
|
||||||
@ -288,9 +303,13 @@ int uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd)
|
|||||||
|
|
||||||
rv = uper_open_type_get(ctx, &s_td, 0, 0, pd);
|
rv = uper_open_type_get(ctx, &s_td, 0, 0, pd);
|
||||||
if (rv.code != RC_OK)
|
if (rv.code != RC_OK)
|
||||||
return -1;
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return 0;
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -310,7 +329,9 @@ static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *ctx,
|
|||||||
(void)sptr;
|
(void)sptr;
|
||||||
|
|
||||||
while (per_get_few_bits(pd, 24) >= 0)
|
while (per_get_few_bits(pd, 24) >= 0)
|
||||||
;
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
rv.code = RC_OK;
|
rv.code = RC_OK;
|
||||||
rv.consumed = pd->moved;
|
rv.consumed = pd->moved;
|
||||||
@ -340,7 +361,10 @@ static int uper_ugot_refill(asn_per_data_t *pd)
|
|||||||
if (arg->unclaimed)
|
if (arg->unclaimed)
|
||||||
{
|
{
|
||||||
/* Refill the container */
|
/* Refill the container */
|
||||||
if (per_get_few_bits(oldpd, 1)) return -1;
|
if (per_get_few_bits(oldpd, 1))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (oldpd->nboff == 0)
|
if (oldpd->nboff == 0)
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
@ -362,7 +386,10 @@ static int uper_ugot_refill(asn_per_data_t *pd)
|
|||||||
next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat);
|
next_chunk_bytes = uper_get_length(oldpd, -1, &arg->repeat);
|
||||||
ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d",
|
ASN_DEBUG("Open type LENGTH %d bytes at off %d, repeat %d",
|
||||||
next_chunk_bytes, oldpd->moved, arg->repeat);
|
next_chunk_bytes, oldpd->moved, arg->repeat);
|
||||||
if (next_chunk_bytes < 0) return -1;
|
if (next_chunk_bytes < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (next_chunk_bytes == 0)
|
if (next_chunk_bytes == 0)
|
||||||
{
|
{
|
||||||
pd->refill = 0; /* No more refills, naturally */
|
pd->refill = 0; /* No more refills, naturally */
|
||||||
@ -399,9 +426,13 @@ static int per_skip_bits(asn_per_data_t *pd, int skip_nbits)
|
|||||||
{
|
{
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
if (skip_nbits < skip)
|
if (skip_nbits < skip)
|
||||||
skip = skip_nbits;
|
{
|
||||||
|
skip = skip_nbits;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
skip = 24;
|
{
|
||||||
|
skip = 24;
|
||||||
|
}
|
||||||
skip_nbits -= skip;
|
skip_nbits -= skip;
|
||||||
|
|
||||||
switch (per_get_few_bits(pd, skip))
|
switch (per_get_few_bits(pd, skip))
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user