Index: abi/include/abi/ipc/interfaces.h
===================================================================
--- abi/include/abi/ipc/interfaces.h	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ abi/include/abi/ipc/interfaces.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -202,5 +202,7 @@
 	    FOURCC_COMPACT('w', 'm', 'g', 't') | IFACE_EXCHANGE_SERIALIZE | IFACE_MOD_CALLBACK,
 	INTERFACE_TBARCFG_NOTIFY =
-	    FOURCC_COMPACT('t', 'b', 'c', 'f') | IFACE_EXCHANGE_SERIALIZE
+	    FOURCC_COMPACT('t', 'b', 'c', 'f') | IFACE_EXCHANGE_SERIALIZE,
+	INTERFACE_PCAP_CONTROL =
+	    FOURCC_COMPACT('p', 'c', 't', 'l') | IFACE_EXCHANGE_SERIALIZE,
 } iface_t;
 
Index: uspace/app/meson.build
===================================================================
--- uspace/app/meson.build	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/app/meson.build	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -72,4 +72,5 @@
 	'nic',
 	'nterm',
+	'pcapctl',
 	'ofw',
 	'pci',
Index: uspace/app/pcapctl/doc/doxygroups.h
===================================================================
--- uspace/app/pcapctl/doc/doxygroups.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/app/pcapctl/doc/doxygroups.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,4 @@
+/** @addtogroup pcapctl pcapctl
+ * @brief Dump network packets
+ * @ingroup apps
+ */
Index: uspace/app/pcapctl/main.c
===================================================================
--- uspace/app/pcapctl/main.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/app/pcapctl/main.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * 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 pcapctl
+ * @{
+ */
+/** @file pcapctl app
+ */
+
+#include <stdio.h>
+#include <str.h>
+#include <errno.h>
+#include <arg_parse.h>
+#include <getopt.h>
+
+#include "pcapctl_dump.h"
+
+#define NAME "pcapctl"
+#define DEFAULT_DEV_NUM 0
+
+static errno_t start_dumping(int *dev_number, const char *name)
+{
+	pcapctl_sess_t *sess = NULL;
+	errno_t rc = pcapctl_dump_open(dev_number, &sess);
+	if (rc != EOK) {
+		return 1;
+	}
+
+	pcapctl_dump_start(name, sess);
+	pcapctl_dump_close(sess);
+	return EOK;
+}
+
+static errno_t stop_dumping(int *dev_number)
+{
+	pcapctl_sess_t *sess = NULL;
+	errno_t rc = pcapctl_dump_open(dev_number, &sess);
+	if (rc != EOK) {
+		return 1;
+	}
+	pcapctl_dump_stop(sess);
+	pcapctl_dump_close(sess);
+	return EOK;
+}
+
+static void list_devs(void)
+{
+	pcapctl_list();
+}
+
+/**
+ * Array of supported commandline options
+ */
+static const struct option opts[] = {
+	{ "device", required_argument, 0, 'd' },
+	{ "list", no_argument, 0, 'l' },
+	{ "help", no_argument, 0, 'h' },
+	{ "outfile", required_argument, 0, 'f' },
+	{ "start", no_argument, 0, 'r' },
+	{ "stop", no_argument, 0, 't' },
+	{ 0, 0, 0, 0 }
+};
+
+static void usage(void)
+{
+	printf("Usage:\n"
+	    NAME " --list | -l \n"
+	    "\tList of devices\n"
+	    NAME " --start | -r --device= | -d <device number from list> --outfile= | -f <outfile>\n"
+	    "\tPackets dumped from device will be written to <outfile>\n"
+	    NAME " --stop | -t --device= | -d <device>\n"
+	    "\tDumping from <device> stops\n"
+	    NAME " --start | -s --outfile= | -f <outfile>\n"
+	    "\tPackets dumped from the 0. device from the list will be written to <outfile>\n"
+	    NAME " --help | -h\n"
+	    "\tShow this application help.\n");
+}
+
+int main(int argc, char *argv[])
+{
+	bool start = false;
+	bool stop = false;
+	int dev_number = DEFAULT_DEV_NUM;
+	const char *output_file_name;
+	int idx = 0;
+	int ret = 0;
+	if (argc == 1) {
+		usage();
+		return 0;
+	}
+	while (ret != -1) {
+		ret = getopt_long(argc, argv, "d:lhf:rt", opts, &idx);
+		switch (ret) {
+		case 'd':
+			char *rest;
+			long result = strtol(optarg, &rest, 10);
+			dev_number = (int)result;
+			errno_t rc = pcapctl_is_valid_device(&dev_number);
+			if (rc != EOK) {
+				printf("Device with index %d not found\n", dev_number);
+				return 1;
+			}
+			break;
+		case 'l':
+			list_devs();
+			return 0;
+		case 'h':
+			usage();
+			return 0;
+		case 'f':
+			output_file_name = optarg;
+			break;
+		case 'r':
+			start = true;
+			break;
+		case 't':
+			stop = true;
+			break;
+		}
+	}
+
+	printf("%s: HelenOS Packet Dumping utility: device - %d\n", NAME, dev_number);
+
+	if (start) {
+		// start with dev number and optional..name
+		start_dumping(&dev_number, output_file_name);
+	} else if (stop) {
+		//stop with dev number
+		stop_dumping(&dev_number);
+	}
+	return 0;
+}
+
+/** @}
+ */
Index: uspace/app/pcapctl/meson.build
===================================================================
--- uspace/app/pcapctl/meson.build	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/app/pcapctl/meson.build	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2023 Nataliia Korop
+# 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.
+#
+deps = ['pcap']
+src = files('main.c')
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/drv/nic/e1k/e1k.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -49,4 +49,5 @@
 #include <nic.h>
 #include <ops/nic.h>
+#include <pcapdump_iface.h>
 #include "e1k.h"
 
@@ -174,4 +175,5 @@
 	/** Lock for EEPROM access */
 	fibril_mutex_t eeprom_lock;
+
 } e1000_t;
 
