static int format_ami_endpoint_transport(const struct ast_sip_endpoint *endpoint,
struct ast_sip_ami *ami)
{
- RAII_VAR(struct ast_str *, buf,
- ast_sip_create_ami_event("TransportDetail", ami), ast_free);
- RAII_VAR(struct ast_sip_transport *,
- transport, ast_sorcery_retrieve_by_id(
- ast_sip_get_sorcery(), "transport",
- endpoint->transport), ao2_cleanup);
+ RAII_VAR(struct ast_str *, buf, NULL, ast_free);
+ RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
+
+ if (ast_strlen_zero(endpoint->transport)) {
+ return 0;
+ }
+
+ buf = ast_sip_create_ami_event("TransportDetail", ami);
if (!buf) {
return -1;
}
+ transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport",
+ endpoint->transport);
if (!transport) {
astman_send_error_va(ami->s, ami->m, "Unable to retrieve "
"transport %s\n", endpoint->transport);
ast_sorcery_object_get_id(endpoint));
astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
+ ami->count++;
+
return 0;
}
static int ami_show_endpoint(struct mansession *s, const struct message *m)
{
- struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"), };
+ struct ast_sip_ami ami = { .s = s, .m = m, .action_id = astman_get_header(m, "ActionID"),
+ .count = 0, };
RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
const char *endpoint_name = astman_get_header(m, "Endpoint");
int count = 0;
astman_append(s, "ActionID: %s\r\n", ami.action_id);
}
astman_append(s, "EventList: Complete\r\n"
- "ListItems: %d\r\n\r\n", count + 1);
+ "ListItems: %d\r\n\r\n", ami.count + 1);
+
return 0;
}
ast_str_append(&buf, 0, "EndpointName: %s\r\n",
ast_sorcery_object_get_id(endpoint));
astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
-
+ ami->count++;
+
ast_free(buf);
ao2_cleanup(status);
return 0;