SimpleLib_03272011

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ethernet.h Source File

ethernet.h

00001 /*
00002 * Copyright or � or Copr. 2010, Thomas SOETE
00003 * 
00004 * Author e-mail: thomas@soete.org
00005 * Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
00006 * 
00007 * This software is governed by the CeCILL license under French law and
00008 * abiding by the rules of distribution of free software.  You can  use, 
00009 * modify and/ or redistribute the software under the terms of the CeCILL
00010 * license as circulated by CEA, CNRS and INRIA at the following URL
00011 * "http://www.cecill.info". 
00012 * 
00013 * As a counterpart to the access to the source code and  rights to copy,
00014 * modify and redistribute granted by the license, users are provided only
00015 * with a limited warranty  and the software's author,  the holder of the
00016 * economic rights,  and the successive licensors  have only  limited
00017 * liability. 
00018 * 
00019 * In this respect, the user's attention is drawn to the risks associated
00020 * with loading,  using,  modifying and/or developing or reproducing the
00021 * software by the user in light of its specific status of free software,
00022 * that may mean  that it is complicated to manipulate,  and  that  also
00023 * therefore means  that it is reserved for developers  and  experienced
00024 * professionals having in-depth computer knowledge. Users are therefore
00025 * encouraged to load and test the software's suitability as regards their
00026 * requirements in conditions enabling the security of their systems and/or 
00027 * data to be ensured and,  more generally, to use and operate it in the 
00028 * same conditions as regards security. 
00029 * 
00030 * The fact that you are presently reading this means that you have had
00031 * knowledge of the CeCILL license and that you accept its terms.
00032 */
00033 
00034 #ifndef __SIMPLELIB_ETHERNET_H__
00035 #define __SIMPLELIB_ETHERNET_H__
00036 
00037 typedef __packed struct {
00038     char destination[6];
00039     char source[6];
00040     uint16_t type;
00041 } ethernet_packet;
00042 #define asETH(x) ((ethernet_packet*)(x))
00043 
00044 #define IPV4_TYPE 0x0800
00045 #define ARP_TYPE  0x0806
00046 
00047 typedef __packed struct {
00048     ethernet_packet eth;
00049     __packed struct {
00050         char hardware_type[2];
00051         char protocol_type[2];
00052         char hardware_size;
00053         char protocol_size;
00054         uint16_t opcode_request;
00055         char sender_mac[6];
00056         char sender_ip[4];
00057         char target_mac[6];
00058         char target_ip[4];
00059     } arp;
00060 } arp_packet;
00061 #define asARP(x) ((arp_packet*)(x))
00062 
00063 #define ARP_REQUEST 0x0001
00064 #define ARP_REPLY   0x0002
00065 
00066 #endif