2002-05-30 01:40:29 +00:00
|
|
|
/*
|
2005-08-30 18:32:10 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2002-05-30 01:40:29 +00:00
|
|
|
*
|
2006-03-28 03:28:52 +00:00
|
|
|
* Copyright (C) 1999 - 2006, Digium, Inc.
|
2002-05-30 01:40:29 +00:00
|
|
|
*
|
2005-07-19 23:17:02 +00:00
|
|
|
* Mark Spencer <markster@digium.com>
|
2002-05-30 01:40:29 +00:00
|
|
|
*
|
2005-08-30 18:32:10 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
|
* channels for your use.
|
|
|
|
|
*
|
2002-05-30 01:40:29 +00:00
|
|
|
* This program is free software, distributed under the terms of
|
2005-08-30 18:32:10 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
|
* at the top of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
|
|
|
|
* \brief Access Control of various sorts
|
2002-05-30 01:40:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef _ASTERISK_ACL_H
|
|
|
|
|
#define _ASTERISK_ACL_H
|
|
|
|
|
|
2004-05-27 20:53:02 +00:00
|
|
|
|
2002-05-30 01:40:29 +00:00
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/io.h"
|
2005-01-11 17:08:52 +00:00
|
|
|
|
|
|
|
|
#define AST_SENSE_DENY 0
|
|
|
|
|
#define AST_SENSE_ALLOW 1
|
2002-05-30 01:40:29 +00:00
|
|
|
|
|
|
|
|
/* Host based access control */
|
|
|
|
|
|
2007-07-20 14:38:36 +00:00
|
|
|
/*! \brief internal representation of acl entries
|
|
|
|
|
* In principle user applications would have no need for this,
|
|
|
|
|
* but there is sometimes a need to extract individual items,
|
|
|
|
|
* e.g. to print them, and rather than defining iterators to
|
|
|
|
|
* navigate the list, and an externally visible 'struct ast_ha_entry',
|
|
|
|
|
* at least in the short term it is more convenient to make the whole
|
|
|
|
|
* thing public and let users play with them.
|
|
|
|
|
*/
|
|
|
|
|
struct ast_ha {
|
|
|
|
|
/* Host access rule */
|
|
|
|
|
struct in_addr netaddr;
|
|
|
|
|
struct in_addr netmask;
|
|
|
|
|
int sense;
|
|
|
|
|
struct ast_ha *next;
|
|
|
|
|
};
|
2002-05-30 01:40:29 +00:00
|
|
|
|
2007-01-01 19:20:46 +00:00
|
|
|
/*! \brief Free host access list */
|
2006-03-28 03:28:52 +00:00
|
|
|
void ast_free_ha(struct ast_ha *ha);
|
2007-01-01 19:20:46 +00:00
|
|
|
|
|
|
|
|
/*! \brief Append ACL entry to host access list. */
|
2007-11-14 13:18:40 +00:00
|
|
|
struct ast_ha *ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error);
|
2007-01-01 19:20:46 +00:00
|
|
|
|
|
|
|
|
/*! \brief Check IP address with host access list */
|
2006-03-28 03:28:52 +00:00
|
|
|
int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin);
|
2007-01-01 19:20:46 +00:00
|
|
|
|
|
|
|
|
/*! \brief Copy host access list */
|
|
|
|
|
struct ast_ha *ast_duplicate_ha_list(struct ast_ha *original);
|
|
|
|
|
|
2006-03-28 03:28:52 +00:00
|
|
|
int ast_get_ip(struct sockaddr_in *sin, const char *value);
|
2007-01-01 19:20:46 +00:00
|
|
|
|
2006-03-28 03:28:52 +00:00
|
|
|
int ast_get_ip_or_srv(struct sockaddr_in *sin, const char *value, const char *service);
|
2007-01-01 19:20:46 +00:00
|
|
|
|
2006-03-28 03:28:52 +00:00
|
|
|
int ast_ouraddrfor(struct in_addr *them, struct in_addr *us);
|
2007-01-01 19:20:46 +00:00
|
|
|
|
2006-03-28 03:28:52 +00:00
|
|
|
int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr);
|
2007-04-30 16:16:26 +00:00
|
|
|
|
|
|
|
|
int ast_str2cos(const char *value, unsigned int *cos);
|
|
|
|
|
|
2006-03-28 03:28:52 +00:00
|
|
|
int ast_str2tos(const char *value, unsigned int *tos);
|
|
|
|
|
const char *ast_tos2str(unsigned int tos);
|
2002-05-30 01:40:29 +00:00
|
|
|
|
|
|
|
|
#if defined(__cplusplus) || defined(c_plusplus)
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-08-30 18:32:10 +00:00
|
|
|
#endif /* _ASTERISK_ACL_H */
|