mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-09 06:28:14 +00:00
Merged revisions 324484 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r324484 | twilson | 2011-06-22 13:52:04 -0500 (Wed, 22 Jun 2011) | 20 lines Stop sending IPv6 link-local scope-ids in SIP messages The idea behind the patch listed below was used, but in a more targeted manner. There are now address stringification functions for addresses that are meant to be sent to a remote party. Link-local scope-ids only make sense on the machine from which they originate and so are stripped in the new functions. There is also a host sanitization function added to chan_sip which is used for when peer and dialog tohost fields or sip_registry hostnames are used to craft a SIP message. Also added are some basic unit tests for netsock2 address parsing. (closes issue ASTERISK-17711) Reported by: ch_djalel Patches: asterisk-1.8.3.2-ipv6_ll_scope.patch uploaded by ch_djalel (license 1251) Review: https://reviewboard.asterisk.org/r/1278/ ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@324487 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -152,8 +152,13 @@ int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockadd
|
||||
#define AST_SOCKADDR_STR_ADDR (1 << 0)
|
||||
#define AST_SOCKADDR_STR_PORT (1 << 1)
|
||||
#define AST_SOCKADDR_STR_BRACKETS (1 << 2)
|
||||
#define AST_SOCKADDR_STR_HOST AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_BRACKETS
|
||||
#define AST_SOCKADDR_STR_DEFAULT AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT
|
||||
#define AST_SOCKADDR_STR_REMOTE (1 << 3)
|
||||
#define AST_SOCKADDR_STR_HOST (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_BRACKETS)
|
||||
#define AST_SOCKADDR_STR_DEFAULT (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT)
|
||||
#define AST_SOCKADDR_STR_ADDR_REMOTE (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_REMOTE)
|
||||
#define AST_SOCKADDR_STR_HOST_REMOTE (AST_SOCKADDR_STR_HOST | AST_SOCKADDR_STR_REMOTE)
|
||||
#define AST_SOCKADDR_STR_DEFAULT_REMOTE (AST_SOCKADDR_STR_DEFAULT | AST_SOCKADDR_STR_REMOTE)
|
||||
#define AST_SOCKADDR_STR_FORMAT_MASK (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT | AST_SOCKADDR_STR_BRACKETS)
|
||||
|
||||
/*!
|
||||
* \since 1.8
|
||||
@@ -199,6 +204,23 @@ static inline char *ast_sockaddr_stringify(const struct ast_sockaddr *addr)
|
||||
return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_DEFAULT);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \since 1.8
|
||||
*
|
||||
* \brief
|
||||
* Wrapper around ast_sockaddr_stringify_fmt() with default format
|
||||
*
|
||||
* \note This address will be suitable for passing to a remote machine via the
|
||||
* application layer. For example, the scope-id on a link-local IPv6 address
|
||||
* will be stripped.
|
||||
*
|
||||
* \return same as ast_sockaddr_stringify_fmt()
|
||||
*/
|
||||
static inline char *ast_sockaddr_stringify_remote(const struct ast_sockaddr *addr)
|
||||
{
|
||||
return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_DEFAULT_REMOTE);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \since 1.8
|
||||
*
|
||||
@@ -212,6 +234,23 @@ static inline char *ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
|
||||
return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_ADDR);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \since 1.8
|
||||
*
|
||||
* \brief
|
||||
* Wrapper around ast_sockaddr_stringify_fmt() to return an address only
|
||||
*
|
||||
* \note This address will be suitable for passing to a remote machine via the
|
||||
* application layer. For example, the scope-id on a link-local IPv6 address
|
||||
* will be stripped.
|
||||
*
|
||||
* \return same as ast_sockaddr_stringify_fmt()
|
||||
*/
|
||||
static inline char *ast_sockaddr_stringify_addr_remote(const struct ast_sockaddr *addr)
|
||||
{
|
||||
return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_ADDR_REMOTE);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \since 1.8
|
||||
*
|
||||
@@ -226,6 +265,24 @@ static inline char *ast_sockaddr_stringify_host(const struct ast_sockaddr *addr)
|
||||
return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_HOST);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \since 1.8
|
||||
*
|
||||
* \brief
|
||||
* Wrapper around ast_sockaddr_stringify_fmt() to return an address only,
|
||||
* suitable for a URL (with brackets for IPv6).
|
||||
*
|
||||
* \note This address will be suitable for passing to a remote machine via the
|
||||
* application layer. For example, the scope-id on a link-local IPv6 address
|
||||
* will be stripped.
|
||||
*
|
||||
* \return same as ast_sockaddr_stringify_fmt()
|
||||
*/
|
||||
static inline char *ast_sockaddr_stringify_host_remote(const struct ast_sockaddr *addr)
|
||||
{
|
||||
return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_HOST_REMOTE);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \since 1.8
|
||||
*
|
||||
@@ -409,6 +466,20 @@ int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr);
|
||||
*/
|
||||
int ast_sockaddr_is_ipv4_multicast(const struct ast_sockaddr *addr);
|
||||
|
||||
/*!
|
||||
* \since 1.8
|
||||
*
|
||||
* \brief
|
||||
* Determine if this is a link-local IPv6 address
|
||||
*
|
||||
* \warning You should rarely need this function. Only use if you know what
|
||||
* you're doing.
|
||||
*
|
||||
* \retval 1 This is a link-local IPv6 address.
|
||||
* \retval 0 This is link-local IPv6 address.
|
||||
*/
|
||||
int ast_sockaddr_is_ipv6_link_local(const struct ast_sockaddr *addr);
|
||||
|
||||
/*!
|
||||
* \since 1.8
|
||||
*
|
||||
|
Reference in New Issue
Block a user