This is the firmware for the LaOS - Laser Open Source project. You can use it to drive a laser cutter. For hardware and more information, look at our wiki: http://wiki.laoslaser.org

Dependencies:   EthernetNetIf mbed

Committer:
fablabtruck
Date:
Fri Jun 08 09:26:40 2012 +0000
Revision:
0:3852426a5068
svn revision 379

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fablabtruck 0:3852426a5068 1
fablabtruck 0:3852426a5068 2 /*
fablabtruck 0:3852426a5068 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
fablabtruck 0:3852426a5068 4
fablabtruck 0:3852426a5068 5 Permission is hereby granted, free of charge, to any person obtaining a copy
fablabtruck 0:3852426a5068 6 of this software and associated documentation files (the "Software"), to deal
fablabtruck 0:3852426a5068 7 in the Software without restriction, including without limitation the rights
fablabtruck 0:3852426a5068 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
fablabtruck 0:3852426a5068 9 copies of the Software, and to permit persons to whom the Software is
fablabtruck 0:3852426a5068 10 furnished to do so, subject to the following conditions:
fablabtruck 0:3852426a5068 11
fablabtruck 0:3852426a5068 12 The above copyright notice and this permission notice shall be included in
fablabtruck 0:3852426a5068 13 all copies or substantial portions of the Software.
fablabtruck 0:3852426a5068 14
fablabtruck 0:3852426a5068 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
fablabtruck 0:3852426a5068 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
fablabtruck 0:3852426a5068 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
fablabtruck 0:3852426a5068 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
fablabtruck 0:3852426a5068 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
fablabtruck 0:3852426a5068 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
fablabtruck 0:3852426a5068 21 THE SOFTWARE.
fablabtruck 0:3852426a5068 22 */
fablabtruck 0:3852426a5068 23
fablabtruck 0:3852426a5068 24 #ifndef NET_H
fablabtruck 0:3852426a5068 25 #define NET_H
fablabtruck 0:3852426a5068 26
fablabtruck 0:3852426a5068 27 class NetIf;
fablabtruck 0:3852426a5068 28 class NetTcpSocket;
fablabtruck 0:3852426a5068 29 class NetUdpSocket;
fablabtruck 0:3852426a5068 30 class NetDnsRequest;
fablabtruck 0:3852426a5068 31
fablabtruck 0:3852426a5068 32 #include <list>
fablabtruck 0:3852426a5068 33 using std::list;
fablabtruck 0:3852426a5068 34
fablabtruck 0:3852426a5068 35 /*
fablabtruck 0:3852426a5068 36 #include "host.h"
fablabtruck 0:3852426a5068 37 #include "ipaddr.h"
fablabtruck 0:3852426a5068 38 #include "netservice.h"
fablabtruck 0:3852426a5068 39 #include "if/net/netif.h"
fablabtruck 0:3852426a5068 40 #include "if/net/nettcpsocket.h"
fablabtruck 0:3852426a5068 41 #include "if/net/netudpsocket.h"
fablabtruck 0:3852426a5068 42 #include "if/net/netdnsrequest.h"
fablabtruck 0:3852426a5068 43 */
fablabtruck 0:3852426a5068 44
fablabtruck 0:3852426a5068 45 class Host;
fablabtruck 0:3852426a5068 46 class NetIf;
fablabtruck 0:3852426a5068 47 class NetTcpSocket;
fablabtruck 0:3852426a5068 48 class NetUdpSocket;
fablabtruck 0:3852426a5068 49 class NetDnsRequest;
fablabtruck 0:3852426a5068 50
fablabtruck 0:3852426a5068 51 class Net
fablabtruck 0:3852426a5068 52 {
fablabtruck 0:3852426a5068 53 private:
fablabtruck 0:3852426a5068 54 Net();
fablabtruck 0:3852426a5068 55 ~Net();
fablabtruck 0:3852426a5068 56 public:
fablabtruck 0:3852426a5068 57 static void poll(); //Poll every if & socket
fablabtruck 0:3852426a5068 58
fablabtruck 0:3852426a5068 59 static NetTcpSocket* tcpSocket(NetIf& netif);
fablabtruck 0:3852426a5068 60 static NetTcpSocket* tcpSocket(); //Socket on default if
fablabtruck 0:3852426a5068 61 static void releaseTcpSocket(NetTcpSocket* pNetTcpSocket);
fablabtruck 0:3852426a5068 62
fablabtruck 0:3852426a5068 63 static NetUdpSocket* udpSocket(NetIf& netif);
fablabtruck 0:3852426a5068 64 static NetUdpSocket* udpSocket(); //Socket on default if
fablabtruck 0:3852426a5068 65 static void releaseUdpSocket(NetUdpSocket* pNetUdpSocket);
fablabtruck 0:3852426a5068 66
fablabtruck 0:3852426a5068 67 static NetDnsRequest* dnsRequest(const char* hostname, NetIf& netif);
fablabtruck 0:3852426a5068 68 static NetDnsRequest* dnsRequest(const char* hostname); //Create a new NetDnsRequest object from default if
fablabtruck 0:3852426a5068 69
fablabtruck 0:3852426a5068 70 static NetDnsRequest* dnsRequest(Host* pHost, NetIf& netif);
fablabtruck 0:3852426a5068 71 static NetDnsRequest* dnsRequest(Host* pHost); //Create a new NetDnsRequest object from default if
fablabtruck 0:3852426a5068 72
fablabtruck 0:3852426a5068 73 static void setDefaultIf(NetIf& netif); //Deprecated
fablabtruck 0:3852426a5068 74 static void setDefaultIf(NetIf* pIf);
fablabtruck 0:3852426a5068 75 static NetIf* getDefaultIf();
fablabtruck 0:3852426a5068 76
fablabtruck 0:3852426a5068 77 protected:
fablabtruck 0:3852426a5068 78 friend class NetIf;
fablabtruck 0:3852426a5068 79 friend class NetTcpSocket;
fablabtruck 0:3852426a5068 80 friend class NetUdpSocket;
fablabtruck 0:3852426a5068 81
fablabtruck 0:3852426a5068 82 static void registerIf(NetIf* pIf);
fablabtruck 0:3852426a5068 83 static void unregisterIf(NetIf* pIf);
fablabtruck 0:3852426a5068 84
fablabtruck 0:3852426a5068 85 static void registerNetTcpSocket(NetTcpSocket* pNetTcpSocket);
fablabtruck 0:3852426a5068 86 static void unregisterNetTcpSocket(NetTcpSocket* pNetTcpSocket);
fablabtruck 0:3852426a5068 87
fablabtruck 0:3852426a5068 88 static void registerNetUdpSocket(NetUdpSocket* pNetUdpSocket);
fablabtruck 0:3852426a5068 89 static void unregisterNetUdpSocket(NetUdpSocket* pNetUdpSocket);
fablabtruck 0:3852426a5068 90
fablabtruck 0:3852426a5068 91 private:
fablabtruck 0:3852426a5068 92 static Net& net(); //Return inst of singleton
fablabtruck 0:3852426a5068 93
fablabtruck 0:3852426a5068 94 NetIf* m_defaultIf;
fablabtruck 0:3852426a5068 95
fablabtruck 0:3852426a5068 96 list<NetIf*> m_lpIf;
fablabtruck 0:3852426a5068 97 list<NetTcpSocket*> m_lpNetTcpSocket;
fablabtruck 0:3852426a5068 98 list<NetUdpSocket*> m_lpNetUdpSocket;
fablabtruck 0:3852426a5068 99 };
fablabtruck 0:3852426a5068 100
fablabtruck 0:3852426a5068 101 #endif