Index: uspace/srv/net/il/arp/arp.c
===================================================================
--- uspace/srv/net/il/arp/arp.c	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/arp/arp.c	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -73,4 +73,9 @@
 arp_globals_t	arp_globals;
 
+/** Clears the device specific data.
+ *  @param[in] device The device specific data.
+ */
+void arp_clear_device(arp_device_ref device);
+
 /** Creates new protocol specific data.
  *  Allocates and returns the needed memory block as the proto parameter.
@@ -82,9 +87,4 @@
  */
 int arp_proto_create(arp_proto_ref * proto, services_t service, measured_string_ref address);
-
-/** Clears the device specific data.
- *  @param[in] device The device specific data.
- */
-void arp_clear_device(arp_device_ref device);
 
 /** @name Message processing functions
@@ -105,16 +105,11 @@
 int arp_device_message(device_id_t device_id, services_t service, services_t protocol, measured_string_ref address);
 
-/** Returns the hardware address for the given protocol address.
- *  Sends the ARP request packet if the hardware address is not found in the cache.
+/** Updates the device content length according to the new MTU value.
  *  @param[in] device_id The device identifier.
- *  @param[in] protocol The protocol service.
- *  @param[in] target The target protocol address.
- *  @returns The hardware address of the target.
- *  @returns NULL if the target parameter is NULL.
- *  @returns NULL if the device is not found.
- *  @returns NULL if the device packet is too small to send a&nbsp;request.
- *  @returns NULL if the hardware address is not found in the cache.
- */
-measured_string_ref arp_translate_message(device_id_t device_id, services_t protocol, measured_string_ref target);
+ *  @param[in] mtu The new mtu value.
+ *  @returns ENOENT if device is not found.
+ *  @returns EOK on success.
+ */
+int arp_mtu_changed_message(device_id_t device_id, size_t mtu);
 
 /** Processes the received ARP packet.
@@ -133,11 +128,16 @@
 int arp_receive_message(device_id_t device_id, packet_t packet);
 
-/** Updates the device content length according to the new MTU value.
+/** Returns the hardware address for the given protocol address.
+ *  Sends the ARP request packet if the hardware address is not found in the cache.
  *  @param[in] device_id The device identifier.
- *  @param[in] mtu The new mtu value.
- *  @returns ENOENT if device is not found.
- *  @returns EOK on success.
- */
-int arp_mtu_changed_message(device_id_t device_id, size_t mtu);
+ *  @param[in] protocol The protocol service.
+ *  @param[in] target The target protocol address.
+ *  @returns The hardware address of the target.
+ *  @returns NULL if the target parameter is NULL.
+ *  @returns NULL if the device is not found.
+ *  @returns NULL if the device packet is too small to send a&nbsp;request.
+ *  @returns NULL if the hardware address is not found in the cache.
+ */
+measured_string_ref arp_translate_message(device_id_t device_id, services_t protocol, measured_string_ref target);
 
 /*@}*/
@@ -148,43 +148,4 @@
 
 GENERIC_CHAR_MAP_IMPLEMENT(arp_addr, measured_string_t)
-
-task_id_t arp_task_get_id(void){
-	return task_get_id();
-}
-
-int arp_clear_device_req(int arp_phone, device_id_t device_id){
-	arp_device_ref device;
-
-	fibril_rwlock_write_lock(&arp_globals.lock);
-	device = arp_cache_find(&arp_globals.cache, device_id);
-	if(! device){
-		fibril_rwlock_write_unlock(&arp_globals.lock);
-		return ENOENT;
-	}
-	arp_clear_device(device);
-	printf("Device %d cleared\n", device_id);
-	fibril_rwlock_write_unlock(&arp_globals.lock);
-	return EOK;
-}
-
-int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address){
-	arp_device_ref device;
-	arp_proto_ref proto;
-
-	fibril_rwlock_write_lock(&arp_globals.lock);
-	device = arp_cache_find(&arp_globals.cache, device_id);
-	if(! device){
-		fibril_rwlock_write_unlock(&arp_globals.lock);
-		return ENOENT;
-	}
-	proto = arp_protos_find(&device->protos, protocol);
-	if(! proto){
-		fibril_rwlock_write_unlock(&arp_globals.lock);
-		return ENOENT;
-	}
-	arp_addr_exclude(&proto->addresses, address->value, address->length);
-	fibril_rwlock_write_unlock(&arp_globals.lock);
-	return EOK;
-}
 
 int arp_clean_cache_req(int arp_phone){
@@ -211,62 +172,61 @@
 }
 
