aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2013-03-25 11:06:31 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-03-25 11:16:13 +0100
commit7916cb881d5ecfbe7406ba88ac0338554da9ac7b (patch)
tree6b655a931cacdbee58968846dbf3f08f5d355e20
parent63bb41152266fb61ed10f5972b37a7dcebe8d479 (diff)
bss patch: Patch all slots with FR2 in the assignment request
* Patch all slots with the FR2 codec. This is the easiest way to patch the entire message.
-rw-r--r--src/bss_patch.c18
-rw-r--r--tests/patching/patching_test.c2
2 files changed, 13 insertions, 7 deletions
diff --git a/src/bss_patch.c b/src/bss_patch.c
index c05def5..f49098f 100644
--- a/src/bss_patch.c
+++ b/src/bss_patch.c
@@ -40,8 +40,9 @@ static int handle_bss_dtap(struct msgb *msg, struct sccp_parse_result *sccp, int
static void patch_ass_rqst(struct msgb *msg, int length)
{
struct tlv_parsed tp;
- uint8_t *data, audio;
+ uint8_t *data;
int len;
+ int i;
tlv_parse(&tp, gsm0808_att_tlvdef(), msg->l3h + 1, length - 1, 0, 0);
len = TLVP_LEN(&tp, GSM0808_IE_CHANNEL_TYPE);
@@ -53,12 +54,17 @@ static void patch_ass_rqst(struct msgb *msg, int length)
if ((data[0] & 0xf) != 0x1)
return;
- /* blindly assign */
+ /* blindly assign FR2 on all slots */
data[1] = GSM0808_SPEECH_FULL_PREF;
- audio = GSM0808_PERM_FR2;
- if (len > 3)
- audio |= 0x80;
- data[2] = audio;
+ for (i = 0; i < len - 2; ++i) {
+ uint8_t audio = GSM0808_PERM_FR2;
+
+ /* at the end? */
+ if (i + 1 != len - 2)
+ audio |= 0x80;
+ data[2 + i] = audio;
+ printf("PATCHED %d\n", i);
+ }
}
static void patch_ass_cmpl(struct msgb *msg, int length)
diff --git a/tests/patching/patching_test.c b/tests/patching/patching_test.c
index f9fd5a4..16ba879 100644
--- a/tests/patching/patching_test.c
+++ b/tests/patching/patching_test.c
@@ -44,7 +44,7 @@ static const uint8_t ass_rewrite[] = {
static const uint8_t ass_rewrite_patched[] = {
0x06, 0xe5, 0xe2, 0x0e, 0x00, 0x01, 0x0c, 0x00,
- 0x0a, 0x01, 0x0b, 0x04, 0x01, 0x0a, 0x91, 0x25,
+ 0x0a, 0x01, 0x0b, 0x04, 0x01, 0x0a, 0x91, 0x11,
0x01, 0x00, 0x08
};