Committer:
jp
Date:
Sat Apr 02 23:23:07 2011 +0000
Revision:
0:011be8250218

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jp 0:011be8250218 1 /*
jp 0:011be8250218 2 * Copyright or © or Copr. 2010, Thomas SOETE
jp 0:011be8250218 3 *
jp 0:011be8250218 4 * Author e-mail: thomas@soete.org
jp 0:011be8250218 5 * Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
jp 0:011be8250218 6 *
jp 0:011be8250218 7 * This software is governed by the CeCILL license under French law and
jp 0:011be8250218 8 * abiding by the rules of distribution of free software. You can use,
jp 0:011be8250218 9 * modify and/ or redistribute the software under the terms of the CeCILL
jp 0:011be8250218 10 * license as circulated by CEA, CNRS and INRIA at the following URL
jp 0:011be8250218 11 * "http://www.cecill.info".
jp 0:011be8250218 12 *
jp 0:011be8250218 13 * As a counterpart to the access to the source code and rights to copy,
jp 0:011be8250218 14 * modify and redistribute granted by the license, users are provided only
jp 0:011be8250218 15 * with a limited warranty and the software's author, the holder of the
jp 0:011be8250218 16 * economic rights, and the successive licensors have only limited
jp 0:011be8250218 17 * liability.
jp 0:011be8250218 18 *
jp 0:011be8250218 19 * In this respect, the user's attention is drawn to the risks associated
jp 0:011be8250218 20 * with loading, using, modifying and/or developing or reproducing the
jp 0:011be8250218 21 * software by the user in light of its specific status of free software,
jp 0:011be8250218 22 * that may mean that it is complicated to manipulate, and that also
jp 0:011be8250218 23 * therefore means that it is reserved for developers and experienced
jp 0:011be8250218 24 * professionals having in-depth computer knowledge. Users are therefore
jp 0:011be8250218 25 * encouraged to load and test the software's suitability as regards their
jp 0:011be8250218 26 * requirements in conditions enabling the security of their systems and/or
jp 0:011be8250218 27 * data to be ensured and, more generally, to use and operate it in the
jp 0:011be8250218 28 * same conditions as regards security.
jp 0:011be8250218 29 *
jp 0:011be8250218 30 * The fact that you are presently reading this means that you have had
jp 0:011be8250218 31 * knowledge of the CeCILL license and that you accept its terms.
jp 0:011be8250218 32 */
jp 0:011be8250218 33
jp 0:011be8250218 34 #ifndef __SIMPLELIB_IP_H__
jp 0:011be8250218 35 #define __SIMPLELIB_IP_H__
jp 0:011be8250218 36
jp 0:011be8250218 37 #include "ip.h"
jp 0:011be8250218 38
jp 0:011be8250218 39 typedef __packed struct {
jp 0:011be8250218 40 unsigned char version:4;
jp 0:011be8250218 41 unsigned char length:4;
jp 0:011be8250218 42 unsigned char services;
jp 0:011be8250218 43 uint16_t total_length;
jp 0:011be8250218 44 uint16_t identification;
jp 0:011be8250218 45 unsigned int flags:3;
jp 0:011be8250218 46 unsigned fragment_offset:13;
jp 0:011be8250218 47 unsigned char ttl;
jp 0:011be8250218 48 unsigned char protocol;
jp 0:011be8250218 49 uint16_t header_checksum;
jp 0:011be8250218 50 unsigned char source[4];
jp 0:011be8250218 51 unsigned char destination[4];
jp 0:011be8250218 52 } s_ip;
jp 0:011be8250218 53
jp 0:011be8250218 54 typedef __packed struct {
jp 0:011be8250218 55 ethernet_packet eth;
jp 0:011be8250218 56 s_ip ip;
jp 0:011be8250218 57 } ipv4_packet;
jp 0:011be8250218 58 #define asIPV4(x) ((ipv4_packet*)(x))
jp 0:011be8250218 59
jp 0:011be8250218 60 #define PROTO_ICMP 0x01
jp 0:011be8250218 61
jp 0:011be8250218 62 typedef __packed struct {
jp 0:011be8250218 63 ethernet_packet eth;
jp 0:011be8250218 64 s_ip ip;
jp 0:011be8250218 65 __packed struct {
jp 0:011be8250218 66 unsigned char type;
jp 0:011be8250218 67 unsigned char code;
jp 0:011be8250218 68 uint16_t checksum;
jp 0:011be8250218 69 uint16_t identifier;
jp 0:011be8250218 70 uint16_t sequence_number;
jp 0:011be8250218 71 unsigned char data[];
jp 0:011be8250218 72 } icmp;
jp 0:011be8250218 73 } icmp_packet;
jp 0:011be8250218 74 #define asICMP(x) ((icmp_packet*)(x))
jp 0:011be8250218 75
jp 0:011be8250218 76 #define ICMP_REQUEST 0x08
jp 0:011be8250218 77 #define ICMP_REPLY 0x00
jp 0:011be8250218 78
jp 0:011be8250218 79 #endif