@wildboar/copp
Version:
Connection-oriented presentation protocol (COPP) data structures and business logic in TypeScript
186 lines (185 loc) • 7.83 kB
JavaScript
/* eslint-disable */
import { ASN1TagClass as _TagClass, } from '@wildboar/asn1';
import * as $ from '@wildboar/asn1/functional';
import { _decode_Mode_selector, _encode_Mode_selector, } from '../ISO8823-PRESENTATION/Mode-selector.ta.mjs';
import { _decode_CPA_PPDU_x410_mode_parameters, _encode_CPA_PPDU_x410_mode_parameters, } from '../ISO8823-PRESENTATION/CPA-PPDU-x410-mode-parameters.ta.mjs';
import { _decode_CPA_PPDU_normal_mode_parameters, _encode_CPA_PPDU_normal_mode_parameters, } from '../ISO8823-PRESENTATION/CPA-PPDU-normal-mode-parameters.ta.mjs';
/**
* @summary CPA_PPDU
* @description
*
* ### ASN.1 Definition:
*
* ```asn1
* CPA-PPDU ::= SET {
* mode-selector [0] IMPLICIT Mode-selector,
* x410-mode-parameters
* [1] IMPLICIT SET {COMPONENTS OF Reliable-Transfer-APDU.RTOACapdu} OPTIONAL-- This OPTIONAL element shall be absent for a
* -- nested presentation connection.
* -- Shall be used for X.410 mode only. Shall be bitwise
* -- compatible with CCITT Recommendation X.410-1984.
* -- This shall be the User data parameter of the CPA PPDU1) --,
* normal-mode-parameters
* [2] IMPLICIT SEQUENCE {protocol-version
* [0] IMPLICIT Protocol-version DEFAULT {version-1},
* responding-presentation-selector
* [3] IMPLICIT Responding-presentation-selector
* OPTIONAL,
* presentation-context-definition-result-list
* [5] IMPLICIT Presentation-context-definition-result-list
* OPTIONAL,
* presentation-requirements
* [8] IMPLICIT Presentation-requirements OPTIONAL,
* user-session-requirements
* [9] IMPLICIT User-session-requirements OPTIONAL,
* -- shall not be present if equal to the Revised session
* -- requirements parameter
* protocol-options
* [11] Protocol-options DEFAULT {},
* -- shall be absent if no options are selected
* responders-nominated-context
* [13] Presentation-context-identifier OPTIONAL,
* -- shall only be present if nominated-context is
* -- selected in protocol-options
* user-data
* User-data OPTIONAL} OPTIONAL
* -- Shall be used for normal mode only.
* }
* ```
*
*/
export class CPA_PPDU {
mode_selector;
x410_mode_parameters;
normal_mode_parameters;
constructor(
/**
* @summary `mode_selector`.
* @public
* @readonly
*/
mode_selector,
/**
* @summary `x410_mode_parameters`.
* @public
* @readonly
*/
x410_mode_parameters,
/**
* @summary `normal_mode_parameters`.
* @public
* @readonly
*/
normal_mode_parameters) {
this.mode_selector = mode_selector;
this.x410_mode_parameters = x410_mode_parameters;
this.normal_mode_parameters = normal_mode_parameters;
}
/**
* @summary Restructures an object into a CPA_PPDU
* @description
*
* This takes an `object` and converts it to a `CPA_PPDU`.
*
* @public
* @static
* @method
* @param {Object} _o An object having all of the keys and values of a `CPA_PPDU`.
* @returns {CPA_PPDU}
*/
static _from_object(_o) {
return new CPA_PPDU(_o.mode_selector, _o.x410_mode_parameters, _o.normal_mode_parameters);
}
}
/**
* @summary The Leading Root Component Types of CPA_PPDU
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the leading root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_1_spec_for_CPA_PPDU = [
new $.ComponentSpec('mode-selector', false, $.hasTag(_TagClass.context, 0)),
new $.ComponentSpec('x410-mode-parameters', true, $.hasTag(_TagClass.context, 1)),
new $.ComponentSpec('normal-mode-parameters', true, $.hasTag(_TagClass.context, 2)),
];
/**
* @summary The Trailing Root Component Types of CPA_PPDU
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the trailing root component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _root_component_type_list_2_spec_for_CPA_PPDU = [];
/**
* @summary The Extension Addition Component Types of CPA_PPDU
* @description
*
* This is an array of `ComponentSpec`s that define how to decode the extension addition component type list of a SET or SEQUENCE.
*
* @constant
*/
export const _extension_additions_list_spec_for_CPA_PPDU = [];
let _cached_decoder_for_CPA_PPDU = null;
/**
* @summary Decodes an ASN.1 element into a(n) CPA_PPDU
* @function
* @param {_Element} el The element being decoded.
* @returns {CPA_PPDU} The decoded data structure.
*/
export function _decode_CPA_PPDU(el) {
if (!_cached_decoder_for_CPA_PPDU) {
_cached_decoder_for_CPA_PPDU = function (el) {
/* START_OF_SET_COMPONENT_DECLARATIONS */
let mode_selector;
let x410_mode_parameters;
let normal_mode_parameters;
/* END_OF_SET_COMPONENT_DECLARATIONS */
const callbacks = {
'mode-selector': (_el) => {
mode_selector = $._decode_implicit(() => _decode_Mode_selector)(_el);
},
'x410-mode-parameters': (_el) => {
x410_mode_parameters = $._decode_implicit(() => _decode_CPA_PPDU_x410_mode_parameters)(_el);
},
'normal-mode-parameters': (_el) => {
normal_mode_parameters = $._decode_implicit(() => _decode_CPA_PPDU_normal_mode_parameters)(_el);
},
};
$._parse_set(el, callbacks, _root_component_type_list_1_spec_for_CPA_PPDU, _extension_additions_list_spec_for_CPA_PPDU, _root_component_type_list_2_spec_for_CPA_PPDU, undefined);
return new CPA_PPDU /* SET_CONSTRUCTOR_CALL */(mode_selector, x410_mode_parameters, normal_mode_parameters);
};
}
return _cached_decoder_for_CPA_PPDU(el);
}
let _cached_encoder_for_CPA_PPDU = null;
/**
* @summary Encodes a(n) CPA_PPDU into an ASN.1 Element.
* @function
* @param value The element being encoded.
* @param elGetter A function that can be used to get new ASN.1 elements.
* @returns {_Element} The CPA_PPDU, encoded as an ASN.1 Element.
*/
export function _encode_CPA_PPDU(value, elGetter) {
if (!_cached_encoder_for_CPA_PPDU) {
_cached_encoder_for_CPA_PPDU = function (value) {
return $._encodeSet([]
.concat([
/* REQUIRED */ $._encode_implicit(_TagClass.context, 0, () => _encode_Mode_selector, $.BER)(value.mode_selector, $.BER),
/* IF_ABSENT */ value.x410_mode_parameters ===
undefined
? undefined
: $._encode_implicit(_TagClass.context, 1, () => _encode_CPA_PPDU_x410_mode_parameters, $.BER)(value.x410_mode_parameters, $.BER),
/* IF_ABSENT */ value.normal_mode_parameters ===
undefined
? undefined
: $._encode_implicit(_TagClass.context, 2, () => _encode_CPA_PPDU_normal_mode_parameters, $.BER)(value.normal_mode_parameters, $.BER),
])
.filter((c) => !!c), $.BER);
};
}
return _cached_encoder_for_CPA_PPDU(value, elGetter);
}
/* eslint-enable */