Fixed typo
[lcr.git] / port.cpp
index 74f8aac..8fed914 100644 (file)
--- a/port.cpp
+++ b/port.cpp
@@ -149,8 +149,6 @@ Port::Port(int type, const char *portname, struct port_settings *settings)
 {
        class Port *temp, **tempp;
 
-       PDEBUG(DEBUG_PORT, "new port of type 0x%x, name '%s'\n", type, portname);
-
        /* initialize object */
        if (settings)
                memcpy(&p_settings, settings, sizeof(struct port_settings));
@@ -195,6 +193,8 @@ Port::Port(int type, const char *portname, struct port_settings *settings)
        *tempp = this;
 
        classuse++;
+
+       PDEBUG(DEBUG_PORT, "new port (%d) of type 0x%x, name '%s'\n", p_serial, type, portname);
 }
 
 
@@ -206,7 +206,7 @@ Port::~Port(void)
        class Port *temp, **tempp;
        struct lcr_msg *message;
 
-       PDEBUG(DEBUG_PORT, "removing port of type 0x%x, name '%s'\n", p_type, p_name);
+       PDEBUG(DEBUG_PORT, "removing port (%d) of type 0x%x, name '%s'\n", p_serial, p_type, p_name);
 
        if (p_bridge) {
                PDEBUG(DEBUG_PORT, "Removing us from bridge %u\n", p_bridge->bridge_id);
@@ -301,7 +301,7 @@ void Port::set_tone(const char *dir, const char *name)
        if (name == NULL)
                name = "";
 
-       if (!dir && !dir[0])
+       if (!dir || !dir[0])
                dir = options.tones_dir; /* just in case we have no PmISDN instance */
 
        /* no counter, no eof, normal speed */
@@ -1264,23 +1264,31 @@ void Port::bridge(unsigned int bridge_id)
        p_bridge = NULL;
 }
 
-/* send data to remote Port */
-int Port::bridge_tx(unsigned char *data, int len)
+class Port *Port::bridge_remote(void)
 {
-       class Port *to_port = NULL;
+       class Port *remote = NULL;
 
        /* get remote port from bridge */
        if (!p_bridge)
-               return -EINVAL;
+               return NULL;
        if (p_bridge->sunrise == this)
-               to_port = p_bridge->sunset;
+               remote = p_bridge->sunset;
        if (p_bridge->sunset == this)
-               to_port = p_bridge->sunrise;
-       if (!to_port)
+               remote = p_bridge->sunrise;
+
+       return remote;
+}
+
+/* send data to remote Port */
+int Port::bridge_tx(unsigned char *data, int len)
+{
+       class Port *remote = bridge_remote();
+
+       if (!remote)
                return -EINVAL;
 
-//     printf("Traffic: %u -> %u (bridge %u)\n", p_serial, to_port->p_serial, p_bridge->bridge_id);
-       return to_port->bridge_rx(data, len);
+//     printf("Traffic: %u -> %u (bridge %u)\n", p_serial, remote->p_serial, p_bridge->bridge_id);
+       return remote->bridge_rx(data, len);
 }
 
 /* receive data from remote Port (dummy, needs to be inherited) */