I'm not sure I follow, that function does:
{
	memcpy(buffer, (const uint8_t *)&msg->magic, MAVLINK_NUM_NON_PAYLOAD_BYTES + (uint16_t)msg->len);
	return MAVLINK_NUM_NON_PAYLOAD_BYTES + (uint16_t)msg->len;
}