summaryrefslogtreecommitdiffstats
path: root/src/net/udp.c
diff options
context:
space:
mode:
authorNikhil Chandru Rao2006-07-19 18:25:23 +0200
committerNikhil Chandru Rao2006-07-19 18:25:23 +0200
commitab577e1a3a45c4e23912523d30d5822eeb532258 (patch)
treeb11671988c2f49de37f516fbd9cd2a79cb7e139d /src/net/udp.c
parentAdded macros for generating static DHCP options (diff)
downloadipxe-ab577e1a3a45c4e23912523d30d5822eeb532258.tar.gz
ipxe-ab577e1a3a45c4e23912523d30d5822eeb532258.tar.xz
ipxe-ab577e1a3a45c4e23912523d30d5822eeb532258.zip
The following edits were made: \
1. Updated UDP send data code\ 2. Corrected internet checksum\ 3. Moved udp_buffer() and udp_buflen() to udp.c from udp.h
Diffstat (limited to 'src/net/udp.c')
-rw-r--r--src/net/udp.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/net/udp.c b/src/net/udp.c
index b84d5161..0fca99a4 100644
--- a/src/net/udp.c
+++ b/src/net/udp.c
@@ -18,6 +18,14 @@
* UDP protocol
*/
+/**
+ * List of registered UDP connections
+ */
+static LIST_HEAD ( udp_conns );
+
+/**
+ * Some utility functions
+ */
static inline void copy_sockaddr ( struct sockaddr *source, struct sockaddr *dest ) {
memcpy ( dest, source, sizeof ( *dest ) );
}
@@ -98,7 +106,27 @@ int udp_buf_alloc ( struct udp_connection *conn, size_t len ) {
}
/**
- * Send data via a UDP connection
+ * User request to send data via a UDP connection
+ *
+ * @v conn UDP connection
+ *
+ * This function allocates buffer space and invokes the function's senddata()
+ * callback. The callback may use the buffer space
+ */
+int udp_senddata ( struct udp_connection *conn ) {
+ conn->tx_pkb = pkb_alloc ( UDP_MAX_TXPKB );
+ if ( conn->tx_pkb == NULL ) {
+ DBG ( "Error allocating packet buffer of length %d\n",
+ UDP_MAX_TXPKB );
+ return -ENOMEM;
+ }
+ conn->udp_op->senddata ( conn, conn->tx_pkb, pkb_len ( conn->tx_pkb ) );
+ return 0;
+}
+
+
+/**
+ * Transmit data via a UDP connection
*
* @v conn UDP connection
* @v data Data to send
@@ -124,7 +152,7 @@ int udp_send ( struct udp_connection *conn, const void *data, size_t len ) {
/* Reserve space for the headers and copy contents */
pkb_reserve ( conn->tx_pkb, UDP_MAX_HLEN );
- memcpy ( pkb_put ( conn->tx_pkb, len ), data, len );
+ memmove ( pkb_put ( conn->tx_pkb, len ), data, len );
}
/*