diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-12-02 15:36:46 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-12-02 15:36:46 +0000 |
commit | b49338ee972a66fb6e5ece4b97440d0c3cfa642b (patch) | |
tree | 0a3df788f90101bd04b667021eac514355f22b1f /pjlib/src/pj/sock_common.c | |
parent | ea951533e9d970b9fd9d98b34081f568679d9bfc (diff) |
More ticket #415: Added pj_sockaddr_get_len() and pj_inet_ntop2(), and fixed Symbian combilation warnings with gcce
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1608 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/sock_common.c')
-rw-r--r-- | pjlib/src/pj/sock_common.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/pjlib/src/pj/sock_common.c b/pjlib/src/pj/sock_common.c index 06aa9411..1c108336 100644 --- a/pjlib/src/pj/sock_common.c +++ b/pjlib/src/pj/sock_common.c @@ -47,6 +47,18 @@ PJ_DEF(pj_in_addr) pj_inet_addr2(const char *cp) } /* + * Get text representation. + */ +PJ_DEF(char*) pj_inet_ntop2( int af, const void *src, + char *dst, int size) +{ + pj_status_t status; + + status = pj_inet_ntop(af, src, dst, size); + return (status==PJ_SUCCESS)? dst : NULL; +} + +/* * Set the IP address of an IP socket address from string address, * with resolving the host if necessary. The string address may be in a * standard numbers and dots notation or may be a hostname. If hostname @@ -253,6 +265,18 @@ PJ_DEF(unsigned) pj_sockaddr_get_addr_len(const pj_sockaddr_t *addr) } /* + * Get socket address length. + */ +PJ_DEF(unsigned) pj_sockaddr_get_len(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); + return a->addr.sa_family == PJ_AF_INET6 ? + sizeof(pj_sockaddr_in6) : sizeof(pj_sockaddr_in); +} + +/* * Set port number of pj_sockaddr_in */ PJ_DEF(void) pj_sockaddr_in_set_port(pj_sockaddr_in *addr, @@ -269,8 +293,7 @@ PJ_DEF(pj_status_t) pj_sockaddr_set_port(pj_sockaddr *addr, { int af = addr->addr.sa_family; - PJ_ASSERT_ON_FAIL(af == PJ_AF_INET || af == PJ_AF_INET6, - PJ_EINVAL); + PJ_ASSERT_RETURN(af==PJ_AF_INET || af==PJ_AF_INET6, PJ_EINVAL); if (af == PJ_AF_INET6) addr->ipv6.sin6_port = pj_htons(hostport); |