LCR now compiles with current version of OpenBSC.
[lcr.git] / endpoint.cpp
index b5d6f64..28ea12f 100644 (file)
@@ -9,10 +9,9 @@
 **                                                                           **
 \*****************************************************************************/ 
 
-#include <stdio.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;
 
@@ -20,12 +19,11 @@ class Endpoint *epoint_first = NULL;
 /*
  * 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;
 
-       while(epoint)
-       {
+       while(epoint) {
 //printf("comparing: '%s' with '%s'\n", name, epoint->name);
                if (epoint->ep_serial == epoint_id)
                        return(epoint);
@@ -39,7 +37,7 @@ class Endpoint *find_epoint_id(unsigned long epoint_id)
 /*
  * endpoint constructor (link with either port or join id)
  */
-Endpoint::Endpoint(unsigned long port_id, unsigned long join_id, unsigned long use_epoint_id)
+Endpoint::Endpoint(unsigned int port_id, unsigned int join_id)
 {
        class Port *port;
        class Endpoint **epointpointer;
@@ -60,18 +58,13 @@ Endpoint::Endpoint(unsigned long port_id, unsigned long join_id, unsigned long u
        *epointpointer = this;
 
        /* serial */
-       if (use_epoint_id)
-               ep_serial = use_epoint_id;
-       else
-               ep_serial = epoint_serial++;
+       ep_serial = epoint_serial++;
 
        /* link to join or port */
-       if (port_id)
-       {
+       if (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");
@@ -101,17 +94,14 @@ Endpoint::~Endpoint(void)
                delete ep_app;
        
        /* free relations */
-       if (ep_join_id)
-       {
+       if (ep_join_id) {
                PERROR("warning: still relation to join.\n");
        }
 
        /* 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;
@@ -124,8 +114,7 @@ Endpoint::~Endpoint(void)
        /* detach */
        temp =epoint_first;
        tempp = &epoint_first;
-       while(temp)
-       {
+       while(temp) {
                if (temp == this)
                        break;
 
@@ -142,7 +131,7 @@ Endpoint::~Endpoint(void)
 
 /* 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;
 
@@ -175,8 +164,7 @@ void Endpoint::free_portlist(struct port_list *portlist)
 
        temp = ep_portlist;
        tempp = &ep_portlist;
-       while(temp)
-       {
+       while(temp) {
                if (temp == portlist)
                        break;
 
@@ -199,8 +187,7 @@ void Endpoint::free_portlist(struct port_list *portlist)
  */
 int Endpoint::handler(void)
 {
-       if (ep_use <= 0)
-       {
+       if (ep_use <= 0) {
                delete this;
                return(-1);
        }