[PATCH] osmo-pcu[master]: README: Clarify that fixed allocations have been revmoved fr...

2017-07-29 Thread Harald Welte

Review at  https://gerrit.osmocom.org/3389

README: Clarify that fixed allocations have been revmoved from 3GPP specs

In Release 5, Fixed Allocations were removed as part of a "GPRS
simplification project" inside 3PGPP.  This means that any MS compatible
with Rel-5 or higher may not support it, which makes implementation
in the PCU af historical interest only.  See Tdoc GP-021277 for the
actual removal, it happened at 5.0.0 time.

Change-Id: I8138bc0a47d3468b67cec866447fd4b0fc69d4c5
---
M README.md
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/89/3389/1

diff --git a/README.md b/README.md
index ed5ab17..65cf475 100644
--- a/README.md
+++ b/README.md
@@ -75,7 +75,7 @@
 ---
 
  * No PFC support
- * No fixed allocation support
+ * No fixed allocation support (was removed from 3GPP Rel >= 5 anyway)
  * No extended dynamic allocation support
  * No unacknowledged mode operation
  * Only single slot assignment on uplink direction

-- 
To view, visit https://gerrit.osmocom.org/3389
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8138bc0a47d3468b67cec866447fd4b0fc69d4c5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[MERGED] osmo-pcu[master]: GSMTAP: Fix channel type for data blocks: PDTCH instead of P...

2017-07-29 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: GSMTAP: Fix channel type for data blocks: PDTCH instead of PACCH
..


GSMTAP: Fix channel type for data blocks: PDTCH instead of PACCH

PACCH is used only for RLC/MAC control messages, while PDTCH is used
for data.

Change-Id: I6c912e17d8c8d4178096679a541e61eeeb4b6643
---
M src/bts.cpp
M src/gprs_rlcmac_sched.cpp
2 files changed, 3 insertions(+), 3 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/bts.cpp b/src/bts.cpp
index 5d1a500..2bafd63 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1598,9 +1598,9 @@
cs.name());
return -EINVAL;
}
-   bts()->send_gsmtap(PCU_GSMTAP_C_UL_DATA_EGPRS, true, trx_no(), 
ts_no, GSMTAP_CHANNEL_PACCH, fn, data, data_len);
+   bts()->send_gsmtap(PCU_GSMTAP_C_UL_DATA_EGPRS, true, trx_no(), 
ts_no, GSMTAP_CHANNEL_PDTCH, fn, data, data_len);
} else {
-   bts()->send_gsmtap(PCU_GSMTAP_C_UL_DATA_GPRS, true, trx_no(), 
ts_no, GSMTAP_CHANNEL_PACCH, fn, data, data_len);
+   bts()->send_gsmtap(PCU_GSMTAP_C_UL_DATA_GPRS, true, trx_no(), 
ts_no, GSMTAP_CHANNEL_PDTCH, fn, data, data_len);
}
 
LOGP(DRLCMACUL, LOGL_DEBUG, "  UL data: %s\n", osmo_hexdump(data, len));
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index e5c8ec8..42f0308 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -367,7 +367,7 @@
if (msg) {
bts->bts->rlc_sent();
/* FIXME: distinguish between GPRS and EGPRS */
-   bts->bts->send_gsmtap(PCU_GSMTAP_C_DL_DATA_GPRS, false, 
trx, ts, GSMTAP_CHANNEL_PACCH, fn, msg->data, msg->len);
+   bts->bts->send_gsmtap(PCU_GSMTAP_C_DL_DATA_GPRS, false, 
trx, ts, GSMTAP_CHANNEL_PDTCH, fn, msg->data, msg->len);
}
}
 

-- 
To view, visit https://gerrit.osmocom.org/3386
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6c912e17d8c8d4178096679a541e61eeeb4b6643
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-pcu[master]: GSMTAP: Ad PTCCH as separate gsmtap category

2017-07-29 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: GSMTAP: Ad PTCCH as separate gsmtap category
..


GSMTAP: Ad PTCCH as separate gsmtap category

This allows us to send GSMTAP for PTCCH only if requested by user/vty

Change-Id: Id720f4bebdce7f6152fbbe05036638c5866e
---
M src/bts.h
M src/pcu_l1_if.cpp
M src/pcu_vty.c
3 files changed, 5 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/bts.h b/src/bts.h
index 66875f1..25193f9 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -51,6 +51,7 @@
PCU_GSMTAP_C_DL_CTRL= 2,/* downlink control blocks */
PCU_GSMTAP_C_DL_DATA_GPRS   = 3,/* downlink GPRS data blocks */
PCU_GSMTAP_C_DL_DATA_EGPRS  = 4,/* downlink EGPRS data blocks */
+   PCU_GSMTAP_C_DL_PTCCH   = 5,/* downlink PTCCH blocks */
 
