+/*************************** SUBROUTINES ***************************/
+/*
+ * Just for the heck of it, let's try to not link with iwlib.
+ * This will keep the binary small and tiny...
+ */
+
+/*------------------------------------------------------------------*/
+/*
+ * Open a socket.
+ * Depending on the protocol present, open the right socket. The socket
+ * will allow us to talk to the driver.
+ */
+int
+iw_sockets_open(void)
+{
+ int ipx_sock = -1; /* IPX socket */
+ int ax25_sock = -1; /* AX.25 socket */
+ int inet_sock = -1; /* INET socket */
+ int ddp_sock = -1; /* Appletalk DDP socket */
+
+ /*
+ * Now pick any (exisiting) useful socket family for generic queries
+ * Note : don't open all the socket, only returns when one matches,
+ * all protocols might not be valid.
+ * Workaround by Jim Kaba <jkaba@sarnoff.com>
+ * Note : in 99% of the case, we will just open the inet_sock.
+ * The remaining 1% case are not fully correct...
+ */
+ inet_sock=socket(AF_INET, SOCK_DGRAM, 0);
+ if(inet_sock!=-1)
+ return inet_sock;
+ ipx_sock=socket(AF_IPX, SOCK_DGRAM, 0);
+ if(ipx_sock!=-1)
+ return ipx_sock;
+ ax25_sock=socket(AF_AX25, SOCK_DGRAM, 0);
+ if(ax25_sock!=-1)
+ return ax25_sock;
+ ddp_sock=socket(AF_APPLETALK, SOCK_DGRAM, 0);
+ /*
+ * If this is -1 we have no known network layers and its time to jump.
+ */
+ return ddp_sock;
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Display an Ethernet address in readable format.
+ */
+void
+iw_ether_ntop(const struct ether_addr* eth, char* buf)
+{
+ sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+ eth->ether_addr_octet[0], eth->ether_addr_octet[1],
+ eth->ether_addr_octet[2], eth->ether_addr_octet[3],
+ eth->ether_addr_octet[4], eth->ether_addr_octet[5]);
+}
+