embkernel
 All Classes Functions Variables Typedefs Groups Pages
Net.hpp
1 //------------------------------------------------------------------------------
2 //This file is part of embKernel.
3 //See license.txt for the full license governing this code.
4 //------------------------------------------------------------------------------
5 
6 #ifndef NET_HPP_
7 #define NET_HPP_
8 
9 #include "RtosInclude.hpp"
10 #include "NetMac.hpp"
11 #include "LibDmem.hpp"
12 #include <stddef.h>
13 
14 class Net {
15  friend class NetMac;
16  friend class NetArp;
17  friend class NetIp;
18  friend class NetIcmp;
19  friend class NetUdp;
20  friend class NetUdpSocket;
21  friend class NetTcp;
22  friend class NetTcpSocket;
23  friend class NetClientDhcp;
24  friend class NetNbns;
25  friend class NetDefs;
26  friend class NetRemoteConfiguration;
27  friend class RtosInterrupt;
28 public:
29  static void init(Rtos::PRIORITY priority, size_t stackSize, NetMac* mac, LibDmem* mem);
30  static NetDefs::NET_CONFIG& getConfig();
31  static size_t getTotalMemory();
32  static size_t getFreeMemory();
33  static unsigned int getBlockCount();
34 
35 private:
36  static RtosSemaphore sSemaEvent;
37  static RtosSemaphore sSemaMemory;
38  static RtosTask* sTask;
39  static NetMac* sMac;
40  static LibDmem* sMem;
41  static NetDefs::MAC_ADDR sMacAddr;
42  static NetDefs::NET_CONFIG sConfig;
43  static Rtos::TICK sTickTimerArp;
44  static Rtos::TICK sTickTimerTcp;
45  static Rtos::TICK sTickTimerClientDhcp;
46 
47  static void loadMac(NetDefs::MAC_ADDR& macAddr);
48  static void storeMac(NetDefs::MAC_ADDR& macAddr);
49  static void loadConfig(NetDefs::NET_CONFIG& config);
50  static void storeConfig(NetDefs::NET_CONFIG& config);
51 
52  static void run(RtosTask*);
53 
54  static NetDefs::FRAME* allocFrame(size_t size);
55  static void freeFrame(NetDefs::FRAME& frame);
56  static void* resizeFrame(NetDefs::FRAME& frame, size_t size);
57  static void* resizeFrameLeft(NetDefs::FRAME& frame, size_t left);
58 
59  static void putHeader(NetDefs::FRAME& frame, const NetDefs::MAC_ADDR& dst, NetDefs::MAC_TYPE type);
60  static void flush(NetDefs::FRAME& frame, size_t len, bool discardable);
61 
62  static bool onMacEventInterrupt();
63 };
64 
65 #endif /* NET_HPP_ */