src/pomp_prot.c
static void pomp_prot_decode_header(struct pomp_prot *prot)
{
	uint32_t d = 0;

	/* Decode header inside structure */
	memcpy(&prot->header.magic[0], prot->headerbuf, 4);
	memcpy(&d, &prot->headerbuf[4], 4);
	prot->header.msgid = POMP_LE32TOH(d);
	memcpy(&d, &prot->headerbuf[8], 4);
	prot->header.size = POMP_LE32TOH(d);

	/* Check header and setup payload decoding */
	if (prot->header.size < POMP_PROT_HEADER_SIZE) {
		POMP_LOGW("Bad header size : %d", prot->header.size);
		prot->state = POMP_PROT_STATE_HEADER_MAGIC_0;
	} else if (pomp_prot_alloc_msg(prot, prot->header.msgid,
			prot->header.size) < 0) {
		prot->state = POMP_PROT_STATE_HEADER_MAGIC_0;
	} else {
		/* Copy header in message buffer */
		prot->offpayload = 0;
		pomp_buffer_write(prot->msg->buf, &prot->offpayload,
				prot->headerbuf, POMP_PROT_HEADER_SIZE);
		prot->state = POMP_PROT_STATE_PAYLOAD;
	}
}
/**
 * Decode the header of the message.
 * @param prot : protocol decoder.
 *
 * @remarks in case of error during header decoding or message allocation,
 * the decoder state is reseted.
 */
Decode the header of the message.
@param prot : protocol decoder.

@remarks in case of error during header decoding or message allocation,
the decoder state is reseted.
Decode the header of the message . @param prot : protocol decoder . @remarks in case of error during header decoding or message allocation the decoder state is reseted .
static void pomp_prot_decode_header(struct pomp_prot *prot)
{
	uint32_t d = 0;
	memcpy(&prot->header.magic[0], prot->headerbuf, 4);
	memcpy(&d, &prot->headerbuf[4], 4);
	prot->header.msgid = POMP_LE32TOH(d);
	memcpy(&d, &prot->headerbuf[8], 4);
	prot->header.size = POMP_LE32TOH(d);
	if (prot->header.size < POMP_PROT_HEADER_SIZE) {
		POMP_LOGW("Bad header size : %d", prot->header.size);
		prot->state = POMP_PROT_STATE_HEADER_MAGIC_0;
	} else if (pomp_prot_alloc_msg(prot, prot->header.msgid,
			prot->header.size) < 0) {
		prot->state = POMP_PROT_STATE_HEADER_MAGIC_0;
	} else {
		prot->offpayload = 0;
		pomp_buffer_write(prot->msg->buf, &prot->offpayload,
				prot->headerbuf, POMP_PROT_HEADER_SIZE);
		prot->state = POMP_PROT_STATE_PAYLOAD;
	}
}
static void pomp_prot_decode_header ( struct pomp_prot * prot ) { uint32_t d = 0 ; memcpy ( & prot -> header . magic [ 0 ] , prot -> headerbuf , 4 ) ; memcpy ( & d , & prot -> headerbuf [ 4 ] , 4 ) ; prot -> header . msgid = POMP_LE32TOH ( d ) ; memcpy ( & d , & prot -> headerbuf [ 8 ] , 4 ) ; prot -> header . size = POMP_LE32TOH ( d ) ; if ( prot -> header . size < POMP_PROT_HEADER_SIZE ) { POMP_LOGW ( " " , prot -> header . size ) ; prot -> state = POMP_PROT_STATE_HEADER_MAGIC_0 ; } else if ( pomp_prot_alloc_msg ( prot , prot -> header . msgid , prot -> header . size ) < 0 ) { prot -> state = POMP_PROT_STATE_HEADER_MAGIC_0 ; } else { prot -> offpayload = 0 ; pomp_buffer_write ( prot -> msg -> buf , & prot -> offpayload , prot -> headerbuf , POMP_PROT_HEADER_SIZE ) ; prot -> state = POMP_PROT_STATE_PAYLOAD ; } }
Decode the header of the message.
Decode the header of the message .
/* Decode header inside structure */ /* Check header and setup payload decoding */ /* Copy header in message buffer */