PCU_GSMTAP_C_UL_UNKNOWN = 15,   /* unknown or undecodable 
uplink blocks */
PCU_GSMTAP_C_UL_DUMMY   = 16,   /* uplink dummy blocks */
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 42164e4..8ea2ad5 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -183,7 +183,8 @@
 {
struct gprs_rlcmac_bts *bts = bts_main_data();
 
-   gsmtap_send(bts->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PTCCH, 0, fn, 0, 0, 
msg->data, msg->len);
+   if (bts->gsmtap_categ_mask & PCU_GSMTAP_C_DL_PTCCH)
+   gsmtap_send(bts->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PTCCH, 0, 
fn, 0, 0, msg->data, msg->len);
 #ifdef ENABLE_DIRECT_PHY
if (bts->trx[trx].fl1h) {
l1if_pdch_req(bts->trx[trx].fl1h, ts, 1, fn, arfcn, block_nr,
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index fc57a5f..cd22e38 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -24,6 +24,7 @@
{ PCU_GSMTAP_C_DL_CTRL, "dl-ctrl" },
{ PCU_GSMTAP_C_DL_DATA_GPRS,"dl-data-gprs" },
{ PCU_GSMTAP_C_DL_DATA_EGPRS,   "dl-data-egprs" },
+   { PCU_GSMTAP_C_DL_PTCCH,"dl-ptcch" },
 
{ PCU_GSMTAP_C_UL_UNKNOWN,  "ul-unknown" },
{ PCU_GSMTAP_C_UL_DUMMY,"ul-dummy" },
@@ -40,6 +41,7 @@
{ PCU_GSMTAP_C_DL_CTRL, "Downlink Control Blocks" },
{ PCU_GSMTAP_C_DL_DATA_GPRS,"Downlink Data Blocks (GPRS)" },
{ PCU_GSMTAP_C_DL_DATA_EGPRS,   "Downlink Data Blocks (EGPRS)" },
+   { PCU_GSMTAP_C_DL_PTCCH,"Downlink PTCCH Blocks" },
 
{ PCU_GSMTAP_C_UL_UNKNOWN,  "Unknown / Unparseable / Erroneous 
Downlink Blocks" },
{ PCU_GSMTAP_C_UL_DUMMY,"Uplink Dummy Blocks" },

-- 
To view, visit https://gerrit.osmocom.org/3388
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id720f4bebdce7f6152fbbe05036638c5866e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-pcu[master]: GSMTAP: Fix logical channel of downlink PTCCH

2017-07-29 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: GSMTAP: Fix logical channel of downlink PTCCH
..


GSMTAP: Fix logical channel of downlink PTCCH

Change-Id: I29ecc968d56d4d0165cffa206297c42d6fb02cf4
---
M src/pcu_l1_if.cpp
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 420bca0..42164e4 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -183,7 +183,7 @@
 {
struct gprs_rlcmac_bts *bts = bts_main_data();
 
-   gsmtap_send(bts->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PACCH, 0, fn, 0, 0, 
msg->data, msg->len);
+   gsmtap_send(bts->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PTCCH, 0, fn, 0, 0, 
msg->data, msg->len);
 #ifdef ENABLE_DIRECT_PHY
if (bts->trx[trx].fl1h) {
l1if_pdch_req(bts->trx[trx].fl1h, ts, 1, fn, arfcn, block_nr,

-- 
To view, visit https://gerrit.osmocom.org/3387
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I29ecc968d56d4d0165cffa206297c42d6fb02cf4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


osmo-pcu[master]: GSMTAP: Ad PTCCH as separate gsmtap category

2017-07-29 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/3388
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id720f4bebdce7f6152fbbe05036638c5866e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-HasComments: No


osmo-pcu[master]: GSMTAP: Fix logical channel of downlink PTCCH

2017-07-29 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/3387
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I29ecc968d56d4d0165cffa206297c42d6fb02cf4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-HasComments: No


osmo-pcu[master]: GSMTAP: Fix channel type for data blocks: PDTCH instead of P...

2017-07-29 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/3386
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I6c912e17d8c8d4178096679a541e61eeeb4b6643
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-HasComments: No


[MERGED] libosmocore[master]: Rename GSMTAP_CHANNEL_PDCH to GSMTAP_CHANNEL_PDTCH

2017-07-29 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Rename GSMTAP_CHANNEL_PDCH to GSMTAP_CHANNEL_PDTCH
..


Rename GSMTAP_CHANNEL_PDCH to GSMTAP_CHANNEL_PDTCH

PDCH is the physical channel, while actually we want to talk about
PDTCH the logical channel.  Introduce backwards compatibility define.

Change-Id: Id6782d2247846e2db29fc58d98684970a66db948
---
M include/osmocom/core/gsmtap.h
1 file changed, 3 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/core/gsmtap.h b/include/osmocom/core/gsmtap.h
index 1e19315..c226185 100644
--- a/include/osmocom/core/gsmtap.h
+++ b/include/osmocom/core/gsmtap.h
@@ -85,7 +85,9 @@
 #define GSMTAP_CHANNEL_TCH_H   0x0a
 #define GSMTAP_CHANNEL_PACCH   0x0b
 #define GSMTAP_CHANNEL_CBCH52  0x0c
-#define GSMTAP_CHANNEL_PDCH0x0d
+#define GSMTAP_CHANNEL_PDTCH   0x0d
+/* for legacy reasons we use a mis-spelled name. PDCH is really the physical 
channel, but we use it as PDTCH */
+#define GSMTAP_CHANNEL_PDCHGSMTAP_CHANNEL_PDTCH
 #define GSMTAP_CHANNEL_PTCCH   0x0e
 #define GSMTAP_CHANNEL_CBCH51  0x0f
 

-- 
To view, visit https://gerrit.osmocom.org/3385
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id6782d2247846e2db29fc58d98684970a66db948
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[PATCH] osmo-pcu[master]: GSMTAP: Fix logical channel of downlink PTCCH

2017-07-29 Thread Harald Welte

Review at  https://gerrit.osmocom.org/3387

GSMTAP: Fix logical channel of downlink PTCCH

Change-Id: I29ecc968d56d4d0165cffa206297c42d6fb02cf4
---
M src/pcu_l1_if.cpp
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/87/3387/1

diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 420bca0..42164e4 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -183,7 +183,7 @@
 {
struct gprs_rlcmac_bts *bts = bts_main_data();
 
-   gsmtap_send(bts->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PACCH, 0, fn, 0, 0, 
msg->data, msg->len);
+   gsmtap_send(bts->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PTCCH, 0, fn, 0, 0, 
msg->data, msg->len);
 #ifdef ENABLE_DIRECT_PHY
if (bts->trx[trx].fl1h) {
l1if_pdch_req(bts->trx[trx].fl1h, ts, 1, fn, arfcn, block_nr,

-- 
To view, visit https://gerrit.osmocom.org/3387
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I29ecc968d56d4d0165cffa206297c42d6fb02cf4
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-pcu[master]: GSMTAP: Fix channel type for data blocks: PDTCH instead of P...

2017-07-29 Thread Harald Welte

Review at  https://gerrit.osmocom.org/3386

GSMTAP: Fix channel type for data blocks: PDTCH instead of PACCH

PACCH is used only for RLC/MAC control messages, while PDTCH is used
for data.

Change-Id: I6c912e17d8c8d4178096679a541e61eeeb4b6643
---
M src/bts.cpp
M src/gprs_rlcmac_sched.cpp
2 files changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/86/3386/1

diff --git a/src/bts.cpp b/src/bts.cpp
index 5d1a500..2bafd63 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1598,9 +1598,9 @@
cs.name());
return -EINVAL;
}
-   bts()->send_gsmtap(PCU_GSMTAP_C_UL_DATA_EGPRS, true, trx_no(), 
ts_no, GSMTAP_CHANNEL_PACCH, fn, data, data_len);
+   bts()->send_gsmtap(PCU_GSMTAP_C_UL_DATA_EGPRS, true, trx_no(), 
ts_no, GSMTAP_CHANNEL_PDTCH, fn, data, data_len);
} else {
-   bts()->send_gsmtap(PCU_GSMTAP_C_UL_DATA_GPRS, true, trx_no(), 
ts_no, GSMTAP_CHANNEL_PACCH, fn, data, data_len);
+   bts()->send_gsmtap(PCU_GSMTAP_C_UL_DATA_GPRS, true, trx_no(), 
ts_no, GSMTAP_CHANNEL_PDTCH, fn, data, data_len);
}
 
LOGP(DRLCMACUL, LOGL_DEBUG, "  UL data: %s\n", osmo_hexdump(data, len));
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index e5c8ec8..42f0308 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -367,7 +367,7 @@
if (msg) {
bts->bts->rlc_sent();
/* FIXME: distinguish between GPRS and EGPRS */
-   bts->bts->send_gsmtap(PCU_GSMTAP_C_DL_DATA_GPRS, false, 
trx, ts, GSMTAP_CHANNEL_PACCH, fn, msg->data, msg->len);
+   bts->bts->send_gsmtap(PCU_GSMTAP_C_DL_DATA_GPRS, false, 
trx, ts, GSMTAP_CHANNEL_PDTCH, fn, msg->data, msg->len);
}
}
 

-- 
To view, visit https://gerrit.osmocom.org/3386
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6c912e17d8c8d4178096679a541e61eeeb4b6643
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-pcu[master]: GSMTAP: Ad PTCCH as separate gsmtap category

2017-07-29 Thread Harald Welte

Review at  https://gerrit.osmocom.org/3388

GSMTAP: Ad PTCCH as separate gsmtap category

This allows us to send GSMTAP for PTCCH only if requested by user/vty

Change-Id: Id720f4bebdce7f6152fbbe05036638c5866e
---
M src/bts.h
M src/pcu_l1_if.cpp
M src/pcu_vty.c
3 files changed, 5 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/88/3388/1

diff --git a/src/bts.h b/src/bts.h
index 66875f1..25193f9 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -51,6 +51,7 @@
PCU_GSMTAP_C_DL_CTRL= 2,/* downlink control blocks */
PCU_GSMTAP_C_DL_DATA_GPRS   = 3,/* downlink GPRS data blocks */
PCU_GSMTAP_C_DL_DATA_EGPRS  = 4,/* downlink EGPRS data blocks */
+   PCU_GSMTAP_C_DL_PTCCH   = 5,/* downlink PTCCH blocks */
 
PCU_GSMTAP_C_UL_UNKNOWN = 15,   /* unknown or undecodable 
uplink blocks */
PCU_GSMTAP_C_UL_DUMMY   = 16,   /* uplink dummy blocks */
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 42164e4..8ea2ad5 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -183,7 +183,8 @@
 {
struct gprs_rlcmac_bts *bts = bts_main_data();
 
-   gsmtap_send(bts->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PTCCH, 0, fn, 0, 0, 
msg->data, msg->len);
+   if (bts->gsmtap_categ_mask & PCU_GSMTAP_C_DL_PTCCH)
+   gsmtap_send(bts->gsmtap, arfcn, ts, GSMTAP_CHANNEL_PTCCH, 0, 
fn, 0, 0, msg->data, msg->len);
 #ifdef ENABLE_DIRECT_PHY
if (bts->trx[trx].fl1h) {
l1if_pdch_req(bts->trx[trx].fl1h, ts, 1, fn, arfcn, block_nr,
diff --git a/src/pcu_vty.c b/src/pcu_vty.c
index fc57a5f..cd22e38 100644
--- a/src/pcu_vty.c
+++ b/src/pcu_vty.c
@@ -24,6 +24,7 @@
{ PCU_GSMTAP_C_DL_CTRL, "dl-ctrl" },
{ PCU_GSMTAP_C_DL_DATA_GPRS,"dl-data-gprs" },
{ PCU_GSMTAP_C_DL_DATA_EGPRS,   "dl-data-egprs" },
+   { PCU_GSMTAP_C_DL_PTCCH,"dl-ptcch" },
 
{ PCU_GSMTAP_C_UL_UNKNOWN,  "ul-unknown" },
{ PCU_GSMTAP_C_UL_DUMMY,"ul-dummy" },
@@ -40,6 +41,7 @@
{ PCU_GSMTAP_C_DL_CTRL, "Downlink Control Blocks" },
{ PCU_GSMTAP_C_DL_DATA_GPRS,"Downlink Data Blocks (GPRS)" },
{ PCU_GSMTAP_C_DL_DATA_EGPRS,   "Downlink Data Blocks (EGPRS)" },
+   { PCU_GSMTAP_C_DL_PTCCH,"Downlink PTCCH Blocks" },
 
{ PCU_GSMTAP_C_UL_UNKNOWN,  "Unknown / Unparseable / Erroneous 
Downlink Blocks" },
{ PCU_GSMTAP_C_UL_DUMMY,"Uplink Dummy Blocks" },

-- 
To view, visit https://gerrit.osmocom.org/3388
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id720f4bebdce7f6152fbbe05036638c5866e
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


libosmocore[master]: Rename GSMTAP_CHANNEL_PDCH to GSMTAP_CHANNEL_PDTCH

2017-07-29 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/3385
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Id6782d2247846e2db29fc58d98684970a66db948
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] libosmocore[master]: Rename GSMTAP_CHANNEL_PDCH to GSMTAP_CHANNEL_PDTCH

2017-07-29 Thread Harald Welte

Review at  https://gerrit.osmocom.org/3385

Rename GSMTAP_CHANNEL_PDCH to GSMTAP_CHANNEL_PDTCH

PDCH is the physical channel, while actually we want to talk about
PDTCH the logical channel.  Introduce backwards compatibility define.

Change-Id: Id6782d2247846e2db29fc58d98684970a66db948
---
M include/osmocom/core/gsmtap.h
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/3385/1

diff --git a/include/osmocom/core/gsmtap.h b/include/osmocom/core/gsmtap.h
index 1e19315..c226185 100644
--- a/include/osmocom/core/gsmtap.h
+++ b/include/osmocom/core/gsmtap.h
@@ -85,7 +85,9 @@
 #define GSMTAP_CHANNEL_TCH_H   0x0a
 #define GSMTAP_CHANNEL_PACCH   0x0b
 #define GSMTAP_CHANNEL_CBCH52  0x0c
-#define GSMTAP_CHANNEL_PDCH0x0d
+#define GSMTAP_CHANNEL_PDTCH   0x0d
+/* for legacy reasons we use a mis-spelled name. PDCH is really the physical 
channel, but we use it as PDTCH */
+#define GSMTAP_CHANNEL_PDCHGSMTAP_CHANNEL_PDTCH
 #define GSMTAP_CHANNEL_PTCCH   0x0e
 #define GSMTAP_CHANNEL_CBCH51  0x0f
 

-- 
To view, visit https://gerrit.osmocom.org/3385
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6782d2247846e2db29fc58d98684970a66db948
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


osmo-pcu[master]: Remove #warnings that have been adressed since 2015

2017-07-29 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/3382
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I7a1767bc7cab01048e851fd4e63112bc676d6c78
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[MERGED] osmo-pcu[master]: Remove #warnings that have been adressed since 2015

2017-07-29 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: Remove #warnings that have been adressed since 2015
..


Remove #warnings that have been adressed since 2015

In commit 939904672961fa7e28397e27f942a7d1fff4bbdf the lookup by
TLLI, TLLI-OLD and IMSI has been implemented, but the corresponding
compile-time warning was never removed.

Change-Id: I7a1767bc7cab01048e851fd4e63112bc676d6c78
---
M src/tbf_dl.cpp
1 file changed, 0 insertions(+), 2 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index a894789..505d488 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -126,8 +126,6 @@
GprsMs *ms;
 
/* check for uplink data, so we copy our informations */
-#warning "Do the same look up for IMSI, TLLI and OLD_TLLI"
-#warning "Refactor the below lines... into a new method"
ms = bts->bts->ms_store().get_ms(tlli, tlli_old, imsi);
if (ms) {
ul_tbf = ms->ul_tbf();

-- 
To view, visit https://gerrit.osmocom.org/3382
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7a1767bc7cab01048e851fd4e63112bc676d6c78
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder


[MERGED] osmo-pcu[master]: BSSGP: Improve logging of received messages

2017-07-29 Thread Harald Welte
Harald Welte has submitted this change and it was merged.

Change subject: BSSGP: Improve logging of received messages
..


BSSGP: Improve logging of received messages

We now differentiate clearly between messages that

a) we don't expect based on our reading of the spec
b) we have not implemented yet (but should)
c) we do not even know of

Also, unify the log string formats and provide BVCI whenever possible.

Change-Id: Ie32f5771d49960547ec5d7611f96a74facc1b035
---
M src/gprs_bssgp_pcu.cpp
1 file changed, 75 insertions(+), 41 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index 437479b..9c78ecf 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -208,6 +208,7 @@
 {
struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) 
msgb_bssgph(msg);
enum bssgp_pdu_type pdu_type = (enum bssgp_pdu_type) bgph->pdu_type;
+   int bvci = bctx ? bctx->bvci : -1;
unsigned rc = 0;
 
if (!bctx)
@@ -224,29 +225,51 @@
}
 
switch (pdu_type) {
+   case BSSGP_PDUT_STATUS:
+   /* already handled in libosmogb */
+   OSMO_ASSERT(0);
+   break;
case BSSGP_PDUT_DL_UNITDATA:
-   LOGP(DBSSGP, LOGL_DEBUG, "RX: [SGSN->PCU] 
BSSGP_PDUT_DL_UNITDATA\n");
+   LOGP(DBSSGP, LOGL_DEBUG, "Rx BSSGP BVCI=%d (PTP) 
DL_UNITDATA\n", bvci);
if (the_pcu.on_dl_unit_data)
the_pcu.on_dl_unit_data(_pcu, msg, tp);
gprs_bssgp_pcu_rx_dl_ud(msg, tp);
break;
-   case BSSGP_PDUT_PAGING_PS:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_PAGING_PS\n");
-   break;
-   case BSSGP_PDUT_PAGING_CS:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_PAGING_CS\n");
-   break;
-   case BSSGP_PDUT_RA_CAPA_UPDATE_ACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_RA_CAPA_UPDATE_ACK\n");
-   break;
case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx 
BSSGP_PDUT_FLOW_CONTROL_BVC_ACK\n");
-   break;
case BSSGP_PDUT_FLOW_CONTROL_MS_ACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_FLOW_CONTROL_MS_ACK\n");
+   LOGP(DBSSGP, LOGL_DEBUG, "Rx BSSGP BVCI=%d (PTP) %s\n",
+bvci, bssgp_pdu_str(pdu_type));
+   break;
+   case BSSGP_PDUT_PAGING_PS:
+   case BSSGP_PDUT_PAGING_CS:
+   case BSSGP_PDUT_RA_CAPABILITY:
+   case BSSGP_PDUT_RA_CAPA_UPDATE_ACK:
+   LOGP(DBSSGP, LOGL_INFO, "Rx BSSGP BVCI=%d (PTP) PDU type %s not 
implemented\n",
+bvci, bssgp_pdu_str(pdu_type));
+   break;
+   /* See TS 08.18 5.4.1 */
+   case BSSGP_PDUT_SUSPEND:
+   case BSSGP_PDUT_SUSPEND_ACK:
+   case BSSGP_PDUT_SUSPEND_NACK:
+   case BSSGP_PDUT_RESUME:
+   case BSSGP_PDUT_RESUME_ACK:
+   case BSSGP_PDUT_RESUME_NACK:
+   case BSSGP_PDUT_FLUSH_LL:
+   case BSSGP_PDUT_FLUSH_LL_ACK:
+   case BSSGP_PDUT_LLC_DISCARD:
+   case BSSGP_PDUT_BVC_BLOCK:
+   case BSSGP_PDUT_BVC_BLOCK_ACK:
+   case BSSGP_PDUT_BVC_UNBLOCK:
+   case BSSGP_PDUT_BVC_UNBLOCK_ACK:
+   case BSSGP_PDUT_BVC_RESET:
+   case BSSGP_PDUT_BVC_RESET_ACK:
+   case BSSGP_PDUT_SGSN_INVOKE_TRACE:
+   LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%u (PTP) PDU type %s 
unexpected at PTP\n",
+   bctx->bvci, bssgp_pdu_str(pdu_type));
+   rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
break;
default:
-   LOGP(DBSSGP, LOGL_NOTICE, "BSSGP BVCI=%u PDU type %s unknown\n",
+   LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%u (PTP) PDU type %s 
unknown\n",
bctx->bvci, bssgp_pdu_str(pdu_type));
rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
break;
@@ -263,18 +286,17 @@
int bvci = bctx ? bctx->bvci : -1;
switch (pdu_type) {
case BSSGP_PDUT_STATUS:
-   /* Some exception has occurred */
-   DEBUGP(DBSSGP, "BSSGP BVCI=%d Rx BVC STATUS\n", bvci);
-   /* FIXME: send NM_STATUS.ind to NM */
+   /* already handled in libosmogb */
+   OSMO_ASSERT(0);
break;
case BSSGP_PDUT_SUSPEND_ACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_SUSPEND_ACK\n");
-   break;
-   case BSSGP_PDUT_SUSPEND_NACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_SUSPEND_NACK\n");
+   case BSSGP_PDUT_RESUME_ACK:
+   case BSSGP_PDUT_BVC_BLOCK_ACK:
+   LOGP(DBSSGP, LOGL_DEBUG, "Rx BSSGP BVCI=%d (SIGN) %s\n",
+bvci, bssgp_pdu_str(pdu_type));
break;
   

osmo-pcu[master]: BSSGP: Improve logging of received messages

2017-07-29 Thread Harald Welte

Patch Set 1: Code-Review+2

-- 
To view, visit https://gerrit.osmocom.org/3383
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ie32f5771d49960547ec5d7611f96a74facc1b035
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-HasComments: No


[PATCH] osmo-pcu[master]: Forward GPRS SUSPEND REQ from BTS to SGSN using BSSGP

2017-07-29 Thread Harald Welte

Review at  https://gerrit.osmocom.org/3384

Forward GPRS SUSPEND REQ from BTS to SGSN using BSSGP

As specified in 3GPP TS 03.60 Section 16.2.1 and 44.018 Section 3.4.15,
a Class B MS is sending a "RR GPRS SUSPEND REQ" via a DCCH to the BTS if
it wants to suspend GPRS services.  As of
Change-Id I3c1af662c8f0d3d22da200638480f6ef05c3ed1f, OsmoBTS forwards
this via the PCU socket, so we need to pick it up and send it via BSSGP
to the SGSN.

Change-Id: I7b4beb413a6f974373a404b5a11c44d86ba695d3
Closes: OS#2249
---
M include/osmocom/pcu/pcuif_proto.h
M src/pcu_l1_if.cpp
2 files changed, 27 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/84/3384/1

diff --git a/include/osmocom/pcu/pcuif_proto.h 
b/include/osmocom/pcu/pcuif_proto.h
index 88dc09e..d6c7556 100644
--- a/include/osmocom/pcu/pcuif_proto.h
+++ b/include/osmocom/pcu/pcuif_proto.h
@@ -10,6 +10,7 @@
 #define PCU_IF_MSG_DATA_REQ0x00/* send data to given channel */
 #define PCU_IF_MSG_DATA_CNF0x01/* confirm (e.g. transmission on PCH) */
 #define PCU_IF_MSG_DATA_IND0x02/* receive data from given channel */   
+#define PCU_IF_MSG_SUSP_REQ0x03/* BTS forwards GPRS SUSP REQ to PCU */
 #define PCU_IF_MSG_RTS_REQ 0x10/* ready to send request */
 #define PCU_IF_MSG_RACH_IND0x22/* receive RACH */
 #define PCU_IF_MSG_INFO_IND0x32/* retrieve BTS info */
@@ -150,6 +151,13 @@
uint8_t identity_lv[9];
 } __attribute__ ((packed));
 
+/* BTS tells PCU about a GPRS SUSPENSION REQUEST received on DCCH */
+struct gsm_pcu_if_susp_req {
+   uint32_ttlli;
+   uint8_t ra_id[6];
+   uint8_t cause;
+} __attribute__ ((packed));
+
 struct gsm_pcu_if {
/* context based information */
uint8_t msg_type;   /* message type */
@@ -160,6 +168,7 @@
struct gsm_pcu_if_data  data_req;
struct gsm_pcu_if_data  data_cnf;
struct gsm_pcu_if_data  data_ind;
+   struct gsm_pcu_if_susp_req  susp_req;
struct gsm_pcu_if_rts_req   rts_req;
struct gsm_pcu_if_rach_ind  rach_ind;
struct gsm_pcu_if_txt_ind   txt_ind;
diff --git a/src/pcu_l1_if.cpp b/src/pcu_l1_if.cpp
index 420bca0..9d05539 100644
--- a/src/pcu_l1_if.cpp
+++ b/src/pcu_l1_if.cpp
@@ -563,6 +563,21 @@
pag_req->identity_lv);
 }
 
+static int pcu_rx_susp_req(struct gsm_pcu_if_susp_req *susp_req)
+{
+   struct bssgp_bvc_ctx *bctx = gprs_bssgp_pcu_current_bctx();
+   struct gprs_ra_id ra_id;
+
+   gsm48_parse_ra(_id, susp_req->ra_id);
+
+   LOGP(DL1IF, LOGL_DEBUG, "GPRS Suspent request received: tlli=0x%08x\n", 
susp_req->tlli);
+
+   if (!bctx)
+   return -1;
+
+   return bssgp_tx_suspend(bctx->nsei, susp_req->tlli, _id);
+}
+
 int pcu_rx(uint8_t msg_type, struct gsm_pcu_if *pcu_prim)
 {
int rc = 0;
@@ -589,6 +604,9 @@
case PCU_IF_MSG_PAG_REQ:
rc = pcu_rx_pag_req(_prim->u.pag_req);
break;
+   case PCU_IF_MSG_SUSP_REQ:
+   rc = pcu_rx_susp_req(_prim->u.susp_req);
+   break;
default:
LOGP(DL1IF, LOGL_ERROR, "Received unknwon PCU msg type %d\n",
msg_type);

-- 
To view, visit https://gerrit.osmocom.org/3384
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b4beb413a6f974373a404b5a11c44d86ba695d3
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-pcu[master]: Remove #warnings that have been adressed since 2015

2017-07-29 Thread Harald Welte

Review at  https://gerrit.osmocom.org/3382

Remove #warnings that have been adressed since 2015

In commit 939904672961fa7e28397e27f942a7d1fff4bbdf the lookup by
TLLI, TLLI-OLD and IMSI has been implemented, but the corresponding
compile-time warning was never removed.

Change-Id: I7a1767bc7cab01048e851fd4e63112bc676d6c78
---
M src/tbf_dl.cpp
1 file changed, 0 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/82/3382/1

diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index a894789..505d488 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -126,8 +126,6 @@
GprsMs *ms;
 
/* check for uplink data, so we copy our informations */
-#warning "Do the same look up for IMSI, TLLI and OLD_TLLI"
-#warning "Refactor the below lines... into a new method"
ms = bts->bts->ms_store().get_ms(tlli, tlli_old, imsi);
if (ms) {
ul_tbf = ms->ul_tbf();

-- 
To view, visit https://gerrit.osmocom.org/3382
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a1767bc7cab01048e851fd4e63112bc676d6c78
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Harald Welte 


[PATCH] osmo-pcu[master]: BSSGP: Improve logging of received messages

2017-07-29 Thread Harald Welte

Review at  https://gerrit.osmocom.org/3383

BSSGP: Improve logging of received messages

We now differentiate clearly between messages that

a) we don't expect based on our reading of the spec
b) we have not implemented yet (but should)
c) we do not even know of

Also, unify the log string formats and provide BVCI whenever possible.

Change-Id: Ie32f5771d49960547ec5d7611f96a74facc1b035
---
M src/gprs_bssgp_pcu.cpp
1 file changed, 75 insertions(+), 41 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/83/3383/1

diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index 437479b..9c78ecf 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -208,6 +208,7 @@
 {
struct bssgp_normal_hdr *bgph = (struct bssgp_normal_hdr *) 
msgb_bssgph(msg);
enum bssgp_pdu_type pdu_type = (enum bssgp_pdu_type) bgph->pdu_type;
+   int bvci = bctx ? bctx->bvci : -1;
unsigned rc = 0;
 
if (!bctx)
@@ -224,29 +225,51 @@
}
 
switch (pdu_type) {
+   case BSSGP_PDUT_STATUS:
+   /* already handled in libosmogb */
+   OSMO_ASSERT(0);
+   break;
case BSSGP_PDUT_DL_UNITDATA:
-   LOGP(DBSSGP, LOGL_DEBUG, "RX: [SGSN->PCU] 
BSSGP_PDUT_DL_UNITDATA\n");
+   LOGP(DBSSGP, LOGL_DEBUG, "Rx BSSGP BVCI=%d (PTP) 
DL_UNITDATA\n", bvci);
if (the_pcu.on_dl_unit_data)
the_pcu.on_dl_unit_data(_pcu, msg, tp);
gprs_bssgp_pcu_rx_dl_ud(msg, tp);
break;
-   case BSSGP_PDUT_PAGING_PS:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_PAGING_PS\n");
-   break;
-   case BSSGP_PDUT_PAGING_CS:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_PAGING_CS\n");
-   break;
-   case BSSGP_PDUT_RA_CAPA_UPDATE_ACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_RA_CAPA_UPDATE_ACK\n");
-   break;
case BSSGP_PDUT_FLOW_CONTROL_BVC_ACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx 
BSSGP_PDUT_FLOW_CONTROL_BVC_ACK\n");
-   break;
case BSSGP_PDUT_FLOW_CONTROL_MS_ACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_FLOW_CONTROL_MS_ACK\n");
+   LOGP(DBSSGP, LOGL_DEBUG, "Rx BSSGP BVCI=%d (PTP) %s\n",
+bvci, bssgp_pdu_str(pdu_type));
+   break;
+   case BSSGP_PDUT_PAGING_PS:
+   case BSSGP_PDUT_PAGING_CS:
+   case BSSGP_PDUT_RA_CAPABILITY:
+   case BSSGP_PDUT_RA_CAPA_UPDATE_ACK:
+   LOGP(DBSSGP, LOGL_INFO, "Rx BSSGP BVCI=%d (PTP) PDU type %s not 
implemented\n",
+bvci, bssgp_pdu_str(pdu_type));
+   break;
+   /* See TS 08.18 5.4.1 */
+   case BSSGP_PDUT_SUSPEND:
+   case BSSGP_PDUT_SUSPEND_ACK:
+   case BSSGP_PDUT_SUSPEND_NACK:
+   case BSSGP_PDUT_RESUME:
+   case BSSGP_PDUT_RESUME_ACK:
+   case BSSGP_PDUT_RESUME_NACK:
+   case BSSGP_PDUT_FLUSH_LL:
+   case BSSGP_PDUT_FLUSH_LL_ACK:
+   case BSSGP_PDUT_LLC_DISCARD:
+   case BSSGP_PDUT_BVC_BLOCK:
+   case BSSGP_PDUT_BVC_BLOCK_ACK:
+   case BSSGP_PDUT_BVC_UNBLOCK:
+   case BSSGP_PDUT_BVC_UNBLOCK_ACK:
+   case BSSGP_PDUT_BVC_RESET:
+   case BSSGP_PDUT_BVC_RESET_ACK:
+   case BSSGP_PDUT_SGSN_INVOKE_TRACE:
+   LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%u (PTP) PDU type %s 
unexpected at PTP\n",
+   bctx->bvci, bssgp_pdu_str(pdu_type));
+   rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
break;
default:
-   LOGP(DBSSGP, LOGL_NOTICE, "BSSGP BVCI=%u PDU type %s unknown\n",
+   LOGP(DBSSGP, LOGL_NOTICE, "Rx BSSGP BVCI=%u (PTP) PDU type %s 
unknown\n",
bctx->bvci, bssgp_pdu_str(pdu_type));
rc = bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
break;
@@ -263,18 +286,17 @@
int bvci = bctx ? bctx->bvci : -1;
switch (pdu_type) {
case BSSGP_PDUT_STATUS:
-   /* Some exception has occurred */
-   DEBUGP(DBSSGP, "BSSGP BVCI=%d Rx BVC STATUS\n", bvci);
-   /* FIXME: send NM_STATUS.ind to NM */
+   /* already handled in libosmogb */
+   OSMO_ASSERT(0);
break;
case BSSGP_PDUT_SUSPEND_ACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_SUSPEND_ACK\n");
-   break;
-   case BSSGP_PDUT_SUSPEND_NACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_SUSPEND_NACK\n");
+   case BSSGP_PDUT_RESUME_ACK:
+   case BSSGP_PDUT_BVC_BLOCK_ACK:
+   LOGP(DBSSGP, LOGL_DEBUG, "Rx BSSGP BVCI=%d (SIGN) %s\n",
+bvci, bssgp_pdu_str(pdu_type));
break;
case BSSGP_PDUT_BVC_RESET_ACK:
-   LOGP(DBSSGP, LOGL_DEBUG, "rx BSSGP_PDUT_BVC_RESET_ACK\n");
+   LOGP(DBSSGP, LOGL_NOTICE, 

[PATCH] libosmocore[master]: gsm0480: refactor the parse_process_uss_req()

2017-07-29 Thread Vadim Yanitskiy
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/3375

to look at the new patch set (#2).

gsm0480: refactor the parse_process_uss_req()

This change reduces the degree of code nesting using
the 'follow by contradiction' pattern.

Change-Id: I467f75794c5ac9df75c001245b18bbdfcfaadd88
---
M src/gsm/gsm0480.c
1 file changed, 20 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/75/3375/2

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 1c01e64..de99223 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -427,36 +427,37 @@
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct ss_request *req)
 {
-   int rc = 0;
int num_chars;
uint8_t dcs;
-
 
/* we need at least that much */
if (length < 8)
return 0;
 
+   if (uss_req_data[0] != GSM_0480_SEQUENCE_TAG)
+   return 0;
 
-   if (uss_req_data[0] == GSM_0480_SEQUENCE_TAG) {
-   if (uss_req_data[2] == ASN1_OCTET_STRING_TAG) {
-   dcs = uss_req_data[4];
-   if ((dcs == 0x0F) &&
-   (uss_req_data[5] == ASN1_OCTET_STRING_TAG)) {
-   num_chars = (uss_req_data[6] * 8) / 7;
-   /* Prevent a mobile-originated buffer-overrun! 
*/
-   if (num_chars > MAX_LEN_USSD_STRING)
-   num_chars = MAX_LEN_USSD_STRING;
+   /* Both 2th and 5th should be equal to ASN1_OCTET_STRING_TAG */
+   if ((uss_req_data[2] & uss_req_data[5]) != ASN1_OCTET_STRING_TAG)
+   return 0;
 
-   num_chars = gsm_7bit_decode_n_ussd((char 
*)req->ussd_text,
-   sizeof(req->ussd_text), 
&(uss_req_data[7]), num_chars);
+   dcs = uss_req_data[4];
+   if (dcs == 0x0F) {
+   num_chars = (uss_req_data[6] * 8) / 7;
+   /* Prevent a mobile-originated buffer-overrun! */
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
 
-   req->ussd_text_language = 0x80;
-   req->ussd_text_len = num_chars;
-   rc = 1;
-   }
-   }
+   num_chars = gsm_7bit_decode_n_ussd((char *)req->ussd_text,
+   sizeof(req->ussd_text), &(uss_req_data[7]), num_chars);
+
+   req->ussd_text_language = 0x80;
+   req->ussd_text_len = num_chars;
+
+   return 1;
}
-   return rc;
+
+   return 0;
 }
 
 /* Parse the parameters of a Interrogate/Activate/DeactivateSS Request */

-- 
To view, visit https://gerrit.osmocom.org/3375
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I467f75794c5ac9df75c001245b18bbdfcfaadd88
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Jenkins Builder


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_OP_CODE_PROCESS_USS_DATA

2017-07-29 Thread Vadim Yanitskiy

gsm0480: handle GSM0480_OP_CODE_PROCESS_USS_DATA

Change-Id: I470290c2b544555e53cedd849b1d6a961db7b5a4
---
M src/gsm/gsm0480.c
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/80/3380/2

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index c74077a..6731cec 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -425,6 +425,11 @@
   length - offset - 3,
   req);
break;
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   rc = parse_process_uss_data(invoke_data + offset + 3,
+   length - offset - 3,
+   req);
+   break;
case GSM0480_OP_CODE_ACTIVATE_SS:
case GSM0480_OP_CODE_DEACTIVATE_SS:
case GSM0480_OP_CODE_INTERROGATE_SS:

-- 
To view, visit https://gerrit.osmocom.org/3380
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I470290c2b544555e53cedd849b1d6a961db7b5a4
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: handle USS_NOTIFY and USS_REQUEST with PROCESS_USS_REQ

2017-07-29 Thread Vadim Yanitskiy

gsm0480: handle USS_NOTIFY and USS_REQUEST with PROCESS_USS_REQ

Change-Id: If7cc6a966dfc17d37e22338ecc1f239f908a9f2e
---
M src/gsm/gsm0480.c
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/79/3379/2

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 7e036ba..c74077a 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -418,6 +418,8 @@
uint8_t operation_code = invoke_data[offset+2];
req->opcode = operation_code;
switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
case GSM0480_OP_CODE_PROCESS_USS_REQ:
rc = parse_process_uss_req(invoke_data + offset + 3,
   length - offset - 3,

-- 
To view, visit https://gerrit.osmocom.org/3379
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If7cc6a966dfc17d37e22338ecc1f239f908a9f2e
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: expose the gsm0480_parse_ss_facility_ie()

2017-07-29 Thread Vadim Yanitskiy

gsm0480: expose the gsm0480_parse_ss_facility_ie()

Change-Id: I35d3360f36c48eb1295610ab96ff264c45af77eb
---
M include/osmocom/gsm/gsm0480.h
M src/gsm/gsm0480.c
M src/gsm/libosmogsm.map
3 files changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/81/3381/2

diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h
index e3b15d2..e3d40a9 100644
--- a/include/osmocom/gsm/gsm0480.h
+++ b/include/osmocom/gsm/gsm0480.h
@@ -50,6 +50,8 @@
 
 int gsm0480_decode_ss_request(const struct gsm48_hdr *hdr, uint16_t len,
struct ss_request *request);
+int gsm0480_parse_ss_facility_ie(const uint8_t *facility_ie, uint16_t length,
+struct ss_request *req);
 
 struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, 
const char *text);
 struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char 
*text);
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 6731cec..9705359 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -198,8 +198,6 @@
 struct ss_request *req);
 static int parse_ss_info_elements(const uint8_t *ussd_ie, uint16_t len,
  struct ss_request *req);
-static int parse_facility_ie(const uint8_t *facility_ie, uint16_t length,
-struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct ss_request *req);
 static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
@@ -302,7 +300,8 @@
if (len - 1 < facility_length)
return 0;
 
-   return parse_facility_ie(ss_facility + 1, facility_length, req);
+   return gsm0480_parse_ss_facility_ie(ss_facility + 1,
+   facility_length, req);
 }
 
 static int parse_ss_info_elements(const uint8_t *ss_ie, uint16_t len,
@@ -324,7 +323,7 @@
case GSM48_IE_CAUSE:
break;
case GSM0480_IE_FACILITY:
-   rc = parse_facility_ie(ss_ie + 2, iei_length, req);
+   rc = gsm0480_parse_ss_facility_ie(ss_ie + 2, iei_length, req);
break;
case GSM0480_IE_SS_VERSION:
break;
@@ -338,8 +337,8 @@
return rc;
 }
 
-static int parse_facility_ie(const uint8_t *facility_ie, uint16_t length,
-struct ss_request *req)
+int gsm0480_parse_ss_facility_ie(const uint8_t *facility_ie, uint16_t length,
+struct ss_request *req)
 {
int rc = 1;
uint8_t offset = 0;
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 714cb25..b9d30bb 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -83,6 +83,7 @@
 gsm0480_create_ussd_release_complete;
 gsm0480_decode_ussd_request;
 gsm0480_decode_ss_request;
+gsm0480_parse_ss_facility_ie;
 gsm0480_wrap_facility;
 gsm0480_wrap_invoke;
 

-- 
To view, visit https://gerrit.osmocom.org/3381
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I35d3360f36c48eb1295610ab96ff264c45af77eb
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2017-07-29 Thread Vadim Yanitskiy

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
---
M src/gsm/gsm0480.c
1 file changed, 84 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/2

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index e8a3bc3..7e036ba 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -202,6 +202,10 @@
 struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -360,6 +364,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -439,6 +446,83 @@
return rc;
 }
 
+/* Parse an Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 1;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
+
+   req->ussd_text_language = 1;
+   req->ussd_text_len = num_chars;
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct ss_request *req)

-- 
To view, visit https://gerrit.osmocom.org/3378
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: parse GSM0480_MTYPE_FACILITY separately

2017-07-29 Thread Vadim Yanitskiy

gsm0480: parse GSM0480_MTYPE_FACILITY separately

Change-Id: I6e029c436a50fa8c2823ea39c5d123ee701becfa
---
M src/gsm/gsm0480.c
1 file changed, 17 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/77/3377/2

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 87095d2..e8a3bc3 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -194,6 +194,8 @@
 /* Forward declarations */
 static int parse_ss(const struct gsm48_hdr *hdr,
uint16_t len, struct ss_request *req);
+static int parse_ss_facility(const uint8_t *ss_facility, uint16_t len,
+struct ss_request *req);
 static int parse_ss_info_elements(const uint8_t *ussd_ie, uint16_t len,
  struct ss_request *req);
 static int parse_facility_ie(const uint8_t *facility_ie, uint16_t length,
@@ -272,8 +274,10 @@
req->ussd_text[0] = 0xFF;
break;
case GSM0480_MTYPE_REGISTER:
-   case GSM0480_MTYPE_FACILITY:
rc &= parse_ss_info_elements(>data[0], len - sizeof(*hdr), 
req);
+   break;
+   case GSM0480_MTYPE_FACILITY:
+   rc &= parse_ss_facility(>data[0], len - sizeof(*hdr), req);
break;
default:
LOGP(0, LOGL_DEBUG, "Unknown GSM 04.80 message-type field 
0x%02x\n",
@@ -285,6 +289,18 @@
return rc;
 }
 
+static int parse_ss_facility(const uint8_t *ss_facility, uint16_t len,
+struct ss_request *req)
+{
+   uint8_t facility_length;
+
+   facility_length = ss_facility[0];
+   if (len - 1 < facility_length)
+   return 0;
+
+   return parse_facility_ie(ss_facility + 1, facility_length, req);
+}
+
 static int parse_ss_info_elements(const uint8_t *ss_ie, uint16_t len,
  struct ss_request *req)
 {

-- 
To view, visit https://gerrit.osmocom.org/3377
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I6e029c436a50fa8c2823ea39c5d123ee701becfa
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: handle UnstructuredSS request with DSC != 0x0F

2017-07-29 Thread Vadim Yanitskiy

gsm0480: handle UnstructuredSS request with DSC != 0x0F

Change-Id: I73d602f6f20b0afe7600d16bbd432069ae7be788
---
M src/gsm/gsm0480.c
1 file changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/3376/2

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index de99223..87095d2 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -455,6 +455,17 @@
req->ussd_text_len = num_chars;
 
return 1;
+   } else {
+   num_chars = uss_req_data[6];
+   /* Prevent a mobile-originated buffer-overrun! */
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
+
+   req->ussd_text_language = dcs;
+   req->ussd_text_len = num_chars;
+   memcpy(req->ussd_text, &(uss_req_data[7]), num_chars);
+
+   return 1;
}
 
return 0;

-- 
To view, visit https://gerrit.osmocom.org/3376
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I73d602f6f20b0afe7600d16bbd432069ae7be788
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Jenkins Builder


[PATCH] libosmocore[master]: gsm0480: expose the gsm0480_parse_ss_facility_ie()

2017-07-29 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/3381

gsm0480: expose the gsm0480_parse_ss_facility_ie()

Change-Id: I35d3360f36c48eb1295610ab96ff264c45af77eb
---
M include/osmocom/gsm/gsm0480.h
M src/gsm/gsm0480.c
M src/gsm/libosmogsm.map
3 files changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/81/3381/1

diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h
index e3b15d2..e3d40a9 100644
--- a/include/osmocom/gsm/gsm0480.h
+++ b/include/osmocom/gsm/gsm0480.h
@@ -50,6 +50,8 @@
 
 int gsm0480_decode_ss_request(const struct gsm48_hdr *hdr, uint16_t len,
struct ss_request *request);
+int gsm0480_parse_ss_facility_ie(const uint8_t *facility_ie, uint16_t length,
+struct ss_request *req);
 
 struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, 
const char *text);
 struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char 
*text);
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 6731cec..9705359 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -198,8 +198,6 @@
 struct ss_request *req);
 static int parse_ss_info_elements(const uint8_t *ussd_ie, uint16_t len,
  struct ss_request *req);
-static int parse_facility_ie(const uint8_t *facility_ie, uint16_t length,
-struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct ss_request *req);
 static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
@@ -302,7 +300,8 @@
if (len - 1 < facility_length)
return 0;
 
-   return parse_facility_ie(ss_facility + 1, facility_length, req);
+   return gsm0480_parse_ss_facility_ie(ss_facility + 1,
+   facility_length, req);
 }
 
 static int parse_ss_info_elements(const uint8_t *ss_ie, uint16_t len,
@@ -324,7 +323,7 @@
case GSM48_IE_CAUSE:
break;
case GSM0480_IE_FACILITY:
-   rc = parse_facility_ie(ss_ie + 2, iei_length, req);
+   rc = gsm0480_parse_ss_facility_ie(ss_ie + 2, iei_length, req);
break;
case GSM0480_IE_SS_VERSION:
break;
@@ -338,8 +337,8 @@
return rc;
 }
 
-static int parse_facility_ie(const uint8_t *facility_ie, uint16_t length,
-struct ss_request *req)
+int gsm0480_parse_ss_facility_ie(const uint8_t *facility_ie, uint16_t length,
+struct ss_request *req)
 {
int rc = 1;
uint8_t offset = 0;
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 714cb25..b9d30bb 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -83,6 +83,7 @@
 gsm0480_create_ussd_release_complete;
 gsm0480_decode_ussd_request;
 gsm0480_decode_ss_request;
+gsm0480_parse_ss_facility_ie;
 gsm0480_wrap_facility;
 gsm0480_wrap_invoke;
 

-- 
To view, visit https://gerrit.osmocom.org/3381
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35d3360f36c48eb1295610ab96ff264c45af77eb
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: handle UnstructuredSS request with DSC != 0x0F

2017-07-29 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/3376

gsm0480: handle UnstructuredSS request with DSC != 0x0F

Change-Id: I73d602f6f20b0afe7600d16bbd432069ae7be788
---
M src/gsm/gsm0480.c
1 file changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/76/3376/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index de99223..87095d2 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -455,6 +455,17 @@
req->ussd_text_len = num_chars;
 
return 1;
+   } else {
+   num_chars = uss_req_data[6];
+   /* Prevent a mobile-originated buffer-overrun! */
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
+
+   req->ussd_text_language = dcs;
+   req->ussd_text_len = num_chars;
+   memcpy(req->ussd_text, &(uss_req_data[7]), num_chars);
+
+   return 1;
}
 
return 0;

-- 
To view, visit https://gerrit.osmocom.org/3376
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I73d602f6f20b0afe7600d16bbd432069ae7be788
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: refactor the parse_process_uss_req()

2017-07-29 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/3375

gsm0480: refactor the parse_process_uss_req()

This change reduces the degree of code nesting using
the 'follow by contradiction' pattern.

Change-Id: I467f75794c5ac9df75c001245b18bbdfcfaadd88
---
M src/gsm/gsm0480.c
1 file changed, 20 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/75/3375/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 1c01e64..de99223 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -427,36 +427,37 @@
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct ss_request *req)
 {
-   int rc = 0;
int num_chars;
uint8_t dcs;
-
 
/* we need at least that much */
if (length < 8)
return 0;
 
+   if (uss_req_data[0] != GSM_0480_SEQUENCE_TAG)
+   return 0;
 
-   if (uss_req_data[0] == GSM_0480_SEQUENCE_TAG) {
-   if (uss_req_data[2] == ASN1_OCTET_STRING_TAG) {
-   dcs = uss_req_data[4];
-   if ((dcs == 0x0F) &&
-   (uss_req_data[5] == ASN1_OCTET_STRING_TAG)) {
-   num_chars = (uss_req_data[6] * 8) / 7;
-   /* Prevent a mobile-originated buffer-overrun! 
*/
-   if (num_chars > MAX_LEN_USSD_STRING)
-   num_chars = MAX_LEN_USSD_STRING;
+   /* Both 2th and 5th should be equal to ASN1_OCTET_STRING_TAG */
+   if ((uss_req_data[2] & uss_req_data[5]) != ASN1_OCTET_STRING_TAG)
+   return 0;
 
-   num_chars = gsm_7bit_decode_n_ussd((char 
*)req->ussd_text,
-   sizeof(req->ussd_text), 
&(uss_req_data[7]), num_chars);
+   dcs = uss_req_data[4];
+   if (dcs == 0x0F) {
+   num_chars = (uss_req_data[6] * 8) / 7;
+   /* Prevent a mobile-originated buffer-overrun! */
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
 
-   req->ussd_text_language = 0x80;
-   req->ussd_text_len = num_chars;
-   rc = 1;
-   }
-   }
+   num_chars = gsm_7bit_decode_n_ussd((char *)req->ussd_text,
+   sizeof(req->ussd_text), &(uss_req_data[7]), num_chars);
+
+   req->ussd_text_language = 0x80;
+   req->ussd_text_len = num_chars;
+
+   return 1;
}
-   return rc;
+
+   return 0;
 }
 
 /* Parse the parameters of a Interrogate/Activate/DeactivateSS Request */

-- 
To view, visit https://gerrit.osmocom.org/3375
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I467f75794c5ac9df75c001245b18bbdfcfaadd88
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_OP_CODE_PROCESS_USS_DATA

2017-07-29 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/3380

gsm0480: handle GSM0480_OP_CODE_PROCESS_USS_DATA

Change-Id: I470290c2b544555e53cedd849b1d6a961db7b5a4
---
M src/gsm/gsm0480.c
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/80/3380/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index c74077a..6731cec 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -425,6 +425,11 @@
   length - offset - 3,
   req);
break;
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   rc = parse_process_uss_data(invoke_data + offset + 3,
+   length - offset - 3,
+   req);
+   break;
case GSM0480_OP_CODE_ACTIVATE_SS:
case GSM0480_OP_CODE_DEACTIVATE_SS:
case GSM0480_OP_CODE_INTERROGATE_SS:

-- 
To view, visit https://gerrit.osmocom.org/3380
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I470290c2b544555e53cedd849b1d6a961db7b5a4
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

2017-07-29 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/3378

gsm0480: handle GSM0480_CTYPE_RETURN_RESULT

Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
---
M src/gsm/gsm0480.c
1 file changed, 84 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/78/3378/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index e8a3bc3..7e036ba 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -202,6 +202,10 @@
 struct ss_request *req);
 static int parse_ss_invoke(const uint8_t *invoke_data, uint16_t length,
struct ss_request *req);
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req);
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req);
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
struct ss_request *req);
 static int parse_ss_for_bs_req(const uint8_t *ss_req_data,
@@ -360,6 +364,9 @@
  req);
