Version 0.3.0 from FTP
[asterisk/asterisk.git] / channels / chan_vofr.c
index 6ea76c0..f1bb5e5 100755 (executable)
@@ -14,6 +14,7 @@
 #include <stdio.h>
 #include <pthread.h>
 #include <string.h>
 #include <stdio.h>
 #include <pthread.h>
 #include <string.h>
+#include <asterisk/lock.h>
 #include <asterisk/channel.h>
 #include <asterisk/channel_pvt.h>
 #include <asterisk/config.h>
 #include <asterisk/channel.h>
 #include <asterisk/channel_pvt.h>
 #include <asterisk/config.h>
@@ -52,14 +53,14 @@ static char context[AST_MAX_EXTENSION] = "default";
 static char language[MAX_LANGUAGE] = "";
 
 static int usecnt =0;
 static char language[MAX_LANGUAGE] = "";
 
 static int usecnt =0;
-static pthread_mutex_t usecnt_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t usecnt_lock = AST_MUTEX_INITIALIZER;
 
 /* Protect the interface list (of vofr_pvt's) */
 
 /* Protect the interface list (of vofr_pvt's) */
-static pthread_mutex_t iflock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t iflock = AST_MUTEX_INITIALIZER;
 
 /* Protect the monitoring thread, so only one process can kill or start it, and not
    when it's doing something critical. */
 
 /* Protect the monitoring thread, so only one process can kill or start it, and not
    when it's doing something critical. */
-static pthread_mutex_t monlock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t monlock = AST_MUTEX_INITIALIZER;
 
 /* This is the thread for the monitor which checks for input on the channels
    which are not currently in use.  */
 
 /* This is the thread for the monitor which checks for input on the channels
    which are not currently in use.  */
@@ -253,6 +254,8 @@ static void vofr_dump_packet(struct vofr_hdr *vh, int len)
 
 #endif
 
 
 #endif
 
+static struct ast_frame  *vofr_read(struct ast_channel *ast);
+
 static int vofr_xmit(struct vofr_pvt *p, char *data, int len)
 {
        int res;
 static int vofr_xmit(struct vofr_pvt *p, char *data, int len)
 {
        int res;
@@ -360,7 +363,7 @@ static int vofr_call(struct ast_channel *ast, char *dest, int timeout)
                        /* Musta gotten hung up, or no ack on off hook */
                        return -1;      
                }
                        /* Musta gotten hung up, or no ack on off hook */
                        return -1;      
                }
-               f = ast_read(ast);
+               f = vofr_read(ast);
                if (!f)
                        return -1;
                if ((f->frametype == AST_FRAME_CONTROL) &&
                if (!f)
                        return -1;
                if ((f->frametype == AST_FRAME_CONTROL) &&
@@ -390,7 +393,7 @@ static int vofr_call(struct ast_channel *ast, char *dest, int timeout)
                                /* Musta gotten hung up, or no ack on off hook */
                                return -1;      
                        }
                                /* Musta gotten hung up, or no ack on off hook */
                                return -1;      
                        }
-                       f = ast_read(ast);
+                       f = vofr_read(ast);
                        if (!f) 
                                return -1;
                        
                        if (!f) 
                                return -1;
                        
