firmware.h File Reference

IAX Firmware Support header file. More...

#include "parser.h"

Include dependency graph for firmware.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int iax_firmware_append (struct iax_ie_data *ie_data, const char *device_name, unsigned int block_desc)
int iax_firmware_get_version (const char *device_name, uint16_t *version)
void iax_firmware_reload (void)
void iax_firmware_traverse (const char *prefix, int(*callback)(struct ast_iax2_firmware_header *header, void *user_data), void *user_data)
void iax_firmware_unload (void)


Detailed Description

IAX Firmware Support header file.

Definition in file firmware.h.


Function Documentation

int iax_firmware_append ( struct iax_ie_data ie_data,
const char *  device_name,
unsigned int  block_desc 
)

Definition at line 282 of file firmware.c.

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero, bs, ast_iax2_firmware_header::data, ast_iax2_firmware_header::datalen, ast_iax2_firmware_header::devname, iax_firmware::fwh, iax_ie_append(), iax_ie_append_int(), iax_ie_append_raw(), IAX_IE_FWBLOCKDATA, IAX_IE_FWBLOCKDESC, and iax_firmware::list.

Referenced by socket_process_helper().

00283 {
00284    int res = -1;
00285    unsigned int bs = desc & 0xff;
00286    unsigned int start = (desc >> 8) & 0xffffff;
00287    unsigned int bytes;
00288    struct iax_firmware *cur;
00289 
00290    if (ast_strlen_zero((char *)dev) || !bs)
00291       return -1;
00292 
00293    start *= bs;
00294 
00295    AST_LIST_LOCK(&firmwares);
00296    AST_LIST_TRAVERSE(&firmwares, cur, list) {
00297       if (strcmp(dev, (const char *) cur->fwh->devname))
00298          continue;
00299       iax_ie_append_int(ied, IAX_IE_FWBLOCKDESC, desc);
00300       if (start < ntohl(cur->fwh->datalen)) {
00301          bytes = ntohl(cur->fwh->datalen) - start;
00302          if (bytes > bs)
00303             bytes = bs;
00304          iax_ie_append_raw(ied, IAX_IE_FWBLOCKDATA, cur->fwh->data + start, bytes);
00305       } else {
00306          bytes = 0;
00307          iax_ie_append(ied, IAX_IE_FWBLOCKDATA);
00308       }
00309       if (bytes == bs)
00310          res = 0;
00311       else
00312          res = 1;
00313       break;
00314    }
00315    AST_LIST_UNLOCK(&firmwares);
00316 
00317    return res;
00318 }

int iax_firmware_get_version ( const char *  device_name,
uint16_t *  version 
)

Definition at line 262 of file firmware.c.

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero, ast_iax2_firmware_header::devname, iax_firmware::fwh, iax_firmware::list, NULL, and ast_iax2_firmware_header::version.

Referenced by update_registry().

00263 {
00264    struct iax_firmware *cur = NULL;
00265 
00266    if (ast_strlen_zero(dev))
00267       return 0;
00268 
00269    AST_LIST_LOCK(&firmwares);
00270    AST_LIST_TRAVERSE(&firmwares, cur, list) {
00271       if (!strcmp(dev, (const char *) cur->fwh->devname)) {
00272          *version = ntohs(cur->fwh->version);
00273          AST_LIST_UNLOCK(&firmwares);
00274          return 1;
00275       }
00276    }
00277    AST_LIST_UNLOCK(&firmwares);
00278 
00279    return 0;
00280 }

void iax_firmware_reload ( void   ) 

Definition at line 206 of file firmware.c.

References ast_config_AST_DATA_DIR, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log, ast_verb, iax_firmware::dead, destroy_firmware(), errno, iax_firmware::list, LOG_WARNING, NULL, and try_firmware().

Referenced by load_module().

00207 {
00208    struct iax_firmware *cur = NULL;
00209    DIR *fwd;
00210    struct dirent *de;
00211    char dir[256], fn[256];
00212 
00213    AST_LIST_LOCK(&firmwares);
00214 
00215    /* Mark all as dead */
00216    AST_LIST_TRAVERSE(&firmwares, cur, list) {
00217       cur->dead = 1;
00218    }
00219 
00220    /* Now that we have marked them dead... load new ones */
00221    snprintf(dir, sizeof(dir), "%s/firmware/iax", ast_config_AST_DATA_DIR);
00222    fwd = opendir(dir);
00223    if (fwd) {
00224       while((de = readdir(fwd))) {
00225          if (de->d_name[0] != '.') {
00226             snprintf(fn, sizeof(fn), "%s/%s", dir, de->d_name);
00227             if (!try_firmware(fn)) {
00228                ast_verb(2, "Loaded firmware '%s'\n", de->d_name);
00229             }
00230          }
00231       }
00232       closedir(fwd);
00233    } else {
00234       ast_log(LOG_WARNING, "Error opening firmware directory '%s': %s\n", dir, strerror(errno));
00235    }
00236 
00237    /* Clean up leftovers */
00238    AST_LIST_TRAVERSE_SAFE_BEGIN(&firmwares, cur, list) {
00239       if (!cur->dead)
00240          continue;
00241       AST_LIST_REMOVE_CURRENT(list);
00242       destroy_firmware(cur);
00243    }
00244    AST_LIST_TRAVERSE_SAFE_END;
00245 
00246    AST_LIST_UNLOCK(&firmwares);
00247 }

void iax_firmware_traverse ( const char *  prefix,
int(*)(struct ast_iax2_firmware_header *header, void *user_data)  callback,
void *  user_data 
)

void iax_firmware_unload ( void   ) 


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