110 } frametype2str[] = {
129 } controlframetype2str[] = {
154 enum direction list_type;
155 int values[ARRAY_LEN(frametype2str)];
156 int controlvalues[ARRAY_LEN(controlframetype2str)];
159 static void datastore_destroy_cb(
void *data) {
165 .destroy = datastore_destroy_cb
168 static void hook_destroy_cb(
void *framedata)
188 for (i = 0; i < ARRAY_LEN(controlframetype2str); i++) {
190 if (framedata->controlvalues[i]) {
197 for (i = 0; i < ARRAY_LEN(frametype2str); i++) {
198 if (frame->
frametype == frametype2str[i].type) {
199 if (framedata->values[i]) {
214 static int frame_drop_helper(
struct ast_channel *chan,
const char *cmd,
char *data,
const char *value)
220 .
version = AST_FRAMEHOOK_INTERFACE_VERSION,
221 .event_cb = hook_event_cb,
222 .destroy_cb = hook_destroy_cb,
226 if (!(framedata =
ast_calloc(1,
sizeof(*framedata)))) {
230 interface.
data = framedata;
232 if (!strcasecmp(data,
"RX")) {
233 framedata->list_type = RX;
235 framedata->list_type = TX;
239 snprintf(buffer,
sizeof(value) + 2,
",%s,", value);
240 for (i = 0; i < ARRAY_LEN(frametype2str); i++) {
241 if (strcasestr(buffer, frametype2str[i].str)) {
242 framedata->values[i] = 1;
246 for (i = 0; i < ARRAY_LEN(controlframetype2str); i++) {
247 if (strcasestr(buffer, controlframetype2str[i].str)) {
248 framedata->controlvalues[i] = 1;
253 ast_channel_lock(chan);
258 id = datastore->
data;
264 if (!(datastore = ast_datastore_alloc(&frame_drop_datastore, NULL))) {
266 ast_channel_unlock(chan);
273 ast_channel_unlock(chan);
278 datastore->
data = id;
281 ast_channel_unlock(chan);
287 .
name =
"FRAME_DROP",
288 .write = frame_drop_helper,
291 static int unload_module(
void)
296 static int load_module(
void)
302 AST_MODULE_INFO_STANDARD_EXTENDED(
ASTERISK_GPL_KEY,
"Function to drop frames on a channel.");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
ast_framehook_event
These are the types of events that the framehook's event callback can receive.
int ast_framehook_detach(struct ast_channel *chan, int framehook_id)
Detach an framehook from a channel.
Structure for a data store type.
Structure for a data store object.
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
struct ast_frame_subclass subclass
int ast_framehook_attach(struct ast_channel *chan, struct ast_framehook_interface *i)
Attach an framehook onto a channel for frame interception.
General Asterisk PBX channel definitions.
Data structure associated with a custom dialplan function.
#define ast_malloc(len)
A wrapper for malloc()
Core PBX routines and definitions.
ast_frame_type
Frame types.
union ast_frame::@224 data
#define ast_calloc(num, len)
A wrapper for calloc()
Module has failed to load, may be in an inconsistent state.
struct ast_frame ast_null_frame
Data structure associated with a single frame of data.
enum ast_frame_type frametype
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
#define ast_custom_function_register(acf)
Register a custom function.