Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions
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

◆ iax_firmware_append()

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

Definition at line 283 of file firmware.c.

284{
285 int res = -1;
286 unsigned int bs = desc & 0xff;
287 unsigned int start = (desc >> 8) & 0xffffff;
288 unsigned int bytes;
289 struct iax_firmware *cur;
290
291 if (ast_strlen_zero((char *)dev) || !bs)
292 return -1;
293
294 start *= bs;
295
298 if (strcmp(dev, (const char *) cur->fwh->devname))
299 continue;
301 if (start < ntohl(cur->fwh->datalen)) {
302 bytes = ntohl(cur->fwh->datalen) - start;
303 if (bytes > bs)
304 bytes = bs;
305 iax_ie_append_raw(ied, IAX_IE_FWBLOCKDATA, cur->fwh->data + start, bytes);
306 } else {
307 bytes = 0;
309 }
310 if (bytes == bs)
311 res = 0;
312 else
313 res = 1;
314 break;
315 }
317
318 return res;
319}
static const char desc[]
Definition: cdr_radius.c:84
char * bs
Definition: eagi_proxy.c:73
#define IAX_IE_FWBLOCKDATA
Definition: iax2.h:166
#define IAX_IE_FWBLOCKDESC
Definition: iax2.h:165
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#define AST_LIST_LOCK(head)
Locks a list.
Definition: linkedlists.h:40
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
Definition: linkedlists.h:140
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie)
Definition: parser.c:780
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
Definition: parser.c:726
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
Definition: parser.c:756
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
unsigned char devname[16]
Definition: iax2.h:298
unsigned int datalen
Definition: iax2.h:299
unsigned char data[0]
Definition: iax2.h:301
struct ast_iax2_firmware_header * fwh
Definition: firmware.c:54
struct iax_firmware::@138 list

References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), bs, ast_iax2_firmware_header::data, ast_iax2_firmware_header::datalen, desc, 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().

◆ iax_firmware_get_version()

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

Definition at line 263 of file firmware.c.

264{
265 struct iax_firmware *cur = NULL;
266
267 if (ast_strlen_zero(dev))
268 return 0;
269
272 if (!strcmp(dev, (const char *) cur->fwh->devname)) {
273 *version = ntohs(cur->fwh->version);
275 return 1;
276 }
277 }
279
280 return 0;
281}
static char version[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:391
#define NULL
Definition: resample.c:96
unsigned short version
Definition: iax2.h:297

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, version, and ast_iax2_firmware_header::version.

Referenced by update_registry().

◆ iax_firmware_reload()

void iax_firmware_reload ( void  )

Definition at line 206 of file firmware.c.

207{
208 struct iax_firmware *cur = NULL;
209 DIR *fwd;
210 struct dirent *de;
211 char fn[PATH_MAX + sizeof(IAX_FIRMWARE_SUBDIR) + sizeof(de->d_name)];
212
214
215 /* Mark all as dead */
216 AST_LIST_TRAVERSE(&firmwares, cur, list) {
217 cur->dead = 1;
218 }
219
220 /* Now that we have marked them dead... load new ones */
221 snprintf(fn, sizeof(fn), "%s%s", ast_config_AST_DATA_DIR, IAX_FIRMWARE_SUBDIR);
222 fwd = opendir(fn);
223 if (fwd) {
224 while((de = readdir(fwd))) {
225 if (de->d_name[0] != '.') {
226 snprintf(fn, sizeof(fn), "%s%s/%s",
228 if (!try_firmware(fn)) {
229 ast_verb(2, "Loaded firmware '%s'\n", de->d_name);
230 }
231 }
232 }
233 closedir(fwd);
234 } else {
235 ast_log(LOG_WARNING, "Error opening firmware directory '%s': %s\n", fn, strerror(errno));
236 }
237
238 /* Clean up leftovers */
240 if (!cur->dead)
241 continue;
243 destroy_firmware(cur);
244 }
246
248}
#define PATH_MAX
Definition: asterisk.h:40
#define ast_log
Definition: astobj2.c:42
static int try_firmware(char *s)
Definition: firmware.c:60
#define IAX_FIRMWARE_SUBDIR
Definition: firmware.c:47
static void destroy_firmware(struct iax_firmware *cur)
Definition: firmware.c:196
#define ast_verb(level,...)
#define LOG_WARNING
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:529
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
int errno
const char * ast_config_AST_DATA_DIR
Definition: options.c:158

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_SUBDIR, LOG_WARNING, NULL, PATH_MAX, and try_firmware().

Referenced by load_module(), and reload_config().

◆ iax_firmware_traverse()

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

◆ iax_firmware_unload()

void iax_firmware_unload ( void  )