|
@@ -42,6 +42,7 @@ typedef struct
|
42
|
42
|
unsigned recvCnt;
|
43
|
43
|
unsigned queCbCnt;
|
44
|
44
|
unsigned errCnt;
|
|
45
|
+ cmChar_t ntopBuf[ INET_ADDRSTRLEN+1 ]; // use INET6_ADDRSTRLEN for IPv6
|
45
|
46
|
} cmUdp_t;
|
46
|
47
|
|
47
|
48
|
cmUdpH_t cmUdpNullHandle = cmSTATIC_NULL_HANDLE;
|
|
@@ -545,3 +546,19 @@ cmUdpRC_t cmUdpInitAddr( cmUdpH_t h, const char* addrStr, cmUdpPort_t portNumber
|
545
|
546
|
cmUdp_t* p = _cmUdpHandleToPtr(h);
|
546
|
547
|
return _cmUdpInitAddr(p,addrStr,portNumber,retAddrPtr);
|
547
|
548
|
}
|
|
549
|
+
|
|
550
|
+const cmChar_t* cmUdpAddrToString( cmUdpH_t h, const struct sockaddr_in* addr )
|
|
551
|
+{
|
|
552
|
+ cmUdp_t* p = _cmUdpHandleToPtr(h);
|
|
553
|
+
|
|
554
|
+ _cmUdpClear_errno();
|
|
555
|
+
|
|
556
|
+ if( inet_ntop(AF_INET, addr, p->ntopBuf, INET_ADDRSTRLEN) == NULL)
|
|
557
|
+ {
|
|
558
|
+ cmErrSysMsg(&p->err,kNtoPFailUdpRC,errno, "Network address to string conversion failed." );
|
|
559
|
+ return NULL;
|
|
560
|
+ }
|
|
561
|
+
|
|
562
|
+ p->ntopBuf[INET_ADDRSTRLEN]=0;
|
|
563
|
+ return p->ntopBuf;
|
|
564
|
+}
|