-int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address){
-	ERROR_DECLARE;
-
-	measured_string_ref tmp;
-
-	// copy the given address for exclusive use
-	tmp = measured_string_copy(address);
-	if(ERROR_OCCURRED(arp_device_message(device_id, netif, protocol, tmp))){
-		free(tmp->value);
-		free(tmp);
-	}
-	return ERROR_CODE;
-}
-
-int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data){
-	measured_string_ref tmp;
-
-	fibril_rwlock_read_lock(&arp_globals.lock);
-	tmp = arp_translate_message(device_id, protocol, address);
-	if(tmp){
-		*translation = measured_string_copy(tmp);
-		fibril_rwlock_read_unlock(&arp_globals.lock);
-		if(*translation){
-			*data = (** translation).value;
-			return EOK;
-		}else{
-			return ENOMEM;
-		}
-	}else{
-		fibril_rwlock_read_unlock(&arp_globals.lock);
+int arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address){
+	arp_device_ref device;
+	arp_proto_ref proto;
+
+	fibril_rwlock_write_lock(&arp_globals.lock);
+	device = arp_cache_find(&arp_globals.cache, device_id);
+	if(! device){
+		fibril_rwlock_write_unlock(&arp_globals.lock);
 		return ENOENT;
 	}
-}
-
-int arp_initialize(async_client_conn_t client_connection){
-	ERROR_DECLARE;
-
-	fibril_rwlock_initialize(&arp_globals.lock);
+	proto = arp_protos_find(&device->protos, protocol);
+	if(! proto){
+		fibril_rwlock_write_unlock(&arp_globals.lock);
+		return ENOENT;
+	}
+	arp_addr_exclude(&proto->addresses, address->value, address->length);
+	fibril_rwlock_write_unlock(&arp_globals.lock);
+	return EOK;
+}
+
+void arp_clear_device(arp_device_ref device){
+	int count;
+	arp_proto_ref proto;
+
+	for(count = arp_protos_count(&device->protos) - 1; count >= 0; -- count){
+		proto = arp_protos_get_index(&device->protos, count);
+		if(proto){
+			if(proto->addr){
+				free(proto->addr);
+			}
+			if(proto->addr_data){
+				free(proto->addr_data);
+			}
+			arp_addr_destroy(&proto->addresses);
+		}
+	}
+	arp_protos_clear(&device->protos);
+}
+
+int arp_clear_device_req(int arp_phone, device_id_t device_id){
+	arp_device_ref device;
+
 	fibril_rwlock_write_lock(&arp_globals.lock);
-	arp_globals.client_connection = client_connection;
-	ERROR_PROPAGATE(arp_cache_initialize(&arp_globals.cache));
+	device = arp_cache_find(&arp_globals.cache, device_id);
+	if(! device){
+		fibril_rwlock_write_unlock(&arp_globals.lock);
+		return ENOENT;
+	}
+	arp_clear_device(device);
+	printf("Device %d cleared\n", device_id);
 	fibril_rwlock_write_unlock(&arp_globals.lock);
 	return EOK;
 }
 
-int arp_proto_create(arp_proto_ref * proto, services_t service, measured_string_ref address){
-	ERROR_DECLARE;
-
-	*proto = (arp_proto_ref) malloc(sizeof(arp_proto_t));
-	if(!(*proto)){
-		return ENOMEM;
-	}
-	(** proto).service = service;
-	(** proto).addr = address;
-	(** proto).addr_data = address->value;
-	if(ERROR_OCCURRED(arp_addr_initialize(&(** proto).addresses))){
-		free(*proto);
-		return ERROR_CODE;
+int arp_connect_module(services_t service){
+	if(service != SERVICE_ARP){
+		return EINVAL;
 	}
 	return EOK;
@@ -383,168 +343,25 @@
 }
 
-measured_string_ref arp_translate_message(device_id_t device_id, services_t protocol, measured_string_ref target){
-	arp_device_ref device;
-	arp_proto_ref proto;
-	measured_string_ref addr;
-	size_t length;
-	packet_t packet;
-	arp_header_ref header;
-
-	if(! target){
-		return NULL;
-	}
-	device = arp_cache_find(&arp_globals.cache, device_id);
-	if(! device){
-		return NULL;
-	}
-	proto = arp_protos_find(&device->protos, protocol);
-	if((! proto) || (proto->addr->length != target->length)){
-		return NULL;
-	}
-	addr = arp_addr_find(&proto->addresses, target->value, target->length);
-	if(addr){
-		return addr;
-	}
-	// ARP packet content size = header + (address + translation) * 2
-	length = 8 + (CONVERT_SIZE(char, uint8_t, proto->addr->length) + CONVERT_SIZE(char, uint8_t, device->addr->length)) * 2;
-	if(length > device->packet_dimension.content){
-		return NULL;
-	}
-	packet = packet_get_4(arp_globals.net_phone, device->packet_dimension.addr_len, device->packet_dimension.prefix, length, device->packet_dimension.suffix);
-	if(! packet){
-		return NULL;
-	}
-	header = (arp_header_ref) packet_suffix(packet, length);
-	if(! header){
-		pq_release(arp_globals.net_phone, packet_get_id(packet));
-		return NULL;
-	}
-	header->hardware = htons(device->hardware);
-	header->hardware_length = (uint8_t) device->addr->length;
-	header->protocol = htons(protocol_map(device->service, protocol));
-	header->protocol_length = (uint8_t) proto->addr->length;
-	header->operation = htons(ARPOP_REQUEST);
-	length = sizeof(arp_header_t);
-	memcpy(((uint8_t *) header) + length, device->addr->value, device->addr->length);
-	length += device->addr->length;
-	memcpy(((uint8_t *) header) + length, proto->addr->value, proto->addr->length);
-	length += proto->addr->length;
-	bzero(((uint8_t *) header) + length, device->addr->length);
-	length += device->addr->length;
-	memcpy(((uint8_t *) header) + length, target->value, target->length);
-	if(packet_set_addr(packet, (uint8_t *) device->addr->value, (uint8_t *) device->broadcast_addr->value, CONVERT_SIZE(char, uint8_t, device->addr->length)) != EOK){
-		pq_release(arp_globals.net_phone, packet_get_id(packet));
-		return NULL;
-	}
-	nil_send_msg(device->phone, device_id, packet, SERVICE_ARP);
-	return NULL;
-}
-
-int arp_receive_message(device_id_t device_id, packet_t packet){
+int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address){
 	ERROR_DECLARE;
 
-	size_t length;
-	arp_header_ref header;
-	arp_device_ref device;
-	arp_proto_ref proto;
-	measured_string_ref hw_source;
-	uint8_t * src_hw;
-	uint8_t * src_proto;
-	uint8_t * des_hw;
-	uint8_t * des_proto;
-
-	length = packet_get_data_length(packet);
-	if(length <= sizeof(arp_header_t)){
-		return EINVAL;
-	}
-	device = arp_cache_find(&arp_globals.cache, device_id);
-	if(! device){
-		return ENOENT;
-	}
-	header = (arp_header_ref) packet_get_data(packet);
-	if((ntohs(header->hardware) != device->hardware)
-		|| (length < sizeof(arp_header_t) + header->hardware_length * 2u + header->protocol_length * 2u)){
-		return EINVAL;
-	}
-	proto = arp_protos_find(&device->protos, protocol_unmap(device->service, ntohs(header->protocol)));
-	if(! proto){
-		return ENOENT;
-	}
-	src_hw = ((uint8_t *) header) + sizeof(arp_header_t);
-	src_proto = src_hw + header->hardware_length;
-	des_hw = src_proto + header->protocol_length;
-	des_proto = des_hw + header->hardware_length;
-	hw_source = arp_addr_find(&proto->addresses, (char *) src_proto, CONVERT_SIZE(uint8_t, char, header->protocol_length));
-	// exists?
-	if(hw_source){
-		if(hw_source->length != CONVERT_SIZE(uint8_t, char, header->hardware_length)){
-			return EINVAL;
-		}
-		memcpy(hw_source->value, src_hw, hw_source->length);
-	}
-	// is my protocol address?
-	if(proto->addr->length != CONVERT_SIZE(uint8_t, char, header->protocol_length)){
-		return EINVAL;
-	}
-	if(! str_lcmp(proto->addr->value, (char *) des_proto, proto->addr->length)){
-		// not already upadted?
-		if(! hw_source){
-			hw_source = measured_string_create_bulk((char *) src_hw, CONVERT_SIZE(uint8_t, char, header->hardware_length));
-			if(! hw_source){
-				return ENOMEM;
-			}
-			ERROR_PROPAGATE(arp_addr_add(&proto->addresses, (char *) src_proto, CONVERT_SIZE(uint8_t, char, header->protocol_length), hw_source));
-		}
-		if(ntohs(header->operation) == ARPOP_REQUEST){
-			header->operation = htons(ARPOP_REPLY);
-			memcpy(des_proto, src_proto, header->protocol_length);
-			memcpy(src_proto, proto->addr->value, header->protocol_length);
-			memcpy(src_hw, device->addr->value, device->packet_dimension.addr_len);
-			memcpy(des_hw, hw_source->value, header->hardware_length);
-			ERROR_PROPAGATE(packet_set_addr(packet, src_hw, des_hw, header->hardware_length));
-			nil_send_msg(device->phone, device_id, packet, SERVICE_ARP);
-			return 1;
-		}
-	}
-	return EOK;
-}
-
-void arp_clear_device(arp_device_ref device){
-	int count;
-	arp_proto_ref proto;
-
-	for(count = arp_protos_count(&device->protos) - 1; count >= 0; -- count){
-		proto = arp_protos_get_index(&device->protos, count);
-		if(proto){
-			if(proto->addr){
-				free(proto->addr);
-			}
-			if(proto->addr_data){
-				free(proto->addr_data);
-			}
-			arp_addr_destroy(&proto->addresses);
-		}
-	}
-	arp_protos_clear(&device->protos);
-}
-
-int arp_connect_module(services_t service){
-	if(service != SERVICE_ARP){
-		return EINVAL;
-	}
-	return EOK;
-}
-
-int arp_mtu_changed_message(device_id_t device_id, size_t mtu){
-	arp_device_ref device;
-
+	measured_string_ref tmp;
+
+	// copy the given address for exclusive use
+	tmp = measured_string_copy(address);
+	if(ERROR_OCCURRED(arp_device_message(device_id, netif, protocol, tmp))){
+		free(tmp->value);
+		free(tmp);
+	}
+	return ERROR_CODE;
+}
+
+int arp_initialize(async_client_conn_t client_connection){
+	ERROR_DECLARE;
+
+	fibril_rwlock_initialize(&arp_globals.lock);
 	fibril_rwlock_write_lock(&arp_globals.lock);
-	device = arp_cache_find(&arp_globals.cache, device_id);
-	if(! device){
-		fibril_rwlock_write_unlock(&arp_globals.lock);
-		return ENOENT;
-	}
-	device->packet_dimension.content = mtu;
-	printf("arp - device %d changed mtu to %d\n\n", device_id, mtu);
+	arp_globals.client_connection = client_connection;
+	ERROR_PROPAGATE(arp_cache_initialize(&arp_globals.cache));
 	fibril_rwlock_write_unlock(&arp_globals.lock);
 	return EOK;
@@ -618,4 +435,187 @@
 }
 
+int arp_mtu_changed_message(device_id_t device_id, size_t mtu){
+	arp_device_ref device;
+
+	fibril_rwlock_write_lock(&arp_globals.lock);
+	device = arp_cache_find(&arp_globals.cache, device_id);
+	if(! device){
+		fibril_rwlock_write_unlock(&arp_globals.lock);
+		return ENOENT;
+	}
+	device->packet_dimension.content = mtu;
+	printf("arp - device %d changed mtu to %d\n\n", device_id, mtu);
+	fibril_rwlock_write_unlock(&arp_globals.lock);
+	return EOK;
+}
+
+int arp_proto_create(arp_proto_ref * proto, services_t service, measured_string_ref address){
+	ERROR_DECLARE;
+
+	*proto = (arp_proto_ref) malloc(sizeof(arp_proto_t));
+	if(!(*proto)){
+		return ENOMEM;
+	}
+	(** proto).service = service;
+	(** proto).addr = address;
+	(** proto).addr_data = address->value;
+	if(ERROR_OCCURRED(arp_addr_initialize(&(** proto).addresses))){
+		free(*proto);
+		return ERROR_CODE;
+	}
+	return EOK;
+}
+
+int arp_receive_message(device_id_t device_id, packet_t packet){
+	ERROR_DECLARE;
+
+	size_t length;
+	arp_header_ref header;
+	arp_device_ref device;
+	arp_proto_ref proto;
+	measured_string_ref hw_source;
+	uint8_t * src_hw;
+	uint8_t * src_proto;
+	uint8_t * des_hw;
+	uint8_t * des_proto;
+
+	length = packet_get_data_length(packet);
+	if(length <= sizeof(arp_header_t)){
+		return EINVAL;
+	}
+	device = arp_cache_find(&arp_globals.cache, device_id);
+	if(! device){
+		return ENOENT;
+	}
+	header = (arp_header_ref) packet_get_data(packet);
+	if((ntohs(header->hardware) != device->hardware)
+		|| (length < sizeof(arp_header_t) + header->hardware_length * 2u + header->protocol_length * 2u)){
+		return EINVAL;
+	}
+	proto = arp_protos_find(&device->protos, protocol_unmap(device->service, ntohs(header->protocol)));
+	if(! proto){
+		return ENOENT;
+	}
+	src_hw = ((uint8_t *) header) + sizeof(arp_header_t);
+	src_proto = src_hw + header->hardware_length;
+	des_hw = src_proto + header->protocol_length;
+	des_proto = des_hw + header->hardware_length;
+	hw_source = arp_addr_find(&proto->addresses, (char *) src_proto, CONVERT_SIZE(uint8_t, char, header->protocol_length));
+	// exists?
+	if(hw_source){
+		if(hw_source->length != CONVERT_SIZE(uint8_t, char, header->hardware_length)){
+			return EINVAL;
+		}
+		memcpy(hw_source->value, src_hw, hw_source->length);
+	}
+	// is my protocol address?
+	if(proto->addr->length != CONVERT_SIZE(uint8_t, char, header->protocol_length)){
+		return EINVAL;
+	}
+	if(! str_lcmp(proto->addr->value, (char *) des_proto, proto->addr->length)){
+		// not already upadted?
+		if(! hw_source){
+			hw_source = measured_string_create_bulk((char *) src_hw, CONVERT_SIZE(uint8_t, char, header->hardware_length));
+			if(! hw_source){
+				return ENOMEM;
+			}
+			ERROR_PROPAGATE(arp_addr_add(&proto->addresses, (char *) src_proto, CONVERT_SIZE(uint8_t, char, header->protocol_length), hw_source));
+		}
+		if(ntohs(header->operation) == ARPOP_REQUEST){
+			header->operation = htons(ARPOP_REPLY);
+			memcpy(des_proto, src_proto, header->protocol_length);
+			memcpy(src_proto, proto->addr->value, header->protocol_length);
+			memcpy(src_hw, device->addr->value, device->packet_dimension.addr_len);
+			memcpy(des_hw, hw_source->value, header->hardware_length);
+			ERROR_PROPAGATE(packet_set_addr(packet, src_hw, des_hw, header->hardware_length));
+			nil_send_msg(device->phone, device_id, packet, SERVICE_ARP);
+			return 1;
+		}
+	}
+	return EOK;
+}
+
+task_id_t arp_task_get_id(void){
+	return task_get_id();
+}
+
+measured_string_ref arp_translate_message(device_id_t device_id, services_t protocol, measured_string_ref target){
+	arp_device_ref device;
+	arp_proto_ref proto;
+	measured_string_ref addr;
+	size_t length;
+	packet_t packet;
+	arp_header_ref header;
+
+	if(! target){
+		return NULL;
+	}
+	device = arp_cache_find(&arp_globals.cache, device_id);
+	if(! device){
+		return NULL;
+	}
+	proto = arp_protos_find(&device->protos, protocol);
+	if((! proto) || (proto->addr->length != target->length)){
+		return NULL;
+	}
+	addr = arp_addr_find(&proto->addresses, target->value, target->length);
+	if(addr){
+		return addr;
+	}
+	// ARP packet content size = header + (address + translation) * 2
+	length = 8 + (CONVERT_SIZE(char, uint8_t, proto->addr->length) + CONVERT_SIZE(char, uint8_t, device->addr->length)) * 2;
+	if(length > device->packet_dimension.content){
+		return NULL;
+	}
+	packet = packet_get_4(arp_globals.net_phone, device->packet_dimension.addr_len, device->packet_dimension.prefix, length, device->packet_dimension.suffix);
+	if(! packet){
+		return NULL;
+	}
+	header = (arp_header_ref) packet_suffix(packet, length);
+	if(! header){
+		pq_release(arp_globals.net_phone, packet_get_id(packet));
+		return NULL;
+	}
+	header->hardware = htons(device->hardware);
+	header->hardware_length = (uint8_t) device->addr->length;
+	header->protocol = htons(protocol_map(device->service, protocol));
+	header->protocol_length = (uint8_t) proto->addr->length;
+	header->operation = htons(ARPOP_REQUEST);
+	length = sizeof(arp_header_t);
+	memcpy(((uint8_t *) header) + length, device->addr->value, device->addr->length);
+	length += device->addr->length;
+	memcpy(((uint8_t *) header) + length, proto->addr->value, proto->addr->length);
+	length += proto->addr->length;
+	bzero(((uint8_t *) header) + length, device->addr->length);
+	length += device->addr->length;
+	memcpy(((uint8_t *) header) + length, target->value, target->length);
+	if(packet_set_addr(packet, (uint8_t *) device->addr->value, (uint8_t *) device->broadcast_addr->value, CONVERT_SIZE(char, uint8_t, device->addr->length)) != EOK){
+		pq_release(arp_globals.net_phone, packet_get_id(packet));
+		return NULL;
+	}
+	nil_send_msg(device->phone, device_id, packet, SERVICE_ARP);
+	return NULL;
+}
+
+int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data){
+	measured_string_ref tmp;
+
+	fibril_rwlock_read_lock(&arp_globals.lock);
+	tmp = arp_translate_message(device_id, protocol, address);
+	if(tmp){
+		*translation = measured_string_copy(tmp);
+		fibril_rwlock_read_unlock(&arp_globals.lock);
+		if(*translation){
+			*data = (** translation).value;
+			return EOK;
+		}else{
+			return ENOMEM;
+		}
+	}else{
+		fibril_rwlock_read_unlock(&arp_globals.lock);
+		return ENOENT;
+	}
+}
+
 /** @}
  */
Index: uspace/srv/net/il/arp/arp.h
===================================================================
--- uspace/srv/net/il/arp/arp.h	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/arp/arp.h	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -51,9 +51,4 @@
 
 
-/** Type definition of the ARP global data.
- *  @see arp_globals
- */
-typedef struct arp_globals	arp_globals_t;
-
 /** Type definition of the ARP device specific data.
  *  @see arp_device
@@ -66,4 +61,9 @@
 typedef arp_device_t *		arp_device_ref;
 
+/** Type definition of the ARP global data.
+ *  @see arp_globals
+ */
+typedef struct arp_globals	arp_globals_t;
+
 /** Type definition of the ARP protocol specific data.
  *  @see arp_proto
@@ -75,4 +75,10 @@
  */
 typedef arp_proto_t *		arp_proto_ref;
+
+/** ARP address map.
+ *  Translates addresses.
+ *  @see generic_char_map.h
+ */
+GENERIC_CHAR_MAP_DECLARE(arp_addr, measured_string_t)
 
 /** ARP address cache.
@@ -88,22 +94,7 @@
 INT_MAP_DECLARE(arp_protos, arp_proto_t)
 
-/** ARP address map.
- *  Translates addresses.
- *  @see generic_char_map.h
- */
-GENERIC_CHAR_MAP_DECLARE(arp_addr, measured_string_t)
-
 /** ARP device specific data.
  */
 struct arp_device{
-	/** Device identifier.
-	 */
-	device_id_t device_id;
-	/** Hardware type.
-	 */
-	hw_type_t hardware;
-	/** Packet dimension.
-	 */
-	packet_dimension_t packet_dimension;
 	/** Actual device hardware address.
 	 */
@@ -118,7 +109,13 @@
 	 */
 	char * broadcast_data;
-	/** Device module service.
+	/** Device identifier.
 	 */
-	services_t service;
+	device_id_t device_id;
+	/** Hardware type.
+	 */
+	hw_type_t hardware;
+	/** Packet dimension.
+	 */
+	packet_dimension_t packet_dimension;
 	/** Device module phone.
 	 */
@@ -128,4 +125,25 @@
 	 */
 	arp_protos_t protos;
+	/** Device module service.
+	 */
+	services_t service;
+};
+
+/** ARP global data.
+ */
+struct	arp_globals{
+	/** ARP address cache.
+	 */
+	arp_cache_t cache;
+	/** The client connection processing function.
+	 *  The module skeleton propagates its own one.
+	 */
+	async_client_conn_t client_connection;
+	/** Networking module phone.
+	 */
+	int net_phone;
+	/** Safety lock.
+	 */
+	fibril_rwlock_t lock;
 };
 
@@ -133,7 +151,4 @@
  */
 struct arp_proto{
-	/** Protocol service.
-	 */
-	services_t service;
 	/** Actual device protocol address.
 	 */
@@ -145,22 +160,7 @@
 	 */
 	arp_addr_t addresses;
-};
-
-/** ARP global data.
- */
-struct	arp_globals{
-	/** Networking module phone.
+	/** Protocol service.
 	 */
-	int net_phone;
-	/** Safety lock.
-	 */
-	fibril_rwlock_t lock;
-	/** ARP address cache.
-	 */
-	arp_cache_t cache;
-	/** The client connection processing function.
-	 *  The module skeleton propagates its own one.
-	 */
-	async_client_conn_t client_connection;
+	services_t service;
 };
 
Index: uspace/srv/net/il/arp/arp_messages.h
===================================================================
--- uspace/srv/net/il/arp/arp_messages.h	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/arp/arp_messages.h	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -46,24 +46,24 @@
  */
 typedef enum{
-	/** New device message.
-	 *  @see arp_device_req()
+	/** Clean cache message.
+	 *  @see arp_clean_cache()
 	 */
-	NET_ARP_DEVICE = NET_ARP_FIRST,
-	/** Address translation message.
-	 *  @see arp_translate_req()
+	NET_ARP_CLEAN_CACHE = NET_ARP_FIRST,
+	/** Clear address cache message.
+	 *  @see arp_clear_address_msg()
 	 */
-	NET_ARP_TRANSLATE,
+	NET_ARP_CLEAR_ADDRESS,
 	/** Clear device cache message.
 	 *  @see arp_clear_device_req()
 	 */
 	NET_ARP_CLEAR_DEVICE,
-	/** Clear address cache message.
-	 *  @see arp_clear_address_msg()
+	/** New device message.
+	 *  @see arp_device_req()
 	 */
-	NET_ARP_CLEAR_ADDRESS,
-	/** Clean cache message.
-	 *  @see arp_clean_cache()
+	NET_ARP_DEVICE,
+	/** Address translation message.
+	 *  @see arp_translate_req()
 	 */
-	NET_ARP_CLEAN_CACHE,
+	NET_ARP_TRANSLATE
 } arp_messages;
 
Index: uspace/srv/net/il/arp/arp_module.c
===================================================================
--- uspace/srv/net/il/arp/arp_module.c	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/arp/arp_module.c	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -58,4 +58,18 @@
 #define NAME	"ARP protocol"
 
+/** ARP module global data.
+ */
+extern arp_globals_t	arp_globals;
+
+/** Processes the ARP message.
+ *  @param[in] callid The message identifier.
+ *  @param[in] call The message parameters.
+ *  @param[out] answer The message answer parameters.
+ *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the arp_message() function.
+ */
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
+
 /** Prints the module name.
  *  @see NAME
@@ -72,17 +86,7 @@
 int module_start(async_client_conn_t client_connection);
 
-/** Processes the ARP message.
- *  @param[in] callid The message identifier.
- *  @param[in] call The message parameters.
- *  @param[out] answer The message answer parameters.
- *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
- *  @returns EOK on success.
- *  @returns Other error codes as defined for the arp_message() function.
- */
-int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
-
-/** ARP module global data.
- */
-extern arp_globals_t	arp_globals;
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
+	return arp_message(callid, call, answer, answer_count);
+}
 
 void module_print_name(void){
@@ -110,8 +114,4 @@
 }
 
-int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
-	return arp_message(callid, call, answer, answer_count);
-}
-
 /** @}
  */
