lpc1768

Committer:
jh1cdv00
Date:
Tue Jan 27 01:38:19 2015 +0000
Revision:
0:f35dada1dac1
lpc1768

Who changed what in which revision?

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