buf is the data buffer you are reading the q931 message into.
pTrunk->L3Buf is the buffer in the trunk that you are reading it from it has the last received message in it.


*Mes is a pointer being declared to point at &buf[Q931L2HeaderSpace];

buf is a raw buffer
Q931L2HeaderSpace is a constant of the 921 header space which i think is 2 bytes.

so it's a pointer to the beginning of the actual message which is 2 bytes into buf.



On Tue, Jun 24, 2008 at 12:33 AM, Michael Collins <mcollins@fcnetwork.com> wrote:

I have question about the two different buffers that are accessed in this function:

 

/*****************************************************************************

 

  Function:     Q931Rx23

 

  Description:  Receive message from layer 2 (LAPD). Receiving a message

                is always done in 2 steps. First the message must be

                interpreted and translated to a static struct. Secondly

                the message is processed and responded to.

 

                The Q.931 message contains a static header that is

                interpreted in this function. The rest is interpreted

                in a sub function according to mestype.

 

  Parameters:   pTrunk  [IN]    Ptr to trunk info.

                buf     [IN]    Ptr to buffer containing message.

                Size    [IN]    Size of message.

 

  Return Value: Error Code. 0 = No Error, < 0 :error, > 0 : Warning

                see q931errors.h for details.

 

*****************************************************************************/

L3INT Q931Rx23(Q931_TrunkInfo_t *pTrunk, L3UCHAR * buf, L3INT Size)

{

    L3UCHAR *Mes = &buf[Q931L2HeaderSpace];

    L3INT RetCode = Q931E_NO_ERROR;

    Q931mes_Generic *m = (Q931mes_Generic *) pTrunk->L3Buf;

    L3INT ISize;

 

    L3INT IOff = 0;

 

    /* Protocol Discriminator */

    m->ProtDisc = Mes[IOff++];

 

    /* CRV */

    m->CRVFlag = Mes[IOff + 1] & 0x80;

    m->CRV = Q931Uie_CRV(pTrunk, Mes, m->buf, &IOff, &ISize);

 

    /* Message Type */

    m->MesType = Mes[IOff++];

 

    /* Call table proc to unpack codec message */

    /*debug */

    printf("\n\nQ931Rx23-  Dialect: %d, MsgType: %d\nCause: [%x]\n",pTrunk->Dialect,m->MesType,m->Cause);

    printf("Message: %s\n",Mes);

    RetCode = Q931Umes[pTrunk->Dialect][m->MesType](pTrunk, Mes, (Q931mes_Generic *)pTrunk->L3Buf, Q931L4HeaderSpace + IOff , Size - Q931L4HeaderSpace - IOff + 1);

 

    if(RetCode >= Q931E_NO_ERROR)

    {

        RetCode = Q931Proc[pTrunk->Dialect][m->MesType](pTrunk, pTrunk->L3Buf, 2);

    }

 

    return RetCode;

}

 

What's the difference between pTrunk->L3Buf and *buf in this function?  I'm trying to understand where the q931 message is coming from as it is passed up the stack from layer 2 to layer 3.  I may have found a clue about the phantom cause IE issue but I won't know for sure until I know what exactly I'm looking at.

 

Also, can you tell me what is accomplished by creating *Mes as opposed to *m?  I am familiar with the Q931mes_Generic data struct but the line:

    L3UCHAR *Mes = &buf[Q931L2HeaderSpace];

… is confusing me.  What does that do?

 

Thanks for your time!!

 

-MC


_______________________________________________
Freeswitch-dev mailing list
Freeswitch-dev@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
http://www.freeswitch.org




--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale@hotmail.com
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org
pstn:213-799-1400