|
@@ -1,6 +1,12 @@
|
1
|
1
|
#include <string.h>
|
2
|
2
|
#include <assert.h>
|
3
|
3
|
#include <byteswap.h>
|
|
4
|
+#include <latch.h>
|
|
5
|
+#include <gpxe/process.h>
|
|
6
|
+#include <gpxe/init.h>
|
|
7
|
+#include <gpxe/netdevice.h>
|
|
8
|
+#include <gpxe/pkbuff.h>
|
|
9
|
+#include <gpxe/ip.h>
|
4
|
10
|
#include <gpxe/tcp.h>
|
5
|
11
|
#include "uip/uip.h"
|
6
|
12
|
|
|
@@ -162,3 +168,59 @@ void uip_tcp_appcall ( void ) {
|
162
|
168
|
*/
|
163
|
169
|
void uip_udp_appcall ( void ) {
|
164
|
170
|
}
|
|
171
|
+
|
|
172
|
+/**
|
|
173
|
+ * Perform periodic processing of all TCP connections
|
|
174
|
+ *
|
|
175
|
+ * This allows TCP connections to retransmit data if necessary.
|
|
176
|
+ */
|
|
177
|
+static void tcp_periodic ( void ) {
|
|
178
|
+ struct pk_buff *pkb;
|
|
179
|
+ int i;
|
|
180
|
+
|
|
181
|
+ for ( i = 0 ; i < UIP_CONNS ; i++ ) {
|
|
182
|
+ uip_periodic ( i );
|
|
183
|
+ if ( uip_len > 0 ) {
|
|
184
|
+ pkb = alloc_pkb ( uip_len + MAX_LL_HEADER_LEN);
|
|
185
|
+ if ( ! pkb )
|
|
186
|
+ continue;
|
|
187
|
+
|
|
188
|
+ pkb_reserve ( pkb, MAX_LL_HEADER_LEN );
|
|
189
|
+ pkb_put ( pkb, uip_len );
|
|
190
|
+ memcpy ( pkb->data, uip_buf, uip_len );
|
|
191
|
+ pkb->net_protocol = &ipv4_protocol;
|
|
192
|
+
|
|
193
|
+ net_transmit ( pkb );
|
|
194
|
+ }
|
|
195
|
+ }
|
|
196
|
+}
|
|
197
|
+
|
|
198
|
+/**
|
|
199
|
+ * Single-step the TCP stack
|
|
200
|
+ *
|
|
201
|
+ * @v process TCP process
|
|
202
|
+ *
|
|
203
|
+ * This calls tcp_periodic() at regular intervals.
|
|
204
|
+ */
|
|
205
|
+static void tcp_step ( struct process *process ) {
|
|
206
|
+ static long timeout = 0;
|
|
207
|
+
|
|
208
|
+ if ( currticks() > timeout ) {
|
|
209
|
+ timeout = currticks() + ( TICKS_PER_SEC / 10 );
|
|
210
|
+ tcp_periodic ();
|
|
211
|
+ }
|
|
212
|
+
|
|
213
|
+ schedule ( process );
|
|
214
|
+}
|
|
215
|
+
|
|
216
|
+/** TCP stack process */
|
|
217
|
+static struct process tcp_process = {
|
|
218
|
+ .step = tcp_step,
|
|
219
|
+};
|
|
220
|
+
|
|
221
|
+/** Initialise the TCP stack */
|
|
222
|
+static void init_tcp ( void ) {
|
|
223
|
+ schedule ( &tcp_process );
|
|
224
|
+}
|
|
225
|
+
|
|
226
|
+INIT_FN ( INIT_PROCESS, init_tcp, NULL, NULL );
|