hi all,

is there anyone able to explain the changes of patch 661 inside libq931/callref.c ?


OLD VERSION:

void q931_make_callref(
        void *void_buf,
        int size,
        q931_callref callref,
        enum q931_callref_flag direction)
{
        assert(void_buf);
        assert(direction == Q931_CALLREF_FLAG_FROM_ORIGINATING_SIDE ||
               direction == Q931_CALLREF_FLAG_TO_ORIGINATING_SIDE);

        int i;
        __u8 *buf = void_buf;

        for (i=0; i<size; i++) {
                buf[i] = callref & (0xFF << ((size-i-1) * 8));

                if (i == 0 &&
                    direction == Q931_CALLREF_FLAG_TO_ORIGINATING_SIDE)
                        buf[i] |= 0x80;
        }
}


ACTUAL VERSION(patch 661):

void q931_make_callref(
        void *buf,
        int len,
        q931_callref callref,
        enum q931_callref_flag direction)
{
        assert(buf);
        assert(direction == Q931_CALLREF_FLAG_FROM_ORIGINATING_SIDE ||
               direction == Q931_CALLREF_FLAG_TO_ORIGINATING_SIDE);
        assert(len <= sizeof(q931_callref));

        union { q931_callref cr; __u8 raw[sizeof(q931_callref)]; } cu;

        cu.cr = callref;

        int i;
        for (i=0; i<len; i++) {
#if __BYTE_ORDER == __LITTLE_ENDIAN
                ((__u8 *)buf)[i] = cu.raw[len - 1 - i];
#else
                ((__u8 *)buf)[i] = cu.raw[i];
#endif
        }

        if (direction == Q931_CALLREF_FLAG_TO_ORIGINATING_SIDE)
                *((__u8 *)buf) |= 0x80;
}


...as this patch breaks at least audio from asterisk to nt-mode phone on ppc


thx
Dirk

_______________________________________________
Visdn-hackers mailing list
[email protected]
https://mailman.uli.it/mailman/listinfo/visdn-hackers

Reply via email to