@@ -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());
@@ -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);
};
@@ -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;
@@ -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);
@@ -682,7 +682,7 @@
llc.put_frame(llc_data, 20);
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
- &llc, &write_offset, &num_chunks, data, true);
+ &llc, &write_offset, &num_chunks, data, true, NULL);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_BLOCK_FILLED);
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);
@@ -897,7 +897,7 @@
llc.put_frame(llc_data, 12);
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
- &llc, &write_offset, &num_chunks, data, true);
+ &llc, &write_offset, &num_chunks, data, true, NULL);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_BLOCK_FILLED);
OSMO_ASSERT(rdbi.e == 0);
@@ -926,7 +926,7 @@
llc.put_frame(llc_data, rdbi.data_len);
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
- &llc, &write_offset, &num_chunks, data, true);
+ &llc, &write_offset, &num_chunks, data, true, NULL);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_BLOCK_FILLED);
OSMO_ASSERT(rdbi.e == 1);
@@ -950,7 +950,7 @@
llc.put_frame(llc_data, rdbi.data_len - 1);
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
- &llc, &write_offset, &num_chunks, data, true);
+ &llc, &write_offset, &num_chunks, data, true, NULL);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_BLOCK_FILLED);
OSMO_ASSERT(rdbi.e == 0);
@@ -975,7 +975,7 @@
llc.put_frame(llc_data, rdbi.data_len - 2);
ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
- &llc, &write_offset, &num_chunks, data, true);
+ &llc, &write_offset, &num_chunks, data, true, NULL);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_BLOCK_FILLED);
OSMO_ASSERT(rdbi.e == 0);