[En-Nut-Discussion] PPP/AHDLC logic problems...

Vesa Jääskeläinen chaac at nic.fi
Sat Apr 16 21:05:53 CEST 2005


Hi,

I have been trying to solve problem with closing PPP connection and then 
issuing hangup sequence and continuing using it for normal AT commands 
and perhaps create another PPP connection.

First problem I see here is to close PPP-connection. I am using 
following to close it:

_ioctl(pppcom, LCP_CLOSE, 0);
//_ioctl(pppcom, LCP_LOWERDOWN, 0);
if (pppcom != -1)
{
     _close(pppcom);
     pppcom = -1;
}

// Reopen device
// _open()...
// hangup sequence here

Now problem with _close() is that it only closes IPCP and not LCP. So I 
need to shutdown LCP either by LCP_CLOSE/LCP_LOWERDOWN.

After this ahdlc thread is still handling all characters from USART. 
There is bug in this routine as it never allows leaving the loop. So if 
I add following patch to ahdlcavr.c, ...

-----
diff -u -r1.8 ahdlcavr.c
--- ahdlcavr.c  5 Apr 2005 17:44:56 -0000       1.8
+++ ahdlcavr.c  16 Apr 2005 18:52:02 -0000
@@ -438,6 +438,9 @@
                  }
              }

+            if (dev->dev_icb == 0)
+                break;
+
              ch = dcb->dcb_rx_buf[dcb->dcb_rd_idx++];

              if (inframe) {
-----

... there is even possibility that it gets out of that loop. After a 
timeout or received character it would exit that loop, this waiting 
could also be triggered in _ioctl HDLC_SETIFNET, but the problem is that 
no-one is calling it...

Is there someone with more knowledge where would be correct place to fix 
this? I will continue to evaluate this myself, but if someone has more 
information about it's internals I would be pleased to hear about them. 
If I just call this ioctl myself, I get reboots and that ain't nice.

In my opinion there is at least a bug in PPP as it doesn't lower LCP on 
closing and I need to manually to do that. There is one _ioctl(fd, 
HDLC_SETIFNET, 0) in PPP's state machine, but that state is never 
reached in my tests.

Thanks,
Vesa Jääskeläinen



More information about the En-Nut-Discussion mailing list