FreeCalypso > hg > freecalypso-citrine
comparison ccd/asn1_objid.c @ 0:75a11d740a02
initial import of gsm-fw from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 09 Jun 2016 00:02:41 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:75a11d740a02 |
---|---|
1 | |
2 /* | |
3 +------------------------------------------------------------------------------ | |
4 | File: asn1_objid.c | |
5 +------------------------------------------------------------------------------ | |
6 | Copyright 2002 Texas Instruments Berlin, AG | |
7 | All rights reserved. | |
8 | | |
9 | This file is confidential and a trade secret of Texas | |
10 | Instruments Berlin, AG. | |
11 | The receipt of or possession of this file does not convey | |
12 | any rights to reproduce or disclose its contents or to | |
13 | manufacture, use, or sell anything it may describe, in | |
14 | whole, or in part, without the specific written consent of | |
15 | Texas Instruments Berlin, AG. | |
16 +------------------------------------------------------------------------------ | |
17 | Purpose: Encoding and decoding functions for ASN1_OBJ_ID type | |
18 | | |
19 | $Identity:$ | |
20 +------------------------------------------------------------------------------ | |
21 */ | |
22 | |
23 /* | |
24 * Standard definitions like UCHAR, ERROR etc. | |
25 */ | |
26 #include "typedefs.h" | |
27 #include "header.h" | |
28 | |
29 /* | |
30 * Prototypes of ccd (USE_DRIVER EQ undef) for prototypes only | |
31 * look at ccdapi.h | |
32 */ | |
33 #undef USE_DRIVER | |
34 #include "ccdapi.h" | |
35 | |
36 /* | |
37 * Types and functions for bit access and manipulation | |
38 */ | |
39 #include "ccd_globs.h" | |
40 #include "bitfun.h" | |
41 | |
42 /* | |
43 * Prototypes and constants in the common part of ccd | |
44 */ | |
45 #include "ccd.h" | |
46 | |
47 /* | |
48 * Declaration of coder/decoder tables | |
49 */ | |
50 #include "ccdtable.h" | |
51 #include "ccddata.h" | |
52 | |
53 #ifndef RUN_INT_RAM | |
54 /* | |
55 +------------------------------------------------------------------------+ | |
56 | PROJECT : CCD (6144) MODULE : asn1_objid | | |
57 | STATE : code ROUTINE : cdc_asn1_obj_id_decode | | |
58 +------------------------------------------------------------------------+ | |
59 | |
60 PURPOSE : Decode PER OBJECT IDENTIFIER type | |
61 | |
62 The PER encoding of an object identifier type uses the | |
63 content octets of BER preceded by a length determinant | |
64 that will in practice be a single octet. | |
65 */ | |
66 SHORT cdc_asn1_obj_id_decode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs) | |
67 { | |
68 U8 BER_Len; | |
69 | |
70 #ifdef DEBUG_CCD | |
71 #ifndef CCD_SYMBOLS | |
72 TRACE_CCD (globs, "cdc_asn1_obj_id_decode()"); | |
73 #else | |
74 TRACE_CCD (globs, "cdc_asn1_obj_id_decode() %s", | |
75 mcomp[melem[e_ref].elemRef].name); | |
76 #endif | |
77 #endif | |
78 | |
79 globs->pstructOffs = melem[e_ref].structOffs; | |
80 | |
81 /* For optional elements we have already set the valid flag in the | |
82 * C-structure. We have done it while processing ASN1_SEQ. | |
83 */ | |
84 if ( ! cdc_isPresent(e_ref, globs) ) { | |
85 return 1; | |
86 } | |
87 | |
88 /* | |
89 * Skip over PER length octet and BER tag octet. | |
90 */ | |
91 bf_incBitpos (16, globs); | |
92 | |
93 /* | |
94 * For unknown extension read the length and skip over the octets. | |
95 */ | |
96 BER_Len = (U8) bf_getBits (8, globs); | |
97 *(U8 *)(globs->pstruct + globs->pstructOffs++) = BER_Len; | |
98 | |
99 /* | |
100 * Copy the content of object identifier bytes into the C-Structure. | |
101 */ | |
102 #if 1 //#ifdef _TMS470 | |
103 bf_incBitpos (8 * BER_Len, globs); | |
104 #else | |
105 { | |
106 int i; | |
107 for (i=0; i < BER_Len; i++) | |
108 *(U8 *)(globs->pstruct + globs->pstructOffs++) = (U8) bf_getBits (8, globs); | |
109 } | |
110 #endif | |
111 | |
112 return 1; | |
113 } | |
114 #endif /* !RUN_INT_RAM */ | |
115 | |
116 #ifndef RUN_INT_RAM | |
117 /* | |
118 +------------------------------------------------------------------------+ | |
119 | PROJECT : CCD (6144) MODULE : asn1_objid | | |
120 | STATE : code ROUTINE : cdc_asn1_obj_id_encode | | |
121 +------------------------------------------------------------------------+ | |
122 | |
123 PURPOSE : Encode PER OBJECT IDENTIFIER type | |
124 | |
125 The PER encoding of an object identifier type uses the | |
126 content octets of BER preceded by a length determinant | |
127 that will in practice be a single octet. | |
128 */ | |
129 SHORT cdc_asn1_obj_id_encode (const ULONG c_ref, const ULONG e_ref, T_CCD_Globs *globs) | |
130 { | |
131 | |
132 #ifdef DEBUG_CCD | |
133 #ifndef CCD_SYMBOLS | |
134 TRACE_CCD (globs, "cdc_asn1_obj_id_encode()"); | |
135 #else | |
136 TRACE_CCD (globs, "cdc_asn1_obj_id_encode() %s", | |
137 mcomp[melem[e_ref].elemRef].name); | |
138 #endif | |
139 #endif | |
140 | |
141 return 1; | |
142 } | |
143 #endif /* !RUN_INT_RAM */ |