summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-06-17 12:25:53 +0800
committerHarald Welte <laforge@gnumonks.org>2012-06-17 12:38:07 +0800
commitf543036719ccbb2431563d6af968502f9097db98 (patch)
treed461318f5a8eddf9283b9098e44e7606b0d20adf
parent15a36434e9d51e57514b2b9357a41293b063e970 (diff)
libgb: prefix all NS related functions with gprs_
-rw-r--r--openbsc/include/osmocom/gprs/gprs_ns.h19
-rw-r--r--openbsc/src/libgb/common_vty.c24
-rw-r--r--openbsc/src/libgb/common_vty.h6
-rw-r--r--openbsc/src/libgb/gprs_bssgp_vty.c12
-rw-r--r--openbsc/src/libgb/gprs_ns.c20
-rw-r--r--openbsc/src/libgb/gprs_ns_vty.c38
-rw-r--r--openbsc/src/libgb/libosmo-gb.map6
7 files changed, 92 insertions, 33 deletions
diff --git a/openbsc/include/osmocom/gprs/gprs_ns.h b/openbsc/include/osmocom/gprs/gprs_ns.h
index a77515d2..206873b6 100644
--- a/openbsc/include/osmocom/gprs/gprs_ns.h
+++ b/openbsc/include/osmocom/gprs/gprs_ns.h
@@ -211,6 +211,12 @@ void gprs_ns_destroy(struct gprs_ns_inst *nsi);
/* Listen for incoming GPRS packets via NS/UDP */
int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi);
+/* Establish a connection (from the BSS) to the SGSN */
+struct gprs_nsvc *gprs_ns_nsip_connect(struct gprs_ns_inst *nsi,
+ struct sockaddr_in *dest,
+ uint16_t nsei, uint16_t nsvci);
+
+
struct sockaddr_in;
/* main function for higher layers (BSSGP) to send NS messages */
@@ -223,15 +229,10 @@ int gprs_ns_tx_unblock(struct gprs_nsvc *nsvc);
/* Listen for incoming GPRS packets via NS/FR/GRE */
int gprs_ns_frgre_listen(struct gprs_ns_inst *nsi);
-/* Establish a connection (from the BSS) to the SGSN */
-struct gprs_nsvc *nsip_connect(struct gprs_ns_inst *nsi,
- struct sockaddr_in *dest, uint16_t nsei,
- uint16_t nsvci);
-
-struct gprs_nsvc *nsvc_create(struct gprs_ns_inst *nsi, uint16_t nsvci);
-void nsvc_delete(struct gprs_nsvc *nsvc);
-struct gprs_nsvc *nsvc_by_nsei(struct gprs_ns_inst *nsi, uint16_t nsei);
-struct gprs_nsvc *nsvc_by_nsvci(struct gprs_ns_inst *nsi, uint16_t nsvci);
+struct gprs_nsvc *gprs_nsvc_create(struct gprs_ns_inst *nsi, uint16_t nsvci);
+void gprs_nsvc_delete(struct gprs_nsvc *nsvc);
+struct gprs_nsvc *gprs_nsvc_by_nsei(struct gprs_ns_inst *nsi, uint16_t nsei);
+struct gprs_nsvc *gprs_nsvc_by_nsvci(struct gprs_ns_inst *nsi, uint16_t nsvci);
/* Initiate a RESET procedure (including timer start, ...)*/
void gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause);
diff --git a/openbsc/src/libgb/common_vty.c b/openbsc/src/libgb/common_vty.c
index a16e9957..408dddf7 100644
--- a/openbsc/src/libgb/common_vty.c
+++ b/openbsc/src/libgb/common_vty.c
@@ -28,6 +28,10 @@
#include <osmocom/vty/buffer.h>
#include <osmocom/vty/vty.h>
+#include <osmocom/gprs/gprs_msgb.h>
+
+#include "common_vty.h"
+
/* Down vty node level. */
gDEFUN(libgb_exit,
libgb_exit_cmd, "exit", "Exit current mode and down to previous mode\n")
@@ -62,4 +66,24 @@ gDEFUN(libgb_end,
return CMD_SUCCESS;
}
+int gprs_log_filter_fn(const struct log_context *ctx,
+ struct log_target *tar)
+{
+ const struct gprs_nsvc *nsvc = ctx->ctx[GPRS_CTX_NSVC];
+ const struct gprs_nsvc *bvc = ctx->ctx[GPRS_CTX_BVC];
+
+ /* Filter on the NS Virtual Connection */
+ if ((tar->filter_map & (1 << FLT_NSVC)) != 0
+ && nsvc && (nsvc == tar->filter_data[FLT_NSVC]))
+ return 1;
+
+ /* Filter on the NS Virtual Connection */
+ if ((tar->filter_map & (1 << FLT_BVC)) != 0
+ && bvc && (bvc == tar->filter_data[FLT_BVC]))
+ return 1;
+
+ return 0;
+}
+
+
int DNS, DBSSGP;
diff --git a/openbsc/src/libgb/common_vty.h b/openbsc/src/libgb/common_vty.h
index 8c6b9ab1..d8d00407 100644
--- a/openbsc/src/libgb/common_vty.h
+++ b/openbsc/src/libgb/common_vty.h
@@ -3,6 +3,12 @@
extern int DNS, DBSSGP;
+enum log_filter {
+ _FLT_ALL = LOG_FILTER_ALL, /* libosmocore */
+ FLT_NSVC = 1,
+ FLT_BVC = 2,
+};
+
extern struct cmd_element libgb_exit_cmd;
extern struct cmd_element libgb_end_cmd;
diff --git a/openbsc/src/libgb/gprs_bssgp_vty.c b/openbsc/src/libgb/gprs_bssgp_vty.c
index ff1b8f5c..49a90c37 100644
--- a/openbsc/src/libgb/gprs_bssgp_vty.c
+++ b/openbsc/src/libgb/gprs_bssgp_vty.c
@@ -48,6 +48,18 @@ static const struct value_string gprs_bssgp_timer_strs[] = {
{ 0, NULL }
};
+static void log_set_bvc_filter(struct log_target *target,
+ struct bssgp_bvc_ctx *bctx)
+{
+ if (bctx) {
+ target->filter_map |= (1 << FLT_BVC);
+ target->filter_data[FLT_BVC] = bctx;
+ } else if (target->filter_data[FLT_NSVC]) {
+ target->filter_map = ~(1 << FLT_BVC);
+ target->filter_data[FLT_BVC] = NULL;
+ }
+}
+
static struct cmd_node bssgp_node = {
L_BSSGP_NODE,
"%s(bssgp)#",
diff --git a/openbsc/src/libgb/gprs_ns.c b/openbsc/src/libgb/gprs_ns.c
index 04a7f106..cdee8338 100644
--- a/openbsc/src/libgb/gprs_ns.c
+++ b/openbsc/src/libgb/gprs_ns.c
@@ -121,7 +121,7 @@ static const struct rate_ctr_group_desc nsvc_ctrg_desc = {
* \param[in] nsvci NSVCI to be searched
* \returns gprs_nsvc of respective NSVCI
*/
-struct gprs_nsvc *nsvc_by_nsvci(struct gprs_ns_inst *nsi, uint16_t nsvci)
+struct gprs_nsvc *gprs_nsvc_by_nsvci(struct gprs_ns_inst *nsi, uint16_t nsvci)
{
struct gprs_nsvc *nsvc;
llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
@@ -136,7 +136,7 @@ struct gprs_nsvc *nsvc_by_nsvci(struct gprs_ns_inst *nsi, uint16_t nsvci)
* \param[in] nsei NSEI to be searched
* \returns gprs_nsvc of respective NSEI
*/
-struct gprs_nsvc *nsvc_by_nsei(struct gprs_ns_inst *nsi, uint16_t nsei)
+struct gprs_nsvc *gprs_nsvc_by_nsei(struct gprs_ns_inst *nsi, uint16_t nsei)
{
struct gprs_nsvc *nsvc;
llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
@@ -162,7 +162,7 @@ static struct gprs_nsvc *nsvc_by_rem_addr(struct gprs_ns_inst *nsi,
static void gprs_ns_timer_cb(void *data);
-struct gprs_nsvc *nsvc_create(struct gprs_ns_inst *nsi, uint16_t nsvci)
+struct gprs_nsvc *gprs_nsvc_create(struct gprs_ns_inst *nsi, uint16_t nsvci)
{
struct gprs_nsvc *nsvc;
@@ -185,7 +185,7 @@ struct gprs_nsvc *nsvc_create(struct gprs_ns_inst *nsi, uint16_t nsvci)
/*! \brief Delete given NS-VC
* \param[in] nsvc gprs_nsvc to be deleted
*/
-void nsvc_delete(struct gprs_nsvc *nsvc)
+void gprs_nsvc_delete(struct gprs_nsvc *nsvc)
{
if (osmo_timer_pending(&nsvc->timer))
osmo_timer_del(&nsvc->timer);
@@ -557,7 +557,7 @@ int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg)
struct gprs_ns_hdr *nsh;
uint16_t bvci = msgb_bvci(msg);
- nsvc = nsvc_by_nsei(nsi, msgb_nsei(msg));
+ nsvc = gprs_nsvc_by_nsei(nsi, msgb_nsei(msg));
if (!nsvc) {
LOGP(DNS, LOGL_ERROR, "Unable to resolve NSEI %u "
"to NS-VC!\n", msgb_nsei(msg));
@@ -795,9 +795,9 @@ int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg,
nsei = ntohs(*(uint16_t *)TLVP_VAL(&tp, NS_IE_NSEI));
/* Check if we already know this NSEI, the remote end might
* simply have changed addresses, or it is a SGSN */
- nsvc = nsvc_by_nsei(nsi, nsei);
+ nsvc = gprs_nsvc_by_nsei(nsi, nsei);
if (!nsvc) {
- nsvc = nsvc_create(nsi, 0xffff);
+ nsvc = gprs_nsvc_create(nsi, 0xffff);
nsvc->ll = ll;
log_set_context(GPRS_CTX_NSVC, nsvc);
LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s:%u\n",
@@ -909,7 +909,7 @@ struct gprs_ns_inst *gprs_ns_instantiate(gprs_ns_cb_t *cb, void *ctx)
/* Create the dummy NSVC that we use for sending
* messages to non-existant/unknown NS-VC's */
- nsi->unknown_nsvc = nsvc_create(nsi, 0xfffe);
+ nsi->unknown_nsvc = gprs_nsvc_create(nsi, 0xfffe);
llist_del(&nsi->unknown_nsvc->list);
return nsi;
@@ -1077,7 +1077,7 @@ void gprs_nsvc_reset(struct gprs_nsvc *nsvc, uint8_t cause)
* This function will establish a single NS/UDP/IP connection in uplink
* (BSS to SGSN) direction.
*/
-struct gprs_nsvc *nsip_connect(struct gprs_ns_inst *nsi,
+struct gprs_nsvc *gprs_ns_nsip_connect(struct gprs_ns_inst *nsi,
struct sockaddr_in *dest, uint16_t nsei,
uint16_t nsvci)
{
@@ -1085,7 +1085,7 @@ struct gprs_nsvc *nsip_connect(struct gprs_ns_inst *nsi,
nsvc = nsvc_by_rem_addr(nsi, dest);
if (!nsvc)
- nsvc = nsvc_create(nsi, nsvci);
+ nsvc = gprs_nsvc_create(nsi, nsvci);
nsvc->ip.bts_addr = *dest;
nsvc->nsei = nsei;
nsvc->nsvci = nsvci;
diff --git a/openbsc/src/libgb/gprs_ns_vty.c b/openbsc/src/libgb/gprs_ns_vty.c
index 2f0b70ad..fac431cb 100644
--- a/openbsc/src/libgb/gprs_ns_vty.c
+++ b/openbsc/src/libgb/gprs_ns_vty.c
@@ -57,6 +57,18 @@ static const struct value_string gprs_ns_timer_strs[] = {
{ 0, NULL }
};
+static void log_set_nsvc_filter(struct log_target *target,
+ struct gprs_nsvc *nsvc)
+{
+ if (nsvc) {
+ target->filter_map |= (1 << FLT_NSVC);
+ target->filter_data[FLT_NSVC] = nsvc;
+ } else if (target->filter_data[FLT_NSVC]) {
+ target->filter_map = ~(1 << FLT_NSVC);
+ target->filter_data[FLT_NSVC] = NULL;
+ }
+}
+
static struct cmd_node ns_node = {
L_NS_NODE,
"%s(ns)#",
@@ -207,9 +219,9 @@ DEFUN(show_nse, show_nse_cmd, "show ns (nsei|nsvc) <0-65535> [stats]",
int show_stats = 0;
if (!strcmp(argv[0], "nsei"))
- nsvc = nsvc_by_nsei(nsi, id);
+ nsvc = gprs_nsvc_by_nsei(nsi, id);
else
- nsvc = nsvc_by_nsvci(nsi, id);
+ nsvc = gprs_nsvc_by_nsvci(nsi, id);
if (!nsvc) {
vty_out(vty, "No such NS Entity%s", VTY_NEWLINE);
@@ -236,9 +248,9 @@ DEFUN(cfg_nse_nsvc, cfg_nse_nsvci_cmd,
uint16_t nsvci = atoi(argv[1]);
struct gprs_nsvc *nsvc;
- nsvc = nsvc_by_nsei(vty_nsi, nsei);
+ nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei);
if (!nsvc) {
- nsvc = nsvc_create(vty_nsi, nsvci);
+ nsvc = gprs_nsvc_create(vty_nsi, nsvci);
nsvc->nsei = nsei;
}
nsvc->nsvci = nsvci;
@@ -259,7 +271,7 @@ DEFUN(cfg_nse_remoteip, cfg_nse_remoteip_cmd,
uint16_t nsei = atoi(argv[0]);
struct gprs_nsvc *nsvc;
- nsvc = nsvc_by_nsei(vty_nsi, nsei);
+ nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei);
if (!nsvc) {
vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
return CMD_WARNING;
@@ -280,7 +292,7 @@ DEFUN(cfg_nse_remoteport, cfg_nse_remoteport_cmd,
uint16_t port = atoi(argv[1]);
struct gprs_nsvc *nsvc;
- nsvc = nsvc_by_nsei(vty_nsi, nsei);
+ nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei);
if (!nsvc) {
vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
return CMD_WARNING;
@@ -307,7 +319,7 @@ DEFUN(cfg_nse_fr_dlci, cfg_nse_fr_dlci_cmd,
uint16_t dlci = atoi(argv[1]);
struct gprs_nsvc *nsvc;
- nsvc = nsvc_by_nsei(vty_nsi, nsei);
+ nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei);
if (!nsvc) {
vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
return CMD_WARNING;
@@ -333,7 +345,7 @@ DEFUN(cfg_nse_encaps, cfg_nse_encaps_cmd,
uint16_t nsei = atoi(argv[0]);
struct gprs_nsvc *nsvc;
- nsvc = nsvc_by_nsei(vty_nsi, nsei);
+ nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei);
if (!nsvc) {
vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
return CMD_WARNING;
@@ -358,7 +370,7 @@ DEFUN(cfg_nse_remoterole, cfg_nse_remoterole_cmd,
uint16_t nsei = atoi(argv[0]);
struct gprs_nsvc *nsvc;
- nsvc = nsvc_by_nsei(vty_nsi, nsei);
+ nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei);
if (!nsvc) {
vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
return CMD_WARNING;
@@ -380,7 +392,7 @@ DEFUN(cfg_no_nse, cfg_no_nse_cmd,
uint16_t nsei = atoi(argv[0]);
struct gprs_nsvc *nsvc;
- nsvc = nsvc_by_nsei(vty_nsi, nsei);
+ nsvc = gprs_nsvc_by_nsei(vty_nsi, nsei);
if (!nsvc) {
vty_out(vty, "No such NSE (%u)%s", nsei, VTY_NEWLINE);
return CMD_WARNING;
@@ -486,7 +498,7 @@ DEFUN(nsvc_nsei, nsvc_nsei_cmd,
const char *operation = argv[1];
struct gprs_nsvc *nsvc;
- nsvc = nsvc_by_nsei(vty_nsi, nsvci);
+ nsvc = gprs_nsvc_by_nsei(vty_nsi, nsvci);
if (!nsvc) {
vty_out(vty, "No such NSVCI (%u)%s", nsvci, VTY_NEWLINE);
return CMD_WARNING;
@@ -521,9 +533,9 @@ DEFUN(logging_fltr_nsvc,
return CMD_WARNING;
if (!strcmp(argv[0], "nsei"))
- nsvc = nsvc_by_nsei(vty_nsi, id);
+ nsvc = gprs_nsvc_by_nsei(vty_nsi, id);
else
- nsvc = nsvc_by_nsvci(vty_nsi, id);
+ nsvc = gprs_nsvc_by_nsvci(vty_nsi, id);
if (!nsvc) {
vty_out(vty, "No NS-VC by that identifier%s", VTY_NEWLINE);
diff --git a/openbsc/src/libgb/libosmo-gb.map b/openbsc/src/libgb/libosmo-gb.map
index ab3c4eaf..60f85b26 100644
--- a/openbsc/src/libgb/libosmo-gb.map
+++ b/openbsc/src/libgb/libosmo-gb.map
@@ -37,6 +37,7 @@ gprs_ns_frgre_listen;
gprs_ns_frgre_sendmsg;
gprs_ns_instantiate;
gprs_ns_nsip_listen;
+gprs_ns_nsip_connect;
gprs_ns_rcvmsg;
gprs_ns_sendmsg;
gprs_ns_set_log_ss;
@@ -48,9 +49,12 @@ gprs_ns_tx_status;
gprs_ns_tx_unblock;
gprs_ns_vty_init;
+gprs_nsvc_create;
+gprs_nsvc_delete;
gprs_nsvc_reset;
+gprs_nsvc_by_nsvci;
+gprs_nsvc_by_nsei;
-nsip_connect;
local: *;
};