Index: uspace/lib/c/generic/dhcp.c
===================================================================
--- uspace/lib/c/generic/dhcp.c	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/generic/dhcp.c	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -84,4 +84,14 @@
 }
 
+int dhcp_discover(sysarg_t link_id)
+{
+	async_exch_t *exch = async_exchange_begin(dhcp_sess);
+
+	int rc = async_req_1_0(exch, DHCP_DISCOVER, link_id);
+	async_exchange_end(exch);
+
+	return rc;
+}
+
 /** @}
  */
Index: uspace/lib/c/generic/fibril.c
===================================================================
--- uspace/lib/c/generic/fibril.c	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/generic/fibril.c	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -57,5 +57,5 @@
 /**
  * This futex serializes access to ready_list,
- * serialized_list and manager_list.
+ * serialized_list, manager_list and fibril_list.
  */
 static futex_t fibril_futex = FUTEX_INITIALIZER;
@@ -126,12 +126,19 @@
 	
 	fibril->waits_for = NULL;
+
+	futex_lock(&fibril_futex);
 	list_append(&fibril->all_link, &fibril_list);
+	futex_unlock(&fibril_futex);
 	
 	return fibril;
 }
 
-void fibril_teardown(fibril_t *fibril)
-{
+void fibril_teardown(fibril_t *fibril, bool locked)
+{	
+	if (!locked)
+		futex_lock(&fibril_futex);
 	list_remove(&fibril->all_link);
+	if (!locked)
+		futex_unlock(&fibril_futex);
 	tls_free(fibril->tcb);
 	free(fibril);
@@ -208,5 +215,5 @@
 					as_area_destroy(stack);
 				}
-				fibril_teardown(srcf->clean_after_me);
+				fibril_teardown(srcf->clean_after_me, true);
 				srcf->clean_after_me = NULL;
 			}
@@ -294,5 +301,5 @@
 	    AS_AREA_LATE_RESERVE);
 	if (fibril->stack == (void *) -1) {
-		fibril_teardown(fibril);
+		fibril_teardown(fibril, false);
 		return 0;
 	}
@@ -321,5 +328,5 @@
 	
 	as_area_destroy(fibril->stack);
-	fibril_teardown(fibril);
+	fibril_teardown(fibril, false);
 }
 
Index: uspace/lib/c/generic/getopt.c
===================================================================
--- uspace/lib/c/generic/getopt.c	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/generic/getopt.c	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -95,11 +95,8 @@
  * Compute the greatest common divisor of a and b.
  */
-static int
-gcd(a, b)
-	int a;
-	int b;
+static int gcd(int a, int b)
 {
 	int c;
-
+	
 	c = a % b;
 	while (c != 0) {
@@ -108,5 +105,5 @@
 		c = a % b;
 	}
-	   
+	
 	return b;
 }
@@ -117,10 +114,6 @@
  * in each block).
  */
