2010-04-30 18:26:32 +00:00
|
|
|
/* NS-over-IP proxy */
|
|
|
|
|
|
|
|
/* (C) 2010 by Harald Welte <laforge@gnumonks.org>
|
2010-10-06 12:37:09 +00:00
|
|
|
* (C) 2010 by On-Waves
|
2010-04-30 18:26:32 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2010-04-30 18:26:32 +00:00
|
|
|
* (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
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2010-04-30 18:26:32 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-04-30 18:26:32 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/stat.h>
|
2010-05-11 08:15:42 +00:00
|
|
|
#include <arpa/inet.h>
|
2010-04-30 18:26:32 +00:00
|
|
|
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/talloc.h>
|
|
|
|
#include <osmocom/core/select.h>
|
2010-04-30 18:26:32 +00:00
|
|
|
|
2012-06-16 06:59:56 +00:00
|
|
|
#include <osmocom/gprs/gprs_ns.h>
|
|
|
|
#include <osmocom/gprs/gprs_bssgp.h>
|
|
|
|
|
2010-04-30 18:26:32 +00:00
|
|
|
#include <openbsc/signal.h>
|
|
|
|
#include <openbsc/debug.h>
|
2010-05-03 16:54:58 +00:00
|
|
|
#include <openbsc/gb_proxy.h>
|
2010-04-30 18:26:32 +00:00
|
|
|
|
2012-09-04 18:42:20 +00:00
|
|
|
static uint16_t tlvp_val16_unal(const struct tlv_parsed *tp, int pos)
|
|
|
|
{
|
|
|
|
uint16_t res;
|
|
|
|
memcpy(&res, TLVP_VAL(tp, pos), sizeof(res));
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2010-04-30 18:26:32 +00:00
|
|
|
struct gbprox_peer {
|
|
|
|
struct llist_head list;
|
|
|
|
|
|
|
|
/* NS-VC over which we send/receive data to this BVC */
|
|
|
|
struct gprs_nsvc *nsvc;
|
|
|
|
|
|
|
|
/* BVCI used for Point-to-Point to this peer */
|
|
|
|
uint16_t bvci;
|
2011-02-06 12:09:29 +00:00
|
|
|
int blocked;
|
2010-04-30 18:26:32 +00:00
|
|
|
|
|
|
|
/* Routeing Area that this peer is part of (raw 04.08 encoding) */
|
|
|
|
uint8_t ra[6];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Linked list of all Gb peers (except SGSN) */
|
|
|
|
static LLIST_HEAD(gbprox_bts_peers);
|
|
|
|
|
|
|
|
/* Find the gbprox_peer by its BVCI */
|
|
|
|
static struct gbprox_peer *peer_by_bvci(uint16_t bvci)
|
|
|
|
{
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
llist_for_each_entry(peer, &gbprox_bts_peers, list) {
|
|
|
|
if (peer->bvci == bvci)
|
|
|
|
return peer;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct gbprox_peer *peer_by_nsvc(struct gprs_nsvc *nsvc)
|
|
|
|
{
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
llist_for_each_entry(peer, &gbprox_bts_peers, list) {
|
|
|
|
if (peer->nsvc == nsvc)
|
|
|
|
return peer;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* look-up a peer by its Routeing Area Code (RAC) */
|
2010-05-01 10:10:57 +00:00
|
|
|
static struct gbprox_peer *peer_by_rac(const uint8_t *ra)
|
2010-04-30 18:26:32 +00:00
|
|
|
{
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
llist_for_each_entry(peer, &gbprox_bts_peers, list) {
|
2010-05-11 22:07:29 +00:00
|
|
|
if (!memcmp(peer->ra, ra, 6))
|
2010-04-30 18:26:32 +00:00
|
|
|
return peer;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* look-up a peer by its Location Area Code (LAC) */
|
2010-05-01 10:10:57 +00:00
|
|
|
static struct gbprox_peer *peer_by_lac(const uint8_t *la)
|
2010-04-30 18:26:32 +00:00
|
|
|
{
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
llist_for_each_entry(peer, &gbprox_bts_peers, list) {
|
2010-05-11 22:07:29 +00:00
|
|
|
if (!memcmp(peer->ra, la, 5))
|
2010-04-30 18:26:32 +00:00
|
|
|
return peer;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct gbprox_peer *peer_alloc(uint16_t bvci)
|
|
|
|
{
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
|
|
|
|
peer = talloc_zero(tall_bsc_ctx, struct gbprox_peer);
|
|
|
|
if (!peer)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
peer->bvci = bvci;
|
|
|
|
llist_add(&peer->list, &gbprox_bts_peers);
|
|
|
|
|
|
|
|
return peer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void peer_free(struct gbprox_peer *peer)
|
|
|
|
{
|
|
|
|
llist_del(&peer->list);
|
|
|
|
talloc_free(peer);
|
|
|
|
}
|
|
|
|
|
2010-05-12 18:10:25 +00:00
|
|
|
/* FIXME: this needs to go to libosmocore/msgb.c */
|
|
|
|
static struct msgb *msgb_copy(const struct msgb *msg, const char *name)
|
|
|
|
{
|
2012-06-16 08:09:52 +00:00
|
|
|
struct libgb_msgb_cb *old_cb, *new_cb;
|
2010-05-12 18:10:25 +00:00
|
|
|
struct msgb *new_msg;
|
|
|
|
|
2010-06-08 10:14:37 +00:00
|
|
|
new_msg = msgb_alloc(msg->data_len, name);
|
2010-05-12 18:10:25 +00:00
|
|
|
if (!new_msg)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* copy data */
|
2010-06-08 10:14:37 +00:00
|
|
|
memcpy(new_msg->_data, msg->_data, new_msg->data_len);
|
|
|
|
|
|
|
|
/* copy header */
|
|
|
|
new_msg->len = msg->len;
|
|
|
|
new_msg->data += msg->data - msg->_data;
|
|
|
|
new_msg->head += msg->head - msg->_data;
|
|
|
|
new_msg->tail += msg->tail - msg->_data;
|
|
|
|
|
|
|
|
new_msg->l1h = new_msg->_data + (msg->l1h - msg->_data);
|
|
|
|
new_msg->l2h = new_msg->_data + (msg->l2h - msg->_data);
|
|
|
|
new_msg->l3h = new_msg->_data + (msg->l3h - msg->_data);
|
|
|
|
new_msg->l4h = new_msg->_data + (msg->l4h - msg->_data);
|
|
|
|
|
|
|
|
/* copy GB specific data */
|
2012-06-16 08:09:52 +00:00
|
|
|
old_cb = LIBGB_MSGB_CB(msg);
|
|
|
|
new_cb = LIBGB_MSGB_CB(new_msg);
|
2010-06-08 10:14:37 +00:00
|
|
|
|
|
|
|
new_cb->bssgph = new_msg->_data + (old_cb->bssgph - msg->_data);
|
|
|
|
new_cb->llch = new_msg->_data + (old_cb->llch - msg->_data);
|
|
|
|
|
2011-02-06 16:17:05 +00:00
|
|
|
/* bssgp_cell_id is a pointer into the old msgb, so we need to make
|
|
|
|
* it a pointer into the new msgb */
|
|
|
|
new_cb->bssgp_cell_id = new_msg->_data + (old_cb->bssgp_cell_id - msg->_data);
|
2010-06-08 10:14:37 +00:00
|
|
|
new_cb->nsei = old_cb->nsei;
|
|
|
|
new_cb->bvci = old_cb->bvci;
|
|
|
|
new_cb->tlli = old_cb->tlli;
|
2010-05-12 18:10:25 +00:00
|
|
|
|
|
|
|
return new_msg;
|
|
|
|
}
|
|
|
|
|
2010-05-03 17:05:10 +00:00
|
|
|
/* strip off the NS header */
|
|
|
|
static void strip_ns_hdr(struct msgb *msg)
|
|
|
|
{
|
|
|
|
int strip_len = msgb_bssgph(msg) - msg->data;
|
|
|
|
msgb_pull(msg, strip_len);
|
|
|
|
}
|
|
|
|
|
2010-05-03 16:54:58 +00:00
|
|
|
/* feed a message down the NS-VC associated with the specified peer */
|
2010-05-12 18:10:25 +00:00
|
|
|
static int gbprox_relay2sgsn(struct msgb *old_msg, uint16_t ns_bvci)
|
2010-05-03 16:54:58 +00:00
|
|
|
{
|
2010-05-12 18:10:25 +00:00
|
|
|
/* create a copy of the message so the old one can
|
|
|
|
* be free()d safely when we return from gbprox_rcvmsg() */
|
|
|
|
struct msgb *msg = msgb_copy(old_msg, "msgb_relay2sgsn");
|
|
|
|
|
2010-05-11 18:20:13 +00:00
|
|
|
DEBUGP(DGPRS, "NSEI=%u proxying BTS->SGSN (NS_BVCI=%u, NSEI=%u)\n",
|
2010-05-03 17:28:05 +00:00
|
|
|
msgb_nsei(msg), ns_bvci, gbcfg.nsip_sgsn_nsei);
|
2010-05-03 17:22:32 +00:00
|
|
|
|
2010-05-03 16:54:58 +00:00
|
|
|
msgb_bvci(msg) = ns_bvci;
|
|
|
|
msgb_nsei(msg) = gbcfg.nsip_sgsn_nsei;
|
|
|
|
|
2010-05-03 17:05:10 +00:00
|
|
|
strip_ns_hdr(msg);
|
|
|
|
|
2010-05-11 08:01:17 +00:00
|
|
|
return gprs_ns_sendmsg(bssgp_nsi, msg);
|
2010-05-03 16:54:58 +00:00
|
|
|
}
|
|
|
|
|
2010-04-30 18:26:32 +00:00
|
|
|
/* feed a message down the NS-VC associated with the specified peer */
|
2010-05-12 18:10:25 +00:00
|
|
|
static int gbprox_relay2peer(struct msgb *old_msg, struct gbprox_peer *peer,
|
2010-04-30 18:26:32 +00:00
|
|
|
uint16_t ns_bvci)
|
|
|
|
{
|
2010-05-12 18:10:25 +00:00
|
|
|
/* create a copy of the message so the old one can
|
|
|
|
* be free()d safely when we return from gbprox_rcvmsg() */
|
|
|
|
struct msgb *msg = msgb_copy(old_msg, "msgb_relay2peer");
|
|
|
|
|
2010-05-13 08:34:56 +00:00
|
|
|
DEBUGP(DGPRS, "NSEI=%u proxying SGSN->BSS (NS_BVCI=%u, NSEI=%u)\n",
|
2010-05-03 17:28:05 +00:00
|
|
|
msgb_nsei(msg), ns_bvci, peer->nsvc->nsei);
|
2010-05-03 17:22:32 +00:00
|
|
|
|
2010-04-30 18:26:32 +00:00
|
|
|
msgb_bvci(msg) = ns_bvci;
|
|
|
|
msgb_nsei(msg) = peer->nsvc->nsei;
|
|
|
|
|
2010-05-13 08:34:56 +00:00
|
|
|
/* Strip the old NS header, it will be replaced with a new one */
|
2010-05-03 17:05:10 +00:00
|
|
|
strip_ns_hdr(msg);
|
|
|
|
|
2010-05-11 08:01:17 +00:00
|
|
|
return gprs_ns_sendmsg(bssgp_nsi, msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
}
|
|
|
|
|
2011-02-06 12:09:29 +00:00
|
|
|
static int block_unblock_peer(uint16_t ptp_bvci, uint8_t pdu_type)
|
|
|
|
{
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
|
|
|
|
peer = peer_by_bvci(ptp_bvci);
|
|
|
|
if (!peer) {
|
|
|
|
LOGP(DGPRS, LOGL_ERROR, "BVCI=%u: Cannot find BSS\n",
|
|
|
|
ptp_bvci);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (pdu_type) {
|
|
|
|
case BSSGP_PDUT_BVC_BLOCK_ACK:
|
|
|
|
peer->blocked = 1;
|
|
|
|
break;
|
|
|
|
case BSSGP_PDUT_BVC_UNBLOCK_ACK:
|
|
|
|
peer->blocked = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-30 18:26:32 +00:00
|
|
|
/* Send a message to a peer identified by ptp_bvci but using ns_bvci
|
|
|
|
* in the NS hdr */
|
2010-05-03 17:05:10 +00:00
|
|
|
static int gbprox_relay2bvci(struct msgb *msg, uint16_t ptp_bvci,
|
2010-04-30 18:26:32 +00:00
|
|
|
uint16_t ns_bvci)
|
|
|
|
{
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
|
|
|
|
peer = peer_by_bvci(ptp_bvci);
|
2010-05-03 19:37:11 +00:00
|
|
|
if (!peer) {
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGP(DGPRS, LOGL_ERROR, "BVCI=%u: Cannot find BSS\n",
|
2010-05-03 19:37:11 +00:00
|
|
|
ptp_bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
return -ENOENT;
|
2010-05-03 19:37:11 +00:00
|
|
|
}
|
2010-04-30 18:26:32 +00:00
|
|
|
|
2010-05-03 17:05:10 +00:00
|
|
|
return gbprox_relay2peer(msg, peer, ns_bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
}
|
|
|
|
|
2012-06-17 04:16:31 +00:00
|
|
|
int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-30 18:26:32 +00:00
|
|
|
/* Receive an incoming signalling message from a BSS-side NS-VC */
|
|
|
|
static int gbprox_rx_sig_from_bss(struct msgb *msg, struct gprs_nsvc *nsvc,
|
|
|
|
uint16_t ns_bvci)
|
|
|
|
{
|
2010-05-03 14:30:59 +00:00
|
|
|
struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
struct tlv_parsed tp;
|
|
|
|
uint8_t pdu_type = bgph->pdu_type;
|
2010-05-03 14:30:59 +00:00
|
|
|
int data_len = msgb_bssgp_len(msg) - sizeof(*bgph);
|
2010-04-30 18:26:32 +00:00
|
|
|
struct gbprox_peer *from_peer;
|
2010-05-01 10:10:57 +00:00
|
|
|
struct gprs_ra_id raid;
|
2010-04-30 18:26:32 +00:00
|
|
|
|
2011-02-06 16:13:12 +00:00
|
|
|
if (ns_bvci != 0 && ns_bvci != 1) {
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u BVCI=%u is not signalling\n",
|
2010-05-03 17:22:32 +00:00
|
|
|
nsvc->nsei, ns_bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we actually should never see those two for BVCI == 0, but double-check
|
|
|
|
* just to make sure */
|
|
|
|
if (pdu_type == BSSGP_PDUT_UL_UNITDATA ||
|
|
|
|
pdu_type == BSSGP_PDUT_DL_UNITDATA) {
|
2010-05-03 17:22:32 +00:00
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u UNITDATA not allowed in "
|
|
|
|
"signalling\n", nsvc->nsei);
|
2010-04-30 18:26:32 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bssgp_tlv_parse(&tp, bgph->data, data_len);
|
|
|
|
|
|
|
|
switch (pdu_type) {
|
|
|
|
case BSSGP_PDUT_SUSPEND:
|
|
|
|
case BSSGP_PDUT_RESUME:
|
2010-05-01 10:10:57 +00:00
|
|
|
/* We implement RAC snooping during SUSPEND/RESUME, since
|
|
|
|
* it establishes a relationsip between BVCI/peer and the
|
|
|
|
* routeing area code. The snooped information is then
|
|
|
|
* used for routing the {SUSPEND,RESUME}_[N]ACK back to
|
|
|
|
* the correct BSSGP */
|
2010-04-30 18:26:32 +00:00
|
|
|
if (!TLVP_PRESENT(&tp, BSSGP_IE_ROUTEING_AREA))
|
|
|
|
goto err_mand_ie;
|
|
|
|
from_peer = peer_by_nsvc(nsvc);
|
|
|
|
if (!from_peer)
|
|
|
|
goto err_no_peer;
|
2010-05-11 22:07:29 +00:00
|
|
|
memcpy(from_peer->ra, TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA),
|
|
|
|
sizeof(from_peer->ra));
|
2010-05-11 08:15:42 +00:00
|
|
|
gsm48_parse_ra(&raid, from_peer->ra);
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGP(DGPRS, LOGL_INFO, "NSEI=%u BSSGP SUSPEND/RESUME "
|
|
|
|
"RAC snooping: RAC %u-%u-%u-%u behind BVCI=%u, "
|
|
|
|
"NSVCI=%u\n",nsvc->nsei, raid.mcc, raid.mnc, raid.lac,
|
|
|
|
raid.rac , from_peer->bvci, nsvc->nsvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
/* FIXME: This only supports one BSS per RA */
|
|
|
|
break;
|
2010-05-03 17:22:32 +00:00
|
|
|
case BSSGP_PDUT_BVC_RESET:
|
|
|
|
/* If we receive a BVC reset on the signalling endpoint, we
|
|
|
|
* don't want the SGSN to reset, as the signalling endpoint
|
|
|
|
* is common for all point-to-point BVCs (and thus all BTS) */
|
|
|
|
if (TLVP_PRESENT(&tp, BSSGP_IE_BVCI)) {
|
2012-09-04 18:42:20 +00:00
|
|
|
uint16_t bvci = ntohs(tlvp_val16_unal(&tp, BSSGP_IE_BVCI));
|
2010-05-11 22:20:41 +00:00
|
|
|
LOGP(DGPRS, LOGL_INFO, "NSEI=%u Rx BVC RESET (BVCI=%u)\n",
|
2010-05-11 18:20:13 +00:00
|
|
|
nsvc->nsei, bvci);
|
2010-05-03 17:22:32 +00:00
|
|
|
if (bvci == 0) {
|
|
|
|
/* FIXME: only do this if SGSN is alive! */
|
2010-05-11 18:20:13 +00:00
|
|
|
LOGP(DGPRS, LOGL_INFO, "NSEI=%u Tx fake "
|
2010-05-03 17:22:32 +00:00
|
|
|
"BVC RESET ACK of BVCI=0\n", nsvc->nsei);
|
|
|
|
return bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_RESET_ACK,
|
|
|
|
nsvc->nsei, 0, ns_bvci);
|
2010-05-11 22:07:29 +00:00
|
|
|
}
|
|
|
|
from_peer = peer_by_bvci(bvci);
|
|
|
|
if (!from_peer) {
|
2010-05-03 19:37:11 +00:00
|
|
|
/* if a PTP-BVC is reset, and we don't know that
|
|
|
|
* PTP-BVCI yet, we should allocate a new peer */
|
|
|
|
LOGP(DGPRS, LOGL_INFO, "Allocationg new peer for "
|
|
|
|
"BVCI=%u via NSVCI=%u/NSEI=%u\n", bvci,
|
|
|
|
nsvc->nsvci, nsvc->nsei);
|
|
|
|
from_peer = peer_alloc(bvci);
|
|
|
|
from_peer->nsvc = nsvc;
|
2010-05-03 17:22:32 +00:00
|
|
|
}
|
2010-05-11 22:07:29 +00:00
|
|
|
if (TLVP_PRESENT(&tp, BSSGP_IE_CELL_ID)) {
|
|
|
|
struct gprs_ra_id raid;
|
|
|
|
/* We have a Cell Identifier present in this
|
|
|
|
* PDU, this means we can extend our local
|
|
|
|
* state information about this particular cell
|
|
|
|
* */
|
|
|
|
memcpy(from_peer->ra,
|
|
|
|
TLVP_VAL(&tp, BSSGP_IE_CELL_ID),
|
|
|
|
sizeof(from_peer->ra));
|
|
|
|
gsm48_parse_ra(&raid, from_peer->ra);
|
|
|
|
LOGP(DGPRS, LOGL_INFO, "NSEI=%u/BVCI=%u "
|
2010-05-11 22:20:41 +00:00
|
|
|
"Cell ID %u-%u-%u-%u\n", nsvc->nsei,
|
2010-05-11 22:07:29 +00:00
|
|
|
bvci, raid.mcc, raid.mnc, raid.lac,
|
|
|
|
raid.rac);
|
|
|
|
}
|
2010-05-03 17:22:32 +00:00
|
|
|
}
|
|
|
|
break;
|
2010-04-30 18:26:32 +00:00
|
|
|
}
|
|
|
|
|
2010-05-11 18:20:13 +00:00
|
|
|
/* Normally, we can simply pass on all signalling messages from BSS to
|
|
|
|
* SGSN */
|
2010-05-03 17:05:10 +00:00
|
|
|
return gbprox_relay2sgsn(msg, ns_bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
err_no_peer:
|
2010-05-11 08:01:17 +00:00
|
|
|
LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(BSS) cannot find peer based on RAC\n",
|
|
|
|
nsvc->nsei);
|
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, NULL, msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
err_mand_ie:
|
2010-05-11 08:01:17 +00:00
|
|
|
LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(BSS) missing mandatory RA IE\n",
|
|
|
|
nsvc->nsei);
|
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Receive paging request from SGSN, we need to relay to proper BSS */
|
|
|
|
static int gbprox_rx_paging(struct msgb *msg, struct tlv_parsed *tp,
|
|
|
|
struct gprs_nsvc *nsvc, uint16_t ns_bvci)
|
|
|
|
{
|
2010-05-13 12:14:56 +00:00
|
|
|
struct gbprox_peer *peer = NULL;
|
2010-04-30 18:26:32 +00:00
|
|
|
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGP(DGPRS, LOGL_INFO, "NSEI=%u(SGSN) BSSGP PAGING ",
|
|
|
|
nsvc->nsei);
|
2010-04-30 18:26:32 +00:00
|
|
|
if (TLVP_PRESENT(tp, BSSGP_IE_BVCI)) {
|
2012-09-04 18:42:20 +00:00
|
|
|
uint16_t bvci = ntohs(tlvp_val16_unal(tp, BSSGP_IE_BVCI));
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGPC(DGPRS, LOGL_INFO, "routing by BVCI to peer BVCI=%u\n",
|
|
|
|
bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
} else if (TLVP_PRESENT(tp, BSSGP_IE_ROUTEING_AREA)) {
|
|
|
|
peer = peer_by_rac(TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA));
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGPC(DGPRS, LOGL_INFO, "routing by RAC to peer BVCI=%u\n",
|
2010-06-08 08:30:24 +00:00
|
|
|
peer ? peer->bvci : -1);
|
2010-04-30 18:26:32 +00:00
|
|
|
} else if (TLVP_PRESENT(tp, BSSGP_IE_LOCATION_AREA)) {
|
|
|
|
peer = peer_by_lac(TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA));
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGPC(DGPRS, LOGL_INFO, "routing by LAC to peer BVCI=%u\n",
|
2010-06-08 08:30:24 +00:00
|
|
|
peer ? peer->bvci : -1);
|
2010-04-30 18:26:32 +00:00
|
|
|
} else
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGPC(DGPRS, LOGL_INFO, "\n");
|
|
|
|
|
|
|
|
if (!peer) {
|
|
|
|
LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) BSSGP PAGING: "
|
|
|
|
"unable to route, missing IE\n", nsvc->nsei);
|
2010-04-30 18:26:32 +00:00
|
|
|
return -EINVAL;
|
2010-05-13 12:14:56 +00:00
|
|
|
}
|
|
|
|
return gbprox_relay2peer(msg, peer, ns_bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
}
|
|
|
|
|
2010-05-11 08:01:17 +00:00
|
|
|
/* Receive an incoming BVC-RESET message from the SGSN */
|
|
|
|
static int rx_reset_from_sgsn(struct msgb *msg, struct tlv_parsed *tp,
|
|
|
|
struct gprs_nsvc *nsvc, uint16_t ns_bvci)
|
|
|
|
{
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
uint16_t ptp_bvci;
|
|
|
|
|
|
|
|
if (!TLVP_PRESENT(tp, BSSGP_IE_BVCI)) {
|
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE,
|
|
|
|
NULL, msg);
|
|
|
|
}
|
2012-09-04 18:42:20 +00:00
|
|
|
ptp_bvci = ntohs(tlvp_val16_unal(tp, BSSGP_IE_BVCI));
|
2010-05-11 08:01:17 +00:00
|
|
|
|
|
|
|
if (ptp_bvci >= 2) {
|
|
|
|
/* A reset for a PTP BVC was received, forward it to its
|
|
|
|
* respective peer */
|
|
|
|
peer = peer_by_bvci(ptp_bvci);
|
|
|
|
if (!peer) {
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGP(DGPRS, LOGL_ERROR, "NSEI=%u BVCI=%u: Cannot find BSS\n",
|
|
|
|
nsvc->nsei, ptp_bvci);
|
2010-05-11 08:01:17 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI,
|
|
|
|
NULL, msg);
|
|
|
|
}
|
|
|
|
return gbprox_relay2peer(msg, peer, ns_bvci);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* A reset for the Signalling entity has been received
|
|
|
|
* from the SGSN. As the signalling BVCI is shared
|
|
|
|
* among all the BSS's that we multiplex, it needs to
|
|
|
|
* be relayed */
|
|
|
|
llist_for_each_entry(peer, &gbprox_bts_peers, list)
|
|
|
|
gbprox_relay2peer(msg, peer, ns_bvci);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-30 18:26:32 +00:00
|
|
|
/* Receive an incoming signalling message from the SGSN-side NS-VC */
|
|
|
|
static int gbprox_rx_sig_from_sgsn(struct msgb *msg, struct gprs_nsvc *nsvc,
|
|
|
|
uint16_t ns_bvci)
|
|
|
|
{
|
2010-05-03 14:30:59 +00:00
|
|
|
struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) msgb_bssgph(msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
struct tlv_parsed tp;
|
|
|
|
uint8_t pdu_type = bgph->pdu_type;
|
2010-05-03 14:30:59 +00:00
|
|
|
int data_len = msgb_bssgp_len(msg) - sizeof(*bgph);
|
2010-04-30 18:26:32 +00:00
|
|
|
struct gbprox_peer *peer;
|
|
|
|
uint16_t bvci;
|
|
|
|
int rc = 0;
|
|
|
|
|
2011-02-06 16:13:12 +00:00
|
|
|
if (ns_bvci != 0 && ns_bvci != 1) {
|
2010-05-13 12:14:56 +00:00
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u(SGSN) BVCI=%u is not "
|
2010-05-03 17:22:32 +00:00
|
|
|
"signalling\n", nsvc->nsei, ns_bvci);
|
2010-05-11 08:01:17 +00:00
|
|
|
/* FIXME: Send proper error message */
|
2010-04-30 18:26:32 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we actually should never see those two for BVCI == 0, but double-check
|
|
|
|
* just to make sure */
|
|
|
|
if (pdu_type == BSSGP_PDUT_UL_UNITDATA ||
|
|
|
|
pdu_type == BSSGP_PDUT_DL_UNITDATA) {
|
2010-05-03 17:22:32 +00:00
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u(SGSN) UNITDATA not allowed in "
|
|
|
|
"signalling\n", nsvc->nsei);
|
2010-05-11 08:01:17 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rc = bssgp_tlv_parse(&tp, bgph->data, data_len);
|
|
|
|
|
|
|
|
switch (pdu_type) {
|
2010-05-11 08:01:17 +00:00
|
|
|
case BSSGP_PDUT_BVC_RESET:
|
|
|
|
rc = rx_reset_from_sgsn(msg, &tp, nsvc, ns_bvci);
|
|
|
|
break;
|
2010-04-30 18:26:32 +00:00
|
|
|
case BSSGP_PDUT_FLUSH_LL:
|
|
|
|
case BSSGP_PDUT_BVC_RESET_ACK:
|
|
|
|
/* simple case: BVCI IE is mandatory */
|
|
|
|
if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI))
|
|
|
|
goto err_mand_ie;
|
2012-09-04 18:42:20 +00:00
|
|
|
bvci = ntohs(tlvp_val16_unal(&tp, BSSGP_IE_BVCI));
|
2010-05-03 17:05:10 +00:00
|
|
|
rc = gbprox_relay2bvci(msg, bvci, ns_bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
break;
|
|
|
|
case BSSGP_PDUT_PAGING_PS:
|
|
|
|
case BSSGP_PDUT_PAGING_CS:
|
|
|
|
/* process the paging request (LAC/RAC lookup) */
|
|
|
|
rc = gbprox_rx_paging(msg, &tp, nsvc, ns_bvci);
|
|
|
|
break;
|
|
|
|
case BSSGP_PDUT_STATUS:
|
2010-05-11 08:01:17 +00:00
|
|
|
/* Some exception has occurred */
|
2010-05-03 17:22:32 +00:00
|
|
|
LOGP(DGPRS, LOGL_NOTICE,
|
2010-05-13 12:14:56 +00:00
|
|
|
"NSEI=%u(SGSN) BSSGP STATUS ", nsvc->nsei);
|
2010-05-11 08:01:17 +00:00
|
|
|
if (!TLVP_PRESENT(&tp, BSSGP_IE_CAUSE)) {
|
|
|
|
LOGPC(DGPRS, LOGL_NOTICE, "\n");
|
|
|
|
goto err_mand_ie;
|
|
|
|
}
|
|
|
|
LOGPC(DGPRS, LOGL_NOTICE,
|
|
|
|
"cause=0x%02x(%s) ", *TLVP_VAL(&tp, BSSGP_IE_CAUSE),
|
|
|
|
bssgp_cause_str(*TLVP_VAL(&tp, BSSGP_IE_CAUSE)));
|
|
|
|
if (TLVP_PRESENT(&tp, BSSGP_IE_BVCI)) {
|
2012-09-04 18:42:20 +00:00
|
|
|
uint16_t bvci = tlvp_val16_unal(&tp, BSSGP_IE_BVCI);
|
2010-05-11 08:01:17 +00:00
|
|
|
LOGPC(DGPRS, LOGL_NOTICE,
|
2012-09-04 18:42:20 +00:00
|
|
|
"BVCI=%u\n", ntohs(bvci));
|
2010-05-11 08:01:17 +00:00
|
|
|
} else
|
|
|
|
LOGPC(DGPRS, LOGL_NOTICE, "\n");
|
2010-04-30 18:26:32 +00:00
|
|
|
break;
|
|
|
|
/* those only exist in the SGSN -> BSS direction */
|
|
|
|
case BSSGP_PDUT_SUSPEND_ACK:
|
|
|
|
case BSSGP_PDUT_SUSPEND_NACK:
|
|
|
|
case BSSGP_PDUT_RESUME_ACK:
|
|
|
|
case BSSGP_PDUT_RESUME_NACK:
|
|
|
|
/* RAC IE is mandatory */
|
|
|
|
if (!TLVP_PRESENT(&tp, BSSGP_IE_ROUTEING_AREA))
|
|
|
|
goto err_mand_ie;
|
|
|
|
peer = peer_by_rac(TLVP_VAL(&tp, BSSGP_IE_ROUTEING_AREA));
|
|
|
|
if (!peer)
|
|
|
|
goto err_no_peer;
|
2010-05-03 17:05:10 +00:00
|
|
|
rc = gbprox_relay2peer(msg, peer, ns_bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
break;
|
2011-02-06 12:09:29 +00:00
|
|
|
case BSSGP_PDUT_BVC_BLOCK_ACK:
|
|
|
|
case BSSGP_PDUT_BVC_UNBLOCK_ACK:
|
|
|
|
if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI))
|
|
|
|
goto err_mand_ie;
|
2012-09-04 18:42:20 +00:00
|
|
|
bvci = ntohs(tlvp_val16_unal(&tp, BSSGP_IE_BVCI));
|
2011-02-06 12:09:29 +00:00
|
|
|
if (bvci == 0) {
|
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "NSEI=%u(SGSN) BSSGP "
|
|
|
|
"%sBLOCK_ACK for signalling BVCI ?!?\n", nsvc->nsei,
|
|
|
|
pdu_type == BSSGP_PDUT_BVC_UNBLOCK_ACK ? "UN":"");
|
|
|
|
/* should we send STATUS ? */
|
|
|
|
} else {
|
|
|
|
/* Mark BVC as (un)blocked */
|
|
|
|
block_unblock_peer(bvci, pdu_type);
|
|
|
|
}
|
|
|
|
rc = gbprox_relay2bvci(msg, bvci, ns_bvci);
|
|
|
|
break;
|
2010-04-30 18:26:32 +00:00
|
|
|
case BSSGP_PDUT_SGSN_INVOKE_TRACE:
|
2010-05-03 17:22:32 +00:00
|
|
|
LOGP(DGPRS, LOGL_ERROR,
|
2010-05-13 12:14:56 +00:00
|
|
|
"NSEI=%u(SGSN) BSSGP INVOKE TRACE not supported\n",nsvc->nsei);
|
2010-05-11 08:01:17 +00:00
|
|
|
rc = bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_FEAT, NULL, msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-05-11 22:20:41 +00:00
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "BSSGP PDU type 0x%02x unknown\n",
|
|
|
|
pdu_type);
|
2010-05-11 08:01:17 +00:00
|
|
|
rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
err_mand_ie:
|
2010-05-03 19:37:11 +00:00
|
|
|
LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) missing mandatory IE\n",
|
|
|
|
nsvc->nsei);
|
2010-05-11 08:01:17 +00:00
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
err_no_peer:
|
2010-05-11 08:01:17 +00:00
|
|
|
LOGP(DGPRS, LOGL_ERROR, "NSEI=%u(SGSN) cannot find peer based on RAC\n",
|
|
|
|
nsvc->nsei);
|
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_UNKNOWN_BVCI, NULL, msg);
|
2010-04-30 18:26:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Main input function for Gb proxy */
|
|
|
|
int gbprox_rcvmsg(struct msgb *msg, struct gprs_nsvc *nsvc, uint16_t ns_bvci)
|
|
|
|
{
|
2010-05-03 16:54:58 +00:00
|
|
|
int rc;
|
2011-02-06 12:09:29 +00:00
|
|
|
struct gbprox_peer *peer;
|
2010-04-30 18:26:32 +00:00
|
|
|
|
|
|
|
/* Only BVCI=0 messages need special treatment */
|
|
|
|
if (ns_bvci == 0 || ns_bvci == 1) {
|
|
|
|
if (nsvc->remote_end_is_sgsn)
|
2010-05-03 16:54:58 +00:00
|
|
|
rc = gbprox_rx_sig_from_sgsn(msg, nsvc, ns_bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
else
|
2010-05-03 16:54:58 +00:00
|
|
|
rc = gbprox_rx_sig_from_bss(msg, nsvc, ns_bvci);
|
|
|
|
} else {
|
|
|
|
/* All other BVCI are PTP and thus can be simply forwarded */
|
2010-05-03 19:37:11 +00:00
|
|
|
if (!nsvc->remote_end_is_sgsn) {
|
2011-02-06 12:09:29 +00:00
|
|
|
return gbprox_relay2sgsn(msg, ns_bvci);
|
|
|
|
}
|
|
|
|
/* else: SGSN -> BSS direction */
|
|
|
|
peer = peer_by_bvci(ns_bvci);
|
|
|
|
if (!peer) {
|
|
|
|
LOGP(DGPRS, LOGL_INFO, "Allocationg new peer for "
|
|
|
|
"BVCI=%u via NSVC=%u/NSEI=%u\n", ns_bvci,
|
|
|
|
nsvc->nsvci, nsvc->nsei);
|
|
|
|
peer = peer_alloc(ns_bvci);
|
|
|
|
peer->nsvc = nsvc;
|
2010-05-01 10:10:57 +00:00
|
|
|
}
|
2011-02-06 12:09:29 +00:00
|
|
|
if (peer->blocked) {
|
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "Dropping PDU for "
|
|
|
|
"blocked BVCI=%u via NSVC=%u/NSEI=%u\n",
|
|
|
|
ns_bvci, nsvc->nsvci, nsvc->nsei);
|
|
|
|
return bssgp_tx_status(BSSGP_CAUSE_BVCI_BLOCKED, NULL, msg);
|
|
|
|
}
|
|
|
|
rc = gbprox_relay2peer(msg, peer, ns_bvci);
|
2010-04-30 18:26:32 +00:00
|
|
|
}
|
|
|
|
|
2010-05-03 16:54:58 +00:00
|
|
|
return rc;
|
2010-04-30 18:26:32 +00:00
|
|
|
}
|
2010-05-11 03:49:43 +00:00
|
|
|
|
2010-05-14 11:53:08 +00:00
|
|
|
int gbprox_reset_persistent_nsvcs(struct gprs_ns_inst *nsi)
|
|
|
|
{
|
|
|
|
struct gprs_nsvc *nsvc;
|
|
|
|
|
|
|
|
llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
|
|
|
|
if (!nsvc->persistent)
|
|
|
|
continue;
|
|
|
|
gprs_nsvc_reset(nsvc, NS_CAUSE_OM_INTERVENTION);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-11 04:34:24 +00:00
|
|
|
/* Signal handler for signals from NS layer */
|
|
|
|
int gbprox_signal(unsigned int subsys, unsigned int signal,
|
|
|
|
void *handler_data, void *signal_data)
|
|
|
|
{
|
|
|
|
struct ns_signal_data *nssd = signal_data;
|
|
|
|
struct gprs_nsvc *nsvc = nssd->nsvc;
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
|
2012-06-16 08:40:42 +00:00
|
|
|
if (subsys != SS_L_NS)
|
2010-05-11 04:34:24 +00:00
|
|
|
return 0;
|
|
|
|
|
2010-05-11 16:29:44 +00:00
|
|
|
if (signal == S_NS_RESET && nsvc->nsei == gbcfg.nsip_sgsn_nsei) {
|
|
|
|
/* We have received a NS-RESET from the NSEI and NSVC
|
|
|
|
* of the SGSN. This might happen with SGSN that start
|
|
|
|
* their own NS-RESET procedure without waiting for our
|
|
|
|
* NS-RESET */
|
|
|
|
nsvc->remote_end_is_sgsn = 1;
|
|
|
|
}
|
|
|
|
|
2010-05-12 13:28:25 +00:00
|
|
|
if (signal == S_NS_ALIVE_EXP && nsvc->remote_end_is_sgsn) {
|
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "Tns alive expired too often, "
|
|
|
|
"re-starting RESET procedure\n");
|
2012-06-17 04:25:53 +00:00
|
|
|
gprs_ns_nsip_connect(nsvc->nsi, &nsvc->ip.bts_addr,
|
|
|
|
nsvc->nsei, nsvc->nsvci);
|
2010-05-12 13:28:25 +00:00
|
|
|
}
|
|
|
|
|
2011-02-06 15:33:29 +00:00
|
|
|
if (!nsvc->remote_end_is_sgsn) {
|
|
|
|
/* from BSS to SGSN */
|
|
|
|
peer = peer_by_nsvc(nsvc);
|
|
|
|
if (!peer) {
|
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "signal %u for unknown peer "
|
|
|
|
"NSEI=%u/NSVCI=%u\n", signal, nsvc->nsei,
|
|
|
|
nsvc->nsvci);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-05-11 04:34:24 +00:00
|
|
|
switch (signal) {
|
|
|
|
case S_NS_RESET:
|
|
|
|
case S_NS_BLOCK:
|
2011-02-06 15:33:29 +00:00
|
|
|
if (!peer->blocked)
|
|
|
|
break;
|
|
|
|
LOGP(DGPRS, LOGL_NOTICE, "Converting NS_RESET from "
|
|
|
|
"NSEI=%u/NSVCI=%u into BSSGP_BVC_BLOCK to SGSN\n",
|
|
|
|
nsvc->nsei, nsvc->nsvci);
|
|
|
|
bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_BLOCK, nsvc->nsei,
|
|
|
|
peer->bvci, 0);
|
2010-05-11 04:34:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-02-06 15:33:29 +00:00
|
|
|
} else {
|
|
|
|
/* iterate over all BTS peers and send the respective PDU */
|
|
|
|
llist_for_each_entry(peer, &gbprox_bts_peers, list) {
|
|
|
|
switch (signal) {
|
|
|
|
case S_NS_RESET:
|
|
|
|
gprs_ns_tx_reset(peer->nsvc, nssd->cause);
|
|
|
|
break;
|
|
|
|
case S_NS_BLOCK:
|
|
|
|
gprs_ns_tx_block(peer->nsvc, nssd->cause);
|
|
|
|
break;
|
|
|
|
case S_NS_UNBLOCK:
|
|
|
|
gprs_ns_tx_unblock(peer->nsvc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-05-11 04:34:24 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-11 03:49:43 +00:00
|
|
|
|
2010-05-19 17:45:32 +00:00
|
|
|
#include <osmocom/vty/command.h>
|
2010-05-11 03:49:43 +00:00
|
|
|
|
|
|
|
gDEFUN(show_gbproxy, show_gbproxy_cmd, "show gbproxy",
|
|
|
|
SHOW_STR "Display information about the Gb proxy")
|
|
|
|
{
|
|
|
|
struct gbprox_peer *peer;
|
|
|
|
|
|
|
|
llist_for_each_entry(peer, &gbprox_bts_peers, list) {
|
|
|
|
struct gprs_nsvc *nsvc = peer->nsvc;
|
|
|
|
struct gprs_ra_id raid;
|
2010-05-11 08:15:42 +00:00
|
|
|
gsm48_parse_ra(&raid, peer->ra);
|
2010-05-11 03:49:43 +00:00
|
|
|
|
2010-05-19 15:42:20 +00:00
|
|
|
vty_out(vty, "NSEI %5u, NS-VC %5u, PTP-BVCI %5u, "
|
2010-05-19 15:06:16 +00:00
|
|
|
"RAC %u-%u-%u-%u",
|
2010-05-11 03:49:43 +00:00
|
|
|
nsvc->nsei, nsvc->nsvci, peer->bvci,
|
2010-05-19 15:06:16 +00:00
|
|
|
raid.mcc, raid.mnc, raid.lac, raid.rac);
|
|
|
|
if (nsvc->ll == GPRS_NS_LL_UDP || nsvc->ll == GPRS_NS_LL_FR_GRE)
|
2011-02-06 16:44:14 +00:00
|
|
|
vty_out(vty, " %s:%u",
|
2010-05-11 03:49:43 +00:00
|
|
|
inet_ntoa(nsvc->ip.bts_addr.sin_addr),
|
2011-02-06 16:44:14 +00:00
|
|
|
ntohs(nsvc->ip.bts_addr.sin_port));
|
|
|
|
if (peer->blocked)
|
|
|
|
vty_out(vty, " [BVC-BLOCKED]");
|
|
|
|
|
|
|
|
vty_out(vty, "%s", VTY_NEWLINE);
|
2010-05-11 03:49:43 +00:00
|
|
|
}
|
|
|
|
return CMD_SUCCESS;
|
|
|
|
}
|