/src/open5gs/lib/asn1c/common/VisibleString.c
Line | Count | Source |
1 | | /*- |
2 | | * Copyright (c) 2003, 2006 Lev Walkin <vlm@lionet.info>. All rights reserved. |
3 | | * Redistribution and modifications are permitted subject to BSD license. |
4 | | */ |
5 | | #include <asn_internal.h> |
6 | | #include <VisibleString.h> |
7 | | |
8 | | /* |
9 | | * VisibleString basic type description. |
10 | | */ |
11 | | static const ber_tlv_tag_t asn_DEF_VisibleString_tags[] = { |
12 | | (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), /* [UNIVERSAL 26] IMPLICIT ...*/ |
13 | | (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ |
14 | | }; |
15 | | #if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) |
16 | | static asn_per_constraints_t asn_DEF_VisibleString_constraints = { |
17 | | { APC_CONSTRAINED, 7, 7, 0x20, 0x7e }, /* Value */ |
18 | | { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ |
19 | | 0, 0 |
20 | | }; |
21 | | #endif /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */ |
22 | | asn_TYPE_operation_t asn_OP_VisibleString = { |
23 | | .kind = ASN_KIND_PRIMITIVE, |
24 | | OCTET_STRING_free, |
25 | | #if !defined(ASN_DISABLE_PRINT_SUPPORT) |
26 | | OCTET_STRING_print_utf8, /* ASCII subset */ |
27 | | #else |
28 | | 0, |
29 | | #endif /* !defined(ASN_DISABLE_PRINT_SUPPORT) */ |
30 | | OCTET_STRING_compare, |
31 | | OCTET_STRING_copy, |
32 | | #if !defined(ASN_DISABLE_BER_SUPPORT) |
33 | | OCTET_STRING_decode_ber, /* Implemented in terms of OCTET STRING */ |
34 | | OCTET_STRING_encode_der, |
35 | | #else |
36 | | 0, |
37 | | 0, |
38 | | #endif /* !defined(ASN_DISABLE_BER_SUPPORT) */ |
39 | | #if !defined(ASN_DISABLE_XER_SUPPORT) |
40 | | OCTET_STRING_decode_xer_utf8, |
41 | | OCTET_STRING_encode_xer_utf8, |
42 | | #else |
43 | | 0, |
44 | | 0, |
45 | | #endif /* !defined(ASN_DISABLE_XER_SUPPORT) */ |
46 | | #if !defined(ASN_DISABLE_JER_SUPPORT) |
47 | | OCTET_STRING_decode_jer_utf8, |
48 | | OCTET_STRING_encode_jer_utf8, |
49 | | #else |
50 | | 0, |
51 | | 0, |
52 | | #endif /* !defined(ASN_DISABLE_JER_SUPPORT) */ |
53 | | #if !defined(ASN_DISABLE_OER_SUPPORT) |
54 | | OCTET_STRING_decode_oer, |
55 | | OCTET_STRING_encode_oer, |
56 | | #else |
57 | | 0, |
58 | | 0, |
59 | | #endif /* !defined(ASN_DISABLE_OER_SUPPORT) */ |
60 | | #if !defined(ASN_DISABLE_UPER_SUPPORT) |
61 | | OCTET_STRING_decode_uper, |
62 | | OCTET_STRING_encode_uper, |
63 | | #else |
64 | | 0, |
65 | | 0, |
66 | | #endif /* !defined(ASN_DISABLE_UPER_SUPPORT) */ |
67 | | #if !defined(ASN_DISABLE_APER_SUPPORT) |
68 | | OCTET_STRING_decode_aper, |
69 | | OCTET_STRING_encode_aper, |
70 | | #else |
71 | | 0, |
72 | | 0, |
73 | | #endif /* !defined(ASN_DISABLE_APER_SUPPORT) */ |
74 | | #if !defined(ASN_DISABLE_RFILL_SUPPORT) |
75 | | OCTET_STRING_random_fill, |
76 | | #else |
77 | | 0, |
78 | | #endif /* !defined(ASN_DISABLE_RFILL_SUPPORT) */ |
79 | | 0, /* Use generic outmost tag fetcher */ |
80 | | #if !defined(ASN_DISABLE_CBOR_SUPPORT) |
81 | | OCTET_STRING_decode_cbor_utf8, |
82 | | OCTET_STRING_encode_cbor_utf8, |
83 | | #else |
84 | | 0, |
85 | | 0, |
86 | | #endif /* !defined(ASN_DISABLE_CBOR_SUPPORT) */ |
87 | | }; |
88 | | asn_TYPE_descriptor_t asn_DEF_VisibleString = { |
89 | | "VisibleString", |
90 | | "VisibleString", |
91 | | &asn_OP_VisibleString, |
92 | | asn_DEF_VisibleString_tags, |
93 | | sizeof(asn_DEF_VisibleString_tags) |
94 | | / sizeof(asn_DEF_VisibleString_tags[0]) - 1, |
95 | | asn_DEF_VisibleString_tags, |
96 | | sizeof(asn_DEF_VisibleString_tags) |
97 | | / sizeof(asn_DEF_VisibleString_tags[0]), |
98 | | { |
99 | | #if !defined(ASN_DISABLE_OER_SUPPORT) |
100 | | 0, |
101 | | #endif /* !defined(ASN_DISABLE_OER_SUPPORT) */ |
102 | | #if !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) |
103 | | &asn_DEF_VisibleString_constraints, |
104 | | #endif /* !defined(ASN_DISABLE_UPER_SUPPORT) || !defined(ASN_DISABLE_APER_SUPPORT) */ |
105 | | #if !defined(ASN_DISABLE_JER_SUPPORT) |
106 | | 0, |
107 | | #endif /* !defined(ASN_DISABLE_JER_SUPPORT) */ |
108 | | VisibleString_constraint |
109 | | }, |
110 | | 0, 0, /* No members */ |
111 | | 0 /* No specifics */ |
112 | | }; |
113 | | |
114 | | int |
115 | | VisibleString_constraint(const asn_TYPE_descriptor_t *td, const void *sptr, |
116 | 0 | asn_app_constraint_failed_f *ctfailcb, void *app_key) { |
117 | 0 | const VisibleString_t *st = (const VisibleString_t *)sptr; |
118 | |
|
119 | 0 | if(st && st->buf) { |
120 | 0 | uint8_t *buf = st->buf; |
121 | 0 | uint8_t *end = buf + st->size; |
122 | | |
123 | | /* |
124 | | * Check the alphabet of the VisibleString. |
125 | | * ISO646, ISOReg#6 |
126 | | * The alphabet is a subset of ASCII between the space |
127 | | * and "~" (tilde). |
128 | | */ |
129 | 0 | for(; buf < end; buf++) { |
130 | 0 | if(*buf < 0x20 || *buf > 0x7e) { |
131 | 0 | ASN__CTFAIL(app_key, td, sptr, |
132 | 0 | "%s: value byte %ld (%d) " |
133 | 0 | "not in VisibleString alphabet (%s:%d)", |
134 | 0 | td->name, |
135 | 0 | (long)((buf - st->buf) + 1), |
136 | 0 | *buf, |
137 | 0 | __FILE__, __LINE__); |
138 | 0 | return -1; |
139 | 0 | } |
140 | 0 | } |
141 | 0 | } else { |
142 | 0 | ASN__CTFAIL(app_key, td, sptr, |
143 | 0 | "%s: value not given (%s:%d)", |
144 | 0 | td->name, __FILE__, __LINE__); |
145 | 0 | return -1; |
146 | 0 | } |
147 | | |
148 | 0 | return 0; |
149 | 0 | } |