Browse Source

Make udp_send() call udp_sendto(), rather than vice-versa.

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
a38010fb0e
1 changed files with 10 additions and 16 deletions
  1. 10
    16
      src/net/udp.c

+ 10
- 16
src/net/udp.c View File

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
  * @v conn      UDP connection
114
  * @v conn      UDP connection
115
+ * @v peer	Destination address
115
  * @v data      Data to send
116
  * @v data      Data to send
116
  * @v len       Length of data
117
  * @v len       Length of data
117
  *
118
  *
119
  * network protocol through the sa_family field in the destination socket
120
  * network protocol through the sa_family field in the destination socket
120
  * address.
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
        	struct udp_header *udphdr;		/* UDP header */
125
        	struct udp_header *udphdr;		/* UDP header */
124
-	struct sockaddr *sock = &conn->sin;	/* Destination sockaddr */
125
 	uint16_t *dest;
126
 	uint16_t *dest;
126
 
127
 
127
 	/* Copy payload */
128
 	/* Copy payload */
134
 	 * sending it over the network
135
 	 * sending it over the network
135
 	 */
136
 	 */
136
 	udphdr = pkb_push ( conn->tx_pkb, sizeof ( *udphdr ) );
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
 		return -EAFNOSUPPORT;
140
 		return -EAFNOSUPPORT;
140
 	}
141
 	}
141
 	udphdr->dest_port = *dest;
142
 	udphdr->dest_port = *dest;
146
 	udp_dump ( udphdr );
147
 	udp_dump ( udphdr );
147
 
148
 
148
 	/* Send it to the next layer for processing */
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
  * @v conn      UDP connection
156
  * @v conn      UDP connection
156
- * @v peer      Destination address
157
  * @v data      Data to send
157
  * @v data      Data to send
158
  * @v len       Length of data
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
 /**

Loading…
Cancel
Save