|
||||
Warning, cross-references for /kernel/include/drivers/net/ethernet.h need to be fixed.
0001 /* The Quest Operating System 0002 * Copyright (C) 2005-2010 Richard West, Boston University 0003 * 0004 * This program is free software: you can redistribute it and/or modify 0005 * it under the terms of the GNU General Public License as published by 0006 * the Free Software Foundation, either version 3 of the License, or 0007 * (at your option) any later version. 0008 * 0009 * This program is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 * GNU General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU General Public License 0015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0016 */ 0017 0018 #ifndef _ETHERNET_H_ 0019 #define _ETHERNET_H_ 0020 0021 #include "types.h" 0022 #include "lwip/netif.h" 0023 0024 #define MAX_FRAME_SIZE 1600 0025 #define ETH_ADDR_LEN 6 0026 0027 struct _ethernet_device; 0028 0029 typedef void (*packet_recv_func_t)(struct _ethernet_device *dev, 0030 uint8* buffer, sint len); 0031 typedef sint (*packet_send_func_t)(uint8* buffer, sint len); 0032 typedef bool (*get_hwaddr_func_t)(uint8 addr[ETH_ADDR_LEN]); 0033 typedef void (*packet_poll_func_t)(void); 0034 0035 typedef struct _ethernet_device { 0036 /* ethernet device number */ 0037 uint num; 0038 /* function that should be invoked by the driver when a packet 0039 * arrives on its device */ 0040 packet_recv_func_t recv_func; 0041 /* function that should be invoked by other subsystems to send a 0042 * packet out on this device */ 0043 packet_send_func_t send_func; 0044 /* function that populates a buffer with the hardware address */ 0045 get_hwaddr_func_t get_hwaddr_func; 0046 /* function that attempts to poll the network device */ 0047 packet_poll_func_t poll_func; 0048 /* lwip network interface struct */ 0049 struct netif netif; 0050 /* driver-specific field */ 0051 void *drvdata; 0052 } ethernet_device; 0053 0054 bool net_init (void); 0055 bool net_register_device (ethernet_device *); 0056 bool net_set_default (char *devname); 0057 bool net_dhcp_start (char *devname); 0058 bool net_set_up (char *devname); 0059 bool net_static_config(char *devname, char *myip_s, char *gwip_s, char *netmask_s); 0060 0061 0062 /* From Linux */ 0063 0064 /** 0065 * is_zero_ether_addr - Determine if give Ethernet address is all zeros. 0066 * @addr: Pointer to a six-byte array containing the Ethernet address 0067 * 0068 * Return true if the address is all zeroes. 0069 */ 0070 static inline int 0071 is_zero_ether_addr(const u8 *addr) 0072 { 0073 return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); 0074 } 0075 0076 /** 0077 * is_multicast_ether_addr - Determine if the Ethernet address is a multicast. 0078 * @addr: Pointer to a six-byte array containing the Ethernet address 0079 * 0080 * Return true if the address is a multicast address. 0081 * By definition the broadcast address is also a multicast address. 0082 */ 0083 static inline int 0084 is_multicast_ether_addr(const u8 *addr) 0085 { 0086 return (0x01 & addr[0]); 0087 } 0088 0089 /** 0090 * is_local_ether_addr - Determine if the Ethernet address is locally-assigned one (IEEE 802). 0091 * @addr: Pointer to a six-byte array containing the Ethernet address 0092 * 0093 * Return true if the address is a local address. 0094 */ 0095 static inline int 0096 is_local_ether_addr(const u8 *addr) 0097 { 0098 return (0x02 & addr[0]); 0099 } 0100 0101 /** 0102 * is_broadcast_ether_addr - Determine if the Ethernet address is broadcast 0103 * @addr: Pointer to a six-byte array containing the Ethernet address 0104 * 0105 * Return true if the address is the broadcast address. 0106 */ 0107 static inline int 0108 is_broadcast_ether_addr(const u8 *addr) 0109 { 0110 return (addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) == 0xff; 0111 } 0112 0113 /** 0114 * is_valid_ether_addr - Determine if the given Ethernet address is valid 0115 * @addr: Pointer to a six-byte array containing the Ethernet address 0116 * 0117 * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not 0118 * a multicast address, and is not FF:FF:FF:FF:FF:FF. 0119 * 0120 * Return true if the address is valid. 0121 */ 0122 static inline int 0123 is_valid_ether_addr(const u8 *addr) 0124 { 0125 /* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to 0126 * explicitly check for it here. */ 0127 return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); 0128 } 0129 0130 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 1.2.0 LXR engine. |