libosmogb  1.10.0.2-2e788.202408182026
Osmocom Gb library
frame_relay.h
Go to the documentation of this file.
1 
3 /* (C) 2020 Harald Welte <laforge@gnumonks.org>
4  * (C) 2020 sysmocom - s.f.m.c. GmbH
5  * Author: Alexander Couzens <lynxis@fe80.eu>
6  *
7  * All Rights Reserved
8  *
9  * SPDX-License-Identifier: GPL-2.0+
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25 
26 #pragma once
27 
28 #include <osmocom/core/linuxlist.h>
29 #include <osmocom/core/timer.h>
30 #include <osmocom/core/utils.h>
31 
32 #include <stdint.h>
33 
34 struct osmo_tdef;
35 struct msgb;
36 struct vty;
37 
41 };
42 
43 /* 48.016 ยง 6.1.4.2 default maximum information field size of 1600 octets */
44 #define FRAME_RELAY_MTU 1600
45 /* FR DLC header is 2 byte */
46 #define FRAME_RELAY_SDU (FRAME_RELAY_MTU - 2)
47 
48 extern const struct value_string osmo_fr_role_names[];
49 
50 static inline const char *osmo_fr_role_str(enum osmo_fr_role role) {
52 }
53 
55  struct llist_head links;
56 
57  unsigned int n391; /* full status polling counter */
58  unsigned int n392; /* error threshold */
59  unsigned int n393; /* monitored events count */
60 
61  struct osmo_tdef *T_defs; /* T391, T392 */
62 };
63 
64 struct osmo_fr_dlc;
65 
66 /* Frame Relay Link */
67 struct osmo_fr_link {
68  /* list in osmo_fr_network.links */
69  struct llist_head list;
71  enum osmo_fr_role role;
72  /* human-readable name */
73  const char *name;
74 
75  /* value of the last received send sequence number field in the
76  * link integrity verification information element */
77  uint8_t last_rx_seq;
78 
79  /* value of the send sequence number field of the last link
80  * integrity verification information element sent */
81  uint8_t last_tx_seq;
82 
83  struct osmo_timer_list t391;
84  struct osmo_timer_list t392;
85 
86  unsigned int polling_count;
87  unsigned int err_count;
88  unsigned int succeed;
89  /* the type of the last status enquiry */
90  uint8_t expected_rep;
91  bool state;
92 
93  /* list of data link connections at this link */
94  struct llist_head dlc_list;
95 
96  /* optional call-back to be called for each PDU received on an unknown DLC */
97  int (*unknown_dlc_rx_cb)(void *cb_data, struct msgb *msg);
99 
100  /* call-back to be called for transmitting on the underlying hardware */
101  int (*tx_cb)(void *data, struct msgb *msg);
102  /* optional call-back to be called each time the status changes active/inactive */
103  void (*status_cb)(struct osmo_fr_link *link, void *cb_data, bool active);
104  void *cb_data;
105 };
106 
107 /* Frame Relay Data Link Connection */
108 struct osmo_fr_dlc {
109  /* entry in fr_link.dlc_list */
110  struct llist_head list;
112 
113  uint16_t dlci;
114 
115  /* is this DLC marked active for traffic? */
116  bool active;
117  /* was this DLC newly added? */
118  bool add;
119  /* is this DLC about to be destroyed */
120  bool del;
121 
122  /* The local state needs to be transferred to the USER;
123  * NET must wait until USER confirms it implicitly by a seq number check */
125 
126  /* call-back to be called for each PDU received on this DLC */
127  int (*rx_cb)(void *cb_data, struct msgb *msg);
128  /* optional call-back to be called each time the status changes active/inactive */
129  void (*status_cb)(struct osmo_fr_dlc *dlc, void *cb_data, bool active);
130  void *cb_data;
131 };
132 
133 /* allocate a frame relay network */
134 struct osmo_fr_network *osmo_fr_network_alloc(void *ctx);
136 void osmo_fr_network_dump_vty(struct vty *vty, const struct osmo_fr_network *net);
137 
138 /* allocate a frame relay link in a given network */
139 struct osmo_fr_link *osmo_fr_link_alloc(struct osmo_fr_network *net, enum osmo_fr_role role, const char *name);
140 
141 /* free a frame link in a given network */
142 void osmo_fr_link_free(struct osmo_fr_link *link);
143 
144 /* allocate a data link connectoin on a given framerelay link */
145 struct osmo_fr_dlc *osmo_fr_dlc_alloc(struct osmo_fr_link *link, uint16_t dlci);
146 void osmo_fr_dlc_free(struct osmo_fr_dlc *dlc);
147 
148 struct osmo_fr_dlc *osmo_fr_dlc_by_dlci(struct osmo_fr_link *link, uint16_t dlci);
149 
150 int osmo_fr_rx(struct msgb *msg);
151 int osmo_fr_tx_dlc(struct msgb *msg);
struct osmo_fr_link * osmo_fr_link_alloc(struct osmo_fr_network *net, enum osmo_fr_role role, const char *name)
Definition: frame_relay.c:927
void osmo_fr_network_dump_vty(struct vty *vty, const struct osmo_fr_network *net)
Definition: frame_relay.c:1041
void osmo_fr_dlc_free(struct osmo_fr_dlc *dlc)
Definition: frame_relay.c:992
struct osmo_fr_dlc * osmo_fr_dlc_by_dlci(struct osmo_fr_link *link, uint16_t dlci)
Definition: frame_relay.c:1007
int osmo_fr_tx_dlc(struct msgb *msg)
Definition: frame_relay.c:834
osmo_fr_role
Definition: frame_relay.h:38
@ FR_ROLE_NETWORK_EQUIPMENT
Definition: frame_relay.h:40
@ FR_ROLE_USER_EQUIPMENT
Definition: frame_relay.h:39
static const char * osmo_fr_role_str(enum osmo_fr_role role)
Definition: frame_relay.h:50
const struct value_string osmo_fr_role_names[]
Definition: frame_relay.c:151
void osmo_fr_link_free(struct osmo_fr_link *link)
Definition: frame_relay.c:955
void osmo_fr_network_free(struct osmo_fr_network *net)
Definition: frame_relay.c:914
struct osmo_fr_network * osmo_fr_network_alloc(void *ctx)
Definition: frame_relay.c:898
int osmo_fr_rx(struct msgb *msg)
Definition: frame_relay.c:769
struct osmo_fr_dlc * osmo_fr_dlc_alloc(struct osmo_fr_link *link, uint16_t dlci)
Definition: frame_relay.c:974
uint8_t net[5]
uint8_t data[0]
variable-length payload
Definition: gsm_08_16.h:1
const char * name
const char * get_value_string(const struct value_string *vs, uint32_t val)
uint8_t msg[0]
Definition: frame_relay.h:108
bool add
Definition: frame_relay.h:118
bool state_send
Definition: frame_relay.h:124
void(* status_cb)(struct osmo_fr_dlc *dlc, void *cb_data, bool active)
Definition: frame_relay.h:129
struct osmo_fr_link * link
Definition: frame_relay.h:111
bool del
Definition: frame_relay.h:120
void * cb_data
Definition: frame_relay.h:130
struct llist_head list
Definition: frame_relay.h:110
bool active
Definition: frame_relay.h:116
int(* rx_cb)(void *cb_data, struct msgb *msg)
Definition: frame_relay.h:127
uint16_t dlci
Definition: frame_relay.h:113
Definition: frame_relay.h:54
struct llist_head links
Definition: frame_relay.h:55
unsigned int n392
Definition: frame_relay.h:58
unsigned int n391
Definition: frame_relay.h:57
unsigned int n393
Definition: frame_relay.h:59
struct osmo_tdef * T_defs
Definition: frame_relay.h:61