Index: uspace/srv/net/il/arp/arp_oc.h
===================================================================
--- uspace/srv/net/il/arp/arp_oc.h	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/arp/arp_oc.h	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -44,81 +44,81 @@
 /** REQUEST operation code.
  */
-#define ARPOP_REQUEST		1
+#define ARPOP_REQUEST					1
 
 /** REPLY operation code.
  */
-#define ARPOP_REPLY		2
+#define ARPOP_REPLY						2
 
 /** Reverse request operation code.
  */
-#define ARPOP_RREQUEST		3
+#define ARPOP_RREQUEST					3
 
 /** Reverse reply operation code.
  */
-#define ARPOP_RREPLY		4
+#define ARPOP_RREPLY					4
 
 /** DRARP-Request operation code.
  */
-#define ARPOP_DRARP_Request		5
+#define ARPOP_DRARP_Request				5
 
 /** DRARP-Reply operation code.
  */
-#define ARPOP_DRARP_Reply		6
+#define ARPOP_DRARP_Reply				6
 
 /** DRARP-Error operation code.
  */
-#define ARPOP_DRARP_Error		7
+#define ARPOP_DRARP_Error				7
 
 /** InARP-Request operation code.
  */
-#define ARPOP_InREQUEST		8
+#define ARPOP_InREQUEST					8
 
 /** InARP-Reply operation code.
  */
