Demo Application for the Celeritous Breakout Board

Dependencies:   mbed

Committer:
celeritous
Date:
Fri May 18 03:55:10 2012 +0000
Revision:
0:1a3da73fe36a
Celeritous_BreakoutBoardDemo

Who changed what in which revision?

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