~sysman-one/starlet/main

« back to all changes in this revision

Viewing changes to avproto.c

  • Committer: Ruslan (The BadAss SysMan) Laishev
  • Date: 2023-09-11 10:31:24 UTC
  • Revision ID: git-v1:7a4443ce31e3cbbb095e2282ff3d62c96b674799
[*] Added API for TLV/AV

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
**--
87
87
*/
88
88
 
 
89
#include        <stdint.h>
89
90
#include        <stddef.h>
90
91
#include        <ctype.h>
91
92
#include        <limits.h>
154
155
                {
155
156
                case    TAG$K_WORD:     /* 16 bits */
156
157
                        {
157
 
                        unsigned short *vptr = (unsigned short *) ptlv->b_val;
 
158
                        uint16_t *vptr = (unsigned short *) ptlv->b_val;
158
159
 
159
160
                        *vptr = 0;
160
 
                        memcpy(vptr, val, valsz ? valsz : sizeof( unsigned short));
 
161
                        memcpy(vptr, val, valsz ? valsz : sizeof( uint16_t));
161
162
                        *(vptr) = htobe16(*vptr);
162
163
 
163
 
                        ptlv->w_len = htobe16( len = sizeof(unsigned short) );
 
164
                        ptlv->w_len = htobe16( len = sizeof(uint16_t) );
164
165
 
165
166
                        break;
166
167
                        }
167
168
 
168
169
                case    TAG$K_LONGWORD: /* 32 bits */
169
170
                        {
170
 
                        unsigned *vptr = (unsigned *) ptlv->b_val;
 
171
                        uint32_t *vptr = (uint32_t *) ptlv->b_val;
171
172
 
172
173
                        *vptr = 0UL;
173
 
                        memcpy(vptr, val, valsz ? valsz : sizeof( unsigned));
 
174
                        memcpy(vptr, val, valsz ? valsz : sizeof( uint32_t));
174
175
                        *(vptr) = htobe32(*vptr);
175
176
 
176
 
                        ptlv->w_len = htobe16( len = sizeof(unsigned) );
 
177
                        ptlv->w_len = htobe16( len = sizeof(uint32_t) );
177
178
 
178
179
                        break;
179
180
                        }
180
181
 
181
182
                case    TAG$K_QWORD:    /* 64 bits */
182
183
                        {
183
 
                        unsigned long long *vptr = (unsigned long long *) ptlv->b_val;
 
184
                        uint64_t *vptr = (uint64_t *) ptlv->b_val;
184
185
 
185
186
                        *vptr = 0ULL;
186
 
                        memcpy(vptr, val, valsz ? valsz : sizeof( unsigned long long));
 
187
                        memcpy(vptr, val, valsz ? valsz : sizeof( uint64_t));
187
188
                        *(vptr) = htobe64(*vptr);
188
189
 
189
 
                        ptlv->w_len = htobe16( len = sizeof(unsigned long long) );
 
190
                        ptlv->w_len = htobe16( len = sizeof(uint64_t) );
190
191
 
191
192
                        break;
192
193
                        }
290
291
        switch ( *v_type )
291
292
                {
292
293
                case    TAG$K_WORD:     /* 16 bits */
293
 
                        *((unsigned short *) val) = be16toh(ptlv->w_val[0]);
294
 
                        len  = sizeof(unsigned short);
 
294
                        *((uint16_t *) val) = be16toh(ptlv->w_val[0]);
 
295
                        len  = sizeof(uint16_t);
295
296
 
296
297
                        break;
297
298
 
298
299
                case    TAG$K_LONGWORD: /* 32 bits */
299
 
                        *((unsigned  *) val) = be32toh(ptlv->u_val[0]);
300
 
                        len  = sizeof(unsigned);
 
300
                        *((uint32_t  *) val) = be32toh(ptlv->u_val[0]);
 
301
                        len  = sizeof(uint32_t);
301
302
 
302
303
                        break;
303
304
 
304
305
                case    TAG$K_QWORD:    /* 64 bits */
305
 
                        *((unsigned long long *) val) = be64toh(ptlv->q_val[0]);
306
 
                        len  = sizeof(unsigned long long);
 
306
                        *((uint64_t *) val) = be64toh(ptlv->q_val[0]);
 
307
                        len  = sizeof(uint64_t);
307
308
 
308
309
                        break;
309
310
 
310
311
                case    TAG$K_UUID:     /* 16 octets  */
311
312
                        len = 16;
312
313
                        w_len = $MIN(w_len, 16);
313
 
                        __util$movc5 (&w_len, ptlv->b_val,  0, &len, val);
 
314
                        __util$movc5 (&w_len, ptlv->b_val,  0, (unsigned short *)  &len, val);
314
315
 
315
316
                        break;
316
317
                default: