static ssize_t ssl_send(struct stream *stream, const void *buffer, size_t n) { struct ssl_stream *sslv = ssl_stream_cast(stream); if (sslv->txbuf) { return -EAGAIN; } else { int error; sslv->txbuf = ofpbuf_clone_data(buffer, n); error = ssl_do_tx(stream); switch (error) { case 0: ssl_clear_txbuf(sslv); return n; case EAGAIN: leak_checker_claim(buffer); return n; default: sslv->txbuf = NULL; return -error; } } }
/* Blocking function that waits for a packet from datapath. 'pkt' will get * populated with packet data. */ int dpdk_link_recv_packet(struct ofpbuf **pkt, struct dpif_dpdk_upcall *info) { struct rte_mbuf *mbuf = NULL; uint16_t pktmbuf_len = 0; void *pktmbuf_data = NULL; DPDK_DEBUG() if (rte_ring_sc_dequeue(packet_ring, (void **)&mbuf) != 0) { return EAGAIN; } pktmbuf_data = rte_pktmbuf_mtod(mbuf, void *); pktmbuf_len = rte_pktmbuf_data_len(mbuf); rte_memcpy(info, pktmbuf_data, sizeof(*info)); pktmbuf_data = (uint8_t *)pktmbuf_data + sizeof(*info); *pkt = ofpbuf_clone_data(pktmbuf_data, pktmbuf_len - sizeof(*info)); rte_pktmbuf_free(mbuf); return 0; }
struct ofpbuf * ofpbuf_clone(const struct ofpbuf *buffer) { return ofpbuf_clone_data(buffer->data, buffer->size); }