Commit Graph

32 Commits

Author SHA1 Message Date
Karsten Keil ce11bd31a3 Merge pull request #5 from kristovschulz/fix-pty-loopback
mISDNcapid: ignore incoming B3 data packets until PTY slave sent data
2017-07-24 09:15:29 +02:00
Christoph Schulz cf98743fb3 mISDNcapid: ignore incoming B3 data packets until PTY slave sent data
In hijacking mode (CAPIFLAG_HIGHJACKING), a PTY master/slave pair is created to
pass data back and forth between the application and mISDNcapid. However, there
is a small time window between creating the PTY slave and the application
opening the PTY slave. If a B3 data connection is established before the
application has opened the PTY slave, and B3 data is received and written to the
PTY master end, it is immediately read back by the B3 data receiver thread
(BCthread), which then sends the data back to the original sender, causing a
loopback. This e.g. happens when the application is the PPP daemon pppd which
has been configured to not send any data until it receives a valid LCP packet
("silent" option).

In order to fix this, an additional flag called tty_received remembers whether
the B3 data receiver thread has already read data from the PTY at least once.
Only if this is the case B3 data is written to the PTY master end, otherwise it
is discarded as there is no potential receiver at the PTY slave end yet. This
effectively avoids any loopback situations due to an unconnected PTY slave end.

Signed-off-by: Christoph Schulz <develop@kristov.de>
2017-02-27 17:47:59 +01:00
Christoph Schulz c3c05bfb63 mISDNcapid: fix B channel activation
Always sends PH_ACTIVATE_REQ and not DL_ESTABLISH_REQ down the mISDN stack when
opening a B-channel, as DL_ESTABLISH_REQ is only understood by layer-2, and
B-channel management is done at layer-1.

Signed-off-by: Christoph Schulz <develop@kristov.de>
2017-02-27 17:44:26 +01:00
Maciej S. Szmigiero e3e71a7f94 mISDNcapid: Add experimental partial early B3 support
Early B3 support is an useful functionality not only to listen to actual
exchange ringback tone but also to hear announcements like number changed,
line not provisioned, etc.

This commit adds partial early B3 support: mISDNcapid will try to open
B channel on "Call is not end-to-end ISDN; further call progress
information may be available in-band" and "In-band information or an
appropriate pattern is now available" progress indications, so CAPI
application will be able to connect to this B channel with CONNECT_B3_REQ
message.

Doing it this way needs only minimal changes to existing code - we just
need to make sure that B channel opening function ( lPLCILinkUp() )
doesn't try do it again when it is called for the second time.

Full early B3 support would need further decoupling NCCI management
from PLCI management so B channel could be opened on demand when CAPI
application issues CONNECT_B3_REQ.

While we are at it also make sure that lPLCILinkUp() function also
cleans up what it has already done when it exits early with an error.

Since this functionality is experimental it is not enabled by default -
a define needs to be uncommented at top of capi20/lplci.c to enable it.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-04-14 23:24:17 +02:00
Karsten Keil 7e1924062d Create the socket directory on runtime
Since nowadays often the /var/run is /run and is in tmpfs creating it on the fly should be
a better solution.
2016-03-29 12:31:22 +02:00
Karsten Keil c686153484 mISDNcapid: Add hint for the -d --debug parameter in help output 2016-03-15 12:53:33 +01:00
Thomas Jarosch 6c25cdacd3 Fix memory leak on read() error
Detected by cppcheck.
2015-08-01 18:06:43 +02:00
Karsten Keil bd6ea3f85f Fix overwriting ret in action loop, improve debug/error messages. 2014-10-20 14:11:35 +02:00
Karsten Keil fc757c58dc Better refcount locking to avoid use after free
Under some conditions it could be happen that on a freeing capi object
a other thread still get a reference and then it use the already freed object.
To avoid this, we do 2 things, we only take a refernce if get_obj() succeed, it
do not longer succeed if the object is already cleaned. We also force scheduling
after releaseing the lock before really freeing the object - so the waiting thread
will not get a new reference.
2014-10-14 14:39:44 +02:00
Karsten Keil 43cd10a657 Better debugging for descriptor leaks and fixing application release leak 2014-09-22 01:35:42 +02:00
Karsten Keil d927b710c6 Mutex should be unlocked before setting bi to NULL - fix SEGFAULT 2014-09-15 08:32:05 +02:00
Karsten Keil dee4e5684a Try to fix filedescriptor leak and add additional debug output to get more info about the leak 2014-09-09 12:55:50 +02:00
Karsten Keil 2f83a0448f Inform all applications about incoming calls before handling responses
Implement a method to disable temporary messages from applications to
synchronize the delivery of a incoming call. It is important, that
all listening application get informed before the first answer was handled.

