/* This function is called when user wants to send data to peer host.  */
static int winc1500_send(struct net_pkt *pkt, net_context_send_cb_t cb, int32_t timeout, void *user_data)
/* This function is called when user wants to send data to peer host.  */
static int winc1500_send(struct net_pkt *pkt, net_context_send_cb_t cb, int32_t timeout, void *user_data)
{
	struct net_context *context = pkt->context;
	SOCKET socket = (int)context->offload_context;
	int ret = 0;
	struct net_buf *buf;
	buf = net_buf_alloc(&winc1500_tx_pool, WINC1500_BUF_TIMEOUT);
	if (!buf) {
		return -ENOBUFS;
	}
	if (net_pkt_read(pkt, buf->data, net_pkt_get_len(pkt))) {
		ret = -ENOBUFS;
		goto out;
	}
	net_buf_add(buf, net_pkt_get_len(pkt));
	ret = send(socket, buf->data, buf->len, 0);
	if (ret) {
		LOG_ERR("send error %d %s!", ret, socket_error_string(ret));
		goto out;
	}
	net_pkt_unref(pkt);
out:
	net_buf_unref(buf);
	return ret;
}