include "logger.h" and errno.h from asterisk.h - usage shows that they
[asterisk/asterisk.git] / channels / chan_jingle.c
index 7f7c0ef..f8072fd 100644 (file)
 /*** MODULEINFO
        <depend>iksemel</depend>
        <depend>res_jabber</depend>
-       <use>gnutls</use>
+       <use>openssl</use>
  ***/
 
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
 #include <sys/socket.h>
-#include <errno.h>
 #include <fcntl.h>
 #include <netdb.h>
 #include <netinet/in.h>
@@ -51,19 +46,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <iksemel.h>
 #include <pthread.h>
 
-#ifdef HAVE_GNUTLS
-#include <gcrypt.h>
-GCRY_THREAD_OPTION_PTHREAD_IMPL;
-#endif /* HAVE_GNUTLS */
-
 #include "asterisk/lock.h"
 #include "asterisk/channel.h"
 #include "asterisk/config.h"
-#include "asterisk/logger.h"
 #include "asterisk/module.h"
 #include "asterisk/pbx.h"
 #include "asterisk/options.h"
-#include "asterisk/lock.h"
 #include "asterisk/sched.h"
 #include "asterisk/io.h"
 #include "asterisk/rtp.h"
@@ -111,7 +99,7 @@ struct jingle_pvt {
        time_t laststun;
        struct jingle *parent;           /*!< Parent client */
        char sid[100];
-       char from[100];
+       char them[AJI_MAX_JIDLEN];
        char ring[10];                   /*!< Message ID of ring */
        iksrule *ringrule;               /*!< Rule for matching RING request */
        int initiator;                   /*!< If we're the initiator */
@@ -191,6 +179,8 @@ static int jingle_indicate(struct ast_channel *ast, int condition, const void *d
 static int jingle_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static int jingle_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
 static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from, const char *sid);
+static char *jingle_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *jingle_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 /*----- RTP interface functions */
 static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp,
                                                           struct ast_rtp *vrtp, struct ast_rtp *tpeer, int codecs, int nat_active);
