Index: uspace/srv/inet/Makefile
===================================================================
--- uspace/srv/inet/Makefile	(revision fa101c4ef128bcbc266ee366dd9b3fcfe2bcf4ab)
+++ uspace/srv/inet/Makefile	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
@@ -32,4 +32,5 @@
 SOURCES = \
 	addrobj.c \
+	icmp.c \
 	inet.c \
 	inet_link.c \
Index: uspace/srv/inet/icmp.c
===================================================================
--- uspace/srv/inet/icmp.c	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
+++ uspace/srv/inet/icmp.c	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2012 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup inet
+ * @{
+ */
+/**
+ * @file
+ * @brief
+ */
+
+#include <byteorder.h>
+#include <errno.h>
+#include <io/log.h>
+#include <mem.h>
+#include <stdlib.h>
+
+#include "icmp.h"
+#include "icmp_std.h"
+#include "inet.h"
+#include "pdu.h"
+
+/* XXX */
+#define INET_TTL_MAX 255
+
+static int icmp_echo_request(inet_dgram_t *);
+
+int icmp_recv(inet_dgram_t *dgram)
+{
+	uint8_t type;
+
+	log_msg(LVL_DEBUG, "icmp_recv()");
+
+	if (dgram->size < 1)
+		return EINVAL;
+
+	type = *(uint8_t *)dgram->data;
+
+	switch (type) {
+	case ICMP_ECHO_REQUEST:
+		return icmp_echo_request(dgram);
+	default:
+		break;
+	}
+
+	return EINVAL;
+}
+
+static int icmp_echo_request(inet_dgram_t *dgram)
+{
+	icmp_echo_t *request, *reply;
+	uint16_t checksum;
+	size_t size;
+	inet_dgram_t rdgram;
+	int rc;
+
+	log_msg(LVL_DEBUG, "icmp_echo_request()");
+
+	if (dgram->size < sizeof(icmp_echo_t))
+		return EINVAL;
+
+	request = (icmp_echo_t *)dgram->data;
+	size = dgram->size;
+
+	reply = calloc(size, 1);
+	if (reply == NULL)
+		return ENOMEM;
+
+	memcpy(reply, request, size);
+
+	reply->type = ICMP_ECHO_REPLY;
+	reply->code = 0;
+	reply->checksum = 0;
+
+	checksum = inet_checksum_calc(INET_CHECKSUM_INIT, reply, size);
+	reply->checksum = host2uint16_t_be(checksum);
+
+	rdgram.src = dgram->dest;
+	rdgram.dest = dgram->src;
+	rdgram.tos = 0;
+	rdgram.data = reply;
+	rdgram.size = size;
+
+	rc = inet_route_packet(&rdgram, IP_PROTO_ICMP, INET_TTL_MAX, 0);
+
+	free(reply);
+
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/srv/inet/icmp.h
===================================================================
--- uspace/srv/inet/icmp.h	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
+++ uspace/srv/inet/icmp.h	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2012 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup inet
+ * @{
+ */
+/**
+ * @file
+ * @brief
+ */
+
+#ifndef ICMP_H_
+#define ICMP_H_
+
+#include "inet.h"
+
+extern int icmp_recv(inet_dgram_t *);
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/inet/icmp_std.h
===================================================================
--- uspace/srv/inet/icmp_std.h	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
+++ uspace/srv/inet/icmp_std.h	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup inet
+ * @{
+ */
+/**
+ * @file ICMP standard definitions
+ *
+ */
+
+#ifndef ICMP_STD_H_
+#define ICMP_STD_H_
+
+#include <sys/types.h>
+
+#define IP_PROTO_ICMP 1
+
+/** ICMP message type */
+enum icmp_type {
+	ICMP_ECHO_REPLY   = 0,
+	ICMP_ECHO_REQUEST = 8
+};
+
+/** ICMP Echo Request or Reply message header */
+typedef struct {
+	/** ICMP message type */
+	uint8_t type;
+	/** Code (0) */
+	uint8_t code;
+	/** Internet checksum of the ICMP message */
+	uint16_t checksum;
+	/** Indentifier */
+	uint16_t ident;
+	/** Sequence number */
+	uint16_t seq_no;
+} icmp_echo_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/srv/inet/inet.c
===================================================================
--- uspace/srv/inet/inet.c	(revision fa101c4ef128bcbc266ee366dd9b3fcfe2bcf4ab)
+++ uspace/srv/inet/inet.c	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
@@ -48,4 +48,6 @@
 
 #include "addrobj.h"
+#include "icmp.h"
+#include "icmp_std.h"
 #include "inet.h"
 #include "inetcfg.h"
@@ -110,5 +112,5 @@
 }
 
-static int inet_route_packet(inet_dgram_t *dgram, uint8_t proto, uint8_t ttl,
+int inet_route_packet(inet_dgram_t *dgram, uint8_t proto, uint8_t ttl,
     int df)
 {
@@ -338,4 +340,8 @@
 	log_msg(LVL_DEBUG, "inet_recv_dgram_local()");
 
+	/* ICMP messages are handled internally */
+	if (proto == IP_PROTO_ICMP)
+		return icmp_recv(dgram);
+
 	client = inet_client_find(proto);
 	if (client == NULL) {
Index: uspace/srv/inet/inet.h
===================================================================
--- uspace/srv/inet/inet.h	(revision fa101c4ef128bcbc266ee366dd9b3fcfe2bcf4ab)
+++ uspace/srv/inet/inet.h	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
@@ -117,4 +117,5 @@
 extern int inet_ev_recv(inet_client_t *, inet_dgram_t *);
 extern int inet_recv_packet(inet_packet_t *);
+extern int inet_route_packet(inet_dgram_t *, uint8_t, uint8_t, int);
 
 #endif
Index: uspace/srv/inet/pdu.c
===================================================================
--- uspace/srv/inet/pdu.c	(revision fa101c4ef128bcbc266ee366dd9b3fcfe2bcf4ab)
+++ uspace/srv/inet/pdu.c	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
@@ -51,6 +51,4 @@
 static uint16_t ip_ident = 0;
 
-#define INET_CHECKSUM_INIT 0xffff
-
 /** One's complement addition.
  *
@@ -65,5 +63,5 @@
 }
 
-static uint16_t inet_checksum_calc(uint16_t ivalue, void *data, size_t size)
+uint16_t inet_checksum_calc(uint16_t ivalue, void *data, size_t size)
 {
 	uint16_t sum;
Index: uspace/srv/inet/pdu.h
===================================================================
--- uspace/srv/inet/pdu.h	(revision fa101c4ef128bcbc266ee366dd9b3fcfe2bcf4ab)
+++ uspace/srv/inet/pdu.h	(revision 637a3b4e56e958cd6417e7489a439f0c676ec89f)
@@ -38,5 +38,10 @@
 #define INET_PDU_H_
 
+#include <sys/types.h>
 #include "inet.h"
+
+#define INET_CHECKSUM_INIT 0xffff
+
+extern uint16_t inet_checksum_calc(uint16_t, void *, size_t);
 
 extern int inet_pdu_encode(inet_packet_t *, void **, size_t *);
