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