NetServices Stack source

Dependents:   HelloWorld ServoInterfaceBoardExample1 4180_Lab4

Committer:
donatien
Date:
Thu Aug 05 15:01:33 2010 +0000
Revision:
11:da4498f591ee
Parent:
9:c79fa4034f5b

        

Who changed what in which revision?

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