friendev EtherDune TCP/IP library
/home/jander/temp/etherdune/ICMPPingAutoReply.cpp
Go to the documentation of this file.
1 // EtherDune ICMP automatic Echo reply class
2 // Author: Javier Peletier <jm@friendev.com>
3 // Summary: Implements an ICMP Echo reply service
4 //
5 // Copyright (c) 2015 All Rights Reserved, http://friendev.com
6 //
7 // This source is subject to the GPLv2 license.
8 // Please see the License.txt file for more information.
9 // All other rights reserved.
10 //
11 // THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
12 // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13 // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
14 // PARTICULAR PURPOSE.
15 
16 
17 #include "ICMPPingAutoReply.h"
18 
19 bool ICMPPingAutoReply::onICMPMessage()
20 {
22  return false;
23 
24  if (!loadAll())
25  return true; //checksum error, drop packet.
26 
28 
29 #if !ENABLE_ICMP_RX_CHECKSUM
30  packet.icmp.checksum = 0; //checksum calculation already sets this to zero in ICMP::loadAll().
31 #endif
34 
36 
37  return true;
38 
39 }
uint16_t checksum
Error checking data.
Definition: inet.h:435
static const uint8_t ICMP_TYPE_ECHOREPLY
ICMP echo reply operation type.
Definition: inet.h:574
ICMPHeader icmp
Definition: inet.h:509
bool loadAll()
Loads the entire ICMP packet into memory.
Definition: ICMP.cpp:40
IPAddress sourceIP
Source address.
Definition: inet.h:320
static EthBuffer packet
in-memory packet buffer currently being processed.
static const uint8_t ICMP_TYPE_ECHOREQUEST
ICMP echo request operation type.
Definition: inet.h:575
uint8_t type
ICMP type.
Definition: inet.h:433
void calcICMPChecksum()
Calculates the ICMP checksum and populates the checksum field in the ICMP header. ...
Definition: ICMP.cpp:59
static bool sendIPPacket(uint16_t length)
Puts the current in-memory packet in the network
static void prepareIPPacket(const IPAddress &remoteIP)
Sets up common IP header values for all outgoing IP packets and calculates the IP header checksum ...
IPHeader ip
Definition: inet.h:506
nint16_t totalLength
This 16-bit field defines the entire packet (fragment) size, including header and data...
Definition: inet.h:310