-#define ARPOP_InREPLY		9
+#define ARPOP_InREPLY					9
 
 /** ARP-NAK operation code.
  */
-#define ARPOP_NAK		10
+#define ARPOP_NAK						10
 
 /** MARS-Request operation code.
  */
-#define ARPOP_MARS_Request		11
+#define ARPOP_MARS_Request				11
 
 /** MARS-Multi operation code.
  */
-#define ARPOP_MARS_Multi		12
+#define ARPOP_MARS_Multi				12
 
 /** MARS-MServ operation code.
  */
-#define ARPOP_MARS_MServ		13
+#define ARPOP_MARS_MServ				13
 
 /** MARS-Join operation code.
  */
-#define ARPOP_MARS_Join		14
+#define ARPOP_MARS_Join					14
 
 /** MARS-Leave operation code.
  */
-#define ARPOP_MARS_Leave		15
+#define ARPOP_MARS_Leave				15
 
 /** MARS-NAK operation code.
  */
-#define ARPOP_MARS_NAK		16
+#define ARPOP_MARS_NAK					16
 
 /** MARS-Unserv operation code.
  */
-#define ARPOP_MARS_Unserv		17
+#define ARPOP_MARS_Unserv				17
 
 /** MARS-SJoin operation code.
  */
-#define ARPOP_MARS_SJoin		18
+#define ARPOP_MARS_SJoin				18
 
 /** MARS-SLeave operation code.
  */
