Choco OS  V.0.16.9.0
Join to the chocolate world
oc_icmp.h
Go to the documentation of this file.
1 
30 #ifndef SYSTEM_CORE_INC_NET_PROTOCOLS_ICMP_OC_ICMP_H_
31 #define SYSTEM_CORE_INC_NET_PROTOCOLS_ICMP_OC_ICMP_H_
32 
33 #include <oc_net.h>
34 #include <oc_process.h>
35 #include <oc_netif.h>
36 
42 #define _________________________________________TYPES_SECTION______________________________________________________________________________
43 
48 //==========================================================================================================================================
54 //==========================================================================================================================================
55 typedef enum
56 {
72 
73 
74  oC_Icmp_Type_Empty = 0xFF
76 
77 //==========================================================================================================================================
81 //==========================================================================================================================================
82 typedef struct
83 {
84  uint8_t Type;
85  uint8_t Code;
86  uint16_t Checksum;
88 
89 //==========================================================================================================================================
93 //==========================================================================================================================================
94 typedef struct
95 {
96  uint16_t ID;
97  uint16_t SequenceNumber;
98  uint32_t Payload[40];
100 
101 //==========================================================================================================================================
105 //==========================================================================================================================================
106 typedef struct
107 {
108  uint16_t ID;
109  uint16_t SequenceNumber;
110  uint32_t OriginateTimestamp;
111  uint32_t ReceiveTimestamp;
112  uint32_t TransmitTimestamp;
114 
115 //==========================================================================================================================================
119 //==========================================================================================================================================
120 typedef struct
121 {
122  uint16_t ID;
123  uint16_t SequenceNumber;
124  uint32_t AddressMask;
126 
127 //==========================================================================================================================================
131 //==========================================================================================================================================
132 typedef struct
133 {
134  uint16_t Unused;
135  uint16_t NextHopMtu;
136  oC_Net_Ipv4PacketHeader_t IPv4Header;
137  uint8_t Data[8];
139 
140 //==========================================================================================================================================
144 //==========================================================================================================================================
145 typedef struct
146 {
148  union
149  {
150  uint8_t Payload[4];
155  } Message;
157 
158 //==========================================================================================================================================
162 //==========================================================================================================================================
163 typedef union
164 {
166 
167  struct
168  {
171  } IPv4;
172 
173  struct
174  {
176  oC_Icmp_Datagram_t IcmpDatagram;
177  } IPv6;
179 
181 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
182 
188 #define _________________________________________PROTOTYPES_SECTION_________________________________________________________________________
189 
194 extern oC_ErrorCode_t oC_Icmp_TurnOn ( void );
195 extern oC_ErrorCode_t oC_Icmp_TurnOff ( void );
196 extern bool oC_Icmp_IsTypeReserved ( oC_Icmp_Type_t Type , oC_Process_t Process );
197 extern oC_ErrorCode_t oC_Icmp_ReserveType ( oC_Icmp_Type_t Type , oC_Time_t Timeout );
198 extern oC_ErrorCode_t oC_Icmp_ReleaseType ( oC_Icmp_Type_t Type , oC_Time_t Timeout );
199 extern oC_ErrorCode_t oC_Icmp_ReleaseAllTypesReservedBy ( oC_Process_t Process , oC_Time_t Timeout );
200 extern oC_ErrorCode_t oC_Icmp_CalculateChecksum ( oC_Icmp_Packet_t * Packet , uint16_t * outChecksum );
201 extern oC_Icmp_Packet_t* oC_Icmp_Packet_New ( Allocator_t PacketAllocator , oC_Net_PacketType_t Type , oC_Icmp_Type_t IcmpType , uint8_t Code , const void * Data , uint16_t Size );
202 extern bool oC_Icmp_Packet_SetSize ( oC_Icmp_Packet_t * Packet , uint16_t Size );
203 extern bool oC_Icmp_Packet_Delete ( oC_Icmp_Packet_t ** Packet );
204 extern void * oC_Icmp_Packet_GetMessageReference ( oC_Icmp_Packet_t * Packet );
205 extern oC_ErrorCode_t oC_Icmp_Send ( oC_Netif_t Netif , const oC_Net_Address_t * Destination , oC_Icmp_Packet_t * Packet , oC_Time_t Timeout );
206 extern oC_ErrorCode_t oC_Icmp_Receive ( oC_Netif_t Netif , oC_Icmp_Packet_t * outPacket , oC_Icmp_Type_t Type , oC_Time_t Timeout );
207 
209 #undef _________________________________________PROTOTYPES_SECTION_________________________________________________________________________
210 
211 
212 #endif /* SYSTEM_CORE_INC_NET_PROTOCOLS_ICMP_OC_ICMP_H_ */
oC_ErrorCode_t oC_Icmp_Send(oC_Netif_t Netif, const oC_Net_Address_t *Destination, oC_Icmp_Packet_t *Packet, oC_Time_t Timeout)
sends ICMP packet
Definition: oc_icmp.c:642
Timestamp.
Definition: oc_icmp.h:66
stores ICMP datagram
Definition: oc_icmp.h:145
stores ICMP timestamp message
Definition: oc_icmp.h:106
bool oC_Icmp_IsTypeReserved(oC_Icmp_Type_t Type, oC_Process_t Process)
checks if the given ICMP type is reserved
Definition: oc_icmp.c:211
stores ICMP message header
Definition: oc_icmp.h:82
identifier for allocations
Definition: oc_stdlib.h:159
uint16_t Checksum
Checksum with ICMP header and Data (with 0 for this field)
Definition: oc_icmp.h:86
Information Request.
Definition: oc_icmp.h:68
uint16_t ID
Identification of the transaction.
Definition: oc_icmp.h:108
Address Mask Reply.
Definition: oc_icmp.h:71
Echo Request.
Definition: oc_icmp.h:61
stores ICMP echo message
Definition: oc_icmp.h:94
Router Solicitation.
Definition: oc_icmp.h:63
oC_Net_Ipv6PacketHeader_t Header
IPv6 header.
Definition: oc_icmp.h:175
oC_Net_Packet_t Packet
IP packet.
Definition: oc_icmp.h:165
stores ICMP packet (datagram + IP header)
Definition: oc_icmp.h:163
oC_Icmp_Type_t
stores ICMP message type
Definition: oc_icmp.h:55
stores network address
Definition: oc_net.h:441
Contains interface for netif object.
void * oC_Icmp_Packet_GetMessageReference(oC_Icmp_Packet_t *Packet)
returns reference to the message inside ICMP packet
Definition: oc_icmp.c:594
oC_Net_PacketType_t
stores type of the packet
Definition: oc_net.h:174
oC_Icmp_Datagram_t IcmpDatagram
ICMP data in the IPv4 packet.
Definition: oc_icmp.h:170
Redirect Message.
Definition: oc_icmp.h:60
Information Reply.
Definition: oc_icmp.h:69
Echo reply.
Definition: oc_icmp.h:57
uint16_t ID
Identification of the transaction.
Definition: oc_icmp.h:96
oC_ErrorCode_t oC_Icmp_Receive(oC_Netif_t Netif, oC_Icmp_Packet_t *outPacket, oC_Icmp_Type_t Type, oC_Time_t Timeout)
receives ICMP packet
Definition: oc_icmp.c:742
oC_ErrorCode_t oC_Icmp_CalculateChecksum(oC_Icmp_Packet_t *Packet, uint16_t *outChecksum)
Calculates checksum for ICMP packet.
Definition: oc_icmp.c:469
Timestamp Reply.
Definition: oc_icmp.h:67
stores ICMP Destination Unreachable message
Definition: oc_icmp.h:132
oC_Icmp_Message_DestinationUnreachable_t DestinationUnreachable
Destination unreachable message data.
Definition: oc_icmp.h:154
Address Mask Request.
Definition: oc_icmp.h:70
bool oC_Icmp_Packet_Delete(oC_Icmp_Packet_t **Packet)
release memory allocated for a ICMP packet
Definition: oc_icmp.c:577
oC_Icmp_Packet_t * oC_Icmp_Packet_New(Allocator_t PacketAllocator, oC_Net_PacketType_t Type, oC_Icmp_Type_t IcmpType, uint8_t Code, const void *Data, uint16_t Size)
allocates memory for a ICMP packet
Definition: oc_icmp.c:513
uint8_t Type
Type of the ICMP message.
Definition: oc_icmp.h:84
stores network packet
Definition: oc_net.h:302
oC_ErrorCode_t oC_Icmp_ReserveType(oC_Icmp_Type_t Type, oC_Time_t Timeout)
reserves a ICMP type
Definition: oc_icmp.c:252
uint32_t AddressMask
Subnet mask.
Definition: oc_icmp.h:124
Router Advertisement.
Definition: oc_icmp.h:62
oC_Icmp_Message_Echo_t Echo
Echo message data.
Definition: oc_icmp.h:151
uint16_t SequenceNumber
Sequence number of the message.
Definition: oc_icmp.h:97
Destination unreachable message.
Definition: oc_icmp.h:58
oC_Icmp_Header_t Header
Header of the ICMP packet.
Definition: oc_icmp.h:147
oC_Icmp_Message_AddressMask_t AddressMask
Address mask message data.
Definition: oc_icmp.h:153
uint16_t ID
Identification of the transaction.
Definition: oc_icmp.h:122
Parameter Problem Bad Ip Header.
Definition: oc_icmp.h:65
oC_ErrorCode_t oC_Icmp_TurnOff(void)
turns off ICMP module
Definition: oc_icmp.c:165
stores ICMP Address Mask message
Definition: oc_icmp.h:120
Source Quench (depracated)
Definition: oc_icmp.h:59
The file with interface for process mechanism.
oC_ErrorCode_t oC_Icmp_TurnOn(void)
turns on ICMP module
Definition: oc_icmp.c:109
oC_Icmp_Message_Timestamp_t Timestamp
Timestamp message data.
Definition: oc_icmp.h:152
uint16_t SequenceNumber
Sequence number of the message.
Definition: oc_icmp.h:109
oC_Net_Ipv4PacketHeader_t Header
IPv4 header.
Definition: oc_icmp.h:169
File with interface for the NET module.
uint16_t SequenceNumber
Sequence number of the message.
Definition: oc_icmp.h:123
uint8_t Code
Sub type of the ICMP message.
Definition: oc_icmp.h:85
Time Exceeded.
Definition: oc_icmp.h:64
oC_ErrorCode_t oC_Icmp_ReleaseAllTypesReservedBy(oC_Process_t Process, oC_Time_t Timeout)
releases all types reserved by the process
Definition: oc_icmp.c:414
oC_ErrorCode_t oC_Icmp_ReleaseType(oC_Icmp_Type_t Type, oC_Time_t Timeout)
releases a type
Definition: oc_icmp.c:347
bool oC_Icmp_Packet_SetSize(oC_Icmp_Packet_t *Packet, uint16_t Size)
sets size of the packet
Definition: oc_icmp.c:555
stores IPv6 address
Definition: oc_net.h:142