Phone provisioning application for the asterisk internal http server. More...
#include "asterisk.h"
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include "asterisk/channel.h"
#include "asterisk/file.h"
#include "asterisk/paths.h"
#include "asterisk/pbx.h"
#include "asterisk/cli.h"
#include "asterisk/module.h"
#include "asterisk/http.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/strings.h"
#include "asterisk/stringfields.h"
#include "asterisk/options.h"
#include "asterisk/config.h"
#include "asterisk/acl.h"
#include "asterisk/astobj2.h"
#include "asterisk/ast_version.h"
Go to the source code of this file.
Data Structures | |
struct | extension |
struct | http_route |
structure to hold http routes (valid URIs, and the files they link to) More... | |
struct | phone_profile |
structure to hold phone profiles read from phoneprov.conf More... | |
struct | phoneprov_file |
structure to hold file data More... | |
struct | pp_variable_lookup |
Lookup table to translate between users.conf property names and variables for use in phoneprov templates. More... | |
struct | user |
structure to hold users read from users.conf More... | |
Macros | |
#define | FORMAT "%-40.40s %-30.30s\n" |
#define | MAX_PROFILE_BUCKETS 17 |
#define | MAX_ROUTE_BUCKETS 563 |
#define | MAX_USER_BUCKETS 563 |
#define | VAR_BUF_SIZE 4096 |
Enumerations | |
enum | pp_variables { PP_MACADDRESS, PP_USERNAME, PP_FULLNAME, PP_SECRET, PP_LABEL, PP_CALLERID, PP_TIMEZONE, PP_LINENUMBER, PP_LINEKEYS, PP_VAR_LIST_LENGTH } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | add_user_extension (struct user *user, struct extension *exten) |
Add an extension to a user ordered by index/linenumber. More... | |
static struct extension * | build_extension (struct ast_config *cfg, const char *name) |
static void | build_profile (const char *name, struct ast_variable *v) |
Build a phone profile and add it to the list of phone profiles. More... | |
static void | build_route (struct phoneprov_file *pp_file, struct user *user, char *uri) |
Build a route structure and add it to the list of available http routes. More... | |
static struct user * | build_user (const char *mac, struct phone_profile *profile) |
Build and return a user structure based on gathered config data. More... | |
static int | build_user_routes (struct user *user) |
Add an http route for dynamic files attached to the profile of the user. More... | |
static struct extension * | delete_extension (struct extension *exten) |
static void | delete_file (struct phoneprov_file *file) |
static void | delete_profiles (void) |
Delete all phone profiles, freeing their memory. More... | |
static void | delete_routes (void) |
Delete all http routes, freeing their memory. More... | |
static void | delete_users (void) |
Delete all users. More... | |
static struct phone_profile * | find_profile (const char *name) |
Return a phone profile looked up by name. More... | |
static struct user * | find_user (const char *macaddress) |
Return a user looked up by name. More... | |
static char * | handle_show_routes (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
CLI command to list static and dynamic routes. More... | |
static int | load_file (const char *filename, char **ret) |
Read a TEXT file into a string and return the length. More... | |
static int | load_module (void) |
static int | lookup_iface (const char *iface, struct in_addr *address) |
static int | phoneprov_callback (struct ast_tcptls_session_instance *ser, const struct ast_http_uri *urih, const char *uri, enum ast_http_method method, struct ast_variable *get_vars, struct ast_variable *headers) |
Callback that is executed everytime an http request is received by this module. More... | |
static int | pp_each_extension_helper (struct ast_channel *chan, const char *cmd, char *data, char *buf, struct ast_str **bufstr, int len) |
A dialplan function that can be used to output a template for each extension attached to a user. More... | |
static int | pp_each_extension_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
static int | pp_each_extension_read2 (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len) |
static int | pp_each_user_helper (struct ast_channel *chan, char *data, char *buf, struct ast_str **bufstr, int len) |
A dialplan function that can be used to print a string for each phoneprov user. More... | |
static int | pp_each_user_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
static int | pp_each_user_read2 (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len) |
static int | profile_cmp_fn (void *obj, void *arg, int flags) |
static void | profile_destructor (void *obj) |
static int | profile_hash_fn (const void *obj, const int flags) |
static int | reload (void) |
static void | route_destructor (void *obj) |
static int | routes_cmp_fn (void *obj, void *arg, int flags) |
static int | routes_hash_fn (const void *obj, const int flags) |
static int | set_config (void) |
static void | set_timezone_variables (struct varshead *headp, const char *zone) |
Set all timezone-related variables based on a zone (i.e. America/New_York) More... | |
static int | unload_module (void) |
static struct phone_profile * | unref_profile (struct phone_profile *prof) |
static struct http_route * | unref_route (struct http_route *route) |
static struct user * | unref_user (struct user *user) |
static void | user_destructor (void *obj) |
Free all memory associated with a user. More... | |
static int | users_cmp_fn (void *obj, void *arg, int flags) |
static int | users_hash_fn (const void *obj, const int flags) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "HTTP Phone Provisioning" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .reload = reload, } |
static struct in_addr | __ourip = { .s_addr = 0x00000000, } |
for use in lookup_iface More... | |
static struct ast_module_info * | ast_module_info = &__mod_info |
static char | global_default_profile [80] = "" |
static char | global_server [80] = "" |
static char | global_serverport [6] = "" |
static struct varshead | global_variables |
List of global variables currently available: VOICEMAIL_EXTEN struct ast_string_field_mgr __field_mgr struct ast_string_field_mgr __field_mgr EXTENSION_LENGTH. More... | |
static ast_mutex_t | globals_lock |
static struct ao2_container * | http_routes |
static struct ast_http_uri | phoneprovuri |
static struct ast_cli_entry | pp_cli [] |
static struct ast_custom_function | pp_each_extension_function |
static struct ast_custom_function | pp_each_user_function |
static struct pp_variable_lookup | pp_variable_list [] |
static struct ao2_container * | profiles |
static struct ao2_container * | users |
Phone provisioning application for the asterisk internal http server.
Definition in file res_phoneprov.c.
#define FORMAT "%-40.40s %-30.30s\n" |
#define MAX_PROFILE_BUCKETS 17 |
Definition at line 65 of file res_phoneprov.c.
#define MAX_ROUTE_BUCKETS 563 |
Definition at line 66 of file res_phoneprov.c.
#define MAX_USER_BUCKETS 563 |
Definition at line 67 of file res_phoneprov.c.
#define VAR_BUF_SIZE 4096 |
Definition at line 70 of file res_phoneprov.c.
enum pp_variables |
Enumerator | |
---|---|
PP_MACADDRESS | |
PP_USERNAME | |
PP_FULLNAME | |
PP_SECRET | |
PP_LABEL | |
PP_CALLERID | |
PP_TIMEZONE | |
PP_LINENUMBER | |
PP_LINEKEYS | |
PP_VAR_LIST_LENGTH |
Definition at line 108 of file res_phoneprov.c.
|
static |
Definition at line 1338 of file res_phoneprov.c.
|
static |
Definition at line 1338 of file res_phoneprov.c.
Add an extension to a user ordered by index/linenumber.
Definition at line 837 of file res_phoneprov.c.
|
static |
Definition at line 692 of file res_phoneprov.c.
|
static |
Build a phone profile and add it to the list of phone profiles.
name | the name of the profile |
v | ast_variable from parsing phoneprov.conf |
Definition at line 570 of file res_phoneprov.c.
|
static |
Build a route structure and add it to the list of available http routes.
pp_file | File to link to the route |
user | User to link to the route (NULL means static route) |
uri | URI of the route |
Definition at line 543 of file res_phoneprov.c.
References ao2_alloc, ao2_link, ast_log(), ast_string_field_init, ast_string_field_set, http_route::file, phoneprov_file::format, LOG_ERROR, route_destructor(), S_OR, unref_route(), user, and http_route::user.
|
static |
Build and return a user structure based on gathered config data.
Definition at line 815 of file res_phoneprov.c.
|
static |
Add an http route for dynamic files attached to the profile of the user.
Definition at line 881 of file res_phoneprov.c.
Definition at line 678 of file res_phoneprov.c.
|
static |
Definition at line 257 of file res_phoneprov.c.
References CMP_MATCH, CMP_STOP, and phone_profile::name.
|
static |
Delete all phone profiles, freeing their memory.
Definition at line 1062 of file res_phoneprov.c.
|
static |
Delete all http routes, freeing their memory.
Definition at line 1048 of file res_phoneprov.c.
|
static |
Delete all users.
Definition at line 801 of file res_phoneprov.c.
|
static |
|
static |
|
static |
CLI command to list static and dynamic routes.
Definition at line 1211 of file res_phoneprov.c.
|
static |
Read a TEXT file into a string and return the length.
Definition at line 311 of file res_phoneprov.c.
|
static |
Definition at line 1267 of file res_phoneprov.c.
|
static |
Definition at line 196 of file res_phoneprov.c.
|
static |
Callback that is executed everytime an http request is received by this module.
Definition at line 401 of file res_phoneprov.c.
|
static |
A dialplan function that can be used to output a template for each extension attached to a user.
Definition at line 1133 of file res_phoneprov.c.
Referenced by pp_each_extension_read2().
|
static |
Definition at line 1194 of file res_phoneprov.c.
|
static |
Definition at line 1199 of file res_phoneprov.c.
References pp_each_extension_helper().
|
static |
A dialplan function that can be used to print a string for each phoneprov user.
Definition at line 1076 of file res_phoneprov.c.
Referenced by pp_each_user_read2().
|
static |
Definition at line 1116 of file res_phoneprov.c.
|
static |
Definition at line 1121 of file res_phoneprov.c.
References pp_each_user_helper().
|
static |
Definition at line 250 of file res_phoneprov.c.
References ast_str_case_hash(), and phone_profile::name.
|
static |
Definition at line 263 of file res_phoneprov.c.
References ast_string_field_free_memory, and free.
|
static |
Definition at line 243 of file res_phoneprov.c.
|
static |
Definition at line 1315 of file res_phoneprov.c.
|
static |
Definition at line 303 of file res_phoneprov.c.
References CMP_MATCH, CMP_STOP, and http_route::uri.
Referenced by build_route().
|
static |
Definition at line 296 of file res_phoneprov.c.
References ast_str_case_hash(), and http_route::uri.
|
static |
|
static |
Definition at line 900 of file res_phoneprov.c.
|
static |
Set all timezone-related variables based on a zone (i.e. America/New_York)
headp | pointer to list of user variables |
zone | A time zone. NULL sets variables based on timezone of the machine |
Definition at line 344 of file res_phoneprov.c.
|
static |
Definition at line 1288 of file res_phoneprov.c.
|
static |
Definition at line 226 of file res_phoneprov.c.
|
static |
Definition at line 752 of file res_phoneprov.c.
|
static |
Free all memory associated with a user.
Definition at line 784 of file res_phoneprov.c.
|
static |
Definition at line 776 of file res_phoneprov.c.
References ast_str_case_hash(), and user::macaddress.
|
static |
Definition at line 769 of file res_phoneprov.c.
|
static |
Definition at line 1338 of file res_phoneprov.c.
|
static |
for use in lookup_iface
Definition at line 104 of file res_phoneprov.c.
|
static |
Definition at line 1338 of file res_phoneprov.c.
|
static |
Default profile to use if one isn't specified
Definition at line 189 of file res_phoneprov.c.
|
static |
Server to substitute into templates
Definition at line 187 of file res_phoneprov.c.
|
static |
Server port to substitute into templates
Definition at line 188 of file res_phoneprov.c.
|
static |
List of global variables currently available: VOICEMAIL_EXTEN struct ast_string_field_mgr __field_mgr struct ast_string_field_mgr __field_mgr EXTENSION_LENGTH.
Definition at line 192 of file res_phoneprov.c.
|
static |
Definition at line 193 of file res_phoneprov.c.
|
static |
Definition at line 184 of file res_phoneprov.c.
|
static |
Definition at line 1258 of file res_phoneprov.c.
|
static |
Definition at line 1254 of file res_phoneprov.c.
|
static |
Definition at line 1204 of file res_phoneprov.c.
|
static |
Definition at line 1126 of file res_phoneprov.c.
|
static |
|
static |
Definition at line 183 of file res_phoneprov.c.
|
static |
Definition at line 185 of file res_phoneprov.c.