Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / clients / net-snk / app / netlib / ethernet.h
1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12
13 #ifndef _ETHERNET_H
14 #define _ETHERNET_H
15
16 #include <stdint.h>
17
18 #define ETH_MTU_SIZE     1518   /**< Maximum Transfer Unit         */
19 #define ETH_ALEN            6   /**< HW address length             */
20 #define ETHERTYPE_IP   0x0800
21 #define ETHERTYPE_IPv6 0x86DD
22 #define ETHERTYPE_ARP  0x0806
23
24 /** \struct ethhdr
25  *  A header for Ethernet-packets.
26  */
27 struct ethhdr {
28         uint8_t dest_mac[ETH_ALEN];   /**< Destination HW address        */
29         uint8_t src_mac[ETH_ALEN];    /**< Source HW address             */
30         uint16_t type;                /**< Next level protocol type      */
31 };
32
33 /* Initializes ethernet layer */
34 extern void set_mac_address(const uint8_t * own_mac);
35 extern const uint8_t * get_mac_address(void);
36
37 /* Receives and handles packets, according to Receive-handle diagram */
38 extern int32_t receive_ether(int fd);
39
40 /* Sends an ethernet frame. */
41 extern int send_ether(int fd, void* buffer, int len);
42
43 /* fills ethernet header */
44 extern void fill_ethhdr(uint8_t * packet, uint16_t eth_type,
45                         const uint8_t * src_mac, const uint8_t * dest_mac);
46
47 #endif