WebSocketServer test

Dependencies:   mbed

Committer:
gtk2k
Date:
Sun Apr 29 03:58:08 2012 +0000
Revision:
0:74be48b504a5
WebSocketServer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gtk2k 0:74be48b504a5 1
gtk2k 0:74be48b504a5 2 /*
gtk2k 0:74be48b504a5 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
gtk2k 0:74be48b504a5 4
gtk2k 0:74be48b504a5 5 Permission is hereby granted, free of charge, to any person obtaining a copy
gtk2k 0:74be48b504a5 6 of this software and associated documentation files (the "Software"), to deal
gtk2k 0:74be48b504a5 7 in the Software without restriction, including without limitation the rights
gtk2k 0:74be48b504a5 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
gtk2k 0:74be48b504a5 9 copies of the Software, and to permit persons to whom the Software is
gtk2k 0:74be48b504a5 10 furnished to do so, subject to the following conditions:
gtk2k 0:74be48b504a5 11
gtk2k 0:74be48b504a5 12 The above copyright notice and this permission notice shall be included in
gtk2k 0:74be48b504a5 13 all copies or substantial portions of the Software.
gtk2k 0:74be48b504a5 14
gtk2k 0:74be48b504a5 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
gtk2k 0:74be48b504a5 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
gtk2k 0:74be48b504a5 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
gtk2k 0:74be48b504a5 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
gtk2k 0:74be48b504a5 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
gtk2k 0:74be48b504a5 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
gtk2k 0:74be48b504a5 21 THE SOFTWARE.
gtk2k 0:74be48b504a5 22 */
gtk2k 0:74be48b504a5 23
gtk2k 0:74be48b504a5 24 #ifndef IPADDR_H
gtk2k 0:74be48b504a5 25 #define IPADDR_H
gtk2k 0:74be48b504a5 26
gtk2k 0:74be48b504a5 27 #include "netCfg.h"
gtk2k 0:74be48b504a5 28 #if NET_LWIP_STACK
gtk2k 0:74be48b504a5 29 typedef struct ip_addr ip_addr_t;
gtk2k 0:74be48b504a5 30 #endif
gtk2k 0:74be48b504a5 31
gtk2k 0:74be48b504a5 32 #include "stdint.h"
gtk2k 0:74be48b504a5 33
gtk2k 0:74be48b504a5 34 ///IP Address container
gtk2k 0:74be48b504a5 35 /**
gtk2k 0:74be48b504a5 36 This class is a container for an IPv4 address.
gtk2k 0:74be48b504a5 37 */
gtk2k 0:74be48b504a5 38 class IpAddr //Basically a C++ frontend to ip_addr_t
gtk2k 0:74be48b504a5 39 {
gtk2k 0:74be48b504a5 40 public:
gtk2k 0:74be48b504a5 41 #if NET_LWIP_STACK
gtk2k 0:74be48b504a5 42 IpAddr(ip_addr_t* pIp);
gtk2k 0:74be48b504a5 43 #endif
gtk2k 0:74be48b504a5 44
gtk2k 0:74be48b504a5 45 ///Initializes IP address with provided values
gtk2k 0:74be48b504a5 46 IpAddr(uint8_t ip0, uint8_t ip1, uint8_t ip2, uint8_t ip3);
gtk2k 0:74be48b504a5 47
gtk2k 0:74be48b504a5 48 ///Initializes IP address with null values
gtk2k 0:74be48b504a5 49 IpAddr();
gtk2k 0:74be48b504a5 50
gtk2k 0:74be48b504a5 51 #if NET_LWIP_STACK
gtk2k 0:74be48b504a5 52 ip_addr_t getStruct() const;
gtk2k 0:74be48b504a5 53 #endif
gtk2k 0:74be48b504a5 54
gtk2k 0:74be48b504a5 55 ///Returns IP address byte #
gtk2k 0:74be48b504a5 56 uint8_t operator[](unsigned int i) const;
gtk2k 0:74be48b504a5 57
gtk2k 0:74be48b504a5 58 ///Compares too addresses
gtk2k 0:74be48b504a5 59 /**
gtk2k 0:74be48b504a5 60 @return true if the two addresses are equal
gtk2k 0:74be48b504a5 61 */
gtk2k 0:74be48b504a5 62 bool isEq(const IpAddr& b) const;
gtk2k 0:74be48b504a5 63
gtk2k 0:74be48b504a5 64 ///Compares too addresses
gtk2k 0:74be48b504a5 65 /**
gtk2k 0:74be48b504a5 66 @return true if the two addresses are equal
gtk2k 0:74be48b504a5 67 */
gtk2k 0:74be48b504a5 68 bool operator==(const IpAddr& b) const;
gtk2k 0:74be48b504a5 69
gtk2k 0:74be48b504a5 70 ///Compares too addresses
gtk2k 0:74be48b504a5 71 /**
gtk2k 0:74be48b504a5 72 @return true if the two addresses are different
gtk2k 0:74be48b504a5 73 */
gtk2k 0:74be48b504a5 74 bool operator!=(const IpAddr& b) const;
gtk2k 0:74be48b504a5 75
gtk2k 0:74be48b504a5 76 ///Checks whether the address is null
gtk2k 0:74be48b504a5 77 /**
gtk2k 0:74be48b504a5 78 @return true if the address is null
gtk2k 0:74be48b504a5 79 */
gtk2k 0:74be48b504a5 80 bool isNull() const;
gtk2k 0:74be48b504a5 81
gtk2k 0:74be48b504a5 82 ///Checks whether the address is a broadcast address
gtk2k 0:74be48b504a5 83 /**
gtk2k 0:74be48b504a5 84 @return true if the address is a broadcast address
gtk2k 0:74be48b504a5 85 */
gtk2k 0:74be48b504a5 86 bool isBroadcast() const;
gtk2k 0:74be48b504a5 87
gtk2k 0:74be48b504a5 88 ///Checks whether the address is a multicast address
gtk2k 0:74be48b504a5 89 /**
gtk2k 0:74be48b504a5 90 @return true if the address is a multicast address
gtk2k 0:74be48b504a5 91 */
gtk2k 0:74be48b504a5 92 bool isMulticast() const;
gtk2k 0:74be48b504a5 93
gtk2k 0:74be48b504a5 94 private:
gtk2k 0:74be48b504a5 95 uint8_t m_ip[4];
gtk2k 0:74be48b504a5 96 };
gtk2k 0:74be48b504a5 97
gtk2k 0:74be48b504a5 98 #endif