embkernel
 All Classes Functions Variables Typedefs Groups Pages
NetUdp.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_UDP_HPP_
7 #define NET_UDP_HPP_
8 
9 #include "NetDefs.hpp"
10 #include "RtosSemaphore.hpp"
11 #include "LibLinkedList.hpp"
12 
13 class NetUdpSocket;
14 
15 class NetUdp {
16  friend class NetIp;
17  friend class NetClientDhcp;
18  friend class NetNbns;
19  friend class NetUdpSocket;
20  friend class NetRemoteConfiguration;
21 
22 private:
23  static LibLinkedList<NetUdpSocket> sSocketList;
24  static RtosSemaphore sSema;
25 
26  static void processFrame(NetDefs::FRAME& frame, NetDefs::UDP_HEADER& header, int len);
27  static void putHeader(NetDefs::FRAME& frame, const NetDefs::MAC_ADDR& macDst, const NetDefs::IP_ADDR& dstAddr, uint16_t srcPort, uint16_t dstPort,
28  int dataLen);
29  static void flush(NetDefs::FRAME& frame, int dataLen, bool discardable);
30  static void swapHeader(NetDefs::UDP_HEADER& header);
31 
32  static NetUdpSocket* findMatchingSocket(NetDefs::UDP_PORT port);
33  static void addSocket(NetUdpSocket& socket);
34  static void removeSocket(NetUdpSocket& socket);
35 };
36 
37 #endif /* NET_UDP_HPP_ */