12Oct2012MbedLab

Dependents:   Lab3_VoiceMeter

Fork of EthernetNetIf by Donatien Garnier

Committer:
donatien
Date:
Thu Aug 05 15:09:22 2010 +0000
Revision:
5:bc7df6da7589
Child:
6:22ce63eddd2b

        

Who changed what in which revision?

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