32 #include <sys/types.h> 38 #include <arpa/inet.h> 47 #define IAX_FIRMWARE_SUBDIR "/firmware/iax" 64 int ifd,
fd, res,
len, chunk;
67 unsigned char sum[16],
buf[1024];
72 last = strrchr(s,
'/');
78 snprintf(s2, strlen(s) + 100,
"/var/tmp/%s-%ld", last,
ast_random());
80 if (stat(s, &stbuf) < 0) {
86 if (S_ISDIR(stbuf.st_mode))
88 ifd = open(s, O_RDONLY);
106 if (chunk >
sizeof(buf))
108 res = read(ifd, buf, chunk);
115 res = write(fd, buf, chunk);
126 lseek(fd, 0, SEEK_SET);
127 if ((res = read(fd, &fwh2,
sizeof(fwh2))) !=
sizeof(fwh2)) {
137 if (ntohl(fwh2.
datalen) != (stbuf.st_size -
sizeof(fwh2))) {
148 if (fwh == MAP_FAILED) {
156 if (memcmp(sum, fwh->
chksum,
sizeof(sum))) {
158 munmap((
void*)fwh, stbuf.st_size);
171 munmap((
void*)fwh, stbuf.st_size);
177 if (!cur && ((cur =
ast_calloc(1,
sizeof(*cur))))) {
224 while((de = readdir(fwd))) {
225 if (de->d_name[0] !=
'.') {
226 snprintf(fn,
sizeof(fn),
"%s%s/%s",
229 ast_verb(2,
"Loaded firmware '%s'\n", de->d_name);
272 if (!strcmp(dev, (
const char *) cur->
fwh->
devname)) {
286 unsigned int bs = desc & 0xff;
287 unsigned int start = (desc >> 8) & 0xffffff;
298 if (strcmp(dev, (
const char *) cur->
fwh->
devname))
334 if (!filter || !strcasecmp(filter, (
const char *) cur->
fwh->
devname)) {
335 if (callback(cur->
fwh, data)) {
void iax_firmware_reload(void)
int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value)
#define AST_LIST_LOCK(head)
Locks a list.
Asterisk main include file. File version handling, generic pbx functions.
int iax_firmware_get_version(const char *dev, uint16_t *version)
#define AST_LIST_UNLOCK(head)
Attempts to unlock a list.
void MD5Final(unsigned char digest[16], struct MD5Context *context)
static int try_firmware(char *s)
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
#define ast_verb(level,...)
void MD5Init(struct MD5Context *context)
int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen)
#define ast_strlen_zero(foo)
Asterisk file paths, configured in asterisk.conf.
struct sla_ringing_trunk * last
IAX Firmware Support header file.
#define IAX_FIRMWARE_MAGIC
int iax_ie_append(struct iax_ie_data *ied, unsigned char ie)
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
long int ast_random(void)
A set of macros to manage forward-linked lists.
static void destroy_firmware(struct iax_firmware *cur)
#define AST_LIST_HEAD_STATIC(name, type)
Defines a structure to be used to hold a list of specified type, statically initialized.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
const char * ast_config_AST_DATA_DIR
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len)
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
void iax_firmware_unload(void)
struct iax_firmware::@155 list
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define IAX_IE_FWBLOCKDESC
static char version[AST_MAX_EXTENSION]
#define ast_calloc(num, len)
A wrapper for calloc()
int iax_firmware_append(struct iax_ie_data *ied, const char *dev, unsigned int desc)
void iax_firmware_traverse(const char *filter, int(*callback)(struct ast_iax2_firmware_header *header, void *data), void *data)
#define IAX_IE_FWBLOCKDATA
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
static int filter(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
struct ast_iax2_firmware_header * fwh
#define IAX_FIRMWARE_SUBDIR