lists.osmocom.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
August
July
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
List overview
Download
OpenBSC
May 2016
----- 2025 -----
August 2025
July 2025
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
openbsc@lists.osmocom.org
25 participants
165 discussions
Start a n
N
ew thread
[PATCH] osmo-pcu[master]: RFC: remove this == NULL checks
by lynxis lazus
Review at
https://gerrit.osmocom.org/136
RFC: remove this == NULL checks The compile should ensure that this == NULL should never happen Change-Id: Ifddaef70bb0a4402050c817b1000d515c3a7118b --- M src/llc.h M src/tbf.cpp 2 files changed, 2 insertions(+), 5 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/36/136/1 diff --git a/src/llc.h b/src/llc.h index 94de16e..4883624 100644 --- a/src/llc.h +++ b/src/llc.h @@ -127,10 +127,10 @@ inline size_t gprs_llc_queue::size() const { - return this ? m_queue_size : 0; + return m_queue_size; } inline size_t gprs_llc_queue::octets() const { - return this ? m_queue_octets : 0; + return m_queue_octets; } diff --git a/src/tbf.cpp b/src/tbf.cpp index 69b9e3a..51705e2 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -1181,9 +1181,6 @@ const char *gprs_rlcmac_tbf::name() const { - if (this == NULL) - return "(no TBF)"; - snprintf(m_name_buf, sizeof(m_name_buf) - 1, "TBF(TFI=%d TLLI=0x%08x DIR=%s STATE=%s%s)", m_tfi, tlli(), -- To view, visit
https://gerrit.osmocom.org/136
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: Ifddaef70bb0a4402050c817b1000d515c3a7118b Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
9 years, 2 months
4
4
0
0
Change in libosmocore[master]: add vty call show asciidoc: generate a documentation for cou...
by gerrit-no-reply@lists.osmocom.org
>From lynxis lazus <lynxis(a)fe80.eu>: lynxis lazus has uploaded a new change for review.
https://gerrit.osmocom.org/70
Change subject: add vty call show asciidoc: generate a documentation for counters ...................................................................... add vty call show asciidoc: generate a documentation for counters For each counter group a ascii doc table is generated containing all single counter with a reference to a section to add additional information to the counter Change-Id: Ia8af883167e5ee631059299b107ea83c8bbffdfb --- M src/vty/stats_vty.c 1 file changed, 111 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/70/70/1 diff --git a/src/vty/stats_vty.c b/src/vty/stats_vty.c index e0239bf..2193e70 100644 --- a/src/vty/stats_vty.c +++ b/src/vty/stats_vty.c @@ -33,6 +33,8 @@ #include <osmocom/vty/misc.h> #include <osmocom/core/stats.h> +#include <osmocom/core/statistics.h> +#include <osmocom/core/rate_ctr.h> #define CFG_STATS_STR "Configure stats sub-system\n" #define CFG_REPORTER_STR "Configure a stats reporter\n" @@ -355,6 +357,113 @@ return CMD_SUCCESS; } +static int ascii_handle_counter(struct osmo_counter *counter, void *sctx_) +{ + struct vty *vty = sctx_; + const char *description = counter->description ? counter->description : ""; + + /* | name | This document & | description | */ + vty_out(vty, "| %s | <<ungroup_counter_%s>> | %s%s", + counter->name, + counter->name, + description, + VTY_NEWLINE); + + return 0; +} + +static void ascii_counter_generate(struct vty *vty) +{ + vty_out(vty, "// ungrouped osmo_counters%s", VTY_NEWLINE); + vty_out(vty, ".ungrouped osmo counters%s", VTY_NEWLINE); + vty_out(vty, "|===%s", VTY_NEWLINE); + vty_out(vty, "| name | This document & | description%s", VTY_NEWLINE); + osmo_counters_for_each(ascii_handle_counter, vty); + vty_out(vty, "|===%s", VTY_NEWLINE); +} + +static int asciidoc_rate_ctr_handler( + struct rate_ctr_group *ctrg, struct rate_ctr *ctr, + const struct rate_ctr_desc *desc, void *sctx_) +{ + struct vty *vty = sctx_; + const char *description = desc->description ? desc->description : ""; + + /* | name | This document & | description | */ + vty_out(vty, "| %s | <<%s_%s>> | %s%s", + desc->name, + ctrg->desc->group_name_prefix, + desc->name, + description, + VTY_NEWLINE); + return 0; +} + +static int asciidoc_rate_ctr_group_handler(struct rate_ctr_group *ctrg, void *sctx_) +{ + struct vty *vty = sctx_; + vty_out(vty, "// rate_ctr_group table %s%s", ctrg->desc->group_description, VTY_NEWLINE); + vty_out(vty, ".%s - %s %s", ctrg->desc->group_name_prefix, ctrg->desc->group_description, VTY_NEWLINE); + vty_out(vty, "|===%s", VTY_NEWLINE); + vty_out(vty, "| name | This document & | description%s", VTY_NEWLINE); + rate_ctr_for_each_counter(ctrg, asciidoc_rate_ctr_handler, sctx_); + vty_out(vty, "|===%s", VTY_NEWLINE); + + return 0; +} + +static int asciidoc_osmo_stat_item_handler( + struct osmo_stat_item_group *statg, struct osmo_stat_item *item, void *sctx_) +{ + struct vty *vty = sctx_; + + const char *description = item->desc->description ? item->desc->description : ""; + const char *unit = item->desc->unit ? item->desc->unit : ""; + + /* | name | This document & | description | unit | */ + vty_out(vty, "| %s | <<%s_%s>> | %s | %s%s", + item->desc->name, + statg->desc->group_name_prefix, + item->desc->name, + description, + unit, + VTY_NEWLINE); + + return 0; +} + +static int asciidoc_osmo_stat_item_group_handler(struct osmo_stat_item_group *statg, void *sctx_) +{ + struct vty *vty = sctx_; + vty_out(vty, "%s%s", statg->desc->group_description, VTY_NEWLINE); + + vty_out(vty, "// osmo_stat_item_group table %s%s", statg->desc->group_description, VTY_NEWLINE); + vty_out(vty, ".%s - %s %s", statg->desc->group_name_prefix, statg->desc->group_description, VTY_NEWLINE); + vty_out(vty, "|===%s", VTY_NEWLINE); + vty_out(vty, "| name | This document & | description | unit%s", VTY_NEWLINE); + osmo_stat_item_for_each_item(statg, asciidoc_osmo_stat_item_handler, sctx_); + vty_out(vty, "|===%s", VTY_NEWLINE); + + + return 0; +} + +DEFUN(show_stats_asciidoc_table, + show_stats_asciidoc_table_cmd, + "show asciidoc", + "Generate an ascii doc table of all registered counters.\n") +{ + vty_out(vty, "// generating tables for rate_ctr_group%s", VTY_NEWLINE); + rate_ctr_for_each_group(asciidoc_rate_ctr_group_handler, vty); + + vty_out(vty, "// generating tables for osmo_stat_items%s", VTY_NEWLINE); + osmo_stat_item_for_each_group(asciidoc_osmo_stat_item_group_handler, vty); + + vty_out(vty, "// generating tables for osmo_counters%s", VTY_NEWLINE); + ascii_counter_generate(vty); + return CMD_SUCCESS; +} + static int config_write_stats_reporter(struct vty *vty, struct osmo_stats_reporter *srep) { if (srep == NULL) @@ -443,4 +552,6 @@ install_element(CFG_STATS_NODE, &cfg_stats_reporter_level_cmd); install_element(CFG_STATS_NODE, &cfg_stats_reporter_enable_cmd); install_element(CFG_STATS_NODE, &cfg_stats_reporter_disable_cmd); + + install_element_ve(&show_stats_asciidoc_table_cmd); } -- To view, visit
https://gerrit.osmocom.org/70
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: Ia8af883167e5ee631059299b107ea83c8bbffdfb Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
9 years, 2 months
4
6
0
0
[PATCH] osmo-pcu[master]: add KPI counter to count bytes for RLC and LLC frames
by lynxis lazus
Review at
https://gerrit.osmocom.org/145
add KPI counter to count bytes for RLC and LLC frames rlc.dl_bytes bytes before sending rlc rlc.dl_payload_bytes count data w/o LI rlc.ul_bytes bytes when received rlc (only valid) rlc.ul_payload_bytes count data fragments w/o LI llc.dl_bytes complete encapsulated LLC PDUs llc.ul_bytes complete received LLC PDUs Change-Id: I9a98a5a375d39b3f4990360056c4d6145e755f4d --- M src/bts.cpp M src/bts.h M src/gprs_rlcmac_sched.cpp M src/tbf_dl.cpp M src/tbf_ul.cpp 5 files changed, 41 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/45/145/1 diff --git a/src/bts.cpp b/src/bts.cpp index 953ac4d..9e91b87 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -73,6 +73,10 @@ { "rlc.late-block", "RLC Late Block "}, { "rlc.sent-dummy", "RLC Sent Dummy "}, { "rlc.sent-control", "RLC Sent Control "}, + { "rlc.dl_bytes", "RLC DL Bytes "}, + { "rlc.dl_payload_bytes", "RLC DL Payload Bytes "}, + { "rlc.ul_bytes", "RLC UL Bytes "}, + { "rlc.ul_payload_bytes", "RLC UL Payload Bytes "}, { "decode.errors", "Decode Errors "}, { "sba.allocated", "SBA Allocated "}, { "sba.freed", "SBA Freed "}, @@ -80,6 +84,8 @@ { "llc.timeout", "Timedout Frames "}, { "llc.dropped", "Dropped Frames "}, { "llc.scheduled", "Scheduled Frames "}, + { "llc.dl_bytes", "RLC encapsulated PDUs"}, + { "llc.ul_bytes", "full PDUs received "}, { "rach.requests", "RACH requests "}, }; @@ -1302,6 +1308,8 @@ return -EINVAL; } + bts()->rlc_ul_bytes(len); + LOGP(DRLCMACUL, LOGL_DEBUG, "Got RLC block, coding scheme: %s, " "length: %d (%d))\n", cs.name(), len, cs.usedSizeUL()); diff --git a/src/bts.h b/src/bts.h index 35f24d1..a713c46 100644 --- a/src/bts.h +++ b/src/bts.h @@ -235,6 +235,10 @@ CTR_RLC_LATE_BLOCK, CTR_RLC_SENT_DUMMY, CTR_RLC_SENT_CONTROL, + CTR_RLC_DL_BYTES, + CTR_RLC_DL_PAYLOAD_BYTES, + CTR_RLC_UL_BYTES, + CTR_RLC_UL_PAYLOAD_BYTES, CTR_DECODE_ERRORS, CTR_SBA_ALLOCATED, CTR_SBA_FREED, @@ -242,6 +246,8 @@ CTR_LLC_FRAME_TIMEDOUT, CTR_LLC_FRAME_DROPPED, CTR_LLC_FRAME_SCHED, + CTR_LLC_DL_BYTES, + CTR_LLC_UL_BYTES, CTR_RACH_REQUESTS, }; @@ -313,6 +319,10 @@ void rlc_late_block(); void rlc_sent_dummy(); void rlc_sent_control(); + void rlc_dl_bytes(int bytes); + void rlc_dl_payload_bytes(int bytes); + void rlc_ul_bytes(int bytes); + void rlc_ul_payload_bytes(int bytes); void decode_error(); void sba_allocated(); void sba_freed(); @@ -320,6 +330,8 @@ void llc_timedout_frame(); void llc_dropped_frame(); void llc_frame_sched(); + void llc_dl_bytes(int bytes); + void llc_ul_bytes(int bytes); void rach_frame(); void ms_present(int32_t n); @@ -427,6 +439,11 @@ return m_statg; } +#define CREATE_COUNT_ADD_INLINE(func_name, ctr_name) \ + inline void BTS::func_name(int inc) {\ + rate_ctr_add(&m_ratectrs->ctr[ctr_name], inc); \ + } + #define CREATE_COUNT_INLINE(func_name, ctr_name) \ inline void BTS::func_name() {\ rate_ctr_inc(&m_ratectrs->ctr[ctr_name]); \ @@ -455,6 +472,10 @@ CREATE_COUNT_INLINE(rlc_late_block, CTR_RLC_LATE_BLOCK); CREATE_COUNT_INLINE(rlc_sent_dummy, CTR_RLC_SENT_DUMMY); CREATE_COUNT_INLINE(rlc_sent_control, CTR_RLC_SENT_CONTROL); +CREATE_COUNT_ADD_INLINE(rlc_dl_bytes, CTR_RLC_DL_BYTES); +CREATE_COUNT_ADD_INLINE(rlc_dl_payload_bytes, CTR_RLC_DL_PAYLOAD_BYTES); +CREATE_COUNT_ADD_INLINE(rlc_ul_bytes, CTR_RLC_UL_BYTES); +CREATE_COUNT_ADD_INLINE(rlc_ul_payload_bytes, CTR_RLC_UL_PAYLOAD_BYTES); CREATE_COUNT_INLINE(decode_error, CTR_DECODE_ERRORS) CREATE_COUNT_INLINE(sba_allocated, CTR_SBA_ALLOCATED) CREATE_COUNT_INLINE(sba_freed, CTR_SBA_FREED) @@ -462,6 +483,8 @@ CREATE_COUNT_INLINE(llc_timedout_frame, CTR_LLC_FRAME_TIMEDOUT); CREATE_COUNT_INLINE(llc_dropped_frame, CTR_LLC_FRAME_DROPPED); CREATE_COUNT_INLINE(llc_frame_sched, CTR_LLC_FRAME_SCHED); +CREATE_COUNT_ADD_INLINE(llc_dl_bytes, CTR_LLC_DL_BYTES); +CREATE_COUNT_ADD_INLINE(llc_ul_bytes, CTR_LLC_UL_BYTES); CREATE_COUNT_INLINE(rach_frame, CTR_RACH_REQUESTS); #undef CREATE_COUNT_INLINE diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp index fce3aaf..0367ad0 100644 --- a/src/gprs_rlcmac_sched.cpp +++ b/src/gprs_rlcmac_sched.cpp @@ -360,6 +360,7 @@ if (!msg) return -ENOMEM; /* msg is now available */ + bts->bts->rlc_dl_bytes(msg->data_len); /* set USF */ OSMO_ASSERT(msgb_length(msg) > 0); diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index 66f747b..5931676 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -513,6 +513,7 @@ do { bool is_final; + int payload_written = 0; if (m_llc.frame_length() == 0) { /* nothing to sent - delay the release of the TBF */ @@ -540,7 +541,10 @@ is_final = llc_queue()->size() == 0 && !keep_open(fn); ar = Encoding::rlc_data_to_dl_append(rdbi, cs, - &m_llc, &write_offset, &num_chunks, data, is_final, NULL); + &m_llc, &write_offset, &num_chunks, data, is_final, &payload_written); + + if (payload_written > 0) + bts->rlc_dl_payload_bytes(payload_written); if (ar == Encoding::AR_NEED_MORE_BLOCKS) break; @@ -548,6 +552,7 @@ LOGP(DRLCMACDL, LOGL_INFO, "Complete DL frame for %s" "len=%d\n", tbf_name(this), m_llc.frame_length()); gprs_rlcmac_dl_bw(this, m_llc.frame_length()); + bts->llc_dl_bytes(m_llc.frame_length()); m_llc.reset(); if (is_final) { diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp index e7c64ad..98962d1 100644 --- a/src/tbf_ul.cpp +++ b/src/tbf_ul.cpp @@ -67,6 +67,8 @@ for (i = 0; i < num_frames; i++) { frame = frames + i; + bts->rlc_ul_payload_bytes(frame->length); + LOGP(DRLCMACUL, LOGL_DEBUG, "-- Frame %d starts at offset %d, " "length=%d, is_complete=%d\n", i + 1, frame->offset, frame->length, frame->is_complete); @@ -79,6 +81,7 @@ LOGP(DRLCMACUL, LOGL_INFO, "%s complete UL frame len=%d\n", tbf_name(this) , m_llc.frame_length()); snd_ul_ud(); + bts->llc_ul_bytes(m_llc.frame_length()); m_llc.reset(); } } -- To view, visit
https://gerrit.osmocom.org/145
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I9a98a5a375d39b3f4990360056c4d6145e755f4d Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
9 years, 2 months
3
4
0
0
[PATCH] osmo-pcu[master]: decoding: remove superfluous double-semicolon
by lynxis lazus
Review at
https://gerrit.osmocom.org/140
decoding: remove superfluous double-semicolon Change-Id: I48ec24f2e10620279cbcbf39c70a4be6438f6b0f --- M src/decoding.cpp 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/40/140/1 diff --git a/src/decoding.cpp b/src/decoding.cpp index 5f64ac0..2600879 100644 --- a/src/decoding.cpp +++ b/src/decoding.cpp @@ -267,7 +267,7 @@ * so drop it (this may happen with EGPRS since * there is no M flag. */ num_chunks -= 1; - break;; + break; } chunks[i].length = data_len - offs; } -- To view, visit
https://gerrit.osmocom.org/140
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I48ec24f2e10620279cbcbf39c70a4be6438f6b0f Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
9 years, 2 months
2
2
0
0
[PATCH] osmo-pcu[master]: rlc.h: correct gprs_rlc_data comment
by lynxis lazus
Review at
https://gerrit.osmocom.org/144
rlc.h: correct gprs_rlc_data comment It's the block data, not the history. Also add including LI headers. Change-Id: Id4d99d1d21c7fa372771fd569d87bbcf2c6b6d22 --- M src/rlc.h 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/44/144/1 diff --git a/src/rlc.h b/src/rlc.h index 03659da..ad10b3a 100644 --- a/src/rlc.h +++ b/src/rlc.h @@ -113,9 +113,9 @@ uint8_t *prepare(size_t block_data_length); void put_data(const uint8_t *data, size_t len); - /* block history */ + /* block data including LI headers */ uint8_t block[RLC_MAX_LEN]; - /* block len of history */ + /* block data len including LI headers*/ uint8_t len; struct gprs_rlc_data_block_info block_info; -- To view, visit
https://gerrit.osmocom.org/144
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: Id4d99d1d21c7fa372771fd569d87bbcf2c6b6d22 Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
9 years, 2 months
2
2
0
0
[PATCH] openbsc[master]: create_pdp_conf(): factor out PDP context accept dispatch as...
by Neels Hofmeyr
Review at
https://gerrit.osmocom.org/159
create_pdp_conf(): factor out PDP context accept dispatch as send_act_pdp_cont_acc() Change-Id: Ibf60e18707ff4aa2e60291e5595386ddda8d8190 --- M openbsc/src/gprs/sgsn_libgtp.c 1 file changed, 14 insertions(+), 9 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/59/159/1 diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index f7a4ca0..504590b 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -304,10 +304,22 @@ { 0, 0 } }; +static int send_act_pdp_cont_acc(struct sgsn_pdp_ctx *pctx) +{ + struct sgsn_signal_data sig_data; + + /* Inform others about it */ + memset(&sig_data, 0, sizeof(sig_data)); + sig_data.pdp = pctx; + osmo_signal_dispatch(SS_SGSN, S_SGSN_PDP_ACT, &sig_data); + + /* Send PDP CTX ACT to MS */ + return gsm48_tx_gsm_act_pdp_acc(pctx); +} + /* The GGSN has confirmed the creation of a PDP Context */ static int create_pdp_conf(struct pdp_t *pdp, void *cbp, int cause) { - struct sgsn_signal_data sig_data; struct sgsn_pdp_ctx *pctx = cbp; uint8_t reject_cause; @@ -342,14 +354,7 @@ /* Activate the SNDCP layer */ sndcp_sm_activate_ind(&pctx->mm->gb.llme->lle[pctx->sapi], pctx->nsapi); - - /* Inform others about it */ - memset(&sig_data, 0, sizeof(sig_data)); - sig_data.pdp = pctx; - osmo_signal_dispatch(SS_SGSN, S_SGSN_PDP_ACT, &sig_data); - - /* Send PDP CTX ACT to MS */ - return gsm48_tx_gsm_act_pdp_acc(pctx); + return send_act_pdp_cont_acc(pctx); reject: /* -- To view, visit
https://gerrit.osmocom.org/159
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: Ibf60e18707ff4aa2e60291e5595386ddda8d8190 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
9 years, 2 months
2
2
0
0
[PATCH] openbsc[master]: prepare sgsn_mm_ctx for Gb and Iu mode (UMTS)
by Neels Hofmeyr
Review at
https://gerrit.osmocom.org/158
prepare sgsn_mm_ctx for Gb and Iu mode (UMTS) Explicitly mark those sgsn_mm_ctx members that apply for Gb mode and (upcoming) Iu mode, respectively. Add some comments in sgsn_mm_ctx. Change-Id: Ife9b02549f284e2547f16117cf43d7a36948fc4b Tweaked-By: Neels Hofmeyr <nhofmeyr(a)sysmocom.de> --- M openbsc/include/openbsc/gprs_sgsn.h M openbsc/src/gprs/gprs_gmm.c M openbsc/src/gprs/gprs_llc.c M openbsc/src/gprs/gprs_sgsn.c M openbsc/src/gprs/sgsn_cdr.c M openbsc/src/gprs/sgsn_libgtp.c M openbsc/src/gprs/sgsn_vty.c M openbsc/tests/sgsn/sgsn_test.c 8 files changed, 135 insertions(+), 86 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/58/158/1 diff --git a/openbsc/include/openbsc/gprs_sgsn.h b/openbsc/include/openbsc/gprs_sgsn.h index 5fbbf28..0e574d8 100644 --- a/openbsc/include/openbsc/gprs_sgsn.h +++ b/openbsc/include/openbsc/gprs_sgsn.h @@ -92,10 +92,28 @@ uint8_t ti; }; +enum sgsn_ran_type { + /* GPRS/EDGE via Gb */ + MM_CTX_T_GERAN_Gb, + /* UMTS via Iu */ + MM_CTX_T_UTRAN_Iu, + /* GPRS/EDGE via Iu */ + MM_CTX_T_GERAN_Iu, +}; + +struct service_info { + uint8_t type; + uint16_t pdp_status; +}; + +struct ue_conn_ctx; + /* According to TS 03.60, Table 5: SGSN MM and PDP Contexts */ /* Extended by 3GPP TS 23.060, Table 6: SGSN MM and PDP Contexts */ struct sgsn_mm_ctx { struct llist_head list; + + enum sgsn_ran_type ran_type; char imsi[GSM23003_IMSI_MAX_DIGITS+1]; enum gprs_gmm_state mm_state; @@ -106,10 +124,32 @@ /* Opt: Software Version Numbber / TS 23.195 */ char msisdn[GSM_EXTENSION_LENGTH]; struct gprs_ra_id ra; - uint16_t cell_id; - uint32_t cell_id_age; - uint16_t sac; /* Iu: Service Area Code */ - uint32_t sac_age;/* Iu: Service Area Code age */ + struct { + uint16_t cell_id; /* Gb only */ + uint32_t cell_id_age; /* Gb only */ + uint8_t radio_prio_sms; + + /* Additional bits not present in the GSM TS */ + uint16_t nsei; + uint16_t bvci; + struct gprs_llc_llme *llme; + uint32_t tlli; + uint32_t tlli_new; + } gb; + struct { + int new_key; + uint16_t sac; /* Iu: Service Area Code */ + uint32_t sac_age; /* Iu: Service Area Code age */ + /* CSG ID */ + /* CSG Membership */ + /* Access Mode */ + /* Seelected CN Operator ID (TS 23.251) */ + /* CSG Subscription Data */ + /* LIPA Allowed */ + /* Voice Support Match Indicator */ + struct ue_conn_ctx *ue_ctx; + struct service_info service; + } iu; /* VLR number */ uint32_t new_sgsn_addr; /* Authentication Triplet */ @@ -118,30 +158,38 @@ /* Iu: CK, IK, KSI */ /* CKSN */ enum gprs_ciph_algo ciph_algo; + struct { uint8_t len; uint8_t buf[50]; /* GSM 04.08 10.5.5.12a, extended in TS 24.008 */ } ms_radio_access_capa; + /* Supported Codecs (SRVCC) */ struct { uint8_t len; uint8_t buf[8]; /* GSM 04.08 10.5.5.12, extended in TS 24.008 */ } ms_network_capa; + /* UE Netowrk Capability (E-UTRAN) */ uint16_t drx_parms; + /* Active Time value for PSM */ int mnrg; /* MS reported to HLR? */ int ngaf; /* MS reported to MSC/VLR? */ int ppf; /* paging for GPRS + non-GPRS? */ + /* Subscribed Charging Characteristics */ + /* Trace Reference */ + /* Trace Type */ + /* Trigger ID */ + /* OMC Identity */ /* SMS Parameters */ int recovery; - uint8_t radio_prio_sms; + /* Access Restriction */ + /* GPRS CSI (CAMEL) */ + /* MG-CSI (CAMEL) */ + /* Subscribed UE-AMBR */ + /* UE-AMBR */ + /* APN Subscribed */ struct llist_head pdp_list; - /* Additional bits not present in the GSM TS */ - struct gprs_llc_llme *llme; - uint32_t tlli; - uint32_t tlli_new; - uint16_t nsei; - uint16_t bvci; struct rate_ctr_group *ctrg; struct osmo_timer_list timer; unsigned int T; /* Txxxx number */ diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index 2bbc5ff..889ac98 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -151,16 +151,16 @@ /* Store BVCI/NSEI in MM context */ static void msgid2mmctx(struct sgsn_mm_ctx *mm, const struct msgb *msg) { - mm->bvci = msgb_bvci(msg); - mm->nsei = msgb_nsei(msg); + mm->gb.bvci = msgb_bvci(msg); + mm->gb.nsei = msgb_nsei(msg); } /* Store BVCI/NSEI in MM context */ static void mmctx2msgid(struct msgb *msg, const struct sgsn_mm_ctx *mm) { - msgb_tlli(msg) = mm->tlli; - msgb_bvci(msg) = mm->bvci; - msgb_nsei(msg) = mm->nsei; + msgb_tlli(msg) = mm->gb.tlli; + msgb_bvci(msg) = mm->gb.bvci; + msgb_nsei(msg) = mm->gb.nsei; } static void mm_ctx_cleanup_free(struct sgsn_mm_ctx *ctx, const char *log_text) @@ -904,8 +904,8 @@ strncpy(ctx->imsi, mi_string, sizeof(ctx->imsi) - 1); #endif } - ctx->tlli = msgb_tlli(msg); - ctx->llme = llme; + ctx->gb.tlli = msgb_tlli(msg); + ctx->gb.llme = llme; msgid2mmctx(ctx, msg); break; case GSM_MI_TYPE_TMSI: @@ -920,8 +920,8 @@ ctx = sgsn_mm_ctx_alloc(msgb_tlli(msg), &ra_id); ctx->p_tmsi = tmsi; } - ctx->tlli = msgb_tlli(msg); - ctx->llme = llme; + ctx->gb.tlli = msgb_tlli(msg); + ctx->gb.llme = llme; msgid2mmctx(ctx, msg); break; default: @@ -932,7 +932,7 @@ } /* Update MM Context with currient RA and Cell ID */ ctx->ra = ra_id; - ctx->cell_id = cid; + ctx->gb.cell_id = cid; /* Update MM Context with other data */ ctx->drx_parms = drx_par; ctx->ms_radio_access_capa.len = ms_ra_acc_cap_len; @@ -952,10 +952,10 @@ #endif /* Even if there is no P-TMSI allocated, the MS will switch from * foreign TLLI to local TLLI */ - ctx->tlli_new = gprs_tmsi2tlli(ctx->p_tmsi, TLLI_LOCAL); + ctx->gb.tlli_new = gprs_tmsi2tlli(ctx->p_tmsi, TLLI_LOCAL); /* Inform LLC layer about new TLLI but keep old active */ - gprs_llgmm_assign(ctx->llme, ctx->tlli, ctx->tlli_new, + gprs_llgmm_assign(ctx->gb.llme, ctx->gb.tlli, ctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); ctx->pending_req = GSM48_MT_GMM_ATTACH_REQ; @@ -1182,7 +1182,7 @@ "TLLI: %08x (%08x), RA: %d-%d-%d-%d\n", msgb_tlli(msg), mmctx->p_tmsi, mmctx->p_tmsi_old, - mmctx->tlli, mmctx->tlli_new, + mmctx->gb.tlli, mmctx->gb.tlli_new, mmctx->ra.mcc, mmctx->ra.mnc, mmctx->ra.lac, mmctx->ra.rac); @@ -1219,7 +1219,7 @@ /* Update the MM context with the new RA-ID */ bssgp_parse_cell_id(&mmctx->ra, msgb_bcid(msg)); /* Update the MM context with the new (i.e. foreign) TLLI */ - mmctx->tlli = msgb_tlli(msg); + mmctx->gb.tlli = msgb_tlli(msg); /* FIXME: Update the MM context with the MS radio acc capabilities */ /* FIXME: Update the MM context with the MS network capabilities */ @@ -1246,10 +1246,10 @@ #endif /* Even if there is no P-TMSI allocated, the MS will switch from * foreign TLLI to local TLLI */ - mmctx->tlli_new = gprs_tmsi2tlli(mmctx->p_tmsi, TLLI_LOCAL); + mmctx->gb.tlli_new = gprs_tmsi2tlli(mmctx->p_tmsi, TLLI_LOCAL); /* Inform LLC layer about new TLLI but keep old active */ - gprs_llgmm_assign(mmctx->llme, mmctx->tlli, mmctx->tlli_new, + gprs_llgmm_assign(mmctx->gb.llme, mmctx->gb.tlli, mmctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); /* Look at PDP Context Status IE and see if MS's view of @@ -1369,8 +1369,8 @@ mmctx->p_tmsi_old = 0; mmctx->pending_req = 0; /* Unassign the old TLLI */ - mmctx->tlli = mmctx->tlli_new; - gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new, + mmctx->gb.tlli = mmctx->gb.tlli_new; + gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); mmctx->mm_state = GMM_REGISTERED_NORMAL; rc = 0; @@ -1387,8 +1387,8 @@ mmctx->p_tmsi_old = 0; mmctx->pending_req = 0; /* Unassign the old TLLI */ - mmctx->tlli = mmctx->tlli_new; - gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new, + mmctx->gb.tlli = mmctx->gb.tlli_new; + gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); mmctx->mm_state = GMM_REGISTERED_NORMAL; rc = 0; @@ -1404,8 +1404,8 @@ mmctx->p_tmsi_old = 0; mmctx->pending_req = 0; /* Unassign the old TLLI */ - mmctx->tlli = mmctx->tlli_new; - //gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new, GPRS_ALGO_GEA0, NULL); + mmctx->gb.tlli = mmctx->gb.tlli_new; + //gprs_llgmm_assign(mmctx->gb.llme, 0xffffffff, mmctx->gb.tlli_new, GPRS_ALGO_GEA0, NULL); rc = 0; break; case GSM48_MT_GMM_AUTH_CIPH_RESP: @@ -2077,7 +2077,7 @@ int gsm0408_gprs_force_reattach(struct sgsn_mm_ctx *mmctx) { int rc; - gprs_llgmm_reset(mmctx->llme); + gprs_llgmm_reset(mmctx->gb.llme); rc = gsm48_tx_gmm_detach_req( mmctx, GPRS_DET_T_MT_REATT_REQ, GMM_CAUSE_IMPL_DETACHED); @@ -2101,7 +2101,7 @@ if (mmctx) { msgid2mmctx(mmctx, msg); rate_ctr_inc(&mmctx->ctrg->ctr[GMM_CTR_PKTS_SIG_IN]); - mmctx->llme = llme; + mmctx->gb.llme = llme; } /* MMCTX can be NULL */ diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c index 4cf5163..3a45f62 100644 --- a/openbsc/src/gprs/gprs_llc.c +++ b/openbsc/src/gprs/gprs_llc.c @@ -56,8 +56,8 @@ dup.ms_ra_cap.v = mmctx->ms_radio_access_capa.buf; /* make sure we only send it to the right llme */ - OSMO_ASSERT(msgb_tlli(msg) == mmctx->llme->tlli - || msgb_tlli(msg) == mmctx->llme->old_tlli); + OSMO_ASSERT(msgb_tlli(msg) == mmctx->gb.llme->tlli + || msgb_tlli(msg) == mmctx->gb.llme->old_tlli); } memcpy(&dup.qos_profile, qos_profile_default, sizeof(qos_profile_default)); diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c index 65f789d..8bb6850 100644 --- a/openbsc/src/gprs/gprs_sgsn.c +++ b/openbsc/src/gprs/gprs_sgsn.c @@ -97,7 +97,7 @@ struct sgsn_mm_ctx *ctx; llist_for_each_entry(ctx, &sgsn_mm_ctxts, list) { - if ((tlli == ctx->tlli || tlli == ctx->tlli_new) && + if ((tlli == ctx->gb.tlli || tlli == ctx->gb.tlli_new) && gprs_ra_id_equals(raid, &ctx->ra)) return ctx; } @@ -165,7 +165,8 @@ return NULL; memcpy(&ctx->ra, raid, sizeof(ctx->ra)); - ctx->tlli = tlli; + ctx->ran_type = MM_CTX_T_GERAN_Gb; + ctx->gb.tlli = tlli; ctx->mm_state = GMM_DEREGISTERED; ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL; ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, tlli); @@ -196,8 +197,8 @@ void sgsn_mm_ctx_cleanup_free(struct sgsn_mm_ctx *mm) { - struct gprs_llc_llme *llme = mm->llme; - uint32_t tlli = mm->tlli; + struct gprs_llc_llme *llme = mm->gb.llme; + uint32_t tlli = mm->gb.tlli; struct sgsn_pdp_ctx *pdp, *pdp2; struct sgsn_signal_data sig_data; @@ -308,7 +309,7 @@ LOGPDPCTXP(LOGL_INFO, pdp, "Forcing release of PDP context\n"); /* Force the deactivation of the SNDCP layer */ - sndcp_sm_deactivate_ind(&pdp->mm->llme->lle[pdp->sapi], pdp->nsapi); + sndcp_sm_deactivate_ind(&pdp->mm->gb.llme->lle[pdp->sapi], pdp->nsapi); memset(&sig_data, 0, sizeof(sig_data)); sig_data.pdp = pdp; @@ -751,7 +752,7 @@ struct sgsn_mm_ctx *mmctx = NULL; llist_for_each_entry(mmctx, &sgsn_mm_ctxts, list) { - if (llme == mmctx->llme) { + if (llme == mmctx->gb.llme) { gsm0408_gprs_access_cancelled(mmctx, SGSN_ERROR_CAUSE_NONE); return; } diff --git a/openbsc/src/gprs/sgsn_cdr.c b/openbsc/src/gprs/sgsn_cdr.c index d0cb712..bf0d6f7 100644 --- a/openbsc/src/gprs/sgsn_cdr.c +++ b/openbsc/src/gprs/sgsn_cdr.c @@ -94,7 +94,7 @@ mmctx->imsi, mmctx->imei, mmctx->msisdn, - mmctx->cell_id, + mmctx->gb.cell_id, mmctx->ra.lac, mmctx->hlr, ev); @@ -179,7 +179,7 @@ pdp->mm ? pdp->mm->imsi : "N/A", pdp->mm ? pdp->mm->imei : "N/A", pdp->mm ? pdp->mm->msisdn : "N/A", - pdp->mm ? pdp->mm->cell_id : -1, + pdp->mm ? pdp->mm->gb.cell_id : -1, pdp->mm ? pdp->mm->ra.lac : -1, pdp->mm ? pdp->mm->hlr : "N/A", ev, diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c index aaf7e7a..f7a4ca0 100644 --- a/openbsc/src/gprs/sgsn_libgtp.c +++ b/openbsc/src/gprs/sgsn_libgtp.c @@ -239,7 +239,7 @@ pdp->userloc_given = 1; pdp->userloc.l = 8; pdp->userloc.v[0] = 0; /* CGI for GERAN */ - bssgp_create_cell_id(&pdp->userloc.v[1], &mmctx->ra, mmctx->cell_id); + bssgp_create_cell_id(&pdp->userloc.v[1], &mmctx->ra, mmctx->gb.cell_id); /* include the IMEI(SV) */ pdp->imeisv_given = 1; @@ -341,7 +341,7 @@ } /* Activate the SNDCP layer */ - sndcp_sm_activate_ind(&pctx->mm->llme->lle[pctx->sapi], pctx->nsapi); + sndcp_sm_activate_ind(&pctx->mm->gb.llme->lle[pctx->sapi], pctx->nsapi); /* Inform others about it */ memset(&sig_data, 0, sizeof(sig_data)); @@ -388,7 +388,7 @@ if (pctx->mm) { /* Deactivate the SNDCP layer */ - sndcp_sm_deactivate_ind(&pctx->mm->llme->lle[pctx->sapi], pctx->nsapi); + sndcp_sm_deactivate_ind(&pctx->mm->gb.llme->lle[pctx->sapi], pctx->nsapi); /* Confirm deactivation of PDP context to MS */ rc = gsm48_tx_gsm_deact_pdp_acc(pctx); @@ -521,9 +521,9 @@ ud = msgb_put(msg, len); memcpy(ud, packet, len); - msgb_tlli(msg) = mm->tlli; - msgb_bvci(msg) = mm->bvci; - msgb_nsei(msg) = mm->nsei; + msgb_tlli(msg) = mm->gb.tlli; + msgb_bvci(msg) = mm->gb.bvci; + msgb_nsei(msg) = mm->gb.nsei; switch (mm->mm_state) { case GMM_REGISTERED_SUSPENDED: @@ -531,12 +531,12 @@ memset(&pinfo, 0, sizeof(pinfo)); pinfo.mode = BSSGP_PAGING_PS; pinfo.scope = BSSGP_PAGING_BVCI; - pinfo.bvci = mm->bvci; + pinfo.bvci = mm->gb.bvci; pinfo.imsi = mm->imsi; pinfo.ptmsi = &mm->p_tmsi; pinfo.drx_params = mm->drx_parms; pinfo.qos[0] = 0; // FIXME - bssgp_tx_paging(mm->nsei, 0, &pinfo); + bssgp_tx_paging(mm->gb.nsei, 0, &pinfo); rate_ctr_inc(&mm->ctrg->ctr[GMM_CTR_PAGING_PS]); /* FIXME: queue the packet we received from GTP */ break; @@ -544,7 +544,7 @@ break; default: LOGP(DGPRS, LOGL_ERROR, "GTP DATA IND for TLLI %08X in state " - "%u\n", mm->tlli, mm->mm_state); + "%u\n", mm->gb.tlli, mm->mm_state); msgb_free(msg); return -1; } @@ -557,7 +557,7 @@ /* It is easier to have a global count */ pdp->cdr_bytes_out += len; - return sndcp_unitdata_req(msg, &mm->llme->lle[pdp->sapi], + return sndcp_unitdata_req(msg, &mm->gb.llme->lle[pdp->sapi], pdp->nsapi, mm); } diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c index f16c95a..02c0f31 100644 --- a/openbsc/src/gprs/sgsn_vty.c +++ b/openbsc/src/gprs/sgsn_vty.c @@ -431,12 +431,12 @@ vty_out(vty, "%sMM Context for IMSI %s, IMEI %s, P-TMSI %08x%s", pfx, mm->imsi, mm->imei, mm->p_tmsi, VTY_NEWLINE); vty_out(vty, "%s MSISDN: %s, TLLI: %08x%s HLR: %s", - pfx, mm->msisdn, mm->tlli, mm->hlr, VTY_NEWLINE); + pfx, mm->msisdn, mm->gb.tlli, mm->hlr, VTY_NEWLINE); vty_out(vty, "%s MM State: %s, Routeing Area: %u-%u-%u-%u, " "Cell ID: %u%s", pfx, get_value_string(gprs_mm_st_strs, mm->mm_state), mm->ra.mcc, mm->ra.mnc, mm->ra.lac, mm->ra.rac, - mm->cell_id, VTY_NEWLINE); + mm->gb.cell_id, VTY_NEWLINE); vty_out_rate_ctr_group(vty, " ", mm->ctrg); diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c index afff30f..3fb359b 100644 --- a/openbsc/tests/sgsn/sgsn_test.c +++ b/openbsc/tests/sgsn/sgsn_test.c @@ -174,7 +174,7 @@ lle = gprs_lle_get_or_create(tlli, 3); ctx = sgsn_mm_ctx_alloc(tlli, raid); ctx->mm_state = GMM_REGISTERED_NORMAL; - ctx->llme = lle->llme; + ctx->gb.llme = lle->llme; ictx = sgsn_mm_ctx_by_tlli(tlli, raid); OSMO_ASSERT(ictx == ctx); @@ -729,7 +729,7 @@ ctx = alloc_mm_ctx(local_tlli, &raid); /* inject the detach */ - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, local_tlli, &raid, detach_req, ARRAY_SIZE(detach_req)); /* verify that a single message (hopefully the Detach Accept) has been @@ -770,7 +770,7 @@ ctx = alloc_mm_ctx(local_tlli, &raid); /* inject the detach */ - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, local_tlli, &raid, detach_req, ARRAY_SIZE(detach_req)); /* verify that no message (and therefore no Detach Accept) has been @@ -967,14 +967,14 @@ OSMO_ASSERT(sgsn_tx_counter == 1); /* inject the identity response (IMEI) */ - send_0408_message(ctx->llme, foreign_tlli, &raid, + send_0408_message(ctx->gb.llme, foreign_tlli, &raid, ident_resp_imei, ARRAY_SIZE(ident_resp_imei)); /* we expect an identity request (IMSI) */ OSMO_ASSERT(sgsn_tx_counter == 1); /* inject the identity response (IMSI) */ - send_0408_message(ctx->llme, foreign_tlli, &raid, + send_0408_message(ctx->gb.llme, foreign_tlli, &raid, ident_resp_imsi, ARRAY_SIZE(ident_resp_imsi)); /* check that the MM context has not been removed due to a failed @@ -996,7 +996,7 @@ /* we got an auth & ciph request */ /* inject the auth & ciph response */ - send_0408_message(ctx->llme, foreign_tlli, &raid, + send_0408_message(ctx->gb.llme, foreign_tlli, &raid, auth_ciph_resp, ARRAY_SIZE(auth_ciph_resp)); /* check that the MM context has not been removed due to a @@ -1018,7 +1018,7 @@ local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL); /* inject the attach complete */ - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, local_tlli, &raid, attach_compl, ARRAY_SIZE(attach_compl)); OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); @@ -1027,7 +1027,7 @@ OSMO_ASSERT(sgsn_tx_counter == 0); /* inject the detach */ - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, local_tlli, &raid, detach_req, ARRAY_SIZE(detach_req)); /* verify that things are gone */ @@ -1555,14 +1555,14 @@ OSMO_ASSERT(sgsn_tx_counter == 1); /* inject the identity response (IMEI) */ - send_0408_message(ctx->llme, foreign_tlli, &raid, + send_0408_message(ctx->gb.llme, foreign_tlli, &raid, ident_resp_imei, ARRAY_SIZE(ident_resp_imei)); /* we expect an identity request (IMSI) */ OSMO_ASSERT(sgsn_tx_counter == 1); /* inject the identity response (IMSI) */ - send_0408_message(ctx->llme, foreign_tlli, &raid, + send_0408_message(ctx->gb.llme, foreign_tlli, &raid, ident_resp_imsi, ARRAY_SIZE(ident_resp_imsi)); /* check that the MM context has not been removed due to a failed @@ -1580,7 +1580,7 @@ local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL); /* inject the attach complete */ - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, foreign_tlli, &raid, attach_compl, ARRAY_SIZE(attach_compl)); OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); @@ -1707,7 +1707,7 @@ OSMO_ASSERT(sgsn_tx_counter == 1); /* inject the identity response (IMEI) */ - send_0408_message(ctx->llme, foreign_tlli, &raid, + send_0408_message(ctx->gb.llme, foreign_tlli, &raid, ident_resp_imei, ARRAY_SIZE(ident_resp_imei)); /* check that the MM context has not been removed due to a failed @@ -1740,7 +1740,7 @@ /* inject the attach complete */ local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL); - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, local_tlli, &raid, attach_compl, ARRAY_SIZE(attach_compl)); /* we don't expect a response */ @@ -1753,7 +1753,7 @@ printf(" - Repeated RA Update Request\n"); /* inject the RA update request */ - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, local_tlli, &raid, ra_upd_req, ARRAY_SIZE(ra_upd_req)); /* we expect an RA update accept */ @@ -1766,7 +1766,7 @@ ptmsi2 = ctx->p_tmsi; /* repeat the RA update request */ - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, local_tlli, &raid, ra_upd_req, ARRAY_SIZE(ra_upd_req)); /* we expect an RA update accept */ @@ -1780,7 +1780,7 @@ /* inject the RA update complete */ local_tlli = gprs_tmsi2tlli(ptmsi2, TLLI_LOCAL); - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, local_tlli, &raid, ra_upd_complete, ARRAY_SIZE(ra_upd_complete)); /* we don't expect a response */ @@ -1791,7 +1791,7 @@ OSMO_ASSERT(ctx->p_tmsi == ptmsi2); /* inject the detach */ - send_0408_message(ctx->llme, local_tlli, &raid, + send_0408_message(ctx->gb.llme, local_tlli, &raid, detach_req, ARRAY_SIZE(detach_req)); /* verify that things are gone */ @@ -1931,7 +1931,7 @@ OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli); /* inject the identity response (IMEI) */ - send_0408_message(ctx->llme, ms_tlli, &raid1, + send_0408_message(ctx->gb.llme, ms_tlli, &raid1, ident_resp_imei, ARRAY_SIZE(ident_resp_imei)); /* check that the MM context has not been removed due to a failed @@ -1951,7 +1951,7 @@ /* inject the attach complete */ ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL); - send_0408_message(ctx->llme, ms_tlli, &raid1, + send_0408_message(ctx->gb.llme, ms_tlli, &raid1, attach_compl, ARRAY_SIZE(attach_compl)); /* we don't expect a response */ @@ -1964,7 +1964,7 @@ printf(" - RA Update Request (RA 1 -> RA 1)\n"); /* inject the RA update request */ - send_0408_message(ctx->llme, ms_tlli, &raid1, + send_0408_message(ctx->gb.llme, ms_tlli, &raid1, ra_upd_req1, ARRAY_SIZE(ra_upd_req1)); /* we expect an RA update accept */ @@ -1983,7 +1983,7 @@ /* inject the RA update complete */ ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL); - send_0408_message(ctx->llme, ms_tlli, &raid1, + send_0408_message(ctx->gb.llme, ms_tlli, &raid1, ra_upd_complete, ARRAY_SIZE(ra_upd_complete)); /* we don't expect a response */ @@ -1992,7 +1992,7 @@ OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); - OSMO_ASSERT(ctx->tlli == ms_tlli); + OSMO_ASSERT(ctx->gb.tlli == ms_tlli); printf(" - RA Update Request (RA 1 -> RA 2)\n"); @@ -2000,7 +2000,7 @@ ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_FOREIGN); /* It is coming from RA 1 => ra_upd_req1 */ - send_0408_message(ctx->llme, ms_tlli, &raid2, + send_0408_message(ctx->gb.llme, ms_tlli, &raid2, ra_upd_req1, ARRAY_SIZE(ra_upd_req1)); /* we expect an RA update accept */ @@ -2013,7 +2013,7 @@ ms_tlli = gprs_tmsi2tlli(0x12345678, TLLI_FOREIGN); /* It is coming from RA 1 => ra_upd_req1 */ - send_0408_message(ctx->llme, ms_tlli, &raid2, + send_0408_message(ctx->gb.llme, ms_tlli, &raid2, ra_upd_req_other, ARRAY_SIZE(ra_upd_req_other)); /* we expect an RA update reject (and a LLC XID RESET) */ @@ -2051,7 +2051,7 @@ OSMO_ASSERT(ictx != NULL); OSMO_ASSERT(ictx == ctx); - send_0408_message(ctx->llme, ms_tlli, &raid2, + send_0408_message(ctx->gb.llme, ms_tlli, &raid2, attach_compl, ARRAY_SIZE(attach_compl)); /* we don't expect a response */ @@ -2064,7 +2064,7 @@ printf(" - RA Update Request (RA 2 -> RA 2)\n"); /* inject the RA update request */ - send_0408_message(ctx->llme, ms_tlli, &raid2, + send_0408_message(ctx->gb.llme, ms_tlli, &raid2, ra_upd_req2, ARRAY_SIZE(ra_upd_req2)); /* we expect an RA update accept */ @@ -2082,7 +2082,7 @@ /* inject the RA update complete */ ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL); - send_0408_message(ctx->llme, ms_tlli, &raid2, + send_0408_message(ctx->gb.llme, ms_tlli, &raid2, ra_upd_complete, ARRAY_SIZE(ra_upd_complete)); /* we don't expect a response */ @@ -2091,11 +2091,11 @@ OSMO_ASSERT(ctx->mm_state == GMM_REGISTERED_NORMAL); OSMO_ASSERT(ctx->p_tmsi_old == 0); OSMO_ASSERT(ctx->p_tmsi == ptmsi1); - OSMO_ASSERT(ctx->tlli == ms_tlli); + OSMO_ASSERT(ctx->gb.tlli == ms_tlli); /* inject the detach */ - send_0408_message(ctx->llme, ms_tlli, &raid2, + send_0408_message(ctx->gb.llme, ms_tlli, &raid2, detach_req, ARRAY_SIZE(detach_req)); /* verify that things are gone */ -- To view, visit
https://gerrit.osmocom.org/158
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: Ife9b02549f284e2547f16117cf43d7a36948fc4b Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr(a)sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge(a)gnumonks.org>
9 years, 2 months
2
2
0
0
[PATCH] openbsc[master]: sgsn: fix use of libosmocore GPRS encryption plugins from LL...
by Neels Hofmeyr
Review at
https://gerrit.osmocom.org/128
sgsn: fix use of libosmocore GPRS encryption plugins from LLC layer Instead of passing the uint64_t kc bytes wrongly interpreted as memory address, pass its actual kc bytes by casting via (uint8_t*)&kc. Change-Id: I1f1b7454a0de5b7f4734aca4d03dbe67db5de189 --- M openbsc/src/gprs/gprs_llc.c 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/28/128/1 diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c index 4cf5163..e3c0726 100644 --- a/openbsc/src/gprs/gprs_llc.c +++ b/openbsc/src/gprs/gprs_llc.c @@ -417,7 +417,7 @@ /* Compute the keystream that we need to XOR with the data */ rc = gprs_cipher_run(cipher_out, crypt_len, lle->llme->algo, - kc, iv, GPRS_CIPH_SGSN2MS); + (uint8_t*)&kc, iv, GPRS_CIPH_SGSN2MS); if (rc < 0) { LOGP(DLLC, LOGL_ERROR, "Error crypting UI frame: %d\n", rc); msgb_free(msg); @@ -623,7 +623,7 @@ iv = gprs_cipher_gen_input_ui(iov_ui, lle->sapi, llhp.seq_tx, lle->oc_ui_recv); rc = gprs_cipher_run(cipher_out, crypt_len, lle->llme->algo, - kc, iv, GPRS_CIPH_MS2SGSN); + (uint8_t*)&kc, iv, GPRS_CIPH_MS2SGSN); if (rc < 0) { LOGP(DLLC, LOGL_ERROR, "Error decrypting frame: %d\n", rc); -- To view, visit
https://gerrit.osmocom.org/128
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I1f1b7454a0de5b7f4734aca4d03dbe67db5de189 Gerrit-PatchSet: 1 Gerrit-Project: openbsc Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr(a)sysmocom.de>
9 years, 2 months
3
4
0
0
[PATCH] libosmocore[master]: Add functions to detect HR/FR SID frames
by Max
Review at
https://gerrit.osmocom.org/160
Add functions to detect HR/FR SID frames Add functions which check if given FR or HR frame (packed in RTP) contains SID (SIlence Descriptor) and corresponding tests. Related: OS#22 Change-Id: I4051e3c0d4fb9ee93d7e9e0ef4abaf9f18e227ca --- M include/osmocom/codec/codec.h M src/codec/gsm610.c M src/codec/gsm620.c M tests/codec/codec_test.c M tests/codec/codec_test.ok 5 files changed, 314 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/160/1 diff --git a/include/osmocom/codec/codec.h b/include/osmocom/codec/codec.h index b7bcc78..23c5e20 100644 --- a/include/osmocom/codec/codec.h +++ b/include/osmocom/codec/codec.h @@ -1,6 +1,7 @@ #pragma once #include <stdint.h> +#include <stdbool.h> #include <osmocom/core/utils.h> @@ -41,6 +42,8 @@ AMR_GOOD = 1 }; +bool osmo_check_sid_fr(uint8_t *rtp_payload, size_t payload_len); +bool osmo_check_sid_hr(uint8_t *rtp_payload, size_t payload_len); int osmo_amr_rtp_enc(uint8_t *payload, uint8_t cmr, enum osmo_amr_type ft, enum osmo_amr_quality bfi); int osmo_amr_rtp_dec(const uint8_t *payload, int payload_len, uint8_t *cmr, diff --git a/src/codec/gsm610.c b/src/codec/gsm610.c index 35f6011..8699253 100644 --- a/src/codec/gsm610.c +++ b/src/codec/gsm610.c @@ -22,6 +22,9 @@ */ #include <stdint.h> +#include <stdbool.h> + +#include <osmocom/core/bitvec.h> /* GSM FR - subjective importance bit ordering */ /* This array encodes GSM 05.03 Table 2. @@ -292,3 +295,215 @@ 11, /* LARc1:0 */ 29, /* LARc5:0 */ }; + +/*! \brief Check whether RTP frame contains FR SID code word according to + * TS 101 318 §5.1.2 + * \param[in] rtp_payload Buffer with RTP payload + * \param[in] payload_len Length of payload + * \returns true if code word is found, false otherwise + */ +bool osmo_check_sid_fr(uint8_t *rtp_payload, size_t payload_len) +{ + struct bitvec bv; + + /* signature does not match Full Rate SID */ + if ((rtp_payload[0] >> 4) != 0xD) + return false; + + bv.data = rtp_payload; + bv.data_len = payload_len; + + /* code word is all 0 at given bits, numbered from 1 */ + if (bitvec_get_bit_pos(&bv, 59) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 60) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 62) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 63) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 65) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 66) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 68) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 69) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 71) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 72) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 74) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 75) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 77) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 78) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 80) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 81) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 83) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 84) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 86) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 87) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 89) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 90) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 92) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 93) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 95) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 96) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 115) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 116) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 118) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 119) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 121) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 122) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 124) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 125) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 127) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 128) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 130) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 131) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 133) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 134) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 136) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 137) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 139) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 140) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 142) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 143) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 145) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 146) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 148) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 149) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 151) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 152) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 171) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 172) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 174) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 175) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 177) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 178) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 180) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 181) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 183) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 184) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 186) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 187) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 189) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 190) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 192) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 193) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 195) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 196) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 198) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 199) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 201) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 202) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 204) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 205) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 207) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 208) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 227) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 228) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 230) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 231) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 233) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 234) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 236) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 237) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 239) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 242) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 245) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 248) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 251) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 254) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 257) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 260) != ZERO) + return false; + if (bitvec_get_bit_pos(&bv, 263) != ZERO) + return false; + + return true; +} diff --git a/src/codec/gsm620.c b/src/codec/gsm620.c index f4ac9ad..873913d 100644 --- a/src/codec/gsm620.c +++ b/src/codec/gsm620.c @@ -22,6 +22,9 @@ */ #include <stdint.h> +#include <stdbool.h> + +#include <osmocom/core/bitvec.h> /* GSM HR unvoiced (mode=0) frames - subjective importance bit ordering */ /* This array encode mapping between GSM 05.03 Table 3a (bits @@ -260,3 +263,62 @@ 82, /* Code 3:6 */ 81, /* Code 3:7 */ }; + +/*! \brief Check whether RTP frame contains HR SID code word according to + * TS 101 318 §5.2.2 + * \param[in] rtp_payload Buffer with RTP payload + * \param[in] payload_len Length of payload + * \returns true if code word is found, false otherwise + */ +bool osmo_check_sid_hr(uint8_t *rtp_payload, size_t payload_len) +{ + struct bitvec bv; + bv.data = rtp_payload; + bv.data_len = payload_len; + + /* code word is all 1 at given bits, numbered from 1, MODE is always 3 */ + bv.cur_bit = 33; + if (bitvec_get_uint(&bv, 1) != 0x1) + return false; + + if (bitvec_get_uint(&bv, 2) != 0x3) + return false; + + if (bitvec_get_uint(&bv, 8) != 0xFF) + return false; + + if (bitvec_get_uint(&bv, 9) != 0x1FF) + return false; + + if (bitvec_get_uint(&bv, 5) != 0x1F) + return false; + + if (bitvec_get_uint(&bv, 4) != 0xF) + return false; + + if (bitvec_get_uint(&bv, 9) != 0x1FF) + return false; + + if (bitvec_get_uint(&bv, 5) != 0x1F) + return false; + + if (bitvec_get_uint(&bv, 4) != 0xF) + return false; + + if (bitvec_get_uint(&bv, 9) != 0x1FF) + return false; + + if (bitvec_get_uint(&bv, 5) != 0x1F) + return false; + + if (bitvec_get_uint(&bv, 4) != 0xF) + return false; + + if (bitvec_get_uint(&bv, 9) != 0x1FF) + return false; + + if (bitvec_get_uint(&bv, 5) != 0x1F) + return false; + + return true; +} diff --git a/tests/codec/codec_test.c b/tests/codec/codec_test.c index 4905dd3..1b278cb 100644 --- a/tests/codec/codec_test.c +++ b/tests/codec/codec_test.c @@ -20,6 +20,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <stdbool.h> #include <osmocom/core/utils.h> #include <osmocom/codec/codec.h> @@ -68,6 +69,26 @@ cmpr(_cmr, cmr), cmpr(_ft, ft), cmpr(_bfi, bfi), cmi, sti); } +uint8_t fr[] = {0xd8, 0xa9, 0xb5, 0x1d, 0xda, 0xa8, 0x82, 0xcc, 0xec, 0x52, + 0x29, 0x05, 0xa8, 0xc3, 0xe3, 0x0e, 0xb0, 0x89, 0x7a, 0xee, + 0x42, 0xca, 0xc4, 0x97, 0x22, 0xe6, 0x9e, 0xa8, 0xb8, 0xec, + 0x52, 0x26, 0xbd}; +uint8_t sid_fr[] = {0xd7, 0x27, 0x93, 0xe5, 0xe3, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +uint8_t hr[] = {0x06, 0x46, 0x76, 0xb1, 0x8e, 0x48, 0x9a, 0x2f, 0x5e, 0x4c, + 0x22, 0x2b, 0x62, 0x25}; +uint8_t sid_hr[] = {0x03, 0x8e, 0xb6, 0xcb, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff}; + +static void test_sid_xr(uint8_t *t, size_t len, bool hr) +{ + printf("%s SID ? %s:: %d\n", hr ? "HR" : "FR", osmo_hexdump(t, len), + hr ? osmo_check_sid_hr(t, len) : osmo_check_sid_fr(t, len)); +} + int main(int argc, char **argv) { printf("AMR RTP payload decoder test:\n"); @@ -79,6 +100,13 @@ test_amr_rt(AMR_12_2, AMR_12_2, AMR_GOOD); test_amr_rt(AMR_7_40, AMR_7_40, AMR_BAD); test_amr_rt(AMR_7_40, AMR_7_40, AMR_GOOD); + printf("FR RTP payload SID test:\n"); + test_sid_xr(sid_fr, 33, false); + test_sid_xr(fr, 33, false); + + printf("HR RTP payload SID test:\n"); + test_sid_xr(sid_hr, 14, true); + test_sid_xr(hr, 14, true); return 0; } diff --git a/tests/codec/codec_test.ok b/tests/codec/codec_test.ok index 0f76fef..2af7cc7 100644 --- a/tests/codec/codec_test.ok +++ b/tests/codec/codec_test.ok @@ -7,3 +7,9 @@ [33/33] AMR 12,2 kbit/s (GSM-EFR), CMR: OK, FT: OK, BFI: OK, CMI: -1, STI: -1 [21/21] AMR 7,40 kbit/s (TDMA-EFR), CMR: OK, FT: OK, BFI: OK, CMI: -1, STI: -1 [21/21] AMR 7,40 kbit/s (TDMA-EFR), CMR: OK, FT: OK, BFI: OK, CMI: -1, STI: -1 +FR RTP payload SID test: +FR SID ? d7 27 93 e5 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 :: 1 +FR SID ? d8 a9 b5 1d da a8 82 cc ec 52 29 05 a8 c3 e3 0e b0 89 7a ee 42 ca c4 97 22 e6 9e a8 b8 ec 52 26 bd :: 0 +HR RTP payload SID test: +HR SID ? 03 8e b6 cb ff ff ff ff ff ff ff ff ff ff :: 1 +HR SID ? 06 46 76 b1 8e 48 9a 2f 5e 4c 22 2b 62 25 :: 0 -- To view, visit
https://gerrit.osmocom.org/160
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I4051e3c0d4fb9ee93d7e9e0ef4abaf9f18e227ca Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Max <msuraev(a)sysmocom.de>
9 years, 2 months
2
4
0
0
[PATCH] osmo-pcu[master]: encoding/rlc_copy_from_aligned_buffer: export written payloa...
by lynxis lazus
Review at
https://gerrit.osmocom.org/142
encoding/rlc_copy_from_aligned_buffer: export written payload bytes via an argument Require to count statistics for rlc_dl_payload_bytes. Change-Id: I0e622acb1f13f7489946baf049de4ba1cde6a1fc --- M src/encoding.cpp M src/encoding.h M src/tbf_dl.cpp M tests/edge/EdgeTest.cpp 4 files changed, 49 insertions(+), 31 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/42/142/1 diff --git a/src/encoding.cpp b/src/encoding.cpp index 9dba4f6..2102a1e 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -899,13 +899,13 @@ * \param num_chunks count the chunks (llc pdu data) within rlc/mac * \param data_block buffer holds rlc/mac data * \param is_final if this is the last rlc/mac within a TBF + * \param count_payload if not NULL save the written size of payload in bytes into it * \return the state of the rlc/mac like if there is more space for another chunk */ static Encoding::AppendResult rlc_data_to_dl_append_gprs( struct gprs_rlc_data_block_info *rdbi, gprs_llc *llc, int *offset, int *num_chunks, - uint8_t *data_block, - bool is_final) + uint8_t *data_block, bool is_final, int *count_payload) { int chunk; int space; @@ -930,6 +930,8 @@ *e_pointer |= 0x01; /* fill only space */ llc->consume(data, space); + if (count_payload) + *count_payload = space; /* return data block as message */ *offset = rdbi->data_len; (*num_chunks)++; @@ -947,6 +949,8 @@ *e_pointer |= 0x01; /* fill space */ llc->consume(data, space); + if (count_payload) + *count_payload = space; *offset = rdbi->data_len; (*num_chunks)++; rdbi->cv = 0; @@ -974,6 +978,8 @@ // no need to set e_pointer nor increase delimiter /* fill only space, which is 1 octet less than chunk */ llc->consume(data, space); + if (count_payload) + *count_payload = space; /* return data block as message */ *offset = rdbi->data_len; (*num_chunks)++; @@ -999,6 +1005,8 @@ (*num_chunks)++; /* copy (rest of) LLC frame to space and reset later */ llc->consume(data, chunk); + if (count_payload) + *count_payload = chunk; data += chunk; space -= chunk; (*offset) += chunk; @@ -1030,13 +1038,14 @@ * \param num_chunks count the chunks (llc pdu data) within rlc/mac * \param data_block buffer holds rlc/mac data * \param is_final if this is the last rlc/mac within a TBF + * \param count_payload if not NULL save the written size of payload in bytes into it * \return the state of the rlc/mac like if there is more space for another chunk */ static Encoding::AppendResult rlc_data_to_dl_append_egprs( struct gprs_rlc_data_block_info *rdbi, gprs_llc *llc, int *offset, int *num_chunks, uint8_t *data_block, - bool is_final) + bool is_final, int *count_payload) { int chunk; int space; @@ -1060,6 +1069,8 @@ chunk, space); /* fill only space */ llc->consume(data, space); + if (count_payload) + *count_payload = space; /* return data block as message */ *offset = rdbi->data_len; (*num_chunks)++; @@ -1074,6 +1085,8 @@ "header, and we are done\n", chunk, space); /* fill space */ llc->consume(data, space); + if (count_payload) + *count_payload = space; *offset = rdbi->data_len; (*num_chunks)++; rdbi->cv = 0; @@ -1088,6 +1101,8 @@ chunk, space); /* fill space */ llc->consume(data, space); + if (count_payload) + *count_payload = space; *offset = rdbi->data_len; (*num_chunks)++; return Encoding::AR_NEED_MORE_BLOCKS; @@ -1118,6 +1133,8 @@ (*num_chunks)++; /* copy (rest of) LLC frame to space and reset later */ llc->consume(data, chunk); + if (count_payload) + *count_payload = chunk; data += chunk; space -= chunk; (*offset) += chunk; @@ -1183,21 +1200,23 @@ * \param num_chunks count the chunks (llc pdu data) within rlc/mac * \param data_block buffer holds rlc/mac data * \param is_final if this is the last rlc/mac within a TBF + * \param count_payload if not NULL save the written size of payload in bytes into it * \return the state of the rlc/mac like if there is more space for another chunk */ Encoding::AppendResult Encoding::rlc_data_to_dl_append( struct gprs_rlc_data_block_info *rdbi, GprsCodingScheme cs, gprs_llc *llc, int *offset, int *num_chunks, - uint8_t *data_block, - bool is_final) + uint8_t *data_block, bool is_final, int *count_payload) { if (cs.isGprs()) return rlc_data_to_dl_append_gprs(rdbi, - llc, offset, num_chunks, data_block, is_final); + llc, offset, num_chunks, data_block, is_final, + count_payload); if (cs.isEgprs()) return rlc_data_to_dl_append_egprs(rdbi, - llc, offset, num_chunks, data_block, is_final); + llc, offset, num_chunks, data_block, is_final, + count_payload); LOGP(DRLCMACDL, LOGL_ERROR, "%s data block encoding not implemented\n", cs.name()); diff --git a/src/encoding.h b/src/encoding.h index 94e9a02..710de78 100644 --- a/src/encoding.h +++ b/src/encoding.h @@ -91,6 +91,5 @@ static AppendResult rlc_data_to_dl_append( struct gprs_rlc_data_block_info *rdbi, GprsCodingScheme cs, gprs_llc *llc, int *offset, int *num_chunks, - uint8_t *data, - bool is_final); + uint8_t *data, bool is_final, int *count_payload); }; diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp index da6628a..00adbc9 100644 --- a/src/tbf_dl.cpp +++ b/src/tbf_dl.cpp @@ -538,7 +538,7 @@ is_final = llc_queue()->size() == 0 && !keep_open(fn); ar = Encoding::rlc_data_to_dl_append(rdbi, cs, - &m_llc, &write_offset, &num_chunks, data, is_final); + &m_llc, &write_offset, &num_chunks, data, is_final, NULL); if (ar == Encoding::AR_NEED_MORE_BLOCKS) break; diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp index 96ea0c1..fef4abb 100644 --- a/tests/edge/EdgeTest.cpp +++ b/tests/edge/EdgeTest.cpp @@ -524,7 +524,7 @@ llc.put_frame(llc_data, 11); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -535,7 +535,7 @@ llc.put_frame(llc_data, 26); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -546,7 +546,7 @@ llc.put_frame(llc_data, 99); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS); OSMO_ASSERT(rdbi.e == 0); @@ -571,7 +571,7 @@ llc.put_frame(llc_data, 20); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS); OSMO_ASSERT(rdbi.e == 0); @@ -590,7 +590,7 @@ OSMO_ASSERT(llc.chunk_size() == 1); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -601,7 +601,7 @@ llc.put_frame(llc_data, 99); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS); OSMO_ASSERT(rdbi.e == 0); @@ -624,7 +624,7 @@ llc.put_frame(llc_data, 7); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -635,7 +635,7 @@ llc.put_frame(llc_data, 11); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_BLOCK_FILLED); OSMO_ASSERT(rdbi.e == 0); @@ -659,7 +659,7 @@ llc.put_frame(llc_data, 99); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS); OSMO_ASSERT(rdbi.e == 1); @@ -705,7 +705,7 @@ llc.put_frame(llc_data, 30); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS); OSMO_ASSERT(rdbi.e == 1); @@ -723,7 +723,7 @@ OSMO_ASSERT(llc.chunk_size() == 10); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -734,7 +734,7 @@ llc.put_frame(llc_data, 99); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS); OSMO_ASSERT(rdbi.e == 0); @@ -757,7 +757,7 @@ llc.put_frame(llc_data, 11); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -768,7 +768,7 @@ llc.put_frame(llc_data, 26); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -779,7 +779,7 @@ llc.put_frame(llc_data, 99); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS); OSMO_ASSERT(rdbi.e == 0); @@ -809,7 +809,7 @@ llc.put_frame(llc_data, 15); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -820,7 +820,7 @@ llc.put_frame(llc_data, 12); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS); OSMO_ASSERT(rdbi.e == 0); @@ -840,7 +840,7 @@ OSMO_ASSERT(llc.chunk_size() == 0); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -851,7 +851,7 @@ llc.put_frame(llc_data, 7); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); @@ -863,7 +863,7 @@ llc.put_frame(llc_data, 18); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_BLOCK_FILLED); OSMO_ASSERT(rdbi.e == 0); @@ -886,7 +886,7 @@ llc.put_frame(llc_data, 6); ar = Encoding::rlc_data_to_dl_append(&rdbi, cs, - &llc, &write_offset, &num_chunks, data, false); + &llc, &write_offset, &num_chunks, data, false, NULL); OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT); OSMO_ASSERT(rdbi.e == 0); -- To view, visit
https://gerrit.osmocom.org/142
To unsubscribe, visit
https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I0e622acb1f13f7489946baf049de4ba1cde6a1fc Gerrit-PatchSet: 1 Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
9 years, 2 months
2
3
0
0
← Newer
1
2
3
4
5
...
17
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Results per page:
10
25
50
100
200