From 4ab290236377bbde59305d4835314cd29e85dc4b Mon Sep 17 00:00:00 2001 From: kpl Date: Sun, 15 Jun 2014 22:17:31 -0700 Subject: [PATCH] cmUdpPort.h/c : Added cmUdpAddrIsEqual(). --- cmUdpPort.c | 8 ++++++++ cmUdpPort.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/cmUdpPort.c b/cmUdpPort.c index e981be6..db84574 100644 --- a/cmUdpPort.c +++ b/cmUdpPort.c @@ -589,6 +589,14 @@ const cmChar_t* cmUdpAddrToString( cmUdpH_t h, const struct sockaddr_in* addr ) return p->ntopBuf; } +bool cmUdpAddrIsEqual( const struct sockaddr_in* a0, const struct sockaddr_in* a1 ) +{ + return a0->sin_family == a1->sin_family + && a0->sin_port == a1->sin_port + && memcmp(&a0->sin_addr,&a1->sin_addr,sizeof(a0->sin_addr))==0; +} + + const cmChar_t* cmUdpHostName( cmUdpH_t h ) { cmUdp_t* p = _cmUdpHandleToPtr(h); diff --git a/cmUdpPort.h b/cmUdpPort.h index 6959f43..827ab44 100644 --- a/cmUdpPort.h +++ b/cmUdpPort.h @@ -132,6 +132,8 @@ extern "C" { const cmChar_t* cmUdpAddrToString( cmUdpH_t h, const struct sockaddr_in* addr ); + bool cmUdpAddrIsEqual( const struct sockaddr_in* a0, const struct sockaddr_in* a1 ); + const cmChar_t* cmUdpHostName( cmUdpH_t h );