summaryrefslogtreecommitdiff
path: root/tools/cxsocket.h
diff options
context:
space:
mode:
authorphintuka <phintuka>2006-12-17 17:47:20 +0000
committerphintuka <phintuka>2006-12-17 17:47:20 +0000
commit0b83bf3bf7117a91973fc66e03c1be5e5c7c5ed6 (patch)
tree17815701580f26953c5a9fa9a55dc48031320271 /tools/cxsocket.h
parent459ed36dd00119b75fa5b18432d7bceb7c0fc3ed (diff)
downloadxineliboutput-0b83bf3bf7117a91973fc66e03c1be5e5c7c5ed6.tar.gz
xineliboutput-0b83bf3bf7117a91973fc66e03c1be5e5c7c5ed6.tar.bz2
ip2txt - convert IP address and port to string
Diffstat (limited to 'tools/cxsocket.h')
-rw-r--r--tools/cxsocket.h23
1 files changed, 21 insertions, 2 deletions
diff --git a/tools/cxsocket.h b/tools/cxsocket.h
index d226fa04..628f4306 100644
--- a/tools/cxsocket.h
+++ b/tools/cxsocket.h
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: cxsocket.h,v 1.12 2006-12-14 15:15:37 phintuka Exp $
+ * $Id: cxsocket.h,v 1.13 2006-12-17 17:47:20 phintuka Exp $
*
*/
@@ -13,6 +13,25 @@
#define CLOSESOCKET(fd) do { if(fd>=0) { close(fd); fd=-1; } } while(0)
+static char *ip2txt(uint32_t ip, unsigned int port, char *str)
+{
+ // inet_ntoa is not thread-safe (?)
+ if(str) {
+ unsigned int iph =(unsigned int)ntohl(ip);
+ unsigned int porth =(unsigned int)ntohs(port);
+ if(!porth)
+ sprintf(str, "%d.%d.%d.%d",
+ ((iph>>24)&0xff), ((iph>>16)&0xff),
+ ((iph>>8)&0xff), ((iph)&0xff));
+ else
+ sprintf(str, "%u.%u.%u.%u:%u",
+ ((iph>>24)&0xff), ((iph>>16)&0xff),
+ ((iph>>8)&0xff), ((iph)&0xff),
+ porth);
+ }
+ return str;
+}
+
//
// Set socket buffers
//
@@ -261,7 +280,7 @@ static inline int udp_discovery_broadcast(int fd_discovery, int m_Port)
LOGERR("UDP broadcast send failed (discovery)");
result = -1;
} else {
- LOGDBG("UDP broadcast send succeed (discovery)");
+ //LOGDBG("UDP broadcast send succeed (discovery)");
result = 1;
}
free(test);