summaryrefslogtreecommitdiffstats
path: root/src/net/udp.c
diff options
context:
space:
mode:
authorMichael Brown2007-01-10 03:31:38 +0100
committerMichael Brown2007-01-10 03:31:38 +0100
commitc821a7b20d8763c7d0de07e762ffae2e97f644dc (patch)
treea5f9406394d4d8fa08fb7e78a6e9b03ead6ec85e /src/net/udp.c
parentAllow an explicit network device to be specified for IP-layer (diff)
downloadipxe-c821a7b20d8763c7d0de07e762ffae2e97f644dc.tar.gz
ipxe-c821a7b20d8763c7d0de07e762ffae2e97f644dc.tar.xz
ipxe-c821a7b20d8763c7d0de07e762ffae2e97f644dc.zip
Add udp_sendto_via() to allow e.g. DHCP to transmit without first having
to set up dummy routing entries.
Diffstat (limited to 'src/net/udp.c')
-rw-r--r--src/net/udp.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/net/udp.c b/src/net/udp.c
index 32dfaec3..05e288bf 100644
--- a/src/net/udp.c
+++ b/src/net/udp.c
@@ -115,6 +115,7 @@ int udp_senddata ( struct udp_connection *conn ) {
*
* @v conn UDP connection
* @v peer Destination address
+ * @v netdev Net device via which to send (or NULL)
* @v data Data to send
* @v len Length of data
* @ret rc Return status code
@@ -125,8 +126,9 @@ int udp_senddata ( struct udp_connection *conn ) {
* call udp_senddata() and wait for its senddata() method to be
* called.
*/
-int udp_sendto ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
- const void *data, size_t len ) {
+int udp_sendto_via ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
+ struct net_device *netdev, const void *data,
+ size_t len ) {
struct udp_header *udphdr;
struct pk_buff *pkb;
@@ -162,7 +164,27 @@ int udp_sendto ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
ntohs ( udphdr->len ) );
/* Send it to the next layer for processing */
- return tcpip_tx ( pkb, &udp_protocol, peer, NULL, &udphdr->chksum );
+ return tcpip_tx ( pkb, &udp_protocol, peer, netdev, &udphdr->chksum );
+}
+
+/**
+ * Transmit data via a UDP connection to a specified address
+ *
+ * @v conn UDP connection
+ * @v peer Destination address
+ * @v data Data to send
+ * @v len Length of data
+ * @ret rc Return status code
+ *
+ * This function fills up the UDP headers and sends the data. It may
+ * be called only from within the context of an application's
+ * senddata() method; if the application wishes to send data it must
+ * call udp_senddata() and wait for its senddata() method to be
+ * called.
+ */
+int udp_sendto ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
+ const void *data, size_t len ) {
+ return udp_sendto_via ( conn, peer, NULL, data, len );
}
/**