@@ -418,7 +421,7 @@ static int vofr_call(struct ast_channel *ast, char *dest, int timeout)
                        timeout = res;
                if (res) {
                        /* Ooh, read what's there. */
                        timeout = res;
                if (res) {
                        /* Ooh, read what's there. */
-                       f = ast_read(ast);
+                       f = vofr_read(ast);
                        if (!f)
                                return -1;
                        if ((f->frametype == AST_FRAME_CONTROL) && 
                        if (!f)
                                return -1;
                        if ((f->frametype == AST_FRAME_CONTROL) && 
@@ -454,11 +457,11 @@ static int vofr_hangup(struct ast_channel *ast)
        ast->state = AST_STATE_DOWN;
        ((struct vofr_pvt *)(ast->pvt->pvt))->owner = NULL;
        ((struct vofr_pvt *)(ast->pvt->pvt))->ringgothangup = 0;
        ast->state = AST_STATE_DOWN;
        ((struct vofr_pvt *)(ast->pvt->pvt))->owner = NULL;
        ((struct vofr_pvt *)(ast->pvt->pvt))->ringgothangup = 0;
-       pthread_mutex_lock(&usecnt_lock);
+       ast_pthread_mutex_lock(&usecnt_lock);
        usecnt--;
        if (usecnt < 0) 
                ast_log(LOG_WARNING, "Usecnt < 0???\n");
        usecnt--;
        if (usecnt < 0) 
                ast_log(LOG_WARNING, "Usecnt < 0???\n");
-       pthread_mutex_unlock(&usecnt_lock);
+       ast_pthread_mutex_unlock(&usecnt_lock);
        ast_update_use_count();
        if (option_verbose > 2) 
                ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
        ast_update_use_count();
        if (option_verbose > 2) 
                ast_verbose( VERBOSE_PREFIX_3 "Hungup '%s'\n", ast->name);
@@ -484,7 +487,7 @@ static int vofr_answer(struct ast_channel *ast)
        while(cnt > 0) {
                cnt = ast_waitfor(ast, cnt);
                if (cnt > 0) {
        while(cnt > 0) {
                cnt = ast_waitfor(ast, cnt);
                if (cnt > 0) {
-                       res = read(ast->fd, buf, sizeof(buf));
+                       res = read(ast->fds[0], buf, sizeof(buf));
 #ifdef VOFRDUMPER
                                vofr_dump_packet((void *)(buf +FR_API_MESS), res - FR_API_MESS);
 #endif
 #ifdef VOFRDUMPER
                                vofr_dump_packet((void *)(buf +FR_API_MESS), res - FR_API_MESS);
 #endif
@@ -782,10 +785,21 @@ static int vofr_write(struct ast_channel *ast, struct ast_frame *frame)
        return 0;
 }
 
        return 0;
 }
 
+static int vofr_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
+{
+       struct vofr_pvt *p = newchan->pvt->pvt;
+       if (p->owner != oldchan) {
+               ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner);
+               return -1;
+       }
+       p->owner = newchan;
+       return 0;
+}
+
 static struct ast_channel *vofr_new(struct vofr_pvt *i, int state)
 {
        struct ast_channel *tmp;
 static struct ast_channel *vofr_new(struct vofr_pvt *i, int state)
 {
        struct ast_channel *tmp;
-       tmp = ast_channel_alloc();
+       tmp = ast_channel_alloc(0);
        if (tmp) {
 #ifdef OLD_SANGOMA_API
                snprintf(tmp->name, sizeof(tmp->name), "AdtranVoFR/%s", i->sa.spkt_device);
        if (tmp) {
 #ifdef OLD_SANGOMA_API
                snprintf(tmp->name, sizeof(tmp->name), "AdtranVoFR/%s", i->sa.spkt_device);
@@ -793,12 +807,14 @@ static struct ast_channel *vofr_new(struct vofr_pvt *i, int state)
                snprintf(tmp->name, sizeof(tmp->name), "AdtranVoFR/%s", i->sa.sll_device);
 #endif
                tmp->type = type;
                snprintf(tmp->name, sizeof(tmp->name), "AdtranVoFR/%s", i->sa.sll_device);
 #endif
                tmp->type = type;
-               tmp->fd = i->s;
+               tmp->fds[0] = i->s;
                /* Adtran VoFR supports only G723.1 format data.  G711 (ulaw) would be nice too */
                /* Adtran VoFR supports only G723.1 format data.  G711 (ulaw) would be nice too */
-               tmp->format = AST_FORMAT_G723_1;
+               tmp->nativeformats = AST_FORMAT_G723_1;
                tmp->state = state;
                if (state == AST_STATE_RING)
                        tmp->rings = 1;
                tmp->state = state;
                if (state == AST_STATE_RING)
                        tmp->rings = 1;
+               tmp->writeformat = AST_FORMAT_G723_1;
+               tmp->readformat = AST_FORMAT_G723_1;
                tmp->pvt->pvt = i;
                tmp->pvt->send_digit = vofr_digit;
                tmp->pvt->call = vofr_call;
                tmp->pvt->pvt = i;
                tmp->pvt->send_digit = vofr_digit;
                tmp->pvt->call = vofr_call;
@@ -806,14 +822,15 @@ static struct ast_channel *vofr_new(struct vofr_pvt *i, int state)
                tmp->pvt->answer = vofr_answer;
                tmp->pvt->read = vofr_read;
                tmp->pvt->write = vofr_write;
                tmp->pvt->answer = vofr_answer;
                tmp->pvt->read = vofr_read;
                tmp->pvt->write = vofr_write;
+               tmp->pvt->fixup = vofr_fixup;
                if (strlen(i->language))
                if (strlen(i->language))
-                       strncpy(tmp->language, i->language, sizeof(tmp->language));
+                       strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
                i->owner = tmp;
                i->owner = tmp;
-               pthread_mutex_lock(&usecnt_lock);
+               ast_pthread_mutex_lock(&usecnt_lock);
                usecnt++;
                usecnt++;
-               pthread_mutex_unlock(&usecnt_lock);
+               ast_pthread_mutex_unlock(&usecnt_lock);
                ast_update_use_count();
                ast_update_use_count();
-               strncpy(tmp->context, i->context, sizeof(tmp->context));
+               strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(tmp)) {
                                ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
                if (state != AST_STATE_DOWN) {
                        if (ast_pbx_start(tmp)) {
                                ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name);
@@ -899,14 +916,14 @@ static void *do_monitor(void *data)
        for(;;) {
                /* Don't let anybody kill us right away.  Nobody should lock the interface list
                   and wait for the monitor list, but the other way around is okay. */
        for(;;) {
                /* Don't let anybody kill us right away.  Nobody should lock the interface list
                   and wait for the monitor list, but the other way around is okay. */
-               if (pthread_mutex_lock(&monlock)) {
+               if (ast_pthread_mutex_lock(&monlock)) {
                        ast_log(LOG_ERROR, "Unable to grab monitor lock\n");
                        return NULL;
                }
                /* Lock the interface list */
                        ast_log(LOG_ERROR, "Unable to grab monitor lock\n");
                        return NULL;
                }
                /* Lock the interface list */
-               if (pthread_mutex_lock(&iflock)) {
+               if (ast_pthread_mutex_lock(&iflock)) {
                        ast_log(LOG_ERROR, "Unable to grab interface lock\n");
                        ast_log(LOG_ERROR, "Unable to grab interface lock\n");
-                       pthread_mutex_unlock(&monlock);
+                       ast_pthread_mutex_unlock(&monlock);
                        return NULL;
                }
                /* Build the stuff we're going to select on, that is the socket of every
                        return NULL;
                }
                /* Build the stuff we're going to select on, that is the socket of every
@@ -930,10 +947,10 @@ static void *do_monitor(void *data)
                        i = i->next;
                }
                /* Okay, now that we know what to do, release the interface lock */
                        i = i->next;
                }
                /* Okay, now that we know what to do, release the interface lock */
-               pthread_mutex_unlock(&iflock);
+               ast_pthread_mutex_unlock(&iflock);
                
                /* And from now on, we're okay to be killed, so release the monitor lock as well */
                
                /* And from now on, we're okay to be killed, so release the monitor lock as well */
-               pthread_mutex_unlock(&monlock);
+               ast_pthread_mutex_unlock(&monlock);
                pthread_testcancel();
                /* Wait indefinitely for something to happen */
                res = select(n + 1, &rfds, NULL, NULL, NULL);
                pthread_testcancel();
                /* Wait indefinitely for something to happen */
                res = select(n + 1, &rfds, NULL, NULL, NULL);
@@ -946,7 +963,7 @@ static void *do_monitor(void *data)
                }
                /* Alright, lock the interface list again, and let's look and see what has
                   happened */
                }
                /* Alright, lock the interface list again, and let's look and see what has
                   happened */
-               if (pthread_mutex_lock(&iflock)) {
+               if (ast_pthread_mutex_lock(&iflock)) {
                        ast_log(LOG_WARNING, "Unable to lock the interface list\n");
                        continue;
                }
                        ast_log(LOG_WARNING, "Unable to lock the interface list\n");
                        continue;
                }
@@ -970,7 +987,7 @@ static void *do_monitor(void *data)
                        }
                        i=i->next;
                }
                        }
                        i=i->next;
                }
-               pthread_mutex_unlock(&iflock);
+               ast_pthread_mutex_unlock(&iflock);
        }
        /* Never reached */
        return NULL;
        }
        /* Never reached */
        return NULL;
@@ -982,32 +999,27 @@ static int restart_monitor(void)
        /* If we're supposed to be stopped -- stay stopped */
        if (monitor_thread == -2)
                return 0;
        /* If we're supposed to be stopped -- stay stopped */
        if (monitor_thread == -2)
                return 0;
-       if (pthread_mutex_lock(&monlock)) {
+       if (ast_pthread_mutex_lock(&monlock)) {
                ast_log(LOG_WARNING, "Unable to lock monitor\n");
                return -1;
        }
        if (monitor_thread == pthread_self()) {
                ast_log(LOG_WARNING, "Unable to lock monitor\n");
                return -1;
        }
        if (monitor_thread == pthread_self()) {
-               pthread_mutex_unlock(&monlock);
+               ast_pthread_mutex_unlock(&monlock);
                ast_log(LOG_WARNING, "Cannot kill myself\n");
                return -1;
        }
        if (monitor_thread) {
                ast_log(LOG_WARNING, "Cannot kill myself\n");
                return -1;
        }
        if (monitor_thread) {
-#if 0
-               pthread_cancel(monitor_thread);
-#endif
+               /* Wake up the thread */
                pthread_kill(monitor_thread, SIGURG);
                pthread_kill(monitor_thread, SIGURG);
-#if 0
-               pthread_join(monitor_thread, NULL);
-#endif
-       }
-       if (!monitor_thread)
-       /* Start a new monitor */
-       if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) {
-               pthread_mutex_unlock(&monlock);
-               ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
-               return -1;
+       } else {
+               /* Start a new monitor */
+               if (pthread_create(&monitor_thread, NULL, do_monitor, NULL) < 0) {
+                       ast_pthread_mutex_unlock(&monlock);
+                       ast_log(LOG_ERROR, "Unable to start monitor thread.\n");
+                       return -1;
+               }
        }
        }
-       pthread_mutex_unlock(&monlock);
+       ast_pthread_mutex_unlock(&monlock);
        return 0;
 }
 
        return 0;
 }
 
@@ -1039,7 +1051,7 @@ static struct vofr_pvt *mkif(char *type, char *iface)
 #ifdef OLD_SANGOMA_API
                /* Prepare sockaddr for binding */
                memset(&tmp->sa, 0, sizeof(tmp->sa));
 #ifdef OLD_SANGOMA_API
                /* Prepare sockaddr for binding */
                memset(&tmp->sa, 0, sizeof(tmp->sa));
-               strncpy(tmp->sa.spkt_device, iface, sizeof(tmp->sa.spkt_device));
+               strncpy(tmp->sa.spkt_device, iface, sizeof(tmp->sa.spkt_device)-1);
                tmp->sa.spkt_protocol = htons(0x16);
                tmp->sa.spkt_family = AF_PACKET;
                if (bind(tmp->s, (struct sockaddr *)&tmp->sa, sizeof(struct sockaddr))) {
                tmp->sa.spkt_protocol = htons(0x16);
                tmp->sa.spkt_family = AF_PACKET;
                if (bind(tmp->s, (struct sockaddr *)&tmp->sa, sizeof(struct sockaddr))) {
@@ -1048,8 +1060,8 @@ static struct vofr_pvt *mkif(char *type, char *iface)
                memset(&tmp->sa, 0, sizeof(tmp->sa));
                tmp->sa.sll_family = AF_WANPIPE;
                tmp->sa.sll_protocol = htons(ETH_P_IP);
                memset(&tmp->sa, 0, sizeof(tmp->sa));
                tmp->sa.sll_family = AF_WANPIPE;
                tmp->sa.sll_protocol = htons(ETH_P_IP);
-               strncpy(tmp->sa.sll_device, iface, sizeof(tmp->sa.sll_device));
-               strncpy(tmp->sa.sll_card, "wanpipe1", sizeof(tmp->sa.sll_card));
+               strncpy(tmp->sa.sll_device, iface, sizeof(tmp->sa.sll_device)-1);
+               strncpy(tmp->sa.sll_card, "wanpipe1", sizeof(tmp->sa.sll_card)-1);
                tmp->sa.sll_ifindex = 0;
                if (bind(tmp->s, (struct sockaddr *)&tmp->sa, sizeof(struct wan_sockaddr_ll))) {
 #endif         
                tmp->sa.sll_ifindex = 0;
                if (bind(tmp->s, (struct sockaddr *)&tmp->sa, sizeof(struct wan_sockaddr_ll))) {
 #endif         
@@ -1077,8 +1089,8 @@ static struct vofr_pvt *mkif(char *type, char *iface)
                tmp->dlcih = 0;
                tmp->cid = 1;
                tmp->ringgothangup = 0;
                tmp->dlcih = 0;
                tmp->cid = 1;
                tmp->ringgothangup = 0;
-               strncpy(tmp->language, language, sizeof(tmp->language));
-               strncpy(tmp->context, context, sizeof(tmp->context));
+               strncpy(tmp->language, language, sizeof(tmp->language)-1);
+               strncpy(tmp->context, context, sizeof(tmp->context)-1);
                /* User terminations are game for outgoing connections */
                if (!strcasecmp(type, "user")) 
                        tmp->outgoing = 1;
                /* User terminations are game for outgoing connections */
                if (!strcasecmp(type, "user")) 
                        tmp->outgoing = 1;
@@ -1107,7 +1119,7 @@ static struct ast_channel *vofr_request(char *type, int format, void *data)
                return NULL;
        }
        /* Search for an unowned channel */
                return NULL;
        }
        /* Search for an unowned channel */
-       if (pthread_mutex_lock(&iflock)) {
+       if (ast_pthread_mutex_lock(&iflock)) {
                ast_log(LOG_ERROR, "Unable to lock interface list???\n");
                return NULL;
        }
                ast_log(LOG_ERROR, "Unable to lock interface list???\n");
                return NULL;
        }
@@ -1119,7 +1131,7 @@ static struct ast_channel *vofr_request(char *type, int format, void *data)
                }
                p = p->next;
        }
                }
                p = p->next;
        }
