cs: Add family related methods
Add family handling and the related methods family, isFamilyCompatible, isCombinable, decToSingleBlock to GprsCodingScheme. Sponsored-by: On-Waves ehf
This commit is contained in:
parent
4cc46d3e2a
commit
2305afd86c
|
@ -30,23 +30,38 @@ static struct {
|
||||||
unsigned int data_bytes;
|
unsigned int data_bytes;
|
||||||
const char *name;
|
const char *name;
|
||||||
GprsCodingScheme::HeaderType data_hdr;
|
GprsCodingScheme::HeaderType data_hdr;
|
||||||
|
GprsCodingScheme::Family family;
|
||||||
} mcs_info[GprsCodingScheme::NUM_SCHEMES] = {
|
} mcs_info[GprsCodingScheme::NUM_SCHEMES] = {
|
||||||
{{0, 0}, {0, 0}, 0, "UNKNOWN", GprsCodingScheme::HEADER_INVALID},
|
{{0, 0}, {0, 0}, 0, "UNKNOWN",
|
||||||
{{23, 0}, {23, 0}, 20, "CS-1", GprsCodingScheme::HEADER_GPRS_DATA},
|
GprsCodingScheme::HEADER_INVALID, GprsCodingScheme::FAMILY_INVALID},
|
||||||
{{33, 7}, {33, 7}, 30, "CS-2", GprsCodingScheme::HEADER_GPRS_DATA},
|
{{23, 0}, {23, 0}, 20, "CS-1",
|
||||||
{{39, 3}, {39, 3}, 36, "CS-3", GprsCodingScheme::HEADER_GPRS_DATA},
|
GprsCodingScheme::HEADER_GPRS_DATA, GprsCodingScheme::FAMILY_INVALID},
|
||||||
{{53, 7}, {53, 7}, 50, "CS-4", GprsCodingScheme::HEADER_GPRS_DATA},
|
{{33, 7}, {33, 7}, 30, "CS-2",
|
||||||
|
GprsCodingScheme::HEADER_GPRS_DATA, GprsCodingScheme::FAMILY_INVALID},
|
||||||
|
{{39, 3}, {39, 3}, 36, "CS-3",
|
||||||
|
GprsCodingScheme::HEADER_GPRS_DATA, GprsCodingScheme::FAMILY_INVALID},
|
||||||
|
{{53, 7}, {53, 7}, 50, "CS-4",
|
||||||
|
GprsCodingScheme::HEADER_GPRS_DATA, GprsCodingScheme::FAMILY_INVALID},
|
||||||
|
|
||||||
{{26, 1}, {26, 1}, 22, "MCS-1", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3},
|
{{26, 1}, {26, 1}, 22, "MCS-1",
|
||||||
{{32, 1}, {32, 1}, 28, "MCS-2", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3},
|
GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3, GprsCodingScheme::FAMILY_C},
|
||||||
{{41, 1}, {41, 1}, 37, "MCS-3", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3},
|
{{32, 1}, {32, 1}, 28, "MCS-2",
|
||||||
{{48, 1}, {48, 1}, 44, "MCS-4", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3},
|
GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3, GprsCodingScheme::FAMILY_B},
|
||||||
|
{{41, 1}, {41, 1}, 37, "MCS-3",
|
||||||
|
GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3, GprsCodingScheme::FAMILY_A},
|
||||||
|
{{48, 1}, {48, 1}, 44, "MCS-4",
|
||||||
|
GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_3, GprsCodingScheme::FAMILY_C},
|
||||||
|
|
||||||
{{60, 7}, {59, 6}, 56, "MCS-5", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_2},
|
{{60, 7}, {59, 6}, 56, "MCS-5",
|
||||||
{{78, 7}, {77, 6}, 74, "MCS-6", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_2},
|
GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_2, GprsCodingScheme::FAMILY_B},
|
||||||
{{118, 2}, {117, 4}, 56, "MCS-7", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1},
|
{{78, 7}, {77, 6}, 74, "MCS-6",
|
||||||
{{142, 2}, {141, 4}, 68, "MCS-8", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1},
|
GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_2, GprsCodingScheme::FAMILY_A},
|
||||||
{{154, 2}, {153, 4}, 74, "MCS-9", GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1},
|
{{118, 2}, {117, 4}, 56, "MCS-7",
|
||||||
|
GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1, GprsCodingScheme::FAMILY_B},
|
||||||
|
{{142, 2}, {141, 4}, 68, "MCS-8",
|
||||||
|
GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1, GprsCodingScheme::FAMILY_A},
|
||||||
|
{{154, 2}, {153, 4}, 74, "MCS-9",
|
||||||
|
GprsCodingScheme::HEADER_EGPRS_DATA_TYPE_1, GprsCodingScheme::FAMILY_A},
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -167,6 +182,11 @@ GprsCodingScheme::HeaderType GprsCodingScheme::headerTypeData() const
|
||||||
return mcs_info[m_scheme].data_hdr;
|
return mcs_info[m_scheme].data_hdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GprsCodingScheme::Family GprsCodingScheme::family() const
|
||||||
|
{
|
||||||
|
return mcs_info[m_scheme].family;
|
||||||
|
}
|
||||||
|
|
||||||
void GprsCodingScheme::inc(Mode mode)
|
void GprsCodingScheme::inc(Mode mode)
|
||||||
{
|
{
|
||||||
if (!isCompatible(mode))
|
if (!isCompatible(mode))
|
||||||
|
@ -232,3 +252,29 @@ const char *GprsCodingScheme::modeName(Mode mode)
|
||||||
default: return "???";
|
default: return "???";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GprsCodingScheme::isFamilyCompatible(GprsCodingScheme o) const
|
||||||
|
{
|
||||||
|
if (*this == o)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (family() == FAMILY_INVALID)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return family() == o.family();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GprsCodingScheme::isCombinable(GprsCodingScheme o) const
|
||||||
|
{
|
||||||
|
return numDataBlocks() == o.numDataBlocks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GprsCodingScheme::decToSingleBlock(bool *needStuffing)
|
||||||
|
{
|
||||||
|
switch (m_scheme) {
|
||||||
|
case MCS7: *needStuffing = false; m_scheme = MCS5; break;
|
||||||
|
case MCS8: *needStuffing = true; m_scheme = MCS6; break;
|
||||||
|
case MCS9: *needStuffing = false; m_scheme = MCS6; break;
|
||||||
|
default: *needStuffing = false; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,13 @@ public:
|
||||||
NUM_HEADER_TYPES
|
NUM_HEADER_TYPES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Family {
|
||||||
|
FAMILY_INVALID,
|
||||||
|
FAMILY_A,
|
||||||
|
FAMILY_B,
|
||||||
|
FAMILY_C,
|
||||||
|
};
|
||||||
|
|
||||||
GprsCodingScheme(Scheme s = UNKNOWN);
|
GprsCodingScheme(Scheme s = UNKNOWN);
|
||||||
|
|
||||||
operator bool() const {return m_scheme != UNKNOWN;}
|
operator bool() const {return m_scheme != UNKNOWN;}
|
||||||
|
@ -65,11 +72,14 @@ public:
|
||||||
bool isEgprsGmsk() const {return isEgprs() && m_scheme <= MCS4;}
|
bool isEgprsGmsk() const {return isEgprs() && m_scheme <= MCS4;}
|
||||||
bool isCompatible(Mode mode) const;
|
bool isCompatible(Mode mode) const;
|
||||||
bool isCompatible(GprsCodingScheme o) const;
|
bool isCompatible(GprsCodingScheme o) const;
|
||||||
|
bool isFamilyCompatible(GprsCodingScheme o) const;
|
||||||
|
bool isCombinable(GprsCodingScheme o) const;
|
||||||
|
|
||||||
void inc(Mode mode);
|
void inc(Mode mode);
|
||||||
void dec(Mode mode);
|
void dec(Mode mode);
|
||||||
void inc();
|
void inc();
|
||||||
void dec();
|
void dec();
|
||||||
|
void decToSingleBlock(bool *needStuffing);
|
||||||
|
|
||||||
unsigned int sizeUL() const;
|
unsigned int sizeUL() const;
|
||||||
unsigned int sizeDL() const;
|
unsigned int sizeDL() const;
|
||||||
|
@ -87,6 +97,7 @@ public:
|
||||||
const char *name() const;
|
const char *name() const;
|
||||||
HeaderType headerTypeData() const;
|
HeaderType headerTypeData() const;
|
||||||
HeaderType headerTypeControl() const;
|
HeaderType headerTypeControl() const;
|
||||||
|
Family family() const;
|
||||||
|
|
||||||
static GprsCodingScheme getBySizeUL(unsigned size);
|
static GprsCodingScheme getBySizeUL(unsigned size);
|
||||||
static GprsCodingScheme getGprsByNum(unsigned num);
|
static GprsCodingScheme getGprsByNum(unsigned num);
|
||||||
|
|
|
@ -46,6 +46,7 @@ int16_t spoof_mnc = 0, spoof_mcc = 0;
|
||||||
static void check_coding_scheme(GprsCodingScheme& cs, GprsCodingScheme::Mode mode)
|
static void check_coding_scheme(GprsCodingScheme& cs, GprsCodingScheme::Mode mode)
|
||||||
{
|
{
|
||||||
volatile unsigned expected_size;
|
volatile unsigned expected_size;
|
||||||
|
bool need_padding;
|
||||||
GprsCodingScheme new_cs;
|
GprsCodingScheme new_cs;
|
||||||
|
|
||||||
OSMO_ASSERT(cs.isValid());
|
OSMO_ASSERT(cs.isValid());
|
||||||
|
@ -84,6 +85,18 @@ static void check_coding_scheme(GprsCodingScheme& cs, GprsCodingScheme::Mode mod
|
||||||
OSMO_ASSERT(new_cs.isCompatible(mode));
|
OSMO_ASSERT(new_cs.isCompatible(mode));
|
||||||
OSMO_ASSERT(new_cs == cs);
|
OSMO_ASSERT(new_cs == cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_cs = cs;
|
||||||
|
new_cs.decToSingleBlock(&need_padding);
|
||||||
|
OSMO_ASSERT(new_cs.isFamilyCompatible(cs));
|
||||||
|
OSMO_ASSERT(cs.isFamilyCompatible(new_cs));
|
||||||
|
OSMO_ASSERT(cs.isCompatible(new_cs));
|
||||||
|
if (need_padding) {
|
||||||
|
OSMO_ASSERT(new_cs.maxDataBlockBytes() > cs.maxDataBlockBytes());
|
||||||
|
} else {
|
||||||
|
OSMO_ASSERT(new_cs.maxDataBlockBytes() == cs.maxDataBlockBytes());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_coding_scheme()
|
static void test_coding_scheme()
|
||||||
|
|
Loading…
Reference in New Issue