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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
fnet_eth.h
00001 /************************************************************************** 00002 * 00003 * Copyright 2011-2016 by Andrey Butok. FNET Community. 00004 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc. 00005 * 00006 *************************************************************************** 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00009 * not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00016 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 * 00020 **********************************************************************/ 00021 /*! 00022 * @brief Ethernet platform independent API definitions. 00023 * 00024 ***************************************************************************/ 00025 00026 #ifndef _FNET_ETH_H_ 00027 00028 #define _FNET_ETH_H_ 00029 00030 /************************************************************************** 00031 * Definitions 00032 ***************************************************************************/ 00033 00034 /*! @addtogroup fnet_netif 00035 */ 00036 /*! @{ */ 00037 00038 /**************************************************************************/ /*! 00039 * @def FNET_MAC_ADDR_STR_SIZE 00040 * @brief Size of the string buffer that will contain 00041 * null-terminated ASCII string of MAC address, represented 00042 * by six groups of two hexadecimal digits, separated by colons (:). 00043 * @see fnet_mac_to_str 00044 * @showinitializer 00045 ******************************************************************************/ 00046 #define FNET_MAC_ADDR_STR_SIZE (18) 00047 00048 /**************************************************************************/ /*! 00049 * @brief Media Access Control (MAC) address type. 00050 ******************************************************************************/ 00051 typedef fnet_uint8_t fnet_mac_addr_t[6]; /* MAC address type.*/ 00052 00053 /**************************************************************************/ /*! 00054 * @def FNET_MAC_ADDR_INIT 00055 * @param a First octet of an MAC address. 00056 * @param b Second octet of an MAC address. 00057 * @param c Third octet of an MAC address. 00058 * @param d Fourth octet of an MAC address. 00059 * @param e Fifth octet of an MAC address. 00060 * @param f Sixth octet of an MAC address. 00061 * @hideinitializer 00062 * @brief Converts the standard notation @c a:b:c:d:e:f to fnet_mac_addr_t value. 00063 ******************************************************************************/ 00064 #define FNET_MAC_ADDR_INIT(a, b, c, d, e, f) { (a), (b), (c), (d), (e), (f) } 00065 00066 /****************************************************************************** 00067 * Function Prototypes 00068 *******************************************************************************/ 00069 00070 #if defined(__cplusplus) 00071 extern "C" { 00072 #endif 00073 00074 /***************************************************************************/ /*! 00075 * 00076 * @brief Converts a 6 byte MAC address into a null terminated string. 00077 * 00078 * 00079 * @param[in] addr MAC address. 00080 * 00081 * @param[out] str_mac Pointer to a character buffer will contain the resulting 00082 * text address in standard ":" notation. @n 00083 * The @c str_mac buffer must be at least 18 bytes long 00084 * (@ref FNET_MAC_ADDR_STR_SIZE). 00085 * 00086 * @return This function always returns the @c str_mac. 00087 * 00088 * @see fnet_str_to_mac() 00089 ****************************************************************************** 00090 * This function takes an MAC-48 address, specified by the @c addr 00091 * parameter, and returns a null-terminated ASCII string, represented 00092 * by six groups of two hexadecimal digits, separated by colons (:), 00093 * in transmission order (e.g. 01:23:45:67:89:ab ), into buffer pointed to by the 00094 * @c str_mac. 00095 ******************************************************************************/ 00096 fnet_char_t *fnet_mac_to_str( const fnet_mac_addr_t addr, fnet_char_t *str_mac ); 00097 00098 /***************************************************************************/ /*! 00099 * 00100 * @brief Converts a null terminated string to a 6 byte MAC address 00101 * 00102 * @param[in] str_mac Null-terminated MAC address string as pairs of 00103 * hexadecimal numbers separated by colons. 00104 * 00105 * @param[out] addr Buffer will contain a suitable 00106 * binary representation of the @c str_mac MAC address . 00107 * 00108 * @return This function returns: 00109 * - @ref FNET_OK if no error occurs. 00110 * - @ref FNET_ERR if the string in the @c str_mac parameter does not contain 00111 * a legitimate MAC address. 00112 * 00113 * @see fnet_mac_to_str() 00114 ****************************************************************************** 00115 * This function interprets the character string specified by the @c str_mac 00116 * parameter. This string represents a numeric MAC address expressed 00117 * in six groups of two hexadecimal digits, separated by colons (:), 00118 * in transmission order. The value returned, pointed to by the @c addr, 00119 * is a number suitable for use as an MAC address. 00120 ******************************************************************************/ 00121 fnet_return_t fnet_str_to_mac( const fnet_char_t *str_mac, fnet_mac_addr_t addr ); 00122 00123 #if defined(__cplusplus) 00124 } 00125 #endif 00126 00127 /*! @} */ 00128 00129 #endif
Generated on Tue Jul 12 2022 13:54:22 by