-#define ARPOP_MARS_SLeave		19
+#define ARPOP_MARS_SLeave				19
 
 /** MARS-Grouplist-Request operation code.
  */
-#define ARPOP_MARS_Grouplist_Request		20
+#define ARPOP_MARS_Grouplist_Request	20
 
 /** MARS-Grouplist-Reply operation code.
@@ -128,9 +128,9 @@
 /** MARS-Redirect-Map operation code.
  */
-#define ARPOP_MARS_Redirect_Map		22
+#define ARPOP_MARS_Redirect_Map			22
 
 /** MAPOS-UNARP operation code.
  */
-#define ARPOP_MAPOS_UNARP		23
+#define ARPOP_MAPOS_UNARP				23
 
 /*@}*/
Index: uspace/srv/net/il/arp/arp_remote.c
===================================================================
--- uspace/srv/net/il/arp/arp_remote.c	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/arp/arp_remote.c	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -52,20 +52,13 @@
 #include "arp_messages.h"
 
-int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address){
-	aid_t message_id;
-	ipcarg_t result;
-
-	message_id = async_send_3(arp_phone, NET_ARP_DEVICE, (ipcarg_t) device_id, protocol, netif, NULL);
-	measured_strings_send(arp_phone, address, 1);
-	async_wait_for(message_id, &result);
-	return (int) result;
+int arp_connect_module(services_t service){
+	if(service != SERVICE_ARP){
+		return EINVAL;
+	}
+	return connect_to_service(SERVICE_ARP);
 }
 
-int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data){
-	return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, protocol, address, 1, translation, data);
-}
-
-int arp_clear_device_req(int arp_phone, device_id_t device_id){
-	return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, (ipcarg_t) device_id);
+int arp_clean_cache_req(int arp_phone){
+	return (int) async_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE);
 }
 
@@ -80,13 +73,16 @@
 }
 
-int arp_clean_cache_req(int arp_phone){
-	return (int) async_req_0_0(arp_phone, NET_ARP_CLEAN_CACHE);
+int arp_clear_device_req(int arp_phone, device_id_t device_id){
+	return (int) async_req_1_0(arp_phone, NET_ARP_CLEAR_DEVICE, (ipcarg_t) device_id);
 }
 
-int arp_connect_module(services_t service){
-	if(service != SERVICE_ARP){
-		return EINVAL;
-	}
-	return connect_to_service(SERVICE_ARP);
+int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol, services_t netif, measured_string_ref address){
+	aid_t message_id;
+	ipcarg_t result;
+
+	message_id = async_send_3(arp_phone, NET_ARP_DEVICE, (ipcarg_t) device_id, protocol, netif, NULL);
+	measured_strings_send(arp_phone, address, 1);
+	async_wait_for(message_id, &result);
+	return (int) result;
 }
 
@@ -95,4 +91,8 @@
 }
 
+int arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, measured_string_ref address, measured_string_ref * translation, char ** data){
+	return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, protocol, address, 1, translation, data);
+}
+
 /** @}
  */
Index: uspace/srv/net/il/il_messages.h
===================================================================
--- uspace/srv/net/il/il_messages.h	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/il_messages.h	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -53,4 +53,12 @@
 	 */
 	NET_IL_DEVICE_STATE,
+	/** Device MTU changed message.
+	 *  @see il_mtu_changed_msg()
+	 */
+	NET_IL_MTU_CHANGED,
+	/** Packet size message.
+	 *  @see il_packet_size_req()
+	 */
+	NET_IL_PACKET_SPACE,
 	/** Packet received message.
 	 *  @see il_received_msg()
@@ -60,13 +68,5 @@
 	 *  @see il_send_msg()
 	 */
-	NET_IL_SEND,
-	/** Packet size message.
-	 *  @see il_packet_size_req()
-	 */
-	NET_IL_PACKET_SPACE,
-	/** Device MTU changed message.
-	 *  @see il_mtu_changed_msg()
-	 */
-	NET_IL_MTU_CHANGED
+	NET_IL_SEND
 } il_messages;
 
@@ -83,5 +83,5 @@
  *  @param[in] call The message call structure.
  */
-#define IL_GET_SERVICE(call)		(services_t) IPC_GET_ARG2(*call)
+#define IL_GET_SERVICE(call)	(services_t) IPC_GET_ARG2(*call)
 
 /*@}*/
