diff options
| author | Michael Brown | 2007-01-30 23:55:19 +0100 |
|---|---|---|
| committer | Michael Brown | 2007-01-30 23:55:19 +0100 |
| commit | 55601b2d38b9be8ccef782949a6ef97cc93faedc (patch) | |
| tree | 11fb7817af54d8f00e5f1d6f8aaa4395affc9a55 /src | |
| parent | Added blocksize for the benefit of HMAC code (diff) | |
| download | ipxe-55601b2d38b9be8ccef782949a6ef97cc93faedc.tar.gz ipxe-55601b2d38b9be8ccef782949a6ef97cc93faedc.tar.xz ipxe-55601b2d38b9be8ccef782949a6ef97cc93faedc.zip | |
Placeholder
Diffstat (limited to 'src')
| -rw-r--r-- | src/net/stream.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/net/stream.c b/src/net/stream.c new file mode 100644 index 000000000..987168178 --- /dev/null +++ b/src/net/stream.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * @file + * + * Stream API + */ + +#include <stdint.h> +#include <string.h> +#include <errno.h> +#include <gpxe/stream.h> + +/** + * Send data via connection + * + * @v app Stream application + * @v data Data to send + * @v len Length of data + * @ret rc Return status code + * + * This method should be called only in the context of an + * application's senddata() method. + */ +int stream_send ( struct stream_application *app, void *data, size_t len ) { + struct stream_connection *conn = app->conn; + int rc; + + DBGC2 ( app, "Stream %p sending %zd bytes\n", app, len ); + + /* Check connection actually exists */ + if ( ! conn ) { + DBGC ( app, "Stream %p has no connection\n", app ); + return -ENOTCONN; + } + + /* Send data via connection */ + if ( ( rc = conn->op->send ( conn, data, len ) ) != 0 ) { + DBGC ( app, "Stream %p failed to send %zd bytes: %s\n", + app, len, strerror ( rc ) ); + return rc; + } + + return 0; +} |
