unsigned char *beg;
unsigned char *end;
unsigned char *cur;
- unsigned bit;
+ unsigned int bit;
} bitstr_t;
/* Tool Functions */
#define INC_BITS(bs,b) if(((bs)->bit+=(b))>7){(bs)->cur+=(bs)->bit>>3;(bs)->bit&=7;}
#define BYTE_ALIGN(bs) if((bs)->bit){(bs)->cur++;(bs)->bit=0;}
#define CHECK_BOUND(bs,n) if((bs)->cur+(n)>(bs)->end)return(H323_ERROR_BOUND)
-static unsigned get_len(bitstr_t * bs);
-static unsigned get_bit(bitstr_t * bs);
-static unsigned get_bits(bitstr_t * bs, unsigned b);
-static unsigned get_bitmap(bitstr_t * bs, unsigned b);
-static unsigned get_uint(bitstr_t * bs, int b);
+static unsigned int get_len(bitstr_t *bs);
+static unsigned int get_bit(bitstr_t *bs);
+static unsigned int get_bits(bitstr_t *bs, unsigned int b);
+static unsigned int get_bitmap(bitstr_t *bs, unsigned int b);
+static unsigned int get_uint(bitstr_t *bs, int b);
/* Decoder Functions */
-static int decode_nul(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_bool(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_oid(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_int(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_enum(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_bitstr(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_numstr(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_octstr(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_bmpstr(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_seq(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_seqof(bitstr_t * bs, field_t * f, char *base, int level);
-static int decode_choice(bitstr_t * bs, field_t * f, char *base, int level);
+static int decode_nul(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_bool(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_oid(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_int(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_enum(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_bitstr(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_numstr(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_octstr(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_bmpstr(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_seq(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_seqof(bitstr_t *bs, field_t *f, char *base, int level);
+static int decode_choice(bitstr_t *bs, field_t *f, char *base, int level);
/* Decoder Functions Vector */
-typedef int (*decoder_t) (bitstr_t *, field_t *, char *, int);
+typedef int (*decoder_t)(bitstr_t *, field_t *, char *, int);
static const decoder_t Decoders[] = {
decode_nul,
decode_bool,
* Functions
****************************************************************************/
/* Assume bs is aligned && v < 16384 */
-static unsigned get_len(bitstr_t * bs)
+static unsigned int get_len(bitstr_t *bs)
{
- unsigned v;
+ unsigned int v;
v = *bs->cur++;
}
/****************************************************************************/
-static unsigned get_bit(bitstr_t * bs)
+static unsigned int get_bit(bitstr_t *bs)
{
- unsigned b = (*bs->cur) & (0x80 >> bs->bit);
+ unsigned int b = (*bs->cur) & (0x80 >> bs->bit);
INC_BIT(bs);
/****************************************************************************/
/* Assume b <= 8 */
-static unsigned get_bits(bitstr_t * bs, unsigned b)
+static unsigned int get_bits(bitstr_t *bs, unsigned int b)
{
- unsigned v, l;
+ unsigned int v, l;
v = (*bs->cur) & (0xffU >> bs->bit);
l = b + bs->bit;
/****************************************************************************/
/* Assume b <= 32 */
-static unsigned get_bitmap(bitstr_t * bs, unsigned b)
+static unsigned int get_bitmap(bitstr_t *bs, unsigned int b)
{
- unsigned v, l, shift, bytes;
+ unsigned int v, l, shift, bytes;
if (!b)
return 0;
l = bs->bit + b;
if (l < 8) {
- v = (unsigned) (*bs->cur) << (bs->bit + 24);
+ v = (unsigned int)(*bs->cur) << (bs->bit + 24);
bs->bit = l;
} else if (l == 8) {
- v = (unsigned) (*bs->cur++) << (bs->bit + 24);
+ v = (unsigned int)(*bs->cur++) << (bs->bit + 24);
bs->bit = 0;
} else {
for (bytes = l >> 3, shift = 24, v = 0; bytes;
bytes--, shift -= 8)
- v |= (unsigned) (*bs->cur++) << shift;
+ v |= (unsigned int)(*bs->cur++) << shift;
if (l < 32) {
- v |= (unsigned) (*bs->cur) << shift;
+ v |= (unsigned int)(*bs->cur) << shift;
v <<= bs->bit;
} else if (l > 32) {
v <<= bs->bit;
/****************************************************************************
* Assume bs is aligned and sizeof(unsigned int) == 4
****************************************************************************/
-static unsigned get_uint(bitstr_t * bs, int b)
+static unsigned int get_uint(bitstr_t *bs, int b)
{
- unsigned v = 0;
+ unsigned int v = 0;
switch (b) {
case 4:
}
/****************************************************************************/
-static int decode_nul(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_nul(bitstr_t *bs, field_t *f, char *base, int level)
{
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
}
/****************************************************************************/
-static int decode_bool(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_bool(bitstr_t *bs, field_t *f, char *base, int level)
{
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
}
/****************************************************************************/
-static int decode_oid(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_oid(bitstr_t *bs, field_t *f, char *base, int level)
{
int len;
}
/****************************************************************************/
-static int decode_int(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_int(bitstr_t *bs, field_t *f, char *base, int level)
{
- unsigned len;
+ unsigned int len;
PRINT("%*.s%s", level * TAB_SIZE, " ", f->name);
len = get_bits(bs, 2) + 1;
BYTE_ALIGN(bs);
if (base && (f->attr & DECODE)) { /* timeToLive */
- unsigned v = get_uint(bs, len) + f->lb;
+ unsigned int v = get_uint(bs, len) + f->lb;
PRINT(" = %u", v);
- *((unsigned *) (base + f->offset)) = v;
+ *((unsigned int *)(base + f->offset)) = v;
}
bs->cur += len;
break;
}
/****************************************************************************/
-static int decode_enum(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_enum(bitstr_t *bs, field_t *f, char *base, int level)
{
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
}
/****************************************************************************/
-static int decode_bitstr(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_bitstr(bitstr_t *bs, field_t *f, char *base, int level)
{
- unsigned len;
+ unsigned int len;
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
}
/****************************************************************************/
-static int decode_numstr(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_numstr(bitstr_t *bs, field_t *f, char *base, int level)
{
- unsigned len;
+ unsigned int len;
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
}
/****************************************************************************/
-static int decode_octstr(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_octstr(bitstr_t *bs, field_t *f, char *base, int level)
{
- unsigned len;
+ unsigned int len;
PRINT("%*.s%s", level * TAB_SIZE, " ", f->name);
bs->cur[0], bs->cur[1],
bs->cur[2], bs->cur[3],
bs->cur[4] * 256 + bs->cur[5]));
- *((unsigned *) (base + f->offset)) =
+ *((unsigned int *)(base + f->offset)) =
bs->cur - bs->buf;
}
}
}
/****************************************************************************/
-static int decode_bmpstr(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_bmpstr(bitstr_t *bs, field_t *f, char *base, int level)
{
- unsigned len;
+ unsigned int len;
PRINT("%*.s%s\n", level * TAB_SIZE, " ", f->name);
}
/****************************************************************************/
-static int decode_seq(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_seq(bitstr_t *bs, field_t *f, char *base, int level)
{
- unsigned ext, bmp, i, opt, len = 0, bmp2, bmp2_len;
+ unsigned int ext, bmp, i, opt, len = 0, bmp2, bmp2_len;
int err;
field_t *son;
unsigned char *beg = NULL;
/* Get fields bitmap */
bmp = get_bitmap(bs, f->sz);
if (base)
- *(unsigned *) base = bmp;
+ *(unsigned int *)base = bmp;
/* Decode the root components */
for (i = opt = 0, son = f->fields; i < f->lb; i++, son++) {
bmp2 = get_bitmap(bs, bmp2_len);
bmp |= bmp2 >> f->sz;
if (base)
- *(unsigned *) base = bmp;
+ *(unsigned int *)base = bmp;
BYTE_ALIGN(bs);
/* Decode the extension components */
}
/****************************************************************************/
-static int decode_seqof(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_seqof(bitstr_t *bs, field_t *f, char *base, int level)
{
- unsigned count, effective_count = 0, i, len = 0;
+ unsigned int count, effective_count = 0, i, len = 0;
int err;
field_t *son;
unsigned char *beg = NULL;
/* Write Count */
if (base) {
effective_count = count > f->ub ? f->ub : count;
- *(unsigned *) base = effective_count;
- base += sizeof(unsigned);
+ *(unsigned int *)base = effective_count;
+ base += sizeof(unsigned int);
}
/* Decode nested field */
/****************************************************************************/
-static int decode_choice(bitstr_t * bs, field_t * f, char *base, int level)
+static int decode_choice(bitstr_t *bs, field_t *f, char *base, int level)
{
- unsigned type, ext, len = 0;
+ unsigned int type, ext, len = 0;
int err;
field_t *son;
unsigned char *beg = NULL;
/* Write Type */
if (base)
- *(unsigned *) base = type;
+ *(unsigned int *)base = type;
/* Check Range */
if (type >= f->ub) { /* Newer version? */
}
/****************************************************************************/
-int DecodeRasMessage(unsigned char *buf, size_t sz, RasMessage * ras)
+int DecodeRasMessage(unsigned char *buf, size_t sz, RasMessage *ras)
{
static field_t ras_message = {
FNAME("RasMessage") CHOICE, 5, 24, 32, DECODE | EXT,
/****************************************************************************/
static int DecodeH323_UserInformation(unsigned char *buf, unsigned char *beg,
- size_t sz, H323_UserInformation * uuie)
+ size_t sz, H323_UserInformation *uuie)
{
static field_t h323_userinformation = {
FNAME("H323-UserInformation") SEQ, 1, 2, 2, DECODE | EXT,
}
/****************************************************************************/
-int DecodeQ931(unsigned char *buf, size_t sz, Q931 * q931)
+int DecodeQ931(unsigned char *buf, size_t sz, Q931 *q931)
{
unsigned char *p = buf;
int len;