Index: uspace/srv/net/netif/lo/lo.c
===================================================================
--- uspace/srv/net/netif/lo/lo.c	(revision 774e6d1abebc631f873d85e623bf7aa61b0aecea)
+++ uspace/srv/net/netif/lo/lo.c	(revision fe8dfa6849229e829003d0fb83de58148a0aa45d)
@@ -48,9 +48,6 @@
 #include <packet_client.h>
 #include <net/device.h>
-#include <nil_interface.h>
 #include <netif_skel.h>
-
-/** Default hardware address. */
-#define DEFAULT_ADDR  0
+#include <nil_remote.h>
 
 /** Default address length. */
@@ -60,6 +57,6 @@
 #define NAME  "lo"
 
-/** Network interface global data. */
-netif_globals_t netif_globals;
+static uint8_t default_addr[DEFAULT_ADDR_LEN] =
+    {0, 0, 0, 0, 0, 0};
 
 int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
@@ -74,8 +71,5 @@
 		return EBADMEM;
 	
-	uint8_t *addr = (uint8_t *) malloc(DEFAULT_ADDR_LEN);
-	memset(addr, DEFAULT_ADDR, DEFAULT_ADDR_LEN);
-	
-	address->value = addr;
+	address->value = default_addr;
 	address->length = DEFAULT_ADDR_LEN;
 	
@@ -85,60 +79,67 @@
 int netif_get_device_stats(device_id_t device_id, device_stats_t *stats)
 {
-	netif_device_t *device;
-	int rc;
-
 	if (!stats)
 		return EBADMEM;
-
-	rc = find_device(device_id, &device);
+	
+	netif_device_t *device;
+	int rc = find_device(device_id, &device);
 	if (rc != EOK)
 		return rc;
-
+	
 	memcpy(stats, (device_stats_t *) device->specific,
 	    sizeof(device_stats_t));
-
-	return EOK;
-}
-
-/** Changes the loopback state.
- *
- * @param[in] device	The device structure.
- * @param[in] state	The new device state.
- * @return		The new state if changed.
- * @return		EOK otherwise.
- */
-static int change_state_message(netif_device_t *device, device_state_t state)
+	
+	return EOK;
+}
+
+/** Change the loopback state.
+ *
+ * @param[in] device The device structure.
+ * @param[in] state  The new device state.
+ *
+ * @return New state if changed.
+ * @return EOK otherwise.
+ *
+ */
+static void change_state_message(netif_device_t *device, device_state_t state)
 {
 	if (device->state != state) {
 		device->state = state;
 		
-		printf("%s: State changed to %s\n", NAME,
-		    (state == NETIF_ACTIVE) ? "active" : "stopped");
+		const char *desc;
+		switch (state) {
+		case NETIF_ACTIVE:
+			desc = "active";
+			break;
+		case NETIF_STOPPED:
+			desc = "stopped";
+			break;
+		default:
+			desc = "unknown";
+		}
 		
-		return state;
-	}
-	
-	return EOK;
-}
-
-/** Creates and returns the loopback network interface structure.
- *
- * @param[in] device_id	The new devce identifier.
- * @param[out] device	The device structure.
- * @return		EOK on success.
- * @return		EXDEV if one loopback network interface already exists.
- * @return		ENOMEM if there is not enough memory left.
- */
-static int create(device_id_t device_id, netif_device_t **device)
-{
-	int index;
-
+		printf("%s: State changed to %s\n", NAME, desc);
+	}
+}
+
+/** Create and return the loopback network interface structure.
+ *
+ * @param[in]  device_id New devce identifier.
+ * @param[out] device    Device structure.
+ *
+ * @return EOK on success.
+ * @return EXDEV if one loopback network interface already exists.
+ * @return ENOMEM if there is not enough memory left.
+ *
+ */
+static int lo_create(device_id_t device_id, netif_device_t **device)
+{
 	if (netif_device_map_count(&netif_globals.device_map) > 0)
 		return EXDEV;
-
+	
 	*device = (netif_device_t *) malloc(sizeof(netif_device_t));
 	if (!*device)
 		return ENOMEM;
-
+	
 	(*device)->specific = (device_stats_t *) malloc(sizeof(device_stats_t));
 	if (!(*device)->specific) {
@@ -146,12 +147,12 @@
 		return ENOMEM;
 	}
-
+	
 	null_device_stats((device_stats_t *) (*device)->specific);
 	(*device)->device_id = device_id;
 	(*device)->nil_phone = -1;
 	(*device)->state = NETIF_STOPPED;
-	index = netif_device_map_add(&netif_globals.device_map,
+	int index = netif_device_map_add(&netif_globals.device_map,
 	    (*device)->device_id, *device);
-
+	
 	if (index < 0) {
 		free(*device);
@@ -167,5 +168,4 @@
 {
 	sysarg_t phonehash;
-
 	return ipc_connect_to_me(PHONE_NS, SERVICE_LO, 0, 0, &phonehash);
 }
@@ -173,15 +173,11 @@
 int netif_probe_message(device_id_t device_id, int irq, void *io)
 {
+	/* Create a new device */
 	netif_device_t *device;
-	int rc;
-
-	/* Create a new device */
-	rc = create(device_id, &device);
+	int rc = lo_create(device_id, &device);
 	if (rc != EOK)
 		return rc;
-
-	/* Print the settings */
+	
 	printf("%s: Device created (id: %d)\n", NAME, device->device_id);
-
 	return EOK;
 }
@@ -190,33 +186,29 @@
 {
 	netif_device_t *device;
-	size_t length;
-	packet_t *next;
-	int phone;
-	int rc;
-
-	rc = find_device(device_id, &device);
+	int rc = find_device(device_id, &device);
 	if (rc != EOK)
 		return EOK;
-
+	
 	if (device->state != NETIF_ACTIVE) {
 		netif_pq_release(packet_get_id(packet));
 		return EFORWARD;
 	}
-
-	next = packet;
+	
+	packet_t *next = packet;
 	do {
 		((device_stats_t *) device->specific)->send_packets++;
 		((device_stats_t *) device->specific)->receive_packets++;
-		length = packet_get_data_length(next);
+		size_t length = packet_get_data_length(next);
 		((device_stats_t *) device->specific)->send_bytes += length;
 		((device_stats_t *) device->specific)->receive_bytes += length;
 		next = pq_next(next);
-	} while(next);
-
-	phone = device->nil_phone;
+	} while (next);
+	
+	int phone = device->nil_phone;
 	fibril_rwlock_write_unlock(&netif_globals.lock);
+	
 	nil_received_msg(phone, device_id, packet, sender);
+	
 	fibril_rwlock_write_lock(&netif_globals.lock);
-	
 	return EOK;
 }
@@ -224,10 +216,12 @@
 int netif_start_message(netif_device_t *device)
 {
-	return change_state_message(device, NETIF_ACTIVE);
+	change_state_message(device, NETIF_ACTIVE);
+	return device->state;
 }
 
 int netif_stop_message(netif_device_t *device)
 {
-	return change_state_message(device, NETIF_STOPPED);
+	change_state_message(device, NETIF_STOPPED);
+	return device->state;
 }
 
