func_blacklist.c File Reference

Function to lookup the callerid number, and see if it is blacklisted. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/astdb.h"

Include dependency graph for func_blacklist.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
static void __unreg_module (void)
static int blacklist_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
static int blacklist_read2 (struct ast_channel *chan, const char *cmd, char *data, struct ast_str **str, ssize_t len)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Look up Caller*ID name/number from blacklist database" , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static struct ast_module_infoast_module_info = &__mod_info
static struct ast_custom_function blacklist_function


Detailed Description

Function to lookup the callerid number, and see if it is blacklisted.

Author:
Mark Spencer <markster@digium.com>

Definition in file func_blacklist.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 114 of file func_blacklist.c.

static void __unreg_module ( void   )  [static]

Definition at line 114 of file func_blacklist.c.

static int blacklist_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
) [static]

Definition at line 59 of file func_blacklist.c.

References ast_channel_caller(), ast_db_get(), ast_log, LOG_WARNING, and name.

Referenced by blacklist_read2().

00060 {
00061    char blacklist[1];
00062    int bl = 0;
00063 
00064    if (!chan) {
00065       ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
00066       return -1;
00067    }
00068 
00069    if (ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str) {
00070       if (!ast_db_get("blacklist", ast_channel_caller(chan)->id.number.str, blacklist, sizeof (blacklist)))
00071          bl = 1;
00072    }
00073    if (ast_channel_caller(chan)->id.name.valid && ast_channel_caller(chan)->id.name.str) {
00074       if (!ast_db_get("blacklist", ast_channel_caller(chan)->id.name.str, blacklist, sizeof (blacklist)))
00075          bl = 1;
00076    }
00077 
00078    snprintf(buf, len, "%d", bl);
00079    return 0;
00080 }

static int blacklist_read2 ( struct ast_channel chan,
const char *  cmd,
char *  data,
struct ast_str **  str,
ssize_t  len 
) [static]

Definition at line 82 of file func_blacklist.c.

References ast_str_buffer(), ast_str_make_space(), ast_str_size(), ast_str_strlen(), ast_str_update(), and blacklist_read().

00083 {
00084    /* 2 bytes is a single integer, plus terminating null */
00085    if (ast_str_size(*str) - ast_str_strlen(*str) < 2) {
00086       if (len > ast_str_size(*str) || len == 0) {
00087          ast_str_make_space(str, len ? len : ast_str_strlen(*str) + 2);
00088       }
00089    }
00090    if (ast_str_size(*str) - ast_str_strlen(*str) >= 2) {
00091       int res = blacklist_read(chan, cmd, data, ast_str_buffer(*str) + ast_str_strlen(*str), 2);
00092       ast_str_update(*str);
00093       return res;
00094    }
00095    return -1;
00096 }

static int load_module ( void   )  [static]

Definition at line 109 of file func_blacklist.c.

References ast_custom_function_register.

00110 {
00111    return ast_custom_function_register(&blacklist_function);
00112 }

static int unload_module ( void   )  [static]

Definition at line 104 of file func_blacklist.c.

References ast_custom_function_unregister().

00105 {
00106    return ast_custom_function_unregister(&blacklist_function);
00107 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Look up Caller*ID name/number from blacklist database" , .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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, } [static]

Definition at line 114 of file func_blacklist.c.

Definition at line 114 of file func_blacklist.c.

Initial value:

 {
   .name = "BLACKLIST",
   .read = blacklist_read,
   .read2 = blacklist_read2,
}

Definition at line 98 of file func_blacklist.c.


Generated on Thu Apr 16 06:31:11 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6