Index: uspace/app/pcapctl/main.c
===================================================================
--- uspace/app/pcapctl/main.c	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/app/pcapctl/main.c	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -107,5 +107,5 @@
 	bool stop = false;
 	int dev_number = -1;
-	const char *output_file_name;
+	const char *output_file_name = "";
 	int idx = 0;
 	int ret = 0;
@@ -117,39 +117,50 @@
 		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;
+			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;
 			}
-			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;
+			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);
+	printf("%s: HelenOS Packet Dumping utility: device - %d.\n", NAME, dev_number);
 
 	if (start) {
-		// start with dev number and optional..name
+		/* start with dev number and name*/
 		start_dumping(&dev_number, output_file_name);
 	} else if (stop) {
-		//stop with dev number
+		/* stop with dev number*/
 		stop_dumping(&dev_number);
 	}
Index: uspace/drv/nic/e1k/e1k.c
===================================================================
--- uspace/drv/nic/e1k/e1k.c	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/drv/nic/e1k/e1k.c	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -2209,6 +2209,4 @@
 	return EOK;
 
-	// err_add_to_cat:
-	// ddf_fun_unbind(fun);
 err_fun_bind:
 err_rx_structure:
Index: uspace/lib/nic/include/nic.h
===================================================================
--- uspace/lib/nic/include/nic.h	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/nic/include/nic.h	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -280,5 +280,5 @@
 
 /* pcapdump interface */
-extern pcap_iface_t *nic_get_pcap_iface(nic_t *);
+extern pcap_dumper_t *nic_get_pcap_iface(nic_t *);
 
 extern errno_t nic_fun_add_to_cats(ddf_fun_t *fun);
Index: uspace/lib/nic/include/nic_driver.h
===================================================================
--- uspace/lib/nic/include/nic_driver.h	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/nic/include/nic_driver.h	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -198,5 +198,5 @@
 
 	/** Interface for dumping packets */
-	pcap_iface_t pcapdump;
+	pcap_dumper_t pcapdump;
 
 	/** Data specific for particular driver */
Index: uspace/lib/nic/src/nic_driver.c
===================================================================
--- uspace/lib/nic/src/nic_driver.c	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/nic/src/nic_driver.c	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -1141,5 +1141,5 @@
 }
 
-pcap_iface_t *nic_get_pcap_iface(nic_t *nic_data)
+pcap_dumper_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 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/nic/src/nic_impl.c	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -850,5 +850,4 @@
 	if (rc != EOK)
 		return rc;
-		return rc;
 
 	rc = ddf_fun_add_to_category(fun, "pcap");
Index: uspace/lib/pcap/include/pcap.h
===================================================================
--- uspace/lib/pcap/include/pcap.h	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/pcap/include/pcap.h	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -54,4 +54,5 @@
 #define PCAP_LINKTYPE_ETHERNET 1    /* IEEE 802.3 Ethernet */
 #define PCAP_LINKTYPE_IP_RAW 101	/* Raw IP packet */
+#define PCAP_LINKTYPE_IEEE802_11_RADIO 127
 #define WIRESHARK_EX 0xc
 #define WIRESHARK_SNAPLEN 0xffff
@@ -99,5 +100,5 @@
     pcap_writer_t *writer, const void *captured_packet, size_t size);
 
-extern void pcap_set_time(pcap_packet_header_t *header, bool nano);
+extern void pcap_set_time(pcap_packet_header_t *header);
 
 #endif
Index: uspace/lib/pcap/include/pcap_iface.h
===================================================================
--- uspace/lib/pcap/include/pcap_iface.h	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/pcap/include/pcap_iface.h	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -37,24 +37,23 @@
 
 #include <errno.h>
+#include <fibril_synch.h>
 #include "pcap.h"
 
-typedef struct pcap_iface {
+typedef struct pcap_dumper {
+	fibril_mutex_t mutex;
 	bool to_dump;
-	errno_t (*init)(const char *);
-	void (*add_packet)(const void *data, size_t size);
-	void (*fini)(void);
-} pcap_iface_t;
+	pcap_writer_t writer;
+} pcap_dumper_t;
 
-extern void pcap_close_file(void);
-extern errno_t pcap_iface_init(pcap_iface_t *);
-//init to file
-//init to serial
-//add packet, dostane strukturu, data, velikost ... to to this pcap_iface_t
+
+extern void pcap_dumper_stop(struct pcap_dumper *);
+
+extern errno_t pcap_dumper_init(pcap_dumper_t *);
+
 // v ramci init jeste linktype prg
 //set snaplen taky lze pridavat prg