break;
case GSM0480_CTYPE_RETURN_RESULT:
+   rc &= parse_ss_return_result(facility_ie+2,
+component_length,
+req);
break;
case GSM0480_CTYPE_RETURN_ERROR:
break;
@@ -439,6 +446,83 @@
return rc;
 }
 
+/* Parse an Return Result component - see table 3.4 */
+static int parse_ss_return_result(const uint8_t *rr_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t operation_code;
+   uint8_t offset;
+
+   if (length < 3)
+   return 0;
+
+   /* Mandatory part */
+   if (rr_data[0] != GSM0480_COMPIDTAG_INVOKE_ID) {
+   LOGP(0, LOGL_DEBUG, "Unexpected GSM 04.80 Component-ID tag "
+"0x%02x (expecting Invoke ID tag)\n", rr_data[0]);
+   return 0;
+   }
+
+   offset = rr_data[1] + 2;
+   req->invoke_id = rr_data[2];
+
+   if (offset >= length)
+   return 1;
+
+   if (rr_data[offset] != GSM_0480_SEQUENCE_TAG)
+   return 0;
+
+   if (offset + 2 > length)
+   return 0;
+
+   offset += 2;
+   operation_code = rr_data[offset + 2];
+   req->opcode = operation_code;
+
+   switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
+   case GSM0480_OP_CODE_PROCESS_USS_REQ:
+   return parse_process_uss_req(rr_data + offset + 3,
+   length - offset - 3, req);
+   case GSM0480_OP_CODE_PROCESS_USS_DATA:
+   return parse_process_uss_data(rr_data + offset + 3,
+   length - offset - 3, req);
+   default:
+   LOGP(0, LOGL_DEBUG, "GSM 04.80 operation code 0x%02x "
+   "is not yet handled\n", operation_code);
+   return 0;
+   }
+
+   return 1;
+}
+
+static int parse_process_uss_data(const uint8_t *uss_req_data, uint16_t length,
+ struct ss_request *req)
+{
+   uint8_t num_chars;
+
+   /* we need at least that much */
+   if (length < 3)
+   return 0;
+
+   if (uss_req_data[0] != ASN1_IA5_STRING_TAG)
+   return 0;
+
+   num_chars = uss_req_data[1];
+   if (num_chars > length - 2)
+   return 0;
+
+   if (num_chars > MAX_LEN_USSD_STRING)
+   num_chars = MAX_LEN_USSD_STRING;
+
+   req->ussd_text_language = 1;
+   req->ussd_text_len = num_chars;
+   memcpy(req->ussd_text, uss_req_data + 2, num_chars);
+
+   return 1;
+}
+
 /* Parse the parameters of a Process UnstructuredSS Request */
 static int parse_process_uss_req(const uint8_t *uss_req_data, uint16_t length,
 struct ss_request *req)

