Implementation of Inter-Asterisk eXchange Protocol, v 2. More...
#include "asterisk.h"
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "asterisk/frame.h"
#include "asterisk/utils.h"
#include "asterisk/unaligned.h"
#include "asterisk/config.h"
#include "asterisk/lock.h"
#include "asterisk/threadstorage.h"
#include "iax2.h"
#include "iax2-parser.h"
#include "iax2-provision.h"
Go to the source code of this file.
Data Structures | |
struct | iax2_ie |
struct | iax_frame_list |
This is just so iax_frames, a list head struct for holding a list of iax_frame structures, is defined. More... | |
struct | iax_frames |
Defines | |
#define | FRAME_CACHE_MAX_SIZE 20 |
Functions | |
AST_THREADSTORAGE_CUSTOM_SCOPE (frame_cache, NULL, frame_cache_cleanup, static) | |
A per-thread cache of iax_frame structures. | |
static void | dump_addr (char *output, int maxlen, void *value, int len) |
static void | dump_byte (char *output, int maxlen, void *value, int len) |
static void | dump_datetime (char *output, int maxlen, void *value, int len) |
static void | dump_ies (unsigned char *iedata, int len) |
static void | dump_int (char *output, int maxlen, void *value, int len) |
static void | dump_ipaddr (char *output, int maxlen, void *value, int len) |
static void | dump_prefs (char *output, int maxlen, void *value, int len) |
static void | dump_prov (char *output, int maxlen, void *value, int len) |
static void | dump_prov_flags (char *output, int maxlen, void *value, int len) |
static void | dump_prov_ies (char *output, int maxlen, unsigned char *iedata, int len) |
static void | dump_samprate (char *output, int maxlen, void *value, int len) |
static void | dump_short (char *output, int maxlen, void *value, int len) |
static void | dump_string (char *output, int maxlen, void *value, int len) |
static void | dump_string_hex (char *output, int maxlen, void *value, int len) |
static void | frame_cache_cleanup (void *data) |
void | iax_frame_free (struct iax_frame *fr) |
struct iax_frame * | iax_frame_new (int direction, int datalen, unsigned int cacheable) |
void | iax_frame_subclass2str (enum iax_frame_subclass subclass, char *str, size_t len) |
void | iax_frame_wrap (struct iax_frame *fr, struct ast_frame *f) |
int | iax_get_frames (void) |
int | iax_get_iframes (void) |
int | iax_get_oframes (void) |
const char * | iax_ie2str (int ie) |
int | iax_ie_append (struct iax_ie_data *ied, unsigned char ie) |
int | iax_ie_append_addr (struct iax_ie_data *ied, unsigned char ie, const struct sockaddr_in *sin) |
int | iax_ie_append_byte (struct iax_ie_data *ied, unsigned char ie, unsigned char dat) |
int | iax_ie_append_int (struct iax_ie_data *ied, unsigned char ie, unsigned int value) |
int | iax_ie_append_raw (struct iax_ie_data *ied, unsigned char ie, const void *data, int datalen) |
int | iax_ie_append_short (struct iax_ie_data *ied, unsigned char ie, unsigned short value) |
int | iax_ie_append_str (struct iax_ie_data *ied, unsigned char ie, const char *str) |
int | iax_parse_ies (struct iax_ies *ies, unsigned char *data, int datalen) |
void | iax_set_error (void(*func)(const char *)) |
void | iax_set_output (void(*func)(const char *)) |
void | iax_showframe (struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen) |
static void | internalerror (const char *str) |
static void | internaloutput (const char *str) |
Variables | |
static void(* | errorf )(const char *str) = internalerror |
static int | frames = 0 |
static int | iframes = 0 |
static struct iax2_ie | infoelts [] |
static int | oframes = 0 |
static void(* | outputf )(const char *str) = internaloutput |
static struct iax2_ie | prov_ies [] |
Implementation of Inter-Asterisk eXchange Protocol, v 2.
Definition in file iax2-parser.c.
#define FRAME_CACHE_MAX_SIZE 20 |
Definition at line 64 of file iax2-parser.c.
Referenced by iax_frame_free(), and iax_frame_new().
AST_THREADSTORAGE_CUSTOM_SCOPE | ( | frame_cache | , |
NULL | , | ||
frame_cache_cleanup | , | ||
static | |||
) |
A per-thread cache of iax_frame structures.
static void dump_addr | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 80 of file iax2-parser.c.
References ast_copy_string(), and ast_inet_ntoa().
{ struct sockaddr_in sin; if (len == (int)sizeof(sin)) { memcpy(&sin, value, len); snprintf(output, maxlen, "IPV4 %s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); } else { ast_copy_string(output, "Invalid Address", maxlen); } }
static void dump_byte | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 145 of file iax2-parser.c.
References ast_copy_string().
{ if (len == (int)sizeof(unsigned char)) snprintf(output, maxlen, "%d", *((unsigned char *)value)); else ast_copy_string(output, "Invalid BYTE", maxlen); }
static void dump_datetime | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 153 of file iax2-parser.c.
References ast_copy_string(), ast_strftime(), get_unaligned_uint32(), ast_tm::tm_hour, ast_tm::tm_mday, ast_tm::tm_min, ast_tm::tm_mon, ast_tm::tm_sec, and ast_tm::tm_year.
{ struct ast_tm tm; unsigned long val = (unsigned long) ntohl(get_unaligned_uint32(value)); if (len == (int)sizeof(unsigned int)) { tm.tm_sec = (val & 0x1f) << 1; tm.tm_min = (val >> 5) & 0x3f; tm.tm_hour = (val >> 11) & 0x1f; tm.tm_mday = (val >> 16) & 0x1f; tm.tm_mon = ((val >> 21) & 0x0f) - 1; tm.tm_year = ((val >> 25) & 0x7f) + 100; ast_strftime(output, maxlen, "%Y-%m-%d %T", &tm); } else ast_copy_string(output, "Invalid DATETIME format!", maxlen); }
static void dump_ies | ( | unsigned char * | iedata, |
int | len | ||
) | [static] |
Definition at line 365 of file iax2-parser.c.
References ARRAY_LEN, iax2_ie::dump, iax2_ie::ie, infoelts, name, and outputf.
Referenced by iax_showframe().
{ int ielen; int ie; int x; int found; char interp[1024]; char tmp[1024]; if (len < 2) return; while(len > 2) { ie = iedata[0]; ielen = iedata[1]; if (ielen + 2> len) { snprintf(tmp, (int)sizeof(tmp), "Total IE length of %d bytes exceeds remaining frame length of %d bytes\n", ielen + 2, len); outputf(tmp); return; } found = 0; for (x = 0; x < ARRAY_LEN(infoelts); x++) { if (infoelts[x].ie == ie) { if (infoelts[x].dump) { infoelts[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen); snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", infoelts[x].name, interp); outputf(tmp); } else { if (ielen) snprintf(interp, (int)sizeof(interp), "%d bytes", ielen); else strcpy(interp, "Present"); snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", infoelts[x].name, interp); outputf(tmp); } found++; } } if (!found) { snprintf(tmp, (int)sizeof(tmp), " Unknown IE %03d : Present\n", ie); outputf(tmp); } iedata += (2 + ielen); len -= (2 + ielen); } outputf("\n"); }
static void dump_int | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 129 of file iax2-parser.c.
References ast_copy_string(), and get_unaligned_uint32().
{ if (len == (int)sizeof(unsigned int)) snprintf(output, maxlen, "%lu", (unsigned long)ntohl(get_unaligned_uint32(value))); else ast_copy_string(output, "Invalid INT", maxlen); }
static void dump_ipaddr | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 169 of file iax2-parser.c.
References ast_copy_string(), and ast_inet_ntoa().
{ struct sockaddr_in sin; if (len == (int)sizeof(unsigned int)) { memcpy(&sin.sin_addr, value, len); snprintf(output, maxlen, "%s", ast_inet_ntoa(sin.sin_addr)); } else ast_copy_string(output, "Invalid IPADDR", maxlen); }
static void dump_prefs | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 110 of file iax2-parser.c.
References ast_codec_pref_convert(), ast_codec_pref_string(), and len().
{ struct ast_codec_pref pref; int total_len = 0; maxlen--; total_len = maxlen; if (maxlen > len) maxlen = len; strncpy(output, value, maxlen); output[maxlen] = '\0'; ast_codec_pref_convert(&pref, output, total_len, 0); memset(output,0,total_len); ast_codec_pref_string(&pref, output, total_len); }
static void dump_prov | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 218 of file iax2-parser.c.
References dump_prov_ies().
{ dump_prov_ies(output, maxlen, value, len); }
static void dump_prov_flags | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 180 of file iax2-parser.c.
References ast_copy_string(), buf, get_unaligned_uint32(), and iax_provflags2str().
{ char buf[256] = ""; if (len == (int)sizeof(unsigned int)) snprintf(output, maxlen, "%lu (%s)", (unsigned long)ntohl(get_unaligned_uint32(value)), iax_provflags2str(buf, sizeof(buf), ntohl(get_unaligned_uint32(value)))); else ast_copy_string(output, "Invalid INT", maxlen); }
static void dump_prov_ies | ( | char * | output, |
int | maxlen, | ||
unsigned char * | iedata, | ||
int | len | ||
) | [static] |
Definition at line 313 of file iax2-parser.c.
References ast_copy_string(), iax2_ie::dump, iax2_ie::ie, and name.
Referenced by dump_prov().
{ int ielen; int ie; int x; int found; char interp[80]; char tmp[256]; if (len < 2) return; strcpy(output, "\n"); maxlen -= strlen(output); output += strlen(output); while(len > 2) { ie = iedata[0]; ielen = iedata[1]; if (ielen + 2> len) { snprintf(tmp, (int)sizeof(tmp), "Total Prov IE length of %d bytes exceeds remaining prov frame length of %d bytes\n", ielen + 2, len); ast_copy_string(output, tmp, maxlen); maxlen -= strlen(output); output += strlen(output); return; } found = 0; for (x=0;x<(int)sizeof(prov_ies) / (int)sizeof(prov_ies[0]); x++) { if (prov_ies[x].ie == ie) { if (prov_ies[x].dump) { prov_ies[x].dump(interp, (int)sizeof(interp), iedata + 2, ielen); snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", prov_ies[x].name, interp); ast_copy_string(output, tmp, maxlen); maxlen -= strlen(output); output += strlen(output); } else { if (ielen) snprintf(interp, (int)sizeof(interp), "%d bytes", ielen); else strcpy(interp, "Present"); snprintf(tmp, (int)sizeof(tmp), " %-15.15s : %s\n", prov_ies[x].name, interp); ast_copy_string(output, tmp, maxlen); maxlen -= strlen(output); output += strlen(output); } found++; } } if (!found) { snprintf(tmp, (int)sizeof(tmp), " Unknown Prov IE %03d : Present\n", ie); ast_copy_string(output, tmp, maxlen); maxlen -= strlen(output); output += strlen(output); } iedata += (2 + ielen); len -= (2 + ielen); } }
static void dump_samprate | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 190 of file iax2-parser.c.
References ast_copy_string(), IAX_RATE_11KHZ, IAX_RATE_16KHZ, IAX_RATE_22KHZ, IAX_RATE_44KHZ, IAX_RATE_48KHZ, and IAX_RATE_8KHZ.
{ char tmp[256]=""; int sr; if (len == (int)sizeof(unsigned short)) { sr = ntohs(*((unsigned short *)value)); if (sr & IAX_RATE_8KHZ) strcat(tmp, ",8khz"); if (sr & IAX_RATE_11KHZ) strcat(tmp, ",11.025khz"); if (sr & IAX_RATE_16KHZ) strcat(tmp, ",16khz"); if (sr & IAX_RATE_22KHZ) strcat(tmp, ",22.05khz"); if (sr & IAX_RATE_44KHZ) strcat(tmp, ",44.1khz"); if (sr & IAX_RATE_48KHZ) strcat(tmp, ",48khz"); if (strlen(tmp)) ast_copy_string(output, &tmp[1], maxlen); else ast_copy_string(output, "None Specified!\n", maxlen); } else ast_copy_string(output, "Invalid SHORT", maxlen); }
static void dump_short | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 137 of file iax2-parser.c.
References ast_copy_string(), and get_unaligned_uint16().
{ if (len == (int)sizeof(unsigned short)) snprintf(output, maxlen, "%d", ntohs(get_unaligned_uint16(value))); else ast_copy_string(output, "Invalid SHORT", maxlen); }
static void dump_string | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 101 of file iax2-parser.c.
References len().
static void dump_string_hex | ( | char * | output, |
int | maxlen, | ||
void * | value, | ||
int | len | ||
) | [static] |
Definition at line 91 of file iax2-parser.c.
{ int i = 0; while (len-- && (i + 1) * 4 < maxlen) { sprintf(output + (4 * i), "\\x%2.2x", *((unsigned char *)value + i)); i++; } }
static void frame_cache_cleanup | ( | void * | data | ) | [static] |
Definition at line 1208 of file iax2-parser.c.
References ast_free, AST_LIST_REMOVE_HEAD, iax_frame::list, and iax_frames::list.
{ struct iax_frames *framelist = data; struct iax_frame *current; while ((current = AST_LIST_REMOVE_HEAD(&framelist->list, list))) ast_free(current); ast_free(framelist); }
void iax_frame_free | ( | struct iax_frame * | fr | ) |
Definition at line 1168 of file iax2-parser.c.
References iax_frame::afdatalen, ast_atomic_fetchadd_int(), ast_free, AST_LIST_FIRST, AST_LIST_INSERT_HEAD, AST_LIST_INSERT_TAIL, ast_threadstorage_get(), iax_frame::cacheable, iax_frame::direction, DIRECTION_INGRESS, DIRECTION_OUTGRESS, errorf, FRAME_CACHE_MAX_SIZE, iax_frames::list, and iax_frames::size.
Referenced by iax2_frame_free(), and network_thread().
{ #if !defined(LOW_MEMORY) struct iax_frames *iax_frames = NULL; #endif /* Note: does not remove from scheduler! */ if (fr->direction == DIRECTION_INGRESS) ast_atomic_fetchadd_int(&iframes, -1); else if (fr->direction == DIRECTION_OUTGRESS) ast_atomic_fetchadd_int(&oframes, -1); else { errorf("Attempt to double free frame detected\n"); return; } ast_atomic_fetchadd_int(&frames, -1); #if !defined(LOW_MEMORY) if (!fr->cacheable || !(iax_frames = ast_threadstorage_get(&frame_cache, sizeof(*iax_frames)))) { ast_free(fr); return; } if (iax_frames->size < FRAME_CACHE_MAX_SIZE) { fr->direction = 0; /* Pseudo-sort: keep smaller frames at the top of the list. This should * increase the chance that we pick the smallest applicable frame for use. */ if (AST_LIST_FIRST(&iax_frames->list) && AST_LIST_FIRST(&iax_frames->list)->afdatalen < fr->afdatalen) { AST_LIST_INSERT_TAIL(&iax_frames->list, fr, list); } else { AST_LIST_INSERT_HEAD(&iax_frames->list, fr, list); } iax_frames->size++; return; } #endif ast_free(fr); }
struct iax_frame* iax_frame_new | ( | int | direction, |
int | datalen, | ||
unsigned int | cacheable | ||
) | [read] |
Definition at line 1110 of file iax2-parser.c.
References iax_frame::afdatalen, ast_atomic_fetchadd_int(), ast_calloc, ast_calloc_cache, AST_LIST_FIRST, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_realloc, ast_threadstorage_get(), iax_frame::cacheable, iax_frame::datalen, iax_frame::direction, DIRECTION_INGRESS, FRAME_CACHE_MAX_SIZE, iax_frame::list, iax_frames::list, iax_frame::retrans, and iax_frames::size.
Referenced by iax2_send(), and iaxfrdup2().
{ struct iax_frame *fr = NULL; #if !defined(LOW_MEMORY) struct iax_frames *iax_frames = NULL; struct iax_frame *smallest = NULL; /* Attempt to get a frame from this thread's cache */ if ((iax_frames = ast_threadstorage_get(&frame_cache, sizeof(*iax_frames)))) { smallest = AST_LIST_FIRST(&iax_frames->list); AST_LIST_TRAVERSE_SAFE_BEGIN(&iax_frames->list, fr, list) { if (fr->afdatalen >= datalen) { size_t afdatalen = fr->afdatalen; AST_LIST_REMOVE_CURRENT(list); iax_frames->size--; memset(fr, 0, sizeof(*fr)); fr->afdatalen = afdatalen; break; } else if (smallest->afdatalen > fr->afdatalen) { smallest = fr; } } AST_LIST_TRAVERSE_SAFE_END; } if (!fr) { if (iax_frames->size >= FRAME_CACHE_MAX_SIZE && smallest) { /* Make useless cache into something more useful */ AST_LIST_REMOVE(&iax_frames->list, smallest, list); if (!(fr = ast_realloc(smallest, sizeof(*fr) + datalen))) { AST_LIST_INSERT_TAIL(&iax_frames->list, smallest, list); return NULL; } } else if (!(fr = ast_calloc_cache(1, sizeof(*fr) + datalen))) return NULL; fr->afdatalen = datalen; } #else if (!(fr = ast_calloc(1, sizeof(*fr) + datalen))) return NULL; fr->afdatalen = datalen; #endif fr->direction = direction; fr->retrans = -1; fr->cacheable = cacheable; if (fr->direction == DIRECTION_INGRESS) ast_atomic_fetchadd_int(&iframes, 1); else ast_atomic_fetchadd_int(&oframes, 1); ast_atomic_fetchadd_int(&frames, 1); return fr; }
void iax_frame_subclass2str | ( | enum iax_frame_subclass | subclass, |
char * | str, | ||
size_t | len | ||
) |
Definition at line 411 of file iax2-parser.c.
References ast_copy_string(), IAX_COMMAND_ACCEPT, IAX_COMMAND_ACK, IAX_COMMAND_AUTHREP, IAX_COMMAND_AUTHREQ, IAX_COMMAND_CALLTOKEN, IAX_COMMAND_DIAL, IAX_COMMAND_DPREP, IAX_COMMAND_DPREQ, IAX_COMMAND_FWDATA, IAX_COMMAND_FWDOWNL, IAX_COMMAND_HANGUP, IAX_COMMAND_INVAL, IAX_COMMAND_LAGRP, IAX_COMMAND_LAGRQ, IAX_COMMAND_MWI, IAX_COMMAND_NEW, IAX_COMMAND_PAGE, IAX_COMMAND_PING, IAX_COMMAND_POKE, IAX_COMMAND_PONG, IAX_COMMAND_PROVISION, IAX_COMMAND_QUELCH, IAX_COMMAND_REGACK, IAX_COMMAND_REGAUTH, IAX_COMMAND_REGREJ, IAX_COMMAND_REGREL, IAX_COMMAND_REGREQ, IAX_COMMAND_REJECT, IAX_COMMAND_RTKEY, IAX_COMMAND_TRANSFER, IAX_COMMAND_TXACC, IAX_COMMAND_TXCNT, IAX_COMMAND_TXMEDIA, IAX_COMMAND_TXREADY, IAX_COMMAND_TXREJ, IAX_COMMAND_TXREL, IAX_COMMAND_TXREQ, IAX_COMMAND_UNQUELCH, IAX_COMMAND_UNSUPPORT, and IAX_COMMAND_VNAK.
Referenced by ast_cli_netstats(), handle_cli_iax2_show_channels(), and iax_showframe().
{ const char *cmd = "Unknown"; /* if an error occurs here during compile, that means a new iax frame subclass * has been added to the iax_frame_subclass enum. Add the new subclass to the * switch case and make sure to update it with a new string representation. */ switch (subclass) { case IAX_COMMAND_NEW: cmd = "NEW "; break; case IAX_COMMAND_PING: cmd = "PING "; break; case IAX_COMMAND_PONG: cmd = "PONG "; break; case IAX_COMMAND_ACK: cmd = "ACK "; break; case IAX_COMMAND_HANGUP: cmd = "HANGUP "; break; case IAX_COMMAND_REJECT: cmd = "REJECT "; break; case IAX_COMMAND_ACCEPT: cmd = "ACCEPT "; break; case IAX_COMMAND_AUTHREQ: cmd = "AUTHREQ"; break; case IAX_COMMAND_AUTHREP: cmd = "AUTHREP"; break; case IAX_COMMAND_INVAL: cmd = "INVAL "; break; case IAX_COMMAND_LAGRQ: cmd = "LAGRQ "; break; case IAX_COMMAND_LAGRP: cmd = "LAGRP "; break; case IAX_COMMAND_REGREQ: cmd = "REGREQ "; break; case IAX_COMMAND_REGAUTH: cmd = "REGAUTH"; break; case IAX_COMMAND_REGACK: cmd = "REGACK "; break; case IAX_COMMAND_REGREJ: cmd = "REGREJ "; break; case IAX_COMMAND_REGREL: cmd = "REGREL "; break; case IAX_COMMAND_VNAK: cmd = "VNAK "; break; case IAX_COMMAND_DPREQ: cmd = "DPREQ "; break; case IAX_COMMAND_DPREP: cmd = "DPREP "; break; case IAX_COMMAND_DIAL: cmd = "DIAL "; break; case IAX_COMMAND_TXREQ: cmd = "TXREQ "; break; case IAX_COMMAND_TXCNT: cmd = "TXCNT "; break; case IAX_COMMAND_TXACC: cmd = "TXACC "; break; case IAX_COMMAND_TXREADY: cmd = "TXREADY"; break; case IAX_COMMAND_TXREL: cmd = "TXREL "; break; case IAX_COMMAND_TXREJ: cmd = "TXREJ "; break; case IAX_COMMAND_QUELCH: cmd = "QUELCH "; break; case IAX_COMMAND_UNQUELCH: cmd = "UNQULCH"; break; case IAX_COMMAND_POKE: cmd = "POKE "; break; case IAX_COMMAND_PAGE: cmd = "PAGE "; break; case IAX_COMMAND_MWI: cmd = "MWI "; break; case IAX_COMMAND_UNSUPPORT: cmd = "UNSPRTD"; break; case IAX_COMMAND_TRANSFER: cmd = "TRANSFR"; break; case IAX_COMMAND_PROVISION: cmd = "PROVISN"; break; case IAX_COMMAND_FWDOWNL: cmd = "FWDWNLD"; break; case IAX_COMMAND_FWDATA: cmd = "FWDATA "; break; case IAX_COMMAND_TXMEDIA: cmd = "TXMEDIA"; break; case IAX_COMMAND_RTKEY: cmd = "RTKEY "; break; case IAX_COMMAND_CALLTOKEN: cmd = "CTOKEN "; break; } ast_copy_string(str, cmd, len); }
Definition at line 1079 of file iax2-parser.c.
References iax_frame::af, iax_frame::afdata, iax_frame::afdatalen, AST_FORMAT_SLINEAR, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), ast_swapcopy_samples(), ast_frame::data, ast_frame::datalen, ast_frame::delivery, ast_frame::frametype, ast_frame::len, LOG_ERROR, ast_frame::mallocd, ast_frame::offset, ast_frame::ptr, ast_frame::samples, ast_frame::src, and ast_frame::subclass.
Referenced by iax2_send(), iaxfrdup2(), socket_process(), and socket_process_meta().
{ fr->af.frametype = f->frametype; fr->af.subclass = f->subclass; fr->af.mallocd = 0; /* Our frame is static relative to the container */ fr->af.datalen = f->datalen; fr->af.samples = f->samples; fr->af.offset = AST_FRIENDLY_OFFSET; fr->af.src = f->src; fr->af.delivery.tv_sec = 0; fr->af.delivery.tv_usec = 0; fr->af.data.ptr = fr->afdata; fr->af.len = f->len; if (fr->af.datalen) { size_t copy_len = fr->af.datalen; if (copy_len > fr->afdatalen) { ast_log(LOG_ERROR, "Losing frame data because destination buffer size '%d' bytes not big enough for '%d' bytes in the frame\n", (int) fr->afdatalen, (int) fr->af.datalen); copy_len = fr->afdatalen; } #if __BYTE_ORDER == __LITTLE_ENDIAN /* We need to byte-swap slinear samples from network byte order */ if ((fr->af.frametype == AST_FRAME_VOICE) && (fr->af.subclass == AST_FORMAT_SLINEAR)) { /* 2 bytes / sample for SLINEAR */ ast_swapcopy_samples(fr->af.data.ptr, f->data.ptr, copy_len / 2); } else #endif memcpy(fr->af.data.ptr, f->data.ptr, copy_len); } }
int iax_get_frames | ( | void | ) |
Definition at line 1220 of file iax2-parser.c.
References frames.
Referenced by handle_cli_iax2_show_stats().
{ return frames; }
int iax_get_iframes | ( | void | ) |
Definition at line 1221 of file iax2-parser.c.
References iframes.
Referenced by handle_cli_iax2_show_stats().
{ return iframes; }
int iax_get_oframes | ( | void | ) |
Definition at line 1222 of file iax2-parser.c.
References oframes.
Referenced by handle_cli_iax2_show_stats().
{ return oframes; }
const char* iax_ie2str | ( | int | ie | ) |
Definition at line 302 of file iax2-parser.c.
References ARRAY_LEN, infoelts, and iax2_ie::name.
Referenced by iax_ie_append_raw(), and iax_parse_ies().
int iax_ie_append | ( | struct iax_ie_data * | ied, |
unsigned char | ie | ||
) |
Definition at line 702 of file iax2-parser.c.
References iax_ie_append_raw().
Referenced by iax2_call(), and iax_firmware_append().
{ return iax_ie_append_raw(ied, ie, NULL, 0); }
int iax_ie_append_addr | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
const struct sockaddr_in * | sin | ||
) |
Definition at line 673 of file iax2-parser.c.
References iax_ie_append_raw().
Referenced by iax2_start_transfer(), and update_registry().
{ return iax_ie_append_raw(ied, ie, sin, (int)sizeof(struct sockaddr_in)); }
int iax_ie_append_byte | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
unsigned char | dat | ||
) |
Definition at line 697 of file iax2-parser.c.
References iax_ie_append_raw().
Referenced by __auth_reject(), __auto_hangup(), authenticate_request(), iax2_call(), iax2_hangup(), iax_provision_build(), and socket_process().
{ return iax_ie_append_raw(ied, ie, &dat, 1); }
int iax_ie_append_int | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
unsigned int | value | ||
) |
Definition at line 678 of file iax2-parser.c.
References iax_ie_append_raw().
Referenced by cache_get_callno_locked(), construct_rr(), iax2_call(), iax2_start_transfer(), iax_firmware_append(), iax_provision_build(), socket_process(), try_transfer(), and update_registry().
{ unsigned int newval; newval = htonl(value); return iax_ie_append_raw(ied, ie, &newval, (int)sizeof(newval)); }
int iax_ie_append_raw | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
const void * | data, | ||
int | datalen | ||
) |
Definition at line 658 of file iax2-parser.c.
References iax_ie_data::buf, errorf, iax_ie2str(), and iax_ie_data::pos.
Referenced by iax2_call(), iax2_key_rotate(), iax2_provision(), iax_firmware_append(), iax_ie_append(), iax_ie_append_addr(), iax_ie_append_byte(), iax_ie_append_int(), iax_ie_append_short(), and iax_ie_append_str().
{ char tmp[256]; if (datalen > ((int)sizeof(ied->buf) - ied->pos)) { snprintf(tmp, (int)sizeof(tmp), "Out of space for ie '%s' (%d), need %d have %d\n", iax_ie2str(ie), ie, datalen, (int)sizeof(ied->buf) - ied->pos); errorf(tmp); return -1; } ied->buf[ied->pos++] = ie; ied->buf[ied->pos++] = datalen; memcpy(ied->buf + ied->pos, data, datalen); ied->pos += datalen; return 0; }
int iax_ie_append_short | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
unsigned short | value | ||
) |
Definition at line 685 of file iax2-parser.c.
References iax_ie_append_raw().
Referenced by authenticate_request(), cache_get_callno_locked(), construct_rr(), dp_lookup(), iax2_call(), iax2_do_register(), iax2_start_transfer(), iax_provision_build(), registry_authrequest(), registry_rerequest(), socket_process(), and update_registry().
{ unsigned short newval; newval = htons(value); return iax_ie_append_raw(ied, ie, &newval, (int)sizeof(newval)); }
int iax_ie_append_str | ( | struct iax_ie_data * | ied, |
unsigned char | ie, | ||
const char * | str | ||
) |
Definition at line 692 of file iax2-parser.c.
References iax_ie_append_raw().
Referenced by __auth_reject(), __auto_hangup(), authenticate(), authenticate_request(), cache_get_callno_locked(), dp_lookup(), handle_call_token(), iax2_call(), iax2_do_register(), iax2_dprequest(), iax2_transfer(), iax_provision_build(), registry_authrequest(), registry_rerequest(), resend_with_token(), socket_process(), and update_registry().
{ return iax_ie_append_raw(ied, ie, str, strlen(str)); }
int iax_parse_ies | ( | struct iax_ies * | ies, |
unsigned char * | data, | ||
int | datalen | ||
) |
Definition at line 717 of file iax2-parser.c.
References iax_ies::adsicpe, iax_ies::apparent_addr, ast_copy_string(), ast_free, ast_str_buffer(), ast_str_create(), ast_str_set(), ast_variable_new(), iax_ies::authmethods, iax_ies::autoanswer, iax_ies::called_context, iax_ies::called_number, iax_ies::calling_ani, iax_ies::calling_name, iax_ies::calling_number, iax_ies::calling_pres, iax_ies::calling_tns, iax_ies::calling_ton, iax_ies::callno, iax_ies::calltoken, iax_ies::calltokendata, iax_ies::capability, iax_ies::cause, iax_ies::causecode, iax_ies::challenge, iax_ies::codec_prefs, iax_ies::datetime, iax_ies::devicetype, iax_ies::dnid, iax_ies::dpstatus, iax_ies::enckey, iax_ies::enckeylen, iax_ies::encmethods, errorf, ast_variable::file, iax_ies::firmwarever, iax_ies::format, iax_ies::fwdata, iax_ies::fwdatalen, iax_ies::fwdesc, get_unaligned_uint16(), get_unaligned_uint32(), iax_ie2str(), IAX_IE_ADSICPE, IAX_IE_APPARENT_ADDR, IAX_IE_AUTHMETHODS, IAX_IE_AUTOANSWER, IAX_IE_CALLED_CONTEXT, IAX_IE_CALLED_NUMBER, IAX_IE_CALLING_ANI, IAX_IE_CALLING_NAME, IAX_IE_CALLING_NUMBER, IAX_IE_CALLINGPRES, IAX_IE_CALLINGTNS, IAX_IE_CALLINGTON, IAX_IE_CALLNO, IAX_IE_CALLTOKEN, IAX_IE_CAPABILITY, IAX_IE_CAUSE, IAX_IE_CAUSECODE, IAX_IE_CHALLENGE, IAX_IE_CODEC_PREFS, IAX_IE_DATETIME, IAX_IE_DEVICETYPE, IAX_IE_DNID, IAX_IE_DPSTATUS, IAX_IE_ENCKEY, IAX_IE_ENCRYPTION, IAX_IE_FIRMWAREVER, IAX_IE_FORMAT, IAX_IE_FWBLOCKDATA, IAX_IE_FWBLOCKDESC, IAX_IE_IAX_UNKNOWN, IAX_IE_LANGUAGE, IAX_IE_MD5_RESULT, IAX_IE_MSGCOUNT, IAX_IE_MUSICONHOLD, IAX_IE_OSPTOKEN, IAX_IE_PASSWORD, IAX_IE_PROVVER, IAX_IE_RDNIS, IAX_IE_REFRESH, IAX_IE_RR_DELAY, IAX_IE_RR_DROPPED, IAX_IE_RR_JITTER, IAX_IE_RR_LOSS, IAX_IE_RR_OOO, IAX_IE_RR_PKTS, IAX_IE_RSA_RESULT, IAX_IE_SAMPLINGRATE, IAX_IE_SERVICEIDENT, IAX_IE_TRANSFERID, IAX_IE_USERNAME, IAX_IE_VARIABLE, IAX_IE_VERSION, IAX_MAX_OSPBLOCK_NUM, IAX_RATE_8KHZ, iax_ies::iax_unknown, iax_ies::language, len(), iax_ies::md5_result, iax_ies::msgcount, iax_ies::musiconhold, ast_variable::name, ast_variable::next, iax_ies::ospblocklength, iax_ies::osptokenblock, outputf, iax_ies::password, iax_ies::provver, iax_ies::provverpres, iax_ies::rdnis, iax_ies::refresh, iax_ies::rr_delay, iax_ies::rr_dropped, iax_ies::rr_jitter, iax_ies::rr_loss, iax_ies::rr_ooo, iax_ies::rr_pkts, iax_ies::rsa_result, iax_ies::samprate, iax_ies::serviceident, str, iax_ies::transferid, iax_ies::username, ast_variable::value, var, iax_ies::vars, and iax_ies::version.
Referenced by socket_process().
{ /* Parse data into information elements */ int len; int ie; char tmp[256], *tmp2; struct ast_variable *var, *var2, *prev; unsigned int count; memset(ies, 0, (int)sizeof(struct iax_ies)); ies->msgcount = -1; ies->firmwarever = -1; ies->calling_ton = -1; ies->calling_tns = -1; ies->calling_pres = -1; ies->samprate = IAX_RATE_8KHZ; while(datalen >= 2) { ie = data[0]; len = data[1]; if (len > datalen - 2) { errorf("Information element length exceeds message size\n"); return -1; } switch(ie) { case IAX_IE_CALLED_NUMBER: ies->called_number = (char *)data + 2; break; case IAX_IE_CALLING_NUMBER: ies->calling_number = (char *)data + 2; break; case IAX_IE_CALLING_ANI: ies->calling_ani = (char *)data + 2; break; case IAX_IE_CALLING_NAME: ies->calling_name = (char *)data + 2; break; case IAX_IE_CALLED_CONTEXT: ies->called_context = (char *)data + 2; break; case IAX_IE_USERNAME: ies->username = (char *)data + 2; break; case IAX_IE_PASSWORD: ies->password = (char *)data + 2; break; case IAX_IE_CODEC_PREFS: ies->codec_prefs = (char *)data + 2; break; case IAX_IE_CAPABILITY: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else ies->capability = ntohl(get_unaligned_uint32(data + 2)); break; case IAX_IE_FORMAT: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else ies->format = ntohl(get_unaligned_uint32(data + 2)); break; case IAX_IE_LANGUAGE: ies->language = (char *)data + 2; break; case IAX_IE_VERSION: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting version to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->version = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_ADSICPE: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting adsicpe to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->adsicpe = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_SAMPLINGRATE: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting samplingrate to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->samprate = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_DNID: ies->dnid = (char *)data + 2; break; case IAX_IE_RDNIS: ies->rdnis = (char *)data + 2; break; case IAX_IE_AUTHMETHODS: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting authmethods to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->authmethods = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_ENCRYPTION: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting encryption to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->encmethods = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_CHALLENGE: ies->challenge = (char *)data + 2; break; case IAX_IE_MD5_RESULT: ies->md5_result = (char *)data + 2; break; case IAX_IE_RSA_RESULT: ies->rsa_result = (char *)data + 2; break; case IAX_IE_APPARENT_ADDR: ies->apparent_addr = ((struct sockaddr_in *)(data + 2)); break; case IAX_IE_REFRESH: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting refresh to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->refresh = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_DPSTATUS: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting dpstatus to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->dpstatus = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_CALLNO: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting callno to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->callno = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_CAUSE: ies->cause = (char *)data + 2; break; case IAX_IE_CAUSECODE: if (len != 1) { snprintf(tmp, (int)sizeof(tmp), "Expecting causecode to be single byte but was %d\n", len); errorf(tmp); } else { ies->causecode = data[2]; } break; case IAX_IE_IAX_UNKNOWN: if (len == 1) ies->iax_unknown = data[2]; else { snprintf(tmp, (int)sizeof(tmp), "Expected single byte Unknown command, but was %d long\n", len); errorf(tmp); } break; case IAX_IE_MSGCOUNT: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting msgcount to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->msgcount = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_AUTOANSWER: ies->autoanswer = 1; break; case IAX_IE_MUSICONHOLD: ies->musiconhold = 1; break; case IAX_IE_TRANSFERID: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expecting transferid to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else ies->transferid = ntohl(get_unaligned_uint32(data + 2)); break; case IAX_IE_DATETIME: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expecting date/time to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else ies->datetime = ntohl(get_unaligned_uint32(data + 2)); break; case IAX_IE_FIRMWAREVER: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting firmwarever to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->firmwarever = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_DEVICETYPE: ies->devicetype = (char *)data + 2; break; case IAX_IE_SERVICEIDENT: ies->serviceident = (char *)data + 2; break; case IAX_IE_FWBLOCKDESC: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expected block desc to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else ies->fwdesc = ntohl(get_unaligned_uint32(data + 2)); break; case IAX_IE_FWBLOCKDATA: ies->fwdata = data + 2; ies->fwdatalen = len; break; case IAX_IE_ENCKEY: ies->enckey = data + 2; ies->enckeylen = len; break; case IAX_IE_PROVVER: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expected provisioning version to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else { ies->provverpres = 1; ies->provver = ntohl(get_unaligned_uint32(data + 2)); } break; case IAX_IE_CALLINGPRES: if (len == 1) ies->calling_pres = data[2]; else { snprintf(tmp, (int)sizeof(tmp), "Expected single byte callingpres, but was %d long\n", len); errorf(tmp); } break; case IAX_IE_CALLINGTON: if (len == 1) ies->calling_ton = data[2]; else { snprintf(tmp, (int)sizeof(tmp), "Expected single byte callington, but was %d long\n", len); errorf(tmp); } break; case IAX_IE_CALLINGTNS: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expecting callingtns to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else ies->calling_tns = ntohs(get_unaligned_uint16(data + 2)); break; case IAX_IE_RR_JITTER: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expected jitter rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else { ies->rr_jitter = ntohl(get_unaligned_uint32(data + 2)); } break; case IAX_IE_RR_LOSS: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else { ies->rr_loss = ntohl(get_unaligned_uint32(data + 2)); } break; case IAX_IE_RR_PKTS: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else { ies->rr_pkts = ntohl(get_unaligned_uint32(data + 2)); } break; case IAX_IE_RR_DELAY: if (len != (int)sizeof(unsigned short)) { snprintf(tmp, (int)sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len); errorf(tmp); } else { ies->rr_delay = ntohs(get_unaligned_uint16(data + 2)); } break; case IAX_IE_RR_DROPPED: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else { ies->rr_dropped = ntohl(get_unaligned_uint32(data + 2)); } break; case IAX_IE_RR_OOO: if (len != (int)sizeof(unsigned int)) { snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len); errorf(tmp); } else { ies->rr_ooo = ntohl(get_unaligned_uint32(data + 2)); } break; case IAX_IE_VARIABLE: ast_copy_string(tmp, (char *)data + 2, len + 1); tmp2 = strchr(tmp, '='); if (tmp2) *tmp2++ = '\0'; else tmp2 = ""; { struct ast_str *str = ast_str_create(16); /* Existing variable or new variable? */ for (var2 = ies->vars, prev = NULL; var2; prev = var2, var2 = var2->next) { if (strcmp(tmp, var2->name) == 0) { ast_str_set(&str, 0, "%s%s", var2->value, tmp2); var = ast_variable_new(tmp, ast_str_buffer(str), var2->file); var->next = var2->next; if (prev) { prev->next = var; } else { ies->vars = var; } snprintf(tmp, sizeof(tmp), "Assigned (%p)%s to (%p)%s\n", var->name, var->name, var->value, var->value); outputf(tmp); ast_free(var2); break; } } ast_free(str); } if (!var2) { var = ast_variable_new(tmp, tmp2, ""); snprintf(tmp, sizeof(tmp), "Assigned (%p)%s to (%p)%s\n", var->name, var->name, var->value, var->value); outputf(tmp); var->next = ies->vars; ies->vars = var; } break; case IAX_IE_OSPTOKEN: if ((count = data[2]) < IAX_MAX_OSPBLOCK_NUM) { ies->osptokenblock[count] = (char *)data + 2 + 1; ies->ospblocklength[count] = len - 1; } else { snprintf(tmp, (int)sizeof(tmp), "Expected OSP token block index to be 0~%d but was %d\n", IAX_MAX_OSPBLOCK_NUM - 1, count); errorf(tmp); } break; case IAX_IE_CALLTOKEN: if (len) { ies->calltokendata = (unsigned char *) data + 2; } ies->calltoken = 1; break; default: snprintf(tmp, (int)sizeof(tmp), "Ignoring unknown information element '%s' (%d) of length %d\n", iax_ie2str(ie), ie, len); outputf(tmp); } /* Overwrite information element with 0, to null terminate previous portion */ data[0] = 0; datalen -= (len + 2); data += (len + 2); } /* Null-terminate last field */ *data = '\0'; if (datalen) { errorf("Invalid information element contents, strange boundary\n"); return -1; } return 0; }
void iax_set_error | ( | void(*)(const char *) | func | ) |
Definition at line 712 of file iax2-parser.c.
References errorf.
Referenced by load_module().
{ errorf = func; }
void iax_set_output | ( | void(*)(const char *) | func | ) |
Definition at line 707 of file iax2-parser.c.
References outputf.
Referenced by load_module().
{ outputf = func; }
void iax_showframe | ( | struct iax_frame * | f, |
struct ast_iax2_full_hdr * | fhi, | ||
int | rx, | ||
struct sockaddr_in * | sin, | ||
int | datalen | ||
) |
Definition at line 543 of file iax2-parser.c.
References ARRAY_LEN, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_IAX, ast_inet_ntoa(), ast_iax2_full_hdr::csub, iax_frame::data, ast_iax2_full_hdr::dcallno, dir, dump_ies(), IAX_FLAG_FULL, IAX_FLAG_RETRANS, iax_frame_subclass2str(), ast_iax2_full_hdr::iedata, ast_iax2_full_hdr::iseqno, ast_iax2_full_hdr::oseqno, outputf, iax_frame::retries, ast_iax2_full_hdr::scallno, ast_iax2_full_hdr::ts, and ast_iax2_full_hdr::type.
Referenced by iax_outputframe(), and send_packet().
{ const char *framelist[] = { "(0?)", "DTMF_E ", "VOICE ", "VIDEO ", "CONTROL", "NULL ", "IAX ", "TEXT ", "IMAGE ", "HTML ", "CNG ", "MODEM ", "DTMF_B ", }; const char *cmds[] = { "(0?)", "HANGUP ", "RING ", "RINGING", "ANSWER ", "BUSY ", "TKOFFHK", "OFFHOOK", "CONGSTN", "FLASH ", "WINK ", "OPTION ", "RDKEY ", "RDUNKEY", "PROGRES", "PROCDNG", "HOLD ", "UNHOLD ", "VIDUPDT", "T38 ", "SRCUPDT", }; struct ast_iax2_full_hdr *fh; char retries[20]; char class2[20]; char subclass2[20]; const char *class; const char *subclass; char *dir; char tmp[512]; switch(rx) { case 0: dir = "Tx"; break; case 2: dir = "TE"; break; case 3: dir = "RD"; break; default: dir = "Rx"; break; } if (f) { fh = f->data; snprintf(retries, sizeof(retries), "%03d", f->retries); } else { fh = fhi; if (ntohs(fh->dcallno) & IAX_FLAG_RETRANS) strcpy(retries, "Yes"); else strcpy(retries, " No"); } if (!(ntohs(fh->scallno) & IAX_FLAG_FULL)) { /* Don't mess with mini-frames */ return; } if (fh->type >= ARRAY_LEN(framelist)) { snprintf(class2, sizeof(class2), "(%d?)", fh->type); class = class2; } else { class = framelist[(int)fh->type]; } if (fh->type == AST_FRAME_DTMF_BEGIN || fh->type == AST_FRAME_DTMF_END) { sprintf(subclass2, "%c", fh->csub); subclass = subclass2; } else if (fh->type == AST_FRAME_IAX) { iax_frame_subclass2str((int)fh->csub, subclass2, sizeof(subclass2)); subclass = subclass2; } else if (fh->type == AST_FRAME_CONTROL) { if (fh->csub >= ARRAY_LEN(cmds)) { snprintf(subclass2, sizeof(subclass2), "(%d?)", fh->csub); subclass = subclass2; } else { subclass = cmds[(int)fh->csub]; } } else { snprintf(subclass2, sizeof(subclass2), "%d", fh->csub); subclass = subclass2; } snprintf(tmp, sizeof(tmp), "%s-Frame Retry[%s] -- OSeqno: %3.3d ISeqno: %3.3d Type: %s Subclass: %s\n", dir, retries, fh->oseqno, fh->iseqno, class, subclass); outputf(tmp); snprintf(tmp, sizeof(tmp), " Timestamp: %05lums SCall: %5.5d DCall: %5.5d [%s:%d]\n", (unsigned long)ntohl(fh->ts), ntohs(fh->scallno) & ~IAX_FLAG_FULL, ntohs(fh->dcallno) & ~IAX_FLAG_RETRANS, ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port)); outputf(tmp); if (fh->type == AST_FRAME_IAX) dump_ies(fh->iedata, datalen); }
static void internalerror | ( | const char * | str | ) | [static] |
Definition at line 72 of file iax2-parser.c.
{ fprintf(stderr, "WARNING: %s", str); }
static void internaloutput | ( | const char * | str | ) | [static] |
Definition at line 67 of file iax2-parser.c.
{ fputs(str, stdout); }
Definition at line 78 of file iax2-parser.c.
Referenced by iax_frame_free(), iax_ie_append_raw(), iax_parse_ies(), and iax_set_error().
int frames = 0 [static] |
Definition at line 45 of file iax2-parser.c.
Referenced by __ast_answer(), __ast_queue_frame(), __frame_free(), ast_frame_header_new(), ast_frdup(), fixed_jb_get(), frame_cache_cleanup(), iax_get_frames(), and queue_put().
int iframes = 0 [static] |
Definition at line 46 of file iax2-parser.c.
Referenced by iax_get_iframes().
Referenced by dump_ies(), and iax_ie2str().
int oframes = 0 [static] |
Definition at line 47 of file iax2-parser.c.
Referenced by iax_get_oframes().
Definition at line 77 of file iax2-parser.c.
Referenced by dump_ies(), iax_parse_ies(), iax_set_output(), and iax_showframe().
Definition at line 282 of file iax2-parser.c.