3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 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"
48 /** Protocol IP address of the host (client) machine, once assigned by DHCP */
49 #define CLIENT_IP_ADDRESS { 10, 0, 0, 1}
51 /** Protocol IP address of the virtual server machine */
52 #define SERVER_IP_ADDRESS { 10, 0, 0, 2}
54 /** Protocol IP address of the broadcast address */
55 #define BROADCAST_IP_ADDRESS {0xFF, 0xFF, 0xFF, 0xFF}
57 /** Default Time To Live (TTL) value for sent packets, indicating the maximum allowable hops until their destination is reached */
58 #define DEFAULT_TTL 128
60 /** Performs a comparison between two IP addresses, indicating if they are identical.
62 * \param[in] IP1 First IP address
63 * \param[in] IP2 Second IP address
65 * \return True if the addresses match, false otherwise
67 #define IP_COMPARE(IP1, IP2) (memcmp(IP1, IP2, sizeof(IP_Address_t)) == 0)
70 /** Type define of an IP packet header. */
73 unsigned char HeaderLength
: 4; /**< Total length of the packet header, in 4-byte blocks */
74 unsigned char Version
: 4; /**< IP protocol version */
75 uint8_t TypeOfService
; /**< Special service type identifier, indicating delay/throughput/reliability levels */
76 uint16_t TotalLength
; /**< Total length of the IP packet, in bytes */
78 uint16_t Identification
; /**< Identification value for identifying fragmented packets */
79 unsigned int FragmentOffset
: 13; /**< Offset of this IP fragment */
80 unsigned int Flags
: 3; /**< Fragment flags, to indicate if a packet is fragmented */
82 uint8_t TTL
; /**< Maximum allowable number of hops to reach the packet destination */
83 uint8_t Protocol
; /**< Encapsulated protocol type */
84 uint16_t HeaderChecksum
; /**< Ethernet checksum of the IP header */
86 IP_Address_t SourceAddress
; /**< Source protocol IP address of the packet */
87 IP_Address_t DestinationAddress
; /**< Destination protocol IP address of the packet */
90 /* Function Prototypes: */
91 int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t
* FrameIN
, void* InDataStart
, void* OutDataStart
);