-//create kam posila 
-// init
-extern errno_t pcap_init(const char *);
-extern void pcap_add_packet(const void *data, size_t size);
+
+extern errno_t pcap_dumper_start(struct pcap_dumper *, const char *);
+extern void pcap_dumper_add_packet(struct pcap_dumper *, const void *data, size_t size);
 
 #endif
Index: uspace/lib/pcap/include/pcapdump_iface.h
===================================================================
--- uspace/lib/pcap/include/pcapdump_iface.h	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/pcap/include/pcapdump_iface.h	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -48,7 +48,6 @@
 } pcap_request_t;
 
-extern errno_t pcapdump_init(pcap_iface_t *);
-extern void pcapdump_packet(pcap_iface_t *, const void *, size_t);
-
+extern errno_t pcapdump_init(pcap_dumper_t *);
+extern void pcapdump_packet(pcap_dumper_t *, const void *, size_t);
 extern void pcapdump_conn(ipc_call_t *, void *);
 #endif
Index: uspace/lib/pcap/src/pcap.c
===================================================================
--- uspace/lib/pcap/src/pcap.c	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/pcap/src/pcap.c	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -43,10 +43,10 @@
  *
  */
-void pcap_set_time(pcap_packet_header_t *header, bool nano) // maybe without bool nano as nano is in pcapng
+void pcap_set_time(pcap_packet_header_t *header)
 {
 	struct timespec ts;
 	getrealtime(&ts);
 	header->seconds_stamp = (uint32_t)ts.tv_sec;
-	header->magic_stamp = (uint32_t)ts.tv_nsec / 1000;
+	header->magic_stamp = (uint32_t)ts.tv_nsec;
 }
 
