Index: uspace/lib/net/netif/netif_skel.c
===================================================================
--- uspace/lib/net/netif/netif_skel.c	(revision ee2fa30aed4921e38c357a0420357b61329be533)
+++ uspace/lib/net/netif/netif_skel.c	(revision ffa2c8ef45390c01f3f4be4827bcd41c32f7951c)
@@ -61,4 +61,5 @@
 /** Probe the existence of the device.
  *
+ * @param[in] netif_phone Network interface phone.
  * @param[in] device_id   Device identifier.
  * @param[in] irq         Device interrupt number.
@@ -70,5 +71,6 @@
  *
  */
-static int netif_probe_req_local(device_id_t device_id, int irq, void *io)
+static int netif_probe_req_local(int netif_phone, device_id_t device_id,
+    int irq, void *io)
 {
 	fibril_rwlock_write_lock(&netif_globals.lock);
@@ -81,4 +83,5 @@
 /** Send the packet queue.
  *
+ * @param[in] netif_phone Network interface phone.
  * @param[in] device_id   Device identifier.
  * @param[in] packet      Packet queue.
@@ -90,6 +93,6 @@
  *
  */
-static int netif_send_msg_local(device_id_t device_id, packet_t *packet,
-    services_t sender)
+static int netif_send_msg_local(int netif_phone, device_id_t device_id,
+    packet_t *packet, services_t sender)
 {
 	fibril_rwlock_write_lock(&netif_globals.lock);
@@ -102,4 +105,5 @@
 /** Start the device.
  *
+ * @param[in] netif_phone Network interface phone.
  * @param[in] device_id   Device identifier.
  *
@@ -111,5 +115,5 @@
  *
  */
-static int netif_start_req_local(device_id_t device_id)
+static int netif_start_req_local(int netif_phone, device_id_t device_id)
 {
 	fibril_rwlock_write_lock(&netif_globals.lock);
@@ -124,5 +128,6 @@
 	int result = netif_start_message(device);
 	if (result > NETIF_NULL) {
-		nil_device_state_msg(netif_globals.nil_sess, device_id, result);
+		int phone = device->nil_phone;
+		nil_device_state_msg(phone, device_id, result);
 		fibril_rwlock_write_unlock(&netif_globals.lock);
 		return EOK;
@@ -136,4 +141,5 @@
 /** Stop the device.
  *
+ * @param[in] netif_phone Network interface phone.
  * @param[in] device_id   Device identifier.
  *
@@ -145,5 +151,5 @@
  *
  */
-static int netif_stop_req_local(device_id_t device_id)
+static int netif_stop_req_local(int netif_phone, device_id_t device_id)
 {
 	fibril_rwlock_write_lock(&netif_globals.lock);
@@ -158,5 +164,6 @@
 	int result = netif_stop_message(device);
 	if (result > NETIF_NULL) {
-		nil_device_state_msg(netif_globals.nil_sess, device_id, result);
+		int phone = device->nil_phone;
+		nil_device_state_msg(phone, device_id, result);
 		fibril_rwlock_write_unlock(&netif_globals.lock);
 		return EOK;
@@ -212,5 +219,5 @@
 void netif_pq_release(packet_id_t packet_id)
 {
-	pq_release_remote(netif_globals.sess, packet_id);
+	pq_release_remote(netif_globals.net_phone, packet_id);
 }
 
@@ -225,29 +232,31 @@
 packet_t *netif_packet_get_1(size_t content)
 {
-	return packet_get_1_remote(netif_globals.sess, content);
+	return packet_get_1_remote(netif_globals.net_phone, content);
 }
 
 /** Register the device notification receiver,
  *
- * Register a network interface layer module as the device
+ * Register a  network interface layer module as the device
  * notification receiver.
  *
- * @param[in] sess      Session to the network interface layer module.
- *
- * @return EOK on success.
+ * @param[in] device_id Device identifier.
+ * @param[in] phone     Network interface layer module phone.
+ *
+ * @return EOK on success.
+ * @return ENOENT if there is no such device.
  * @return ELIMIT if there is another module registered.
  *
  */
-static int register_message(async_sess_t *sess)
-{
-	fibril_rwlock_write_lock(&netif_globals.lock);
-	if (netif_globals.nil_sess != NULL) {
-		fibril_rwlock_write_unlock(&netif_globals.lock);
+static int register_message(device_id_t device_id, int phone)
+{
+	netif_device_t *device;
+	int rc = find_device(device_id, &device);
+	if (rc != EOK)
+		return rc;
+	
+	if (device->nil_phone >= 0)
 		return ELIMIT;
-	}
-	
-	netif_globals.nil_sess = sess;
-	
-	fibril_rwlock_write_unlock(&netif_globals.lock);
+	
+	device->nil_phone = phone;
 	return EOK;
 }
@@ -279,28 +288,31 @@
 	*count = 0;
 	
-	if (!IPC_GET_IMETHOD(*call))
+	switch (IPC_GET_IMETHOD(*call)) {
+	case IPC_M_PHONE_HUNGUP:
 		return EOK;
 	
-	async_sess_t *callback =
-	    async_callback_receive_start(EXCHANGE_SERIALIZE, call);
-	if (callback)
-		return register_message(callback);
-	
-	switch (IPC_GET_IMETHOD(*call)) {
 	case NET_NETIF_PROBE:
-		return netif_probe_req_local(IPC_GET_DEVICE(*call),
+		return netif_probe_req_local(0, IPC_GET_DEVICE(*call),
 		    NETIF_GET_IRQ(*call), NETIF_GET_IO(*call));
 	
+	case IPC_M_CONNECT_TO_ME:
+		fibril_rwlock_write_lock(&netif_globals.lock);
+		
+		rc = register_message(IPC_GET_DEVICE(*call), IPC_GET_PHONE(*call));
+		
+		fibril_rwlock_write_unlock(&netif_globals.lock);
+		return rc;
+	
 	case NET_NETIF_SEND:
-		rc = packet_translate_remote(netif_globals.sess, &packet,
+		rc = packet_translate_remote(netif_globals.net_phone, &packet,
 		    IPC_GET_PACKET(*call));
 		if (rc != EOK)
 			return rc;
 		
-		return netif_send_msg_local(IPC_GET_DEVICE(*call), packet,
+		return netif_send_msg_local(0, IPC_GET_DEVICE(*call), packet,
 		    IPC_GET_SENDER(*call));
 	
 	case NET_NETIF_START:
-		return netif_start_req_local(IPC_GET_DEVICE(*call));
+		return netif_start_req_local(0, IPC_GET_DEVICE(*call));
 	
 	case NET_NETIF_STATS:
@@ -328,5 +340,5 @@
 	
 	case NET_NETIF_STOP:
-		return netif_stop_req_local(IPC_GET_DEVICE(*call));
+		return netif_stop_req_local(0, IPC_GET_DEVICE(*call));
 	
 	case NET_NETIF_GET_ADDR:
@@ -350,6 +362,5 @@
  *
  */
-static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall,
-    void *arg)
+static void netif_client_connection(ipc_callid_t iid, ipc_call_t *icall)
 {
 	/*
@@ -374,5 +385,6 @@
 		
 		/* End if said to either by the message or the processing result */
-		if ((!IPC_GET_IMETHOD(call)) || (res == EHANGUP))
+		if ((IPC_GET_IMETHOD(call) == IPC_M_PHONE_HUNGUP) ||
+		    (res == EHANGUP))
 			return;
 		
@@ -397,6 +409,5 @@
 	async_set_client_connection(netif_client_connection);
 	
-	netif_globals.sess = connect_to_service(SERVICE_NETWORKING);
-	netif_globals.nil_sess = NULL;
+	netif_globals.net_phone = connect_to_service(SERVICE_NETWORKING);
 	netif_device_map_initialize(&netif_globals.device_map);
 	
