subsys/net/lib/mqtt/mqtt.c
/**
 * Linearizes an IP fragmented packet
 *
 * @param [in] ctx MQTT context structure
 * @param [in] rx RX IP stack packet
 * @param [in] min_size Min message size allowed. This allows us to exit if the
 * rx packet is shorter than the expected msg size
 *
 * @retval Data buffer
 * @retval NULL on error
 */
Linearizes an IP fragmented packet
@param [in] ctx MQTT context structure
@param [in] rx RX IP stack packet
@param [in] min_size Min message size allowed. This allows us to exit if the
rx packet is shorter than the expected msg size

@retval Data buffer
@retval NULL on error
Linearizes an IP fragmented packet @param [ in ] ctx MQTT context structure @param [ in ] rx RX IP stack packet @param [ in ] min_size Min message size allowed . This allows us to exit if the rx packet is shorter than the expected msg size @retval Data buffer @retval NULL on error
static
struct net_buf *mqtt_linearize_packet(struct mqtt_ctx *ctx, struct net_pkt *rx,
				      u16_t min_size)
{
	struct net_buf *data = NULL;
	u16_t data_len;
	u16_t offset;
	int rc;
	data_len = net_pkt_appdatalen(rx);
	if (data_len < min_size || data_len > CONFIG_MQTT_MSG_MAX_SIZE) {
		return NULL;
	}
	data = net_buf_alloc(&mqtt_msg_pool, ctx->net_timeout);
	if (data == NULL) {
		return NULL;
	}
	offset = net_pkt_get_len(rx) - data_len;
	rc = net_frag_linear_copy(data, rx->frags, offset, data_len);
	if (rc != 0) {
		goto exit_error;
	}
	return data;
exit_error:
	net_pkt_frag_unref(data);
	return NULL;
}
static struct net_buf * mqtt_linearize_packet ( struct mqtt_ctx * ctx , struct net_pkt * rx , u16_t min_size ) { struct net_buf * data = NULL ; u16_t data_len ; u16_t offset ; int rc ; data_len = net_pkt_appdatalen ( rx ) ; if ( data_len < min_size || data_len > CONFIG_MQTT_MSG_MAX_SIZE ) { return NULL ; } data = net_buf_alloc ( & mqtt_msg_pool , ctx -> net_timeout ) ; if ( data == NULL ) { return NULL ; } offset = net_pkt_get_len ( rx ) - data_len ; rc = net_frag_linear_copy ( data , rx -> frags , offset , data_len ) ; if ( rc != 0 ) { goto exit_error ; } return data ; exit_error : net_pkt_frag_unref ( data ) ; return NULL ; }
Linearizes an IP fragmented packet
 @param [in] ctx MQTT context structure
 @param [in] rx RX IP stack packet
 @param [in] min_size Min message size allowed.
Linearizes an IP fragmented packet @param [ in ] ctx MQTT context structure @param [ in ] rx RX IP stack packet @param [ in ] min_size Min message size allowed .
/* CONFIG_MQTT_MSG_MAX_SIZE is defined via Kconfig. So here it's
	 * determined if the input packet could fit our data buffer or if
	 * it has the expected size.
	 */