ns2: move link layer type into NSE
Even it was in theory possible to mix NS-VC ll types within
a NSE. This is an unrealistic configuration.
Further more to select the correct load sharing mechanism
the NSE must know the correct link layer.
Change-Id: I18dfd40a2429cd61b7c4a3dad5f226c64296f7d8
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 96ad767..5e43364 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -226,7 +226,7 @@
if (!buf_len)
return NULL;
- switch (nsvc->ll) {
+ switch (nsvc->nse->ll) {
case GPRS_NS2_LL_UDP:
if (!gprs_ns2_is_ip_bind(nsvc->bind)) {
buf[0] = '\0';
@@ -397,15 +397,11 @@
/* signalling */
nsvc = ns2_load_sharing_signal(nse);
} else {
- enum gprs_ns2_ll ll;
-
/* data with load sharing parameter */
if (llist_empty(&nse->nsvc))
return NULL;
- nsvc = llist_first_entry(&nse->nsvc, struct gprs_ns2_vc, list);
- ll = nsvc->ll;
- switch (ll) {
+ switch (nse->ll) {
case GPRS_NS2_LL_FR:
nsvc = ns2_load_sharing_modulor(nse, bvci, link_selector);
break;
@@ -676,7 +672,7 @@
* \param[in] nsi NS instance in which to create NS Entity
* \param[in] nsei NS Entity Identifier of to-be-created NSE
* \returns newly-allocated NS-E in successful case; NULL on error */
-struct gprs_ns2_nse *gprs_ns2_create_nse(struct gprs_ns2_inst *nsi, uint16_t nsei)
+struct gprs_ns2_nse *gprs_ns2_create_nse(struct gprs_ns2_inst *nsi, uint16_t nsei, enum gprs_ns2_ll linklayer)
{
struct gprs_ns2_nse *nse;
@@ -690,6 +686,7 @@
if (!nse)
return NULL;
+ nse->ll = linklayer;
nse->nsei = nsei;
nse->nsi = nsi;
nse->first = true;
@@ -845,7 +842,7 @@
return GPRS_NS2_CS_SKIPPED;
}
- nse = gprs_ns2_create_nse(bind->nsi, nsei);
+ nse = gprs_ns2_create_nse(bind->nsi, nsei, bind->ll);
if (!nse) {
return GPRS_NS2_CS_ERROR;
}
@@ -855,8 +852,6 @@
if (!nsvc)
return GPRS_NS2_CS_SKIPPED;
- nsvc->ll = GPRS_NS2_LL_UDP;
-
nsvci = tlvp_val16be(&tp, NS_IE_VCI);
nsvc->nsvci = nsvci;
nsvc->nsvci_is_valid = true;
@@ -926,7 +921,7 @@
struct gprs_ns2_nse *nse = gprs_ns2_nse_by_nsei(bind->nsi, nsei);
if (!nse) {
- nse = gprs_ns2_create_nse(bind->nsi, nsei);
+ nse = gprs_ns2_create_nse(bind->nsi, nsei, GPRS_NS2_LL_UDP);
if (!nse)
return NULL;
}
@@ -947,7 +942,7 @@
struct gprs_ns2_vc *nsvc;
if (!nse) {
- nse = gprs_ns2_create_nse(bind->nsi, nsei);
+ nse = gprs_ns2_create_nse(bind->nsi, nsei, GPRS_NS2_LL_UDP);
if (!nse)
return -1;
}