diff options
| author | Michael Brown | 2006-04-30 04:08:42 +0200 |
|---|---|---|
| committer | Michael Brown | 2006-04-30 04:08:42 +0200 |
| commit | 9c9208a13255ceebd59bd564eb2aa50a0761899d (patch) | |
| tree | bf07949f925cfaee2dda8f82bcb0f665ccc63cbc | |
| parent | Consistency (diff) | |
| download | ipxe-9c9208a13255ceebd59bd564eb2aa50a0761899d.tar.gz ipxe-9c9208a13255ceebd59bd564eb2aa50a0761899d.tar.xz ipxe-9c9208a13255ceebd59bd564eb2aa50a0761899d.zip | |
Put the TCP connection periodic processing in tcp.c, where it belongs.
| -rw-r--r-- | src/arch/i386/include/latch.h | 2 | ||||
| -rw-r--r-- | src/include/gpxe/ip.h | 10 | ||||
| -rw-r--r-- | src/net/tcp.c | 62 |
3 files changed, 66 insertions, 8 deletions
diff --git a/src/arch/i386/include/latch.h b/src/arch/i386/include/latch.h index 38a8bd211..5000d5826 100644 --- a/src/arch/i386/include/latch.h +++ b/src/arch/i386/include/latch.h @@ -7,4 +7,6 @@ * sleep_latch and the definitions of it's length here... */ +extern unsigned long currticks ( void ); + #endif /* LATCH_H */ diff --git a/src/include/gpxe/ip.h b/src/include/gpxe/ip.h index 94f906b58..44aee7d11 100644 --- a/src/include/gpxe/ip.h +++ b/src/include/gpxe/ip.h @@ -5,16 +5,10 @@ * * IP protocol * - * This file defines the gPXE IP API. - * */ -#include <gpxe/in.h> +struct net_protocol; -extern void set_ipaddr ( struct in_addr address ); -extern void set_netmask ( struct in_addr address ); -extern void set_gateway ( struct in_addr address ); -extern void init_tcpip ( void ); -extern void run_tcpip ( void ); +extern struct net_protocol ipv4_protocol; #endif /* _GPXE_IP_H */ diff --git a/src/net/tcp.c b/src/net/tcp.c index 69fe95f5d..50c9731fe 100644 --- a/src/net/tcp.c +++ b/src/net/tcp.c @@ -1,6 +1,12 @@ #include <string.h> #include <assert.h> #include <byteswap.h> +#include <latch.h> +#include <gpxe/process.h> +#include <gpxe/init.h> +#include <gpxe/netdevice.h> +#include <gpxe/pkbuff.h> +#include <gpxe/ip.h> #include <gpxe/tcp.h> #include "uip/uip.h" @@ -162,3 +168,59 @@ void uip_tcp_appcall ( void ) { */ void uip_udp_appcall ( void ) { } + +/** + * Perform periodic processing of all TCP connections + * + * This allows TCP connections to retransmit data if necessary. + */ +static void tcp_periodic ( void ) { + struct pk_buff *pkb; + int i; + + for ( i = 0 ; i < UIP_CONNS ; i++ ) { + uip_periodic ( i ); + if ( uip_len > 0 ) { + pkb = alloc_pkb ( uip_len + MAX_LL_HEADER_LEN); + if ( ! pkb ) + continue; + + pkb_reserve ( pkb, MAX_LL_HEADER_LEN ); + pkb_put ( pkb, uip_len ); + memcpy ( pkb->data, uip_buf, uip_len ); + pkb->net_protocol = &ipv4_protocol; + + net_transmit ( pkb ); + } + } +} + +/** + * Single-step the TCP stack + * + * @v process TCP process + * + * This calls tcp_periodic() at regular intervals. + */ +static void tcp_step ( struct process *process ) { + static long timeout = 0; + + if ( currticks() > timeout ) { + timeout = currticks() + ( TICKS_PER_SEC / 10 ); + tcp_periodic (); + } + + schedule ( process ); +} + +/** TCP stack process */ +static struct process tcp_process = { + .step = tcp_step, +}; + +/** Initialise the TCP stack */ +static void init_tcp ( void ) { + schedule ( &tcp_process ); +} + +INIT_FN ( INIT_PROCESS, init_tcp, NULL, NULL ); |
