aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-12-27 23:05:51 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-12-27 23:05:51 +0100
commit7f12860f08784f4a789c9bb9664db917ccba630d (patch)
treeabe7c68fd6e397f74c35d00a7ab777ac1cde2421
parent96efd189ccab412b0f42bf4564c72359ef358a1c (diff)
wip... encoding and stuff
-rw-r--r--include/osmo-bts/paging.h4
-rw-r--r--src/common/etws_p1.c5
-rw-r--r--src/common/paging.c15
-rw-r--r--src/common/vty.c37
4 files changed, 51 insertions, 10 deletions
diff --git a/include/osmo-bts/paging.h b/include/osmo-bts/paging.h
index c3ac8074..d657fafc 100644
--- a/include/osmo-bts/paging.h
+++ b/include/osmo-bts/paging.h
@@ -49,8 +49,8 @@ int paging_group_queue_empty(struct paging_state *ps, uint8_t group);
int paging_queue_length(struct paging_state *ps);
int paging_buffer_space(struct paging_state *ps);
-extern uint8_t etws_segment_data[4][17];
-extern uint8_t etws_segment_len[4];
+extern uint8_t etws_segment_data[5][17];
+extern uint8_t etws_segment_len[5];
extern uint8_t etws_nr_seg;
extern uint8_t etws_data[60];
extern size_t etws_len;
diff --git a/src/common/etws_p1.c b/src/common/etws_p1.c
index 47642e4d..e1877f87 100644
--- a/src/common/etws_p1.c
+++ b/src/common/etws_p1.c
@@ -100,7 +100,10 @@ int construct_etws_prim_notif(struct bitvec *bv, uint8_t pni,
/* expand packed payload bits to unpacked bits and set them in
* the bit vector */
osmo_pbit2ubit(payload_ubits, payload, num_payload_bits);
- bitvec_set_bits(bv, (enum bit_value *) payload_ubits, num_payload_bits);
+ int i;
+ for (i = 0; i < num_payload_bits; ++i)
+ bitvec_set_bit(bv, payload_ubits[i]);
+// bitvec_set_bits(bv, (enum bit_value *) payload_ubits, num_payload_bits);
return 0;
}
diff --git a/src/common/paging.c b/src/common/paging.c
index ce60cdf3..69ab101b 100644
--- a/src/common/paging.c
+++ b/src/common/paging.c
@@ -46,6 +46,9 @@
#define MAX_PAGING_BLOCKS_CCCH 9
#define MAX_BS_PA_MFRMS 9
+static const uint8_t empty_id_lv[] = { 0x01, 0xF0 };
+
+
enum paging_record_type {
PAGING_RECORD_PAGING,
PAGING_RECORD_IMM_ASS
@@ -263,8 +266,8 @@ int paging_add_imm_ass(struct paging_state *ps, const uint8_t *data,
#define L2_PLEN(len) (((len - 1) << 2) | 0x01)
static int current_segment[MAX_PAGING_BLOCKS_CCCH*MAX_BS_PA_MFRMS];
-uint8_t etws_segment_data[4][17];
-uint8_t etws_segment_len[4];
+uint8_t etws_segment_data[5][17];
+uint8_t etws_segment_len[5];
uint8_t etws_nr_seg;
uint8_t etws_data[60];
size_t etws_len;
@@ -286,12 +289,14 @@ static int fill_paging_type_1(int group, uint8_t *out_buf, const uint8_t *identi
cur = lv_put(pt1->data, identity1_lv[0], identity1_lv+1);
if (identity2_lv)
cur = lv_put(cur, identity2_lv[0], identity2_lv+1);
-
- if (etws_nr_seg > 0) {
+ else if (identity1_lv == empty_id_lv && etws_nr_seg > 0) {
int cur_segment = current_segment[group];
current_segment[group] += 1;
current_segment[group] %= etws_nr_seg;
+ LOGP(DPAG, LOGL_NOTICE, "paging group(%d) segment(%d)\n",
+ group, cur_segment);
+
/* move the pointer */
memcpy(cur, etws_segment_data[cur_segment], etws_segment_len[cur_segment]);
cur += etws_segment_len[cur_segment];
@@ -354,8 +359,6 @@ static int fill_paging_type_3(uint8_t *out_buf, const uint8_t *tmsi1_lv,
return cur - out_buf;
}
-static const uint8_t empty_id_lv[] = { 0x01, 0xF0 };
-
static struct paging_record *dequeue_pr(struct llist_head *group_q)
{
struct paging_record *pr;
diff --git a/src/common/vty.c b/src/common/vty.c
index 4db3930d..958fa2cf 100644
--- a/src/common/vty.c
+++ b/src/common/vty.c
@@ -615,20 +615,55 @@ DEFUN(bts_t_t_l_jitter_buf,
return CMD_SUCCESS;
}
+extern int construct_p1_rest_octets(struct bitvec *bv, int etws_will_follow);
+extern int construct_etws_prim_notif(struct bitvec *bv, uint8_t pni,
+ uint8_t seg_nr, uint8_t num_segs,
+ const uint8_t *payload,
+ uint8_t num_payload_bits);
+
DEFUN(bts_etsw_idle, bts_etsw_idle_cmd,
"etsw-message MESSAGE",
"ETSW Message\nMessage in Hex\n")
{
int rc;
+ int segment = 0, rest = 56;
rc = osmo_hexparse(argv[0], etws_data, sizeof(etws_data));
+ if (rc != 56) {
+ vty_out(vty, "%%we expect 56 bytes of the data.%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
vty_out(vty, "%% parsed: %s%s",
osmo_hexdump(etws_data, rc), VTY_NEWLINE);
etws_len = rc;
- /* factor and segment.. */
+ for (segment = 0; segment < 5; ++segment) {
+ struct bitvec bv = { 0, };
+ bv.data_len = 14;
+ bv.data = &etws_segment_data[segment][0];
+
+ LOGP(DPAG, LOGL_NOTICE, "Goint to create segment(%d) offset %d len %d\n",
+ segment, segment * 12,
+ rest >= 12 ? 12 : rest);
+ construct_p1_rest_octets(&bv, 1);
+ printf("CUR BIT: %d %s\n", bv.cur_bit,
+ osmo_hexdump(&etws_data[segment * 12],
+ rest >= 12 ? 12 : rest));
+ construct_etws_prim_notif(&bv, 1, segment, 5,
+ &etws_data[segment * 12],
+ rest >= 12 ? 12 * 8 : rest * 8);
+ etws_segment_len[segment] = (bv.cur_bit + 7) / 8;
+ rest -= 12;
+
+ LOGP(DPAG, LOGL_NOTICE,
+ "Created segment(%d) with len %d %s\n",
+ segment, etws_segment_len[segment],
+ osmo_hexdump(etws_segment_data[segment], etws_segment_len[segment]));
+ }
+ etws_nr_seg = 5;
return CMD_SUCCESS;
}