-- 
To view, visit https://gerrit.osmocom.org/3378
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8fb2856acbbf4c53e7d53200a37bc8f79e763bcf
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: parse GSM0480_MTYPE_FACILITY separately

2017-07-29 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/3377

gsm0480: parse GSM0480_MTYPE_FACILITY separately

Change-Id: I6e029c436a50fa8c2823ea39c5d123ee701becfa
---
M src/gsm/gsm0480.c
1 file changed, 17 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/77/3377/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 87095d2..e8a3bc3 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -194,6 +194,8 @@
 /* Forward declarations */
 static int parse_ss(const struct gsm48_hdr *hdr,
uint16_t len, struct ss_request *req);
+static int parse_ss_facility(const uint8_t *ss_facility, uint16_t len,
+struct ss_request *req);
 static int parse_ss_info_elements(const uint8_t *ussd_ie, uint16_t len,
  struct ss_request *req);
 static int parse_facility_ie(const uint8_t *facility_ie, uint16_t length,
@@ -272,8 +274,10 @@
req->ussd_text[0] = 0xFF;
break;
case GSM0480_MTYPE_REGISTER:
-   case GSM0480_MTYPE_FACILITY:
rc &= parse_ss_info_elements(>data[0], len - sizeof(*hdr), 
req);
+   break;
+   case GSM0480_MTYPE_FACILITY:
+   rc &= parse_ss_facility(>data[0], len - sizeof(*hdr), req);
break;
default:
LOGP(0, LOGL_DEBUG, "Unknown GSM 04.80 message-type field 
0x%02x\n",
@@ -285,6 +289,18 @@
return rc;
 }
 
+static int parse_ss_facility(const uint8_t *ss_facility, uint16_t len,
+struct ss_request *req)
+{
+   uint8_t facility_length;
+
+   facility_length = ss_facility[0];
+   if (len - 1 < facility_length)
+   return 0;
+
+   return parse_facility_ie(ss_facility + 1, facility_length, req);
+}
+
 static int parse_ss_info_elements(const uint8_t *ss_ie, uint16_t len,
  struct ss_request *req)
 {

-- 
To view, visit https://gerrit.osmocom.org/3377
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e029c436a50fa8c2823ea39c5d123ee701becfa
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: handle USS_NOTIFY and USS_REQUEST with PROCESS_USS_REQ

2017-07-29 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/3379

gsm0480: handle USS_NOTIFY and USS_REQUEST with PROCESS_USS_REQ

Change-Id: If7cc6a966dfc17d37e22338ecc1f239f908a9f2e
---
M src/gsm/gsm0480.c
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/79/3379/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 7e036ba..c74077a 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -418,6 +418,8 @@
uint8_t operation_code = invoke_data[offset+2];
req->opcode = operation_code;
switch (operation_code) {
+   case GSM0480_OP_CODE_USS_NOTIFY:
+   case GSM0480_OP_CODE_USS_REQUEST:
case GSM0480_OP_CODE_PROCESS_USS_REQ:
rc = parse_process_uss_req(invoke_data + offset + 3,
   length - offset - 3,

-- 
To view, visit https://gerrit.osmocom.org/3379
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If7cc6a966dfc17d37e22338ecc1f239f908a9f2e
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: modify USSD structures to support external handling

2017-07-29 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/3374

gsm0480: modify USSD structures to support external handling

This change adds the following new fields to ss_request struct:

  - message_type - GSM 04.80 Chapter 2.2
  - component_type - GSM 04.80 Chapter 3.6.2
  - error_code - GSM 04.80 Chapter 3.6.6
  - problem_code - GSM 04.80 Chapter 3.6.7
  - ussd_text_language
  - ussd_text_len

Also, the MAX_LEN_USSD_STRING was increased to 182.

Change-Id: I5f8972b86cd4dcb54b643a24b5794a87c8758073
---
M include/osmocom/gsm/gsm0480.h
M src/gsm/gsm0480.c
2 files changed, 33 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/74/3374/1

diff --git a/include/osmocom/gsm/gsm0480.h b/include/osmocom/gsm/gsm0480.h
index 672ffe5..e3b15d2 100644
--- a/include/osmocom/gsm/gsm0480.h
+++ b/include/osmocom/gsm/gsm0480.h
@@ -7,7 +7,7 @@
 #include 
 #include 
 
-#define MAX_LEN_USSD_STRING31
+#define MAX_LEN_USSD_STRING182
 
 /* deprecated */
 struct ussd_request {
@@ -21,11 +21,31 @@
struct ussd_request *request) 
OSMO_DEPRECATED("Use gsm0480_decode_ss_request() instead");
 
 struct ss_request {
-   uint8_t opcode;
-   uint8_t ss_code;
-   uint8_t ussd_text[MAX_LEN_USSD_STRING + 1];
+   /*! L3 transaction ID */
uint8_t transaction_id;
+   /*! Message type2.2   */
+   uint8_t message_type;
+
+   /*! Component type  3.6.2 */
+   uint8_t component_type;
+   /*! Invoke id   3.6.3 */
uint8_t invoke_id;
+
+   union {
+   /*! Operational code3.6.4 */
+   uint8_t opcode;
+   /*! Error code  3.6.6 */
+   uint8_t error_code;
+   /*! Problem code3.6.7 */
+   uint8_t problem_code;
+   };
+
+   uint8_t ussd_text_len;
+   uint8_t ussd_text_language;
+   uint8_t ussd_text[MAX_LEN_USSD_STRING + 1];
+
+   /*! Parameters of a Interrogate/Activate/DeactivateSS Request */
+   uint8_t ss_code;
 };
 
 int gsm0480_decode_ss_request(const struct gsm48_hdr *hdr, uint16_t len,
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 38693d4..1c01e64 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -264,6 +264,7 @@
int rc = 1;
uint8_t msg_type = hdr->msg_type & 0x3F;  /* message-type - section 3.4 
*/
 
+   req->message_type = msg_type;
switch (msg_type) {
case GSM0480_MTYPE_RELEASE_COMPLETE:
LOGP(0, LOGL_DEBUG, "SS Release Complete\n");
@@ -333,6 +334,8 @@
LOGP(0, LOGL_ERROR, "Component does not fit.\n");
return 0;
}
+
+   req->component_type = component_type;
 
switch (component_type) {
case GSM0480_CTYPE_INVOKE:
@@ -443,9 +446,12 @@
/* Prevent a mobile-originated buffer-overrun! 
*/
if (num_chars > MAX_LEN_USSD_STRING)
num_chars = MAX_LEN_USSD_STRING;
-   gsm_7bit_decode_n_ussd((char *)req->ussd_text,
-   sizeof(req->ussd_text),
-   &(uss_req_data[7]), 
num_chars);
+
+   num_chars = gsm_7bit_decode_n_ussd((char 
*)req->ussd_text,
+   sizeof(req->ussd_text), 
&(uss_req_data[7]), num_chars);
+
+   req->ussd_text_language = 0x80;
+   req->ussd_text_len = num_chars;
rc = 1;
}
}

-- 
To view, visit https://gerrit.osmocom.org/3374
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f8972b86cd4dcb54b643a24b5794a87c8758073
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 


[PATCH] libosmocore[master]: gsm0480: drop length check in gsm0480_decode_ss_request()

2017-07-29 Thread Vadim Yanitskiy

Review at  https://gerrit.osmocom.org/3373

gsm0480: drop length check in gsm0480_decode_ss_request()

According to GSM 04.80 Section 2.5 'Release complete' Table 2.5,
the 'RELEASE COMPLETE' message payload is optional, so let's drop
length check in gsm0480_decode_ss_request().

Change-Id: I63b7f8ce403169a9dbdbdb031db16693de2196d6
---
M src/gsm/gsm0480.c
1 file changed, 0 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/73/3373/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 557aa14..38693d4 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -248,12 +248,6 @@
struct ss_request *req)
 {
int rc = 0;
-
-   if (len < sizeof(*hdr) + 2) {
-   LOGP(0, LOGL_DEBUG, "SS Request is too short.\n");
-   return 0;
-   }
-
if (gsm48_hdr_pdisc(hdr) == GSM48_PDISC_NC_SS) {
req->transaction_id = hdr->proto_discr & 0x70;
rc = parse_ss(hdr, len, req);

-- 
To view, visit https://gerrit.osmocom.org/3373
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I63b7f8ce403169a9dbdbdb031db16693de2196d6
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy