37 #include "include/sip.h"
38 #include "include/globals.h"
39 #include "include/dialog.h"
40 #include "include/dialplan_functions.h"
41 #include "include/sip_utils.h"
64 if (!IS_SIP_TECH(chan->
tech)) {
69 memset(buf, 0, buflen);
75 if (!strcasecmp(
args.param,
"peerip")) {
77 }
else if (!strcasecmp(
args.param,
"recvip")) {
79 }
else if (!strcasecmp(
args.param,
"from")) {
81 }
else if (!strcasecmp(
args.param,
"uri")) {
83 }
else if (!strcasecmp(
args.param,
"useragent")) {
85 }
else if (!strcasecmp(
args.param,
"peername")) {
87 }
else if (!strcasecmp(
args.param,
"t38passthrough")) {
88 ast_copy_string(buf, (p->t38.state == T38_DISABLED) ?
"0" :
"1", buflen);
89 }
else if (!strcasecmp(
args.param,
"rtpdest")) {
96 if (!strcasecmp(
args.type,
"audio"))
98 else if (!strcasecmp(
args.type,
"video"))
100 else if (!strcasecmp(
args.type,
"text"))
112 }
else if (!strcasecmp(
args.param,
"rtpsource")) {
119 if (!strcasecmp(
args.type,
"audio"))
121 else if (!strcasecmp(
args.type,
"video"))
123 else if (!strcasecmp(
args.type,
"text"))
142 }
else if (!strcasecmp(
args.param,
"rtpqos")) {
149 if (!strcasecmp(
args.type,
"audio")) {
151 }
else if (!strcasecmp(
args.type,
"video")) {
153 }
else if (!strcasecmp(
args.type,
"text")) {
173 enum { INT, DBL }
type;
179 {
"txcount", INT, { .i4 = &stats.
txcount, }, },
180 {
"rxcount", INT, { .i4 = &stats.
rxcount, }, },
181 {
"txjitter", DBL, { .d8 = &stats.
txjitter, }, },
182 {
"rxjitter", DBL, { .d8 = &stats.
rxjitter, }, },
191 {
"txploss", INT, { .i4 = &stats.
txploss, }, },
192 {
"rxploss", INT, { .i4 = &stats.
rxploss, }, },
201 {
"rtt", DBL, { .d8 = &stats.
rtt, }, },
202 {
"maxrtt", DBL, { .d8 = &stats.
maxrtt, }, },
203 {
"minrtt", DBL, { .d8 = &stats.
minrtt, }, },
204 {
"normdevrtt", DBL, { .d8 = &stats.
normdevrtt, }, },
205 {
"stdevrtt", DBL, { .d8 = &stats.
stdevrtt, }, },
206 {
"local_ssrc", INT, { .i4 = &stats.
local_ssrc, }, },
207 {
"remote_ssrc", INT, { .i4 = &stats.
remote_ssrc, }, },
216 if (!strcasecmp(
args.field, lookup[i].name)) {
217 if (lookup[i].
type == INT) {
218 snprintf(buf, buflen,
"%u", *lookup[i].i4);
220 snprintf(buf, buflen,
"%f", *lookup[i].d8);
228 }
else if (!strcasecmp(
args.param,
"secure_signaling")) {
229 snprintf(buf, buflen,
"%s", p->socket.type == SIP_TRANSPORT_TLS ?
"1" :
"");
230 }
else if (!strcasecmp(
args.param,
"secure_media")) {
231 snprintf(buf, buflen,
"%s", p->srtp ?
"1" :
"");
238 #ifdef TEST_FRAMEWORK
267 memcpy(stats, s,
sizeof(*stats));
276 .new = test_sip_rtpqos_1_new,
277 .destroy = test_sip_rtpqos_1_destroy,
278 .read = test_sip_rtpqos_1_read,
279 .write = test_sip_rtpqos_1_write,
280 .get_stat = test_sip_rtpqos_1_get_stat,
284 struct sip_pvt *p = NULL;
286 struct ast_str *varstr = NULL, *buffer = NULL;
289 enum { INT, DBL }
type;
295 {
"txcount", INT, { .i4 = &mine.
txcount, }, },
296 {
"rxcount", INT, { .i4 = &mine.
rxcount, }, },
297 {
"txjitter", DBL, { .d8 = &mine.
txjitter, }, },
298 {
"rxjitter", DBL, { .d8 = &mine.
rxjitter, }, },
307 {
"txploss", INT, { .i4 = &mine.
txploss, }, },
308 {
"rxploss", INT, { .i4 = &mine.
rxploss, }, },
317 {
"rtt", DBL, { .d8 = &mine.
rtt, }, },
318 {
"maxrtt", DBL, { .d8 = &mine.
maxrtt, }, },
319 {
"minrtt", DBL, { .d8 = &mine.
minrtt, }, },
320 {
"normdevrtt", DBL, { .d8 = &mine.
normdevrtt, }, },
321 {
"stdevrtt", DBL, { .d8 = &mine.
stdevrtt, }, },
322 {
"local_ssrc", INT, { .i4 = &mine.
local_ssrc, }, },
323 {
"remote_ssrc", INT, { .i4 = &mine.
remote_ssrc, }, },
329 info->name =
"test_sip_rtpqos";
330 info->category =
"/channels/chan_sip/";
331 info->summary =
"Test retrieval of SIP RTP QOS stats";
333 "Verify values in the RTP instance structure can be accessed through the dialplan.";
341 if (!(p =
sip_alloc(NULL, NULL, 0, SIP_NOTIFY, NULL))) {
356 chan->
tech_pvt = dialog_ref(p,
"Give the owner channel a reference to the dialog");
361 if (!varstr || !buffer) {
368 ast_str_set(&varstr, 0,
"${CHANNEL(rtpqos,audio,%s)}", lookup[i].
name);
369 if (lookup[i].
type == INT) {
372 for (j = 1; j < 25; j++) {
375 snprintf(cmpstr,
sizeof(cmpstr),
"%d", j);
383 double j, cmpdbl = 0.0;
384 for (j = 1.0; j < 10.0; j += 0.3) {
387 if (sscanf(
ast_str_buffer(buffer),
"%lf", &cmpdbl) != 1 || fabs(j - cmpdbl > .05)) {
403 dialog_unref(p,
"Destroy test object");
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
double local_normdevrxploss
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
struct ast_frame ast_null_frame
#define AST_MAX_USER_FIELD
int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Retrieve statistics about an RTP instance.
double remote_normdevjitter
void sip_dialplan_function_register_tests(void)
SIP test registration.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
double remote_stdevjitter
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
#define AST_TEST_REGISTER(cb)
struct sip_pvt * sip_alloc(ast_string_field callid, struct ast_sockaddr *addr, int useglobal_nat, const int intended_method, struct sip_request *req)
Allocate sip_pvt structure, set defaults and link in the container. Returns a reference to the object...
struct ast_str * ast_str_create(size_t init_len)
Create a malloc'ed dynamic length string.
Socket address structure.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
void dialog_unlink_all(struct sip_pvt *dialog)
Unlink a dialog from the dialogs container, as well as any other places that it may be currently stor...
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
int ast_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us)
Get our local IP address when contacting a remote host.
void sip_dialplan_function_unregister_tests(void)
SIP test registration.
General Asterisk PBX channel definitions.
int ast_rtp_engine_unregister(struct ast_rtp_engine *engine)
Unregister an RTP engine.
void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data)
Set the data portion of an RTP instance.
#define ast_test_status_update(a, b, c...)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Access Control of various sorts.
int ast_rtp_instance_set_remote_address(struct ast_rtp_instance *instance, const struct ast_sockaddr *address)
Set the address of the remote endpoint that we are sending RTP to.
double local_stdevrxploss
char * ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size)
Retrieve quality statistics about an RTP instance.
int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
Core PBX routines and definitions.
double remote_normdevrxploss
#define ast_strdupa(s)
duplicate a string in memory from the stack
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
struct ast_sockaddr bindaddr
#define AST_TEST_UNREGISTER(cb)
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static void parse(struct mgcp_request *req)
void * ast_rtp_instance_get_data(struct ast_rtp_instance *instance)
Get the data portion of an RTP instance.
void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the address of the remote endpoint that we are sending RTP to.
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Data structure associated with a single frame of data.
double remote_stdevrxploss
#define AST_TEST_DEFINE(hdr)
#define AST_APP_ARG(name)
Define an application argument.
struct ast_channel_tech sip_tech
Definition of this channel for PBX channel registration.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
double local_normdevjitter
struct ast_channel * ast_dummy_channel_alloc(void)
Create a fake channel structure.
Pluggable RTP Architecture.
struct ast_channel_tech * tech
int ast_rtp_engine_register2(struct ast_rtp_engine *engine, struct ast_module *module)
Register an RTP engine.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.