@@ -1189,4 +1191,5 @@
 		if (frame != NULL) {
 			memcpy(frame->data, e1000->rx_frame_virt[next_tail], frame_size);
+
 			nic_received_frame(nic, frame);
 		} else {
@@ -2198,12 +2201,14 @@
 		goto err_fun_bind;
 
-	rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC);
-	if (rc != EOK)
-		goto err_add_to_cat;
-
+	rc = nic_fun_add_to_cats(fun);
+	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding function to categories");
+		ddf_fun_unbind(fun);
+		return rc;
+	}
 	return EOK;
 
-err_add_to_cat:
-	ddf_fun_unbind(fun);
+	// err_add_to_cat:
+	// ddf_fun_unbind(fun);
 err_fun_bind:
 err_rx_structure:
@@ -2365,5 +2370,4 @@
 
 	memcpy(e1000->tx_frame_virt[tdt], data, size);
-
 	tx_descriptor_addr->phys_addr = PTR_TO_U64(e1000->tx_frame_phys[tdt]);
 	tx_descriptor_addr->length = size;
Index: uspace/drv/nic/e1k/meson.build
===================================================================
--- uspace/drv/nic/e1k/meson.build	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/drv/nic/e1k/meson.build	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -27,4 +27,4 @@
 #
 
-deps = [ 'nic' ]
+deps = [ 'nic' , 'pcap' ]
 src = files('e1k.c')
Index: uspace/drv/nic/ne2k/ne2k.c
===================================================================
--- uspace/drv/nic/ne2k/ne2k.c	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/drv/nic/ne2k/ne2k.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -43,4 +43,5 @@
 #include <str_error.h>
 #include <async.h>
+#include <ddf/log.h>
 #include "dp8390.h"
 
@@ -449,8 +450,8 @@
 	}
 
-	rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC);
+	rc = nic_fun_add_to_cats(fun);
 	if (rc != EOK) {
+		ddf_msg(LVL_ERROR, "Failed adding function to categories");
 		ddf_fun_unbind(fun);
-		ddf_fun_destroy(fun);
 		return rc;
 	}
@@ -482,4 +483,5 @@
 	nic_driver_implement(&ne2k_driver_ops, &ne2k_dev_ops, &ne2k_nic_iface);
 
+	ddf_log_init(NAME);
 	return ddf_driver_main(&ne2k_driver);
 }
Index: uspace/drv/nic/rtl8139/driver.c
===================================================================
--- uspace/drv/nic/rtl8139/driver.c	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/drv/nic/rtl8139/driver.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -42,4 +42,5 @@
 #include <stdio.h>
 #include <str.h>
+#include <pcapdump_iface.h>
 
 #include "defs.h"
@@ -1305,8 +1306,10 @@
 		goto err_fun_create;
 	}
-	rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC);
+
+	rc = nic_fun_add_to_cats(fun);
 	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed adding function to category");
-		goto err_fun_bind;
+		ddf_msg(LVL_ERROR, "Failed adding function to categories");
+		ddf_fun_unbind(fun);
+		return rc;
 	}
 
@@ -1316,6 +1319,6 @@
 	return EOK;
 
-err_fun_bind:
-	ddf_fun_unbind(fun);
+	// err_fun_bind:
+	// ddf_fun_unbind(fun);
 err_fun_create:
 	ddf_fun_destroy(fun);
