diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-11-07 07:50:26 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2013-11-07 07:50:26 +0100 |
commit | b7840466ceea8c68eb5db86c1fc98219b39ad086 (patch) | |
tree | 81750fbc5bddaf88e8760f3e6352819135bd3da5 | |
parent | a1da251c10940291581f016e89e18d91803b9b95 (diff) |
tbf: Split create_dl_acked_block into two methods
The method was more than 300 hundred lines of code. Split the
selection of the index and the creation of the dl_msg.
-rw-r--r-- | src/tbf.cpp | 26 | ||||
-rw-r--r-- | src/tbf.h | 3 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp index b10b729f..41aaf903 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -901,15 +901,14 @@ struct msgb *gprs_rlcmac_tbf::create_dl_acked_block(uint32_t fn, uint8_t ts) struct rlc_li_field *li; uint8_t block_length; /* total length of block, including spare bits */ uint8_t block_data; /* usable data of block, w/o spare bits, inc. MAC */ - struct msgb *msg, *dl_msg; + struct msgb *msg; uint8_t bsn; uint16_t mod_sns = sns - 1; uint16_t mod_sns_half = (sns >> 1) - 1; uint16_t index; uint8_t *delimiter, *data, *e_pointer; - uint8_t len; uint16_t space, chunk; - int first_fin_ack = 0; + bool first_fin_ack = false; LOGP(DRLCMACDL, LOGL_DEBUG, "%s downlink (V(A)==%d .. " "V(S)==%d)\n", tbf_name(this), dir.dl.v_a, dir.dl.v_s); @@ -925,7 +924,7 @@ do_resend: bsn); /* re-send block with negative aknowlegement */ dir.dl.v_b[index] = 'U'; /* unacked */ - goto tx_block; + return create_dl_acked_block(fn, ts, index, first_fin_ack); } } @@ -954,7 +953,7 @@ do_resend: "so we re-transmit final block!\n"); /* we just send final block again */ index = ((dir.dl.v_s - 1) & mod_sns_half); - goto tx_block; + return create_dl_acked_block(fn, ts, index, first_fin_ack); } /* cycle through all unacked blocks */ @@ -975,7 +974,7 @@ do_resend: " != V(S). PLEASE FIX!\n"); /* we just send final block again */ index = ((dir.dl.v_s - 1) & mod_sns_half); - goto tx_block; + return create_dl_acked_block(fn, ts, index, first_fin_ack); } goto do_resend; } @@ -1114,7 +1113,7 @@ do_resend: "done.\n"); li->e = 1; /* we cannot extend */ rh->fbi = 1; /* we indicate final block */ - first_fin_ack = 1; + first_fin_ack = true; /* + 1 indicates: first final ack */ tbf_new_state(this, GPRS_RLCMAC_FINISHED); break; @@ -1132,8 +1131,17 @@ do_resend: dir.dl.v_b[index] = 'U'; /* unacked */ dir.dl.v_s = (dir.dl.v_s + 1) & mod_sns; /* inc send state */ -tx_block: - /* from this point on, new block is sent or old block is resent */ + return create_dl_acked_block(fn, ts, index, first_fin_ack); +} + +struct msgb *gprs_rlcmac_tbf::create_dl_acked_block( + const uint32_t fn, const uint8_t ts, + const int index, const bool first_fin_ack) +{ + uint8_t *data; + struct rlc_dl_header *rh; + struct msgb *dl_msg; + uint8_t len; /* get data and header from current block */ data = rlc_block[index]; @@ -266,6 +266,9 @@ protected: int append_data(const uint8_t ms_class, const uint16_t pdu_delay_csec, const uint8_t *data, const uint16_t len); + + struct msgb *create_dl_acked_block(const uint32_t fn, const uint8_t ts, + const int index, const bool fin_first_ack); }; |