diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-04-11 19:17:05 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-04-11 19:17:05 +0000 |
commit | 48ac799bb17c7993299599903846ae9c1affe31d (patch) | |
tree | 3ac186bf799e3c6c8d267136777f3d5693fd1691 /channels/chan_mgcp.c | |
parent | 24957e66efbfa6ab6b2d1ce53433513265785998 (diff) |
Add MGCP audit
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@834 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_mgcp.c')
-rwxr-xr-x | channels/chan_mgcp.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 09cdfabb0..96c67ecf3 100755 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -179,6 +179,7 @@ static int transmit_response(struct mgcp_endpoint *p, char *msg, struct mgcp_req static int transmit_notify_request(struct mgcp_endpoint *p, char *tone, int offhook); static int transmit_connection_del(struct mgcp_endpoint *p); static int transmit_notify_request_with_callerid(struct mgcp_endpoint *p, char *tone, int offhook, char *callerid); +static int transmit_audit_endpoint(struct mgcp_endpoint *p); static int __mgcp_xmit(struct mgcp_endpoint *p, char *data, int len) { @@ -442,6 +443,63 @@ static char show_endpoints_usage[] = static struct ast_cli_entry cli_show_endpoints = { { "mgcp", "show", "endpoints", NULL }, mgcp_show_endpoints, "Show defined MGCP endpoints", show_endpoints_usage }; +static int mgcp_audit_endpoint(int fd, int argc, char *argv[]) +{ + struct mgcp_gateway *g; + struct mgcp_endpoint *e; + int found = 0; + char *ename,*gname; + if (!mgcpdebug) { + return RESULT_SHOWUSAGE; + } + if (argc != 4) + return RESULT_SHOWUSAGE; + /* split the name into parts by null */ + ename = argv[3]; + gname = ename; + while (*gname) { + if (*gname == '@') { + *gname = 0; + gname++; + break; + } + gname++; + } + + ast_pthread_mutex_lock(&gatelock); + g = gateways; + while(g) { + if (!strcasecmp(g->name, gname)) { + e = g->endpoints; + while(e) { + if (!strcasecmp(e->name, ename)) { + found = 1; + transmit_audit_endpoint(e); + break; + } + e = e->next; + } + if (found) { + break; + } + } + g = g->next; + } + if (!found) { + ast_cli(fd, " << Could not find endpoint >> "); + } + ast_pthread_mutex_unlock(&gatelock); + return RESULT_SUCCESS; +} + +static char audit_endpoint_usage[] = +"Usage: mgcp audit endpoint <endpointid>\n" +" List the capabilities of an endpoint in the MGCP (Media Gateawy Control Protocol) subsystem.\n" +" mgcp debug MUST be on to see the results of this command.\n"; + +static struct ast_cli_entry cli_audit_endpoint = + { { "mgcp", "audit", "endpoint", NULL }, mgcp_audit_endpoint, "Audit specified MGCP endpoint", audit_endpoint_usage }; + static int mgcp_answer(struct ast_channel *ast) { int res = 0; @@ -1255,6 +1313,15 @@ static int transmit_notify_request_with_callerid(struct mgcp_endpoint *p, char * add_header(&resp, "S", tone2); return send_request(p, &resp, oseq); } + +static int transmit_audit_endpoint(struct mgcp_endpoint *p) +{ + struct mgcp_request resp; + reqprep(&resp, p, "AUEP"); + add_header(&resp, "F", "A,R,D,S,X,N,I,T,O,ES,VS,E,MD"); + return send_request(p, &resp, oseq); +} + static int transmit_connection_del(struct mgcp_endpoint *p) { struct mgcp_request resp; @@ -1888,6 +1955,7 @@ int load_module() mgcp_rtp.type = type; ast_rtp_proto_register(&mgcp_rtp); ast_cli_register(&cli_show_endpoints); + ast_cli_register(&cli_audit_endpoint); ast_cli_register(&cli_debug); ast_cli_register(&cli_no_debug); /* And start the monitor for the first time */ |