-       pthread_mutex_unlock(&iflock);
+       ast_pthread_mutex_unlock(&iflock);
        restart_monitor();
        return tmp;
 }
        restart_monitor();
        return tmp;
 }
@@ -1136,7 +1148,7 @@ int load_module()
                ast_log(LOG_ERROR, "Unable to load config %s\n", config);
                return -1;
        }
                ast_log(LOG_ERROR, "Unable to load config %s\n", config);
                return -1;
        }
-       if (pthread_mutex_lock(&iflock)) {
+       if (ast_pthread_mutex_lock(&iflock)) {
                /* It's a little silly to lock it, but we mind as well just to be sure */
                ast_log(LOG_ERROR, "Unable to lock interface list???\n");
                return -1;
                /* It's a little silly to lock it, but we mind as well just to be sure */
                ast_log(LOG_ERROR, "Unable to lock interface list???\n");
                return -1;
@@ -1153,18 +1165,18 @@ int load_module()
                                } else {
                                        ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
                                        ast_destroy(cfg);
                                } else {
                                        ast_log(LOG_ERROR, "Unable to register channel '%s'\n", v->value);
                                        ast_destroy(cfg);
-                                       pthread_mutex_unlock(&iflock);
+                                       ast_pthread_mutex_unlock(&iflock);
                                        unload_module();
                                        return -1;
                                }
                } else if (!strcasecmp(v->name, "context")) {
                                        unload_module();
                                        return -1;
                                }
                } else if (!strcasecmp(v->name, "context")) {
-                       strncpy(context, v->value, sizeof(context));
+                       strncpy(context, v->value, sizeof(context)-1);
                } else if (!strcasecmp(v->name, "language")) {
                } else if (!strcasecmp(v->name, "language")) {
-                       strncpy(language, v->value, sizeof(language));
+                       strncpy(language, v->value, sizeof(language)-1);
                }
                v = v->next;
        }
                }
                v = v->next;
        }
