Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of UIPEthernet by
IPAddress.cpp
00001 /* 00002 IPAddress.cpp - Base class that provides IPAddress 00003 Copyright (c) 2011 Adrian McEwen. All right reserved. 00004 00005 Modified (ported to mbed) by Zoltan Hudak <hudakz@inbox.com> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 #include "mbed.h" 00022 #include "IPAddress.h" 00023 00024 /** 00025 * @brief 00026 * @note 00027 * @param 00028 * @retval 00029 */ 00030 IPAddress::IPAddress(void) { 00031 memset(_address, 0, sizeof(_address)); 00032 } 00033 00034 /** 00035 * @brief 00036 * @note 00037 * @param 00038 * @retval 00039 */ 00040 IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet) { 00041 _address[0] = first_octet; 00042 _address[1] = second_octet; 00043 _address[2] = third_octet; 00044 _address[3] = fourth_octet; 00045 } 00046 00047 /** 00048 * @brief 00049 * @note 00050 * @param 00051 * @retval 00052 */ 00053 IPAddress::IPAddress(uint32_t address) { 00054 memcpy(_address, &address, sizeof(_address)); 00055 } 00056 00057 /** 00058 * @brief 00059 * @note 00060 * @param 00061 * @retval 00062 */ 00063 IPAddress::IPAddress(const uint8_t* address) { 00064 memcpy(_address, address, sizeof(_address)); 00065 } 00066 00067 /** 00068 * @brief 00069 * @note 00070 * @param 00071 * @retval 00072 */ 00073 IPAddress &IPAddress::operator=(const uint8_t* address) { 00074 memcpy(_address, address, sizeof(_address)); 00075 return *this; 00076 } 00077 00078 /** 00079 * @brief 00080 * @note 00081 * @param 00082 * @retval 00083 */ 00084 IPAddress &IPAddress::operator=(uint32_t address) { 00085 memcpy(_address, (const uint8_t*) &address, sizeof(_address)); 00086 return *this; 00087 } 00088 00089 /** 00090 * @brief 00091 * @note 00092 * @param 00093 * @retval 00094 */ 00095 bool IPAddress::operator==(const uint8_t* addr) const 00096 { 00097 return memcmp(addr, _address, sizeof(_address)) == 0; 00098 }
Generated on Tue Jul 12 2022 18:10:58 by
