3      Copyright (C) Dean Camera, 2012. 
   5   dean [at] fourwalledcubicle [dot] com 
  10   Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, distribute, and sell this 
  13   software and its documentation for any purpose is hereby granted 
  14   without fee, provided that the above copyright notice appear in 
  15   all copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33  *  Header file for IP.c. 
  43                 #include "EthernetProtocols.h" 
  45                 #include "ProtocolDecoders.h" 
  46                 #include "Config/AppConfig.h" 
  49                 /** Protocol IP address of the broadcast address. */ 
  50                 #define BROADCAST_IP_ADDRESS             {0xFF, 0xFF, 0xFF, 0xFF} 
  52                 /** Default Time To Live (TTL) value for sent packets, indicating the maximum allowable hops until their destination 
  55                 #define DEFAULT_TTL                      128 
  57                 /** Performs a comparison between two IP addresses, indicating if they are identical. 
  59                  *  \param[in] IP1  First IP address 
  60                  *  \param[in] IP2  Second IP address 
  62                  *  \return True if the addresses match, false otherwise 
  64                 #define IP_COMPARE(IP1, IP2)             (memcmp(IP1, IP2, sizeof(IP_Address_t)) == 0) 
  67                 /** Type define of an IP packet header. */ 
  70                         unsigned     HeaderLength   
: 4; /**< Total length of the packet header, in 4-byte blocks */ 
  71                         unsigned     Version        
: 4; /**< IP protocol version */ 
  72                         uint8_t      TypeOfService
; /**< Special service type identifier, indicating delay/throughput/reliability levels */ 
  73                         uint16_t     TotalLength
; /**< Total length of the IP packet, in bytes */ 
  75                         uint16_t     Identification
; /**< Identification value for identifying fragmented packets */ 
  76                         unsigned     FragmentOffset 
: 13; /**< Offset of this IP fragment */ 
  77                         unsigned     Flags          
: 3; /**< Fragment flags, to indicate if a packet is fragmented */ 
  79                         uint8_t      TTL
; /**< Maximum allowable number of hops to reach the packet destination */ 
  80                         uint8_t      Protocol
; /**< Encapsulated protocol type */ 
  81                         uint16_t     HeaderChecksum
; /**< Ethernet checksum of the IP header */ 
  83                         IP_Address_t SourceAddress
; /**< Source protocol IP address of the packet */ 
  84                         IP_Address_t DestinationAddress
; /**< Destination protocol IP address of the packet */ 
  87         /* Function Prototypes: */ 
  88                 int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t
* const FrameIN
,