static void udp_op_write(struct socket * sock, message * m, __unused int blk) { int ret; struct pbuf * pbuf; debug_udp_print("socket num %ld data size %d", get_sock_num(sock), m->COUNT); pbuf = pbuf_alloc(PBUF_TRANSPORT, m->COUNT, PBUF_POOL); if (!pbuf) { ret = ENOMEM; goto write_err; } if ((ret = copy_from_user(m->m_source, pbuf->payload, m->COUNT, (cp_grant_id_t) m->IO_GRANT, 0)) != OK) { pbuf_free(pbuf); goto write_err; } if (sock->usr_flags & NWUO_RWDATONLY) ret = udp_op_send(sock, pbuf, m); else ret = udp_op_sendto(sock, pbuf, m); if (pbuf_free(pbuf) == 0) { panic("We cannot buffer udp packets yet!"); } write_err: sock_reply(sock, ret); }
static int udp_op_write(struct socket * sock, struct sock_req * req, __unused int blk) { int ret; struct pbuf * pbuf; debug_udp_print("socket num %ld data size %u", get_sock_num(sock), req->size); pbuf = pbuf_alloc(PBUF_TRANSPORT, req->size, PBUF_POOL); if (!pbuf) return ENOMEM; if ((ret = copy_from_user(req->endpt, pbuf->payload, req->size, req->grant, 0)) != OK) { pbuf_free(pbuf); return ret; } if (sock->usr_flags & NWUO_RWDATONLY) ret = udp_op_send(sock, pbuf, req->size); else ret = udp_op_sendto(sock, pbuf, req->size); if (pbuf_free(pbuf) == 0) { panic("We cannot buffer udp packets yet!"); } return ret; }