blob: 157ce10727df309cf9a3018d6616704f49a28274 [file] [log] [blame]
Harald Welte9f75c352010-04-30 20:26:32 +02001/* NS-over-IP proxy */
2
3/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freyther85531cc2010-10-06 20:37:09 +08004 * (C) 2010 by On-Waves
Harald Welte9f75c352010-04-30 20:26:32 +02005 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01008 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
Harald Welte9f75c352010-04-30 20:26:32 +020010 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * GNU Affero General Public License for more details.
Harald Welte9f75c352010-04-30 20:26:32 +020016 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010017 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte9f75c352010-04-30 20:26:32 +020019 *
20 */
21
22#include <unistd.h>
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#include <getopt.h>
27#include <errno.h>
28#include <sys/fcntl.h>
29#include <sys/stat.h>
Harald Welte7fc98222010-05-11 10:15:42 +020030#include <arpa/inet.h>
Harald Welte9f75c352010-04-30 20:26:32 +020031
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010032#include <osmocom/core/talloc.h>
33#include <osmocom/core/select.h>
Harald Welte9f75c352010-04-30 20:26:32 +020034
Harald Welteea34a4e2012-06-16 14:59:56 +080035#include <osmocom/gprs/gprs_ns.h>
36#include <osmocom/gprs/gprs_bssgp.h>
37
Harald Welte9f75c352010-04-30 20:26:32 +020038#include <openbsc/signal.h>
39#include <openbsc/debug.h>
Harald Welte672f5c42010-05-03 18:54:58 +020040#include <openbsc/gb_proxy.h>
Harald Welte9f75c352010-04-30 20:26:32 +020041
42struct gbprox_peer {
43 struct llist_head list;
44
Jacob Erlbecke75fec62013-10-15 12:00:27 +020045 /* NSEI of the peer entity */
46 uint16_t nsei;
Harald Welte9f75c352010-04-30 20:26:32 +020047
48 /* BVCI used for Point-to-Point to this peer */
49 uint16_t bvci;
Harald Welte36f98d92011-02-06 13:09:29 +010050 int blocked;
Harald Welte9f75c352010-04-30 20:26:32 +020051
52 /* Routeing Area that this peer is part of (raw 04.08 encoding) */
53 uint8_t ra[6];
54};
55
56/* Linked list of all Gb peers (except SGSN) */
57static LLIST_HEAD(gbprox_bts_peers);
58
Harald Welte9f75c352010-04-30 20:26:32 +020059/* Find the gbprox_peer by its BVCI */
60static struct gbprox_peer *peer_by_bvci(uint16_t bvci)
61{
62 struct gbprox_peer *peer;
63 llist_for_each_entry(peer, &gbprox_bts_peers, list) {
64 if (peer->bvci == bvci)
65 return peer;
66 }
67 return NULL;
68}
69
Jacob Erlbecke75fec62013-10-15 12:00:27 +020070/* Find the gbprox_peer by its NSEI */
71static struct gbprox_peer *peer_by_nsei(uint16_t nsei)
Harald Welte9f75c352010-04-30 20:26:32 +020072{
73 struct gbprox_peer *peer;
74 llist_for_each_entry(peer, &gbprox_bts_peers, list) {
Jacob Erlbecke75fec62013-10-15 12:00:27 +020075 if (peer->nsei == nsei)
Harald Welte9f75c352010-04-30 20:26:32 +020076 return peer;
77 }
78 return NULL;
79}
80
81/* look-up a peer by its Routeing Area Code (RAC) */
Harald Welte70f38d22010-05-01 12:10:57 +020082static struct gbprox_peer *peer_by_rac(const uint8_t *ra)
Harald Welte9f75c352010-04-30 20:26:32 +020083{
84 struct gbprox_peer *peer;
85 llist_for_each_entry(peer, &gbprox_bts_peers, list) {
Harald Welte1174c082010-05-12 00:07:29 +020086 if (!memcmp(peer->ra, ra, 6))
Harald Welte9f75c352010-04-30 20:26:32 +020087 return peer;
88 }
89 return NULL;
90}
91
92/* look-up a peer by its Location Area Code (LAC) */
Harald Welte70f38d22010-05-01 12:10:57 +020093static struct gbprox_peer *peer_by_lac(const uint8_t *la)
Harald Welte9f75c352010-04-30 20:26:32 +020094{
95 struct gbprox_peer *peer;
96 llist_for_each_entry(peer, &gbprox_bts_peers, list) {
Harald Welte1174c082010-05-12 00:07:29 +020097 if (!memcmp(peer->ra, la, 5))
Harald Welte9f75c352010-04-30 20:26:32 +020098 return peer;
99 }
100 return NULL;
101}
102
103static struct gbprox_peer *peer_alloc(uint16_t bvci)
104{
105 struct gbprox_peer *peer;
106
107 peer = talloc_zero(tall_bsc_ctx, struct gbprox_peer);
108 if (!peer)
109 return NULL;
110
111 peer->bvci = bvci;
112 llist_add(&peer->list, &gbprox_bts_peers);
113
114 return peer;
115}
116
117static void peer_free(struct gbprox_peer *peer)
118{
119 llist_del(&peer->list);
120 talloc_free(peer);
121}
122
Harald Welte39d0bb52010-05-12 18:10:25 +0000123/* FIXME: this needs to go to libosmocore/msgb.c */
124static struct msgb *msgb_copy(const struct msgb *msg, const char *name)
125{
Harald Welte8645e102012-06-16 16:09:52 +0800126 struct libgb_msgb_cb *old_cb, *new_cb;
Harald Welte39d0bb52010-05-12 18:10:25 +0000127 struct msgb *new_msg;
128
Holger Hans Peter Freyther62d97982010-06-08 18:14:37 +0800129 new_msg = msgb_alloc(msg->data_len, name);
Harald Welte39d0bb52010-05-12 18:10:25 +0000130 if (!new_msg)
131 return NULL;
132
Harald Welte39d0bb52010-05-12 18:10:25 +0000133 /* copy data */
Holger Hans Peter Freyther62d97982010-06-08 18:14:37 +0800134 memcpy(new_msg->_data, msg->_data, new_msg->data_len);
135
136 /* copy header */
137 new_msg->len = msg->len;
138 new_msg->data += msg->data - msg->_data;
139 new_msg->head += msg->head - msg->_data;
140 new_msg->tail += msg->tail - msg->_data;
141
142 new_msg->l1h = new_msg->_data + (msg->l1h - msg->_data);
143 new_msg->l2h = new_msg->_data + (msg->l2h - msg->_data);
144 new_msg->l3h = new_msg->_data + (msg->l3h - msg->_data);
145 new_msg->l4h = new_msg->_data + (msg->l4h - msg->_data);
146
147 /* copy GB specific data */
Harald Welte8645e102012-06-16 16:09:52 +0800148 old_cb = LIBGB_MSGB_CB(msg);
149 new_cb = LIBGB_MSGB_CB(new_msg);
Holger Hans Peter Freyther62d97982010-06-08 18:14:37 +0800150
151 new_cb->bssgph = new_msg->_data + (old_cb->bssgph - msg->_data);
152 new_cb->llch = new_msg->_data + (old_cb->llch - msg->_data);
153
Harald Weltefb9e06f2011-02-06 17:17:05 +0100154 /* bssgp_cell_id is a pointer into the old msgb, so we need to make
155 * it a pointer into the new msgb */
156 new_cb->bssgp_cell_id = new_msg->_data + (old_cb->bssgp_cell_id - msg->_data);
Holger Hans Peter Freyther62d97982010-06-08 18:14:37 +0800157 new_cb->nsei = old_cb->nsei;
158 new_cb->bvci = old_cb->bvci;
159 new_cb->tlli = old_cb->tlli;
Harald Welte39d0bb52010-05-12 18:10:25 +0000160
161 return new_msg;
162}
163
Harald Welte69619e32010-05-03 19:05:10 +0200164/* strip off the NS header */
165static void strip_ns_hdr(struct msgb *msg)
166{
167 int strip_len = msgb_bssgph(msg) - msg->data;
168 msgb_pull(msg, strip_len);
169}
170
Harald Welte9f75c352010-04-30 20:26:32 +0200171/* feed a message down the NS-VC associated with the specified peer */
Harald Welte39d0bb52010-05-12 18:10:25 +0000172static int gbprox_relay2sgsn(struct msgb *old_msg, uint16_t ns_bvci)
Harald Welte672f5c42010-05-03 18:54:58 +0200173{
Harald Welte39d0bb52010-05-12 18:10:25 +0000174 /* create a copy of the message so the old one can
175 * be free()d safely when we return from gbprox_rcvmsg() */
176 struct msgb *msg = msgb_copy(old_msg, "msgb_relay2sgsn");
177
Harald Weltee9ea2692010-05-11 20:20:13 +0200178 DEBUGP(DGPRS, "NSEI=%u proxying BTS->SGSN (NS_BVCI=%u, NSEI=%u)\n",
Harald Welte96f71f22010-05-03 19:28:05 +0200179 msgb_nsei(msg), ns_bvci, gbcfg.nsip_sgsn_nsei);
Harald Welte44c48302010-05-03 19:22:32 +0200180
Harald Welte672f5c42010-05-03 18:54:58 +0200181 msgb_bvci(msg) = ns_bvci;
182 msgb_nsei(msg) = gbcfg.nsip_sgsn_nsei;
183
Harald Welte69619e32010-05-03 19:05:10 +0200184 strip_ns_hdr(msg);
185
Harald Welte0a4050c2010-05-11 10:01:17 +0200186 return gprs_ns_sendmsg(bssgp_nsi, msg);
Harald Welte672f5c42010-05-03 18:54:58 +0200187}
188
Harald Welte672f5c42010-05-03 18:54:58 +0200189/* feed a message down the NS-VC associated with the specified peer */
Harald Welte39d0bb52010-05-12 18:10:25 +0000190static int gbprox_relay2peer(struct msgb *old_msg, struct gbprox_peer *peer,
Harald Welte9f75c352010-04-30 20:26:32 +0200191 uint16_t ns_bvci)
192{
Harald Welte39d0bb52010-05-12 18:10:25 +0000193 /* create a copy of the message so the old one can
194 * be free()d safely when we return from gbprox_rcvmsg() */
195 struct msgb *msg = msgb_copy(old_msg, "msgb_relay2peer");
196
Harald Welte0ab535b2010-05-13 10:34:56 +0200197 DEBUGP(DGPRS, "NSEI=%u proxying SGSN->BSS (NS_BVCI=%u, NSEI=%u)\n",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200198 msgb_nsei(msg), ns_bvci, peer->nsei);
Harald Welte44c48302010-05-03 19:22:32 +0200199
Harald Welte9f75c352010-04-30 20:26:32 +0200200 msgb_bvci(msg) = ns_bvci;
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200201 msgb_nsei(msg) = peer->nsei;
Harald Welte9f75c352010-04-30 20:26:32 +0200202
Harald Welte0ab535b2010-05-13 10:34:56 +0200203 /* Strip the old NS header, it will be replaced with a new one */
Harald Welte69619e32010-05-03 19:05:10 +0200204 strip_ns_hdr(msg);
205
Harald Welte0a4050c2010-05-11 10:01:17 +0200206 return gprs_ns_sendmsg(bssgp_nsi, msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200207}
208
Harald Welte36f98d92011-02-06 13:09:29 +0100209static int block_unblock_peer(uint16_t ptp_bvci, uint8_t pdu_type)
210{
211 struct gbprox_peer *peer;
212
213 peer = peer_by_bvci(ptp_bvci);
214 if (!peer) {
215 LOGP(DGPRS, LOGL_ERROR, "BVCI=%u: Cannot find BSS\n",
216 ptp_bvci);
217 return -ENOENT;
218 }
219
220 switch (pdu_type) {
221 case BSSGP_PDUT_BVC_BLOCK_ACK:
222 peer->blocked = 1;
223 break;
224 case BSSGP_PDUT_BVC_UNBLOCK_ACK:
225 peer->blocked = 0;
226 break;
227 default:
228 break;
229 }
230 return 0;
231}
232
Harald Welte9f75c352010-04-30 20:26:32 +0200233/* Send a message to a peer identified by ptp_bvci but using ns_bvci
234 * in the NS hdr */
Harald Welte69619e32010-05-03 19:05:10 +0200235static int gbprox_relay2bvci(struct msgb *msg, uint16_t ptp_bvci,
Harald Welte9f75c352010-04-30 20:26:32 +0200236 uint16_t ns_bvci)
237{
238 struct gbprox_peer *peer;
239
240 peer = peer_by_bvci(ptp_bvci);
Harald Welte1c77c6e2010-05-03 21:37:11 +0200241 if (!peer) {
Harald Welte4cf12e92010-05-13 14:14:56 +0200242 LOGP(DGPRS, LOGL_ERROR, "BVCI=%u: Cannot find BSS\n",
Harald Welte1c77c6e2010-05-03 21:37:11 +0200243 ptp_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200244 return -ENOENT;
Harald Welte1c77c6e2010-05-03 21:37:11 +0200245 }
Harald Welte9f75c352010-04-30 20:26:32 +0200246
Harald Welte69619e32010-05-03 19:05:10 +0200247 return gbprox_relay2peer(msg, peer, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200248}
249
Harald Welteb1fd9022012-06-17 12:16:31 +0800250int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
251{
252 return 0;
253}
254
Harald Welte9f75c352010-04-30 20:26:32 +0200255/* Receive an incoming signalling message from a BSS-side NS-VC */
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200256static int gbprox_rx_sig_from_bss(struct msgb *msg, uint16_t nsei,
Harald Welte9f75c352010-04-30 20:26:32 +0200257 uint16_t ns_bvci)
258{
Harald Welteca3620a2010-05-03 16:30:59 +0200259 struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200260 struct tlv_parsed tp;
261 uint8_t pdu_type = bgph->pdu_type;
Harald Welteca3620a2010-05-03 16:30:59 +0200262 int data_len = msgb_bssgp_len(msg) - sizeof(*bgph);
Harald Welte9f75c352010-04-30 20:26:32 +0200263 struct gbprox_peer *from_peer;
Harald Welte70f38d22010-05-01 12:10:57 +0200264 struct gprs_ra_id raid;
Harald Welte9f75c352010-04-30 20:26:32 +0200265
Harald Weltec471d3d2011-02-06 17:13:12 +0100266 if (ns_bvci != 0 && ns_bvci != 1) {
Harald Welte4cf12e92010-05-13 14:14:56 +0200267 LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u BVCI=%u is not signalling\n",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200268 nsei, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200269 return -EINVAL;
270 }
271
272 /* we actually should never see those two for BVCI == 0, but double-check
273 * just to make sure */
274 if (pdu_type == BSSGP_PDUT_UL_UNITDATA ||
275 pdu_type == BSSGP_PDUT_DL_UNITDATA) {
Harald Welte44c48302010-05-03 19:22:32 +0200276 LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u UNITDATA not allowed in "
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200277 "signalling\n", nsei);
Harald Welte9f75c352010-04-30 20:26:32 +0200278 return -EINVAL;
279 }
280
281 bssgp_tlv_parse(&tp, bgph->data, data_len);
282
283 switch (pdu_type) {
284 case BSSGP_PDUT_SUSPEND:
285 case BSSGP_PDUT_RESUME:
Harald Welte70f38d22010-05-01 12:10:57 +0200286 /* We implement RAC snooping during SUSPEND/RESUME, since
287 * it establishes a relationsip between BVCI/peer and the
288 * routeing area code. The snooped information is then
289 * used for routing the {SUSPEND,RESUME}_[N]ACK back to
290 * the correct BSSGP */
Harald Welte9f75c352010-04-30 20:26:32 +0200291 if (!TLVP_PRESENT(&tp, BSSGP_IE_ROUTEING_AREA))
292 goto err_mand_ie;
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200293 from_peer = peer_by_nsei(nsei);
Harald Welte9f75c352010-04-30 20:26:32 +0200294 if (!from_peer)
295 goto err_no_peer;
Harald Welte1174c082010-05-12 00:07:29 +0200296 memcpy(from_peer->ra, TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA),
297 sizeof(from_peer->ra));
Harald Welte7fc98222010-05-11 10:15:42 +0200298 gsm48_parse_ra(&raid, from_peer->ra);
Harald Welte4cf12e92010-05-13 14:14:56 +0200299 LOGP(DGPRS, LOGL_INFO, "NSEI=%u BSSGP SUSPEND/RESUME "
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200300 "RAC snooping: RAC %u-%u-%u-%u behind BVCI=%u\n",
301 nsei, raid.mcc, raid.mnc, raid.lac,
302 raid.rac , from_peer->bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200303 /* FIXME: This only supports one BSS per RA */
304 break;
Harald Welte44c48302010-05-03 19:22:32 +0200305 case BSSGP_PDUT_BVC_RESET:
306 /* If we receive a BVC reset on the signalling endpoint, we
307 * don't want the SGSN to reset, as the signalling endpoint
308 * is common for all point-to-point BVCs (and thus all BTS) */
309 if (TLVP_PRESENT(&tp, BSSGP_IE_BVCI)) {
Holger Hans Peter Freytherffd68562012-09-04 20:42:20 +0200310 uint16_t bvci = ntohs(tlvp_val16_unal(&tp, BSSGP_IE_BVCI));
Harald Welte72953b82010-05-12 00:20:41 +0200311 LOGP(DGPRS, LOGL_INFO, "NSEI=%u Rx BVC RESET (BVCI=%u)\n",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200312 nsei, bvci);
Harald Welte44c48302010-05-03 19:22:32 +0200313 if (bvci == 0) {
314 /* FIXME: only do this if SGSN is alive! */
Harald Weltee9ea2692010-05-11 20:20:13 +0200315 LOGP(DGPRS, LOGL_INFO, "NSEI=%u Tx fake "
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200316 "BVC RESET ACK of BVCI=0\n", nsei);
Harald Welte44c48302010-05-03 19:22:32 +0200317 return bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_RESET_ACK,
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200318 nsei, 0, ns_bvci);
Harald Welte1174c082010-05-12 00:07:29 +0200319 }
320 from_peer = peer_by_bvci(bvci);
321 if (!from_peer) {
Harald Welte1c77c6e2010-05-03 21:37:11 +0200322 /* if a PTP-BVC is reset, and we don't know that
323 * PTP-BVCI yet, we should allocate a new peer */
324 LOGP(DGPRS, LOGL_INFO, "Allocationg new peer for "
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200325 "BVCI=%u via NSEI=%u\n", bvci, nsei);
Harald Welte1c77c6e2010-05-03 21:37:11 +0200326 from_peer = peer_alloc(bvci);
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200327 from_peer->nsei = nsei;
Harald Welte44c48302010-05-03 19:22:32 +0200328 }
Harald Welte1174c082010-05-12 00:07:29 +0200329 if (TLVP_PRESENT(&tp, BSSGP_IE_CELL_ID)) {
330 struct gprs_ra_id raid;
331 /* We have a Cell Identifier present in this
332 * PDU, this means we can extend our local
333 * state information about this particular cell
334 * */
335 memcpy(from_peer->ra,
336 TLVP_VAL(&tp, BSSGP_IE_CELL_ID),
337 sizeof(from_peer->ra));
338 gsm48_parse_ra(&raid, from_peer->ra);
339 LOGP(DGPRS, LOGL_INFO, "NSEI=%u/BVCI=%u "
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200340 "Cell ID %u-%u-%u-%u\n", nsei,
Harald Welte1174c082010-05-12 00:07:29 +0200341 bvci, raid.mcc, raid.mnc, raid.lac,
342 raid.rac);
343 }
Harald Welte44c48302010-05-03 19:22:32 +0200344 }
345 break;
Harald Welte9f75c352010-04-30 20:26:32 +0200346 }
347
Harald Weltee9ea2692010-05-11 20:20:13 +0200348 /* Normally, we can simply pass on all signalling messages from BSS to
349 * SGSN */
Harald Welte69619e32010-05-03 19:05:10 +0200350 return gbprox_relay2sgsn(msg, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200351err_no_peer:
Harald Welte0a4050c2010-05-11 10:01:17 +0200352 LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(BSS) cannot find peer based on RAC\n",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200353 nsei);
Harald Welte0a4050c2010-05-11 10:01:17 +0200354 return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, NULL, msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200355err_mand_ie:
Harald Welte0a4050c2010-05-11 10:01:17 +0200356 LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(BSS) missing mandatory RA IE\n",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200357 nsei);
Harald Welte0a4050c2010-05-11 10:01:17 +0200358 return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200359}
360
361/* Receive paging request from SGSN, we need to relay to proper BSS */
362static int gbprox_rx_paging(struct msgb *msg, struct tlv_parsed *tp,
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200363 uint32_t nsei, uint16_t ns_bvci)
Harald Welte9f75c352010-04-30 20:26:32 +0200364{
Harald Welte4cf12e92010-05-13 14:14:56 +0200365 struct gbprox_peer *peer = NULL;
Harald Welte9f75c352010-04-30 20:26:32 +0200366
Harald Welte4cf12e92010-05-13 14:14:56 +0200367 LOGP(DGPRS, LOGL_INFO, "NSEI=%u(SGSN) BSSGP PAGING ",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200368 nsei);
Harald Welte9f75c352010-04-30 20:26:32 +0200369 if (TLVP_PRESENT(tp, BSSGP_IE_BVCI)) {
Holger Hans Peter Freytherffd68562012-09-04 20:42:20 +0200370 uint16_t bvci = ntohs(tlvp_val16_unal(tp, BSSGP_IE_BVCI));
Harald Welte4cf12e92010-05-13 14:14:56 +0200371 LOGPC(DGPRS, LOGL_INFO, "routing by BVCI to peer BVCI=%u\n",
372 bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200373 } else if (TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA)) {
374 peer = peer_by_rac(TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA));
Harald Welte4cf12e92010-05-13 14:14:56 +0200375 LOGPC(DGPRS, LOGL_INFO, "routing by RAC to peer BVCI=%u\n",
Holger Hans Peter Freyther62eaf542010-06-08 16:30:24 +0800376 peer ? peer->bvci : -1);
Harald Welte9f75c352010-04-30 20:26:32 +0200377 } else if (TLVP_PRESENT(tp, BSSGP_IE_LOCATION_AREA)) {
378 peer = peer_by_lac(TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA));
Harald Welte4cf12e92010-05-13 14:14:56 +0200379 LOGPC(DGPRS, LOGL_INFO, "routing by LAC to peer BVCI=%u\n",
Holger Hans Peter Freyther62eaf542010-06-08 16:30:24 +0800380 peer ? peer->bvci : -1);
Harald Welte9f75c352010-04-30 20:26:32 +0200381 } else
Harald Welte4cf12e92010-05-13 14:14:56 +0200382 LOGPC(DGPRS, LOGL_INFO, "\n");
383
384 if (!peer) {
385 LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) BSSGP PAGING: "
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200386 "unable to route, missing IE\n", nsei);
Harald Welte9f75c352010-04-30 20:26:32 +0200387 return -EINVAL;
Harald Welte4cf12e92010-05-13 14:14:56 +0200388 }
389 return gbprox_relay2peer(msg, peer, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200390}
391
Harald Welte0a4050c2010-05-11 10:01:17 +0200392/* Receive an incoming BVC-RESET message from the SGSN */
393static int rx_reset_from_sgsn(struct msgb *msg, struct tlv_parsed *tp,
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200394 uint32_t nsei, uint16_t ns_bvci)
Harald Welte0a4050c2010-05-11 10:01:17 +0200395{
396 struct gbprox_peer *peer;
397 uint16_t ptp_bvci;
398
399 if (!TLVP_PRESENT(tp, BSSGP_IE_BVCI)) {
400 return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE,
401 NULL, msg);
402 }
Holger Hans Peter Freytherffd68562012-09-04 20:42:20 +0200403 ptp_bvci = ntohs(tlvp_val16_unal(tp, BSSGP_IE_BVCI));
Harald Welte0a4050c2010-05-11 10:01:17 +0200404
405 if (ptp_bvci >= 2) {
406 /* A reset for a PTP BVC was received, forward it to its
407 * respective peer */
408 peer = peer_by_bvci(ptp_bvci);
409 if (!peer) {
Harald Welte4cf12e92010-05-13 14:14:56 +0200410 LOGP(DGPRS, LOGL_ERROR, "NSEI=%u BVCI=%u: Cannot find BSS\n",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200411 nsei, ptp_bvci);
Harald Welte0a4050c2010-05-11 10:01:17 +0200412 return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI,
413 NULL, msg);
414 }
415 return gbprox_relay2peer(msg, peer, ns_bvci);
416 }
417
418 /* A reset for the Signalling entity has been received
419 * from the SGSN. As the signalling BVCI is shared
420 * among all the BSS's that we multiplex, it needs to
421 * be relayed */
422 llist_for_each_entry(peer, &gbprox_bts_peers, list)
423 gbprox_relay2peer(msg, peer, ns_bvci);
424
425 return 0;
426}
427
Harald Welte9f75c352010-04-30 20:26:32 +0200428/* Receive an incoming signalling message from the SGSN-side NS-VC */
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200429static int gbprox_rx_sig_from_sgsn(struct msgb *msg, uint32_t nsei,
Harald Welte9f75c352010-04-30 20:26:32 +0200430 uint16_t ns_bvci)
431{
Harald Welteca3620a2010-05-03 16:30:59 +0200432 struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200433 struct tlv_parsed tp;
434 uint8_t pdu_type = bgph->pdu_type;
Harald Welteca3620a2010-05-03 16:30:59 +0200435 int data_len = msgb_bssgp_len(msg) - sizeof(*bgph);
Harald Welte9f75c352010-04-30 20:26:32 +0200436 struct gbprox_peer *peer;
437 uint16_t bvci;
438 int rc = 0;
439
Harald Weltec471d3d2011-02-06 17:13:12 +0100440 if (ns_bvci != 0 && ns_bvci != 1) {
Harald Welte4cf12e92010-05-13 14:14:56 +0200441 LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u(SGSN) BVCI=%u is not "
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200442 "signalling\n", nsei, ns_bvci);
Harald Welte0a4050c2010-05-11 10:01:17 +0200443 /* FIXME: Send proper error message */
Harald Welte9f75c352010-04-30 20:26:32 +0200444 return -EINVAL;
445 }
446
447 /* we actually should never see those two for BVCI == 0, but double-check
448 * just to make sure */
449 if (pdu_type == BSSGP_PDUT_UL_UNITDATA ||
450 pdu_type == BSSGP_PDUT_DL_UNITDATA) {
Harald Welte44c48302010-05-03 19:22:32 +0200451 LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u(SGSN) UNITDATA not allowed in "
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200452 "signalling\n", nsei);
Harald Welte0a4050c2010-05-11 10:01:17 +0200453 return bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200454 }
455
456 rc = bssgp_tlv_parse(&tp, bgph->data, data_len);
457
458 switch (pdu_type) {
Harald Welte0a4050c2010-05-11 10:01:17 +0200459 case BSSGP_PDUT_BVC_RESET:
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200460 rc = rx_reset_from_sgsn(msg, &tp, nsei, ns_bvci);
Harald Welte0a4050c2010-05-11 10:01:17 +0200461 break;
Harald Welte9f75c352010-04-30 20:26:32 +0200462 case BSSGP_PDUT_FLUSH_LL:
Harald Welte9f75c352010-04-30 20:26:32 +0200463 case BSSGP_PDUT_BVC_RESET_ACK:
464 /* simple case: BVCI IE is mandatory */
465 if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI))
466 goto err_mand_ie;
Holger Hans Peter Freytherffd68562012-09-04 20:42:20 +0200467 bvci = ntohs(tlvp_val16_unal(&tp, BSSGP_IE_BVCI));
Harald Welte69619e32010-05-03 19:05:10 +0200468 rc = gbprox_relay2bvci(msg, bvci, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200469 break;
470 case BSSGP_PDUT_PAGING_PS:
471 case BSSGP_PDUT_PAGING_CS:
472 /* process the paging request (LAC/RAC lookup) */
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200473 rc = gbprox_rx_paging(msg, &tp, nsei, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200474 break;
475 case BSSGP_PDUT_STATUS:
Harald Welte0a4050c2010-05-11 10:01:17 +0200476 /* Some exception has occurred */
Harald Welte44c48302010-05-03 19:22:32 +0200477 LOGP(DGPRS, LOGL_NOTICE,
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200478 "NSEI=%u(SGSN) BSSGP STATUS ", nsei);
Harald Welte0a4050c2010-05-11 10:01:17 +0200479 if (!TLVP_PRESENT(&tp, BSSGP_IE_CAUSE)) {
480 LOGPC(DGPRS, LOGL_NOTICE, "\n");
481 goto err_mand_ie;
482 }
483 LOGPC(DGPRS, LOGL_NOTICE,
484 "cause=0x%02x(%s) ", *TLVP_VAL(&tp, BSSGP_IE_CAUSE),
485 bssgp_cause_str(*TLVP_VAL(&tp, BSSGP_IE_CAUSE)));
486 if (TLVP_PRESENT(&tp, BSSGP_IE_BVCI)) {
Holger Hans Peter Freytherffd68562012-09-04 20:42:20 +0200487 uint16_t bvci = tlvp_val16_unal(&tp, BSSGP_IE_BVCI);
Harald Welte0a4050c2010-05-11 10:01:17 +0200488 LOGPC(DGPRS, LOGL_NOTICE,
Holger Hans Peter Freytherffd68562012-09-04 20:42:20 +0200489 "BVCI=%u\n", ntohs(bvci));
Harald Welte0a4050c2010-05-11 10:01:17 +0200490 } else
491 LOGPC(DGPRS, LOGL_NOTICE, "\n");
Harald Welte9f75c352010-04-30 20:26:32 +0200492 break;
493 /* those only exist in the SGSN -> BSS direction */
494 case BSSGP_PDUT_SUSPEND_ACK:
495 case BSSGP_PDUT_SUSPEND_NACK:
496 case BSSGP_PDUT_RESUME_ACK:
497 case BSSGP_PDUT_RESUME_NACK:
498 /* RAC IE is mandatory */
499 if (!TLVP_PRESENT(&tp, BSSGP_IE_ROUTEING_AREA))
500 goto err_mand_ie;
501 peer = peer_by_rac(TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA));
502 if (!peer)
503 goto err_no_peer;
Harald Welte69619e32010-05-03 19:05:10 +0200504 rc = gbprox_relay2peer(msg, peer, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200505 break;
Harald Welte36f98d92011-02-06 13:09:29 +0100506 case BSSGP_PDUT_BVC_BLOCK_ACK:
507 case BSSGP_PDUT_BVC_UNBLOCK_ACK:
508 if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI))
509 goto err_mand_ie;
Holger Hans Peter Freytherffd68562012-09-04 20:42:20 +0200510 bvci = ntohs(tlvp_val16_unal(&tp, BSSGP_IE_BVCI));
Harald Welte36f98d92011-02-06 13:09:29 +0100511 if (bvci == 0) {
512 LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u(SGSN) BSSGP "
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200513 "%sBLOCK_ACK for signalling BVCI ?!?\n", nsei,
Harald Welte36f98d92011-02-06 13:09:29 +0100514 pdu_type == BSSGP_PDUT_BVC_UNBLOCK_ACK ? "UN":"");
515 /* should we send STATUS ? */
516 } else {
517 /* Mark BVC as (un)blocked */
518 block_unblock_peer(bvci, pdu_type);
519 }
520 rc = gbprox_relay2bvci(msg, bvci, ns_bvci);
521 break;
Harald Welte9f75c352010-04-30 20:26:32 +0200522 case BSSGP_PDUT_SGSN_INVOKE_TRACE:
Harald Welte44c48302010-05-03 19:22:32 +0200523 LOGP(DGPRS, LOGL_ERROR,
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200524 "NSEI=%u(SGSN) BSSGP INVOKE TRACE not supported\n",nsei);
Harald Welte0a4050c2010-05-11 10:01:17 +0200525 rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200526 break;
527 default:
Harald Welte72953b82010-05-12 00:20:41 +0200528 LOGP(DGPRS, LOGL_NOTICE, "BSSGP PDU type 0x%02x unknown\n",
529 pdu_type);
Harald Welte0a4050c2010-05-11 10:01:17 +0200530 rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200531 break;
532 }
533
534 return rc;
535err_mand_ie:
Harald Welte1c77c6e2010-05-03 21:37:11 +0200536 LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) missing mandatory IE\n",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200537 nsei);
Harald Welte0a4050c2010-05-11 10:01:17 +0200538 return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200539err_no_peer:
Harald Welte0a4050c2010-05-11 10:01:17 +0200540 LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) cannot find peer based on RAC\n",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200541 nsei);
Harald Welte0a4050c2010-05-11 10:01:17 +0200542 return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, NULL, msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200543}
544
545/* Main input function for Gb proxy */
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200546int gbprox_rcvmsg(struct msgb *msg, uint16_t nsei, uint16_t ns_bvci, uint16_t nsvci)
Harald Welte9f75c352010-04-30 20:26:32 +0200547{
Harald Welte672f5c42010-05-03 18:54:58 +0200548 int rc;
Harald Welte36f98d92011-02-06 13:09:29 +0100549 struct gbprox_peer *peer;
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200550 int remote_end_is_sgsn = nsei == gbcfg.nsip_sgsn_nsei;
Harald Welte9f75c352010-04-30 20:26:32 +0200551
552 /* Only BVCI=0 messages need special treatment */
553 if (ns_bvci == 0 || ns_bvci == 1) {
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200554 if (remote_end_is_sgsn)
555 rc = gbprox_rx_sig_from_sgsn(msg, nsei, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200556 else
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200557 rc = gbprox_rx_sig_from_bss(msg, nsei, ns_bvci);
Harald Welte672f5c42010-05-03 18:54:58 +0200558 } else {
559 /* All other BVCI are PTP and thus can be simply forwarded */
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200560 if (!remote_end_is_sgsn)
Harald Welte36f98d92011-02-06 13:09:29 +0100561 return gbprox_relay2sgsn(msg, ns_bvci);
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200562
Harald Welte36f98d92011-02-06 13:09:29 +0100563 /* else: SGSN -> BSS direction */
564 peer = peer_by_bvci(ns_bvci);
565 if (!peer) {
566 LOGP(DGPRS, LOGL_INFO, "Allocationg new peer for "
567 "BVCI=%u via NSVC=%u/NSEI=%u\n", ns_bvci,
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200568 nsvci, nsei);
Harald Welte36f98d92011-02-06 13:09:29 +0100569 peer = peer_alloc(ns_bvci);
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200570 peer->nsei = nsei;
Harald Welte36f98d92011-02-06 13:09:29 +0100571 }
572 if (peer->blocked) {
573 LOGP(DGPRS, LOGL_NOTICE, "Dropping PDU for "
574 "blocked BVCI=%u via NSVC=%u/NSEI=%u\n",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200575 ns_bvci, nsvci, nsei);
Harald Welte36f98d92011-02-06 13:09:29 +0100576 return bssgp_tx_status(BSSGP_CAUSE_BVCI_BLOCKED, NULL, msg);
577 }
578 rc = gbprox_relay2peer(msg, peer, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200579 }
580
Harald Welte672f5c42010-05-03 18:54:58 +0200581 return rc;
Harald Welte9f75c352010-04-30 20:26:32 +0200582}
Harald Welte85801d02010-05-11 05:49:43 +0200583
Harald Welte1ccbf442010-05-14 11:53:08 +0000584int gbprox_reset_persistent_nsvcs(struct gprs_ns_inst *nsi)
585{
586 struct gprs_nsvc *nsvc;
587
588 llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
589 if (!nsvc->persistent)
590 continue;
591 gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION);
592 }
593 return 0;
594}
595
Harald Weltec1c1dd22010-05-11 06:34:24 +0200596/* Signal handler for signals from NS layer */
597int gbprox_signal(unsigned int subsys, unsigned int signal,
598 void *handler_data, void *signal_data)
599{
600 struct ns_signal_data *nssd = signal_data;
601 struct gprs_nsvc *nsvc = nssd->nsvc;
602 struct gbprox_peer *peer;
603
Harald Weltea6a20b42012-06-16 16:40:42 +0800604 if (subsys != SS_L_NS)
Harald Weltec1c1dd22010-05-11 06:34:24 +0200605 return 0;
606
Harald Weltef69c0592010-05-11 18:29:44 +0200607 if (signal == S_NS_RESET && nsvc->nsei == gbcfg.nsip_sgsn_nsei) {
608 /* We have received a NS-RESET from the NSEI and NSVC
609 * of the SGSN. This might happen with SGSN that start
610 * their own NS-RESET procedure without waiting for our
611 * NS-RESET */
612 nsvc->remote_end_is_sgsn = 1;
613 }
614
Harald Welteb778d2c2010-05-12 13:28:25 +0000615 if (signal == S_NS_ALIVE_EXP && nsvc->remote_end_is_sgsn) {
616 LOGP(DGPRS, LOGL_NOTICE, "Tns alive expired too often, "
617 "re-starting RESET procedure\n");
Harald Weltee6599ee2012-06-17 12:25:53 +0800618 gprs_ns_nsip_connect(nsvc->nsi, &nsvc->ip.bts_addr,
619 nsvc->nsei, nsvc->nsvci);
Harald Welteb778d2c2010-05-12 13:28:25 +0000620 }
621
Harald Welte5e106d72011-02-06 16:33:29 +0100622 if (!nsvc->remote_end_is_sgsn) {
623 /* from BSS to SGSN */
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200624 peer = peer_by_nsei(nsvc->nsei);
Harald Welte5e106d72011-02-06 16:33:29 +0100625 if (!peer) {
626 LOGP(DGPRS, LOGL_NOTICE, "signal %u for unknown peer "
627 "NSEI=%u/NSVCI=%u\n", signal, nsvc->nsei,
628 nsvc->nsvci);
629 return 0;
630 }
Harald Weltec1c1dd22010-05-11 06:34:24 +0200631 switch (signal) {
632 case S_NS_RESET:
Harald Weltec1c1dd22010-05-11 06:34:24 +0200633 case S_NS_BLOCK:
Harald Welte5e106d72011-02-06 16:33:29 +0100634 if (!peer->blocked)
635 break;
636 LOGP(DGPRS, LOGL_NOTICE, "Converting NS_RESET from "
637 "NSEI=%u/NSVCI=%u into BSSGP_BVC_BLOCK to SGSN\n",
638 nsvc->nsei, nsvc->nsvci);
639 bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_BLOCK, nsvc->nsei,
640 peer->bvci, 0);
Harald Weltec1c1dd22010-05-11 06:34:24 +0200641 break;
Harald Welte5e106d72011-02-06 16:33:29 +0100642 }
643 } else {
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200644 /* Forward this message to all NS-VC to BSS */
645 struct gprs_ns_inst *nsi = gbcfg.nsi;
646 struct gprs_nsvc *next_nsvc;
647
648 llist_for_each_entry(next_nsvc, &nsi->gprs_nsvcs, list) {
649 if (next_nsvc->remote_end_is_sgsn)
650 continue;
651
652 /* Note that the following does not start the full
653 * procedures including timer based retransmissions. */
Harald Welte5e106d72011-02-06 16:33:29 +0100654 switch (signal) {
655 case S_NS_RESET:
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200656 gprs_ns_tx_reset(next_nsvc, nssd->cause);
Harald Welte5e106d72011-02-06 16:33:29 +0100657 break;
658 case S_NS_BLOCK:
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200659 gprs_ns_tx_block(next_nsvc, nssd->cause);
Harald Welte5e106d72011-02-06 16:33:29 +0100660 break;
661 case S_NS_UNBLOCK:
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200662 gprs_ns_tx_unblock(next_nsvc);
Harald Welte5e106d72011-02-06 16:33:29 +0100663 break;
664 }
Harald Weltec1c1dd22010-05-11 06:34:24 +0200665 }
666 }
667 return 0;
668}
669
Jacob Erlbeck51a869c2013-10-15 12:00:26 +0200670int gbprox_dump_peers(FILE *stream, int indent)
671{
672 struct gbprox_peer *peer;
673 struct gprs_ra_id raid;
674 int rc;
675
676 fprintf(stream, "%*sPeers:\n", indent, "");
677 llist_for_each_entry(peer, &gbprox_bts_peers, list) {
678 gsm48_parse_ra(&raid, peer->ra);
679
680 rc = fprintf(stream, "%*s NSEI %u, BVCI %u, %sblocked, "
681 "RAC %u-%u-%u-%u\n",
682 indent, "",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200683 peer->nsei, peer->bvci,
Jacob Erlbeck51a869c2013-10-15 12:00:26 +0200684 peer->blocked ? "" : "not ",
685 raid.mcc, raid.mnc, raid.lac, raid.rac);
686
687 if (rc < 0)
688 return rc;
689 }
690
691 return 0;
692}
Harald Welte85801d02010-05-11 05:49:43 +0200693
Harald Welte4b037e42010-05-19 19:45:32 +0200694#include <osmocom/vty/command.h>
Harald Welte85801d02010-05-11 05:49:43 +0200695
696gDEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy",
697 SHOW_STR "Display information about the Gb proxy")
698{
699 struct gbprox_peer *peer;
700
701 llist_for_each_entry(peer, &gbprox_bts_peers, list) {
Harald Welte85801d02010-05-11 05:49:43 +0200702 struct gprs_ra_id raid;
Harald Welte7fc98222010-05-11 10:15:42 +0200703 gsm48_parse_ra(&raid, peer->ra);
Harald Welte85801d02010-05-11 05:49:43 +0200704
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200705 vty_out(vty, "NSEI %5u, PTP-BVCI %5u, "
Harald Welte7570c212010-05-19 17:06:16 +0200706 "RAC %u-%u-%u-%u",
Jacob Erlbecke75fec62013-10-15 12:00:27 +0200707 peer->nsei, peer->bvci,
Harald Welte7570c212010-05-19 17:06:16 +0200708 raid.mcc, raid.mnc, raid.lac, raid.rac);
Harald Weltef3956cb2011-02-06 17:44:14 +0100709 if (peer->blocked)
710 vty_out(vty, " [BVC-BLOCKED]");
711
712 vty_out(vty, "%s", VTY_NEWLINE);
Harald Welte85801d02010-05-11 05:49:43 +0200713 }
714 return CMD_SUCCESS;
715}