Index: uspace/srv/net/il/ip/ip.h
===================================================================
--- uspace/srv/net/il/ip/ip.h	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/ip/ip.h	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -106,38 +106,38 @@
  */
 struct	ip_netif{
-	/** Device identifier.
-	 */
-	device_id_t device_id;
-	/** Netif module service.
-	 */
-	services_t service;
-	/** Netif module phone.
-	 */
-	int phone;
 	/** ARP module.
 	 *  Assigned if using ARP.
 	 */
 	module_ref arp;
+	/** Broadcast address.
+	 */
+	in_addr_t broadcast;
+	/** Device identifier.
+	 */
+	device_id_t device_id;
+	/** Indicates whether using DHCP.
+	 */
+	int dhcp;
 	/** IP version.
 	 */
 	int ipv;
-	/** Indicates whether using DHCP.
-	 */
-	int dhcp;
+	/** Packet dimension.
+	 */
+	packet_dimension_t packet_dimension;
+	/** Netif module phone.
+	 */
+	int phone;
+	/** Routing table.
+	 */
+	ip_routes_t routes;
 	/** Indicates whether IP routing is enabled.
 	 */
 	int routing;
+	/** Netif module service.
+	 */
+	services_t service;
 	/** Device state.
 	 */
 	device_state_t state;
-	/** Broadcast address.
-	 */
-	in_addr_t broadcast;
-	/** Routing table.
-	 */
-	ip_routes_t routes;
-	/** Packet dimension.
-	 */
-	packet_dimension_t packet_dimension;
 };
 
@@ -145,16 +145,16 @@
  */
 struct ip_proto{
+	/** Protocol module phone.
+	 */
+	int phone;
 	/** Protocol number.
 	 */
 	int protocol;
+	/** Protocol packet receiving function.
+	 */
+	tl_received_msg_t received_msg;
 	/** Protocol module service.
 	 */
 	services_t service;
-	/** Protocol module phone.
-	 */
-	int phone;
-	/** Protocol packet receiving function.
-	 */
-	tl_received_msg_t received_msg;
 };
 
@@ -165,7 +165,4 @@
 	 */
 	in_addr_t address;
-	/** Target network mask.
-	 */
-	in_addr_t netmask;
 	/** Gateway.
 	 */
@@ -174,4 +171,7 @@
 	 */
 	ip_netif_ref netif;
+	/** Target network mask.
+	 */
+	in_addr_t netmask;
 };
 
@@ -179,4 +179,16 @@
  */
 struct	ip_globals{
+	/** Default client connection function for support modules.
+	 */
+	async_client_conn_t client_connection;
+	/** Default gateway.
+	 */
+	ip_route_t gateway;
+	/** Safety lock.
+	 */
+	fibril_rwlock_t lock;
+	/** Known support modules.
+	 */
+	modules_t modules;
 	/** Networking module phone.
 	 */
@@ -188,4 +200,7 @@
 	 */
 	fibril_rwlock_t netifs_lock;
+	/** Packet counter.
+	 */
+	uint16_t packet_counter;
 	/** Registered protocols.
 	 */
@@ -194,19 +209,4 @@
 	 */
 	fibril_rwlock_t protos_lock;
-	/** Default gateway.
-	 */
-	ip_route_t gateway;
-	/** Known support modules.
-	 */
-	modules_t modules;
-	/** Default client connection function for support modules.
-	 */
-	async_client_conn_t client_connection;
-	/** Packet counter.
-	 */
-	uint16_t packet_counter;
-	/** Safety lock.
-	 */
-	fibril_rwlock_t lock;
 };
 
Index: uspace/srv/net/il/ip/ip_client.c
===================================================================
--- uspace/srv/net/il/ip/ip_client.c	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/ip/ip_client.c	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -48,60 +48,4 @@
 #include "ip_header.h"
 
-int ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length){
-	ip_header_ref header;
-	uint8_t * data;
-	size_t padding;
-
-	padding =  ipopt_length % 4;
-	if(padding){
-		padding = 4 - padding;
-		ipopt_length += padding;
-	}
-	data = (uint8_t *) packet_prefix(packet, sizeof(ip_header_t) + padding);
-	if(! data){
-		return ENOMEM;
-	}
-	while(padding --){
-		data[sizeof(ip_header_t) + padding] = IPOPT_NOOP;
-	}
-	header = (ip_header_ref) data;
-	header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + ipopt_length);
-	header->ttl = (ttl ? ttl : IPDEFTTL); //(((ttl) <= MAXTTL) ? ttl : MAXTTL) : IPDEFTTL;
-	header->tos = tos;
-	header->protocol = protocol;
-	if(dont_fragment){
-		header->flags = IPFLAG_DONT_FRAGMENT;
-	}
-	return EOK;
-}
-
-int ip_client_process_packet(packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length){
-	ip_header_ref header;
-
-	header = (ip_header_ref) packet_get_data(packet);
-	if((! header)
-		|| (packet_get_data_length(packet) < sizeof(ip_header_t))){
-		return ENOMEM;
-	}
-	if(protocol){
-		*protocol = header->protocol;
-	}
-	if(ttl){
-		*ttl = header->ttl;
-	}
-	if(tos){
-		*tos = header->tos;
-	}
-	if(dont_fragment){
-		*dont_fragment = header->flags &IPFLAG_DONT_FRAGMENT;
-	}
-	if(ipopt_length){
-		*ipopt_length = IP_HEADER_LENGTH(header) - sizeof(ip_header_t);
-		return sizeof(ip_header_t);
-	}else{
-		return IP_HEADER_LENGTH(header);
-	}
-}
-
 size_t ip_client_header_length(packet_t packet){
 	ip_header_ref header;
@@ -113,19 +57,4 @@
 	}
 	return IP_HEADER_LENGTH(header);
-}
-
-int ip_client_set_pseudo_header_data_length(ip_pseudo_header_ref header, size_t headerlen, size_t data_length){
-	ipv4_pseudo_header_ref header_in;
-
-	if(! header){
-		return EBADMEM;
-	}
-	if(headerlen == sizeof(ipv4_pseudo_header_t)){
-		header_in = (ipv4_pseudo_header_ref) header;
-		header_in->data_length = htons(data_length);
-		return EOK;
-	}else{
-		return EINVAL;
-	}
 }
 
@@ -140,4 +69,5 @@
 		return EINVAL;
 	}
+
 	switch(src->sa_family){
 		case AF_INET:
@@ -171,4 +101,87 @@
 }
 
+int ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl, ip_tos_t tos, int dont_fragment, size_t ipopt_length){
+	ip_header_ref header;
+	uint8_t * data;
+	size_t padding;
+
+	// compute the padding if IP options are set
+	// multiple of 4 bytes
+	padding =  ipopt_length % 4;
+	if(padding){
+		padding = 4 - padding;
+		ipopt_length += padding;
+	}
+
+	// prefix the header
+	data = (uint8_t *) packet_prefix(packet, sizeof(ip_header_t) + padding);
+	if(! data){
+		return ENOMEM;
+	}
+
+	// add the padding
+	while(padding --){
+		data[sizeof(ip_header_t) + padding] = IPOPT_NOOP;
+	}
+
+	// set the header
+	header = (ip_header_ref) data;
+	header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) + ipopt_length);
+	header->ttl = (ttl ? ttl : IPDEFTTL); //(((ttl) <= MAXTTL) ? ttl : MAXTTL) : IPDEFTTL;
+	header->tos = tos;
+	header->protocol = protocol;
+
+	if(dont_fragment){
+		header->flags = IPFLAG_DONT_FRAGMENT;
+	}
+	return EOK;
+}
+
+int ip_client_process_packet(packet_t packet, ip_protocol_t * protocol, ip_ttl_t * ttl, ip_tos_t * tos, int * dont_fragment, size_t * ipopt_length){
+	ip_header_ref header;
+
+	header = (ip_header_ref) packet_get_data(packet);
+	if((! header)
+		|| (packet_get_data_length(packet) < sizeof(ip_header_t))){
+		return ENOMEM;
+	}
+
+	if(protocol){
+		*protocol = header->protocol;
+	}
+	if(ttl){
+		*ttl = header->ttl;
+	}
+	if(tos){
+		*tos = header->tos;
+	}
+	if(dont_fragment){
+		*dont_fragment = header->flags &IPFLAG_DONT_FRAGMENT;
+	}
+	if(ipopt_length){
+		*ipopt_length = IP_HEADER_LENGTH(header) - sizeof(ip_header_t);
+		return sizeof(ip_header_t);
+	}else{
+		return IP_HEADER_LENGTH(header);
+	}
+}
+
+int ip_client_set_pseudo_header_data_length(ip_pseudo_header_ref header, size_t headerlen, size_t data_length){
+	ipv4_pseudo_header_ref header_in;
+
+	if(! header){
+		return EBADMEM;
+	}
+
+	if(headerlen == sizeof(ipv4_pseudo_header_t)){
+		header_in = (ipv4_pseudo_header_ref) header;
+		header_in->data_length = htons(data_length);
+		return EOK;
+	// TODO IPv6
+	}else{
+		return EINVAL;
+	}
+}
+
 /** @}
  */