-       pthread_mutex_unlock(&iflock);
+       ast_pthread_mutex_unlock(&iflock);
        /* Make sure we can register our AdtranVoFR channel type */
        if (ast_channel_register(type, tdesc, AST_FORMAT_G723_1, vofr_request)) {
                ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
        /* Make sure we can register our AdtranVoFR channel type */
        if (ast_channel_register(type, tdesc, AST_FORMAT_G723_1, vofr_request)) {
                ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
@@ -1183,7 +1195,7 @@ int unload_module()
        struct vofr_pvt *p, *pl;
        /* First, take us out of the channel loop */
        ast_channel_unregister(type);
        struct vofr_pvt *p, *pl;
        /* First, take us out of the channel loop */
        ast_channel_unregister(type);
-       if (!pthread_mutex_lock(&iflock)) {
+       if (!ast_pthread_mutex_lock(&iflock)) {
                /* Hangup all interfaces if they have an owner */
                p = iflist;
                while(p) {
                /* Hangup all interfaces if they have an owner */
                p = iflist;
                while(p) {
@@ -1192,25 +1204,25 @@ int unload_module()
                        p = p->next;
                }
                iflist = NULL;
                        p = p->next;
                }
                iflist = NULL;
-               pthread_mutex_unlock(&iflock);
+               ast_pthread_mutex_unlock(&iflock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        }
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        }
-       if (!pthread_mutex_lock(&monlock)) {
+       if (!ast_pthread_mutex_lock(&monlock)) {
                if (monitor_thread) {
                        pthread_cancel(monitor_thread);
                        pthread_kill(monitor_thread, SIGURG);
                        pthread_join(monitor_thread, NULL);
                }
                monitor_thread = -2;
                if (monitor_thread) {
                        pthread_cancel(monitor_thread);
                        pthread_kill(monitor_thread, SIGURG);
                        pthread_join(monitor_thread, NULL);
                }
                monitor_thread = -2;
-               pthread_mutex_unlock(&monlock);
+               ast_pthread_mutex_unlock(&monlock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        }
 
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        }
 
-       if (!pthread_mutex_lock(&iflock)) {
+       if (!ast_pthread_mutex_lock(&iflock)) {
                /* Destroy all the interfaces and free their memory */
                p = iflist;
                while(p) {
                /* Destroy all the interfaces and free their memory */
                p = iflist;
                while(p) {
@@ -1223,7 +1235,7 @@ int unload_module()
                        free(pl);
                }
                iflist = NULL;
                        free(pl);
                }
                iflist = NULL;
-               pthread_mutex_unlock(&iflock);
+               ast_pthread_mutex_unlock(&iflock);
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
        } else {
                ast_log(LOG_WARNING, "Unable to lock the monitor\n");
                return -1;
@@ -1235,12 +1247,17 @@ int unload_module()
 int usecount()
 {
        int res;
 int usecount()
 {
        int res;
-       pthread_mutex_lock(&usecnt_lock);
+       ast_pthread_mutex_lock(&usecnt_lock);
        res = usecnt;
        res = usecnt;
-       pthread_mutex_unlock(&usecnt_lock);
+       ast_pthread_mutex_unlock(&usecnt_lock);
        return res;
 }
 
        return res;
 }
 
+char *key()
+{
+       return ASTERISK_GPL_KEY;
+}
+
 char *description()
 {
        return desc;
 char *description()
 {
        return desc;