|
@@ -109,9 +109,10 @@ int udp_senddata ( struct udp_connection *conn ) {
|
109
|
109
|
}
|
110
|
110
|
|
111
|
111
|
/**
|
112
|
|
- * Transmit data via a UDP connection
|
|
112
|
+ * Transmit data via a UDP connection to a specified address
|
113
|
113
|
*
|
114
|
114
|
* @v conn UDP connection
|
|
115
|
+ * @v peer Destination address
|
115
|
116
|
* @v data Data to send
|
116
|
117
|
* @v len Length of data
|
117
|
118
|
*
|
|
@@ -119,9 +120,9 @@ int udp_senddata ( struct udp_connection *conn ) {
|
119
|
120
|
* network protocol through the sa_family field in the destination socket
|
120
|
121
|
* address.
|
121
|
122
|
*/
|
122
|
|
-int udp_send ( struct udp_connection *conn, const void *data, size_t len ) {
|
|
123
|
+int udp_sendto ( struct udp_connection *conn, struct sockaddr *peer,
|
|
124
|
+ const void *data, size_t len ) {
|
123
|
125
|
struct udp_header *udphdr; /* UDP header */
|
124
|
|
- struct sockaddr *sock = &conn->sin; /* Destination sockaddr */
|
125
|
126
|
uint16_t *dest;
|
126
|
127
|
|
127
|
128
|
/* Copy payload */
|
|
@@ -134,8 +135,8 @@ int udp_send ( struct udp_connection *conn, const void *data, size_t len ) {
|
134
|
135
|
* sending it over the network
|
135
|
136
|
*/
|
136
|
137
|
udphdr = pkb_push ( conn->tx_pkb, sizeof ( *udphdr ) );
|
137
|
|
- if ( (dest = dest_port ( sock ) ) == NULL ) {
|
138
|
|
- DBG ( "Network family %d not supported\n", sock->sa_family );
|
|
138
|
+ if ( (dest = dest_port ( peer ) ) == NULL ) {
|
|
139
|
+ DBG ( "Network family %d not supported\n", peer->sa_family );
|
139
|
140
|
return -EAFNOSUPPORT;
|
140
|
141
|
}
|
141
|
142
|
udphdr->dest_port = *dest;
|
|
@@ -146,25 +147,18 @@ int udp_send ( struct udp_connection *conn, const void *data, size_t len ) {
|
146
|
147
|
udp_dump ( udphdr );
|
147
|
148
|
|
148
|
149
|
/* Send it to the next layer for processing */
|
149
|
|
- return trans_tx ( conn->tx_pkb, &udp_protocol, sock );
|
|
150
|
+ return trans_tx ( conn->tx_pkb, &udp_protocol, peer );
|
150
|
151
|
}
|
151
|
152
|
|
152
|
153
|
/**
|
153
|
|
- * Send data to a specified address
|
|
154
|
+ * Transmit data via a UDP connection to a specified address
|
154
|
155
|
*
|
155
|
156
|
* @v conn UDP connection
|
156
|
|
- * @v peer Destination address
|
157
|
157
|
* @v data Data to send
|
158
|
158
|
* @v len Length of data
|
159
|
159
|
*/
|
160
|
|
-int udp_sendto ( struct udp_connection *conn, struct sockaddr *peer,
|
161
|
|
- const void *data, size_t len ) {
|
162
|
|
- struct sockaddr tempsock;
|
163
|
|
- copy_sockaddr ( &conn->sin, &tempsock );
|
164
|
|
- copy_sockaddr ( peer, &conn->sin );
|
165
|
|
- int rc = udp_send ( conn, data, len );
|
166
|
|
- copy_sockaddr ( &tempsock, &conn->sin );
|
167
|
|
- return rc;
|
|
160
|
+int udp_send ( struct udp_connection *conn, const void *data, size_t len ) {
|
|
161
|
+ return udp_sendto ( conn, &conn->sin, data, len );
|
168
|
162
|
}
|
169
|
163
|
|
170
|
164
|
/**
|