Index: uspace/srv/net/il/ip/ip_header.h
===================================================================
--- uspace/srv/net/il/ip/ip_header.h	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/ip/ip_header.h	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -42,8 +42,13 @@
 #include <sys/types.h>
 
-/** Returns the actual IP header length in bytes.
- *  @param[in] header The IP packet header.
- */
-#define IP_HEADER_LENGTH(header)		((header)->header_length * 4u)
+/** Returns the fragment offest high bits.
+ *  @param[in] length The prefixed data total length.
+ */
+#define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ((((length) / 8u) &0x1F00) >> 8)
+
+/** Returns the fragment offest low bits.
+ *  @param[in] length The prefixed data total length.
+ */
+#define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) (((length) / 8u) &0xFF)
 
 /** Returns the IP header length.
@@ -52,4 +57,24 @@
 #define IP_COMPUTE_HEADER_LENGTH(length)		((uint8_t) ((length) / 4u))
 
+/** Returns the fragment offest.
+ *  @param[in] header The IP packet header.
+ */
+#define IP_FRAGMENT_OFFSET(header) ((((header)->fragment_offset_high << 8) + (header)->fragment_offset_low) * 8u)
+
+/** Returns the IP packet header checksum.
+ *  @param[in] header The IP packet header.
+ */
+#define IP_HEADER_CHECKSUM(header)	(htons(ip_checksum((uint8_t *)(header), IP_HEADER_LENGTH(header))))
+
+/** Returns the actual IP packet data length.
+ *  @param[in] header The IP packet header.
+ */
+#define IP_HEADER_DATA_LENGTH(header)	(IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header))
+
+/** Returns the actual IP header length in bytes.
+ *  @param[in] header The IP packet header.
+ */
+#define IP_HEADER_LENGTH(header)		((header)->header_length * 4u)
+
 /** Returns the actual IP packet total length.
  *  @param[in] header The IP packet header.
@@ -57,28 +82,37 @@
 #define IP_TOTAL_LENGTH(header)		ntohs((header)->total_length)
 
-/** Returns the actual IP packet data length.
- *  @param[in] header The IP packet header.
- */
-#define IP_HEADER_DATA_LENGTH(header)	(IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header))
-
-/** Returns the IP packet header checksum.
- *  @param[in] header The IP packet header.
- */
-#define IP_HEADER_CHECKSUM(header)	(htons(ip_checksum((uint8_t *)(header), IP_HEADER_LENGTH(header))))
-
-/** Returns the fragment offest.
- *  @param[in] header The IP packet header.
- */
-#define IP_FRAGMENT_OFFSET(header) ((((header)->fragment_offset_high << 8) + (header)->fragment_offset_low) * 8u)
-
-/** Returns the fragment offest high bits.
- *  @param[in] length The prefixed data total length.
- */
-#define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ((((length) / 8u) &0x1F00) >> 8)
-
-/** Returns the fragment offest low bits.
- *  @param[in] length The prefixed data total length.
- */
-#define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) (((length) / 8u) &0xFF)
+/** @name IP flags definitions
+ */
+/*@{*/
+
+/** Fragment flag field shift.
+ */
+#define IPFLAG_FRAGMENT_SHIFT		1
+
+/** Fragmented flag field shift.
+ */
+#define IPFLAG_FRAGMENTED_SHIFT		0
+
+/** Don't fragment flag value.
+ *  Permits the packet fragmentation.
+ */
+#define IPFLAG_DONT_FRAGMENT		(0x1 << IPFLAG_FRAGMENT_SHIFT)
+
+/** Last fragment flag value.
+ *  Indicates the last packet fragment.
+ */
+#define IPFLAG_LAST_FRAGMENT		(0x0 << IPFLAG_FRAGMENTED_SHIFT)
+
+/** May fragment flag value.
+ *  Allows the packet fragmentation.
+ */
+#define IPFLAG_MAY_FRAGMENT			(0x0 << IPFLAG_FRAGMENT_SHIFT)
+
+/** More fragments flag value.
+ *  Indicates that more packet fragments follow.
+ */
+#define IPFLAG_MORE_FRAGMENTS		(0x1 << IPFLAG_FRAGMENTED_SHIFT)
+
+/*@}*/
 
 /** Type definition of the internet header.
@@ -91,4 +125,24 @@
  */
 typedef ip_header_t *		ip_header_ref;
+
+/** Type definition of the internet option header.
+ *  @see ip_header
+ */
+typedef struct ip_option	ip_option_t;
+
+/** Type definition of the internet option header pointer.
+ *  @see ip_header
+ */
+typedef ip_option_t *		ip_option_ref;
+
+/** Type definition of the internet version 4 pseudo header.
+ *  @see ipv4_pseudo_header
+ */
+typedef struct ipv4_pseudo_header	ipv4_pseudo_header_t;
+
+/** Type definition of the internet version 4 pseudo header pointer.
+ *  @see ipv4_pseudo_header
+ */
+typedef ipv4_pseudo_header_t *		ipv4_pseudo_header_ref;
 
 /** Internet header.
@@ -171,14 +225,4 @@
 } __attribute__ ((packed));
 
-/** Type definition of the internet option header.
- *  @see ip_header
- */
-typedef struct ip_option	ip_option_t;
-
-/** Type definition of the internet option header pointer.
- *  @see ip_header
- */
-typedef ip_option_t *		ip_option_ref;
-
 /** Internet option header.
  *  Only type field is always valid.
@@ -212,48 +256,4 @@
 } __attribute__ ((packed));
 
-/** @name IP flags definitions
- */
-/*@{*/
-
-/** Fragment flag field shift.
- */
-#define IPFLAG_FRAGMENT_SHIFT		1
-
-/** Fragmented flag field shift.
- */
-#define IPFLAG_FRAGMENTED_SHIFT		0
-
-/** May fragment flag value.
- *  Allows the packet fragmentation.
- */
-#define IPFLAG_MAY_FRAGMENT			(0x0 << IPFLAG_FRAGMENT_SHIFT)
-
-/** Don't fragment flag value.
- *  Permits the packet fragmentation.
- */
-#define IPFLAG_DONT_FRAGMENT		(0x1 << IPFLAG_FRAGMENT_SHIFT)
-
-/** Last fragment flag value.
- *  Indicates the last packet fragment.
- */
-#define IPFLAG_LAST_FRAGMENT		(0x0 << IPFLAG_FRAGMENTED_SHIFT)
-
-/** More fragments flag value.
- *  Indicates that more packet fragments follow.
- */
-#define IPFLAG_MORE_FRAGMENTS		(0x1 << IPFLAG_FRAGMENTED_SHIFT)
-
-/*@}*/
-
-/** Type definition of the internet version 4 pseudo header.
- *  @see ipv4_pseudo_header
- */
-typedef struct ipv4_pseudo_header	ipv4_pseudo_header_t;
-
-/** Type definition of the internet version 4 pseudo header pointer.
- *  @see ipv4_pseudo_header
- */
-typedef ipv4_pseudo_header_t *		ipv4_pseudo_header_ref;
-
 /** Internet version 4 pseudo header.
  */