Signed-off-by: Karsten Keil <keil@b1-systems.de>
2012-09-16 18:30:45 +02:00
Karsten Keil 9252f4080c Really use refcounting for the dynamic objects
Add listing dangling objects via SIGUSR2.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-09-13 14:36:55 +02:00
Karsten Keil 9f5e9dc1c9 Add dumping status information via SIGUSR1 into the debug file
Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-09-13 14:35:54 +02:00
Karsten Keil c594a8bbc1 Fix B-channel thread shutdown
- Add a timeout in the B-channel handler to catch a broken
  downlinks on release
- Do not join the own thread
- pthread functions return error directly, not via errno
- better debug messages

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-08-30 08:47:20 +02:00
Karsten Keil 68c1ccb816 RW locking for lists in capi structs
To avoid races and segfaults on cleardown introduce
locking for main lists.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-07-31 19:23:09 +02:00
Karsten Keil 376ab1d56d Fix crash on wrong message length
If a CAPI message was bigger as it was indicated, the buffer
length was not set at all. Now use the indicated length.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-05-13 19:23:42 +02:00
Karsten Keil 17c2de7e19 Fix listen for more as one application
Fix issues that CIPmask got reset to zero and now
we are removing unused logical contrllers if a
application was deleted.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-03-21 15:22:40 +01:00
Karsten Keil d010a8996c Set mISDNcapi egid to MISDN_GROUP
To allow access to the filesystem socket the effective group is changed
to the MISDN_GROUP, which is uucp or dialout usually.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-03-21 15:19:45 +01:00
Karsten Keil 7eaf74738f Allow group access to the unix socket
Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-03-01 20:07:04 +01:00
Karsten Keil 4506e66db0 mISDNcapid version 0.9
- Fixed all issues found by valgrind
- Fixed all memory leaks
- Add signal handler for clean shutdown (SIGTERM, SIGHUP, SIGINT)

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-01-30 19:05:17 +01:00
Karsten Keil 32af7ded3f Fix write without checking return value
Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2011-12-09 16:42:28 +01:00
Karsten Keil cb15111c92 Fix more gcc warnings
Signed-off-by: Karsten Keil <kkeil@lakepri-test.linux-pingi.de>
2011-12-09 13:59:55 +01:00
Karsten Keil ab44464d37 Merge branch 'capi' of ssh://git.misdn.eu/mISDNuser-devel into capi 2011-12-09 13:55:34 +01:00
Karsten Keil 5bf62c68de Fixed unused return value
Newer gcc are more picky.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2011-12-09 13:53:46 +01:00
Karsten Keil 74e5ceb762 Implement pseudo tty mode
This is needed for pppdcapiplugin.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2011-12-09 13:04:51 +01:00
Karsten Keil e1555b96bd Add some tests
- reduce unconditional debug output
2011-11-28 14:34:55 +01:00
Karsten Keil 4c02448833 CAPI20 fax support
- use spandsp
- allows send/receive fax in TIFF format or SFF format (CAPI default)

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2011-11-25 16:36:12 +01:00
Karsten Keil 7adb7b8017 Allow different B data handler
Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2011-10-29 15:13:58 +02:00
Karsten Keil c597f456b5 CAPI 2.0 for voice
The CAPI 2.0 interface now allows voice calls and
fax with capifax (with spandsp).

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2011-10-28 12:58:42 +02:00
Karsten Keil e1916e0240 Add CAPI 2.0 support
Add first files for CAPI 2.0 support.
Not finished yet.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2011-10-20 18:34:37 +02:00