|
|
@@ -182,13 +182,13 @@ static void udp_close ( struct udp_connection *udp, int rc ) {
|
|
182
|
182
|
*
|
|
183
|
183
|
* @v udp UDP connection
|
|
184
|
184
|
* @v iobuf I/O buffer
|
|
185
|
|
- * @v src_port Source port, or 0 to use default
|
|
|
185
|
+ * @v src Source address, or NULL to use default
|
|
186
|
186
|
* @v dest Destination address, or NULL to use default
|
|
187
|
187
|
* @v netdev Network device, or NULL to use default
|
|
188
|
188
|
* @ret rc Return status code
|
|
189
|
189
|
*/
|
|
190
|
190
|
static int udp_tx ( struct udp_connection *udp, struct io_buffer *iobuf,
|
|
191
|
|
- unsigned int src_port, struct sockaddr_tcpip *dest,
|
|
|
191
|
+ struct sockaddr_tcpip *src, struct sockaddr_tcpip *dest,
|
|
192
|
192
|
struct net_device *netdev ) {
|
|
193
|
193
|
struct udp_header *udphdr;
|
|
194
|
194
|
size_t len;
|
|
|
@@ -201,8 +201,8 @@ static int udp_tx ( struct udp_connection *udp, struct io_buffer *iobuf,
|
|
201
|
201
|
}
|
|
202
|
202
|
|
|
203
|
203
|
/* Fill in default values if not explicitly provided */
|
|
204
|
|
- if ( ! src_port )
|
|
205
|
|
- src_port = udp->local.st_port;
|
|
|
204
|
+ if ( ! src )
|
|
|
205
|
+ src = &udp->local;
|
|
206
|
206
|
if ( ! dest )
|
|
207
|
207
|
dest = &udp->peer;
|
|
208
|
208
|
|
|
|
@@ -210,7 +210,7 @@ static int udp_tx ( struct udp_connection *udp, struct io_buffer *iobuf,
|
|
210
|
210
|
udphdr = iob_push ( iobuf, sizeof ( *udphdr ) );
|
|
211
|
211
|
len = iob_len ( iobuf );
|
|
212
|
212
|
udphdr->dest = dest->st_port;
|
|
213
|
|
- udphdr->src = src_port;
|
|
|
213
|
+ udphdr->src = src->st_port;
|
|
214
|
214
|
udphdr->len = htons ( len );
|
|
215
|
215
|
udphdr->chksum = 0;
|
|
216
|
216
|
udphdr->chksum = tcpip_chksum ( udphdr, len );
|
|
|
@@ -221,7 +221,7 @@ static int udp_tx ( struct udp_connection *udp, struct io_buffer *iobuf,
|
|
221
|
221
|
ntohs ( udphdr->len ) );
|
|
222
|
222
|
|
|
223
|
223
|
/* Send it to the next layer for processing */
|
|
224
|
|
- if ( ( rc = tcpip_tx ( iobuf, &udp_protocol, dest, netdev,
|
|
|
224
|
+ if ( ( rc = tcpip_tx ( iobuf, &udp_protocol, src, dest, netdev,
|
|
225
|
225
|
&udphdr->chksum ) ) != 0 ) {
|
|
226
|
226
|
DBGC ( udp, "UDP %p could not transmit packet: %s\n",
|
|
227
|
227
|
udp, strerror ( rc ) );
|
|
|
@@ -399,22 +399,19 @@ static int udp_xfer_deliver_iob ( struct xfer_interface *xfer,
|
|
399
|
399
|
struct xfer_metadata *meta ) {
|
|
400
|
400
|
struct udp_connection *udp =
|
|
401
|
401
|
container_of ( xfer, struct udp_connection, xfer );
|
|
402
|
|
- struct sockaddr_tcpip *src;
|
|
|
402
|
+ struct sockaddr_tcpip *src = NULL;
|
|
403
|
403
|
struct sockaddr_tcpip *dest = NULL;
|
|
404
|
404
|
struct net_device *netdev = NULL;
|
|
405
|
|
- unsigned int src_port = 0;
|
|
406
|
405
|
|
|
407
|
406
|
/* Apply xfer metadata */
|
|
408
|
407
|
if ( meta ) {
|
|
409
|
408
|
src = ( struct sockaddr_tcpip * ) meta->src;
|
|
410
|
|
- if ( src )
|
|
411
|
|
- src_port = src->st_port;
|
|
412
|
409
|
dest = ( struct sockaddr_tcpip * ) meta->dest;
|
|
413
|
410
|
netdev = meta->netdev;
|
|
414
|
411
|
}
|
|
415
|
412
|
|
|
416
|
413
|
/* Transmit data, if possible */
|
|
417
|
|
- udp_tx ( udp, iobuf, src_port, dest, netdev );
|
|
|
414
|
+ udp_tx ( udp, iobuf, src, dest, netdev );
|
|
418
|
415
|
|
|
419
|
416
|
return 0;
|
|
420
|
417
|
}
|