diff options
Diffstat (limited to 'lib/lufa/Demos/Device/LowLevel/RNDISEthernet/Lib/IP.h')
| -rw-r--r-- | lib/lufa/Demos/Device/LowLevel/RNDISEthernet/Lib/IP.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/lib/lufa/Demos/Device/LowLevel/RNDISEthernet/Lib/IP.h b/lib/lufa/Demos/Device/LowLevel/RNDISEthernet/Lib/IP.h new file mode 100644 index 000000000..48f2c9086 --- /dev/null +++ b/lib/lufa/Demos/Device/LowLevel/RNDISEthernet/Lib/IP.h | |||
| @@ -0,0 +1,92 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 11 | |||
| 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. | ||
| 20 | |||
| 21 | The author disclaims 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 | ||
| 28 | this software. | ||
| 29 | */ | ||
| 30 | |||
| 31 | /** \file | ||
| 32 | * | ||
| 33 | * Header file for IP.c. | ||
| 34 | */ | ||
| 35 | |||
| 36 | #ifndef _IP_H_ | ||
| 37 | #define _IP_H_ | ||
| 38 | |||
| 39 | /* Includes: */ | ||
| 40 | #include <avr/io.h> | ||
| 41 | #include <string.h> | ||
| 42 | |||
| 43 | #include "EthernetProtocols.h" | ||
| 44 | #include "Ethernet.h" | ||
| 45 | #include "ProtocolDecoders.h" | ||
| 46 | #include "Config/AppConfig.h" | ||
| 47 | |||
| 48 | /* Macros: */ | ||
| 49 | /** Protocol IP address of the broadcast address. */ | ||
| 50 | #define BROADCAST_IP_ADDRESS {0xFF, 0xFF, 0xFF, 0xFF} | ||
| 51 | |||
| 52 | /** Default Time To Live (TTL) value for sent packets, indicating the maximum allowable hops until their destination | ||
| 53 | * is reached. | ||
| 54 | */ | ||
| 55 | #define DEFAULT_TTL 128 | ||
| 56 | |||
| 57 | /** Performs a comparison between two IP addresses, indicating if they are identical. | ||
| 58 | * | ||
| 59 | * \param[in] IP1 First IP address | ||
| 60 | * \param[in] IP2 Second IP address | ||
| 61 | * | ||
| 62 | * \return True if the addresses match, \c false otherwise | ||
| 63 | */ | ||
| 64 | #define IP_COMPARE(IP1, IP2) (memcmp(IP1, IP2, sizeof(IP_Address_t)) == 0) | ||
| 65 | |||
| 66 | /* Type Defines: */ | ||
| 67 | /** Type define of an IP packet header. */ | ||
| 68 | typedef struct | ||
| 69 | { | ||
| 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 */ | ||
| 74 | |||
| 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 */ | ||
| 78 | |||
| 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 */ | ||
| 82 | |||
| 83 | IP_Address_t SourceAddress; /**< Source protocol IP address of the packet */ | ||
| 84 | IP_Address_t DestinationAddress; /**< Destination protocol IP address of the packet */ | ||
| 85 | } IP_Header_t; | ||
| 86 | |||
| 87 | /* Function Prototypes: */ | ||
| 88 | int16_t IP_ProcessIPPacket(void* InDataStart, | ||
| 89 | void* OutDataStart); | ||
| 90 | |||
| 91 | #endif | ||
| 92 | |||