Index: uspace/drv/nic/rtl8169/driver.c
===================================================================
--- uspace/drv/nic/rtl8169/driver.c	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/drv/nic/rtl8169/driver.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -458,8 +458,9 @@
 	}
 
-	rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC);
+	rc = nic_fun_add_to_cats(fun);
 	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed adding function to category");
-		goto err_fun_bind;
+		ddf_msg(LVL_ERROR, "Failed adding function to categories");
+		ddf_fun_unbind(fun);
+		return rc;
 	}
 
@@ -468,6 +469,6 @@
 	return EOK;
 
-err_fun_bind:
-	ddf_fun_unbind(fun);
+	// err_fun_bind:
+	// ddf_fun_unbind(fun);
 err_fun_create:
 	ddf_fun_destroy(fun);
Index: uspace/drv/nic/virtio-net/virtio-net.c
===================================================================
--- uspace/drv/nic/virtio-net/virtio-net.c	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/drv/nic/virtio-net/virtio-net.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -43,4 +43,5 @@
 
 #include <virtio-pci.h>
+#include <pcapdump_iface.h>
 
 #define NAME	"virtio-net"
@@ -428,8 +429,9 @@
 	}
 
-	rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC);
+	rc = nic_fun_add_to_cats(fun);
 	if (rc != EOK) {
-		ddf_msg(LVL_ERROR, "Failed adding function to category");
-		goto unbind;
+		ddf_msg(LVL_ERROR, "Failed adding function to categories");
+		ddf_fun_unbind(fun);
+		return rc;
 	}
 
@@ -439,6 +441,6 @@
 	return EOK;
 
-unbind:
-	ddf_fun_unbind(fun);
+	// unbind:
+	// ddf_fun_unbind(fun);
 destroy:
 	ddf_fun_destroy(fun);
Index: uspace/lib/c/include/ipc/services.h
===================================================================
--- uspace/lib/c/include/ipc/services.h	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/lib/c/include/ipc/services.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -67,5 +67,5 @@
 #define SERVICE_NAME_VBD      "vbd"
 #define SERVICE_NAME_VOLSRV   "volsrv"
-
+#define SERVICE_NAME_DUMPPCAP "dumppcap"
 #endif
 
Index: uspace/lib/meson.build
===================================================================
--- uspace/lib/meson.build	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/lib/meson.build	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -81,4 +81,5 @@
 	'minix',
 	'nettl',
+	'pcap',
 	'ofw',
 	'pcm',
Index: uspace/lib/nic/include/nic.h
===================================================================
--- uspace/lib/nic/include/nic.h	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/lib/nic/include/nic.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -44,4 +44,5 @@
 #include <device/hw_res_parsed.h>
 #include <ops/nic.h>
+#include <pcap_iface.h>
 
 #define DEVICE_CATEGORY_NIC "nic"
@@ -278,4 +279,9 @@
 extern void nic_sw_period_stop(nic_t *);
 
+/* pcapdump interface */
+extern pcap_iface_t *nic_get_pcap_iface(nic_t *);
+
+extern errno_t nic_fun_add_to_cats(ddf_fun_t *fun);
+
 #endif // __NIC_H__
 
Index: uspace/lib/nic/include/nic_driver.h
===================================================================
--- uspace/lib/nic/include/nic_driver.h	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/lib/nic/include/nic_driver.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -46,4 +46,5 @@
 #include <nic/nic.h>
 #include <async.h>
+#include <pcapdump_iface.h>
 
 #include "nic.h"
@@ -195,4 +196,8 @@
 	 */
 	poll_request_handler on_poll_request;
+
+	/** Interface for dumping packets */
+	pcap_iface_t pcapdump;
+
 	/** Data specific for particular driver */
 	void *specific;
Index: uspace/lib/nic/include/nic_impl.h
===================================================================
--- uspace/lib/nic/include/nic_impl.h	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/lib/nic/include/nic_impl.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -87,6 +87,4 @@
 extern void nic_close_impl(ddf_fun_t *fun);
 
-extern void nic_device_added_impl(ddf_dev_t *dev);
-
 #endif
 
Index: uspace/lib/nic/meson.build
===================================================================
--- uspace/lib/nic/meson.build	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/lib/nic/meson.build	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -27,5 +27,5 @@
 #
 
-deps = [ 'drv' ]
+deps = [ 'drv' , 'pcap' ]
 c_args = [ '-DLIBNIC_INTERNAL', ]
 src = files(
Index: uspace/lib/nic/src/nic_driver.c
===================================================================
--- uspace/lib/nic/src/nic_driver.c	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/lib/nic/src/nic_driver.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -47,4 +47,5 @@
 #include <ops/nic.h>
 #include <errno.h>
+#include <pcapdump_iface.h>
 
 #include "nic_driver.h"
@@ -522,4 +523,5 @@
 	 * 		 calls it inside send_frame handler (with locked main lock)
 	 */
+	pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size);
 	fibril_rwlock_read_lock(&nic_data->rxc_lock);
 	nic_frame_type_t frame_type;
