2 * Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
6 #include <boot/net/NetStack.h>
12 #include <boot/net/ARP.h>
13 #include <boot/net/Ethernet.h>
14 #include <boot/net/IP.h>
15 #include <boot/net/UDP.h>
16 #include <boot/net/TCP.h>
23 NetStack
*NetStack::sNetStack
= NULL
;
27 : fEthernetInterface(NULL
),
28 fEthernetService(NULL
),
43 delete fEthernetService
;
44 delete fEthernetInterface
;
54 fEthernetService
= new(nothrow
) EthernetService
;
55 if (!fEthernetService
)
59 fARPService
= new(nothrow
) ARPService(fEthernetService
);
62 status_t error
= fARPService
->Init();
67 fIPService
= new(nothrow
) IPService(fEthernetService
, fARPService
);
70 error
= fIPService
->Init();
75 fUDPService
= new(nothrow
) UDPService(fIPService
);
78 error
= fUDPService
->Init();
84 fTCPService
= new(nothrow
) TCPService(fIPService
);
85 if (fTCPService
== NULL
)
87 error
= fTCPService
->Init();
97 NetStack::CreateDefault()
102 NetStack
*netStack
= new(nothrow
) NetStack
;
106 status_t error
= netStack
->Init();
112 sNetStack
= netStack
;
127 if (sNetStack
!= NULL
) {
136 // AddEthernetInterface
138 NetStack::AddEthernetInterface(EthernetInterface
*interface
)
143 // we support only one network interface at the moment
144 if (fEthernetInterface
)
147 if (!fEthernetService
)
150 status_t error
= fEthernetService
->Init(interface
);
154 fEthernetInterface
= interface
;
164 status_t error
= NetStack::CreateDefault();
168 return platform_net_stack_init();
175 return NetStack::ShutDown();