-static void
-permute_args(panonopt_start, panonopt_end, opt_end, nargv)
-	int panonopt_start;
-	int panonopt_end;
-	int opt_end;
-	char **nargv;
+static void permute_args(int panonopt_start, int panonopt_end, int opt_end,
+    char **nargv)
 {
 	int cstart, cyclelen, i, j, ncycle, nnonopts, nopts, pos;
@@ -157,9 +150,5 @@
  *  Returns -2 if -- is found (can be long option or end of options marker).
  */
-static int
-getopt_internal(nargc, nargv, options)
-	int nargc;
-	char **nargv;
-	const char *options;
+static int getopt_internal(int nargc, char **nargv, const char *options)
 {
 	const char *oli;				/* option letter list index */
@@ -299,9 +288,5 @@
  *	Parse argc/argv argument vector.
  */
-int
-getopt(nargc, nargv, options)
-	int nargc;
-	char * const *nargv;
-	const char *options;
+int getopt(int nargc, char * const *nargv, const char *options)
 {
 	int retval;
@@ -332,11 +317,6 @@
  *	Parse argc/argv argument vector.
  */
-int
-getopt_long(nargc, nargv, options, long_options, idx)
-	int nargc;
-	char * const *nargv;
-	const char *options;
-	const struct option *long_options;
-	int *idx;
+int getopt_long(int nargc, char * const *nargv, const char *options,
+    const struct option *long_options, int *idx)
 {
 	int retval;
Index: uspace/lib/c/generic/irq.c
===================================================================
--- uspace/lib/c/generic/irq.c	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/generic/irq.c	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -35,4 +35,19 @@
 #include <ipc/irq.h>
 #include <libc.h>
+#include <stdlib.h>
+#include <macros.h>
+
+static irq_cmd_t default_cmds[] = {
+	{
+		.cmd = CMD_ACCEPT
+	}
+};
+
+static const irq_code_t default_ucode = {
+	0,
+	NULL,
+	ARRAY_SIZE(default_cmds),
+	default_cmds
+};
 
 /** Subscribe to IRQ notification.
@@ -49,4 +64,7 @@
     const irq_code_t *ucode)
 {
+	if (ucode == NULL)
+		ucode = &default_ucode;
+	
 	return __SYSCALL4(SYS_IPC_IRQ_SUBSCRIBE, inr, devno, method,
 	    (sysarg_t) ucode);
Index: uspace/lib/c/generic/libc.c
===================================================================
--- uspace/lib/c/generic/libc.c	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/generic/libc.c	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -122,5 +122,5 @@
 		__stdio_done();
 		task_retval(status);
-		fibril_teardown(__tcb_get()->fibril_data);
+		fibril_teardown(__tcb_get()->fibril_data, false);
 	}
 	
Index: uspace/lib/c/generic/thread.c
===================================================================
--- uspace/lib/c/generic/thread.c	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/generic/thread.c	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -88,5 +88,5 @@
 #endif
 	
-	fibril_teardown(fibril);
+	fibril_teardown(fibril, false);
 	
 	thread_exit(0);
Index: uspace/lib/c/include/fibril.h
===================================================================
--- uspace/lib/c/include/fibril.h	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/include/fibril.h	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -94,5 +94,5 @@
 extern void fibril_destroy(fid_t fid);
 extern fibril_t *fibril_setup(void);
-extern void fibril_teardown(fibril_t *f);
+extern void fibril_teardown(fibril_t *f, bool locked);
 extern int fibril_switch(fibril_switch_type_t stype);
 extern void fibril_add_ready(fid_t fid);
Index: uspace/lib/c/include/ieee80211/ieee80211.h
===================================================================
--- uspace/lib/c/include/ieee80211/ieee80211.h	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
+++ uspace/lib/c/include/ieee80211/ieee80211.h	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015 Jan Kolarik
+ * 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 libc
+ *  @{
+ */
+
+/** @file ieee80211.h
+ *  IEEE 802.11 common definitions.
+ */
+
+#ifndef LIBC_IEEE80211_H_
+#define LIBC_IEEE80211_H_
+
+#include <malloc.h>
+#include <adt/list.h>
+#include <nic/nic.h>
+#include <time.h>
+
+/** Max length of scan results array. */
+#define IEEE80211_MAX_RESULTS_LENGTH  32
+
+/** Max SSID length including null character. */
+#define IEEE80211_MAX_SSID_LENGTH  35
+
+/** WiFi security authentication method indicator. */
+typedef enum {
+	IEEE80211_SECURITY_OPEN,
+	IEEE80211_SECURITY_WEP,
+	IEEE80211_SECURITY_WPA,
+	IEEE80211_SECURITY_WPA2
+} ieee80211_security_type_t;
+
+/** WiFi security suite indicator. */
+typedef enum {
+	IEEE80211_SECURITY_SUITE_WEP40,
+	IEEE80211_SECURITY_SUITE_WEP104,
+	IEEE80211_SECURITY_SUITE_CCMP,
+	IEEE80211_SECURITY_SUITE_TKIP
+} ieee80211_security_suite_t;
+
+/** WiFi security authentication method indicator. */
+typedef enum {
+	IEEE80211_SECURITY_AUTH_PSK,
+	IEEE80211_SECURITY_AUTH_8021X
+} ieee80211_security_auth_t;
+
+/** Structure for indicating security network security settings. */
+typedef struct {
+	int type;
+	int group_alg;
+	int pair_alg;
+	int auth;
+} ieee80211_security_t;
+
+/** Structure with scan result info. */
+typedef struct {
+	nic_address_t bssid;
+	char ssid[IEEE80211_MAX_SSID_LENGTH];
+	uint8_t channel;
+	ieee80211_security_t security;
+} ieee80211_scan_result_t;
+
+/** Array of scan results info. */
+typedef struct {
+	uint8_t length;
+	ieee80211_scan_result_t results[IEEE80211_MAX_RESULTS_LENGTH];
+} ieee80211_scan_results_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/c/include/inet/dhcp.h
===================================================================
--- uspace/lib/c/include/inet/dhcp.h	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/include/inet/dhcp.h	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -41,4 +41,5 @@
 extern int dhcp_link_add(sysarg_t);
 extern int dhcp_link_remove(sysarg_t);
+extern int dhcp_discover(sysarg_t);
 
 #endif
Index: uspace/lib/c/include/ipc/dev_iface.h
===================================================================
--- uspace/lib/c/include/ipc/dev_iface.h	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/include/ipc/dev_iface.h	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -48,4 +48,7 @@
 	/** Network interface controller interface */
 	NIC_DEV_IFACE,
+		
+	/** IEEE 802.11 interface controller interface */
+	IEEE80211_DEV_IFACE,
 	
 	/** Interface provided by any PCI device. */
Index: uspace/lib/c/include/ipc/dhcp.h
===================================================================
--- uspace/lib/c/include/ipc/dhcp.h	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/include/ipc/dhcp.h	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -41,5 +41,6 @@
 typedef enum {
 	DHCP_LINK_ADD = IPC_FIRST_USER_METHOD,
-	DHCP_LINK_REMOVE
+	DHCP_LINK_REMOVE,
+	DHCP_DISCOVER
 } dhcp_request_t;
 
Index: uspace/lib/c/include/malloc.h
===================================================================
--- uspace/lib/c/include/malloc.h	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/include/malloc.h	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -44,5 +44,6 @@
 extern void *memalign(const size_t align, const size_t size)
     __attribute__((malloc));
-extern void *realloc(const void *addr, const size_t size);
+extern void *realloc(const void *addr, const size_t size)
+    __attribute__((warn_unused_result));
 extern void free(const void *addr);
 extern void *heap_check(void);
Index: uspace/lib/c/include/mem.h
===================================================================
--- uspace/lib/c/include/mem.h	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/include/mem.h	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -40,9 +40,13 @@
 
 extern void *memset(void *, int, size_t)
+    __attribute__((nonnull(1)))
     ATTRIBUTE_OPTIMIZE("-fno-tree-loop-distribute-patterns");
 extern void *memcpy(void *, const void *, size_t)
+    __attribute__((nonnull(1, 2)))
     ATTRIBUTE_OPTIMIZE("-fno-tree-loop-distribute-patterns");
-extern void *memmove(void *, const void *, size_t);
-extern int memcmp(const void *, const void *, size_t);
+extern void *memmove(void *, const void *, size_t)
+    __attribute__((nonnull(1, 2)));
+extern int memcmp(const void *, const void *, size_t)
+    __attribute__((nonnull(1, 2)));
 
 #endif
Index: uspace/lib/c/include/task.h
===================================================================
--- uspace/lib/c/include/task.h	(revision c3f7d37086023df6580ccd4691db2d699c80ccf6)
+++ uspace/lib/c/include/task.h	(revision 048cd69e69ce8a5ca8bbf5d8a5b5451745dca93a)
@@ -60,5 +60,6 @@
 extern int task_spawn(task_id_t *, task_wait_t *, const char *path, int,
     va_list ap);
-extern int task_spawnl(task_id_t *, task_wait_t *, const char *path, ...);
+extern int task_spawnl(task_id_t *, task_wait_t *, const char *path, ...)
+    __attribute__((sentinel));
 
 extern int task_setup_wait(task_id_t, task_wait_t *);
