Lines Matching refs:bs

100 #define INC_BIT(bs) if((++(bs)->bit)>7){(bs)->cur++;(bs)->bit=0;}  argument
101 #define INC_BITS(bs,b) if(((bs)->bit+=(b))>7){(bs)->cur+=(bs)->bit>>3;(bs)->bit&=7;} argument
102 #define BYTE_ALIGN(bs) if((bs)->bit){(bs)->cur++;(bs)->bit=0;} argument
103 static unsigned int get_len(struct bitstr *bs);
104 static unsigned int get_bit(struct bitstr *bs);
105 static unsigned int get_bits(struct bitstr *bs, unsigned int b);
106 static unsigned int get_bitmap(struct bitstr *bs, unsigned int b);
107 static unsigned int get_uint(struct bitstr *bs, int b);
110 static int decode_nul(struct bitstr *bs, const struct field_t *f, char *base, int level);
111 static int decode_bool(struct bitstr *bs, const struct field_t *f, char *base, int level);
112 static int decode_oid(struct bitstr *bs, const struct field_t *f, char *base, int level);
113 static int decode_int(struct bitstr *bs, const struct field_t *f, char *base, int level);
114 static int decode_enum(struct bitstr *bs, const struct field_t *f, char *base, int level);
115 static int decode_bitstr(struct bitstr *bs, const struct field_t *f, char *base, int level);
116 static int decode_numstr(struct bitstr *bs, const struct field_t *f, char *base, int level);
117 static int decode_octstr(struct bitstr *bs, const struct field_t *f, char *base, int level);
118 static int decode_bmpstr(struct bitstr *bs, const struct field_t *f, char *base, int level);
119 static int decode_seq(struct bitstr *bs, const struct field_t *f, char *base, int level);
120 static int decode_seqof(struct bitstr *bs, const struct field_t *f, char *base, int level);
121 static int decode_choice(struct bitstr *bs, const struct field_t *f, char *base, int level);
150 static unsigned int get_len(struct bitstr *bs) in get_len() argument
154 v = *bs->cur++; in get_len()
159 v += *bs->cur++; in get_len()
165 static int nf_h323_error_boundary(struct bitstr *bs, size_t bytes, size_t bits) in nf_h323_error_boundary() argument
167 bits += bs->bit; in nf_h323_error_boundary()
172 if (bs->cur + bytes > bs->end) in nf_h323_error_boundary()
178 static unsigned int get_bit(struct bitstr *bs) in get_bit() argument
180 unsigned int b = (*bs->cur) & (0x80 >> bs->bit); in get_bit()
182 INC_BIT(bs); in get_bit()
188 static unsigned int get_bits(struct bitstr *bs, unsigned int b) in get_bits() argument
192 v = (*bs->cur) & (0xffU >> bs->bit); in get_bits()
193 l = b + bs->bit; in get_bits()
197 bs->bit = l; in get_bits()
199 bs->cur++; in get_bits()
200 bs->bit = 0; in get_bits()
204 v += *(++bs->cur); in get_bits()
206 bs->bit = l - 8; in get_bits()
213 static unsigned int get_bitmap(struct bitstr *bs, unsigned int b) in get_bitmap() argument
220 l = bs->bit + b; in get_bitmap()
223 v = (unsigned int)(*bs->cur) << (bs->bit + 24); in get_bitmap()
224 bs->bit = l; in get_bitmap()
226 v = (unsigned int)(*bs->cur++) << (bs->bit + 24); in get_bitmap()
227 bs->bit = 0; in get_bitmap()
231 v |= (unsigned int)(*bs->cur++) << shift; in get_bitmap()
234 v |= (unsigned int)(*bs->cur) << shift; in get_bitmap()
235 v <<= bs->bit; in get_bitmap()
237 v <<= bs->bit; in get_bitmap()
238 v |= (*bs->cur) >> (8 - bs->bit); in get_bitmap()
241 bs->bit = l & 0x7; in get_bitmap()
252 static unsigned int get_uint(struct bitstr *bs, int b) in get_uint() argument
258 v |= *bs->cur++; in get_uint()
262 v |= *bs->cur++; in get_uint()
266 v |= *bs->cur++; in get_uint()
270 v |= *bs->cur++; in get_uint()
276 static int decode_nul(struct bitstr *bs, const struct field_t *f, in decode_nul() argument
284 static int decode_bool(struct bitstr *bs, const struct field_t *f, in decode_bool() argument
289 INC_BIT(bs); in decode_bool()
290 if (nf_h323_error_boundary(bs, 0, 0)) in decode_bool()
295 static int decode_oid(struct bitstr *bs, const struct field_t *f, in decode_oid() argument
302 BYTE_ALIGN(bs); in decode_oid()
303 if (nf_h323_error_boundary(bs, 1, 0)) in decode_oid()
306 len = *bs->cur++; in decode_oid()
307 bs->cur += len; in decode_oid()
308 if (nf_h323_error_boundary(bs, 0, 0)) in decode_oid()
314 static int decode_int(struct bitstr *bs, const struct field_t *f, in decode_int() argument
323 BYTE_ALIGN(bs); in decode_int()
324 bs->cur++; in decode_int()
327 BYTE_ALIGN(bs); in decode_int()
328 bs->cur += 2; in decode_int()
331 if (nf_h323_error_boundary(bs, 0, 2)) in decode_int()
333 len = get_bits(bs, 2) + 1; in decode_int()
334 BYTE_ALIGN(bs); in decode_int()
336 unsigned int v = get_uint(bs, len) + f->lb; in decode_int()
340 bs->cur += len; in decode_int()
343 BYTE_ALIGN(bs); in decode_int()
344 if (nf_h323_error_boundary(bs, 2, 0)) in decode_int()
346 len = get_len(bs); in decode_int()
347 bs->cur += len; in decode_int()
350 INC_BITS(bs, f->sz); in decode_int()
356 if (nf_h323_error_boundary(bs, 0, 0)) in decode_int()
361 static int decode_enum(struct bitstr *bs, const struct field_t *f, in decode_enum() argument
366 if ((f->attr & EXT) && get_bit(bs)) { in decode_enum()
367 INC_BITS(bs, 7); in decode_enum()
369 INC_BITS(bs, f->sz); in decode_enum()
372 if (nf_h323_error_boundary(bs, 0, 0)) in decode_enum()
377 static int decode_bitstr(struct bitstr *bs, const struct field_t *f, in decode_bitstr() argument
384 BYTE_ALIGN(bs); in decode_bitstr()
390 if (nf_h323_error_boundary(bs, 2, 0)) in decode_bitstr()
392 len = (*bs->cur++) << 8; in decode_bitstr()
393 len += (*bs->cur++) + f->lb; in decode_bitstr()
396 if (nf_h323_error_boundary(bs, 2, 0)) in decode_bitstr()
398 len = get_len(bs); in decode_bitstr()
405 bs->cur += len >> 3; in decode_bitstr()
406 bs->bit = len & 7; in decode_bitstr()
408 if (nf_h323_error_boundary(bs, 0, 0)) in decode_bitstr()
413 static int decode_numstr(struct bitstr *bs, const struct field_t *f, in decode_numstr() argument
421 if (nf_h323_error_boundary(bs, 0, f->sz)) in decode_numstr()
423 len = get_bits(bs, f->sz) + f->lb; in decode_numstr()
425 BYTE_ALIGN(bs); in decode_numstr()
426 INC_BITS(bs, (len << 2)); in decode_numstr()
428 if (nf_h323_error_boundary(bs, 0, 0)) in decode_numstr()
433 static int decode_octstr(struct bitstr *bs, const struct field_t *f, in decode_octstr() argument
443 BYTE_ALIGN(bs); in decode_octstr()
448 bs->cur[0], bs->cur[1], in decode_octstr()
449 bs->cur[2], bs->cur[3], in decode_octstr()
450 bs->cur[4] * 256 + bs->cur[5])); in decode_octstr()
452 bs->cur - bs->buf; in decode_octstr()
458 BYTE_ALIGN(bs); in decode_octstr()
459 if (nf_h323_error_boundary(bs, 1, 0)) in decode_octstr()
461 len = (*bs->cur++) + f->lb; in decode_octstr()
464 BYTE_ALIGN(bs); in decode_octstr()
465 if (nf_h323_error_boundary(bs, 2, 0)) in decode_octstr()
467 len = get_len(bs) + f->lb; in decode_octstr()
470 if (nf_h323_error_boundary(bs, 0, f->sz)) in decode_octstr()
472 len = get_bits(bs, f->sz) + f->lb; in decode_octstr()
473 BYTE_ALIGN(bs); in decode_octstr()
477 bs->cur += len; in decode_octstr()
481 if (nf_h323_error_boundary(bs, 0, 0)) in decode_octstr()
486 static int decode_bmpstr(struct bitstr *bs, const struct field_t *f, in decode_bmpstr() argument
495 BYTE_ALIGN(bs); in decode_bmpstr()
496 if (nf_h323_error_boundary(bs, 1, 0)) in decode_bmpstr()
498 len = (*bs->cur++) + f->lb; in decode_bmpstr()
501 if (nf_h323_error_boundary(bs, 0, f->sz)) in decode_bmpstr()
503 len = get_bits(bs, f->sz) + f->lb; in decode_bmpstr()
504 BYTE_ALIGN(bs); in decode_bmpstr()
508 bs->cur += len << 1; in decode_bmpstr()
510 if (nf_h323_error_boundary(bs, 0, 0)) in decode_bmpstr()
515 static int decode_seq(struct bitstr *bs, const struct field_t *f, in decode_seq() argument
529 if (nf_h323_error_boundary(bs, 0, 1)) in decode_seq()
531 ext = (f->attr & EXT) ? get_bit(bs) : 0; in decode_seq()
534 if (nf_h323_error_boundary(bs, 0, f->sz)) in decode_seq()
538 bmp = get_bitmap(bs, f->sz); in decode_seq()
557 if (nf_h323_error_boundary(bs, 2, 0)) in decode_seq()
559 len = get_len(bs); in decode_seq()
560 if (nf_h323_error_boundary(bs, len, 0)) in decode_seq()
565 bs->cur += len; in decode_seq()
568 beg = bs->cur; in decode_seq()
571 if ((err = (Decoders[son->type]) (bs, son, base, in decode_seq()
576 bs->cur = beg + len; in decode_seq()
577 bs->bit = 0; in decode_seq()
578 } else if ((err = (Decoders[son->type]) (bs, son, base, in decode_seq()
589 if (nf_h323_error_boundary(bs, 0, 7)) in decode_seq()
591 bmp2_len = get_bits(bs, 7) + 1; in decode_seq()
592 if (nf_h323_error_boundary(bs, 0, bmp2_len)) in decode_seq()
596 bmp2 = get_bitmap(bs, bmp2_len); in decode_seq()
600 BYTE_ALIGN(bs); in decode_seq()
606 if (nf_h323_error_boundary(bs, 2, 0)) in decode_seq()
608 len = get_len(bs); in decode_seq()
609 if (nf_h323_error_boundary(bs, len, 0)) in decode_seq()
611 bs->cur += len; in decode_seq()
624 if (nf_h323_error_boundary(bs, 2, 0)) in decode_seq()
626 len = get_len(bs); in decode_seq()
627 if (nf_h323_error_boundary(bs, len, 0)) in decode_seq()
632 bs->cur += len; in decode_seq()
635 beg = bs->cur; in decode_seq()
637 if ((err = (Decoders[son->type]) (bs, son, base, in decode_seq()
642 bs->cur = beg + len; in decode_seq()
643 bs->bit = 0; in decode_seq()
648 static int decode_seqof(struct bitstr *bs, const struct field_t *f, in decode_seqof() argument
664 BYTE_ALIGN(bs); in decode_seqof()
665 if (nf_h323_error_boundary(bs, 1, 0)) in decode_seqof()
667 count = *bs->cur++; in decode_seqof()
670 BYTE_ALIGN(bs); in decode_seqof()
671 if (nf_h323_error_boundary(bs, 2, 0)) in decode_seqof()
673 count = *bs->cur++; in decode_seqof()
675 count += *bs->cur++; in decode_seqof()
678 BYTE_ALIGN(bs); in decode_seqof()
679 if (nf_h323_error_boundary(bs, 2, 0)) in decode_seqof()
681 count = get_len(bs); in decode_seqof()
684 if (nf_h323_error_boundary(bs, 0, f->sz)) in decode_seqof()
686 count = get_bits(bs, f->sz); in decode_seqof()
704 BYTE_ALIGN(bs); in decode_seqof()
705 if (nf_h323_error_boundary(bs, 2, 0)) in decode_seqof()
707 len = get_len(bs); in decode_seqof()
708 if (nf_h323_error_boundary(bs, len, 0)) in decode_seqof()
713 bs->cur += len; in decode_seqof()
716 beg = bs->cur; in decode_seqof()
718 if ((err = (Decoders[son->type]) (bs, son, in decode_seqof()
726 bs->cur = beg + len; in decode_seqof()
727 bs->bit = 0; in decode_seqof()
729 if ((err = (Decoders[son->type]) (bs, son, in decode_seqof()
744 static int decode_choice(struct bitstr *bs, const struct field_t *f, in decode_choice() argument
758 if (nf_h323_error_boundary(bs, 0, 1)) in decode_choice()
760 if ((f->attr & EXT) && get_bit(bs)) { in decode_choice()
762 if (nf_h323_error_boundary(bs, 0, 7)) in decode_choice()
764 type = get_bits(bs, 7) + f->lb; in decode_choice()
767 if (nf_h323_error_boundary(bs, 0, f->sz)) in decode_choice()
769 type = get_bits(bs, f->sz); in decode_choice()
780 BYTE_ALIGN(bs); in decode_choice()
781 if (nf_h323_error_boundary(bs, 2, 0)) in decode_choice()
783 len = get_len(bs); in decode_choice()
784 if (nf_h323_error_boundary(bs, len, 0)) in decode_choice()
786 bs->cur += len; in decode_choice()
798 BYTE_ALIGN(bs); in decode_choice()
799 if (nf_h323_error_boundary(bs, len, 0)) in decode_choice()
801 len = get_len(bs); in decode_choice()
802 if (nf_h323_error_boundary(bs, len, 0)) in decode_choice()
807 bs->cur += len; in decode_choice()
810 beg = bs->cur; in decode_choice()
812 if ((err = (Decoders[son->type]) (bs, son, base, level + 1)) < in decode_choice()
816 bs->cur = beg + len; in decode_choice()
817 bs->bit = 0; in decode_choice()
818 } else if ((err = (Decoders[son->type]) (bs, son, base, level + 1)) < in decode_choice()
831 struct bitstr bs; in DecodeRasMessage() local
833 bs.buf = bs.beg = bs.cur = buf; in DecodeRasMessage()
834 bs.end = buf + sz; in DecodeRasMessage()
835 bs.bit = 0; in DecodeRasMessage()
837 return decode_choice(&bs, &ras_message, (char *) ras, 0); in DecodeRasMessage()
847 struct bitstr bs; in DecodeH323_UserInformation() local
849 bs.buf = buf; in DecodeH323_UserInformation()
850 bs.beg = bs.cur = beg; in DecodeH323_UserInformation()
851 bs.end = beg + sz; in DecodeH323_UserInformation()
852 bs.bit = 0; in DecodeH323_UserInformation()
854 return decode_seq(&bs, &h323_userinformation, (char *) uuie, 0); in DecodeH323_UserInformation()
865 struct bitstr bs; in DecodeMultimediaSystemControlMessage() local
867 bs.buf = bs.beg = bs.cur = buf; in DecodeMultimediaSystemControlMessage()
868 bs.end = buf + sz; in DecodeMultimediaSystemControlMessage()
869 bs.bit = 0; in DecodeMultimediaSystemControlMessage()
871 return decode_choice(&bs, &multimediasystemcontrolmessage, in DecodeMultimediaSystemControlMessage()