2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2006, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
20 * \brief Access Control of various sorts
23 #ifndef _ASTERISK_ACL_H
24 #define _ASTERISK_ACL_H
27 #if defined(__cplusplus) || defined(c_plusplus)
31 #include <netinet/in.h>
32 #include "asterisk/io.h"
34 #define AST_SENSE_DENY 0
35 #define AST_SENSE_ALLOW 1
37 /* Host based access control */
39 /*! \brief internal representation of acl entries
40 * In principle user applications would have no need for this,
41 * but there is sometimes a need to extract individual items,
42 * e.g. to print them, and rather than defining iterators to
43 * navigate the list, and an externally visible 'struct ast_ha_entry',
44 * at least in the short term it is more convenient to make the whole
45 * thing public and let users play with them.
48 /* Host access rule */
49 struct in_addr netaddr;
50 struct in_addr netmask;
55 /*! \brief Free host access list */
56 void ast_free_ha(struct ast_ha *ha);
58 /*! \brief Append ACL entry to host access list. */
59 struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int *error);
61 /*! \brief Check IP address with host access list */
62 int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin);
64 /*! \brief Copy host access list */
65 struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original);
67 int ast_get_ip(struct sockaddr_in *sin, const char *value);
69 int ast_get_ip_or_srv(struct sockaddr_in *sin, const char *value, const char *service);
71 int ast_ouraddrfor(struct in_addr *them, struct in_addr *us);
73 int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr);
75 int ast_str2cos(const char *value, unsigned int *cos);
77 int ast_str2tos(const char *value, unsigned int *tos);
78 const char *ast_tos2str(unsigned int tos);
80 #if defined(__cplusplus) || defined(c_plusplus)
84 #endif /* _ASTERISK_ACL_H */