summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-10-14 22:06:47 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-15 09:48:41 +0200
commit96550e03214697be2d1b303a690ef10ea3bb12b7 (patch)
tree51c3ec209620c8e185aea2739dc800aefda3b01d /src
parent6901715124d53574dc607d540105128573808b24 (diff)
gb: Add functions to access the LL part of the NS-VC objects
Adds the functions gprs_ns_ll_copy() and gprs_ns_ll_clear(). Renames gprs_ns_format_peer() to gprs_ns_ll_str(). All of these functions uniformly access the link layer part within the NS-VC objects. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src')
-rw-r--r--src/gb/gprs_ns.c42
-rw-r--r--src/gb/libosmogb.map4
2 files changed, 40 insertions, 6 deletions
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 7801b297..61a96d74 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -802,7 +802,7 @@ int gprs_ns_rcvmsg(struct gprs_ns_inst *nsi, struct msgb *msg,
return rc;
}
-const char *gprs_ns_format_peer(struct gprs_nsvc *nsvc)
+const char *gprs_ns_ll_str(struct gprs_nsvc *nsvc)
{
static char buf[80];
snprintf(buf, sizeof(buf), "%s:%u",
@@ -812,6 +812,38 @@ const char *gprs_ns_format_peer(struct gprs_nsvc *nsvc)
return buf;
}
+void gprs_ns_ll_copy(struct gprs_nsvc *nsvc, struct gprs_nsvc *other)
+{
+ nsvc->ll = other->ll;
+
+ switch (nsvc->ll) {
+ case GPRS_NS_LL_UDP:
+ nsvc->ip = other->ip;
+ break;
+ case GPRS_NS_LL_FR_GRE:
+ nsvc->frgre = other->frgre;
+ break;
+ default:
+ break;
+ }
+}
+
+void gprs_ns_ll_clear(struct gprs_nsvc *nsvc)
+{
+ switch (nsvc->ll) {
+ case GPRS_NS_LL_UDP:
+ nsvc->ip.bts_addr.sin_addr.s_addr = INADDR_ANY;
+ nsvc->ip.bts_addr.sin_port = 0;
+ break;
+ case GPRS_NS_LL_FR_GRE:
+ nsvc->frgre.bts_addr.sin_addr.s_addr = INADDR_ANY;
+ nsvc->frgre.bts_addr.sin_port = 0;
+ break;
+ default:
+ break;
+ }
+}
+
/*! \brief Create/get NS-VC independently from underlying transport layer
* \param nsi NS instance to which the data belongs
* \param[in] msg message buffer containing newly-received data
@@ -841,7 +873,7 @@ int gprs_ns_vc_create(struct gprs_ns_inst *nsi, struct msgb *msg,
if (nsh->pdu_type == NS_PDUT_STATUS) {
LOGP(DNS, LOGL_INFO, "Ignoring NS STATUS from %s "
"for non-existing NS-VC\n",
- gprs_ns_format_peer(fallback_nsvc));
+ gprs_ns_ll_str(fallback_nsvc));
return GPRS_NS_CS_SKIPPED;
}
@@ -851,7 +883,7 @@ int gprs_ns_vc_create(struct gprs_ns_inst *nsi, struct msgb *msg,
log_set_context(GPRS_CTX_NSVC, fallback_nsvc);
LOGP(DNS, LOGL_INFO, "Rejecting NS PDU type 0x%0x "
"from %s for non-existing NS-VC\n",
- nsh->pdu_type, gprs_ns_format_peer(fallback_nsvc));
+ nsh->pdu_type, gprs_ns_ll_str(fallback_nsvc));
fallback_nsvc->nsvci = fallback_nsvc->nsei = 0xfffe;
fallback_nsvc->state = NSE_S_ALIVE;
@@ -859,7 +891,7 @@ int gprs_ns_vc_create(struct gprs_ns_inst *nsi, struct msgb *msg,
NS_CAUSE_PDU_INCOMP_PSTATE, 0, msg);
if (rc < 0) {
LOGP(DNS, LOGL_ERROR, "TX failed (%d) to peer %s\n",
- rc, gprs_ns_format_peer(fallback_nsvc));
+ rc, gprs_ns_ll_str(fallback_nsvc));
return rc;
}
return GPRS_NS_CS_REJECTED;
@@ -887,7 +919,7 @@ int gprs_ns_vc_create(struct gprs_ns_inst *nsi, struct msgb *msg,
*new_nsvc = gprs_nsvc_create(nsi, 0xffff);
log_set_context(GPRS_CTX_NSVC, *new_nsvc);
LOGP(DNS, LOGL_INFO, "Creating NS-VC for BSS at %s\n",
- gprs_ns_format_peer(fallback_nsvc));
+ gprs_ns_ll_str(fallback_nsvc));
return GPRS_NS_CS_CREATED;
}
diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map
index 0270db81..a21a7ac6 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -54,7 +54,9 @@ gprs_ns_tx_reset;
gprs_ns_tx_status;
gprs_ns_tx_unblock;
gprs_ns_vty_init;
-gprs_ns_format_peer;
+gprs_ns_ll_str;
+gprs_ns_ll_copy;
+gprs_ns_ll_clear;
gprs_nsvc_create;
gprs_nsvc_delete;