Index: uspace/srv/net/il/ip/ip_messages.h
===================================================================
--- uspace/srv/net/il/ip/ip_messages.h	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/ip/ip_messages.h	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -51,16 +51,16 @@
 	 */
 	NET_IP_ADD_ROUTE = NET_IP_FIRST,
-	/** Sets the default gateway.
-	 *  @see ip_set_default_gateway()
+	/** Gets the actual route information.
+	 *  @see ip_get_route()
 	 */
-	NET_IP_SET_GATEWAY,
+	NET_IP_GET_ROUTE,
 	/** Processes the received error notification.
 	 *  @see ip_received_error_msg()
 	 */
 	NET_IP_RECEIVED_ERROR,
-	/** Gets the actual route information.
-	 *  @see ip_get_route()
+	/** Sets the default gateway.
+	 *  @see ip_set_default_gateway()
 	 */
-	NET_IP_GET_ROUTE
+	NET_IP_SET_GATEWAY
 } ip_messages;
 
@@ -69,4 +69,9 @@
 /*@{*/
 
+/** Returns the address message parameter.
+ *  @param[in] call The message call structure.
+ */
+#define IP_GET_ADDRESS(call)		({in_addr_t addr; addr.s_addr = IPC_GET_ARG3(*call); addr;})
+
 /** Returns the gateway message parameter.
  *  @param[in] call The message call structure.
@@ -74,8 +79,8 @@
 #define IP_GET_GATEWAY(call)		({in_addr_t addr; addr.s_addr = IPC_GET_ARG2(*call); addr;})
 
-/** Returns the address message parameter.
- *  @param[in] call The message call structure.
+/** Sets the header length in the message answer.
+ *  @param[out] answer The message answer structure.
  */
-#define IP_GET_ADDRESS(call)		({in_addr_t addr; addr.s_addr = IPC_GET_ARG3(*call); addr;})
+#define IP_SET_HEADERLEN(answer)	((size_t *) &IPC_GET_ARG2(*answer))
 
 /** Returns the network mask message parameter.
@@ -89,9 +94,4 @@
 #define IP_GET_PROTOCOL(call)		((ip_protocol_t) IPC_GET_ARG1(*call))
 
-/** Sets the header length in the message answer.
- *  @param[out] answer The message answer structure.
- */
-#define IP_SET_HEADERLEN(answer)	((size_t *) &IPC_GET_ARG2(*answer))
-
 /*@}*/
 
Index: uspace/srv/net/il/ip/ip_module.c
===================================================================
--- uspace/srv/net/il/ip/ip_module.c	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/ip/ip_module.c	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -58,4 +58,18 @@
 #define NAME	"IP protocol"
 
+/** IP module global data.
+ */
+extern ip_globals_t	ip_globals;
+
+/** Processes the IP message.
+ *  @param[in] callid The message identifier.
+ *  @param[in] call The message parameters.
+ *  @param[out] answer The message answer parameters.
+ *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
+ *  @returns EOK on success.
+ *  @returns Other error codes as defined for the ip_message() function.
+ */
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
+
 /** Prints the module name.
  *  @see NAME
@@ -72,17 +86,7 @@
 int module_start(async_client_conn_t client_connection);
 
-/** Processes the IP message.
- *  @param[in] callid The message identifier.
- *  @param[in] call The message parameters.
- *  @param[out] answer The message answer parameters.
- *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
- *  @returns EOK on success.
- *  @returns Other error codes as defined for the ip_message() function.
- */
-int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
-
-/** IP module global data.
- */
-extern ip_globals_t	ip_globals;
+int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
+	return ip_message(callid, call, answer, answer_count);
+}
 
 void module_print_name(void){
@@ -110,8 +114,4 @@
 }
 
-int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
-	return ip_message(callid, call, answer, answer_count);
-}
-
 /** @}
  */
Index: uspace/srv/net/il/ip/ip_remote.c
===================================================================
--- uspace/srv/net/il/ip/ip_remote.c	(revision 836dd794d0b0601e4fd961d6c350bb54de378866)
+++ uspace/srv/net/il/ip/ip_remote.c	(revision a64c64d04f3d981abf5d095ae65ed7ed4b40a244)
@@ -52,10 +52,10 @@
 #include "ip_messages.h"
 
-int ip_device_req(int ip_phone, device_id_t device_id, services_t service){
-	return generic_device_req(ip_phone, NET_IL_DEVICE, device_id, 0, service);
+int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway){
+	return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE, (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr, (ipcarg_t) address.s_addr, (ipcarg_t) netmask.s_addr);
 }
 
-int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){
-	return generic_send_msg(ip_phone, NET_IL_SEND, device_id, packet_get_id(packet), sender, error);
+int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg){
+	return (int) bind_service(service, (ipcarg_t) protocol, me, service, receiver);
 }
 
@@ -64,22 +64,6 @@
 }
 
-int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway){
-	return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE, (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr, (ipcarg_t) address.s_addr, (ipcarg_t) netmask.s_addr);
-}
-
-int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway){
-	return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY, (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr);
-}
-
-int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension){
-	return generic_packet_size_req(ip_phone, NET_IL_PACKET_SPACE, device_id, packet_dimension);
-}
-
-int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg){
-	return (int) bind_service(service, (ipcarg_t) protocol, me, service, receiver);
-}
-
-int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){
-	return generic_received_msg(ip_phone, NET_IP_RECEIVED_ERROR, device_id, packet_get_id(packet), target, error);
+int ip_device_req(int ip_phone, device_id_t device_id, services_t service){
+	return generic_device_req(ip_phone, NET_IL_DEVICE, device_id, 0, service);
 }
 
@@ -95,4 +79,5 @@
 		return EBADMEM;
 	}
+
 	*header = NULL;
 	message_id = async_send_1(ip_phone, NET_IP_GET_ROUTE, (ipcarg_t) protocol, &answer);
@@ -108,4 +93,5 @@
 	}
 	async_wait_for(message_id, &result);
+
 	if((result != EOK) && (*header)){
 		free(*header);
@@ -116,4 +102,20 @@
 }
 
+int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension){
+	return generic_packet_size_req(ip_phone, NET_IL_PACKET_SPACE, device_id, packet_dimension);
+}
+
+int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){
+	return generic_received_msg(ip_phone, NET_IP_RECEIVED_ERROR, device_id, packet_get_id(packet), target, error);
+}
+
+int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error){
+	return generic_send_msg(ip_phone, NET_IL_SEND, device_id, packet_get_id(packet), sender, error);
+}
+
+int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway){
+	return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY, (ipcarg_t) device_id, (ipcarg_t) gateway.s_addr);
+}
+
 /** @}
  */
