diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2020-11-19 00:41:29 +0100 |
---|---|---|
committer | Alexander Couzens <lynxis@fe80.eu> | 2020-11-24 03:53:22 +0100 |
commit | 841817ec52186029ca01f0c082ed84f2dc5ffcc5 (patch) | |
tree | 19aba9c6d3dd9f5b6e9bac61d10aaaef307deb20 /include/osmocom/gprs | |
parent | 595908aab1985f987abac9c1706bf284468665f7 (diff) |
ns2: add support for frame relay
Add support for frame relay over dahdi hdlc device.
It's supporting lmi by q933 and supports both
SGSN and BSS.
Change-Id: Id3b49f93d33c271f77cd9c9db03cde6b727a4d30
Diffstat (limited to 'include/osmocom/gprs')
-rw-r--r-- | include/osmocom/gprs/frame_relay.h | 136 | ||||
-rw-r--r-- | include/osmocom/gprs/gprs_ns2.h | 20 |
2 files changed, 156 insertions, 0 deletions
diff --git a/include/osmocom/gprs/frame_relay.h b/include/osmocom/gprs/frame_relay.h new file mode 100644 index 00000000..b382ea86 --- /dev/null +++ b/include/osmocom/gprs/frame_relay.h @@ -0,0 +1,136 @@ +/*! \file frame_relay.h */ + +/* (C) 2020 Harald Welte <laforge@gnumonks.org> + * (C) 2020 sysmocom - s.f.m.c. GmbH + * Author: Alexander Couzens <lynxis@fe80.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, see <http://www.gnu.org/licenses/>. + * + */ + +#pragma once + +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/timer.h> +#include <osmocom/core/utils.h> + +#include <stdint.h> + +struct osmo_tdef; +struct msgb; + +enum osmo_fr_role { + FR_ROLE_USER_EQUIPMENT, + FR_ROLE_NETWORK_EQUIPMENT, +}; + +extern const struct value_string osmo_fr_role_names[]; + +static inline const char *osmo_fr_role_str(enum osmo_fr_role role) { + return get_value_string(osmo_fr_role_names, role); +} + +struct osmo_fr_network { + struct llist_head links; + + unsigned int n391; /* full status polling counter */ + unsigned int n392; /* error threshold */ + unsigned int n393; /* monitored events count */ + + struct osmo_tdef *T_defs; /* T391, T392 */ +}; + +struct osmo_fr_dlc; + +/* Frame Relay Link */ +struct osmo_fr_link { + /* list in osmo_fr_network.links */ + struct llist_head list; + struct osmo_fr_network *net; + enum osmo_fr_role role; + /* human-readable name */ + const char *name; + + /* value of the last received send sequence number field in the + * link integrity verification information element */ + uint8_t last_rx_seq; + + /* value of the send sequence number field of the last link + * integrity verification information element sent */ + uint8_t last_tx_seq; + + struct osmo_timer_list t391; + struct osmo_timer_list t392; + + unsigned int polling_count; + unsigned int err_count; + unsigned int succeed; + /* the type of the last status enquiry */ + uint8_t expected_rep; + bool state; + + /* list of data link connections at this link */ + struct llist_head dlc_list; + + int (*unknown_dlc_rx_cb)(void *cb_data, struct msgb *msg); + void *unknown_dlc_rx_cb_data; + + int (*tx_cb)(void *data, struct msgb *msg); + void *tx_cb_data; +}; + +/* Frame Relay Data Link Connection */ +struct osmo_fr_dlc { + /* entry in fr_link.dlc_list */ + struct llist_head list; + struct osmo_fr_link *link; + + uint16_t dlci; + + /* is this DLC marked active for traffic? */ + bool active; + /* was this DLC newly added? */ + bool add; + /* is this DLC about to be destroyed */ + bool del; + + /* the local state needs to be transfered to the + * UE. The NET must wait until the UE confirms it implicited by a seq number check */ + bool state_send; + + int (*rx_cb)(void *cb_data, struct msgb *msg); + void *rx_cb_data; +}; + +/* allocate a frame relay network */ +struct osmo_fr_network *osmo_fr_network_alloc(void *ctx); + +/* allocate a frame relay link in a given network */ +struct osmo_fr_link *osmo_fr_link_alloc(struct osmo_fr_network *net, enum osmo_fr_role role, const char *name); + +/* free a frame link in a given network */ +void osmo_fr_link_free(struct osmo_fr_link *link); + +/* allocate a data link connectoin on a given framerelay link */ +struct osmo_fr_dlc *osmo_fr_dlc_alloc(struct osmo_fr_link *link, uint16_t dlci); +void osmo_fr_dlc_free(struct osmo_fr_dlc *dlc); + +struct osmo_fr_dlc *osmo_fr_dlc_by_dlci(struct osmo_fr_link *link, uint16_t dlci); + +int osmo_fr_rx(struct msgb *msg); +int osmo_fr_tx_dlc(struct msgb *msg); diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h index 3b47b3c0..dd4f4d5a 100644 --- a/include/osmocom/gprs/gprs_ns2.h +++ b/include/osmocom/gprs/gprs_ns2.h @@ -8,9 +8,11 @@ #include <osmocom/core/prim.h> #include <osmocom/gprs/protocol/gsm_08_16.h> +#include <osmocom/gprs/frame_relay.h> struct osmo_sockaddr; struct osmo_sockaddr_str; +struct osmo_fr_network; struct gprs_ns2_inst; struct gprs_ns2_nse; @@ -146,6 +148,23 @@ struct gprs_ns2_vc_bind *gprs_ns2_ip_bind_by_sockaddr(struct gprs_ns2_inst *nsi, const struct osmo_sockaddr *sockaddr); void gprs_ns2_bind_set_mode(struct gprs_ns2_vc_bind *bind, enum gprs_ns2_vc_mode mode); +/* FR VL driver */ +struct gprs_ns2_vc_bind *gprs_ns2_fr_bind_by_netif( + struct gprs_ns2_inst *nsi, + const char *netif); +const char *gprs_ns2_fr_bind_netif(struct gprs_ns2_vc_bind *bind); +int gprs_ns2_fr_bind(struct gprs_ns2_inst *nsi, + const char *netif, + struct osmo_fr_network *fr_network, + enum osmo_fr_role fr_role, + struct gprs_ns2_vc_bind **result); +int gprs_ns2_is_fr_bind(struct gprs_ns2_vc_bind *bind); +struct gprs_ns2_vc *gprs_ns2_fr_nsvc_by_dlci(struct gprs_ns2_vc_bind *bind, uint16_t dlci); +struct gprs_ns2_vc *gprs_ns2_fr_connect(struct gprs_ns2_vc_bind *bind, + uint16_t nsei, + uint16_t nsvci, + uint16_t dlci); + /* create a VC connection */ struct gprs_ns2_vc *gprs_ns2_ip_connect(struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *remote, @@ -188,6 +207,7 @@ int gprs_ns2_frgre_bind(struct gprs_ns2_inst *nsi, int dscp, struct gprs_ns2_vc_bind **result); int gprs_ns2_is_frgre_bind(struct gprs_ns2_vc_bind *bind); +uint16_t gprs_ns2_fr_nsvc_dlci(struct gprs_ns2_vc *nsvc); struct gprs_ns2_vc *gprs_ns2_nsvc_by_sockaddr_nse( struct gprs_ns2_nse *nse, |