@@ -560,4 +562,5 @@
 		fibril_rwlock_write_unlock(&nic_data->stats_lock);
 	}
+	//pcapdump_packet(nic_get_pcap_iface(nic_data), frame->data, frame->size);
 	nic_release_frame(nic_data, frame);
 }
@@ -648,4 +651,9 @@
 	nic_data->dev = device;
 
+	errno_t pcap_rc  = pcapdump_init(nic_get_pcap_iface(nic_data));
+	if (pcap_rc != EOK) {
+		printf("Failed creating pcapdump port\n");
+	}
+
 	return nic_data;
 }
@@ -1133,4 +1141,9 @@
 }
 
+pcap_iface_t *nic_get_pcap_iface(nic_t *nic_data)
+{
+	return &nic_data->pcapdump;
+}
+
 /** @}
  */
Index: uspace/lib/nic/src/nic_impl.c
===================================================================
--- uspace/lib/nic/src/nic_impl.c	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/lib/nic/src/nic_impl.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -40,4 +40,5 @@
 #include <ipc/services.h>
 #include <ns.h>
+#include <pcapdump_iface.h>
 #include "nic_driver.h"
 #include "nic_ev.h"
@@ -179,5 +180,5 @@
 		return EBUSY;
 	}
-
+	pcapdump_packet(nic_get_pcap_iface(nic_data), data, size);
 	nic_data->send_frame(nic_data, data, size);
 	fibril_rwlock_read_unlock(&nic_data->main_lock);
@@ -843,4 +844,23 @@
 }
 
+errno_t nic_fun_add_to_cats(ddf_fun_t *fun)
+{
+	errno_t rc;
+	rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC);
+	if (rc != EOK)
+		goto err_add_to_cat;
+
+	rc = ddf_fun_add_to_category(fun, "pcap");
+	if (rc != EOK) {
+		//ddf_msg(LVL_ERROR, "Failed adding function to category pcap");
+		goto err_add_to_cat;
+	}
+	return EOK;
+
+err_add_to_cat:
+	ddf_fun_unbind(fun);
+	return rc;
+}
+
 /** @}
  */
