Commit Graph

465 Commits

Author SHA1 Message Date
Harald Welte ca72be85e9 sff.c: Fix compiler warnings about old uint32 type
sff.c:509:9: error: ‘uint32’ is deprecated [-Werror=deprecated-declarations]
2022-04-03 15:56:47 +02:00
Harald Welte 3bce40c22a Disable -Werror for array-bounds
Otherwise the library won't build with gcc-11.2

In file included from misc/mbuffer.c:21:
misc/mbuffer.c: In function ‘alloc_mbuffer’:
../include/mISDN/mbuffer.h:160:14: error: array subscript ‘struct mbuffer[0]’ is partly outside array bounds of ‘struct mqueue[1]’ [-Werror=array-bounds]
  160 |         next = prev->next;
      |         ~~~~~^~~~~~~~~~~~
2022-03-13 15:19:56 +01:00
Harald Welte b718bf65e4 capi20/alaw: Use 'extern' to avoid multiple definition
The library fails to compile with gcc-11.2 as 'extern' is missing from
forward declaration of global variables.

/usr/bin/ld: faxl3.o:mISDNuser/capi20/alaw.h:7: multiple definition of `alaw2lin'; daemon.o:mISDNuser/capi20/alaw.h:7: first defined here
/usr/bin/ld: faxl3.o:mISDNuser/capi20/alaw.h:6: multiple definition of `slin2alaw'; daemon.o:mISDNuser/capi20/alaw.h:6: first defined here
/usr/bin/ld: faxl3.o:mISDNuser/capi20/alaw.h:5: multiple definition of `lin2alaw'; daemon.o:mISDNuser/capi20/alaw.h:5: first defined here
/usr/bin/ld: alaw.o:mISDNuser/capi20/alaw.h:5: multiple definition of `lin2alaw'; daemon.o:mISDNuser/capi20/alaw.h:5: first defined here
/usr/bin/ld: alaw.o:mISDNuser/capi20/alaw.h:6: multiple definition of `slin2alaw'; daemon.o:mISDNuser/capi20/alaw.h:6: first defined here
/usr/bin/ld: alaw.o:mISDNuser/capi20/alaw.h:7: multiple definition of `alaw2lin'; daemon.o:mISDNuser/capi20/alaw.h:7: first defined here
2022-03-13 15:13:23 +01:00
Harald Welte 09b37dd814 mlayer3: Improve English language log message
"device do not" is incorrect, "device does not" or "doesn't" is correct.
2022-03-13 15:03:50 +01:00
Harald Welte 465dec0d27 cosmetic: Fix typo in comment 2022-03-13 15:02:31 +01:00
Harald Welte 4d45ae8289 bridge.c: Fix some int vs. unsigned long type error
not only is it a signed/unsigned error, but on some architectures the
sizes of those two types are not identical, leading to a buffer overflow
on the stack. gcc-11.2 is complaining about it:

bridge.c: In function ‘ph_control’:
bridge.c:159:9: error: array subscript 2 is outside array bounds of ‘unsigned char[16]’ [-Werror=array-bounds]
  159 |         *d++ = c2;
      |         ^~~~
bridge.c:150:23: note: while referencing ‘data’
  150 |         unsigned char data[MISDN_HEADER_LEN+sizeof(int)+sizeof(int)];
      |                       ^~~~
2022-03-13 14:53:24 +01:00
Karsten Keil d6818dd9a4
Merge pull request #10 from kristovschulz/remove-timeout-warning
mISDNcapid: remove irritating timeout warning
2019-02-27 00:27:01 +01:00
Christoph Schulz b45d87e52b mISDNcapid: remove irritating timeout warning
The loop within BCthread() continuously emits a warning like the following one

  BCthread(24062):Bchannel1 timeout (release not pending) thread=24062

every 500 ms as long as no data is received over the B-channel. This is very
irritating and noisy and fills up the log file without a good reason. This
commit lets the warning be shown only if the timeout occurs while a release
operation is pending (and this is worth a warning because such a timeout does
not occur under normal circumstances).

Signed-off-by: Christoph Schulz <develop@kristov.de>
2019-02-13 00:00:18 +01:00
Karsten Keil 710b87dcb9 Fix possible buffer overflows detected by newer GCC versions
GCC reports problems like this:

gcc -DHAVE_CONFIG_H -I. -I../include -I../include -Wall -Werror -I./include -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -MT layer3/q931.lo -MD -MP -MF layer3/.deps/q931.Tpo -c layer3/q931.c  -fPIC -DPIC -o layer3/.libs/q931.o
In file included from /usr/include/string.h:494,
                 from layer3/q931.c:22:
In function ‘strncpy’,
    inlined from ‘mi_encode_redirecting_nr’ at layer3/q931.c:531:3:
/usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ forming offset [25, 31] is out of the bounds [0, 24] of object ‘ie’ with type ‘unsigned char[24]’ [-Werror=array-bounds]
   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks to Tobias Powalowski for reporting this
