Browse Source

Add udp_sendto_via() to allow e.g. DHCP to transmit without first having

to set up dummy routing entries.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
c821a7b20d
2 changed files with 30 additions and 3 deletions
  1. 5
    0
      src/include/gpxe/udp.h
  2. 25
    3
      src/net/udp.c

+ 5
- 0
src/include/gpxe/udp.h View File

14
 #include <gpxe/tcpip.h>
14
 #include <gpxe/tcpip.h>
15
 #include <gpxe/if_ether.h>
15
 #include <gpxe/if_ether.h>
16
 
16
 
17
+struct net_device;
18
+
17
 /**
19
 /**
18
  * UDP constants
20
  * UDP constants
19
  */
21
  */
161
 extern int udp_sendto ( struct udp_connection *conn,
163
 extern int udp_sendto ( struct udp_connection *conn,
162
 			struct sockaddr_tcpip *peer,
164
 			struct sockaddr_tcpip *peer,
163
 			const void *data, size_t len );
165
 			const void *data, size_t len );
166
+int udp_sendto_via ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
167
+		     struct net_device *netdev, const void *data,
168
+		     size_t len );
164
 
169
 
165
 #endif /* _GPXE_UDP_H */
170
 #endif /* _GPXE_UDP_H */

+ 25
- 3
src/net/udp.c View File

115
  *
115
  *
116
  * @v conn		UDP connection
116
  * @v conn		UDP connection
117
  * @v peer		Destination address
117
  * @v peer		Destination address
118
+ * @v netdev		Net device via which to send (or NULL)
118
  * @v data		Data to send
119
  * @v data		Data to send
119
  * @v len		Length of data
120
  * @v len		Length of data
120
  * @ret rc		Return status code
121
  * @ret rc		Return status code
125
  * call udp_senddata() and wait for its senddata() method to be
126
  * call udp_senddata() and wait for its senddata() method to be
126
  * called.
127
  * called.
127
  */
128
  */
128
-int udp_sendto ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
129
-		 const void *data, size_t len ) {
129
+int udp_sendto_via ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
130
+		     struct net_device *netdev, const void *data,
131
+		     size_t len ) {
130
        	struct udp_header *udphdr;
132
        	struct udp_header *udphdr;
131
 	struct pk_buff *pkb;
133
 	struct pk_buff *pkb;
132
 
134
 
162
 	       ntohs ( udphdr->len ) );
164
 	       ntohs ( udphdr->len ) );
163
 
165
 
164
 	/* Send it to the next layer for processing */
166
 	/* Send it to the next layer for processing */
165
-	return tcpip_tx ( pkb, &udp_protocol, peer, NULL, &udphdr->chksum );
167
+	return tcpip_tx ( pkb, &udp_protocol, peer, netdev, &udphdr->chksum );
168
+}
169
+
170
+/**
171
+ * Transmit data via a UDP connection to a specified address
172
+ *
173
+ * @v conn		UDP connection
174
+ * @v peer		Destination address
175
+ * @v data		Data to send
176
+ * @v len		Length of data
177
+ * @ret rc		Return status code
178
+ *
179
+ * This function fills up the UDP headers and sends the data.  It may
180
+ * be called only from within the context of an application's
181
+ * senddata() method; if the application wishes to send data it must
182
+ * call udp_senddata() and wait for its senddata() method to be
183
+ * called.
184
+ */
185
+int udp_sendto ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
186
+		 const void *data, size_t len ) {
187
+	return udp_sendto_via ( conn, peer, NULL, data, len );
166
 }
188
 }
167
 
189
 
168
 /**
190
 /**

Loading…
Cancel
Save