blob: 4ea06693409d17995c8587b9b37ecca1d9d13966 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*-
2 * Copyright (c) 2003 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
5#include <NULL.h>
6#include <BOOLEAN.h> /* Implemented in terms of BOOLEAN type */
7
8/*
9 * NULL basic type description.
10 */
11static ber_tlv_tag_t asn1_DEF_NULL_tags[] = {
12 (ASN_TAG_CLASS_UNIVERSAL | (5 << 2))
13};
14asn1_TYPE_descriptor_t asn1_DEF_NULL = {
15 "NULL",
16 asn_generic_no_constraint,
17 BOOLEAN_decode_ber, /* Implemented in terms of BOOLEAN */
18 NULL_encode_der, /* Special handling of DER encoding */
19 NULL_print,
20 BOOLEAN_free,
21 0, /* Use generic outmost tag fetcher */
22 asn1_DEF_NULL_tags,
23 sizeof(asn1_DEF_NULL_tags)/sizeof(asn1_DEF_NULL_tags[0]),
24 1, /* Single UNIVERSAL tag may be implicitly overriden */
Lev Walkind9bd7752004-06-05 08:17:50 +000025 0, /* Always in primitive form */
26 0 /* No specifics */
Lev Walkinf15320b2004-06-03 03:38:44 +000027};
28
29der_enc_rval_t
30NULL_encode_der(asn1_TYPE_descriptor_t *sd, void *ptr,
31 int tag_mode, ber_tlv_tag_t tag,
32 asn_app_consume_bytes_f *cb, void *app_key) {
33 der_enc_rval_t erval;
34
35 erval.encoded = der_write_tags(sd, 0, tag_mode, tag, cb, app_key);
36 if(erval.encoded == -1) {
37 erval.failed_type = sd;
38 erval.structure_ptr = ptr;
39 }
40
41 return erval;
42}
43
44int
45NULL_print(asn1_TYPE_descriptor_t *td, const void *sptr, int ilevel,
46 asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkind9bd7752004-06-05 08:17:50 +000047
48 (void)td; /* Unused argument */
49 (void)ilevel; /* Unused argument */
50
Lev Walkinf15320b2004-06-03 03:38:44 +000051 if(sptr) {
52 return cb("<present>", 9, app_key);
53 } else {
54 return cb("<absent>", 8, app_key);
55 }
56}