aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-03-20 13:57:27 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-03-20 14:12:28 +0100
commit612e93e36031ab2d50dd66d148f289b2e3580850 (patch)
tree7c9bc037b82e7f15963f1e4ac76252feeb647c17
parent39645b824a08b355fa48361491d5a1c3e9e6bd4d (diff)
llc: Add put_dummy_frame to create an LLC dummy command
The LLC dummy command is needed for RLC block stuffing, e.g. when a TBF should be kept open if no LLC data is available. The RLC block headers do not support stuffing, only the last block of a TBF can be used partially. LLC dummy commands are discarded by the receiver immediately, because the have an invalid FCS checksum. This commit adds the function put_dummy_frame, which puts a LLC dummy command into the frame buffer. The requested length is given as an argument, but the real length might be adjusted according to the specification (see GSM 44.064, 6.4.2.2). Sponsored-by: On-Waves ehf
-rw-r--r--src/llc.cpp20
-rw-r--r--src/llc.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/src/llc.cpp b/src/llc.cpp
index 2d295f8..b160961 100644
--- a/src/llc.cpp
+++ b/src/llc.cpp
@@ -48,6 +48,26 @@ void gprs_llc::enqueue(struct msgb *llc_msg)
msgb_enqueue(&queue, llc_msg);
}
+/* Put an Unconfirmed Information (UI) Dummy command, see GSM 44.064, 6.4.2.2 */
+void gprs_llc::put_dummy_frame(size_t req_len)
+{
+ /* The shortest dummy command (the spec requests at least 6 octets) */
+ static const uint8_t llc_dummy_command[] = {
+ 0x43, 0xc0, 0x01, 0x2b, 0x2b, 0x2b
+ };
+ static const int max_dummy_command_len = 79;
+
+ put_frame(llc_dummy_command, sizeof(llc_dummy_command));
+
+ if (req_len > max_dummy_command_len)
+ req_len = max_dummy_command_len;
+
+ /* Add further stuffing, if the requested length exceeds the minimum
+ * dummy command length */
+ while (m_length < req_len)
+ frame[m_length++] = 0x2b;
+}
+
void gprs_llc::put_frame(const uint8_t *data, size_t len)
{
/* only put frames when we are empty */
diff --git a/src/llc.h b/src/llc.h
index 1f0c114..f82c4ed 100644
--- a/src/llc.h
+++ b/src/llc.h
@@ -38,6 +38,7 @@ struct gprs_llc {
struct msgb *dequeue();
void put_frame(const uint8_t *data, size_t len);
+ void put_dummy_frame(size_t req_len);
void append_frame(const uint8_t *data, size_t len);
void consume(size_t len);