Compare commits

..

75 Commits

Author SHA1 Message Date
Andreas Eversberg 91ceb56495 Add dial tone detection to disable echo suppressor 2023-03-05 16:39:31 +01:00
Andreas Eversberg 7aa290154a Fixes missing event in LCP FSM 2023-03-05 16:39:28 +01:00
Andreas Eversberg 5268c0fc9b Added echo suppressor option 2023-03-05 16:39:26 +01:00
Andreas Eversberg c2bf2598b1 Add echo suppressor along with echo canceller 2023-03-05 16:39:22 +01:00
Andreas Eversberg f489ce381c Improve management process, to handle startup/blocking/unblocking correctly
This is a big one:

Startup process was hacked. Several state machines do the startup process now:
- system startup
- PSTN startup
- PSTN restart
- 5 state machines to do multiple port unblocking/blocking
2023-03-05 16:39:18 +01:00
Andreas Eversberg dd23410c52 Pulsed signal can have only one byte as value (3 byte IE) 2023-03-03 09:03:43 +01:00
Andreas Eversberg aa07ba4a48 VTY: Show single port; Use 'singular' for ports and links 2023-03-03 09:03:41 +01:00
Andreas Eversberg 40fddb83a7 Send to E1, only if layer 1 is active
This prevents filling the TX queue inside libosmo-abis.
2023-03-03 09:03:38 +01:00
Andreas Eversberg a53c366853 Update configure.ac to current release of libosmocore/libosmo-abis 2023-03-03 09:03:36 +01:00
Andreas Eversberg 56467e746e Link structure of e1inp_line directly with V5 link
This way there is no lookup required, to get e1inp_line from v5
link and vice versa.

The E1 line is configured whenever it is added to the V5 link. This
happens when entering it in the VTY or loading the config. Also the
signaling channel is opened.

If E1 line is removed from the V5 link, all channels are closed.
2023-03-03 09:03:33 +01:00
Andreas Eversberg ebfab5792d Dynamically open and close b-channels depending on the usage 2023-02-24 15:02:42 +01:00
Andreas Eversberg a4483db3af Added echo cancelation option 2023-02-24 15:02:38 +01:00
Andreas Eversberg e59752a1cb Add libg711 to transcode G.711 audio 2023-02-04 16:49:30 +01:00
Andreas Eversberg c6d0c2452c Added libecho, the line-echo-canceler from spandsp 2023-02-04 16:49:26 +01:00
Andreas Eversberg 8b00969b4a Check double use of E1 interface and notify, if not defined
E1 interface may be used by one V5 link only.
Also notify user, if not created and application must be restarted when
created.
2023-01-28 21:42:56 +01:00
Andreas Eversberg 3aee692b1c Added GSMTAP IP option and fixed command line help output format 2023-01-24 18:33:04 +01:00
Andreas Eversberg 687e963fd4 Updated ph-socket interface 2023-01-24 18:07:52 +01:00
Andreas Eversberg 905a1b22cf Add test function to test Sa 7 bit setting and reporting 2023-01-15 20:00:59 +01:00
Andreas Eversberg 85fe6f55bb Add graph of protocol entities 2023-01-15 20:00:58 +01:00
Andreas Eversberg 61d531cedc Work on Makefile.am 2023-01-15 20:00:56 +01:00
Andreas Eversberg 9c0893403d Working on main.c 2023-01-15 20:00:53 +01:00
Andreas Eversberg 36dc03731a Introduce layer1.c to process layer1 data flow and signals 2023-01-15 20:00:52 +01:00
Andreas Eversberg ef33793758 Work on ph_socket.c 2023-01-15 20:00:46 +01:00
Andreas Eversberg 5d972a0077 Work on VTY 2023-01-15 20:00:43 +01:00
Andreas Eversberg a260178387 Work on v5x_protocol.c 2023-01-15 20:00:39 +01:00
Andreas Eversberg 3ebe29e28f Work on v5x_data.c and v5x_internal.h 2023-01-15 20:00:37 +01:00
Andreas Eversberg 5addae556a Work on v5x_le_ctrl_fsm.c 2023-01-15 20:00:34 +01:00
Andreas Eversberg ba46786de7 Work on v5x_le_port_fsm.c 2023-01-15 20:00:32 +01:00
Andreas Eversberg 58937c291b Work on management
Also merged provisioning and management into one source file.
2023-01-15 20:00:29 +01:00
Andreas Eversberg fbb97bdd73 Work on v5x_le_pstn_fsm.c 2023-01-15 20:00:22 +01:00
Andreas Eversberg 920fada1bc Completed implementation of v52_le_pp_fsm.c 2023-01-15 20:00:18 +01:00
Andreas Eversberg 276b423051 Completed implementation of v52_le_bcc_fsm.c 2023-01-15 20:00:17 +01:00
Andreas Eversberg 4994a59962 Completed implementation of v5x_l1_fsm.c 2023-01-15 20:00:14 +01:00
Andreas Eversberg 852990f2e3 Completed implementation of V52_le_lcp_fsm.c 2023-01-08 10:17:58 +01:00
Andreas Eversberg 6a4a58d4b1 Work on logging.c 2023-01-08 10:17:56 +01:00
Andreas Eversberg 513f3bba5a Fixes for lapv5 2023-01-08 10:17:53 +01:00
Andreas Eversberg aeae94c547 Added functions to create and destroy V5.1/V5.2 interface with VTY 2022-12-29 17:14:20 +01:00
Andreas Eversberg 2a23a1c9cf Added destroy function for interface 2022-12-29 17:14:19 +01:00
Andreas Eversberg 65dac95ff0 Move main.c to src/ 2022-12-29 17:14:18 +01:00
Andreas Eversberg b64a17c748 Move v5x_l2_mgmt and v51_le_provisioning to src/
New names are v5x_le_management and v5x_le_provisioning
2022-12-29 17:14:15 +01:00
Andreas Eversberg 7b4561f7cf Move v52_lcp_fsm.c to src/ 2022-12-29 17:14:13 +01:00
Andreas Eversberg ca0d2f6091 Move v5x_le_pstn_fsm.h to src/v5x_le_pstn_fsm.h
Also changed serveral names of functions/structures/defintions.
2022-12-29 17:14:11 +01:00
Andreas Eversberg ff619cc54b Move v52_le_user_port_fsm to src/v5x_le_port_fsm
Also changed serveral names of functions/structures/defintions.
2022-12-29 17:14:09 +01:00
Andreas Eversberg 595d1091bc Move v51_le_ctrl to src/v5x_le_ctrl_fsm
Also changed serveral names of functions/structures/defintions.
2022-12-29 17:14:08 +01:00
Andreas Eversberg f457d272b6 Move v51_l1_fsm.c to src/v5x_l1_fsm.c 2022-12-29 17:14:05 +01:00
Andreas Eversberg 3cabd7f1a6 Move v5x_protocol to src/ 2022-12-29 17:14:03 +01:00
Andreas Eversberg ff5e1d4947 Move lapv5 to src/ 2022-12-29 17:14:00 +01:00
Andreas Eversberg dec8a8adea Move ph_socket to src/ 2022-12-29 17:13:59 +01:00
Andreas Eversberg d91fd97210 Move logging to src/ 2022-12-29 17:13:57 +01:00
Andreas Eversberg 33eea99531 Move v5x_data.c and v5x_internal.h to src/
Also split VTY code into v5x_vty.c and v5x_vty.h

Some VTY code from main.c is moved also.
2022-12-29 17:13:55 +01:00
Andreas Eversberg 83d8cbdd3a Prepared autoconf/automake 2022-12-29 17:13:53 +01:00
Andreas Eversberg 3586180ae2 Jolly's hack on Makefile 2022-12-29 17:13:50 +01:00
Andreas Eversberg f5e54dfa77 Hacking on main 2022-12-29 17:13:48 +01:00
Andreas Eversberg 0325fbedc1 Work on v5x_protocol 2022-12-29 17:13:47 +01:00
Andreas Eversberg afa29770cc Work on v5x_data.c and v5x_internal.h 2022-12-29 17:13:44 +01:00
Andreas Eversberg a8428e073d Work on lapv5 2022-12-29 17:13:43 +01:00
Andreas Eversberg 331c19228e Add PSTN protocol 2022-12-29 17:13:41 +01:00
Andreas Eversberg e066033770 Add L2 management process 2022-12-29 17:13:39 +01:00
Andreas Eversberg a02b14892a Add PH-socket interface
This interface can be used to connect to ISDN/PSTN stacks. It was ported
to work with libosmocore. Still it uses own implementation of socket
handling, because libosmocore does not support abstract socket names
yet.
2022-12-29 17:13:38 +01:00
Andreas Eversberg eeb77df89f Fixed and completed v52_le_user_port_fsm.c for both ISDN and PSTN ports 2022-12-29 17:13:35 +01:00
Andreas Eversberg ae1a7de2b8 Serveral fixes to v51_le_ctrl.c 2022-12-29 17:13:33 +01:00
Andreas Eversberg 537301f656 Fixed primitive handling in v5x_protocol.c 2022-12-29 17:13:30 +01:00
Andreas Eversberg d9cea69a90 Add enum type for user port data structure (PSTN or ISDN) 2022-12-29 17:13:29 +01:00
Andreas Eversberg ee6d366feb Add minimal provisioning protocol (Clause 14.5) 2022-12-29 17:13:27 +01:00
Andreas Eversberg ffeded74af Add more log levels to logging 2022-12-29 17:13:24 +01:00
Harald Welte 65dfe9080b Iniatial gsmtap support
This requires a wireshark with support for passing the new gsmtap V5
format into the existing wireshark dissectors for V5.
2022-12-29 17:13:23 +01:00
Andreas Eversberg 5af684bed2 Work on control protocols 2022-12-29 17:13:20 +01:00
Andreas Eversberg fe6a4b91f8 Hacking on main.c 2022-12-29 17:13:19 +01:00
Andreas Eversberg 1560a36dfc Work on v5x_data.c and v5x_internal.h 2022-12-29 17:13:18 +01:00
Andreas Eversberg 5fd7b682f4 Several fixes for lapv5.c 2022-12-29 17:13:15 +01:00
Andreas Eversberg a77eb4020f Work on v5x_protocol.c 2022-12-29 17:13:14 +01:00
Andreas Eversberg 0bb6303c34 Changes to Makefile 2022-12-29 17:13:13 +01:00
Andreas Eversberg 04e99eb55f Rename SAP functions of lapv5 to be more conclusive 2022-12-29 17:13:10 +01:00
Andreas Eversberg 4f9292b698 Add logging.c/logging.h 2022-12-29 17:13:09 +01:00
Andreas Eversberg 10b269d24c Removed config file 2022-12-29 17:13:03 +01:00
35 changed files with 739 additions and 1246 deletions

1
.gitignore vendored
View File

