haiku/headers/private/kernel/boot/net/NetStack.h

61 lines
1.4 KiB
C
Raw Normal View History

/*
* Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
* All rights reserved. Distributed under the terms of the MIT License.
*/
#ifndef _BOOT_NET_STACK_H
#define _BOOT_NET_STACK_H
#include <SupportDefs.h>
class EthernetInterface;
class EthernetService;
class ARPService;
class IPService;
class UDPService;
boot_net: Add TCP support Modelled after UDP, add limited TCP support to the boot net stack. The socket works by queuing received packets as well as sent packets that have not yet been ACK'ed. Some known issues are documented, especially there's only limited congestion control. I.e., we send immediately and in unlimited quantity, thus its use should be restricted to local networks, and due to a fixed window size there is potential for our socket being overrun with data packets before they are read. Some corner cases like wrapping sequence numbers may cause a timeout. The TCP implementation is based on Andrew S. Tanenbaum's "Computer Networks", 4th ed., as well as lecture notes from Prof. W. Effelsberg, the relevant RFCs and Wikipedia. The pseudo-random number Galois LFSR used for the sequence number was suggested by Endre Varga. Since the code is unlikely to get much smaller, better merge it now so that subsequent changes get easier to review. No platform actively uses TCP sockets yet, and the receiving code has been reviewed for endianness issues and should terminate okay after verifying the checksum if no sockets are open. Based on a version tested with custom code (#5240) as well as with iSCSI. Compile-tested boot_loader_openfirmware, pxehaiku-loader with gcc4 and haiku_loader with gcc2. Closes ticket #5240. Changes from #5240 proposed patch: * Various bug fixes related to queuing, some memory leaks fixed. * Never bump the sequence number when dequeuing a packet. It's done afterwards. * Don't bump the sequence number again when resending the queue or ACK'ing. * Aggressively ACK while waiting for packets. * Don't queue sent ACK-only packets. * More trace output, esp. for queue inspection. * Adapted use of TCP header flags to r38434. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38472 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-31 05:00:06 +04:00
class TCPService;
class NetStack {
private:
NetStack();
~NetStack();
status_t Init();
public:
static status_t CreateDefault();
static NetStack *Default();
static status_t ShutDown();
status_t AddEthernetInterface(EthernetInterface *interface);
EthernetInterface *GetEthernetInterface() const
{ return fEthernetInterface; }
EthernetService *GetEthernetService() const { return fEthernetService; }
ARPService *GetARPService() const { return fARPService; }
IPService *GetIPService() const { return fIPService; }
UDPService *GetUDPService() const { return fUDPService; }
boot_net: Add TCP support Modelled after UDP, add limited TCP support to the boot net stack. The socket works by queuing received packets as well as sent packets that have not yet been ACK'ed. Some known issues are documented, especially there's only limited congestion control. I.e., we send immediately and in unlimited quantity, thus its use should be restricted to local networks, and due to a fixed window size there is potential for our socket being overrun with data packets before they are read. Some corner cases like wrapping sequence numbers may cause a timeout. The TCP implementation is based on Andrew S. Tanenbaum's "Computer Networks", 4th ed., as well as lecture notes from Prof. W. Effelsberg, the relevant RFCs and Wikipedia. The pseudo-random number Galois LFSR used for the sequence number was suggested by Endre Varga. Since the code is unlikely to get much smaller, better merge it now so that subsequent changes get easier to review. No platform actively uses TCP sockets yet, and the receiving code has been reviewed for endianness issues and should terminate okay after verifying the checksum if no sockets are open. Based on a version tested with custom code (#5240) as well as with iSCSI. Compile-tested boot_loader_openfirmware, pxehaiku-loader with gcc4 and haiku_loader with gcc2. Closes ticket #5240. Changes from #5240 proposed patch: * Various bug fixes related to queuing, some memory leaks fixed. * Never bump the sequence number when dequeuing a packet. It's done afterwards. * Don't bump the sequence number again when resending the queue or ACK'ing. * Aggressively ACK while waiting for packets. * Don't queue sent ACK-only packets. * More trace output, esp. for queue inspection. * Adapted use of TCP header flags to r38434. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38472 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-31 05:00:06 +04:00
TCPService *GetTCPService() const { return fTCPService; }
private:
static NetStack *sNetStack;
EthernetInterface *fEthernetInterface;
EthernetService *fEthernetService;
ARPService *fARPService;
IPService *fIPService;
UDPService *fUDPService;
boot_net: Add TCP support Modelled after UDP, add limited TCP support to the boot net stack. The socket works by queuing received packets as well as sent packets that have not yet been ACK'ed. Some known issues are documented, especially there's only limited congestion control. I.e., we send immediately and in unlimited quantity, thus its use should be restricted to local networks, and due to a fixed window size there is potential for our socket being overrun with data packets before they are read. Some corner cases like wrapping sequence numbers may cause a timeout. The TCP implementation is based on Andrew S. Tanenbaum's "Computer Networks", 4th ed., as well as lecture notes from Prof. W. Effelsberg, the relevant RFCs and Wikipedia. The pseudo-random number Galois LFSR used for the sequence number was suggested by Endre Varga. Since the code is unlikely to get much smaller, better merge it now so that subsequent changes get easier to review. No platform actively uses TCP sockets yet, and the receiving code has been reviewed for endianness issues and should terminate okay after verifying the checksum if no sockets are open. Based on a version tested with custom code (#5240) as well as with iSCSI. Compile-tested boot_loader_openfirmware, pxehaiku-loader with gcc4 and haiku_loader with gcc2. Closes ticket #5240. Changes from #5240 proposed patch: * Various bug fixes related to queuing, some memory leaks fixed. * Never bump the sequence number when dequeuing a packet. It's done afterwards. * Don't bump the sequence number again when resending the queue or ACK'ing. * Aggressively ACK while waiting for packets. * Don't queue sent ACK-only packets. * More trace output, esp. for queue inspection. * Adapted use of TCP header flags to r38434. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38472 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-31 05:00:06 +04:00
TCPService *fTCPService;
};
// net_stack_init() creates the NetStack and calls platform_net_stack_init()
// afterwards, which is supposed to add network interfaces.
status_t net_stack_init();
status_t platform_net_stack_init();
status_t net_stack_cleanup();
#endif // _BOOT_NET_STACK_H