Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
3f663a54
Commit
3f663a54
authored
5 years ago
by
Friendly Automation
Committed by
Gerrit Code Review
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge "netsock2: ast_addressfamily_to_sockaddrsize and ast_sockaddr_from_sockaddr."
parents
f6f678fe
3bc8b365
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/asterisk/netsock2.h
+42
-0
42 additions, 0 deletions
include/asterisk/netsock2.h
with
42 additions
and
0 deletions
include/asterisk/netsock2.h
+
42
−
0
View file @
3f663a54
...
...
@@ -31,6 +31,8 @@ extern "C" {
#include
<netinet/in.h>
#include
"asterisk/logger.h"
/*
* String buffer size that can accommodate a fully stringified representation of a
* supported IP address & port:
...
...
@@ -781,6 +783,46 @@ int _ast_sockaddr_to_sin(const struct ast_sockaddr *addr,
void
_ast_sockaddr_from_sin
(
struct
ast_sockaddr
*
addr
,
const
struct
sockaddr_in
*
sin
,
const
char
*
file
,
int
line
,
const
char
*
func
);
/*!
* \since 13.31.0, 16.8.0, 17.2.0
*
* \brief Takes an AF_XXX value as input and returns the size of the underlying
* sockaddr structure if known, or zero if not.
*
* \param family The AF_XXX value to determine the size of
* \return Size of the applicable struct sockaddr.
*/
#define ast_addressfamily_to_sockaddrsize(family) _ast_addressfamily_to_sockaddrsize(addr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
static
inline
int
_ast_addressfamily_to_sockaddrsize
(
int
af
,
const
char
*
file
,
int
line
,
const
char
*
func
)
{
switch
(
af
)
{
case
AF_INET
:
return
sizeof
(
struct
sockaddr_in
);
case
AF_INET6
:
return
sizeof
(
struct
sockaddr_in6
);
default:
ast_log
(
__LOG_WARNING
,
file
,
line
,
func
,
"Unknown address family %d encountered.
\n
"
,
af
);
return
0
;
}
}
/*!
* \since 13.31.0, 16.8.0, 17.2.0
*
* \brief Converts a struct sockaddr to a struct ast_sockaddr.
*
* Note that there is an underlying assumption that sockaddr data is valid, more specifically,
* if sa_family is set to AF_INET that it's actually a sockaddr_in, and in the case of AF_INET6
* a valid sockaddr_in6 structure.
*
* You can check for failure with ast_sockaddr_isnull.
*
* \param[out] addr The address of the ast_sockaddr to store into
* \param sockaddr The sockaddr structure (sockaddr_in or sockaddr_in6) to convert
* \return Nothing
*/
#define ast_sockaddr_from_sockaddr(addr,sockaddr) ast_sockaddr_copy_sockaddr(addr, sockaddr, ast_addressfamily_to_sockaddrsize(((const struct sockaddr*)(sockaddr))->sa_family))
/*@}*/
#if defined(__cplusplus) || defined(c_plusplus)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment