Browse Source

cmUdpPort.h/c : Added cmUdpAddrIsEqual().

master
kpl 10 years ago
parent
commit
4ab2902363
2 changed files with 10 additions and 0 deletions
  1. 8
    0
      cmUdpPort.c
  2. 2
    0
      cmUdpPort.h

+ 8
- 0
cmUdpPort.c View File

@@ -589,6 +589,14 @@ const cmChar_t* cmUdpAddrToString( cmUdpH_t h, const struct sockaddr_in* addr )
589 589
   return p->ntopBuf;
590 590
 }
591 591
 
592
+bool  cmUdpAddrIsEqual( const struct sockaddr_in* a0, const struct sockaddr_in* a1 )
593
+{
594
+  return a0->sin_family == a1->sin_family 
595
+    &&   a0->sin_port   == a1->sin_port 
596
+    &&   memcmp(&a0->sin_addr,&a1->sin_addr,sizeof(a0->sin_addr))==0;
597
+}
598
+
599
+
592 600
 const cmChar_t* cmUdpHostName( cmUdpH_t h )
593 601
 {
594 602
   cmUdp_t* p = _cmUdpHandleToPtr(h);

+ 2
- 0
cmUdpPort.h View File

@@ -132,6 +132,8 @@ extern "C" {
132 132
 
133 133
   const cmChar_t*  cmUdpAddrToString( cmUdpH_t h, const struct sockaddr_in* addr );
134 134
 
135
+  bool             cmUdpAddrIsEqual( const struct sockaddr_in* a0, const struct sockaddr_in* a1 );
136
+
135 137
   const cmChar_t* cmUdpHostName( cmUdpH_t h );
136 138
 
137 139
   

Loading…
Cancel
Save