This commit fixes issue #9 on github.
2018-07-18 07:27:41 +02:00
Karsten Keil e5088699fb
Merge pull request #8 from christian-intra2net/signal-handlers
Signal handlers
2018-06-28 07:39:14 +02:00
Christian Herdtweck a28cb6bc53 Move code from SIGUSR (dump) and SIGTERM signal handlers
There is a very limited list of functions one is allowed to call from a
signal handler (see "man 7 signal"). This list does not include
va_{start,end} required by iprint. Therefore, this commit moves calls to
dump_* from the dumpHandler and the iprint from termHandler to
main_control.

For dumping, this required two new constants MICD_CTRL_DUMP_{1,2}

Note: calling send_master_control from a signal handler is only safe with
argument len==0, because otherwise malloc(), memcpy() and free() would be
called which are VERY unsafe.
2018-06-25 12:34:48 +02:00
Christian Herdtweck 4f7cea4028 Create signal handler for capi20: SIGHUP re-opens debug log file
Create a signal handler just like the termHandler, that sends a new flag
(MICD_CTRL_REOPEN_LOG) to the master control queue. Once main control
encounters that flag, it flushes and closes the debug log file and
re-opens it.
2018-06-25 12:04:51 +02:00
Karsten Keil 0f8548b3d2 Version 2.0.22 2017-07-30 22:30:27 +02:00
Karsten Keil 488c9ea1c8 logger: Fix bearer octet 5 decoding 2017-07-30 22:29:26 +02:00
Karsten Keil c9e711960b Some more const declarations since some crosscompilers are more picky here 2017-07-30 22:29:26 +02:00
Karsten Keil 25c7d7bbf5 Add missing AM_PROG_AR 2017-07-30 22:29:26 +02:00
Thomas Jarosch bdb5d3903c Include misdnlogger.conf.sample in make dist 2017-07-30 22:29:25 +02:00
Karsten Keil 5875f14832 Add LLC logging 2017-07-30 22:29:25 +02:00
Karsten Keil 9097f56457 Support more infoelements and repeated infoelements 2017-07-30 22:29:25 +02:00
Karsten Keil 7d12683f36 export l3_ie2pos() and l3_pos2ie() 2017-07-30 22:29:25 +02:00
Karsten Keil 3c6665d794 Install misdnlogger.conf.sample as default 2017-07-30 22:29:25 +02:00
Karsten Keil d263d37f77 add flex artefact ylwrap 2017-07-30 22:29:25 +02:00
Karsten Keil 46b4dd6a25 Add new misdlogger related artefacts 2017-07-30 22:29:25 +02:00
Karsten Keil 56c333ab10 Export parseQ931 2017-07-30 22:29:24 +02:00
Karsten Keil cc80463f23 First working version of misdnlogger 2017-07-30 22:29:24 +02:00
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 4be89daf43 Call logger first not working skeleton version 2017-07-30 22:29:24 +02:00
Karsten Keil 79f85a5f96 Set version to 2.0.21 2017-07-30 22:29:24 +02:00
Karsten Keil ae15977c06 Remove duplicated const const (detected by gcc 7 warning)
Signed-off-by: Karsten Keil <keil@b1-systems.de>
2017-07-24 09:21:13 +02:00
Karsten Keil 9f5d377216 Make intermediate version 2.0.20
Signed-off-by: Karsten Keil <keil@b1-systems.de>
2017-07-24 09:21:13 +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
Karsten Keil bf6813426b Merge pull request #2 from kristovschulz/fix-tty-mc-leak
mISDNcapid: fix memory leak when using CAPIFLAG_HIGHJACKING
2017-07-24 09:12:41 +02:00
Karsten Keil f732c35c3d Ignore autogenerated capi20/m_capi_sock.h
Signed-off-by: Karsten Keil <keil@b1-systems.de>
2017-06-11 12:16:15 +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
Karsten Keil 1acabc5db3 Set theme jekyll-theme-merlot 2017-02-26 19:58:40 +01:00
Martin Bachem a29326031e testlayer1: polling sockets faster, sleep after bind, etc 2016-06-30 14:29:43 +02:00
Martin Bachem 1bade6d562 testlayer1 starts average rate counter at once for all channels 2016-06-20 15:33:35 +02:00
Martin Bachem b76e29c8c3 layer1 channel activate/deactivate stress test 2016-06-09 17:52:40 +02: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
Maciej S. Szmigiero 0cac6f5176 testlayer3: Normalize successful write() return value in bch_worker()
bch_worker() on {DL,PH}_DATA_IND returns what write() call has returned.
This function returns number of bytes written, however bch_worker() caller
main_worker() treats any non-zero return value of bch_worker() as signal
to disconnect the call.

This all meant that call terminated on first received chunk of data.

Fix it by normalizing a positive return value of write() in bch_worker()
to zero.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Karsten Keil <keil@b1-systems.de>
2016-03-29 12:47:49 +02:00