Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
c821a7b20d
2 değiştirilmiş dosya ile 30 ekleme ve 3 silme
  1. 5
    0
      src/include/gpxe/udp.h
  2. 25
    3
      src/net/udp.c

+ 5
- 0
src/include/gpxe/udp.h Dosyayı Görüntüle

@@ -14,6 +14,8 @@
14 14
 #include <gpxe/tcpip.h>
15 15
 #include <gpxe/if_ether.h>
16 16
 
17
+struct net_device;
18
+
17 19
 /**
18 20
  * UDP constants
19 21
  */
@@ -161,5 +163,8 @@ extern int udp_send ( struct udp_connection *conn,
161 163
 extern int udp_sendto ( struct udp_connection *conn,
162 164
 			struct sockaddr_tcpip *peer,
163 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 170
 #endif /* _GPXE_UDP_H */

+ 25
- 3
src/net/udp.c Dosyayı Görüntüle

@@ -115,6 +115,7 @@ int udp_senddata ( struct udp_connection *conn ) {
115 115
  *
116 116
  * @v conn		UDP connection
117 117
  * @v peer		Destination address
118
+ * @v netdev		Net device via which to send (or NULL)
118 119
  * @v data		Data to send
119 120
  * @v len		Length of data
120 121
  * @ret rc		Return status code
@@ -125,8 +126,9 @@ int udp_senddata ( struct udp_connection *conn ) {
125 126
  * call udp_senddata() and wait for its senddata() method to be
126 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 132
        	struct udp_header *udphdr;
131 133
 	struct pk_buff *pkb;
132 134
 
@@ -162,7 +164,27 @@ int udp_sendto ( struct udp_connection *conn, struct sockaddr_tcpip *peer,
162 164
 	       ntohs ( udphdr->len ) );
163 165
 
164 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…
İptal
Kaydet