@@ -201,7 +191,7 @@ static int jingle_get_codec(struct ast_channel *chan);
 static const struct ast_channel_tech jingle_tech = {
        .type = "Jingle",
        .description = "Jingle Channel Driver",
-       .capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
+       .capabilities = AST_FORMAT_AUDIO_MASK,
        .requester = jingle_request,
        .send_digit_begin = jingle_digit_begin,
        .send_digit_end = jingle_digit_end,
@@ -233,9 +223,15 @@ static struct ast_rtp_protocol jingle_rtp = {
        get_codec: jingle_get_codec,
 };
 
+static struct ast_cli_entry jingle_cli[] = {
+       AST_CLI_DEFINE(jingle_do_reload, "Reload Jingle configuration"),
+       AST_CLI_DEFINE(jingle_show_channels, "Show Jingle channels"),
+};
+
+
 static char externip[16];
 
-static struct jingle_container jingles;
+static struct jingle_container jingle_list;
 
 static void jingle_member_destroy(struct jingle *obj)
 {
@@ -246,12 +242,12 @@ static struct jingle *find_jingle(char *name, char *connection)
 {
        struct jingle *jingle = NULL;
 
-       jingle = ASTOBJ_CONTAINER_FIND(&jingles, name);
+       jingle = ASTOBJ_CONTAINER_FIND(&jingle_list, name);
        if (!jingle && strchr(name, '@'))
-               jingle = ASTOBJ_CONTAINER_FIND_FULL(&jingles, name, user,,, strcasecmp);
+               jingle = ASTOBJ_CONTAINER_FIND_FULL(&jingle_list, name, user,,, strcasecmp);
 
        if (!jingle) {                          /* guest call */
-               ASTOBJ_CONTAINER_TRAVERSE(&jingles, 1, {
+               ASTOBJ_CONTAINER_TRAVERSE(&jingle_list, 1, {
                        ASTOBJ_RDLOCK(iterator);
                        if (!strcasecmp(iterator->name, "guest")) {
                                if (!strcasecmp(iterator->connection->jid->partial, connection)) {
@@ -337,10 +333,7 @@ static int jingle_accept_call(struct jingle *client, struct jingle_pvt *p)
                                continue;
                        if (alreadysent & pref_codec)
                                continue;
-                       if (pref_codec <= AST_FORMAT_MAX_AUDIO)
-                               add_codec_to_answer(p, pref_codec, dcodecs);
-                       else
-                               add_codec_to_answer(p, pref_codec, dcodecs);
+                       add_codec_to_answer(p, pref_codec, dcodecs);
                        alreadysent |= pref_codec;
                }
                payload_red = iks_new("payload-type");
@@ -355,13 +348,13 @@ static int jingle_accept_call(struct jingle *client, struct jingle_pvt *p)
 
 
                iks_insert_attrib(iq, "type", "set");
-               iks_insert_attrib(iq, "to", (p->from) ? p->from : client->user);
+               iks_insert_attrib(iq, "to", (p->them) ? p->them : client->user);
                iks_insert_attrib(iq, "id", client->connection->mid);
                ast_aji_increment_mid(client->connection->mid);
 
                iks_insert_attrib(jingle, "xmlns", JINGLE_NS);
                iks_insert_attrib(jingle, "action", JINGLE_ACCEPT);
-               iks_insert_attrib(jingle, "initiator", p->initiator ? client->connection->jid->full : p->from);
+               iks_insert_attrib(jingle, "initiator", p->initiator ? client->connection->jid->full : p->them);
                iks_insert_attrib(jingle, JINGLE_SID, tmp->sid);
                iks_insert_node(iq, jingle);
                iks_insert_node(jingle, dcodecs);
@@ -369,7 +362,7 @@ static int jingle_accept_call(struct jingle *client, struct jingle_pvt *p)
                iks_insert_node(dcodecs, payload_audio);
                iks_insert_node(dcodecs, payload_cn);
 
-               iks_send(c->p, iq);
+               ast_aji_send(c, iq);
                iks_delete(payload_red);
                iks_delete(payload_audio);
                iks_delete(payload_cn);
@@ -416,7 +409,7 @@ static enum ast_rtp_get_result jingle_get_rtp_peer(struct ast_channel *chan, str
        ast_mutex_lock(&p->lock);
        if (p->rtp) {
                *rtp = p->rtp;
-               res = AST_RTP_TRY_NATIVE;
+               res = AST_RTP_TRY_PARTIAL;
        }
        ast_mutex_unlock(&p->lock);
 
@@ -470,7 +463,7 @@ static int jingle_response(struct jingle *client, ikspak *pak, const char *reaso
                                iks_insert_node(response, error);
                        }
                }
-               iks_send(client->connection->p, response);
+               ast_aji_send(client->connection, response);
                if (reason)
                        iks_delete(reason);
                if (error)
@@ -726,7 +719,7 @@ static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p,
                }
                iks_insert_attrib(candidate, "ufrag", tmp->ufrag);
 
-               iks_send(c->p, iq);
+               ast_aji_send(c, iq);
        }
        p->laststun = 0;
 
@@ -784,10 +777,10 @@ static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from,
 
        if (sid) {
                ast_copy_string(tmp->sid, sid, sizeof(tmp->sid));
-               ast_copy_string(tmp->from, from, sizeof(tmp->from));
+               ast_copy_string(tmp->them, from, sizeof(tmp->them));
        } else {
                snprintf(tmp->sid, sizeof(tmp->sid), "%08lx%08lx", ast_random(), ast_random());
-               ast_copy_string(tmp->from, idroster, sizeof(tmp->from));
+               ast_copy_string(tmp->them, idroster, sizeof(tmp->them));
                tmp->initiator = 1;
        }
        tmp->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
@@ -817,7 +810,7 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
        if (title)
                str = title;
        else
-               str = i->from;
+               str = i->them;
        tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, "", "", "", 0, "Jingle/%s-%04lx", str, ast_random() & 0xffff);
        if (!tmp) {
                ast_log(LOG_WARNING, "Unable to allocate Jingle channel structure!\n");
@@ -901,18 +894,18 @@ static int jingle_action(struct jingle *client, struct jingle_pvt *p, const char
        if (iq) {
                iks_insert_attrib(iq, "type", "set");
                iks_insert_attrib(iq, "from", client->connection->jid->full);
-               iks_insert_attrib(iq, "to", p->from);
+               iks_insert_attrib(iq, "to", p->them);
                iks_insert_attrib(iq, "id", client->connection->mid);
                ast_aji_increment_mid(client->connection->mid);
                if (jingle) {
                        iks_insert_attrib(jingle, "action", action);
                        iks_insert_attrib(jingle, JINGLE_SID, p->sid);
-                       iks_insert_attrib(jingle, "initiator", p->initiator ? client->connection->jid->full : p->from);
+                       iks_insert_attrib(jingle, "initiator", p->initiator ? client->connection->jid->full : p->them);
                        iks_insert_attrib(jingle, "xmlns", JINGLE_NS);
 
                        iks_insert_node(iq, jingle);
 
-                       iks_send(client->connection->p, iq);
+                       ast_aji_send(client->connection, iq);
                        iks_delete(jingle);
                        res = 0;
                }
@@ -984,7 +977,7 @@ static int jingle_newcall(struct jingle *client, ikspak *pak)
        chan = jingle_new(client, p, AST_STATE_DOWN, pak->from->user);
        if (chan) {
                ast_mutex_lock(&p->lock);
-               ast_copy_string(p->from, pak->from->full, sizeof(p->from));
+               ast_copy_string(p->them, pak->from->full, sizeof(p->them));
                if (iks_find_attrib(pak->query, JINGLE_SID)) {
                        ast_copy_string(p->sid, iks_find_attrib(pak->query, JINGLE_SID),
                                                        sizeof(p->sid));
@@ -1056,9 +1049,7 @@ static int jingle_add_candidate(struct jingle *client, ikspak *pak)
        struct aji_client *c = client->connection;
        struct jingle_candidate *newcandidate = NULL;
        iks *traversenodes = NULL, *receipt = NULL;
-       newcandidate = ast_calloc(1, sizeof(*newcandidate));
-       if (!newcandidate)
-               return 0;
+
        for (tmp = client->p; tmp; tmp = tmp->next) {
                if (iks_find_with_attrib(pak->x, JINGLE_NODE, JINGLE_SID, tmp->sid)) {
                        p = tmp;
@@ -1071,31 +1062,38 @@ static int jingle_add_candidate(struct jingle *client, ikspak *pak)
 
        traversenodes = pak->query;
        while(traversenodes) {
-               if(!strcasecmp(iks_name(traversenodes), "session")) {
+               if(!strcasecmp(iks_name(traversenodes), "jingle")) {
+                       traversenodes = iks_child(traversenodes);
+                       continue;
+               }
+               if(!strcasecmp(iks_name(traversenodes), "content")) {
                        traversenodes = iks_child(traversenodes);
                        continue;
                }
+               if(!strcasecmp(iks_name(traversenodes), "transport")) {
+                       traversenodes = iks_child(traversenodes);
+                       continue;
+               }
+
                if(!strcasecmp(iks_name(traversenodes), "candidate")) {
                        newcandidate = ast_calloc(1, sizeof(*newcandidate));
                        if (!newcandidate)
                                return 0;
-                       ast_copy_string(newcandidate->ip, iks_find_attrib(traversenodes, "address"),
-                                                       sizeof(newcandidate->ip));
+                       ast_copy_string(newcandidate->ip, iks_find_attrib(traversenodes, "ip"), sizeof(newcandidate->ip));
                        newcandidate->port = atoi(iks_find_attrib(traversenodes, "port"));
-                       ast_copy_string(newcandidate->password, iks_find_attrib(traversenodes, "password"),
-                                                       sizeof(newcandidate->password));
+                       ast_copy_string(newcandidate->password, iks_find_attrib(traversenodes, "pwd"), sizeof(newcandidate->password));
                        if (!strcasecmp(iks_find_attrib(traversenodes, "protocol"), "udp"))
                                newcandidate->protocol = AJI_PROTOCOL_UDP;
-                       if (!strcasecmp(iks_find_attrib(traversenodes, "protocol"), "ssltcp"))
+                       else if (!strcasecmp(iks_find_attrib(traversenodes, "protocol"), "ssltcp"))
                                newcandidate->protocol = AJI_PROTOCOL_SSLTCP;
-               
+                       
                        if (!strcasecmp(iks_find_attrib(traversenodes, "type"), "host"))
                                newcandidate->type = AJI_CONNECT_HOST;
-                       if (!strcasecmp(iks_find_attrib(traversenodes, "type"), "prflx"))
+                       else if (!strcasecmp(iks_find_attrib(traversenodes, "type"), "prflx"))
                                newcandidate->type = AJI_CONNECT_PRFLX;
-                       if (!strcasecmp(iks_find_attrib(traversenodes, "type"), "relay"))
+                       else if (!strcasecmp(iks_find_attrib(traversenodes, "type"), "relay"))
                                newcandidate->type = AJI_CONNECT_RELAY;
-                       if (!strcasecmp(iks_find_attrib(traversenodes, "type"), "srflx"))
+                       else if (!strcasecmp(iks_find_attrib(traversenodes, "type"), "srflx"))
                                newcandidate->type = AJI_CONNECT_SRFLX;
 
                        newcandidate->network = atoi(iks_find_attrib(traversenodes, "network"));
@@ -1116,7 +1114,7 @@ static int jingle_add_candidate(struct jingle *client, ikspak *pak)
        iks_insert_attrib(receipt, "from", c->jid->full);
        iks_insert_attrib(receipt, "to", iks_find_attrib(pak->x, "from"));
        iks_insert_attrib(receipt, "id", iks_find_attrib(pak->x, "id"));
-       iks_send(c->p, receipt);
+       ast_aji_send(c, receipt);
        iks_delete(receipt);
 
        return 1;
@@ -1260,13 +1258,13 @@ static int jingle_digit(struct ast_channel *ast, char digit, unsigned int durati
        }
 
        iks_insert_attrib(iq, "type", "set");
-       iks_insert_attrib(iq, "to", p->from);
+       iks_insert_attrib(iq, "to", p->them);
        iks_insert_attrib(iq, "from", client->connection->jid->full);
        iks_insert_attrib(iq, "id", client->connection->mid);
        ast_aji_increment_mid(client->connection->mid);
        iks_insert_attrib(jingle, "xmlns", JINGLE_NS);
        iks_insert_attrib(jingle, "action", "session-info");
-       iks_insert_attrib(jingle, "initiator", p->initiator ? client->connection->jid->full : p->from);
+       iks_insert_attrib(jingle, "initiator", p->initiator ? client->connection->jid->full : p->them);
        iks_insert_attrib(jingle, "sid", p->sid);
        iks_insert_attrib(dtmf, "xmlns", JINGLE_DTMF_NS);
        iks_insert_attrib(dtmf, "code", buffer);
@@ -1279,7 +1277,7 @@ static int jingle_digit(struct ast_channel *ast, char digit, unsigned int durati
        } else if (ast->dtmff.frametype == AST_FRAME_DTMF_END || duration != 0) {
                iks_insert_attrib(dtmf, "action", "button-up");
        }
-       iks_send(client->connection->p, iq);
+       ast_aji_send(client->connection, iq);
        iks_delete(iq);
        iks_delete(jingle);
        iks_delete(dtmf);
@@ -1321,7 +1319,7 @@ static int jingle_transmit_invite(struct jingle_pvt *p)
        payload_eg711u = iks_new("payload-type");
 
        iks_insert_attrib(iq, "type", "set");
-       iks_insert_attrib(iq, "to", p->from);
+       iks_insert_attrib(iq, "to", p->them);
        iks_insert_attrib(iq, "from", client->jid->full);
        iks_insert_attrib(iq, "id", client->mid);
        ast_aji_increment_mid(client->mid);
@@ -1346,7 +1344,7 @@ static int jingle_transmit_invite(struct jingle_pvt *p)
        iks_insert_node(jingle, content);
        iks_insert_node(iq, jingle);
 
-       iks_send(client->p, iq);
+       ast_aji_send(client, iq);
 
        iks_delete(iq);
        iks_delete(jingle);
@@ -1397,7 +1395,7 @@ static int jingle_call(struct ast_channel *ast, char *dest, int timeout)
                ast_log(LOG_WARNING, "Whoa, already have a ring rule!\n");
 
        jingle_transmit_invite(p);
-       jingle_create_candidates(p->parent, p, p->sid, p->from);
+       jingle_create_candidates(p->parent, p, p->sid, p->them);
 
        return 0;
 }
@@ -1455,37 +1453,86 @@ static struct ast_channel *jingle_request(const char *type, int format, void *da
        return chan;
 }
 
-#if 0
 /*! \brief CLI command "jingle show channels" */
-static int jingle_show(int fd, int argc, char **argv)
+static char *jingle_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-       struct jingle_pvt *p = NULL;
-       struct jingle *peer = NULL;
-       struct jingle_candidate *tmp;
-       struct jingle *client = NULL;
-       client = ast_aji_get_client("asterisk");
-       if (argc != 3)
-               return RESULT_SHOWUSAGE;
+#define FORMAT  "%-30.30s  %-30.30s  %-15.15s  %-5.5s %-5.5s \n"
+       struct jingle_pvt *p;
+       struct ast_channel *chan;
+       int numchans = 0;
+       char them[AJI_MAX_JIDLEN];
+       char *jid = NULL;
+       char *resource = NULL;
+
+       switch (cmd) {
+       case CLI_INIT:
+               e->command = "jingle show channels";
+               e->usage =
+                       "Usage: jingle show channels\n"
+                       "       Shows current state of the Jingle channels.\n";
+               return NULL;
+       case CLI_GENERATE:
+               return NULL;
+       }
+
+       if (a->argc != 3)
+               return CLI_SHOWUSAGE;
+
        ast_mutex_lock(&jinglelock);
-       if (client)
-               p = jingles->p;
-       while (p) {
-               ast_mutex_lock(&p->lock);
-               ast_cli(fd, "SID = %s\n", p->sid);
-               tmp = p->candidates;
-               while (tmp) {
-                       ast_verbose("port %d\n", tmp->port);
-                       tmp = tmp->next;
+       ast_cli(a->fd, FORMAT, "Channel", "Jabber ID", "Resource", "Read", "Write");
+       ASTOBJ_CONTAINER_TRAVERSE(&jingle_list, 1, {
+               ASTOBJ_WRLOCK(iterator);
+               p = iterator->p;
+               while(p) {
+                       chan = p->owner;
+                       ast_copy_string(them, p->them, sizeof(them));
+                       jid = them;
+                       resource = strchr(them, '/');
+                       if (!resource)
+                               resource = "None";
+                       else {
+                               *resource = '\0';
+                               resource ++;
+                       }
+                       if (chan)
+                               ast_cli(a->fd, FORMAT, 
+                                       chan->name,
+                                       jid,
+                                       resource,
+                                       ast_getformatname(chan->readformat),
+                                       ast_getformatname(chan->writeformat)                                    
+                                       );
+                       else 
+                               ast_log(LOG_WARNING, "No available channel\n");
+                       numchans ++;
+                       p = p->next;
                }
-               ast_mutex_unlock(&p->lock);
-               p = p->next;
-       }
-       if (!jingles->p)
-               ast_cli(fd, "No jingle channels in use\n");
+               ASTOBJ_UNLOCK(iterator);
+       });
+
        ast_mutex_unlock(&jinglelock);
-       return RESULT_SUCCESS;
+
+       ast_cli(a->fd, "%d active jingle channel%s\n", numchans, (numchans != 1) ? "s" : "");
+       return CLI_SUCCESS;
+#undef FORMAT
+}
+
+/*! \brief CLI command "jingle reload" */
+static char *jingle_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+       switch (cmd) {
+       case CLI_INIT:
+               e->command = "jingle reload";
+               e->usage =
+                       "Usage: jingle reload\n"
+                       "       Reload jingle channel driver.\n";
+               return NULL;
+       case CLI_GENERATE:
+               return NULL;
+       }       
+       
+       return CLI_SUCCESS;
 }
-#endif
 
 static int jingle_parser(void *data, ikspak *pak)
 {
@@ -1719,7 +1766,7 @@ static int jingle_load_config(void)
                                                iks_filter_add_rule(iterator->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, JINGLE_NS, IKS_RULE_DONE);
                                                iks_filter_add_rule(iterator->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS, JINGLE_DTMF_NS, IKS_RULE_DONE);
                                                ASTOBJ_UNLOCK(member);
-                                               ASTOBJ_CONTAINER_LINK(&jingles, member);
+                                               ASTOBJ_CONTAINER_LINK(&jingle_list, member);
                                                ASTOBJ_UNLOCK(iterator);
                                        });
                                } else {
@@ -1729,7 +1776,7 @@ static int jingle_load_config(void)
                        } else {
                                ASTOBJ_UNLOCK(member);
                                if (jingle_create_member(cat, var, allowguest, prefs, context, member))
-                                       ASTOBJ_CONTAINER_LINK(&jingles, member);
+                                       ASTOBJ_CONTAINER_LINK(&jingle_list, member);
                                ASTOBJ_UNREF(member, jingle_member_destroy);
                        }
                }
@@ -1742,11 +1789,7 @@ static int jingle_load_config(void)
 /*! \brief Load module into PBX, register channel */
 static int load_module(void)
 {
-#ifdef HAVE_GNUTLS     
-        gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
-#endif /* HAVE_GNUTLS */
-
-       ASTOBJ_CONTAINER_INIT(&jingles);
+       ASTOBJ_CONTAINER_INIT(&jingle_list);
        if (!jingle_load_config()) {
                ast_log(LOG_ERROR, "Unable to read config file %s. Not loading module.\n", JINGLE_CONFIG);
                return AST_MODULE_LOAD_DECLINE;
@@ -1766,7 +1809,7 @@ static int load_module(void)
        }
 
        ast_rtp_proto_register(&jingle_rtp);
-
+       ast_cli_register_multiple(jingle_cli, sizeof(jingle_cli) / sizeof(jingle_cli[0]));
        /* Make sure we can register our channel type */
        if (ast_channel_register(&jingle_tech)) {
                ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -1785,14 +1828,14 @@ static int reload(void)
 static int unload_module(void)
 {
        struct jingle_pvt *privates = NULL;
-
+       ast_cli_unregister_multiple(jingle_cli, sizeof(jingle_cli) / sizeof(jingle_cli[0]));
        /* First, take us out of the channel loop */
        ast_channel_unregister(&jingle_tech);
        ast_rtp_proto_unregister(&jingle_rtp);
 
        if (!ast_mutex_lock(&jinglelock)) {
                /* Hangup all interfaces if they have an owner */
-               ASTOBJ_CONTAINER_TRAVERSE(&jingles, 1, {
+               ASTOBJ_CONTAINER_TRAVERSE(&jingle_list, 1, {
                        ASTOBJ_WRLOCK(iterator);
                        privates = iterator->p;
                        while(privates) {
@@ -1808,8 +1851,8 @@ static int unload_module(void)
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        }
-       ASTOBJ_CONTAINER_DESTROYALL(&jingles, jingle_member_destroy);
-       ASTOBJ_CONTAINER_DESTROY(&jingles);
+       ASTOBJ_CONTAINER_DESTROYALL(&jingle_list, jingle_member_destroy);
+       ASTOBJ_CONTAINER_DESTROY(&jingle_list);
        return 0;
 }