Index: uspace/lib/pcap/doc/doxygoups.h
===================================================================
--- uspace/lib/pcap/doc/doxygoups.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/doc/doxygoups.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,3 @@
+/** @addtogroup libpcap libpcap
+ * @ingroup libs
+ */
Index: uspace/lib/pcap/include/pcap.h
===================================================================
--- uspace/lib/pcap/include/pcap.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/include/pcap.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * 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 libpcap
+ * @{
+ */
+/**
+ * @file
+ * @brief Headers and functions for .pcap file and packets to be dumped
+ */
+
+#ifndef PCAP_H_
+#define PCAP_H_
+
+#include <stdint.h>
+#include <stdio.h>
+#include <str_error.h>
+#include <time.h>
+#include <stdbool.h>
+#include <errno.h>
+
+#define PCAP_MAGIC_MICRO 0xA1B2C3D4
+#define PCAP_MAGIC_NANO 0xA1B23C4D
+#define PCAP_MAJOR_VERSION 0x0002
+#define PCAP_MINOR_VERSION 0x0004
+#define PCAP_SNAP_LEN 0x00040000
+
+#define PCAP_LINKTYPE_ETHERNET 1    /* IEEE 802.3 Ethernet*/
+
+/** Header of the .pcap file
+ */
+typedef struct {
+	uint32_t magic_number;
+	uint16_t major_v;
+	uint16_t minor_v;
+	uint32_t reserved1;
+	uint32_t reserved2;
+	uint32_t snaplen;
+	uint32_t additional; /** The LinkType and additional information field is in the form */
+} pcap_file_header_t;
+
+typedef struct pcap_packet_header {
+	uint32_t seconds_stamp;
+	uint32_t magic_stamp;
+	uint32_t captured_length;
+	uint32_t original_length;
+} pcap_packet_header_t;
+
+typedef struct pcap_writer pcap_writer_t;
+
+typedef struct {
+	size_t (*write_u32)(struct pcap_writer *, uint32_t);
+	size_t (*write_u16)(struct pcap_writer *, uint16_t);
+	size_t (*write_buffer)(struct pcap_writer *, const void *, size_t);
+	void (*close)(struct pcap_writer *);
+
+} pcap_writer_ops_t;
+
+/** Interface for working with .pcap file
+ */
+typedef struct pcap_writer {
+	void *data;
+	pcap_writer_ops_t *ops;
+} pcap_writer_t;
+
+errno_t pcap_writer_to_file_init(pcap_writer_t *writer, const char *filename);
+
+extern void pcap_writer_add_header(pcap_writer_t *);
+extern void pcap_writer_add_packet(
+    pcap_writer_t *writer, const void *captured_packet, size_t size);
+
+extern void pcap_set_time(pcap_packet_header_t *header, bool nano);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/pcap/include/pcap_iface.h
===================================================================
--- uspace/lib/pcap/include/pcap_iface.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/include/pcap_iface.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * 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 libpcap
+ * @{
+ */
+/** @file pcap interface
+ */
+
+#ifndef PCAP_IFACE_H_
+#define PCAP_IFACE_H_
+
+#include <errno.h>
+#include "pcap.h"
+
+typedef struct pcap_iface {
+	bool to_dump;
+	errno_t (*init)(const char *);
+	void (*add_packet)(const void *data, size_t size);
+	void (*fini)(void);
+} pcap_iface_t;
+
+extern void pcap_close_file(void);
+extern errno_t pcap_iface_init(pcap_iface_t *);
+extern errno_t pcap_init(const char *);
+extern void pcap_add_packet(const void *data, size_t size);
+
+#endif
+/** @}
+ */
Index: uspace/lib/pcap/include/pcapctl_dump.h
===================================================================
--- uspace/lib/pcap/include/pcapctl_dump.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/include/pcapctl_dump.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * 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 libpcap
+ * @{
+ */
+/**
+ * @file
+ *
+ */
+
+#ifndef _PCAPCTL_DUMP_H_
+#define _PCAPCTL_DUMP_H_
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <async.h>
+#include <loc.h>
+#include <fibril_synch.h>
+
+typedef struct {
+	async_sess_t *sess;
+} pcapctl_sess_t;
+
+extern errno_t pcapctl_dump_open(int *, pcapctl_sess_t **rsess);
+extern errno_t pcapctl_dump_close(pcapctl_sess_t *sess);
+extern errno_t pcapctl_dump_start(const char *, pcapctl_sess_t *);
+extern errno_t pcapctl_dump_stop(pcapctl_sess_t *);
+extern errno_t pcapctl_list(void);
+extern errno_t pcapctl_is_valid_device(int *);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/pcap/include/pcapdump_iface.h
===================================================================
--- uspace/lib/pcap/include/pcapdump_iface.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/include/pcapdump_iface.h	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * 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 libpcap
+ * @{
+ */
+/**
+ * @file
+ *
+ */
+
+#ifndef _PCAPDUMP_IFACE_H_
+#define _PCAPDUMP_IFACE_H_
+
+#include <errno.h>
+#include "pcap_iface.h"
+
+typedef enum {
+	PCAP_CONTROL_SET_START = IPC_FIRST_USER_METHOD,
+	PCAP_CONTROL_SET_STOP,
+	PCAP_CONTROL_GET_NAME
+} pcap_request_t;
+
+extern errno_t pcapdump_init(pcap_iface_t *);
+extern void pcapdump_packet(pcap_iface_t *, const void *, size_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/pcap/meson.build
===================================================================
--- uspace/lib/pcap/meson.build	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/meson.build	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,34 @@
+#
+# Copyright (c) 2023 Nataliia Korop
+# 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.
+#
+
+src = files(
+    'src/pcap.c',
+    'src/pcap_iface.c',
+    'src/pcapdump_iface.c',
+    'src/pcapctl_dump.c',
+)
Index: uspace/lib/pcap/src/pcap.c
===================================================================
--- uspace/lib/pcap/src/pcap.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/src/pcap.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * 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 libpcap
+ * @{
+ */
+/**
+ * @file
+ * @brief Headers and functions for .pcap file and packets to be dumped
+ */
+
+#include "pcap.h"
+
+/** Set time in seconds and microseconds for the packet header .
+ *
+ * @param header Header of the packet to be dumped.
+ *
+ */
+void pcap_set_time(pcap_packet_header_t *header, bool nano) // maybe without bool nano as nano is in pcapng
+{
+	struct timespec ts;
+	getrealtime(&ts);
+	header->seconds_stamp = (uint32_t)ts.tv_sec;
+	header->magic_stamp = (uint32_t)ts.tv_nsec / 1000;
+}
+
+/** Add pcap file header to the new .pcap file.
+ *
+ * @param writer
+ *
+ */
+void pcap_writer_add_header(pcap_writer_t *writer)
+{
+	pcap_file_header_t file_header = { PCAP_MAGIC_MICRO, PCAP_MAJOR_VERSION, PCAP_MINOR_VERSION,
+		0x00000000, 0x00000000, (uint32_t)PCAP_SNAP_LEN, (uint32_t)PCAP_LINKTYPE_ETHERNET };
+	writer->ops->write_buffer(writer, &file_header, sizeof(file_header));
+}
+
+/** Add packet to the .pcap file.
+ *
+ * @param writer
+ * @param captured_packet Packet to be dumped
+ * @param size Size of the captured packet
+ *
+ */
+void pcap_writer_add_packet(pcap_writer_t *writer, const void *captured_packet, size_t size)
+{
+	if (!writer->data)
+		return;
+	pcap_packet_header_t pcap_packet;
+	pcap_set_time(&pcap_packet, false);
+	pcap_packet.original_length = (uint32_t)size;
+
+	if (PCAP_SNAP_LEN < size) {
+		pcap_packet.captured_length = PCAP_SNAP_LEN;
+	} else {
+		pcap_packet.captured_length = size;
+	}
+	writer->ops->write_buffer(writer, &pcap_packet, sizeof(pcap_packet));
+	writer->ops->write_buffer(writer, captured_packet, pcap_packet.captured_length);
+
+}
+
+/** Initialize writing to .pcap file.
+ *
+ * @param writer    Interface for working with .pcap file
+ * @param filename  Name of the file for dumping packets
+ * @return          EOK on success or an error code
+ *
+ */
+errno_t pcap_writer_to_file_init(pcap_writer_t *writer, const char *filename)
+{
+	errno_t rc;
+	writer->data = fopen(filename, "a");
+	if (writer->data == NULL) {
+		rc = EINVAL;
+		return rc;
+	}
+	pcap_writer_add_header(writer);
+
+	rc = EOK;
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/lib/pcap/src/pcap_iface.c
===================================================================
--- uspace/lib/pcap/src/pcap_iface.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/src/pcap_iface.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * 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 libpcap
+ * @{
+ */
+/** @file
+ *  @brief pcap inteface: Dumping interface for the device which packets we want to dump
+ */
+
+#include <errno.h>
+#include "pcap_iface.h"
+
+static size_t pcap_file_w32(pcap_writer_t *writer, uint32_t data)
+{
+	return fwrite(&data, 1, 4, (FILE *)writer->data);
+}
+
+static size_t pcap_file_w16(pcap_writer_t *writer, uint16_t data)
+{
+	return fwrite(&data, 1, 2, (FILE *)writer->data);
+}
+
+static size_t pcap_file_wbuffer(pcap_writer_t *writer, const void *data, size_t size)
+{
+	return fwrite(data, 1, size, (FILE *)writer->data);
+}
+
+static void pcap_file_close(pcap_writer_t *writer)
+{
+	fclose((FILE *)writer->data);
+}
+
+static pcap_writer_ops_t file_ops = {
+
+	.write_u32 = &pcap_file_w32,
+	.write_u16 = &pcap_file_w16,
+	.write_buffer = &pcap_file_wbuffer,
+	.close = &pcap_file_close
+};
+
+static pcap_writer_t pcap_writer = {
+	.ops = &file_ops,
+};
+
+errno_t pcap_init(const char *name)
+{
+	errno_t rc = pcap_writer_to_file_init(&pcap_writer, name);
+	return rc;
+}
+
+void pcap_add_packet(const void *data, size_t size)
+{
+	if (pcap_writer.data == NULL)
+		return;
+	pcap_writer_add_packet(&pcap_writer, data, size);
+}
+
+void pcap_close_file(void)
+{
+	pcap_writer.ops->close(&pcap_writer);
+	pcap_writer.data = NULL;
+}
+
+/** Initialize interface for dumping packets
+ *
+ * @param iface Device dumping interface
+ *
+ */
+errno_t pcap_iface_init(pcap_iface_t *iface)
+{
+
+	iface->to_dump = false;
+	iface->add_packet = pcap_add_packet;
+	iface->init = pcap_init;
+	iface->fini = pcap_close_file;
+
+	return EOK;
+}
+
+/** @}
+ */
Index: uspace/lib/pcap/src/pcapctl_dump.c
===================================================================
--- uspace/lib/pcap/src/pcapctl_dump.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/src/pcapctl_dump.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * 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 libpcap
+ * @{
+ */
+/** @file
+ * @brief Client side of the pcapctl. Functions are called from the app pcapctl
+ */
+
+#include <errno.h>
+#include <async.h>
+#include <str.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include "pcapctl_dump.h"
+#include "pcapdump_iface.h"
+
+/** Finish an async exchange on the pcapctl session
+ *
+ * @param exch  Exchange to be finished
+ */
+static void pcapctl_dump_exchange_end(async_exch_t *exch)
+{
+	async_exchange_end(exch);
+}
+
+static errno_t pcapctl_cat_get_svc(int *index, service_id_t *svc)
+{
+	errno_t rc;
+	category_id_t pcap_cat;
+	size_t count;
+	service_id_t *pcap_svcs = NULL;
+
+	rc = loc_category_get_id("pcap", &pcap_cat, 0);
+	if (rc != EOK) {
+		printf("Error resolving category 'pcap'.\n");
+		return rc;
+	}
+
+	rc = loc_category_get_svcs(pcap_cat, &pcap_svcs, &count);
+	if (rc != EOK) {
+		printf("Error resolving list of pcap services.\n");
+		free(pcap_svcs);
+		return rc;
+	}
+	if (*index < (int)count) {
+		*svc =  pcap_svcs[*index];
+		free(pcap_svcs);
+		return EOK;
+	}
+
+	return ENOENT;
+}
+
+errno_t pcapctl_is_valid_device(int *index)
+{
+	errno_t rc;
+	category_id_t pcap_cat;
+	size_t count;
+	service_id_t *pcap_svcs = NULL;
+
+	rc = loc_category_get_id("pcap", &pcap_cat, 0);
+	if (rc != EOK) {
+		printf("Error resolving category pcap.\n");
+		return rc;
+	}
+
+	rc = loc_category_get_svcs(pcap_cat, &pcap_svcs, &count);
+	if (rc != EOK) {
+		printf("Error resolving list of pcap services.\n");
+		free(pcap_svcs);
+		return rc;
+	}
+	if (*index + 1 > (int)count || *index < 0) {
+		return EINVAL;
+	}
+	return EOK;
+}
+
+/**
+ *
+ */
+errno_t pcapctl_list(void)
+{
+	errno_t rc;
+	category_id_t pcap_cat;
+	size_t count;
+	service_id_t *pcap_svcs = NULL;
+
+	rc = loc_category_get_id("pcap", &pcap_cat, 0);
+	if (rc != EOK) {
+		printf("Error resolving category pcap.\n");
+		return rc;
+	}
+
+	rc = loc_category_get_svcs(pcap_cat, &pcap_svcs, &count);
+	if (rc != EOK) {
+		printf("Error resolving list of pcap services.\n");
+		free(pcap_svcs);
+		return rc;
+	}
+
+	fprintf(stdout, "Devices:\n");
+	for (unsigned i = 0; i < count; ++i) {
+		char *name = NULL;
+		loc_service_get_name(pcap_svcs[i], &name);
+		fprintf(stdout, "%d. %s\n", i, name);
+	}
+	free(pcap_svcs);
+	return EOK;
+}
+
+/**
+ *
+ */
+errno_t pcapctl_dump_open(int *index, pcapctl_sess_t **rsess)
+{
+	errno_t rc;
+	service_id_t svc;
+	pcapctl_sess_t *sess = calloc(1, sizeof(pcapctl_sess_t));
+	if (sess == NULL)
+		return ENOMEM;
+
+	rc  = pcapctl_cat_get_svc(index, &svc);
+	if (rc != EOK) {
+		printf("Error finding the device with index: %d\n", *index);
+		goto error;
+	}
+
+	async_sess_t *new_session = loc_service_connect(svc, INTERFACE_PCAP_CONTROL, 0);
+	if (new_session == NULL) {
+		fprintf(stderr, "Error connecting to service.\n");
+		rc =  EREFUSED;
+		goto error;
+	}
+	sess->sess = new_session;
+	*rsess = sess;
+	return EOK;
+error:
+	pcapctl_dump_close(sess);
+	return rc;
+}
+
+/**
+ *
+ */
+errno_t pcapctl_dump_close(pcapctl_sess_t *sess)
+{
+	free(sess);
+	return EOK;
+}
+
+/** Starting a new session for pcapctl
+ *
+ * @param name Name of the file to dump packets to
+ * @param sess session to start
+ * @return EOK on success or an error code
+ */
+errno_t pcapctl_dump_start(const char *name, pcapctl_sess_t *sess)
+{
+	errno_t rc;
+	async_exch_t *exch = async_exchange_begin(sess->sess);
+
+	size_t size = str_size(name);
+	aid_t req = async_send_0(exch, PCAP_CONTROL_SET_START, NULL);
+
+	rc = async_data_write_start(exch, (void *) name, size);
+
+	pcapctl_dump_exchange_end(exch);
+
+	if (rc != EOK) {
+		async_forget(req);
+		return rc;
+	}
+
+	errno_t retval;
+	async_wait_for(req, &retval);
+	return retval;
+}
+
+/** Finish current session for pcapctl
+ *
+ * @param sess Session to finish
+ * @return EOK on success or an error code
+ */
+errno_t pcapctl_dump_stop(pcapctl_sess_t *sess)
+{
+	errno_t rc;
+	async_exch_t *exch = async_exchange_begin(sess->sess);
+	rc = async_req_0_0(exch, PCAP_CONTROL_SET_STOP);
+
+	pcapctl_dump_exchange_end(exch);
+	return rc;
+}
+
+/** @}
+ */
Index: uspace/lib/pcap/src/pcapdump_iface.c
===================================================================
--- uspace/lib/pcap/src/pcapdump_iface.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
+++ uspace/lib/pcap/src/pcapdump_iface.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2023 Nataliia Korop
+ * 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 libpcap
+ * @{
+ */
+/**
+ * @file
+ * @brief Server side of the pcapctl
+ */
+
+#include <async.h>
+#include <errno.h>
+#include <fibril_synch.h>
+
+#include "pcapdump_iface.h"
+
+FIBRIL_MUTEX_INITIALIZE(to_dump_mutex);
+
+static void pcapdump_start_srv(ipc_call_t *icall, pcap_iface_t *iface)
+{
+	char *data;
+	size_t size;
+	errno_t rc = async_data_write_accept((void **) &data, false, 0, 0, 0, &size);
+	if (rc != EOK) {
+		async_answer_0(icall, rc);
+		return;
+	}
+
+	/** When try to start when already started, close current and starts new */
+	if (iface->to_dump == true) {
+		iface->fini();
+	}
+	iface->init((const char *)data);
+
+	fibril_mutex_lock(&to_dump_mutex);
+	iface->to_dump = true;
+	fibril_mutex_unlock(&to_dump_mutex);
+
+	async_answer_0(icall, rc);
+}
+
+static void pcapdump_stop_srv(ipc_call_t *icall, pcap_iface_t *iface)
+{
+	/** If want to stop, when already stopped, do nothing */
+	if (iface->to_dump == false) {
+		async_answer_0(icall, EOK);
+		return;
+	}
+
+	fibril_mutex_lock(&to_dump_mutex);
+	iface->to_dump = false;
+	fibril_mutex_unlock(&to_dump_mutex);
+
+	iface->fini();
+	async_answer_0(icall, EOK);
+}
+
+static void pcapdump_conn(ipc_call_t *icall, void *arg)
+{
+	pcap_iface_t *iface = (pcap_iface_t *)arg;
+
+	assert((iface != NULL) && "pcapdump requires pcap interface\n");
+
+	/* Accept connection */
+	async_accept_0(icall);
+
+	while (true) {
+		ipc_call_t call;
+		async_get_call(&call);
+		sysarg_t method = ipc_get_imethod(&call);
+		if (!method) {
+			/* The other side has hung up */
+			async_answer_0(&call, EOK);
+			break;
+		}
+		switch (method) {
+		case PCAP_CONTROL_SET_START:
+			pcapdump_start_srv(&call, iface);
+			break;
+		case PCAP_CONTROL_SET_STOP:
+			pcapdump_stop_srv(&call, iface);
+			break;
+		default:
+			async_answer_0(&call, EINVAL);
+			break;
+		}
+	}
+}
+
+errno_t pcapdump_init(pcap_iface_t *iface)
+{
+	port_id_t port;
+	errno_t rc;
+
+	rc = pcap_iface_init(iface);
+
+	if (rc != EOK) {
+		printf("Failed creating pcap interface: %s", str_error(rc));
+		return rc;
+	}
+
+	rc = async_create_port(INTERFACE_PCAP_CONTROL,
+	    pcapdump_conn, iface, &port);
+	if (rc != EOK) {
+		return rc;
+	}
+	return EOK;
+}
+
+/** Dumping function for driver
+ *
+ * Called every time, the packet is sent/recieved by the device
+ *
+ * @param iface Dumping interface
+ * @param data The packet
+ * @param size Size of the packet
+ *
+ */
+void pcapdump_packet(pcap_iface_t *iface, const void *data, size_t size)
+{
+
+	if (iface == NULL) {
+		return;
+	}
+
+	if (!iface->to_dump) {
+		return;
+	}
+
+	iface->add_packet(data, size);
+}
+
+/** @}
+ */
Index: uspace/srv/locsrv/locsrv.c
===================================================================
--- uspace/srv/locsrv/locsrv.c	(revision af3235d07726dfc8b146c760a25544ea3ac29f9d)
+++ uspace/srv/locsrv/locsrv.c	(revision 87488278a46c7a401ce6ee33baff59600dfccf37)
@@ -1393,4 +1393,6 @@
 	categ_dir_add_cat(&cdir, cat);
 
+	cat = category_new("pcap");
+	categ_dir_add_cat(&cdir, cat);
 	return true;
 }
