mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
Stasis: Update security events to use Stasis
Also moves ACL messages to the security topic and gets rid of the ACL topic (closes issue ASTERISK-21103) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/2496/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@388975 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
44
main/json.c
44
main/json.c
@@ -527,6 +527,50 @@ struct ast_json *ast_json_timeval(const struct timeval tv, const char *zone)
|
||||
return ast_json_string_create(buf);
|
||||
}
|
||||
|
||||
struct ast_json *ast_json_ipaddr(const struct ast_sockaddr *addr, enum ast_transport transport_type)
|
||||
{
|
||||
struct ast_str *string = ast_str_alloca(64);
|
||||
|
||||
if (!string) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ast_str_set(&string, 0, (ast_sockaddr_is_ipv4(addr) ||
|
||||
ast_sockaddr_is_ipv4_mapped(addr)) ? "IPV4/" : "IPV6/");
|
||||
|
||||
if (transport_type) {
|
||||
char *transport_string = NULL;
|
||||
|
||||
/* NOTE: None will be applied if multiple transport types are specified in transport_type */
|
||||
switch(transport_type) {
|
||||
case AST_TRANSPORT_UDP:
|
||||
transport_string = "UDP";
|
||||
break;
|
||||
case AST_TRANSPORT_TCP:
|
||||
transport_string = "TCP";
|
||||
break;
|
||||
case AST_TRANSPORT_TLS:
|
||||
transport_string = "TLS";
|
||||
break;
|
||||
case AST_TRANSPORT_WS:
|
||||
transport_string = "WS";
|
||||
break;
|
||||
case AST_TRANSPORT_WSS:
|
||||
transport_string = "WSS";
|
||||
break;
|
||||
}
|
||||
|
||||
if (transport_string) {
|
||||
ast_str_append(&string, 0, "%s/", transport_string);
|
||||
}
|
||||
}
|
||||
|
||||
ast_str_append(&string, 0, "%s", ast_sockaddr_stringify_addr(addr));
|
||||
ast_str_append(&string, 0, "/%s", ast_sockaddr_stringify_port(addr));
|
||||
|
||||
return ast_json_string_create(ast_str_buffer(string));
|
||||
}
|
||||
|
||||
void ast_json_init(void)
|
||||
{
|
||||
/* Setup to use Asterisk custom allocators */
|
||||
|
Reference in New Issue
Block a user