Commit Graph

88 Commits

Author SHA1 Message Date
Karsten Keil 234e9bc9ce Fix none existing octets 5b1/5b2 in bearer capabilities
Here exist two differnt content versions of octet 5b in bearer capabilities
but only alternatively depending on the L1 protocol, so we only need one octet 5b here.
2017-07-30 22:29:24 +02:00
Karsten Keil 002a6e4bcb Merge pull request #6 from kristovschulz/fix-release-link
mISDNcapid: release B3 link properly when using CAPIFLAG_HIGHJACKING
2017-07-24 09:15:42 +02:00
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
Karsten Keil 6cdc34ef49 Merge pull request #4 from kristovschulz/fix-lplci-disconnect
mISDNcapid: fix lPLCIDisconnectInd() by returning zero when B3 link is missing
2017-07-24 09:14:57 +02:00
Karsten Keil acd627c996 Merge pull request #3 from kristovschulz/fix-bchannel-activation
mISDNcapid: fix B channel activation
2017-07-24 09:14:12 +02:00
Christoph Schulz 0d7fc6fd37 mISDNcapid: fix memory leak when using CAPIFLAG_HIGHJACKING
If using a tty for sending/receiving B3 data, the mc buffer for data sent is
not freed by ncciDataConf() because this is done only by AnswerDataB3Req()
which is not called when using a tty. Fix this by explicitly freeing the mc
buffer when a tty is used.

Signed-off-by: Christoph Schulz <develop@kristov.de>
2017-02-27 17:48:37 +01:00
Christoph Schulz be0f62c087 mISDNcapid: release B3 link properly when using CAPIFLAG_HIGHJACKING
Until now, B3ReleaseLink() did not care about BType_tty B3 links. This commit
makes them behave like BType_Direct links.

Signed-off-by: Christoph Schulz <develop@kristov.de>
2017-02-27 17:48:24 +01: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 86da1e4546 mISDNcapid: fix lPLCIDisconnectInd() by returning zero when B3 link is missing
The function lPLCIDisconnectInd() is called by plci_cc_disconnect_ind() when a
EV_L3_DISCONNECT_IND event is being handled. If the B3 link has already gone,
lPLCIDisconnectInd() returns -ENODEV, which prevents plci_cc_disconnect_ind()
from calling lPLCILinkDown() and therefore from cleaning up properly. This
commit makes lPLCIDisconnectInd() returns zero (i.e. success) in such a
situation.

Signed-off-by: Christoph Schulz <develop@kristov.de>
2017-02-27 17:45:58 +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 21b8c52a64 mISDNcapid: Parse B channel id first from message then its included IEs
If early B3 is enabled we are currently opening channel B on appropriate
"Progress" IE.

If it turns out that this IE arrives in the same message that also sets
which B channel should be used the current code will fail to open
the B channel for early B3 as the current order is to first handle the IEs
then parse channel id.

Change this to first parse the B channel id then handle the IEs so in such
situation the B channel id will already be set at "Progress" IE handling
time.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-04-14 23:41:43 +02: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
Maciej S. Szmigiero 6e79260425 mISDNcapid: Send also second and next IEs as INFO_IND to CAPI application
According to Q.931 (05/98) some of variable length information elements
may occur more than once in a message.

parseQ931() from mISDN layer3 library would store such second and next
occurrence of particular IE in an "extra" array of l3 struct.

This commit adds support for sending these repeated IEs to mISDNcapid
INFO_IND IE posting function ( lPLCIInfoIndIE() ) so they will be
available to CAPI applications.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-04-14 00:35:26 +02:00
Maciej S. Szmigiero a50c5b93da mISDNcapid: Fix INFO_IND IE posting function early return condition
lPLCIInfoIndIE() in lplci.c returned early when mc->l3m was set and
continued execution when it was NULL, however from code further in this
function it is clear that opposite behavior was meant.

This caused CAPI applications to not receive INFO_IND with information
elements, as this function was no-op when called correctly.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-04-13 23:33:05 +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
Maciej S. Szmigiero b4b3e62516 Fix CAPI-initiated disconnection in direct layer 1 mode
When CAPI application asks for B3 disconnection the NCCI state machine
sends disconnect request further down the stack and then goes into N_4
state waiting for disconnection confirmation.

If B channel was in direct layer 1 mode the disconnect request will be
sent as PH_DEACTIVATE_REQ which will go all the way down to an individual
mISDN chip driver.

It looks like all current chip drivers reply to such requests by sending
only PH_DEACTIVATE_IND message, however the state machine in N_4 state
only reacts to PH_DEACTIVATE_CNF message (translated into
EV_DL_RELEASE_CONF).

This means that such call will get stuck until remote side disconnects it.

