Index: uspace/srv/net/ethip/ethip.c
===================================================================
--- uspace/srv/net/ethip/ethip.c	(revision 257feec9d30b7aa8ced34c0ef045309a9cc98d3c)
+++ uspace/srv/net/ethip/ethip.c	(revision 02a09ed9ab72cd7eb2ca3f11873db078ab906acc)
@@ -44,5 +44,5 @@
 #include <stdio.h>
 #include <stdlib.h>
-
+#include <net/socket_codes.h>
 #include "arp.h"
 #include "ethip.h"
@@ -55,8 +55,8 @@
 static int ethip_open(iplink_srv_t *srv);
 static int ethip_close(iplink_srv_t *srv);
-static int ethip_send(iplink_srv_t *srv, iplink_srv_sdu_t *sdu);
+static int ethip_send(iplink_srv_t *srv, iplink_sdu_t *sdu);
 static int ethip_get_mtu(iplink_srv_t *srv, size_t *mtu);
-static int ethip_addr_add(iplink_srv_t *srv, uint32_t addr);
-static int ethip_addr_remove(iplink_srv_t *srv, uint32_t addr);
+static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr);
+static int ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr);
 
 static void ethip_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg);
@@ -164,28 +164,48 @@
 }
 
-static int ethip_send(iplink_srv_t *srv, iplink_srv_sdu_t *sdu)
-{
-	ethip_nic_t *nic = (ethip_nic_t *)srv->arg;
+static int ethip_send(iplink_srv_t *srv, iplink_sdu_t *sdu)
+{
+	log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_send()");
+	
+	ethip_nic_t *nic = (ethip_nic_t *) srv->arg;
+	
+	addr32_t src_v4;
+	addr128_t src_v6;
+	uint16_t src_af = inet_addr_get(&sdu->src, &src_v4, &src_v6);
+	
+	addr32_t dest_v4;
+	addr128_t dest_v6;
+	uint16_t dest_af = inet_addr_get(&sdu->dest, &dest_v4, &dest_v6);
+	
+	if (src_af != dest_af)
+		return EINVAL;
+	
+	int rc;
 	eth_frame_t frame;
+	
+	switch (src_af) {
+	case AF_INET:
+		rc = arp_translate(nic, src_v4, dest_v4, frame.dest);
+		if (rc != EOK) {
+			log_msg(LOG_DEFAULT, LVL_WARN, "Failed to look up IPv4 address 0x%"
+			    PRIx32, dest_v4);
+			return rc;
+		}
+		
+		addr48(nic->mac_addr, frame.src);
+		frame.etype_len = ETYPE_IP;
+		frame.data = sdu->data;
+		frame.size = sdu->size;
+		
+		break;
+	case AF_INET6:
+		// FIXME TODO
+		return ENOTSUP;
+	default:
+		return EINVAL;
+	}
+	
 	void *data;
 	size_t size;
-	mac48_addr_t dest_mac_addr;
-	int rc;
-
-	log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_send()");
-
-	rc = arp_translate(nic, sdu->lsrc, sdu->ldest, &dest_mac_addr);
-	if (rc != EOK) {
-		log_msg(LOG_DEFAULT, LVL_WARN, "Failed to look up IP address 0x%" PRIx32,
-		    sdu->ldest);
-		return rc;
-	}
-
-	frame.dest      = dest_mac_addr;
-	frame.src       = nic->mac_addr;
-	frame.etype_len = ETYPE_IP;
-	frame.data = sdu->data;
-	frame.size = sdu->size;
-
 	rc = eth_pdu_encode(&frame, &data, &size);
 	if (rc != EOK)
@@ -201,18 +221,17 @@
 {
 	log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_received(): srv=%p", srv);
-	ethip_nic_t *nic = (ethip_nic_t *)srv->arg;
+	ethip_nic_t *nic = (ethip_nic_t *) srv->arg;
+	
+	log_msg(LOG_DEFAULT, LVL_DEBUG, " - eth_pdu_decode");
+	
 	eth_frame_t frame;
-	iplink_srv_sdu_t sdu;
-	int rc;
-
-	log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_received()");
-
-	log_msg(LOG_DEFAULT, LVL_DEBUG, " - eth_pdu_decode");
-	rc = eth_pdu_decode(data, size, &frame);
+	int rc = eth_pdu_decode(data, size, &frame);
 	if (rc != EOK) {
 		log_msg(LOG_DEFAULT, LVL_DEBUG, " - eth_pdu_decode failed");
 		return rc;
 	}
-
+	
+	iplink_recv_sdu_t sdu;
+	
 	switch (frame.etype_len) {
 	case ETYPE_ARP:
@@ -221,10 +240,8 @@
 	case ETYPE_IP:
 		log_msg(LOG_DEFAULT, LVL_DEBUG, " - construct SDU");
-		sdu.lsrc = 0;
-		sdu.ldest = 0;
 		sdu.data = frame.data;
 		sdu.size = frame.size;
 		log_msg(LOG_DEFAULT, LVL_DEBUG, " - call iplink_ev_recv");
-		rc = iplink_ev_recv(&nic->iplink, &sdu);
+		rc = iplink_ev_recv(&nic->iplink, &sdu, AF_INET);
 		break;
 	default:
@@ -244,8 +261,6 @@
 }
 
-static int ethip_addr_add(iplink_srv_t *srv, uint32_t addr)
-{
-	log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_addr_add(0x%" PRIx32 ")", addr);
-	
+static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr)
+{
 	ethip_nic_t *nic = (ethip_nic_t *) srv->arg;
 	
@@ -253,11 +268,9 @@
 }
 
-static int ethip_addr_remove(iplink_srv_t *srv, uint32_t addr)
-{
-	log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_addr_remove(0x%" PRIx32 ")", addr);
-	
-	ethip_nic_t *nic = (ethip_nic_t *)srv->arg;
-	
-	return ethip_nic_addr_add(nic, addr);
+static int ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr)
+{
+	ethip_nic_t *nic = (ethip_nic_t *) srv->arg;
+	
+	return ethip_nic_addr_remove(nic, addr);
 }
 