@ -23,7 +23,6 @@ stamp-h1
#libosmo-abis-*
tests/*_test
*~
m4/*.m4
# libtool and e.g. arm-poky-linux-gnueabi-libtool
*libtool

View File

@ -1,8 +1,8 @@
osmo-v5 - Osmocom implementation of ETSI/ITU V5 interface
=========================================================
This is a repository containing code implementing the ETSI/ITU V5 interface as
specified in ITU-T G.964 + G.965.
This is a repository containing *very early work-in-progress* code implementing
the ETSI/ITU V5 interface as specified in ITU-T G.964 + G.965.
V5 is an interface spoken between digital telephone exchange and its [remote]
access network (multiplexers + concentrators of subscriber access lines).
@ -11,22 +11,21 @@ For some general intro into V5, you might find the following OsmoDevCall
recording interesting: https://media.ccc.de/v/osmodevcall-20211228-laforge-retro-isdn-v5
Initial development was done just using the spec as reference; from 09/2022 onwards
a Nokia EKSOS N20 became the primary target. The code has been uses successfully
against Nokia EKSOS N20 and Siemens Fastlink.
a Nokia EKSOS N20 became the primary target.
Homepage
--------
The project homepage is at <https://osmocom.org/projects/retronetworking/wiki/Osmo-v5>.
None yet.
GIT Repository
--------------
You can clone from the official osmo-v5.git repository using
You can clone from the official libosmocore.git repository using
git clone https://gitea.osmocom.org/retronetworking/osmo-v5
git clone https://gitea.osmocom.org/laforge/osmo-v5
There is a web interface at <https://gitea.osmocom.org/retronetworking/osmo-v5>
There is a web interface at <https://gitea.osmocom.org/laforge/osmo-v5>
Mailing List
------------

View File

@ -1,7 +1,6 @@
/* LAPV5-DL as per Section 10.1 of ITU-T G.964 */
/* (C) 2021-2022 by Harald Welte <laforge@gnumonks.org>
* (C) 2022-2023 by Andreas Eversberg <jolly@eversberg.eu>
/* (C) 2021 by Harald Welte <laforge@gnumonks.org>
*
* All Rights Reserved
*
@ -135,7 +134,7 @@ static struct lapv5_sap *lapv5_sap_alloc(struct lapv5_instance *li, uint16_t v5d
if (!sap)
return NULL;
LOGLI(li, LOGL_DEBUG, "(%s): LAPV5 Allocating SAP for V5_DLADDR=%u (dl=%p, sap=%p)\n",
LOGP(DLLAPD, LOGL_DEBUG, "(%s): LAPV5 Allocating SAP for V5_DLADDR=%u (dl=%p, sap=%p)\n",
name, v5dladdr, &sap->dl, sap);
sap->li = li;
@ -144,7 +143,7 @@ static struct lapv5_sap *lapv5_sap_alloc(struct lapv5_instance *li, uint16_t v5d
profile = &li->profile;
k = profile->k[0];
LOGLI(li, LOGL_DEBUG, "(%s): k=%d N200=%d N201=%d T200=%d.%d T203=%d.%d\n",
LOGP(DLLAPD, LOGL_DEBUG, "(%s): k=%d N200=%d N201=%d T200=%d.%d T203=%d.%d\n",
name, k, profile->n200, profile->n201, profile->t200_sec,
profile->t200_usec, profile->t203_sec, profile->t203_usec);
lapd_dl_init2(dl, k, 128, profile->n201, name);
@ -190,7 +189,14 @@ int lapv5_ph_data_ind(struct lapv5_instance *li, struct msgb *msg, int *error)
/* write to PCAP file, if enabled. */
osmo_pcap_lapd_write(li->pcap_fd, OSMO_LAPD_PCAP_INPUT, msg);
if (!li->enabled) {
LOGLI(li, LOGL_DEBUG, "LAPV5 frame ignored, because DL is disabled.\n");
msgb_free(msg);
return -EINVAL;
}
msgb_pull(msg, msg->l2h - msg->data);
LOGLI(li, LOGL_DEBUG, "RX: %s\n", osmo_hexdump(msg->data, msg->len));
if (msg->len < 2) {
LOGLI(li, LOGL_ERROR, "LAPV5 frame receive len %d < 2, ignoring\n", msg->len);
@ -199,20 +205,11 @@ int lapv5_ph_data_ind(struct lapv5_instance *li, struct msgb *msg, int *error)
return -EINVAL;
};
dladdr = ((msg->l2h[0] & 0xfe) << 5) | (msg->l2h[1] >> 1);
if (!li->enabled) {
LOGLI(li, LOGL_NOTICE, "LAPV5 frame ignored, because DL is disabled.\n");
if (dladdr == V5X_DLADDR_PSTN)
LOGLI(li, LOGL_NOTICE, "PLEASE ENABLE EARLY PSTN DATALINK ENABLE AT INTERFACE CONFIG!\n");
msgb_free(msg);
return -EINVAL;
}
memset(&lctx, 0, sizeof(lctx));
i = 0;
/* adress field */
dladdr = ((msg->l2h[0] & 0xfe) << 5) | (msg->l2h[1] >> 1);
lctx.lpd = 0;
lctx.sapi = dladdr >> 7;
lctx.tei = dladdr & 0x7f;
@ -491,7 +488,7 @@ int lapv5ef_rx(struct v5x_link *link, struct msgb *msg)
msg->l1h = msg->data;
if (msgb_length(msg) < 2) {
LOGV5L(link, DV5EF, LOGL_ERROR, "Frame too short.\n");
LOGP(DV5EF, LOGL_ERROR, "Frame too short.\n");
msgb_free(msg);
return -EINVAL;
}
@ -503,7 +500,7 @@ int lapv5ef_rx(struct v5x_link *link, struct msgb *msg)
if (!is_isdn) {
LOGV5L(link, DV5EF, LOGL_ERROR, "EFaddr are structured like isdn-type L3 Address.\n");
LOGP(DV5EF, LOGL_ERROR, "EFaddr are structured like isdn-type L3 Address.\n");
msgb_free(msg);
return -EINVAL;
}
@ -535,30 +532,30 @@ int lapv5ef_rx(struct v5x_link *link, struct msgb *msg)
default:
if (efaddr >= 8176) {
/* reserved as per Section 9.2.2.2 of G.964 */
LOGV5L(link, DV5EF, LOGL_ERROR, "No LAPV5 protocol for EFaddr %d.\n", efaddr);
LOGP(DV5EF, LOGL_ERROR, "No LAPV5 protocol for EFaddr %d.\n", efaddr);
msgb_free(msg);
return -EINVAL;
}
/* relay function for LAPD of user ports */
v5up = v5x_user_port_find(link->interface, efaddr, true);
if (!v5up) {
LOGV5L(link, DV5EF, LOGL_ERROR, "No ISDN user port instance for EFaddr %d created.\n", efaddr);
LOGP(DV5EF, LOGL_ERROR, "No ISDN user port instance for EFaddr %d created.\n", efaddr);
msgb_free(msg);
return -EINVAL;
}
if (!v5x_le_port_isdn_is_operational(v5up->port_fi)) {
LOGV5UP(v5up, DV5EF, LOGL_NOTICE, "Dropping D-channel (AN->LE) message of non-operational ISDN port for EFaddr %d.\n", efaddr);
LOGP(DV5EF, LOGL_NOTICE, "Dropping D-channel (AN->LE) message of non-operational ISDN port for EFaddr %d.\n", efaddr);
msgb_free(msg);
return -EIO;
}
LOGV5UP(v5up, DV5EF, LOGL_DEBUG, "Recevied frame for EFaddr %d: %s\n", efaddr, osmo_hexdump(msg->data, msg->len));
LOGP(DV5EF, LOGL_DEBUG, "Recevied frame for EFaddr %d: %s\n", efaddr, osmo_hexdump(msg->data, msg->len));
ph_socket_tx_msg(&v5up->ph_socket, 3, PH_PRIM_DATA_IND, msg->data, msg->len);
msgb_free(msg);
return 0;
}
if (!li) {
LOGV5UP(v5up, DV5EF, LOGL_ERROR, "No LAPV5 instance for EFaddr %d created.\n", efaddr);
LOGP(DV5EF, LOGL_ERROR, "No LAPV5 instance for EFaddr %d created.\n", efaddr);
msgb_free(msg);
return -EINVAL;
}
@ -573,12 +570,12 @@ int lapv5ef_tx(struct v5x_user_port *v5up, struct msgb *msg)
uint16_t efaddr = v5up->nr, efaddr_enc;
if (!v5x_le_port_isdn_is_operational(v5up->port_fi)) {
LOGV5UP(v5up, DV5EF, LOGL_NOTICE, "Dropping D-channel (LE->AN) message of non-operational ISDN port for EFaddr %d.\n", efaddr);
LOGP(DV5EF, LOGL_NOTICE, "Dropping D-channel (LE->AN) message of non-operational ISDN port for EFaddr %d.\n", efaddr);
msgb_free(msg);
return -EIO;
}
/* relay function for LAPD of user ports */
LOGV5UP(v5up, DV5EF, LOGL_DEBUG, "Sending frame for EFaddr %d: %s\n", efaddr, osmo_hexdump(msg->data, msg->len));
LOGP(DV5EF, LOGL_DEBUG, "Sending frame for EFaddr %d: %s\n", efaddr, osmo_hexdump(msg->data, msg->len));
msg->l2h = msgb_push(msg, 2);
efaddr_enc = v5x_l3_addr_enc(efaddr, 1);
msg->l2h[0] = efaddr_enc >> 8;
@ -593,9 +590,6 @@ void lapv5_set_enabled(struct lapv5_instance *li, bool enabled)
{
struct lapv5_sap *sap;
if (li->enabled == enabled)
return;
li->enabled = enabled;
/* reset DL instances */

View File

@ -1,24 +1,3 @@
/* (C) 2022-2023 by Andreas Eversberg <jolly@eversberg.eu>
*
* All Rights Reserved
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <stdio.h>
#include <errno.h>
@ -59,36 +38,16 @@ static int inp_sig_cb(unsigned int subsys, unsigned int signal, void __attribute
return 0;
/* not used by any link */
OSMO_ASSERT(isd);
OSMO_ASSERT(isd->line);
if (!isd->line->ops)
return 0;
v5l = container_of(isd->line->ops, struct v5x_link, e1_line_ops);
switch (signal) {
case S_L_INP_LINE_LOS:
v5l->los = true;
/* Send LOS, if not alreay set when LOF is detected. */
if (!v5l->lof)
v5x_l1_signal_rcv(v5l, L1_SIGNAL_LOS);
break;
case S_L_INP_LINE_LOF:
/* Send LOS, if not alreay set when LOS is detected. */
v5l->lof = true;
if (!v5l->los)
v5x_l1_signal_rcv(v5l, L1_SIGNAL_LOS);
v5x_l1_signal_rcv(v5l, L1_SIGNAL_LOS);
break;
case S_L_INP_LINE_NOLOS:
/* Send NO_LOS, if also LOF is not detected. */
v5l->los = false;
if (!v5l->lof)
v5x_l1_signal_rcv(v5l, L1_SIGNAL_NO_LOS);
break;
case S_L_INP_LINE_NOLOF:
/* Send NO_LOS, if also LOS is not detected. */
v5l->lof = false;
if (!v5l->los)
v5x_l1_signal_rcv(v5l, L1_SIGNAL_NO_LOS);
v5x_l1_signal_rcv(v5l, L1_SIGNAL_NO_LOS);
break;
case S_L_INP_LINE_RAI:
v5x_l1_signal_rcv(v5l, L1_SIGNAL_RAI);
@ -314,14 +273,8 @@ int ph_data_req_hdlc(struct msgb *msg, struct v5x_interface *v5if)
int ph_data_req_dl_cc(struct msgb *msg, void *cbdata)
{
struct v5x_interface *v5if = (struct v5x_interface *)cbdata;
struct e1inp_line *e1_line;
struct e1inp_line *e1_line = v5if->cc_link->e1_line;
if (!v5if->cc_link) {
msgb_free(msg);
return 0;
}
e1_line = v5if->cc_link->e1_line;
if (!e1_line) {
msgb_free(msg);
return 0;
@ -565,11 +518,6 @@ struct e1inp_line *e1_line_init(struct v5x_link *v5l, int e1_nr)
return NULL;
}
if (test_sa7) {
printf("Initally set Sa 7 to 0. (Link ID %d)\n", v5l->id);
v5x_l1_signal_snd(v5l, L1_SIGNAL_SA7_0);
}
return e1_line;
}

View File

@ -1,9 +1,3 @@
#pragma once
struct v5x_link;
struct v5x_timeslot;
struct v5x_interface;
struct msgb;
enum l1_signal_prim {
L1_SIGNAL_LOS,

View File

@ -8,21 +8,18 @@
* (C) 2023 by Andreas Eversberg <andreas@eversberg.eu>
* All Rights Reserved
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View File

@ -2,21 +2,18 @@
* (C) 2023 by Andreas Eversberg <andreas@eversberg.eu>
* All Rights Reserved
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

View File

@ -9,13 +9,11 @@
** **
\*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "g711.h"
/* ulaw -> signed 16-bit */
static int16_t g711_ulaw_to_linear[256] =
static int16_t _ulaw_flipped_to_linear[256] =
{
0x8284, 0x8684, 0x8a84, 0x8e84, 0x9284, 0x9684, 0x9a84, 0x9e84,
0xa284, 0xa684, 0xaa84, 0xae84, 0xb284, 0xb684, 0xba84, 0xbe84,
@ -52,7 +50,7 @@ static int16_t g711_ulaw_to_linear[256] =
};
/* alaw -> signed 16-bit */
int16_t g711_alaw_flipped_to_linear[256] =
static int16_t _alaw_flipped_to_linear[256] =
{
0x13fc, 0xec04, 0x0144, 0xfebc, 0x517c, 0xae84, 0x051c, 0xfae4,
0x0a3c, 0xf5c4, 0x0048, 0xffb8, 0x287c, 0xd784, 0x028c, 0xfd74,
@ -89,25 +87,17 @@ int16_t g711_alaw_flipped_to_linear[256] =
};
/* Xlaw -> signed 16-bit */
static int16_t g711_alaw_to_linear[256];
int16_t g711_ulaw_flipped_to_linear[256];
static int16_t _alaw_to_linear[256];
static int16_t _ulaw_to_linear[256];
/* signed 16-bit -> Xlaw */
uint8_t g711_linear_to_alaw_flipped[65536];
uint8_t g711_linear_to_ulaw_flipped[65536];
static uint8_t g711_linear_to_alaw[65536];
static uint8_t g711_linear_to_ulaw[65536];
/* transcode */
static uint8_t g711_alaw_to_ulaw[256];
static uint8_t g711_ulaw_to_alaw[256];
static uint8_t g711_alaw_flipped_to_ulaw[256];
static uint8_t g711_ulaw_flipped_to_alaw[256];
static uint8_t g711_alaw_to_ulaw_flipped[256];
static uint8_t g711_ulaw_to_alaw_flipped[256];
static uint8_t _linear_to_alaw_flipped[65536];
static uint8_t _linear_to_ulaw_flipped[65536];
static uint8_t _linear_to_alaw[65536];
static uint8_t _linear_to_ulaw[65536];
/* table is used to generate linear_to_alaw */
static int16_t g711_alaw_relations[] =
static int16_t _alaw_relations[] =
{
0x8684, 0x55, 0x8a84, 0xd5, 0x8e84, 0x15, 0x9284, 0x95,
0x9684, 0x75, 0x9a84, 0xf5, 0x9e84, 0x35, 0xa284, 0xb5,
@ -175,9 +165,20 @@ static int16_t g711_alaw_relations[] =
0x6d7c, 0x94, 0x717c, 0x14, 0x757c, 0xd4, 0x797c, 0x54
};
uint8_t g711_flip[256];
uint8_t _flip[256];
/* Xlaw -> signed 16-bit */
int16_t *g711_ulaw_flipped_to_linear = _ulaw_flipped_to_linear;
int16_t *g711_alaw_flipped_to_linear = _alaw_flipped_to_linear;
int16_t *g711_alaw_to_linear = _alaw_to_linear;
int16_t *g711_ulaw_to_linear = _ulaw_to_linear;
/* signed 16-bit -> Xlaw */
uint8_t *g711_linear_to_alaw_flipped = _linear_to_alaw_flipped;
uint8_t *g711_linear_to_ulaw_flipped = _linear_to_ulaw_flipped;
uint8_t *g711_linear_to_alaw = _linear_to_ulaw;
uint8_t *g711_linear_to_ulaw = _linear_to_ulaw;
static int g711_initialized = 0;
/* generate tables
*/
@ -187,7 +188,7 @@ void g711_init(void)
/* flip tables */
for (i = 0; i < 256; i++) {
g711_flip[i]
_flip[i]
= ((i & 1) << 7)
+ ((i & 2) << 5)
+ ((i & 4) << 3)
@ -196,50 +197,38 @@ void g711_init(void)
+ ((i & 32) >> 3)
+ ((i & 64) >> 5)
+ ((i & 128) >> 7);
g711_alaw_to_linear[i] = g711_alaw_flipped_to_linear[g711_flip[i]];
g711_ulaw_flipped_to_linear[i] = g711_ulaw_to_linear[g711_flip[i]];
_alaw_to_linear[i] = _alaw_flipped_to_linear[_flip[i]];
_ulaw_to_linear[i] = _ulaw_flipped_to_linear[_flip[i]];
}
/* linear to alaw tables */
i = j = 0;
while(i < 65536) {
if (i - 32768 > g711_alaw_relations[j << 1])
if (i - 32768 > _alaw_relations[j << 1])
j++;
if (j > 255)
j = 255;
g711_linear_to_alaw_flipped[(i - 32768) & 0xffff] = g711_alaw_relations[(j << 1) | 1];
g711_linear_to_alaw[(i - 32768) & 0xffff] = g711_flip[g711_alaw_relations[(j << 1) | 1]];
_linear_to_alaw_flipped[(i - 32768) & 0xffff] = _alaw_relations[(j << 1) | 1];
_linear_to_alaw[(i - 32768) & 0xffff] = _flip[_alaw_relations[(j << 1) | 1]];
i++;
}
/* linear to ulaw tables */
i = j = 0;
while(i < 32768) {
if (i - 32768 > g711_ulaw_to_linear[j])
if (i - 32768 > _ulaw_flipped_to_linear[j])
j++;
g711_linear_to_ulaw[(i - 32768) & 0xffff] = j;
g711_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = g711_flip[j];
_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = j;
_linear_to_ulaw[(i - 32768) & 0xffff] = _flip[j];
i++;
}
j = 255;
while(i < 65536) {
if (i - 32768 > g711_ulaw_to_linear[j])
if (i - 32768 > _alaw_flipped_to_linear[j])
j--;
g711_linear_to_ulaw[(i - 32768) & 0xffff] = j;
g711_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = g711_flip[j];
_linear_to_ulaw_flipped[(i - 32768) & 0xffff] = j;
_linear_to_ulaw[(i - 32768) & 0xffff] = _flip[j];
i++;
}
/* transcode */
for (i = 0; i < 256; i++) {
g711_alaw_to_ulaw[i] = g711_linear_to_ulaw[(uint16_t)g711_alaw_to_linear[i]];
g711_ulaw_to_alaw[i] = g711_linear_to_alaw[(uint16_t)g711_ulaw_to_linear[i]];
g711_alaw_flipped_to_ulaw[i] = g711_linear_to_ulaw[(uint16_t)g711_alaw_to_linear[g711_flip[i]]];
g711_ulaw_flipped_to_alaw[i] = g711_linear_to_alaw[(uint16_t)g711_ulaw_to_linear[g711_flip[i]]];
g711_alaw_to_ulaw_flipped[i] = g711_flip[g711_linear_to_ulaw[(uint16_t)g711_alaw_to_linear[i]]];
g711_ulaw_to_alaw_flipped[i] = g711_flip[g711_linear_to_alaw[(uint16_t)g711_ulaw_to_linear[i]]];
}
g711_initialized = 1;
}

View File

@ -1,8 +1,13 @@
#pragma once
extern int16_t g711_alaw_flipped_to_linear[256];
extern int16_t g711_ulaw_flipped_to_linear[256];
extern uint8_t g711_linear_to_alaw_flipped[65536];
extern uint8_t g711_linear_to_ulaw_flipped[65536];
void g711_init(void);
/* Xlaw -> signed 16-bit */
extern int16_t *g711_ulaw_flipped_to_linear;
extern int16_t *g711_alaw_flipped_to_linear;
extern int16_t *g711_alaw_to_linear;
extern int16_t *g711_ulaw_to_linear;
/* signed 16-bit -> Xlaw */
extern uint8_t *g711_linear_to_alaw_flipped;
extern uint8_t *g711_linear_to_ulaw_flipped;
extern uint8_t *g711_linear_to_alaw;
extern uint8_t *g711_linear_to_ulaw;

View File

@ -1,26 +1,3 @@
/* (C) 2021-2022 by Harald Welte <laforge@gnumonks.org>
* (C) 2022-2023 by Andreas Eversberg <jolly@eversberg.eu>
*
* All Rights Reserved
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <osmocom/core/utils.h>
#include "logging.h"

View File

@ -1,24 +1,20 @@
/*
* (C) 2022 by Harald Welte <laforge@osmocom.org>
* (C) 2021 by Andreas Eversberg <andreas@eversberg.eu>
*
* All Rights Reserved
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
@ -96,7 +92,7 @@ static void print_help()
printf(" -D --daemonize Fork the process into a background daemon\n");
printf(" -V --version Print the version number\n");
printf(" -T --gsmtap IP Send GSMTAP messages to ip. (e.g. 224.0.0.1)\n");
printf(" -7 --test-sa7 Continously toggle Sa7 when received. (Do loop interface.)\n");
printf(" -7 --rest-sa7 Continously toggle Sa7 when received. (Do loop interface.)\n");
printf(" --ulaw Use u-Law instead of a-Law for audio processing\n");
printf("\nVTY reference generation:\n");
@ -210,7 +206,6 @@ static void sighandler(int sigset)
int main(int argc, char **argv)
{
struct v5x_interface *v5if;
int rc;
tall_v5le_ctx = talloc_named_const(NULL, 1, "v5le");
@ -238,9 +233,6 @@ int main(int argc, char **argv)
rate_ctr_init(tall_v5le_ctx);
osmo_stats_init(tall_v5le_ctx);
/* don't log the hex pointer address of each FSM instance; we have meaningful IDs */
osmo_fsm_log_addr(false);
/* global inits of protocols */
v5x_l1_init();
v5x_le_ctrl_init();
@ -296,8 +288,11 @@ int main(int argc, char **argv)
signal(SIGPIPE, sighandler);
/* start management state machine */
llist_for_each_entry(v5if, &v5i->interfaces, list)
if (!llist_empty(&v5i->interfaces)) {
struct v5x_interface *v5if;
v5if = (struct v5x_interface *)v5i->interfaces.next;
v5x_le_mgmt_start_delay(v5if, SOCKET_RETRY_TIMER + 1);
}
/* main loop */
while (!quit) {

View File

@ -3,11 +3,9 @@
* (C) 2022 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
@ -15,10 +13,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>

View File

@ -4,12 +4,12 @@
/*
* Procedure:
*
* If socket connection is established, a PH_PRIM_CTRL_REQ message with
* If socket connection is establised, a PH_PRIM_CTRL_REQ message with
* PH_CTRL_ENABLE information is received by the socket server user.
* If the socket connection is lost, a PH_PRIM_CTRL_REQ message with
* PH_CTRL_DISABLE information is received by the user.
*
* If socket connection is established, a PH_PRIM_CTRL_IND message with
*
* If socket connection is establised, a PH_PRIM_CTRL_IND message with
* PH_CTRL_ENABLE information is received by the socket client user.
* If the socket connection is lost, a PH_PRIM_CTRL_IND message with
* PH_CTRL_DISABLE information is received by the user.
@ -24,14 +24,14 @@
* PH_PRIM_DACT_IND, if the socket is currently unavailable.
*
* PH_PRIM_CTRL_REQ and PH_PRIM_CTRL_IND messages with PH_CTRL_ENABLE
* and PH_CTRL_DISABLE information are not associated with a channel
* and PH_CTRL_DISABLE informations are not assoicated with a channel
* number. The socket sender shall set it to 0, the receiver shall
* ignore it.
*
* A missing MODE in PH_PRIM_ACT_REQ is interpreted as default:
* A missing MODE in PH_PRIM_ACT_REQ is interepreted as default:
* HDLC on D-channel, TRANS on B-channel.
*
* Each packet on the socket shall have the following header:
* Each packet on the socket shall have the follwoing header:
* uint8_t channel;
* uint8_t prim;
* uint16_t length;
@ -65,8 +65,8 @@
#define PH_CTRL_BLOCK 0x00 /* disable (block) interface, when socket is disconnected */
#define PH_CTRL_UNBLOCK 0x01 /* enable (unblock) interface, when socket is connected */
#define PH_CTRL_LOOP_DISABLE 0x04 /* disable loopback */
#define PH_CTRL_LOOP1_ENABLE 0x05 /* enable LT transceiver loopback */
#define PH_CTRL_LOOP2_ENABLE 0x06 /* enable NT transceiver loopback */
#define PH_CTRL_LOOP1_ENABLE 0x05 /* enable LT transceier loopback */
#define PH_CTRL_LOOP2_ENABLE 0x06 /* enable NT transceier loopback */
#define PH_CTRL_LOOP_ERROR 0x10 /* frame error report (loopback test) */
#define PH_CTRL_VIOLATION_LT 0x11 /* code violation received by LT */
#define PH_CTRL_VIOLATION_NT 0x12 /* code violation received by NT */

View File

@ -653,7 +653,7 @@ static struct v52_bcc_proc *v52_le_bcc_create(struct v5x_interface *v5if, uint16
OSMO_ASSERT(v5if);
LOGV5IF(v5if, DV5BCC, LOGL_DEBUG, "Creating BCC instance, initiated by %s.\n", (source_id) ? "AN" : "LE");
LOGP(DV5BCC, LOGL_DEBUG, "Creating BCC instance, initiated by %s.\n", (source_id) ? "AN" : "LE");
bcc = talloc_zero(v5if, struct v52_bcc_proc);
if (!bcc)
@ -665,7 +665,6 @@ static struct v52_bcc_proc *v52_le_bcc_create(struct v5x_interface *v5if, uint16
talloc_free(bcc);
return NULL;
}
osmo_fsm_inst_update_id_f(bcc->fi, "%s-P%d-L%d-TS%d", v5x_interface_name(v5if), user_port_id, link_id, ts);
bcc->ref = (bcc_new_ref++) & 0x1fff;
bcc->source_id = source_id;
@ -729,18 +728,18 @@ int v52_le_bcc_dl_rcv(struct v5x_interface *v5if, uint16_t l3_addr, uint8_t msg_
ref = v52_bcc_ref_dec(l3_addr, &source_id);
bcc = find_bcc_proto_ref(v5if, ref, source_id);
/* ignoring remote process (may happen due to message repetition in state 0) */
if (!bcc)
return 0;
/* handle AN fault here, so there is no need to create a process */
if (msg_type == V52_CTRL_MSGT_AN_FAULT) {
LOGPFSML(bcc->fi, LOGL_NOTICE, "Replying to AN FAULT message. No action is taken here.\n");
LOGP(DV5BCC, LOGL_NOTICE, "Replying to AN FAULT message. No action is taken here.\n");
/* Send AN FAULT ACK */
v5x_dl_snd(v5if, V52_DLADDR_BCC, v52_enc_an_fault_ack(ref, source_id));
return 0;
}
/* ignoring remote process (may happen due to message repetition in state 0) */
if (!bcc)
return 0;
switch (msg_type) {
case V52_CTRL_MSGT_ALLOCATION_COMPLETE:
osmo_fsm_inst_dispatch(bcc->fi, V52_BCCFSM_E_ALLOCATION_COMPLETE, (void *)tp);
@ -764,7 +763,7 @@ int v52_le_bcc_dl_rcv(struct v5x_interface *v5if, uint16_t l3_addr, uint8_t msg_
osmo_fsm_inst_dispatch(bcc->fi, V52_BCCFSM_E_PROTOCOL_ERROR, (void *)tp);
break;
default:
LOGPFSML(bcc->fi, LOGL_NOTICE, "Invalid BCC protocol message %d receied from AN.\n", msg_type);
LOGP(DV5BCC, LOGL_NOTICE, "Invalid BCC protocol message %d receied from AN.\n", msg_type);
return -EINVAL;
}
@ -805,7 +804,7 @@ int v52_le_bcc_mdu_snd(struct v5x_interface *v5if, uint16_t user_port_id, bool i
osmo_fsm_inst_dispatch(bcc->fi, V52_BCCFSM_E_MDU_BCC_audit_req, NULL);
break;
default:
LOGPFSML(bcc->fi, LOGL_NOTICE, "Invalid BCC protocol message %d receied from AN.\n", prim);
LOGP(DV5BCC, LOGL_NOTICE, "Invalid BCC protocol message %d receied from AN.\n", prim);
return -EINVAL;
}

View File

@ -1,11 +1,3 @@
#pragma once
#include <stdint.h>
struct v52_bcc_proc;
struct tlv_parsed;
struct v5x_interface;
enum v5x_mgmt_prim;
void v52_le_bcc_destroy(struct v52_bcc_proc *bcc);
void v52_le_bcc_init(void);

View File

@ -777,7 +777,7 @@ struct osmo_fsm_inst *v52_le_lcp_create(void *ctx, struct v5x_link *v5l, uint8_t
fi = osmo_fsm_inst_alloc(&v52_le_lcp_fsm, ctx, v5l, LOGL_DEBUG, NULL);
if (!fi)
return NULL;
osmo_fsm_inst_update_id_f(fi, "%s-L%d", v5x_interface_name(v5l->interface), id);
osmo_fsm_inst_update_id_f(fi, "%d", id);
/* initial state for links that are not in failure state */
fi->state = V52_LCPFSM_S_LE20_OP_OPERATIONAL;
@ -820,39 +820,39 @@ int v52_le_lcp_mph_rcv(struct v5x_link *v5l, enum v5x_mph_prim prim)
switch (prim) {
case MPH_AI:
LOGPFSML(v5l->fi, LOGL_NOTICE, "Received link activation indication from L1 (link ID %d).\n", v5l->id);
LOGP(DV5LCP, LOGL_NOTICE, "Received link activation indication from L1 (link ID %d).\n", v5l->id);
event = V52_LCPFSM_E_MPH_AI;
break;
case MPH_DI:
LOGPFSML(v5l->fi, LOGL_NOTICE, "Received link deactivation indication from L1 (link ID %d).\n", v5l->id);
LOGP(DV5LCP, LOGL_NOTICE, "Received link deactivation indication from L1 (link ID %d).\n", v5l->id);
event = V52_LCPFSM_E_MPH_DI;
break;
case MPH_EIa:
LOGPFSML(v5l->fi, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): LOS\n", v5l->id);
LOGP(DV5LCP, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): LOS\n", v5l->id);
return 0;
case MPH_EIb:
LOGPFSML(v5l->fi, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): RAI\n", v5l->id);
LOGP(DV5LCP, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): RAI\n", v5l->id);
return 0;
case MPH_EIc:
LOGPFSML(v5l->fi, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): AIS\n", v5l->id);
LOGP(DV5LCP, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): AIS\n", v5l->id);
return 0;
case MPH_EId:
LOGPFSML(v5l->fi, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): Internal failure\n",
LOGP(DV5LCP, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): Internal failure\n",
v5l->id);
return 0;
case MPH_EIe:
LOGPFSML(v5l->fi, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): CRC error\n", v5l->id);
LOGP(DV5LCP, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): CRC error\n", v5l->id);
return 0;
case MPH_EIf:
LOGPFSML(v5l->fi, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): "
LOGP(DV5LCP, LOGL_DEBUG, "Received link error indication from L1 (link ID %d): "
"Remote CRC error indication\n", v5l->id);
return 0;
case MPH_IDI:
LOGPFSML(v5l->fi, LOGL_NOTICE, "Received link identification indication from L1 (link ID %d).\n", v5l->id);
LOGP(DV5LCP, LOGL_NOTICE, "Received link identification indication from L1 (link ID %d).\n", v5l->id);
event = V52_LCPFSM_E_MPH_IDI;
break;
case MPH_EIg:
LOGPFSML(v5l->fi, LOGL_NOTICE, "Received link identification failure from L1 (link ID %d).\n", v5l->id);
LOGP(DV5LCP, LOGL_NOTICE, "Received link identification failure from L1 (link ID %d).\n", v5l->id);
event = V52_LCPFSM_E_MPH_EIg;
break;
case MPH_EIdr:
@ -860,7 +860,7 @@ int v52_le_lcp_mph_rcv(struct v5x_link *v5l, enum v5x_mph_prim prim)
case MPH_EIbr:
return 0;
default:
LOGPFSML(v5l->fi, LOGL_NOTICE, "Invalid LCP primitive %d receied from L1/AN (link ID %d).\n", prim, v5l->id);
LOGP(DV5LCP, LOGL_NOTICE, "Invalid LCP primitive %d receied from L1/AN (link ID %d).\n", prim, v5l->id);
return -EINVAL;
}
@ -901,7 +901,7 @@ int v52_le_lcp_fe_rcv(struct v5x_link *v5l, enum v52_link_ctrl_func lcf)
event = V52_LCPFSM_E_FE306;
break;
default:
LOGPFSML(v5l->fi, LOGL_NOTICE, "Invalid link control function primitive %d receied from AN.\n", lcf);
LOGP(DV5LCP, LOGL_NOTICE, "Invalid link control function primitive %d receied from AN.\n", lcf);
return -EINVAL;
}
@ -931,7 +931,7 @@ int v52_le_lcp_mdu_snd(struct v5x_link *v5l, enum v5x_mgmt_prim prim)
event = V52_LCPFSM_E_MDU_LBI;
break;
default:
LOGPFSML(v5l->fi, LOGL_NOTICE, "Invalid MDU primitive %d receied from management.\n", prim);
LOGP(DV5LCP, LOGL_NOTICE, "Invalid MDU primitive %d receied from management.\n", prim);
return -EINVAL;
}

View File

@ -1,11 +1,3 @@
#pragma once
#include <osmocom/core/fsm.h>
struct v5x_link;
enum v5x_mph_prim;
enum v5x_mgmt_prim;
enum v52_link_ctrl_func;
struct osmo_fsm_inst *v52_le_lcp_create(void *ctx, struct v5x_link *v5l, uint8_t id);
void v52_le_lcp_destroy(struct osmo_fsm_inst *fi);

View File

@ -257,7 +257,7 @@ static struct msgb *v52_enc_reset_sn_xxx(uint16_t cc_id, uint8_t msg_type)
static void stop_timer(struct osmo_fsm_inst *fi)
{
LOGPFSML(fi, LOGL_DEBUG, "Stop all timers\n");
LOGP(DV5PP, LOGL_DEBUG, "Stop all timers\n");
osmo_timer_del(&fi->timer);
}
@ -295,7 +295,7 @@ static void start_timer(struct osmo_fsm_inst *fi, enum v52_le_pp_fsm_event event
if (info)
memcpy(&pp->info, info, sizeof(*info));
LOGPFSML(fi, LOGL_DEBUG, "Start timer %s (count = %d)\n", timer_name, count);
LOGP(DV5PP, LOGL_DEBUG, "Start timer %s (count = %d)\n", timer_name, count);
pp->timeout_event = event;
pp->timeout_count = count;
osmo_timer_schedule(&fi->timer, timeout / 1000, timeout % 1000);
@ -699,7 +699,6 @@ struct v52_pp_proto *v52_le_pp_create(struct v5x_interface *v5if)
pp->fi = osmo_fsm_inst_alloc(&v52_le_pp_fsm, pp, pp, LOGL_DEBUG, NULL);
if (!pp->fi)
goto error;
osmo_fsm_inst_update_id_f(pp->fi, "%s", v5x_interface_name(v5if));
return pp;
@ -740,7 +739,7 @@ int v52_le_pp_dl_rcv(struct v5x_link *v5l, uint16_t cc_id, uint8_t msg_type, con
int check_sn = 0;
if (!pp) {
LOGV5L(v5l, DV5PP, LOGL_NOTICE, "Received message from DL, but there is no protection on this interface.\n");
LOGP(DV5PP, LOGL_NOTICE, "Received message from DL, but there is no protection on this interface.\n");
return -EIO;
}
@ -768,12 +767,12 @@ int v52_le_pp_dl_rcv(struct v5x_link *v5l, uint16_t cc_id, uint8_t msg_type, con
event = V52_PPFSM_E_RESET_SN_ACK;
break;
default:
LOGPFSML(pp->fi, LOGL_NOTICE, "Invalid Protection protocol message %d receied from AN.\n", msg_type);
LOGP(DV5PP, LOGL_NOTICE, "Invalid Protection protocol message %d receied from AN.\n", msg_type);
return -EINVAL;
}
if (cc_id != pp->interface->protection.cc_id) {
LOGPFSML(pp->fi, LOGL_NOTICE, "Protection protocol of AN uses CC-ID %d, but we use CC-ID %d. Please check provisioning.\n", cc_id, pp->interface->protection.cc_id);
LOGP(DV5PP, LOGL_NOTICE, "Protection protocol of AN uses CC-ID %d, but we use CC-ID %d. Please check provisioning.\n", cc_id, pp->interface->protection.cc_id);
dl_send(pp->fi, v52_enc_protocol_error(pp, pp->interface->protection.cc_id, V5X_CAUSE_T_REF_NR_CODING_ERROR, NULL, 0));
return -EINVAL;
}
@ -794,7 +793,7 @@ int v52_le_pp_dl_rcv(struct v5x_link *v5l, uint16_t cc_id, uint8_t msg_type, con
diff = (seq_nr - pp->vp_r) & 0x7f;
/* if VP(R)-5 <= SN <= VP(R)-1 (SN is 1..5 values lower than we want) */
if (diff >= 128 - 5) {
LOGPFSML(pp->fi, LOGL_DEBUG, "Receiveds message with sequence %d, while we expect %d. Ignore, because it was already received earlier.\n", seq_nr, pp->vp_r);
LOGP(DV5PP, LOGL_DEBUG, "Receiveds message with sequence %d, while we expect %d. Ignore, because it was already received earlier.\n", seq_nr, pp->vp_r);
return 0;
}
/* if VP(R) <= SN <= VP(R) + 4 (SN is 0..4 higher than we want) */
@ -802,7 +801,7 @@ int v52_le_pp_dl_rcv(struct v5x_link *v5l, uint16_t cc_id, uint8_t msg_type, con
/* set received sequence number to the next one expected and deliver message */
pp->vp_r = (seq_nr + 1) & 0x7f;
} else {
LOGPFSML(pp->fi, LOGL_NOTICE, "Receiveds message with sequence %d, while we expect %d. This a a misalignment, perform an SN reset!\n", seq_nr, pp->vp_r);
LOGP(DV5PP, LOGL_NOTICE, "Receiveds message with sequence %d, while we expect %d. This a a misalignment, perform an SN reset!\n", seq_nr, pp->vp_r);
event = V52_PPFSM_E_VP_S_VP_R_misalignment_detected;
}
}
@ -817,7 +816,7 @@ int v52_le_pp_mdu_snd(struct v5x_interface *v5if, enum v5x_mgmt_prim prim, uint8
struct v52_pp_mgmt_info info = { link_id, ts, cause };
if (!v5if->protection.pp) {
LOGV5IF(v5if, DV5PP, LOGL_NOTICE, "Cannot perform action, because there is no protection on this interface.\n");
LOGP(DV5PP, LOGL_NOTICE, "Cannot perform action, because there is no protection on this interface.\n");
return -EINVAL;
}
OSMO_ASSERT(v5if->protection.pp);
@ -836,7 +835,7 @@ int v52_le_pp_mdu_snd(struct v5x_interface *v5if, enum v5x_mgmt_prim prim, uint8
event = V52_PPFSM_E_MDU_Protection_reset_SN_req;
break;
default:
LOGPFSML(v5if->protection.pp->fi, LOGL_NOTICE, "Invalid MDU primitive %d receied from management.\n", prim);
LOGP(DV5PP, LOGL_NOTICE, "Invalid MDU primitive %d receied from management.\n", prim);
return -EINVAL;
}

View File

@ -1,11 +1,3 @@
#pragma once
#include <stdint.h>
struct v52_pp_proto;
struct v5x_interface;
struct v5x_link;
struct tlv_parsed;
struct v52_pp_proto *v52_le_pp_create(struct v5x_interface *v5if);
void v52_le_pp_destroy(struct v52_pp_proto *pp);

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,4 @@
#pragma once
#include <osmocom/vty/vty.h>
extern struct vty_app_info vty_info;
int v5le_vty_init(void);

View File

@ -1,26 +1,3 @@
/* (C) 2021-2022 by Harald Welte <laforge@gnumonks.org>
* (C) 2022-2023 by Andreas Eversberg <jolly@eversberg.eu>
*
* All Rights Reserved
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <errno.h>
#include <osmocom/core/talloc.h>
@ -92,7 +69,7 @@ struct v5x_link *v5x_link_create(struct v5x_interface *v5if, uint8_t id)
int rc;
if (v5x_link_find_id(v5if, id)) {
LOGV5IF(v5if, DV5, LOGL_ERROR, "Link %d already exists.\n", id);
LOGP(DV5, LOGL_ERROR, "Link %d already exists.\n", id);
return NULL;
}
@ -175,11 +152,11 @@ int v5x_link_destroy(struct v5x_link *v5l)
count = v5x_link_count(v5l->interface);
if (count > 1 && v5l->interface->primary_link == v5l) {
LOGV5L(v5l, DV5, LOGL_ERROR, "Link is primary. Cannot remove it, while other links exist.\n");
LOGP(DV5, LOGL_ERROR, "Link %d is primary. Cannot remove it, while other links exist.\n", v5l->id);
return -EINVAL;
}
if (count > 2 && v5l->interface->secondary_link == v5l) {
LOGV5L(v5l, DV5, LOGL_ERROR, "Link is secondary (standby). Cannot remove it, while other (not primary) links exist.\n");
LOGP(DV5, LOGL_ERROR, "Link %d is secondary (standby). Cannot remove it, while other (not primary) links exist.\n", v5l->id);
return -EINVAL;
}
@ -241,7 +218,7 @@ int v5x_link_destroy(struct v5x_link *v5l)
return 0;
}
struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, uint32_t id, enum v5x_dialect dialect)
struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, enum v5x_dialect dialect)
{
struct v5x_interface *v5if;
struct v5x_link *v5l;
@ -258,7 +235,6 @@ struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, uint32_t id,
llist_add_tail(&v5if->list, &v5i->interfaces);
v5if->instance = v5i;
v5if->id = id;
v5if->dialect = dialect;
if (v5if->dialect == V5X_DIALECT_V51) {
@ -350,13 +326,12 @@ void v5x_interface_free(struct v5x_interface *v5if) {
struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t nr, enum v5x_user_type type,
uint8_t ts1, uint8_t ts2)
{
struct v5x_user_port *v5up, *tmp;
struct llist_head *add;
struct v5x_user_port *v5up;
int i;
int rc;
if (v5x_user_port_find(v5if, nr, (type == V5X_USER_TYPE_ISDN))) {
LOGV5IF(v5if, DV5, LOGL_ERROR, "User port %d already exists.\n", nr);
LOGP(DV5, LOGL_ERROR, "User port %d already exists.\n", nr);
return NULL;
}
@ -365,21 +340,21 @@ struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t
v5l = llist_first_entry(&v5if->links, struct v5x_link, list);
if (!v5l->ts[ts1].b_channel) {
LOGV5IF(v5if, DV5, LOGL_ERROR, "Time slot %d is not a B-channel, select a different one.\n", ts1);
LOGP(DV5, LOGL_ERROR, "Time slot %d is not a B-channel, select a different one.\n", ts1);
return NULL;
}
if ((v5up = v5l->ts[ts1].v5up)) {
LOGV5IF(v5if, DV5, LOGL_ERROR, "Time slot %d is already assigned to another user port.\n", ts1);
LOGP(DV5, LOGL_ERROR, "Time slot %d is already assigned to another user port.\n", ts1);
return NULL;
}
if (type == V5X_USER_TYPE_ISDN) {
if (!v5l->ts[ts2].b_channel) {
LOGV5IF(v5if, DV5, LOGL_ERROR, "Time slot %d is not a B-channel, select a different one.\n",
LOGP(DV5, LOGL_ERROR, "Time slot %d is not a B-channel, select a different one.\n",
ts2);
return NULL;
}
if ((v5up = v5l->ts[ts2].v5up)) {
LOGV5IF(v5if, DV5, LOGL_ERROR, "Time slot %d is already assigned to another user port.\n", ts2);
LOGP(DV5, LOGL_ERROR, "Time slot %d is already assigned to another user port.\n", ts2);
return NULL;
}
}
@ -389,16 +364,7 @@ struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t
if (!v5up)
return NULL;
/* Insert in a sorted way: all port numbers in ascending order, but all ISDN ports behind PSTN ports */
add = &v5if->user_ports;
llist_for_each_entry(tmp, &v5if->user_ports, list) {
if (tmp->type == V5X_USER_TYPE_ISDN && type == V5X_USER_TYPE_PSTN)
break;
if (tmp->nr > nr && tmp->type == type)
break;
add = &tmp->list;
}
llist_add(&v5up->list, add);
llist_add_tail(&v5up->list, &v5if->user_ports);
v5up->interface = v5if;
v5up->nr = nr;
@ -421,33 +387,33 @@ struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t
v5up->ctrl = v5x_le_ctrl_create(V5X_CTRL_TYPE_PORT, v5up, v5up, nr);
if (!v5up->ctrl) {
LOGV5UP(v5up, DV5, LOGL_ERROR, "Failed to create control protocol\n");
LOGP(DV5, LOGL_ERROR, "Failed to create control protocol\n");
goto error;
}
switch (type) {
case V5X_USER_TYPE_ISDN:
LOGV5UP(v5up, DV5, LOGL_NOTICE, "Creating V5 ISDN user port with L3 addr %d\n", nr);
sprintf(v5up->ifname, "%d-isdn-%d", v5if->id, nr);
LOGP(DV5, LOGL_NOTICE, "Creating V5 ISDN user port with L3 addr %d\n", nr);
sprintf(v5up->ifname, "isdn-%d", nr);
OSMO_ASSERT(nr <= 8175);
v5up->port_fi = v5x_le_port_isdn_create(v5up, nr);
if (!v5up->port_fi) {
LOGV5UP(v5up, DV5, LOGL_ERROR, "Failed to create port control\n");
LOGP(DV5, LOGL_ERROR, "Failed to create port control\n");
goto error;
}
break;
case V5X_USER_TYPE_PSTN:
LOGV5UP(v5up, DV5, LOGL_NOTICE, "Creating V5 PSTN user port with L3 addr %d\n", nr);
sprintf(v5up->ifname, "%d-pstn-%d", v5if->id, nr);
LOGP(DV5, LOGL_NOTICE, "Creating V5 PSTN user port with L3 addr %d\n", nr);
sprintf(v5up->ifname, "pstn-%d", nr);
OSMO_ASSERT(nr <= 32767);
v5up->port_fi = v5x_le_port_pstn_create(v5up, nr);
if (!v5up->port_fi) {
LOGV5UP(v5up, DV5, LOGL_ERROR, "Failed to create port control\n");
LOGP(DV5, LOGL_ERROR, "Failed to create port control\n");
goto error;
}
v5up->pstn.proto = v5x_le_pstn_create(v5up, nr);
if (!v5up->pstn.proto) {
LOGV5UP(v5up, DV5, LOGL_ERROR, "Failed to create PSTN protocol\n");
LOGP(DV5, LOGL_ERROR, "Failed to create PSTN protocol\n");
goto error;
}
/* bring port into service */
@ -460,17 +426,17 @@ struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t
/* EC needs to adapt, NLP causes better results on quick volume changes */
v5up->ep[i].ec = echo_can_create(EC_TAPS, ECHO_CAN_USE_ADAPTION | ECHO_CAN_USE_NLP);
if (!v5up->ep[i].ec) {
LOGV5UP(v5up, DV5, LOGL_ERROR, "Failed to create line echo canceler\n");
LOGP(DV5, LOGL_ERROR, "Failed to create line echo canceler\n");
goto error;
}
v5up->ep[i].es = echo_sup_create(v5up, 8000);
if (!v5up->ep[i].es) {
LOGV5UP(v5up, DV5, LOGL_ERROR, "Failed to create line echo suppressor\n");
LOGP(DV5, LOGL_ERROR, "Failed to create line echo suppressor\n");
goto error;
}
rc = answertone_init(&v5up->ep[i].at, 8000);
if (rc < 0) {
LOGV5UP(v5up, DV5, LOGL_ERROR, "Failed to create answer tone detector\n");
LOGP(DV5, LOGL_ERROR, "Failed to create answer tone detector\n");
goto error;
}
if (type != V5X_USER_TYPE_ISDN)
@ -479,7 +445,7 @@ struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t
rc = ph_socket_init(&v5up->ph_socket, ph_socket_rx_cb, v5up, v5up->ifname, 1);
if (rc < 0) {
LOGV5UP(v5up, DV5, LOGL_ERROR, "Failed to create PH-socket\n");
LOGP(DV5, LOGL_ERROR, "Failed to create PH-socket\n");
goto error;
}
@ -498,7 +464,7 @@ void v5x_user_port_destroy(struct v5x_user_port *v5up)
{
int i;
LOGV5UP(v5up, DV5, LOGL_NOTICE, "Destroying V5 user port with L3 addr %d\n", v5up->nr);
LOGP(DV5, LOGL_NOTICE, "Destroying V5 user port with L3 addr %d\n", v5up->nr);
/* close first, because it sends messages */
ph_socket_exit(&v5up->ph_socket);
@ -578,14 +544,3 @@ struct v5x_link *v5x_link_find_id(struct v5x_interface *v5if, uint8_t id)
}
return NULL;
}
const char *v5x_interface_name(const struct v5x_interface *v5if)
{
static char buf[16];
if (v5if->name)
return v5if->name;
snprintf(buf, sizeof(buf), "IF%u", v5if->id);
return buf;
}

View File

@ -37,15 +37,6 @@
#include "libecho/answertone.h"
#include "ph_socket.h"
#define LOGV5IF(v5i, ss, level, fmt, args ...) \
LOGP(ss, level, "(%s): " fmt, v5x_interface_name(v5i), ## args)
#define LOGV5L(v5l, ss, level, fmt, args ...) \
LOGP(ss, level, "(%s-L%u): " fmt, v5x_interface_name((v5l)->interface), (v5l)->id, ## args)
#define LOGV5UP(v5up, ss, level, fmt, args ...) \
LOGP(ss, level, "(%s-P%u): " fmt, v5x_interface_name((v5up)->interface), (v5up)->nr, ## args)
/* Table 35/G.964 */
enum v5x_mph_prim {
MPH_UBR, /* Unblock (req) */
@ -205,17 +196,15 @@ struct v5x_link {
struct osmo_fsm_inst *fi; /* Link Control FSM instance */
struct e1inp_line *e1_line; /* E1 line to use or NULL if not */
struct e1inp_line_ops e1_line_ops; /* use e1pinp_line->ops to point back to v5x_link */
int lof, los; /* current LOS and LOF state, used to determine good/bald link */
};
/* one V5.x interface between AN (Access Network) and LE (Local Exchange) */
struct v5x_interface {
struct llist_head list; /* instance.interfaces */
struct v5x_instance *instance; /* back-pointer */
char *name; /* user-configurable name */
enum v5x_dialect dialect;
uint32_t id, id_remote; /* interface id */
uint8_t variant, variant_remote; /* provisioning variant */
uint32_t id_local, id_remote; /* interface id */
uint8_t variant_local, variant_remote; /* provitioning variant */
bool id_remote_valid;
bool variant_remote_valid;
bool use_capability; /* use bearer transfer capability */
@ -290,7 +279,6 @@ struct v5x_pstn_proto {
struct v5x_mgmt_proto {
struct v5x_interface *interface; /* back-pointer to instance we're part of */
bool auto_restart; /* restart automatically after TC8/TC9 timeout */
bool pstn_enable_early; /* enable datalink before startup */
bool pstn_rs_pending; /* pending restart flag */
bool do_est; /* actively establish datalinks */
bool do_align; /* actively perform alignment */
@ -334,7 +322,6 @@ struct v5x_user_port {
struct v5x_interface *interface; /* back-pointer to instance we're part of */
uint16_t nr; /* port-number in decoded form (0..32767) */
char *name; /* user-configurable name */
char ifname[64]; /* name of interface, also used for PH-socket */
enum v5x_user_type type; /* type of port (ISDN/PSTN) */
@ -397,7 +384,7 @@ struct v5x_instance {
struct v5x_instance *v5x_instance_alloc(void *ctx);
void v5x_instance_free(struct v5x_instance *v5i);
struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, uint32_t id, enum v5x_dialect dialect);
struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, enum v5x_dialect dialect);
struct v5x_user_port *v5x_user_port_create(struct v5x_interface *v5if, uint16_t nr, enum v5x_user_type,
uint8_t ts1, uint8_t ts2);
void v5x_interface_free(struct v5x_interface *v5if);
@ -408,5 +395,3 @@ struct v5x_link *v5x_link_create(struct v5x_interface *v5if, uint8_t id);
int v5x_link_destroy(struct v5x_link *v5l);
int v5x_link_count(struct v5x_interface *v5if);
struct v5x_link *v5x_link_find_id(struct v5x_interface *v5if, uint8_t id);
const char *v5x_interface_name(const struct v5x_interface *v5if);

View File

@ -588,7 +588,7 @@ struct v5x_l1_proto *v5x_l1_fsm_create(void *ctx, struct v5x_link *v5l, uint8_t
l1->fi = osmo_fsm_inst_alloc(&v5x_l1_fsm, l1, l1, LOGL_DEBUG, NULL);
if (!l1->fi)
return NULL;
osmo_fsm_inst_update_id_f(l1->fi, "%s-L%u", v5x_interface_name(v5l->interface), id);
osmo_fsm_inst_update_id_f(l1->fi, "%d", id);
return l1;
}
@ -631,48 +631,47 @@ bool v5x_l1_is_up(struct v5x_l1_proto *l1)
int v5x_l1_signal_rcv(struct v5x_link *v5l, enum l1_signal_prim prim)
{
struct v5x_l1_proto *l1 = v5l->l1;
struct v5x_interface *v5if = v5l->interface;
struct osmo_fsm_inst *fi = l1->fi;
int state_changed = 0;
switch (prim) {
case L1_SIGNAL_LOS:
LOGV5L(v5l, DV5L1, LOGL_DEBUG, "Signal LOS detected on link %d of interface %d.\n", v5l->id, v5if->id);
LOGP(DV5L1, LOGL_DEBUG, "Signal LOS detected on link %d.\n", v5l->id);
if (!l1->los) {
l1->los = 1;
osmo_fsm_inst_dispatch(fi, V5X_L1FSM_E_LOS, NULL);
}
break;
case L1_SIGNAL_NO_LOS:
LOGV5L(v5l, DV5L1, LOGL_DEBUG, "Signal LOS gone on link %d of interface %d.\n", v5l->id, v5if->id);
LOGP(DV5L1, LOGL_DEBUG, "Signal LOS gone on link %d.\n", v5l->id);
if (l1->los) {
l1->los = 0;
state_changed = 1;
}
break;
case L1_SIGNAL_RAI:
LOGV5L(v5l, DV5L1, LOGL_DEBUG, "Signal RAI detected on link %d of interface %d.\n", v5l->id, v5if->id);
LOGP(DV5L1, LOGL_DEBUG, "Signal RAI detected on link %d.\n", v5l->id);
if (!l1->rai) {
l1->rai = 1;
osmo_fsm_inst_dispatch(fi, V5X_L1FSM_E_RAI, NULL);
}
break;
case L1_SIGNAL_NO_RAI:
LOGV5L(v5l, DV5L1, LOGL_DEBUG, "Signal RAI gone on link %d of interface %d.\n", v5l->id, v5if->id);
LOGP(DV5L1, LOGL_DEBUG, "Signal RAI gone on link %d.\n", v5l->id);
if (l1->rai) {
l1->rai = 0;
state_changed = 1;
}
break;
case L1_SIGNAL_AIS:
LOGV5L(v5l, DV5L1, LOGL_DEBUG, "Signal AIS detected on link %d of interface %d.\n", v5l->id, v5if->id);
LOGP(DV5L1, LOGL_DEBUG, "Signal AIS detected on link %d.\n", v5l->id);
if (!l1->ais) {
l1->ais = 1;
osmo_fsm_inst_dispatch(fi, V5X_L1FSM_E_AIS, NULL);
}
break;
case L1_SIGNAL_NO_AIS:
LOGV5L(v5l, DV5L1, LOGL_DEBUG, "Signal AIS gone on link %d of interface %d.\n", v5l->id, v5if->id);
LOGP(DV5L1, LOGL_DEBUG, "Signal AIS gone on link %d.\n", v5l->id);
if (l1->ais) {
l1->ais = 0;
state_changed = 1;
@ -681,20 +680,20 @@ int v5x_l1_signal_rcv(struct v5x_link *v5l, enum l1_signal_prim prim)
case L1_SIGNAL_SA7_0:
if (l1->sa7 != 0) {
LOGV5L(v5l, DV5L1, LOGL_DEBUG, "Bit Sa7=0 on link %d of interface %d.\n", v5l->id, v5if->id);
LOGP(DV5L1, LOGL_DEBUG, "Bit Sa7=0 on link %d.\n", v5l->id);
l1->sa7 = 0;
state_changed = 1;
}
break;
case L1_SIGNAL_SA7_1:
if (l1->sa7 != 1) {
LOGV5L(v5l, DV5L1, LOGL_DEBUG, "Bit Sa7=1 on link %d of interface %d.\n", v5l->id, v5if->id);
LOGP(DV5L1, LOGL_DEBUG, "Bit Sa7=1 on link %d.\n", v5l->id);
l1->sa7 = 1;
state_changed = 1;
}
break;
default:
LOGV5L(v5l, DV5L1, LOGL_NOTICE, "Invalid L1 primitive %d receied from physical layer.\n", prim);
LOGP(DV5L1, LOGL_NOTICE, "Invalid L1 primitive %d receied from physical layer.\n", prim);
return -EINVAL;
}
@ -734,7 +733,7 @@ void v5x_l1_mph_snd(struct v5x_link *v5l, enum v5x_mph_prim prim)
// FIXME: do we need this?
break;
default:
LOGV5L(v5l, DV5PORT, LOGL_NOTICE, "Got invalid prim %d at this protocol\n", prim);
LOGP(DV5PORT, LOGL_NOTICE, "Got invalid prim %d at this protocol\n", prim);
return;
}

View File

@ -1,11 +1,3 @@
#pragma once
#include <stdint.h>
struct v5x_link;
enum v5x_mph_prim;
struct v5x_l1_proto;
enum l1_signal_prim;
void v5x_l1_mph_snd(struct v5x_link *v5i, enum v5x_mph_prim prim);
struct v5x_l1_proto *v5x_l1_fsm_create(void *ctx, struct v5x_link *v5l, uint8_t id);

View File

@ -99,7 +99,7 @@ static void v5x_ctrl_mdu(struct osmo_fsm_inst *fi, const struct tlv_parsed *tp)
rej_cause = 0;
interface_id = 0;
LOGPFSML(fi, LOGL_DEBUG, "MDU-CTRL received.\n");
LOGP(DV5CTRL, LOGL_DEBUG, "MDU-CTRL received.\n");
if (TLVP_PRESENT(tp, V5X_CTRL_IEI_VARIANT))
variant = *TLVP_VAL(tp, V5X_CTRL_IEI_VARIANT) & 0x7f;
@ -113,7 +113,7 @@ static void v5x_ctrl_mdu(struct osmo_fsm_inst *fi, const struct tlv_parsed *tp)
cfe = *TLVP_VAL(tp, V5X_CTRL_IEI_CTRL_F_ELEMENT) & 0x7f;
perf_grading = 0;
LOGPFSML(fi, LOGL_DEBUG, "FE received for address %d.\n", v5up->nr);
LOGP(DV5CTRL, LOGL_DEBUG, "FE received for address %d.\n", v5up->nr);
if (TLVP_PRESENT(tp, V5X_CTRL_IEI_PERFORMANCE_GRADING))
perf_grading = *TLVP_VAL(tp, V5X_CTRL_IEI_PERFORMANCE_GRADING) & 0x0f;
@ -129,7 +129,7 @@ static void v5x_ctrl_mdu(struct osmo_fsm_inst *fi, const struct tlv_parsed *tp)
case V5X_CTRL_TYPE_LINK:
lcf = *TLVP_VAL(tp, V52_CTRL_IEI_LCP_LINK_CTRL_FUNCTION) & 0x7f;
LOGPFSML(fi, LOGL_DEBUG, "FE received for link ID %d.\n", v5l->id);
LOGP(DV5CTRL, LOGL_DEBUG, "FE received for link ID %d.\n", v5l->id);
v52_le_lcp_fe_rcv(v5l, lcf);
break;
@ -137,9 +137,9 @@ static void v5x_ctrl_mdu(struct osmo_fsm_inst *fi, const struct tlv_parsed *tp)
}
/* display MDU-error_indication */
static void v5x_mdu_error(struct osmo_fsm_inst *fi, const char *error)
static void v5x_mdu_error(struct osmo_fsm_inst __attribute__((unused)) *fi, const char *error)
{
LOGPFSML(fi, LOGL_NOTICE, "MDU-error_indication: %s\n", error);
LOGP(DV5CTRL, LOGL_NOTICE, "MDU-error_indication: %s\n", error);
}
/* send control towards lower (DL) layer */
@ -152,7 +152,7 @@ static void v5x_ctrl_send(struct v5x_ctrl_proto *ctrl, struct msgb *msg)
switch (fi->state) {
case V5X_CTRL_ST_IN_SERVICE:
LOGPFSML(fi, LOGL_DEBUG, "We are in service, so we send our message now.\n");
LOGP(DV5CTRL, LOGL_DEBUG, "We are in service, so we send our message now.\n");
/* no message, clone current message and store to be repeated */
ctrl->tx_msg = msgb_copy(msg, NULL);
/* go to AWAIT_PENDING_ACK */
@ -175,7 +175,7 @@ static void v5x_ctrl_send(struct v5x_ctrl_proto *ctrl, struct msgb *msg)
#endif
break;
case V5X_CTRL_ST_AWAIT_ACK:
LOGPFSML(fi, LOGL_DEBUG, "We are waiting for ack, so we queue our message.\n");
LOGP(DV5CTRL, LOGL_DEBUG, "We are waiting for ack, so we queue our message.\n");
/* pending message, save message in queue */
msgb_enqueue(&ctrl->tx_queue, msg);
break;
@ -188,7 +188,7 @@ static void v5x_ctrl_ack(struct osmo_fsm_inst *fi, const struct tlv_parsed __att
struct v5x_ctrl_proto *ctrl = fi->priv;
struct msgb *msg;
LOGPFSML(fi, LOGL_DEBUG, "Received acknowledge, removing pending message, if any.\n");
LOGP(DV5CTRL, LOGL_DEBUG, "Received acknowledge, removing pending message, if any.\n");
/* free pending copy of message, if acked before retry */
if (ctrl->tx_msg) {
msgb_free(ctrl->tx_msg);
@ -199,7 +199,7 @@ static void v5x_ctrl_ack(struct osmo_fsm_inst *fi, const struct tlv_parsed __att
/* sending next pending message in queue */
msg = msgb_dequeue(&ctrl->tx_queue);
if (msg) {
LOGPFSML(fi, LOGL_DEBUG, "Found pending message in queue.\n");
LOGP(DV5CTRL, LOGL_DEBUG, "Found pending message in queue.\n");
v5x_ctrl_send(ctrl, msg);
}
}
@ -231,7 +231,7 @@ static int v5x_ctrl_fsm_timer_cb(struct osmo_fsm_inst *fi)
struct msgb *msg;
if (ctrl->tx_msg) {
LOGPFSML(fi, LOGL_DEBUG, "Timer fired the first time, resending message.\n");
LOGP(DV5CTRL, LOGL_DEBUG, "Timer fired the first time, resending message.\n");
/* first expiry: repeat CONTROL; re-start T01 */
/* send message towards DL */
osmo_timer_schedule(&fi->timer, TIMEOUT, 0);
@ -249,14 +249,14 @@ static int v5x_ctrl_fsm_timer_cb(struct osmo_fsm_inst *fi)
break;
}
} else {
LOGPFSML(fi, LOGL_DEBUG, "Timer fired the second time, indicate an error.\n");
LOGP(DV5CTRL, LOGL_DEBUG, "Timer fired the second time, indicate an error.\n");
/* second expiry: send MDU-error_ind; go to IN_SERVICE */
v5x_mdu_error(fi, "Second timeout while waiting for CONTROL ACK.");
osmo_fsm_inst_state_chg(fi, V5X_CTRL_ST_IN_SERVICE, 0, 0);
/* sending next pending message in queue */
msg = msgb_dequeue(&ctrl->tx_queue);
if (msg) {
LOGPFSML(fi, LOGL_DEBUG, "Found pending message in queue.\n");
LOGP(DV5CTRL, LOGL_DEBUG, "Found pending message in queue.\n");
v5x_ctrl_send(ctrl, msg);
}
}
@ -392,9 +392,6 @@ void v5x_le_ctrl_init(void)
struct v5x_ctrl_proto *v5x_le_ctrl_create(enum v5x_ctrl_type type, void *ctx, void *priv, uint16_t nr)
{
struct v5x_ctrl_proto *ctrl;
struct v5x_link *v5l = NULL;
struct v5x_interface *v5if = NULL;
struct v5x_user_port *v5up = NULL;
OSMO_ASSERT(priv);
@ -410,21 +407,7 @@ struct v5x_ctrl_proto *v5x_le_ctrl_create(enum v5x_ctrl_type type, void *ctx, vo
v5x_le_ctrl_destroy(ctrl);
return NULL;
}
switch (type) {
case V5X_CTRL_TYPE_LINK:
v5l = priv;
osmo_fsm_inst_update_id_f(ctrl->fi, "%s-LINK-L%u", v5x_interface_name(v5l->interface), nr);
break;
case V5X_CTRL_TYPE_COMMON:
v5if = priv;
osmo_fsm_inst_update_id_f(ctrl->fi, "%s-COMMON", v5x_interface_name(v5if));
break;
case V5X_CTRL_TYPE_PORT:
v5up = priv;
osmo_fsm_inst_update_id_f(ctrl->fi, "%s-PORT-P%u", v5x_interface_name(v5up->interface), nr);
break;
}
osmo_fsm_inst_update_id_f(ctrl->fi, "%d", nr);
return ctrl;
}
@ -650,8 +633,8 @@ int v5x_le_ctrl_dl_rcv(struct v5x_interface *v5if, uint16_t l3_addr, bool is_isd
case V5X_CTRL_MSGT_PORT_CTRL_ACK:
v5up = v5x_user_port_find(v5if, l3_addr, is_isdn);
if (!v5up) {
LOGV5IF(v5if, DV5CTRL, LOGL_ERROR, "Received %s port control message with unknown layer 3 address %d. "
"Please check provisioning!\n", is_isdn ? "ISDN" : "PSTN", l3_addr);
LOGP(DV5CTRL, LOGL_ERROR, "Received %s port control message with unknown layer 3 address %d. "
"Please check provisioning!\n", is_isdn ? "ISDN" : "PSTN", l3_addr);
return -ENODEV;
}
return v5x_rcv_ctrl_port(v5up, msg_type, tp);
@ -664,8 +647,8 @@ int v5x_le_ctrl_dl_rcv(struct v5x_interface *v5if, uint16_t l3_addr, bool is_isd
case V52_CTRL_MSGT_LCP_LINK_CTRL_ACK:
v5l = v5x_link_find_id(v5if, l3_addr);
if (!v5l) {
LOGV5IF(v5if, DV5CTRL, LOGL_ERROR, "Received link control message with unknown link ID %d. Please "
"check provisioning!\n", l3_addr);
LOGP(DV5CTRL, LOGL_ERROR, "Received link control message with unknown link ID %d. Please "
"check provisioning!\n", l3_addr);
return -ENODEV;
}
return v52_rcv_ctrl_link(v5l, msg_type, tp);
@ -682,7 +665,7 @@ int v5x_le_ctrl_dl_rcv(struct v5x_interface *v5if, uint16_t l3_addr, bool is_isd
int v5x_le_ctrl_common_snd(struct v5x_interface *v5if, enum v5x_ctrl_func_id cfi,
uint8_t *rej_cause, uint8_t *variant, uint32_t *interface_id)
{
LOGV5IF(v5if, DV5CTRL, LOGL_DEBUG, "Sending MDU-CTRL (from common control).\n");
LOGP(DV5CTRL, LOGL_DEBUG, "Sending MDU-CTRL (from common control).\n");
osmo_fsm_inst_dispatch(v5if->control.ctrl->fi, V5X_CTRL_EV_MDU_CTRL,
v5x_enc_ctrl_common(cfi, variant, rej_cause, interface_id));
@ -692,7 +675,7 @@ int v5x_le_ctrl_common_snd(struct v5x_interface *v5if, enum v5x_ctrl_func_id cfi
/* send port message from upper layer */
int v5x_le_ctrl_port_snd(struct v5x_user_port *v5up, enum v5x_ctrl_func_el cfe)
{
LOGV5UP(v5up, DV5CTRL, LOGL_DEBUG, "Sending FE (from port).\n");
LOGP(DV5CTRL, LOGL_DEBUG, "Sending FE (from port).\n");
osmo_fsm_inst_dispatch(v5up->ctrl->fi, V5X_CTRL_EV_MDU_CTRL,
v5x_enc_ctrl_port(v5up, cfe, v5up->type == V5X_USER_TYPE_ISDN));
@ -702,7 +685,7 @@ int v5x_le_ctrl_port_snd(struct v5x_user_port *v5up, enum v5x_ctrl_func_el cfe)
/* send link message from upper layer */
int v52_le_ctrl_link_snd(struct v5x_link *v5l, enum v52_link_ctrl_func lcf)
{
LOGV5L(v5l, DV5CTRL, LOGL_DEBUG, "Sending FE (from LCP).\n");
LOGP(DV5CTRL, LOGL_DEBUG, "Sending FE (from LCP).\n");
osmo_fsm_inst_dispatch(v5l->ctrl->fi, V5X_CTRL_EV_MDU_CTRL,
v52_enc_ctrl_link(v5l, lcf));

View File

@ -1,15 +1,3 @@
#pragma once
#include <stdint.h>
struct v5x_ctrl_proto;
struct v5x_interface;
struct v5x_user_port;
enum v5x_ctrl_type;
enum v5x_ctrl_func_id;
enum v5x_ctrl_func_el;
enum v52_link_ctrl_func;
struct tlv_parsed;
void v5x_le_ctrl_init(void);
struct v5x_ctrl_proto *v5x_le_ctrl_create(enum v5x_ctrl_type type, void *ctx, void *priv, uint16_t nr);

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +1,3 @@
#pragma once
#include <stdint.h>
struct osmo_fsm_inst;
struct v5x_interface;
struct v5x_mgmt_proto;
struct v5x_link;
struct v5x_user_port;
enum v5x_mgmt_prim;
struct msgb;
const char *v5x_le_system_fsm_state_name(struct osmo_fsm_inst *fi);
const char *v5x_le_pstn_dl_fsm_state_name(struct osmo_fsm_inst *fi);

View File

@ -1,29 +1,5 @@
/* ITU-T G.964 Section 14.1.3.2.2 ISDN user port FSM - LE */
/* (C) 2021-2022 by Harald Welte <laforge@gnumonks.org>
* (C) 2022-2023 by Andreas Eversberg <jolly@eversberg.eu>
*
* All Rights Reserved
*
* SPDX-License-Identifier: GPL-2.0+
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
/***********************************************************************/
/* internal data structures */
/***********************************************************************/
@ -553,7 +529,7 @@ struct osmo_fsm_inst *v5x_le_port_isdn_create(struct v5x_user_port *v5up, uint16
fi = osmo_fsm_inst_alloc(&v5x_le_ctrl_isdn_port_fsm, v5up, v5up, LOGL_DEBUG, NULL);
if (!fi)
return NULL;
osmo_fsm_inst_update_id_f(fi, "%s-P%d", v5x_interface_name(v5up->interface), nr);
osmo_fsm_inst_update_id_f(fi, "%d", nr);
return fi;
}
@ -565,13 +541,13 @@ bool v5x_le_port_isdn_is_operational(struct osmo_fsm_inst *fi)
void v5x_le_port_isdn_block(struct osmo_fsm_inst *fi)
{
LOGPFSML(fi, LOGL_DEBUG, "Put ISDN port into blocked state\n");
LOGP(DV5PORT, LOGL_DEBUG, "Put ISDN port into blocked state\n");
fi->state = V5X_LE_UP_I_S_LE10_NOP_BLOCKED;
}
void v5x_le_port_isdn_unblock(struct osmo_fsm_inst *fi)
{
LOGPFSML(fi, LOGL_DEBUG, "Put ISDN port into unblocked state\n");
LOGP(DV5PORT, LOGL_DEBUG, "Put ISDN port into unblocked state\n");
fi->state = V5X_LE_UP_I_S_LE20_OP_OPERATIONAL_DEACTIVTED;
}
@ -794,13 +770,13 @@ bool v5x_le_port_pstn_is_operational(struct osmo_fsm_inst *fi)
void v5x_le_port_pstn_block(struct osmo_fsm_inst *fi)
{
LOGPFSML(fi, LOGL_DEBUG, "Put PSTN port into blocked state\n");
LOGP(DV5PORT, LOGL_DEBUG, "Put PSTN port into blocked state\n");
fi->state = V5X_LE_UP_P_S_LE10_NOP_BLOCKED;
}
void v5x_le_port_pstn_unblock(struct osmo_fsm_inst *fi)
{
LOGPFSML(fi, LOGL_DEBUG, "Put PSTN port into unblocked state\n");
LOGP(DV5PORT, LOGL_DEBUG, "Put PSTN port into unblocked state\n");
fi->state = V5X_LE_UP_P_S_LE20_OPERATIONAL;
}
@ -830,7 +806,7 @@ void v5x_le_port_pstn_fe_rcv(struct v5x_user_port *v5up, uint8_t cfe)
event = V5X_CUP_LE_FE205_BLOCK_REQ;
break;
default:
LOGPFSML(fi, LOGL_NOTICE, "Received cfe %d not valid at this protocol\n", cfe);
LOGP(DV5PORT, LOGL_NOTICE, "Received cfe %d not valid at this protocol\n", cfe);
}
/* send event to FSM */
@ -868,7 +844,7 @@ void v5x_le_port_isdn_fe_rcv(struct v5x_user_port *v5up, uint8_t cfe, uint8_t pe
event = V5X_CUP_LE_FE206_PREFORMANCE_GRADING_IND;
break;
default:
LOGV5UP(v5up, DV5PORT, LOGL_NOTICE, "Received cfe %d not valid at this protocol\n", cfe);
LOGP(DV5PORT, LOGL_NOTICE, "Received cfe %d not valid at this protocol\n", cfe);
break;
}
@ -902,7 +878,7 @@ void v5x_port_mph_snd(struct v5x_user_port *v5up, enum v5x_mph_prim prim)
event = V5X_CUP_LE_MPH_DU_BLOCK_DCHAN_REQ;
break;
default:
LOGV5UP(v5up, DV5PORT, LOGL_NOTICE, "Got invalid prim %d at this protocol\n", prim);
LOGP(DV5PORT, LOGL_NOTICE, "Got invalid prim %d at this protocol\n", prim);
return;
}

View File

@ -1,10 +1,3 @@
#pragma once
#include <stdint.h>
struct v5x_user_port;
enum v5x_mph_prim;
struct osmo_fsm_inst;
void v5x_port_mph_snd(struct v5x_user_port *v5up, enum v5x_mph_prim prim);

View File

@ -382,7 +382,7 @@ void v5x_le_pstn_fe_snd(struct v5x_user_port *v5up, enum v5x_fe_prim prim, struc
event = V5x_PSTN_LE_FE_disconnect_compl_req;
break;
default:
LOGPFSML(v5up->port_fi, LOGL_NOTICE, "Got invalid prim %d at this protocol\n", prim);
LOGP(DV5PSTN, LOGL_NOTICE, "Got invalid prim %d at this protocol\n", prim);
return;
}
@ -412,7 +412,7 @@ void v5x_le_pstn_mdu_snd(struct v5x_user_port *v5up, enum v5x_mgmt_prim prim)
event = V5x_PSTN_LE_MDU_CTRL_restart_compl_req;
break;
default:
LOGPFSML(v5up->port_fi, LOGL_NOTICE, "Got invalid prim %d at this protocol\n", prim);
LOGP(DV5PSTN, LOGL_NOTICE, "Got invalid prim %d at this protocol\n", prim);
return;
}
@ -437,20 +437,20 @@ static void dl_send(struct osmo_fsm_inst *fi, struct msgb *msg)
static void start_timer_Tr(struct v5x_pstn_proto *pstn)
{
LOGPFSML(pstn->fi, LOGL_DEBUG, "Start timer Tr\n");
LOGP(DV5PSTN, LOGL_DEBUG, "Start timer Tr\n");
osmo_timer_schedule(&pstn->timer_Tr, TIMEOUT_Tr, 0);
}
static void start_timer_Tt(struct v5x_pstn_proto *pstn)
{
LOGPFSML(pstn->fi, LOGL_DEBUG, "Start timer Tt\n");
LOGP(DV5PSTN, LOGL_DEBUG, "Start timer Tt\n");
osmo_timer_schedule(&pstn->timer_Tt, TIMEOUT_Tt, 0);
}
static void stop_timer_Tr(struct v5x_pstn_proto *pstn)
{
if (osmo_timer_pending(&pstn->timer_Tr)) {
LOGPFSML(pstn->fi, LOGL_DEBUG, "Stop timer Tr\n");
LOGP(DV5PSTN, LOGL_DEBUG, "Stop timer Tr\n");
osmo_timer_del(&pstn->timer_Tr);
}
}
@ -458,7 +458,7 @@ static void stop_timer_Tr(struct v5x_pstn_proto *pstn)
static void stop_timer_Tt(struct v5x_pstn_proto *pstn)
{
if (osmo_timer_pending(&pstn->timer_Tt)) {
LOGPFSML(pstn->fi, LOGL_DEBUG, "Stop timer Tt\n");
LOGP(DV5PSTN, LOGL_DEBUG, "Stop timer Tt\n");
osmo_timer_del(&pstn->timer_Tt);
}
}
@ -467,7 +467,7 @@ static void stop_timer(struct osmo_fsm_inst *fi)
{
struct v5x_pstn_proto *pstn = fi->priv;
LOGPFSML(fi, LOGL_DEBUG, "Stop all timers\n");
LOGP(DV5PSTN, LOGL_DEBUG, "Stop all timers\n");
osmo_timer_del(&fi->timer);
stop_timer_Tr(pstn);
stop_timer_Tt(pstn);
@ -499,7 +499,7 @@ static void start_timer(struct osmo_fsm_inst *fi, enum v5x_le_pstn_fsm_event eve
OSMO_ASSERT(0);
}
LOGPFSML(fi, LOGL_DEBUG, "Start timer %s (count = %d)\n", timer_name, count);
LOGP(DV5PSTN, LOGL_DEBUG, "Start timer %s (count = %d)\n", timer_name, count);
pstn->timeout_event = event;
pstn->timeout_count = count;
osmo_timer_schedule(&fi->timer, timeout, 0);
@ -532,7 +532,7 @@ static void do_status_enquiry(struct osmo_fsm_inst *fi)
{
struct v5x_pstn_proto *pstn = fi->priv;
LOGPFSML(fi, LOGL_NOTICE, "Received message not allowed in current state, sending status enquiry.\n");
LOGP(DV5PSTN, LOGL_NOTICE, "Received message not allowed in current state, sending status enquiry.\n");
/* start T4 */
start_timer(fi, V5x_PSTN_LE_TIMEOUT_T4, 1);
@ -1036,8 +1036,8 @@ static void pstn_le4_path_active(struct osmo_fsm_inst *fi, uint32_t event, void
/* get sequence number and check if msg is in sequence */
seq_nr = *TLVP_VAL(tp, V5X_CTRL_IEI_SEQUENCE_NR) & 0x7f;
if (pstn->S_r == seq_nr) {
LOGPFSML(fi, LOGL_DEBUG, "Received expected 'receive' sequence number: S(R)=%d == M(R)=%d\n",
pstn->S_r, seq_nr);
LOGP(DV5PSTN, LOGL_DEBUG, "Received expected 'receive' sequence number: S(R)=%d == M(R)=%d\n",
pstn->S_r, seq_nr);
/* start Tr, if not pending */
if (!osmo_timer_pending(&pstn->timer_Tr))
start_timer_Tr(pstn);
@ -1046,8 +1046,8 @@ static void pstn_le4_path_active(struct osmo_fsm_inst *fi, uint32_t event, void
/* send FE-signal_indication */
rcv_fe(fi, FE_line_signal_ind, tp);
} else {
LOGPFSML(fi, LOGL_ERROR, "Invalid 'receive' sequence number: S(R)=%d != M(R)=%d\n",
pstn->S_r, seq_nr);
LOGP(DV5PSTN, LOGL_ERROR, "Invalid 'receive' sequence number: S(R)=%d != M(R)=%d\n",
pstn->S_r, seq_nr);
/* send FE-signal_indication */
rcv_fe(fi, FE_line_signal_ind, tp);
/* do several thing here */
@ -1059,23 +1059,23 @@ static void pstn_le4_path_active(struct osmo_fsm_inst *fi, uint32_t event, void
unacked = (pstn->S_s - pstn->S_a) & 127;
acked = (pstn->S_s - seq_nr) & 127;
if (acked <= unacked) {
LOGPFSML(fi, LOGL_DEBUG, "Received expected 'transmit' sequence number: M(R)=%d is inside "
"S(A)=%d...S(S)=%d range\n", seq_nr, pstn->S_a, pstn->S_s);
LOGPFSML(fi, LOGL_DEBUG, "We had %d unacked messages, now we have %d acked messages.\n", unacked, acked);
LOGP(DV5PSTN, LOGL_DEBUG, "Received expected 'transmit' sequence number: M(R)=%d is inside "
"S(A)=%d...S(S)=%d range\n", seq_nr, pstn->S_a, pstn->S_s);
LOGP(DV5PSTN, LOGL_DEBUG, "We had %d unacked messages, now we have %d acked messages.\n", unacked, acked);
/* update acknowledge sequence number */
pstn->S_a = seq_nr;
if (pstn->S_a == pstn->S_s) {
LOGPFSML(fi, LOGL_DEBUG, "No more outstanding message, so we don't need Tt anymore.\n");
LOGP(DV5PSTN, LOGL_DEBUG, "No more outstanding message, so we don't need Tt anymore.\n");
/* stop Tt */
stop_timer_Tt(pstn);
} else {
LOGPFSML(fi, LOGL_DEBUG, "There are still outstanding message, we still need Tt.\n");
LOGP(DV5PSTN, LOGL_DEBUG, "There are still outstanding message, we still need Tt.\n");
/* start Tt */
start_timer_Tt(pstn);
}
} else {
LOGPFSML(fi, LOGL_ERROR, "Invalid 'transmit' sequence number: M(R)=%d not inside "
"S(A)=%d...S(S)=%d range\n", seq_nr, pstn->S_a, pstn->S_s);
LOGP(DV5PSTN, LOGL_ERROR, "Invalid 'transmit' sequence number: M(R)=%d not inside "
"S(A)=%d...S(S)=%d range\n", seq_nr, pstn->S_a, pstn->S_s);
/* do several thing here */
do_disconnect_with_error(fi);
}
@ -1180,13 +1180,13 @@ static void pstn_le4_path_active(struct osmo_fsm_inst *fi, uint32_t event, void
break;
case V5x_PSTN_LE_TIMEOUT_Tr:
/* send SIGNAL ACK */
LOGPFSML(fi, LOGL_DEBUG, "Sending recent 'receive' sequence number: S(R)=%d as acknowledge.\n",
pstn->S_r);
LOGP(DV5PSTN, LOGL_DEBUG, "Sending recent 'receive' sequence number: S(R)=%d as acknowledge.\n",
pstn->S_r);
dl_send(fi, v5x_enc_signal_ack(pstn->v5up, pstn->S_r));
break;
case V5x_PSTN_LE_TIMEOUT_Tt:
/* do several thing here */
LOGPFSML(fi, LOGL_ERROR, "Aborting, because of missing acknowledge of outstanding 'transmit' sequence number: S(A)=%d...S(S)=%d\n", pstn->S_a, pstn->S_s);
LOGP(DV5PSTN, LOGL_ERROR, "Aborting, because of missing acknowledge of outstanding 'transmit' sequence number: S(A)=%d...S(S)=%d\n", pstn->S_a, pstn->S_s);
do_disconnect_with_error(fi);
break;
default:
@ -1592,7 +1592,7 @@ int v5x_le_pstn_dl_rcv(struct v5x_user_port *v5up, uint8_t msg_type, const struc
event = V5x_PSTN_LE_STATUS;
break;
default:
LOGPFSML(v5up->port_fi, LOGL_NOTICE, "Invalid PSTN protocol message %d receied from AN.\n", msg_type);
LOGP(DV5PSTN, LOGL_NOTICE, "Invalid PSTN protocol message %d receied from AN.\n", msg_type);
return -EINVAL;
}

View File

@ -1,15 +1,3 @@
#pragma once
#include <stdint.h>
struct v5x_pstn_proto;
struct v5x_user_port;
struct v5x_l1_proto;
struct v5x_user_port;
enum v5x_fe_prim;
enum v5x_mgmt_prim;
struct msgb;
struct tlv_parsed;
struct v5x_pstn_proto *v5x_le_pstn_create(struct v5x_user_port *v5up, uint16_t nr);
void v5x_le_pstn_destroy(struct v5x_pstn_proto *pstn);

View File

@ -1,5 +1,4 @@
/* (C) 2021-2022 by Harald Welte <laforge@gnumonks.org>
* (C) 2022-2023 by Andreas Eversberg <jolly@eversberg.eu>
/* (C) 2021 by Harald Welte <laforge@gnumonks.org>
*
* All Rights Reserved
*
@ -398,10 +397,10 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
switch (odp->oph.primitive) {
case PRIM_DL_DATA:
LOGV5IF(v5if, DV5, LOGL_DEBUG, "DL-DATA indication received (ldaddr=%d)\n", dladdr);
LOGP(DV5, LOGL_DEBUG, "DL-DATA indication received (ldaddr=%d)\n", dladdr);
break;
case PRIM_DL_EST:
LOGV5IF(v5if, DV5, LOGL_DEBUG, "DL-EST indication received (ldaddr=%d)\n", dladdr);
LOGP(DV5, LOGL_DEBUG, "DL-EST indication received (ldaddr=%d)\n", dladdr);
switch (dladdr) {
case V5X_DLADDR_CTRL:
case V5X_DLADDR_PSTN:
@ -415,7 +414,7 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
}
goto out;
case PRIM_DL_REL:
LOGV5IF(v5if, DV5, LOGL_DEBUG, "DL-REL indication received (ldaddr=%d)\n", dladdr);
LOGP(DV5, LOGL_DEBUG, "DL-REL indication received (ldaddr=%d)\n", dladdr);
switch (dladdr) {
case V5X_DLADDR_CTRL:
case V5X_DLADDR_PSTN:
@ -428,12 +427,8 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
break;
}
goto out;
case PRIM_MDL_ERROR:
/* already generates a log message in lapd_core.c, suppress the below log line */
rc = 0;
goto out;
default:
LOGV5IF(v5if, DV5, LOGL_NOTICE, "Unhandled prim=%d (ldaddr=%d)\n", odp->oph.primitive, dladdr);
LOGP(DV5, LOGL_NOTICE, "Unhandled prim=%d (ldaddr=%d)\n", odp->oph.primitive, dladdr);
rc = -EINVAL;
goto out;
}
@ -441,13 +436,13 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
l3h = msgb_l3(msg);
if (msgb_l3len(msg) < sizeof(*l3h)) {
LOGV5IF(v5if, DV5, LOGL_ERROR, "Received short message (%u bytes < %lu)\n", msgb_l3len(msg), sizeof(*l3h));
LOGP(DV5, LOGL_ERROR, "Received short message (%u bytes < %lu)\n", msgb_l3len(msg), sizeof(*l3h));
rc = -EINVAL;
goto out;
}
if (l3h->pdisc != V5X_CTRL_PDISC) {
LOGV5IF(v5if, DV5, LOGL_ERROR, "Received unsupported protocol discriminator 0x%02x\n", l3h->pdisc);
LOGP(DV5, LOGL_ERROR, "Received unsupported protocol discriminator 0x%02x\n", l3h->pdisc);
rc = -EINVAL;
goto out;
}
@ -457,7 +452,7 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
if (rc < 0)
goto out;
LOGV5IF(v5if, DV5, LOGL_DEBUG, "Received message from AN with msg_type %d\n", l3h->msg_type);
LOGP(DV5, LOGL_DEBUG, "Received message from AN with msg_type %d\n", l3h->msg_type);
switch (dladdr) {
case V5X_DLADDR_PSTN:
@ -483,7 +478,7 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
break;
default:
rc = -ENOTSUP;
LOGV5IF(v5if, DV5, LOGL_ERROR, "Received unsupported PSTN message type %s\n",
LOGP(DV5, LOGL_ERROR, "Received unsupported PSTN message type %s\n",
osmo_tlv_prot_msg_name(&v5x_ctrl_msg_tlv, l3h->msg_type));
}
break;
@ -500,7 +495,7 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
break;
default:
rc = -ENOTSUP;
LOGV5IF(v5if, DV5, LOGL_ERROR, "Received unsupported CTRL message type %s\n",
LOGP(DV5, LOGL_ERROR, "Received unsupported CTRL message type %s\n",
osmo_tlv_prot_msg_name(&v5x_ctrl_msg_tlv, l3h->msg_type));
}
break;
@ -522,7 +517,7 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
break;
default:
rc = -ENOTSUP;
LOGV5IF(v5if, DV5, LOGL_ERROR, "Received unsupported BCC message type %s\n",
LOGP(DV5, LOGL_ERROR, "Received unsupported BCC message type %s\n",
osmo_tlv_prot_msg_name(&v5x_ctrl_msg_tlv, l3h->msg_type));
}
break;
@ -541,7 +536,7 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
break;
default:
rc = -ENOTSUP;
LOGV5IF(v5if, DV5, LOGL_ERROR, "Received unsupported PROTECTION message type %s\n",
LOGP(DV5, LOGL_ERROR, "Received unsupported PROTECTION message type %s\n",
osmo_tlv_prot_msg_name(&v5x_ctrl_msg_tlv, l3h->msg_type));
}
break;
@ -554,13 +549,13 @@ int v5x_dl_rcv(struct osmo_dlsap_prim *odp, uint16_t dladdr, void *rx_cbdata)
break;
default:
rc = -ENOTSUP;
LOGV5IF(v5if, DV5, LOGL_ERROR, "Received unsupported LCP message type %s\n",
LOGP(DV5, LOGL_ERROR, "Received unsupported LCP message type %s\n",
osmo_tlv_prot_msg_name(&v5x_ctrl_msg_tlv, l3h->msg_type));
}
break;
default:
rc = -ENOTSUP;
LOGV5IF(v5if, DV5, LOGL_ERROR, "Received unsupported message type %s\n",
LOGP(DV5, LOGL_ERROR, "Received unsupported message type %s\n",
osmo_tlv_prot_msg_name(&v5x_ctrl_msg_tlv, l3h->msg_type));
}
@ -596,7 +591,7 @@ int v5x_dl_snd(struct v5x_interface *v5if, uint16_t dladdr, struct msgb *msg)
}
if (!li) {
LOGV5IF(v5if, DV5, LOGL_ERROR, "No instance for dladdr %d.\n", dladdr);
LOGP(DV5, LOGL_ERROR, "No instance for dladdr %d.\n", dladdr);
msgb_free(msg);
return -EINVAL;
}

View File

@ -6,8 +6,7 @@
/* Definitions related to the V5.1 and V5.2 interface between AN (access
* network) and LE (local exchange) as per ITU-T G.964 + G.965.
*
* (C) 2021-2022 by Harald Welte <laforge@gnumonks.org>
* (C) 2022-2023 by Andreas Eversberg <jolly@eversberg.eu>
* (C) 2021 by Harald Welte <laforge@gnumonks.org>
*/
/***********************************************************************/