blob: 3ed7fdfde6da49a5d4f0158f605ba149091743cc [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>
4 * (C) 2010 by On Waves
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (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
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 */
22
23#include <unistd.h>
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include <getopt.h>
28#include <errno.h>
29#include <sys/fcntl.h>
30#include <sys/stat.h>
31#include <sys/types.h>
32
33#include <osmocore/talloc.h>
34#include <osmocore/select.h>
35
36#include <openbsc/signal.h>
37#include <openbsc/debug.h>
38#include <openbsc/gprs_ns.h>
39#include <openbsc/gprs_bssgp.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
45 /* NS-VC over which we send/receive data to this BVC */
46 struct gprs_nsvc *nsvc;
47
48 /* BVCI used for Point-to-Point to this peer */
49 uint16_t bvci;
50
51 /* Routeing Area that this peer is part of (raw 04.08 encoding) */
52 uint8_t ra[6];
53};
54
55/* Linked list of all Gb peers (except SGSN) */
56static LLIST_HEAD(gbprox_bts_peers);
57
Harald Welte9f75c352010-04-30 20:26:32 +020058extern struct gprs_ns_inst *gbprox_nsi;
59
60/* Find the gbprox_peer by its BVCI */
61static struct gbprox_peer *peer_by_bvci(uint16_t bvci)
62{
63 struct gbprox_peer *peer;
64 llist_for_each_entry(peer, &gbprox_bts_peers, list) {
65 if (peer->bvci == bvci)
66 return peer;
67 }
68 return NULL;
69}
70
71static struct gbprox_peer *peer_by_nsvc(struct gprs_nsvc *nsvc)
72{
73 struct gbprox_peer *peer;
74 llist_for_each_entry(peer, &gbprox_bts_peers, list) {
75 if (peer->nsvc == nsvc)
76 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) {
86 if (!memcmp(&peer->ra, ra, 6))
87 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) {
97 if (!memcmp(&peer->ra, la, 5))
98 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 Welte69619e32010-05-03 19:05:10 +0200123/* strip off the NS header */
124static void strip_ns_hdr(struct msgb *msg)
125{
126 int strip_len = msgb_bssgph(msg) - msg->data;
127 msgb_pull(msg, strip_len);
128}
129
Harald Welte44c48302010-05-03 19:22:32 +0200130/* FIXME: this is copy+paste from gprs_bssgp.c */
131static inline struct msgb *bssgp_msgb_alloc(void)
132{
133 return msgb_alloc_headroom(4096, 128, "BSSGP");
134}
135static int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei,
136 uint16_t bvci, uint16_t ns_bvci)
137{
138 struct msgb *msg = bssgp_msgb_alloc();
139 struct bssgp_normal_hdr *bgph =
140 (struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
141 uint16_t _bvci;
142
143 msgb_nsei(msg) = nsei;
144 msgb_bvci(msg) = ns_bvci;
145
146 bgph->pdu_type = pdu_type;
147 _bvci = htons(bvci);
148 msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci);
149
150 return gprs_ns_sendmsg(gbprox_nsi, msg);
151}
152
153
Harald Welte9f75c352010-04-30 20:26:32 +0200154/* feed a message down the NS-VC associated with the specified peer */
Harald Welte69619e32010-05-03 19:05:10 +0200155static int gbprox_relay2sgsn(struct msgb *msg, uint16_t ns_bvci)
Harald Welte672f5c42010-05-03 18:54:58 +0200156{
Harald Welte44c48302010-05-03 19:22:32 +0200157 DEBUGP(DGPRS, "NSEI=%u proxying to SGSN (NS_BVCI=%u, NSEI=%u)\n",
Harald Welte96f71f22010-05-03 19:28:05 +0200158 msgb_nsei(msg), ns_bvci, gbcfg.nsip_sgsn_nsei);
Harald Welte44c48302010-05-03 19:22:32 +0200159
Harald Welte672f5c42010-05-03 18:54:58 +0200160 msgb_bvci(msg) = ns_bvci;
161 msgb_nsei(msg) = gbcfg.nsip_sgsn_nsei;
162
Harald Welte69619e32010-05-03 19:05:10 +0200163 strip_ns_hdr(msg);
164
Harald Welte672f5c42010-05-03 18:54:58 +0200165 return gprs_ns_sendmsg(gbprox_nsi, msg);
166}
167
Harald Welte672f5c42010-05-03 18:54:58 +0200168/* feed a message down the NS-VC associated with the specified peer */
Harald Welte69619e32010-05-03 19:05:10 +0200169static int gbprox_relay2peer(struct msgb *msg, struct gbprox_peer *peer,
Harald Welte9f75c352010-04-30 20:26:32 +0200170 uint16_t ns_bvci)
171{
Harald Welte1c77c6e2010-05-03 21:37:11 +0200172 DEBUGP(DGPRS, "NSEI=%u proxying to BSS (NS_BVCI=%u, NSEI=%u)\n",
Harald Welte96f71f22010-05-03 19:28:05 +0200173 msgb_nsei(msg), ns_bvci, peer->nsvc->nsei);
Harald Welte44c48302010-05-03 19:22:32 +0200174
Harald Welte9f75c352010-04-30 20:26:32 +0200175 msgb_bvci(msg) = ns_bvci;
176 msgb_nsei(msg) = peer->nsvc->nsei;
177
Harald Welte69619e32010-05-03 19:05:10 +0200178 strip_ns_hdr(msg);
179
Harald Welte9f75c352010-04-30 20:26:32 +0200180 return gprs_ns_sendmsg(gbprox_nsi, msg);
181}
182
183/* Send a message to a peer identified by ptp_bvci but using ns_bvci
184 * in the NS hdr */
Harald Welte69619e32010-05-03 19:05:10 +0200185static int gbprox_relay2bvci(struct msgb *msg, uint16_t ptp_bvci,
Harald Welte9f75c352010-04-30 20:26:32 +0200186 uint16_t ns_bvci)
187{
188 struct gbprox_peer *peer;
189
190 peer = peer_by_bvci(ptp_bvci);
Harald Welte1c77c6e2010-05-03 21:37:11 +0200191 if (!peer) {
192 LOGP(DGPRS, LOGL_ERROR, "Cannot find BSS for BVCI %u\n",
193 ptp_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200194 return -ENOENT;
Harald Welte1c77c6e2010-05-03 21:37:11 +0200195 }
Harald Welte9f75c352010-04-30 20:26:32 +0200196
Harald Welte69619e32010-05-03 19:05:10 +0200197 return gbprox_relay2peer(msg, peer, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200198}
199
200/* Receive an incoming signalling message from a BSS-side NS-VC */
201static int gbprox_rx_sig_from_bss(struct msgb *msg, struct gprs_nsvc *nsvc,
202 uint16_t ns_bvci)
203{
Harald Welteca3620a2010-05-03 16:30:59 +0200204 struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200205 struct tlv_parsed tp;
206 uint8_t pdu_type = bgph->pdu_type;
Harald Welteca3620a2010-05-03 16:30:59 +0200207 int data_len = msgb_bssgp_len(msg) - sizeof(*bgph);
Harald Welte9f75c352010-04-30 20:26:32 +0200208 struct gbprox_peer *from_peer;
Harald Welte70f38d22010-05-01 12:10:57 +0200209 struct gprs_ra_id raid;
Harald Welte9f75c352010-04-30 20:26:32 +0200210
211 if (ns_bvci != 0) {
Harald Welte44c48302010-05-03 19:22:32 +0200212 LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u BVCI %u is not signalling\n",
213 nsvc->nsei, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200214 return -EINVAL;
215 }
216
217 /* we actually should never see those two for BVCI == 0, but double-check
218 * just to make sure */
219 if (pdu_type == BSSGP_PDUT_UL_UNITDATA ||
220 pdu_type == BSSGP_PDUT_DL_UNITDATA) {
Harald Welte44c48302010-05-03 19:22:32 +0200221 LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u UNITDATA not allowed in "
222 "signalling\n", nsvc->nsei);
Harald Welte9f75c352010-04-30 20:26:32 +0200223 return -EINVAL;
224 }
225
226 bssgp_tlv_parse(&tp, bgph->data, data_len);
227
228 switch (pdu_type) {
229 case BSSGP_PDUT_SUSPEND:
230 case BSSGP_PDUT_RESUME:
Harald Welte70f38d22010-05-01 12:10:57 +0200231 /* We implement RAC snooping during SUSPEND/RESUME, since
232 * it establishes a relationsip between BVCI/peer and the
233 * routeing area code. The snooped information is then
234 * used for routing the {SUSPEND,RESUME}_[N]ACK back to
235 * the correct BSSGP */
Harald Welte9f75c352010-04-30 20:26:32 +0200236 if (!TLVP_PRESENT(&tp, BSSGP_IE_ROUTEING_AREA))
237 goto err_mand_ie;
238 from_peer = peer_by_nsvc(nsvc);
239 if (!from_peer)
240 goto err_no_peer;
241 memcpy(&from_peer->ra, TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA),
242 sizeof(&from_peer->ra));
Harald Welte70f38d22010-05-01 12:10:57 +0200243 gsm48_parse_ra(&raid, &from_peer->ra);
Harald Welte44c48302010-05-03 19:22:32 +0200244 DEBUGP(DGPRS, "NSEI=%u RAC snooping: RAC %u/%u/%u/%u behind BVCI=%u, "
245 "NSVCI=%u\n", nsvc->nsei, raid.mcc, raid.mnc, raid.lac,
246 raid.rac , from_peer->bvci, nsvc->nsvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200247 /* FIXME: This only supports one BSS per RA */
248 break;
Harald Welte44c48302010-05-03 19:22:32 +0200249 case BSSGP_PDUT_BVC_RESET:
250 /* If we receive a BVC reset on the signalling endpoint, we
251 * don't want the SGSN to reset, as the signalling endpoint
252 * is common for all point-to-point BVCs (and thus all BTS) */
253 if (TLVP_PRESENT(&tp, BSSGP_IE_BVCI)) {
254 uint16_t bvci = ntohs(*(uint16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
255 if (bvci == 0) {
256 /* FIXME: only do this if SGSN is alive! */
257 LOGP(DGPRS, LOGL_INFO, "NSEI=%u Sending fake "
258 "BVC RESET ACK of BVCI=0\n", nsvc->nsei);
259 return bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_RESET_ACK,
260 nsvc->nsei, 0, ns_bvci);
Harald Welte1c77c6e2010-05-03 21:37:11 +0200261 } else if (!peer_by_bvci(bvci)) {
262 /* if a PTP-BVC is reset, and we don't know that
263 * PTP-BVCI yet, we should allocate a new peer */
264 LOGP(DGPRS, LOGL_INFO, "Allocationg new peer for "
265 "BVCI=%u via NSVCI=%u/NSEI=%u\n", bvci,
266 nsvc->nsvci, nsvc->nsei);
267 from_peer = peer_alloc(bvci);
268 from_peer->nsvc = nsvc;
Harald Welte44c48302010-05-03 19:22:32 +0200269 }
270 }
271 break;
Harald Welte9f75c352010-04-30 20:26:32 +0200272 }
273
274 /* Normally, we can simply pass on all signalling messages from BSS to SGSN */
Harald Welte69619e32010-05-03 19:05:10 +0200275 return gbprox_relay2sgsn(msg, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200276err_no_peer:
277err_mand_ie:
278 /* FIXME: do something */
279 ;
280}
281
282/* Receive paging request from SGSN, we need to relay to proper BSS */
283static int gbprox_rx_paging(struct msgb *msg, struct tlv_parsed *tp,
284 struct gprs_nsvc *nsvc, uint16_t ns_bvci)
285{
286 struct gbprox_peer *peer;
287
288 if (TLVP_PRESENT(tp, BSSGP_IE_BVCI)) {
289 uint16_t bvci = ntohs(*(uint16_t *)TLVP_VAL(tp, BSSGP_IE_BVCI));
Harald Welte69619e32010-05-03 19:05:10 +0200290 return gbprox_relay2bvci(msg, bvci, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200291 } else if (TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA)) {
292 peer = peer_by_rac(TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA));
Harald Welte69619e32010-05-03 19:05:10 +0200293 return gbprox_relay2peer(msg, peer, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200294 } else if (TLVP_PRESENT(tp, BSSGP_IE_LOCATION_AREA)) {
295 peer = peer_by_lac(TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA));
Harald Welte69619e32010-05-03 19:05:10 +0200296 return gbprox_relay2peer(msg, peer, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200297 } else
298 return -EINVAL;
299}
300
301/* Receive an incoming signalling message from the SGSN-side NS-VC */
302static int gbprox_rx_sig_from_sgsn(struct msgb *msg, struct gprs_nsvc *nsvc,
303 uint16_t ns_bvci)
304{
Harald Welteca3620a2010-05-03 16:30:59 +0200305 struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg);
Harald Welte9f75c352010-04-30 20:26:32 +0200306 struct tlv_parsed tp;
307 uint8_t pdu_type = bgph->pdu_type;
Harald Welteca3620a2010-05-03 16:30:59 +0200308 int data_len = msgb_bssgp_len(msg) - sizeof(*bgph);
Harald Welte9f75c352010-04-30 20:26:32 +0200309 struct gbprox_peer *peer;
310 uint16_t bvci;
311 int rc = 0;
312
313 if (ns_bvci != 0) {
Harald Welte44c48302010-05-03 19:22:32 +0200314 LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u(SGSN) BVCI %u is not "
315 "signalling\n", nsvc->nsei, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200316 return -EINVAL;
317 }
318
319 /* we actually should never see those two for BVCI == 0, but double-check
320 * just to make sure */
321 if (pdu_type == BSSGP_PDUT_UL_UNITDATA ||
322 pdu_type == BSSGP_PDUT_DL_UNITDATA) {
Harald Welte44c48302010-05-03 19:22:32 +0200323 LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u(SGSN) UNITDATA not allowed in "
324 "signalling\n", nsvc->nsei);
Harald Welte9f75c352010-04-30 20:26:32 +0200325 return -EINVAL;
326 }
327
328 rc = bssgp_tlv_parse(&tp, bgph->data, data_len);
329
330 switch (pdu_type) {
331 case BSSGP_PDUT_FLUSH_LL:
332 case BSSGP_PDUT_BVC_BLOCK_ACK:
333 case BSSGP_PDUT_BVC_UNBLOCK_ACK:
334 case BSSGP_PDUT_BVC_RESET:
335 case BSSGP_PDUT_BVC_RESET_ACK:
336 /* simple case: BVCI IE is mandatory */
337 if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI))
338 goto err_mand_ie;
339 bvci = ntohs(*(uint16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
Harald Welte69619e32010-05-03 19:05:10 +0200340 rc = gbprox_relay2bvci(msg, bvci, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200341 break;
342 case BSSGP_PDUT_PAGING_PS:
343 case BSSGP_PDUT_PAGING_CS:
344 /* process the paging request (LAC/RAC lookup) */
345 rc = gbprox_rx_paging(msg, &tp, nsvc, ns_bvci);
346 break;
347 case BSSGP_PDUT_STATUS:
348 /* FIXME: Some exception has occurred */
Harald Welte44c48302010-05-03 19:22:32 +0200349 LOGP(DGPRS, LOGL_NOTICE,
350 "NSEI=%u(SGSN) STATUS not implemented yet\n", nsvc->nsei);
Harald Welte9f75c352010-04-30 20:26:32 +0200351 break;
352 /* those only exist in the SGSN -> BSS direction */
353 case BSSGP_PDUT_SUSPEND_ACK:
354 case BSSGP_PDUT_SUSPEND_NACK:
355 case BSSGP_PDUT_RESUME_ACK:
356 case BSSGP_PDUT_RESUME_NACK:
357 /* RAC IE is mandatory */
358 if (!TLVP_PRESENT(&tp, BSSGP_IE_ROUTEING_AREA))
359 goto err_mand_ie;
360 peer = peer_by_rac(TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA));
361 if (!peer)
362 goto err_no_peer;
Harald Welte69619e32010-05-03 19:05:10 +0200363 rc = gbprox_relay2peer(msg, peer, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200364 break;
365 case BSSGP_PDUT_SGSN_INVOKE_TRACE:
Harald Welte44c48302010-05-03 19:22:32 +0200366 LOGP(DGPRS, LOGL_ERROR,
367 "NSEI=%u(SGSN) INVOKE TRACE not supported\n", nsvc->nsei);
Harald Welte9f75c352010-04-30 20:26:32 +0200368 break;
369 default:
370 DEBUGP(DGPRS, "BSSGP PDU type 0x%02x unknown\n", pdu_type);
371 break;
372 }
373
374 return rc;
375err_mand_ie:
Harald Welte1c77c6e2010-05-03 21:37:11 +0200376 LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) missing mandatory IE\n",
377 nsvc->nsei);
378 /* FIXME: this would pull gprs_bssgp.c in, which in turn has dependencies */
Harald Welte9f75c352010-04-30 20:26:32 +0200379 //return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
Harald Welte1c77c6e2010-05-03 21:37:11 +0200380 return;
Harald Welte9f75c352010-04-30 20:26:32 +0200381err_no_peer:
Harald Welte1c77c6e2010-05-03 21:37:11 +0200382 LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) cannot find peer based on RAC\n");
383 /* FIXME */
384 return;
Harald Welte9f75c352010-04-30 20:26:32 +0200385}
386
387/* Main input function for Gb proxy */
388int gbprox_rcvmsg(struct msgb *msg, struct gprs_nsvc *nsvc, uint16_t ns_bvci)
389{
Harald Welte672f5c42010-05-03 18:54:58 +0200390 int rc;
Harald Welte9f75c352010-04-30 20:26:32 +0200391
392 /* Only BVCI=0 messages need special treatment */
393 if (ns_bvci == 0 || ns_bvci == 1) {
394 if (nsvc->remote_end_is_sgsn)
Harald Welte672f5c42010-05-03 18:54:58 +0200395 rc = gbprox_rx_sig_from_sgsn(msg, nsvc, ns_bvci);
Harald Welte9f75c352010-04-30 20:26:32 +0200396 else
Harald Welte672f5c42010-05-03 18:54:58 +0200397 rc = gbprox_rx_sig_from_bss(msg, nsvc, ns_bvci);
398 } else {
399 /* All other BVCI are PTP and thus can be simply forwarded */
Harald Welte1c77c6e2010-05-03 21:37:11 +0200400 if (!nsvc->remote_end_is_sgsn) {
Harald Welte69619e32010-05-03 19:05:10 +0200401 rc = gbprox_relay2sgsn(msg, ns_bvci);
Harald Welte70f38d22010-05-01 12:10:57 +0200402 } else {
Harald Welte672f5c42010-05-03 18:54:58 +0200403 struct gbprox_peer *peer = peer_by_bvci(ns_bvci);
404 if (!peer) {
405 LOGP(DGPRS, LOGL_NOTICE, "Allocationg new peer for "
406 "BVCI=%u via NSVC=%u/NSEI=%u\n", ns_bvci,
407 nsvc->nsvci, nsvc->nsei);
408 peer = peer_alloc(ns_bvci);
409 peer->nsvc = nsvc;
410 }
Harald Welte69619e32010-05-03 19:05:10 +0200411 rc = gbprox_relay2peer(msg, peer, ns_bvci);
Harald Welte70f38d22010-05-01 12:10:57 +0200412 }
Harald Welte9f75c352010-04-30 20:26:32 +0200413 }
414
Harald Welte672f5c42010-05-03 18:54:58 +0200415 return rc;
Harald Welte9f75c352010-04-30 20:26:32 +0200416}
Harald Welte85801d02010-05-11 05:49:43 +0200417
418
419#include <vty/command.h>
420
421gDEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy",
422 SHOW_STR "Display information about the Gb proxy")
423{
424 struct gbprox_peer *peer;
425
426 llist_for_each_entry(peer, &gbprox_bts_peers, list) {
427 struct gprs_nsvc *nsvc = peer->nsvc;
428 struct gprs_ra_id raid;
429 gsm48_parse_ra(&raid, &peer->ra);
430
431 vty_out(vty, "NSEI %5u, NS-VC %5u, PTP-BVCI %u, "
432 "RAC %u-%u-%u-%u%s",
433 nsvc->nsei, nsvc->nsvci, peer->bvci,
434 raid.mcc, raid.mnc, raid.lac, raid.rac, VTY_NEWLINE);
435 if (nsvc->nsi->ll == GPRS_NS_LL_UDP)
436 vty_out(vty, " remote address %s:%u%s",
437 inet_ntoa(nsvc->ip.bts_addr.sin_addr),
438 ntohs(nsvc->ip.bts_addr.sin_port), VTY_NEWLINE);
439 }
440 return CMD_SUCCESS;
441}