Fix this by reacting to PH_DEACTIVATE_IND message also in N_4 state,
just like it is done in N_ACT state.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-03-13 18:54:03 +01:00
Maciej S. Szmigiero 06ed113c3d Use Reject parameter for deciding what happens to call via CONNECT_B3_RESP
CAPI specs say that CONNECT_B3_RESP message uses Reject parameter for
deciding what happens to incoming connection, however mISDNcapid code
used Info instead.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-03-13 18:52:55 +01:00
Maciej S. Szmigiero 4caaa5ac72 Parse channel information from CALL PROCEEDING message too in mISDNcapid
According to Q.931 (05/98) on user-originated calls that did not select
a particular B channel in a SETUP message the selected B channel is sent
in a first message returned by the network in a response to
the SETUP message.

This Recommendation explicitly mentions SETUP ACKNOWLEDGE or
CALL PROCEEDING as examples of such response messages, however mISDNcapid
code ignored channel indication in CALL PROCEEDING messages.

This resulted in a no channel selected error on outgoing calls
on exchanges that reply with CALL PROCEEDING to SETUP.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-03-13 18:52:16 +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 d9a97bb810 Lock refcnt changes for Root objects too
In theory the Root object are never freed so the refcounting is not critical, but it should also not harm
to protect it to avoid wrong refcounts.
2014-10-03 17:27:11 +02:00
Karsten Keil 70c61ca931 Some debug to detect use after free 2014-10-03 16:52:20 +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
Joerg Dorchain 3293be0592 Fix compile error when configured --disable-softdsp 2012-12-05 10:40:19 +01:00
Karsten Keil 5d36b4e2b1 Release FAX call imediately if never received anything
Signed-off-by: Karsten Keil <keil@b1-systems.de>
2012-09-17 00:46:18 +02:00
Karsten Keil 3d596e2ace Only the highest matched bit position gives the CIP value
CAPI 2.0 spec defines the CIP value indicated by CONNECT_IND
als highest matched bit position, not the higest CIP value
calculated from bearer + HLC info.
This bug caused that if a application did not request listening
for some of the higher bit values a not requested CIP was sent, so the
call was ignored.

Signed-off-by: Karsten Keil <keil@b1-systems.de>
2012-09-17 00:01:49 +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 469b9b5f6b Fix Segmentationfault with unattended calls
if a call was not taken by an application and multiple applications
are listening, it could happen that the PLCI was deleted before we
did sent the CONNECT_IND to all applications.

Signed-off-by: Karsten Keil <keil@b1-systems.de>
2012-09-16 10:44:10 +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 18e7679a58 Make the current version compatible to recent kernel stuff
Also allow backward compatibility to older standalone kernel drivers.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-09-13 14:36:08 +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 c89f4f31da Release ncci and fax struct on a not successful Fax call
We did lost memory when no fax was tranfered on a fax call.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-08-30 08:46:54 +02:00
Karsten Keil 7994aa6305 More checks and locking to avoid access to released BIlink
Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-08-30 08:46:09 +02:00
Karsten Keil 657cfb1e01 Fix error path on failed FaxInit
Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-08-30 08:43:14 +02:00
Karsten Keil f66da21a40 Fix extracting a CIP mask from incoming calls
Not only the bit of the cip value has to be set, also
the more generic bearer service bit (not depending on HLC)
need to be set.
Without the fix valid calls got ignored.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-08-30 08:39:01 +02:00
Karsten Keil 7db4a56a06 Use proper cause defines
Add CAUSE_FACILITY_REJECTED to defined cause values.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-08-30 08:00:19 +02:00
Karsten Keil debd47d018 Remove autogenerated files
Many users difd report problems to compile this package because
they had installed different versions of the autotools.
From now it is not longer possible to compile this package without
having autotools installed.

You can generate the the autotool files simply with running 'make'.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-08-02 12:46:39 +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 7c5fb25ef2 Version 2.0.14
Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-07-26 15:16:28 +02:00
Karsten Keil a24737fa8b Changes for auto files
Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-05-30 18:53:31 +02:00
Jānis Rukšāns cb3126f001 Honour installation directories passed to configure
Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-05-30 18:48:25 +02:00
Karsten Keil 78179356a6 Avoid crash in get_lPLCI4Id()
Maybe in a race on setup/cleanup the links
are broken.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-05-24 15:25:48 +02:00
Karsten Keil 30deb395fc Fix wrong format
The usually value for lpi is 98.0 not 96.0, use
100.0 as limit for fine resolution.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-05-22 22:29:32 +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 e1e4b94a01 Fix double NCCI allocation
The capi thread or the B-channel worker thread can create the faxcontext. We need a lock
to protect the operation, sometimes we did create 2 NCCIs.

Signed-off-by: Karsten Keil <kkeil@linux-pingi.de>
2012-05-13 16:27:17 +02:00