projects
/
lcr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
See commit 728d... It was not applied correctly.
[lcr.git]
/
endpoint.cpp
diff --git
a/endpoint.cpp
b/endpoint.cpp
index
819f779
..
cda79c2
100644
(file)
--- a/
endpoint.cpp
+++ b/
endpoint.cpp
@@
-1,18
+1,17
@@
/*****************************************************************************\
** **
/*****************************************************************************\
** **
-**
PBX4Linux
**
+**
Linux Call Router
**
** **
**---------------------------------------------------------------------------**
** Copyright: Andreas Eversberg **
** **
** **
**---------------------------------------------------------------------------**
** Copyright: Andreas Eversberg **
** **
-** The Endpoint is the link between the
call
and the port. **
+** The Endpoint is the link between the
join
and the port. **
** **
\*****************************************************************************/
** **
\*****************************************************************************/
-#include <stdio.h>
#include "main.h"
#include "main.h"
-unsigned
long
epoint_serial = 1; /* initial value must be 1, because 0== no epoint */
+unsigned
int
epoint_serial = 1; /* initial value must be 1, because 0== no epoint */
class Endpoint *epoint_first = NULL;
class Endpoint *epoint_first = NULL;
@@
-20,12
+19,11
@@
class Endpoint *epoint_first = NULL;
/*
* find the epoint with epoint_id
*/
/*
* find the epoint with epoint_id
*/
-class Endpoint *find_epoint_id(unsigned
long
epoint_id)
+class Endpoint *find_epoint_id(unsigned
int
epoint_id)
{
class Endpoint *epoint = epoint_first;
{
class Endpoint *epoint = epoint_first;
- while(epoint)
- {
+ while(epoint) {
//printf("comparing: '%s' with '%s'\n", name, epoint->name);
if (epoint->ep_serial == epoint_id)
return(epoint);
//printf("comparing: '%s' with '%s'\n", name, epoint->name);
if (epoint->ep_serial == epoint_id)
return(epoint);
@@
-35,21
+33,24
@@
class Endpoint *find_epoint_id(unsigned long epoint_id)
return(NULL);
}
return(NULL);
}
+int delete_endpoint(struct lcr_work *work, void *instance, int index);
/*
/*
- * endpoint constructor (link with either port or
call
id)
+ * endpoint constructor (link with either port or
join
id)
*/
*/
-Endpoint::Endpoint(unsigned
long port_id, unsigned long call_id, unsigned long use_epoint
_id)
+Endpoint::Endpoint(unsigned
int port_id, unsigned int join
_id)
{
class Port *port;
class Endpoint **epointpointer;
int earlyb = 0;
/* epoint structure */
{
class Port *port;
class Endpoint **epointpointer;
int earlyb = 0;
/* epoint structure */
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): Allocating enpoint %d and connecting it with:%s%s\n", epoint_serial, epoint_serial, (port_id)?" ioport":"", (
call_id)?" call
":"");
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): Allocating enpoint %d and connecting it with:%s%s\n", epoint_serial, epoint_serial, (port_id)?" ioport":"", (
join_id)?" join
":"");
ep_portlist = NULL;
ep_app = NULL;
ep_portlist = NULL;
ep_app = NULL;
+ memset(&ep_delete, 0, sizeof(ep_delete));
+ add_work(&ep_delete, delete_endpoint, this, 0);
ep_use = 1;
/* add endpoint to chain */
ep_use = 1;
/* add endpoint to chain */
@@
-60,24
+61,19
@@
Endpoint::Endpoint(unsigned long port_id, unsigned long call_id, unsigned long u
*epointpointer = this;
/* serial */
*epointpointer = this;
/* serial */
- if (use_epoint_id)
- ep_serial = use_epoint_id;
- else
- ep_serial = epoint_serial++;
-
- /* link to call or port */
- if (port_id)
- {
+ ep_serial = epoint_serial++;
+
+ /* link to join or port */
+ if (port_id) {
port = find_port_id(port_id);
port = find_port_id(port_id);
- if (port)
- {
- if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1)
+ if (port) {
+ if ((port->p_type&PORT_CLASS_MASK) == PORT_CLASS_mISDN)
earlyb = ((class PmISDN *)port)->p_m_mISDNport->earlyb;
if (!portlist_new(port_id, port->p_type, earlyb))
FATAL("No memory for portlist.\n");
}
}
earlyb = ((class PmISDN *)port)->p_m_mISDNport->earlyb;
if (!portlist_new(port_id, port->p_type, earlyb))
FATAL("No memory for portlist.\n");
}
}
- ep_
call_id = call
_id;
+ ep_
join_id = join
_id;
ep_park = 0;
ep_park_len = 0;
ep_park = 0;
ep_park_len = 0;
@@
-101,17
+97,14
@@
Endpoint::~Endpoint(void)
delete ep_app;
/* free relations */
delete ep_app;
/* free relations */
- if (ep_call_id)
- {
- PERROR("warning: still relation to call.\n");
+ if (ep_join_id) {
+ PERROR("warning: still relation to join.\n");
}
/* free portlist */
portlist = ep_portlist;
}
/* free portlist */
portlist = ep_portlist;
- while(portlist)
- {
- if (portlist->port_id)
- {
+ while(portlist) {
+ if (portlist->port_id) {
PERROR("warning: still relation to port (portlist list)\n");
}
mtemp = portlist;
PERROR("warning: still relation to port (portlist list)\n");
}
mtemp = portlist;
@@
-124,8
+117,7
@@
Endpoint::~Endpoint(void)
/* detach */
temp =epoint_first;
tempp = &epoint_first;
/* detach */
temp =epoint_first;
tempp = &epoint_first;
- while(temp)
- {
+ while(temp) {
if (temp == this)
break;
if (temp == this)
break;
@@
-136,13
+128,15
@@
Endpoint::~Endpoint(void)
FATAL("Endpoint not in Endpoint's list.\n");
*tempp = next;
FATAL("Endpoint not in Endpoint's list.\n");
*tempp = next;
+ del_work(&ep_delete);
+
/* free */
PDEBUG(DEBUG_EPOINT, "removed endpoint %d.\n", ep_serial);
}
/* create new portlist relation
*/
/* free */
PDEBUG(DEBUG_EPOINT, "removed endpoint %d.\n", ep_serial);
}
/* create new portlist relation
*/
-struct port_list *Endpoint::portlist_new(unsigned
long
port_id, int port_type, int earlyb)
+struct port_list *Endpoint::portlist_new(unsigned
int
port_id, int port_type, int earlyb)
{
struct port_list *portlist, **portlistpointer;
{
struct port_list *portlist, **portlistpointer;
@@
-158,7
+152,7
@@
struct port_list *Endpoint::portlist_new(unsigned long port_id, int port_type, i
portlistpointer = &((*portlistpointer)->next);
*portlistpointer = portlist;
portlistpointer = &((*portlistpointer)->next);
*portlistpointer = portlist;
- /* link to
call
or port */
+ /* link to
join
or port */
portlist->port_id = port_id;
portlist->port_type = port_type;
portlist->early_b = earlyb;
portlist->port_id = port_id;
portlist->port_type = port_type;
portlist->early_b = earlyb;
@@
-175,8
+169,7
@@
void Endpoint::free_portlist(struct port_list *portlist)
temp = ep_portlist;
tempp = &ep_portlist;
temp = ep_portlist;
tempp = &ep_portlist;
- while(temp)
- {
+ while(temp) {
if (temp == portlist)
break;
if (temp == portlist)
break;
@@
-195,18
+188,13
@@
void Endpoint::free_portlist(struct port_list *portlist)
}
}
-/* handler for endpoint
- */
-int Endpoint::handler(void)
+int delete_endpoint(struct lcr_work *work, void *instance, int index)
{
{
- if (ep_use <= 0)
- {
- delete this;
- return(-1);
- }
+ class Endpoint *ep = (class Endpoint *)instance;
- /* call application handler */
- if (ep_app)
- return(ep_app->handler());
- return
(0)
;
+ if (ep->ep_use <= 0)
+ delete ep;
+
+ return
0
;
}
}
+