[Asterisk-Dev] struct q931_ie
Schaefer, Mark
Mark.Schaefer at ONSTAR.com
Tue May 18 11:56:57 MST 2004
I'll try this again...
In the libpri source tree, there is the following code in pri_q931.h
/* Information element format */
typedef struct q931_ie {
#if __BYTE_ORDER == __BIG_ENDIAN
u_int8_t f:1;
u_int8_t ie:7;
#else
u_int8_t ie:7;
u_int8_t f:1;
#endif
u_int8_t len;
u_int8_t data[0];
} q931_ie;
I believe this code is incorrect. Here's why:
In q931.c, the following code exists:
if (!(ie->ie & 0xf0) && (y < 0))
mandies[MAX_MAND_IES - 1] = ie->ie;
If the length of ie is 7 bits instead of the normal 8 bits, then that
comparison should be 0x70. The same problem is exhibited when the following
might be received as a valid information element:
#define Q931_LOCKING_SHIFT 0x90
In the current code, that ie will never be parsed.
Suggest you change the code to:
typedef struct q931_ie {
u_int8_t ie:8;
u_int8_t len;
u_int8_t data[0];
} q931_ie;
Anywhere you look for ie->f, you can replace it with ie->ie & 0x80,
which does not break endianness.
BTW: The #define above is incorrect. Q931_LOCKING_SHIFT is 0x90 through
0x97 from what I've seen. Asterisk barfs on any locking shift due to some
poor coding.
Later,
Mark Schaefer
OnStar Corporation
More information about the asterisk-dev
mailing list