#pragma once /* (C) 2021 by Harald Welte * * 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 #include #include struct osmo_fsm_inst; enum v5x_dialect { V5X_DIALECT_V51 = 1, V5X_DIALECT_V52 = 2, }; /* forward-declarations */ struct v5x_interface; struct v5x_instance; struct v5x_link; /* A C-channel is a 64k timeslot used for signalling */ struct v5x_c_channel { struct v5x_link *link; /* back-pointer */ struct v5x_timeslot *ts; /* E1 link timeslot. NULL = C-channel doesn't exist */ bool active; /* false == standby */ }; /* one physical E1 timeslot used on an E1 interface part of a V5.2 interface */ struct v5x_timeslot { uint8_t nr; struct v5x_link *link; /* back-pointer */ uint16_t l3_address; }; /* one physical E1 interface used within a V5.2 interface */ struct v5x_link { uint8_t id; struct v5x_interface *interface; /* back-pointer */ struct v5x_timeslot ts[32]; /* 32 E1 slots; 0 not available */ struct v5x_c_channel c_channel[3]; /* 64k signaling possible on TS16, TS15 and TS31 */ struct osmo_fsm_inst *l1_link_fi; /* Layer 1 Link FSM instance */ }; /* 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 */ enum v5x_dialect dialect; struct v5x_link *primary_link; /* one of the links below */ struct v5x_link *secondary_link; /* one of the links below */ /* 1..16 links in one interface */ struct v5x_link links[16]; struct osmo_fsm_inst *fi; /* Interface FSM instance */ struct { struct lapd_datalink dl; /* Control data link */ struct v5x_c_channel *c_chan; /* pointer to active C-channel */ } control; struct { struct lapd_datalink dl; /* Link control data link */ struct v5x_c_channel *c_chan; /* pointer to active C-channel */ struct osmo_fsm_inst *fi; /* Link Control FSM instance */ } lcp; struct { struct lapd_datalink dl; /* PSTN data link */ struct v5x_c_channel *c_chan; /* pointer to active C-channel */ } pstn; struct { struct lapd_datalink dl; /* BCC data link */ struct v5x_c_channel *c_chan; /* pointer to active C-channel */ } bcc; struct { struct lapd_datalink dl; /* Protection data link 1 + 2 */ struct v5x_c_channel *c_chan; /* pointer to active C-channel */ } protection[2]; }; /* one user-facing port (subscriber line) */ struct v5x_user_port { struct llist_head list; /* part of v5x_instance.ports */ struct v5x_instance *inst; /* back-pointer to instance we're part of */ uint16_t nr; /* port-number in decoded form (0..32767) */ bool is_isdn; /* is this port an ISDN port? */ struct { struct osmo_fsm_inst *ctrl_fi; /* control protocol FSM instance */ struct osmo_fsm_inst *fi; /* port state FSM instance */ } isdn; struct { } pstn; }; struct v5x_instance { struct llist_head list; /* part of global list of instances */ struct llist_head interfaces; /* v5x_interface.list */ struct llist_head user_ports; /* list of v5x_user_port */ struct osmo_fsm_inst *ctrl_fi; /* common control FSM */ }; struct v5x_instance *v5x_instance_alloc(void *ctx); struct v5x_interface *v5x_interface_alloc(struct v5x_instance *v5i, enum v5x_dialect dialect);