diff options
Diffstat (limited to 'pjlib')
-rw-r--r-- | pjlib/include/pj/sock.h | 13 | ||||
-rw-r--r-- | pjlib/src/pj/sock_bsd.c | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/pjlib/include/pj/sock.h b/pjlib/include/pj/sock.h index 3e3307ab..05d1ef5e 100644 --- a/pjlib/include/pj/sock.h +++ b/pjlib/include/pj/sock.h @@ -327,6 +327,19 @@ PJ_DECL(int) pj_inet_aton(const pj_str_t *cp, struct pj_in_addr *inp); */ PJ_DECL(pj_in_addr) pj_inet_addr(const pj_str_t *cp); +/** + * Convert address string with numbers and dots to binary IP address. + * + * @param cp The IP address in numbers and dots notation. + * @return If success, the IP address is returned in network + * byte order. If failed, PJ_INADDR_NONE will be + * returned. + * @remark + * This is an obsolete interface to #pj_inet_aton(); it is obsolete + * because -1 is a valid address (255.255.255.255), and #pj_inet_aton() + * provides a cleaner way to indicate error return. + */ +PJ_DECL(pj_in_addr) pj_inet_addr2(const char *cp); /** * Get the transport layer port number of an Internet socket address. diff --git a/pjlib/src/pj/sock_bsd.c b/pjlib/src/pj/sock_bsd.c index 09b362ad..e207eeaa 100644 --- a/pjlib/src/pj/sock_bsd.c +++ b/pjlib/src/pj/sock_bsd.c @@ -185,6 +185,15 @@ PJ_DEF(pj_in_addr) pj_inet_addr(const pj_str_t *cp) } /* + * Convert address string with numbers and dots to binary IP address. + */ +PJ_DEF(pj_in_addr) pj_inet_addr2(const char *cp) +{ + pj_str_t str = pj_str((char*)cp); + return pj_inet_addr(&str); +} + +/* * 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 |