15 #define DISABLE_DEBUGLOG
19 #include <gwenhywfar/debug.h>
20 #include <gwenhywfar/inherit.h>
21 #include <gwenhywfar/misc.h>
22 #include <gwenhywfar/text.h>
82 tlv->isBerTlv=isBerTlv;
86 tlv->tagData=malloc(dlen);
88 memmove(tlv->tagData, p, dlen);
112 return tlv->tagLength;
133 unsigned int tagMode;
134 unsigned int tagType;
135 unsigned int tagLength;
150 tagMode=tagType=tagLength=0;
161 j=(
unsigned char)(p[pos]);
164 if ((j & 0x1f)==0x1f) {
170 j=(
unsigned char)(p[pos]);
176 isBerTlv?
" (BER-TLV)":
"");
185 j=(
unsigned char)(p[pos]);
194 j=(
unsigned char)(p[pos]);
202 j=((
unsigned char)(p[pos]))<<8;
204 j+=(
unsigned char)(p[pos]);
219 j=((
unsigned char)(p[pos]))<<8;
221 j+=(
unsigned char)(p[pos]);
237 tlv->isBerTlv=isBerTlv;
238 tlv->tagMode=tagMode;
239 tlv->tagType=tagType;
240 tlv->tagLength=tagLength;
242 tlv->tagData=(
void*)malloc(tagLength);
243 memmove(tlv->tagData, tagData, tagLength);
255 return (tlv->tagMode & 0x20);
262 return (tlv->tagMode & 0xc0);
280 unsigned int tagMode,
286 tagLength=strlen(tagData);
310 else if (tagLength>127) {
347 tagMode=tagType=tagLength=0;
356 j=(
unsigned char)(p[pos]);
359 if ((j & 0x1f)==0x1f) {
365 j=(
unsigned char)(p[pos]);
371 isBerTlv?
" (BER-TLV)":
"");
380 j=(
unsigned char)(p[pos]);
389 j=(
unsigned char)(p[pos]);
397 j=((
unsigned char)(p[pos]))<<8;
399 j+=(
unsigned char)(p[pos]);
407 j=((
unsigned char)(p[pos]))<<16;
409 j+=((
unsigned char)(p[pos]))<<8;
411 j+=(
unsigned char)(p[pos]);
419 j=((
unsigned char)(p[pos]))<<24;
421 j+=((
unsigned char)(p[pos]))<<16;
423 j+=((
unsigned char)(p[pos]))<<8;
425 j+=(
unsigned char)(p[pos]);
433 j=((uint64_t) ((
unsigned char)(p[pos])))<<32;
435 j+=((uint64_t) ((
unsigned char)(p[pos])))<<24;
437 j+=((uint64_t) ((
unsigned char)(p[pos])))<<16;
439 j+=((uint64_t) ((
unsigned char)(p[pos])))<<8;
441 j+=(
unsigned char)(p[pos]);
456 j=((
unsigned char)(p[pos]))<<8;
458 j+=(
unsigned char)(p[pos]);
466 tlv->isBerTlv=isBerTlv;
467 tlv->tagMode=tagMode;
468 tlv->tagType=tagType;
469 tlv->tagLength=tagLength;
471 tlv->tagSize=pos+tagLength;
478 unsigned int tagMode,
498 if (tagLength>0xffffffffLL) {
507 else if (tagLength>0xffffffL) {
515 else if (tagLength>0xffff) {
522 else if (tagLength>0xff) {
528 else if (tagLength>127) {