diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-12-12 17:13:34 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-12-12 17:13:34 +0000 |
commit | b3dd74c7d4f70cfac7d4fd8397764c50a629fc1c (patch) | |
tree | 542dde21e8db3aaea6291babcf17e3fd5a9078e8 /pjlib/src/pj/sock_common.c | |
parent | 28ad2e029fa5cc7c8b116c9da524173dd58efdcd (diff) |
Disable assertion in pj_sockaddr_has_addr()
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1629 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/sock_common.c')
-rw-r--r-- | pjlib/src/pj/sock_common.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/pjlib/src/pj/sock_common.c b/pjlib/src/pj/sock_common.c index 5bf19d0c..71cd02e7 100644 --- a/pjlib/src/pj/sock_common.c +++ b/pjlib/src/pj/sock_common.c @@ -309,10 +309,29 @@ PJ_DEF(pj_bool_t) pj_sockaddr_has_addr(const pj_sockaddr_t *addr) { const pj_sockaddr *a = (const pj_sockaddr*)addr; - PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET || - a->addr.sa_family == PJ_AF_INET6, PJ_EAFNOTSUP); + /* It's probably not wise to raise assertion here if + * the address doesn't contain a valid address family, and + * just return PJ_FALSE instead. + * + * The reason is because application may need to distinguish + * these three conditions with sockaddr: + * a) sockaddr is not initialized. This is by convention + * indicated by sa_family==0. + * b) sockaddr is initialized with zero address. This is + * indicated with the address field having zero address. + * c) sockaddr is initialized with valid address/port. + * + * If we enable this assertion, then application will loose + * the capability to specify condition a), since it will be + * forced to always initialize sockaddr (even with zero address). + * This may break some parts of upper layer libraries. + */ + //PJ_ASSERT_RETURN(a->addr.sa_family == PJ_AF_INET || + // a->addr.sa_family == PJ_AF_INET6, PJ_EAFNOTSUP); - if (a->addr.sa_family == PJ_AF_INET6) { + if (a->addr.sa_family!=PJ_AF_INET && a->addr.sa_family!=PJ_AF_INET6) { + return PJ_FALSE; + } else if (a->addr.sa_family == PJ_AF_INET6) { pj_uint8_t zero[24]; pj_bzero(zero, sizeof(zero)); return pj_memcmp(a->ipv6.sin6_addr.s6_addr, zero, |