/** * Prepare a buffer to send to peer during handshake * * The buffer is long HSK_PAYLOAD_LEN bytes */ static void populate_hsk_buf(SBMP_Endpoint *ep, uint8_t* buf) { // [ pref_crc 1B | buf_size 2B ] buf[0] = ep->pref_cksum; buf[1] = U16_LSB(ep->buffer_size); buf[2] = U16_MSB(ep->buffer_size); }
int Iap2CtrlSessionMsg_AddParam(Iap2CtrlSessionMsg* pMsg , uint16 paramId , const uint8* pData , uint16 len) { uint8* pByte = (uint8*)pMsg; uint16 i = SWAP16(pMsg->m_Len); pByte[i++] = U16_MSB(len); //Parameter Length MSB pByte[i++] = U16_LSB(len); //Parameter Length LSB pByte[i++] = U16_MSB(paramId); //Parameter ID MSB pByte[i++] = U16_LSB(paramId); //Parameter ID LSB memcpy(&pByte[i], pData, len); //Parameter Data i += len; pMsg->m_Len = SWAP16(i); return i; }