From d87f8c429e6852d11f7a3bddf6981e2f754c1ea8 Mon Sep 17 00:00:00 2001 From: George Joseph Date: Thu, 19 Jun 2014 20:13:20 +0000 Subject: pjsip cli: Change Identify to show CIDR notation instead of netmasks. * Added ast_sockaddr_cidr_bits() to count the 1 bits in an ast_sockaddr. * Added ast_ha_join_cidr() which uses ast_sockaddr_cidr_bits() for the netmask instead of ast_sockaddr_stringify_addr. * Changed res_pjsip_endpoint_identifier_ip to call ast_ha_join_cidr() instead of ast_ha_join() for the CLI output. This is a CLI change only. AMI was not affected. Tested by: George Joseph Review: https://reviewboard.asterisk.org/r/3652/ ........ Merged revisions 416737 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416738 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/acl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'main/acl.c') diff --git a/main/acl.c b/main/acl.c index 213d6d8aa..5c3b633d7 100644 --- a/main/acl.c +++ b/main/acl.c @@ -677,6 +677,19 @@ void ast_ha_join(const struct ast_ha *ha, struct ast_str **buf) } } +void ast_ha_join_cidr(const struct ast_ha *ha, struct ast_str **buf) +{ + for (; ha; ha = ha->next) { + const char *addr = ast_sockaddr_stringify_addr(&ha->addr); + ast_str_append(buf, 0, "%s%s/%d", + ha->sense == AST_SENSE_ALLOW ? "!" : "", + addr, ast_sockaddr_cidr_bits(&ha->netmask)); + if (ha->next) { + ast_str_append(buf, 0, ","); + } + } +} + enum ast_acl_sense ast_apply_acl(struct ast_acl_list *acl_list, const struct ast_sockaddr *addr, const char *purpose) { struct ast_acl *acl; -- cgit v1.2.3