libosmogb  0.12.0.47-7c74
Osmocom Gb library
gprs_bssgp.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <stdint.h>
6 #include <osmocom/core/timer.h>
8 
9 #include <osmocom/gsm/gsm48.h>
10 #include <osmocom/gsm/prim.h>
11 
13 
14 /* gprs_bssgp_util.c */
15 extern struct gprs_ns_inst *bssgp_nsi;
16 struct msgb *bssgp_msgb_alloc(void);
17 struct msgb *bssgp_msgb_copy(const struct msgb *msg, const char *name);
18 const char *bssgp_cause_str(enum gprs_bssgp_cause cause);
19 const char *bssgp_pdu_str(enum bssgp_pdu_type pdu);
20 /* Transmit a simple response such as BLOCK/UNBLOCK/RESET ACK/NACK */
21 int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei,
22  uint16_t bvci, uint16_t ns_bvci);
23 /* Chapter 10.4.14: Status */
24 int bssgp_tx_status(uint8_t cause, uint16_t *bvci, struct msgb *orig_msg);
25 
26 enum bssgp_prim {
30 
34 
41 };
42 
45 
46  /* common fields */
47  uint16_t nsei;
48  uint16_t bvci;
49  uint32_t tlli;
50  struct tlv_parsed *tp;
51  struct gprs_ra_id *ra_id;
52 
53  /* specific fields */
54  union {
55  struct {
56  uint8_t suspend_ref;
57  } resume;
58  } u;
59 };
60 
61 /* gprs_bssgp.c */
62 
65  uint32_t bucket_size_max;
66  uint32_t bucket_leak_rate;
68  uint32_t bucket_counter;
69  struct timeval time_last_pdu;
71  /* the built-in queue */
72  uint32_t max_queue_depth;
73  uint32_t queue_depth;
74  struct llist_head queue;
75  struct osmo_timer_list timer;
78  int (*out_cb)(struct bssgp_flow_control *fc, struct msgb *msg,
79  uint32_t llc_pdu_len, void *priv);
80 };
81 
82 #define BVC_S_BLOCKED 0x0001
83 
84 /* The per-BTS context that we keep on the SGSN side of the BSSGP link */
85 struct bssgp_bvc_ctx {
86  struct llist_head list;
87 
88  struct gprs_ra_id ra_id;
89  uint16_t cell_id;
91  /* NSEI and BVCI of underlying Gb link. Together they
92  * uniquely identify a link to a BTS (5.4.4) */
93  uint16_t bvci;
94  uint16_t nsei;
95 
96  uint32_t state;
97 
99 
102  uint32_t bmax_default_ms;
104  uint32_t r_default_ms;
105 
106  /* we might want to add this as a shortcut later, avoiding the NSVC
107  * lookup for every packet, similar to a routing cache */
108  //struct gprs_nsvc *nsvc;
109 };
110 extern struct llist_head bssgp_bvc_ctxts;
111 /* Find a BTS Context based on parsed RA ID and Cell ID */
112 struct bssgp_bvc_ctx *btsctx_by_raid_cid(const struct gprs_ra_id *raid, uint16_t cid);
113 /* Find a BTS context based on BVCI+NSEI tuple */
114 struct bssgp_bvc_ctx *btsctx_by_bvci_nsei(uint16_t bvci, uint16_t nsei);
115 
116 #define BVC_F_BLOCKED 0x0001
117 
118 enum bssgp_ctr {
126 };
127 
128 
129 #include <osmocom/gsm/tlv.h>
130 #include <osmocom/gprs/gprs_msgb.h>
131 
132 /* BSSGP-UL-UNITDATA.ind */
133 int bssgp_rcvmsg(struct msgb *msg);
134 
135 /* BSSGP-DL-UNITDATA.req */
136 struct bssgp_lv {
137  uint16_t len;
138  uint8_t *v;
139 };
140 /* parameters for BSSGP downlink userdata transmission */
142  uint32_t *tlli;
143  char *imsi;
145  uint16_t drx_parms;
146  /* FIXME: priority */
147  struct bssgp_lv ms_ra_cap;
148  uint8_t qos_profile[3];
149 };
150 int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime,
151  struct bssgp_dl_ud_par *dup);
152 
153 uint16_t bssgp_parse_cell_id(struct gprs_ra_id *raid, const uint8_t *buf);
154 int bssgp_create_cell_id(uint8_t *buf, const struct gprs_ra_id *raid,
155  uint16_t cid);
156 
157 /* Wrapper around TLV parser to parse BSSGP IEs */
158 static inline int bssgp_tlv_parse(struct tlv_parsed *tp, uint8_t *buf, int len)
159 {
160  return tlv_parse(tp, &tvlv_att_def, buf, len, 0, 0);
161 }
162 
167 };
168 
175 };
176 
179  enum bssgp_paging_mode mode;
180  enum bssgp_paging_scope scope;
181  struct gprs_ra_id raid;
182  uint16_t bvci;
183  char *imsi;
184  uint32_t *ptmsi;
185  uint16_t drx_params;
186  uint8_t qos[3];
187 };
188 
189 /* Send a single GMM-PAGING.req to a given NSEI/NS-BVCI */
190 int bssgp_tx_paging(uint16_t nsei, uint16_t ns_bvci,
191  struct bssgp_paging_info *pinfo);
192 
193 void bssgp_fc_init(struct bssgp_flow_control *fc,
194  uint32_t bucket_size_max, uint32_t bucket_leak_rate,
195  uint32_t max_queue_depth,
196  int (*out_cb)(struct bssgp_flow_control *fc, struct msgb *msg,
197  uint32_t llc_pdu_len, void *priv));
198 
199 /* input function of the flow control implementation, called first
200  * for the MM flow control, and then as the MM flow control output
201  * callback in order to perform BVC flow control */
202 int bssgp_fc_in(struct bssgp_flow_control *fc, struct msgb *msg,
203  uint32_t llc_pdu_len, void *priv);
204 
205 /* Initialize the Flow Control parameters for a new MS according to
206  * default values for the BVC specified by BVCI and NSEI */
207 int bssgp_fc_ms_init(struct bssgp_flow_control *fc_ms, uint16_t bvci,
208  uint16_t nsei, uint32_t max_queue_depth);
209 
212 
213 /* gprs_bssgp_vty.c */
214 int bssgp_vty_init(void);
215 void bssgp_set_log_ss(int ss);
216 
217 int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx);
struct bssgp_flow_control * fc
Definition: gprs_bssgp.h:100
Definition: gprs_bssgp.h:123
Definition: gprs_bssgp.h:38
int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei, uint16_t bvci, uint16_t ns_bvci)
Definition: gprs_bssgp_util.c:198
int bssgp_tx_paging(uint16_t nsei, uint16_t ns_bvci, struct bssgp_paging_info *pinfo)
Definition: gprs_bssgp.c:1201
void bssgp_set_log_ss(int ss)
Definition: gprs_bssgp.c:1262
struct msgb * bssgp_msgb_copy(const struct msgb *msg, const char *name)
Definition: gprs_bssgp_util.c:167
char * imsi
IMSI, if any.
Definition: gprs_bssgp.h:183
struct osmo_prim_hdr oph
Definition: gprs_bssgp.h:44
BSSGP flow control (SGSN side) According to Section 8.2.
Definition: gprs_bssgp.h:64
uint32_t bucket_leak_rate
leak rate of the bucket (octets/sec)
Definition: gprs_bssgp.h:66
uint16_t bssgp_parse_cell_id(struct gprs_ra_id *raid, const uint8_t *buf)
Definition: gprs_bssgp.c:236
uint16_t len
Definition: gprs_bssgp.h:137
uint16_t drx_parms
Definition: gprs_bssgp.h:145
Definition: gprs_bssgp.h:33
struct bssgp_bvc_ctx * btsctx_by_bvci_nsei(uint16_t bvci, uint16_t nsei)
Definition: gprs_bssgp.c:109
An instance of the NS protocol stack.
Definition: gprs_ns.h:77
all cells in RA
Definition: gprs_bssgp.h:173
uint16_t nsei
Definition: gprs_bssgp.h:47
uint32_t bucket_counter
number of tokens in the bucket
Definition: gprs_bssgp.h:68
uint32_t r_default_ms
default bucket leak rate of per-MS bucket in octests/s
Definition: gprs_bssgp.h:104
Definition: gprs_bssgp.h:136
one cell
Definition: gprs_bssgp.h:174
char * imsi
Definition: gprs_bssgp.h:143
Definition: gprs_bssgp.h:36
uint32_t bucket_size_max
maximum size of the bucket (octets)
Definition: gprs_bssgp.h:65
Definition: gprs_bssgp.h:39
Definition: gprs_bssgp.h:120
struct gprs_ra_id * ra_id
Definition: gprs_bssgp.h:51
Definition: gprs_bssgp.h:27
uint16_t cell_id
Cell ID of the remote BTS.
Definition: gprs_bssgp.h:89
uint16_t nsei
Definition: gprs_msgb.h:80
struct bssgp_bvc_ctx * btsctx_by_raid_cid(const struct gprs_ra_id *raid, uint16_t cid)
Definition: gprs_bssgp.c:71
uint32_t tlli
Definition: gprs_bssgp.h:49
uint8_t * v
Definition: gprs_bssgp.h:138
uint32_t * ptmsi
P-TMSI, if any.
Definition: gprs_bssgp.h:184
Definition: gprs_bssgp.h:124
void bssgp_flush_all_queues()
Flush the queues of all BSSGP contexts.
Definition: gprs_bssgp.c:1285
Definition: gprs_bssgp.h:166
gprs_bssgp_cause
Cause coding (Section 11.3.8 / Table 11.10)
Definition: gsm_08_18.h:122
uint16_t bvci
Definition: gprs_msgb.h:81
int bssgp_fc_in(struct bssgp_flow_control *fc, struct msgb *msg, uint32_t llc_pdu_len, void *priv)
Definition: gprs_bssgp.c:738
struct msgb * bssgp_msgb_alloc(void)
Definition: gprs_bssgp_util.c:156
Definition: gprs_bssgp.h:32
struct osmo_bssgp_prim::@0::@1 resume
Definition: gprs_bssgp.h:165
union osmo_bssgp_prim::@0 u
int bssgp_fc_ms_init(struct bssgp_flow_control *fc_ms, uint16_t bvci, uint16_t nsei, uint32_t max_queue_depth)
Definition: gprs_bssgp.c:783
Definition: gprs_bssgp.h:122
struct tlv_parsed * tp
Definition: gprs_bssgp.h:50
uint32_t * tlli
Definition: gprs_bssgp.h:142
struct llist_head bssgp_bvc_ctxts
Definition: gprs_bssgp.h:37
Definition: gprs_bssgp.h:31
Definition: gprs_bssgp.h:29
Definition: gprs_bssgp.h:43
BSSGP paging information.
Definition: gprs_bssgp.h:178
uint16_t nsei
Definition: gprs_bssgp.h:94
uint32_t queue_depth
current length of queue (msgs)
Definition: gprs_bssgp.h:73
uint8_t qos_profile[3]
QoS profile.
Definition: gsm_08_18.h:28
all cells in LA
Definition: gprs_bssgp.h:172
uint32_t max_queue_depth
how many packets to queue (mgs)
Definition: gprs_bssgp.h:72
uint8_t suspend_ref
Definition: gprs_bssgp.h:56
uint32_t bmax_default_ms
default maximum size of per-MS bucket in octets
Definition: gprs_bssgp.h:102
struct bssgp_flow_control * fc
Definition: gprs_bssgp.h:144
uint32_t state
Definition: gprs_bssgp.h:96
bssgp_paging_scope
BSSGP Paging scope.
Definition: gprs_bssgp.h:170
static int bssgp_tlv_parse(struct tlv_parsed *tp, uint8_t *buf, int len)
Definition: gprs_bssgp.h:158
Definition: gprs_bssgp.h:119
Definition: gprs_bssgp.h:28
all cells in BSS
Definition: gprs_bssgp.h:171
Definition: gprs_bssgp.h:40
void bssgp_fc_flush_queue(struct bssgp_flow_control *fc)
Flush the queue of the bssgp_flow_control.
Definition: gprs_bssgp.c:1271
int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
uint16_t bvci
BVCI.
Definition: gprs_bssgp.h:182
struct rate_ctr_group * ctrg
Definition: gprs_bssgp.h:98
int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime, struct bssgp_dl_ud_par *dup)
Definition: gprs_bssgp.c:1104
bssgp_prim
Definition: gprs_bssgp.h:26
const char * bssgp_cause_str(enum gprs_bssgp_cause cause)
Definition: gprs_bssgp_util.c:146
Definition: gprs_bssgp.h:35
bssgp_pdu_type
BSSGP PDU types (Section 11.3.26 / Table 11.27)
Definition: gsm_08_18.h:12
int bssgp_vty_init(void)
Definition: gprs_bssgp_vty.c:202
uint16_t drx_params
DRX parameters.
Definition: gprs_bssgp.h:185
Definition: gprs_bssgp.h:125
uint16_t bvci
Definition: gprs_bssgp.h:93
Definition: gprs_bssgp.h:121
bssgp_ctr
Definition: gprs_bssgp.h:118
int bssgp_tx_status(uint8_t cause, uint16_t *bvci, struct msgb *orig_msg)
Definition: gprs_bssgp_util.c:217
bssgp_paging_mode
BSSGP Paging mode.
Definition: gprs_bssgp.h:164
void bssgp_fc_init(struct bssgp_flow_control *fc, uint32_t bucket_size_max, uint32_t bucket_leak_rate, uint32_t max_queue_depth, int(*out_cb)(struct bssgp_flow_control *fc, struct msgb *msg, uint32_t llc_pdu_len, void *priv))
Definition: gprs_bssgp.c:767
struct gprs_ns_inst * bssgp_nsi
Definition: gprs_bssgp_util.c:37
const char * bssgp_pdu_str(enum bssgp_pdu_type pdu)
Definition: gprs_bssgp_util.c:151
Definition: gprs_bssgp.h:141
Definition: gprs_bssgp.h:85
int bssgp_rcvmsg(struct msgb *msg)
Definition: gprs_bssgp.c:1028
uint16_t bvci
Definition: gprs_bssgp.h:48
int bssgp_create_cell_id(uint8_t *buf, const struct gprs_ra_id *raid, uint16_t cid)
Definition: gprs_bssgp.c:244
uint8_t pdu_type
NS PDU type.
Definition: gsm_08_16.h:24