@@ -58,5 +58,5 @@
 void pcap_writer_add_header(pcap_writer_t *writer)
 {
-	pcap_file_header_t file_header = { PCAP_MAGIC_MICRO, PCAP_MAJOR_VERSION, PCAP_MINOR_VERSION,
+	pcap_file_header_t file_header = { PCAP_MAGIC_NANO, 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));
@@ -75,6 +75,6 @@
 		return;
 	pcap_packet_header_t pcap_packet;
-	pcap_set_time(&pcap_packet, false);
-	pcap_packet.original_length = (uint32_t)size;
+	pcap_set_time(&pcap_packet);
+	pcap_packet.original_length = size;
 
 	if (PCAP_SNAP_LEN < size) {
@@ -98,5 +98,4 @@
 {
 	errno_t rc;
-	printf("File: %s\n", filename);
 	writer->data = fopen(filename, "a");
 	if (writer->data == NULL) {
Index: uspace/lib/pcap/src/pcap_iface.c
===================================================================
--- uspace/lib/pcap/src/pcap_iface.c	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/pcap/src/pcap_iface.c	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -65,39 +65,95 @@
 };
 
-static pcap_writer_t pcap_writer = {
-	.ops = &file_ops,
-};
+// static size_t pcap_short_file_w32(pcap_writer_t *writer, uint32_t data)
+// {
+// 	return fwrite(&data, 1, 4, (FILE *)writer->data);
+// }
 
-errno_t pcap_init(const char *name)
+// static size_t pcap_short_file_w16(pcap_writer_t *writer, uint16_t data)
+// {
+// 	return fwrite(&data, 1, 2, (FILE *)writer->data);
+// }
+
+// static size_t pcap_short_file_wbuffer(pcap_writer_t *writer, const void *data, size_t size)
+// {
+// 	return fwrite(data, 1, size<60?size:60, (FILE *)writer->data);
+// }
+
+// static void pcap_short_file_close(pcap_writer_t *writer)
+// {
+// 	fclose((FILE *)writer->data);
+// }
+
+
+// static pcap_writer_ops_t short_file_ops = {
+// 	.write_u32 = &pcap_short_file_w32,
+// 	.write_u16 = &pcap_short_file_w16,
+// 	.write_buffer = &pcap_short_file_wbuffer,
+// 	.close = &pcap_short_file_close
+
+// };
+
+errno_t pcap_dumper_start(struct pcap_dumper *dumper, const char *name)
 {
-	errno_t rc = pcap_writer_to_file_init(&pcap_writer, name);
+	fibril_mutex_lock(&dumper->mutex);
+
+	/** When try to start when already started, close current and starts new */
+	if (dumper->to_dump == true)
+	{
+		pcap_dumper_stop(dumper);
+	}
+	errno_t rc = pcap_writer_to_file_init(&dumper->writer, name);
+	if (rc == EOK)
+	{
+		dumper->to_dump = true;
+	}
+	else
+	{
+		printf("Failed creating pcap dumper: %s", str_error(rc));
+	}
+	fibril_mutex_unlock(&dumper->mutex);
 	return rc;
 }
 
-void pcap_add_packet(const void *data, size_t size)
+//udelat globalni
+void pcap_dumper_add_packet(struct pcap_dumper *dumper, const void *data, size_t size)
 {
-	if (pcap_writer.data == NULL)
+	fibril_mutex_lock(&dumper->mutex);
+
+	if (dumper->writer.data == NULL || !dumper->to_dump)
+	{
+		fibril_mutex_unlock(&dumper->mutex);
 		return;
-	pcap_writer_add_packet(&pcap_writer, data, size);
+	}
+	pcap_writer_add_packet(&dumper->writer, data, size);
+	fibril_mutex_unlock(&dumper->mutex);
 }
 
-void pcap_close_file(void)
+//udelt globalni
+void pcap_dumper_stop(struct pcap_dumper *dumper)
 {
-	pcap_writer.ops->close(&pcap_writer);
-	pcap_writer.data = NULL;
+	fibril_mutex_lock(&dumper->mutex);
+
+	/** If want to stop, when already stopped, do nothing */
+	if (dumper->to_dump == false) {
+		fibril_mutex_unlock(&dumper->mutex);
+		return;
+	}
+	dumper->to_dump = false;
+	dumper->writer.ops->close(&dumper->writer);
+	dumper->writer.data = NULL;
+	fibril_mutex_unlock(&dumper->mutex);
 }
 
 /** Initialize interface for dumping packets
  *
- * @param iface Device dumping interface
+ * @param dumper Device dumping interface
  *
  */
-errno_t pcap_iface_init(pcap_iface_t *iface)
+errno_t pcap_dumper_init(pcap_dumper_t *dumper)
 {
-	iface->to_dump = false;
-	iface->add_packet = pcap_add_packet;
-	iface->init = pcap_init;
-	iface->fini = pcap_close_file;
-
+	fibril_mutex_initialize(&dumper->mutex);
+	dumper->to_dump = false;
+	dumper->writer.ops = &file_ops;
 	return EOK;
 }
Index: uspace/lib/pcap/src/pcapctl_dump.c
===================================================================
--- uspace/lib/pcap/src/pcapctl_dump.c	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/pcap/src/pcapctl_dump.c	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -151,18 +151,11 @@
 	printf("number: %d\n", *index);
 	if (*index == -1) {
-
-		rc = loc_service_get_id("net/eth1", &svc, 0);
-		if (rc != EOK)
-		{
-			fprintf(stderr, "Error getting service id.\n");
-			return ENOENT;
-		}
-	}
-	else {
-		rc  = pcapctl_cat_get_svc(index, &svc);
-		if (rc != EOK) {
-			printf("Error finding the device with index: %d\n", *index);
-			goto error;
-		}
+		*index = 0;
+	}
+
+	rc  = pcapctl_cat_get_svc(index, &svc);
+	if (rc != EOK) {
+		printf("Error finding the device with index: %d\n", *index);
+		goto error;
 	}
 
@@ -206,5 +199,5 @@
 	aid_t req = async_send_0(exch, PCAP_CONTROL_SET_START, NULL);
 
-	rc = async_data_write_start(exch, (const void *) name, size);
+	rc = async_data_write_start(exch, (const void *)name, size);
 
 	pcapctl_dump_exchange_end(exch);
Index: uspace/lib/pcap/src/pcapdump_iface.c
===================================================================
--- uspace/lib/pcap/src/pcapdump_iface.c	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/lib/pcap/src/pcapdump_iface.c	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -38,15 +38,15 @@
 #include <async.h>
 #include <errno.h>
+#include <stdlib.h>
 #include <fibril_synch.h>
+#include <str.h>
 
 #include "pcapdump_iface.h"
 
-FIBRIL_MUTEX_INITIALIZE(to_dump_mutex);
-
-static void pcapdump_start_srv(ipc_call_t *icall, pcap_iface_t *iface)
+static void pcapdump_start_srv(ipc_call_t *icall, pcap_dumper_t *dumper)
 {
 	char *data;
 	size_t size;
-	errno_t rc = async_data_write_accept((void **) &data, false, 0, 0, 0, &size);
+	errno_t rc = async_data_write_accept((void **) &data, true, 0, 0, 0, &size);
 	if (rc != EOK) {
 		async_answer_0(icall, rc);
@@ -54,30 +54,18 @@
 	}
 
-	/** When try to start when already started, close current and starts new */
-	if (iface->to_dump == true) {
-		iface->fini();
+	assert(str_length(data) == size && "Data were damaged during transmission.\n");
+
+	rc = pcap_dumper_start(dumper, (const char *)data);
+	free(data);
+	if (rc != EOK)
+	{
+		//TODO what?
 	}
-	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);
+	async_answer_0(icall, EOK);
 }
 
-static void pcapdump_stop_srv(ipc_call_t *icall, pcap_iface_t *iface)
+static void pcapdump_stop_srv(ipc_call_t *icall, pcap_dumper_t *dumper)
 {
-	/** 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();
+	pcap_dumper_stop(dumper);
 	async_answer_0(icall, EOK);
 }
@@ -85,7 +73,7 @@
 void pcapdump_conn(ipc_call_t *icall, void *arg)
 {
-	pcap_iface_t *iface = (pcap_iface_t *)arg;
-	printf("pcapdump_conn\n");
-	assert((iface != NULL) && "pcapdump requires pcap interface\n");
+	pcap_dumper_t *dumper = (pcap_dumper_t *)arg;
+
+	assert((dumper != NULL) && "pcapdump requires pcap dumper\n");
 
 	/* Accept connection */
@@ -103,8 +91,8 @@
 		switch (method) {
 		case PCAP_CONTROL_SET_START:
-			pcapdump_start_srv(&call, iface);
+			pcapdump_start_srv(&call, dumper);
 			break;
 		case PCAP_CONTROL_SET_STOP:
-			pcapdump_stop_srv(&call, iface);
+			pcapdump_stop_srv(&call, dumper);
 			break;
 		default:
@@ -115,10 +103,10 @@
 }
 
-errno_t pcapdump_init(pcap_iface_t *iface)
+errno_t pcapdump_init(pcap_dumper_t *dumper)
 {
 	port_id_t port;
 	errno_t rc;
 
-	rc = pcap_iface_init(iface);
+	rc = pcap_dumper_init(dumper);
 
 	if (rc != EOK) {
@@ -128,5 +116,5 @@
 
 	rc = async_create_port(INTERFACE_PCAP_CONTROL,
-	    pcapdump_conn, iface, &port);
+	    pcapdump_conn, dumper, &port);
 	if (rc != EOK) {
 		return rc;
@@ -139,21 +127,17 @@
  * Called every time, the packet is sent/recieved by the device
  *
- * @param iface Dumping interface
+ * @param dumper 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)
+void pcapdump_packet(pcap_dumper_t *dumper, const void *data, size_t size)
 {
 
-	if (iface == NULL) {
+	if (dumper == NULL) {
 		return;
 	}
 
-	if (!iface->to_dump) {
-		return;
-	}
-
-	iface->add_packet(data, size);
+	pcap_dumper_add_packet(dumper, data, size);
 }
 
Index: uspace/srv/net/ethip/ethip.c
===================================================================
--- uspace/srv/net/ethip/ethip.c	(revision 59fe16d48928236158c9d3c9e7e1180bdbfe21d8)
+++ uspace/srv/net/ethip/ethip.c	(revision 03cd7a9eb6605c4b72ed6e4be5bc4822a6665043)
@@ -55,5 +55,4 @@
 #define NAME "ethip"
 /** Interface for dumping packets */
-pcap_iface_t pcapdump;
 
 static errno_t ethip_open(iplink_srv_t *srv);
@@ -93,9 +92,4 @@
 	}
 
-	rc = pcapdump_init(&pcapdump);
-	if (rc != EOK) {
-		log_msg(LOG_DEFAULT, LVL_ERROR, "Failed initializing dumping interface.");
-		return rc;
-	}
 
 	rc = ethip_nic_discovery_start();
@@ -206,5 +200,4 @@
 	if (rc != EOK)
 		return rc;
-	pcapdump_packet(&pcapdump, data, size);
 	rc = ethip_nic_send(nic, data, size);
 	free(data);
@@ -251,5 +244,4 @@
 		return rc;
 	}
-	pcapdump_packet(&pcapdump, data, size);
 
 	iplink_recv_sdu_t sdu;
