Embedded TCP/IP stack: fnet_eth.h Source File

FNET

fnet_eth.h
1 /**************************************************************************
2 *
3 * Copyright 2011-2016 by Andrey Butok. FNET Community.
4 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 ***************************************************************************
21 *
22 * Ethernet platform independent API definitions.
23 *
24 ***************************************************************************/
25 
26 #ifndef _FNET_ETH_H_
27 
28 #define _FNET_ETH_H_
29 
30 /**************************************************************************
31 * Definitions
32 ***************************************************************************/
33 
38 /**************************************************************************/
46 #define FNET_MAC_ADDR_STR_SIZE (18)
47 
48 /**************************************************************************/
53 #define FNET_ETH_MTU (1500u)
54 
55 /**************************************************************************/
58 typedef fnet_uint8_t fnet_mac_addr_t[6]; /* MAC address type.*/
59 
60 /**************************************************************************/
71 #define FNET_MAC_ADDR_INIT(a, b, c, d, e, f) { (a), (b), (c), (d), (e), (f) }
72 
73 /* MAC address is multicast. */
74 #define FNET_MAC_ADDR_IS_MULTICAST(a) ((((a)[0]) == 0x01U)?FNET_TRUE:FNET_FALSE)
75 
76 /* MAC address is broadcast. */
77 #define FNET_MAC_ADDR_IS_BROADCAST(a) (((((a)[0]) == 0xFFU) && \
78  (((a)[1]) == 0xFFU)&& \
79  (((a)[1]) == 0xFFU)&& \
80  (((a)[1]) == 0xFFU)&& \
81  (((a)[1]) == 0xFFU)&& \
82  (((a)[1]) == 0xFFU))? FNET_TRUE:FNET_FALSE)
83 /* Copying address. */
84 #define FNET_MAC_ADDR_COPY(from_addr, to_addr) \
85  (fnet_memcpy(&to_addr[0], &from_addr[0], sizeof(fnet_mac_addr_t)))
86 
87 /* Useful mac addresses */
88 extern const fnet_mac_addr_t fnet_eth_null_addr;
89 extern const fnet_mac_addr_t fnet_eth_broadcast;
90 
91 /******************************************************************************
92 * Function Prototypes
93 *******************************************************************************/
94 
95 #if defined(__cplusplus)
96 extern "C" {
97 #endif
98 
99 /***************************************************************************/
121 fnet_char_t *fnet_mac_to_str( const fnet_mac_addr_t addr, fnet_char_t *str_mac );
122 
123 /***************************************************************************/
147 
148 #if defined(__cplusplus)
149 }
150 #endif
151 
154 #endif
fnet_return_t
General return codes, used by most of API functions.
Definition: fnet_stdlib.h:90
fnet_char_t * fnet_mac_to_str(const fnet_mac_addr_t addr, fnet_char_t *str_mac)
Converts a 6 byte MAC address into a null terminated string.
fnet_return_t fnet_str_to_mac(const fnet_char_t *str_mac, fnet_mac_addr_t addr)
Converts a null terminated string to a 6 byte MAC address.
char fnet_char_t
Type representing the charecter.
Definition: fnet_stdlib.h:76
fnet_uint8_t fnet_mac_addr_t[6]
Media Access Control (MAC) address type.
Definition: fnet_eth.h:58

© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net