pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmo-cbc/+/28696 )
Change subject: Split cbc_message related code to its own .c and .h file
......................................................................
Split cbc_message related code to its own .c and .h file
Change-Id: I41f6e169b1ee6731cd472f6b72ea922260e30ceb
---
M include/osmocom/cbc/Makefile.am
M include/osmocom/cbc/cbc_data.h
A include/osmocom/cbc/cbc_message.h
M include/osmocom/cbc/internal.h
M include/osmocom/cbc/rest_it_op.h
M src/Makefile.am
R src/cbc_message.c
M src/cbc_peer.c
M src/cbc_vty.c
M src/cbsp_server_fsm.c
M src/sbcap_msg.c
M src/sbcap_server_fsm.c
M src/smscb_peer_fsm.c
13 files changed, 120 insertions(+), 112 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
fixeria: Looks good to me, but someone else must approve
diff --git a/include/osmocom/cbc/Makefile.am b/include/osmocom/cbc/Makefile.am
index f8b4241..6c5ad63 100644
--- a/include/osmocom/cbc/Makefile.am
+++ b/include/osmocom/cbc/Makefile.am
@@ -1,6 +1,7 @@
noinst_HEADERS = \
cbc_data.h \
cbc_peer.h \
+ cbc_message.h \
cbc_vty.h \
cbsp_server.h \
charset.h \
diff --git a/include/osmocom/cbc/cbc_data.h b/include/osmocom/cbc/cbc_data.h
index 09b0ebf..1b58ba5 100644
--- a/include/osmocom/cbc/cbc_data.h
+++ b/include/osmocom/cbc/cbc_data.h
@@ -1,7 +1,6 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
-#include <time.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/it_q.h>
#include <osmocom/gsm/protocol/gsm_48_049.h>
@@ -42,97 +41,6 @@
} num_compl;
};
-
-/*********************************************************************************
- * CBC Message
- *********************************************************************************/
-
-/* a single SMSCB page of 82 user bytes (excluding any GSM specific header) */
-#define SMSCB_RAW_PAGE_LEN 82
-#define SMSCB_MAX_NUM_PAGES 15
-
-/* representation of a plain SMSCB message without any metadata such as cell lists */
-struct smscb_message {
- uint16_t message_id;
- uint16_t serial_nr;
-
- bool is_etws;
- union {
- struct {
- /* data coding scheme */
- uint8_t dcs;
- /* number of pages containing valid information */
- unsigned int num_pages;
- /* actual page data, concatenated */
- uint8_t data[SMSCB_MAX_NUM_PAGES][SMSCB_RAW_PAGE_LEN];
- /* total number of octets user data over _all_ the pages */
- uint16_t data_user_len;
- } cbs;
- struct {
- /* WarningTypeValue 7bit parameter as per 23.041 9.3.24 */
- uint16_t warning_type;
- /* Emergency User Alert */
- bool user_alert;
- /* Popup on Display */
- bool popup_on_display;
- uint8_t warning_sec_info[50];
- } etws;
- };
-};
-
-enum cbc_message_scope {
- CBC_MSG_SCOPE_PLMN,
- /* FIXME: more local/regional scopes than PLMN-wide */
-};
-
-/* link between a SMSCB message and a peer (BSC, RNC, MME) */
-struct cbc_message_peer {
- struct llist_head list; /* lined to cbc_message.peers */
-
- /* 'cbcmsg' is not really needed, as the fsm instance parent points to
- * the fsm instance of cbc_message, so we could also dereference those */
- struct cbc_message *cbcmsg; /* the SMSCB this relates to */
- struct cbc_peer *peer; /* the peer thos relates to */
- struct osmo_fsm_inst *fi; /* the FSM instance representing our state */
-
- /* cells in which this message has been established/installed */
- struct llist_head cell_list;
- /* cells in which this message has NOT been established/installed */
- struct llist_head fail_list;
- /* number of broadcasts completed in cells of this peer */
- struct llist_head num_compl_list;
-};
-
-/* internal representation of a CBC message */
-struct cbc_message {
- struct llist_head list; /* global list of currently active CBCs */
-
- const char *cbe_name; /* name of the CBE originating this SMSCB */
- enum cbsp_category priority;
- uint16_t rep_period; /* repetition period (1..4095) in units of 1.883s */
- bool extended_cbch; /* basic (false) or extended (true) CBCH */
- uint32_t warning_period_sec; /* warning period in seconds (0xffffffff = unlimited) */
- uint16_t num_bcast; /* number of broadcasts requested (0=unlimited) */
-
- enum cbc_message_scope scope;
- /* FIXME: data for other scopes than PLMN-wide */
-
- /* SMSCB message with id, serial, dcs, pages, ... */
- struct smscb_message msg;
-
- struct osmo_fsm_inst *fi; /* FSM instance (smscb_message_fsm) */
-
- /* CBC peers (BSCs, RNCs, MMEs) to which this message has already been sent */
- struct llist_head peers;
-
- struct rest_it_op *it_op; /* inter-thread queue operation currently processing */
-
- struct {
- time_t created; /* when was this message created? */
- time_t expired; /* when has this message expired? */
- } time;
-};
-
/*********************************************************************************
* CBC itself
*********************************************************************************/
@@ -164,10 +72,3 @@
};
extern struct cbc *g_cbc;
-
-
-
-int cbc_message_del_peer(struct cbc_message *cbcmsg, struct cbc_peer *peer);
-int cbc_message_add_peer(struct cbc_message *cbcmsg, struct cbc_peer *peer);
-struct cbc_message_peer *smscb_peer_fsm_alloc(struct cbc_peer *peer, struct cbc_message
*cbcmsg);
-struct cbc_message_peer *cbc_message_peer_get(struct cbc_message *cbcmsg, struct cbc_peer
*peer);
diff --git a/include/osmocom/cbc/cbc_message.h b/include/osmocom/cbc/cbc_message.h
new file mode 100644
index 0000000..daf992d
--- /dev/null
+++ b/include/osmocom/cbc/cbc_message.h
@@ -0,0 +1,110 @@
+#pragma once
+#include <stdint.h>
+#include <stdbool.h>
+#include <time.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/it_q.h>
+#include <osmocom/gsm/protocol/gsm_48_049.h>
+#include <osmocom/gsm/gsm23003.h>
+
+
+/*********************************************************************************
+ * CBC Message
+ *********************************************************************************/
+
+/* a single SMSCB page of 82 user bytes (excluding any GSM specific header) */
+#define SMSCB_RAW_PAGE_LEN 82
+#define SMSCB_MAX_NUM_PAGES 15
+
+/* representation of a plain SMSCB message without any metadata such as cell lists */
+struct smscb_message {
+ uint16_t message_id;
+ uint16_t serial_nr;
+
+ bool is_etws;
+ union {
+ struct {
+ /* data coding scheme */
+ uint8_t dcs;
+ /* number of pages containing valid information */
+ unsigned int num_pages;
+ /* actual page data, concatenated */
+ uint8_t data[SMSCB_MAX_NUM_PAGES][SMSCB_RAW_PAGE_LEN];
+ /* total number of octets user data over _all_ the pages */
+ uint16_t data_user_len;
+ } cbs;
+ struct {
+ /* WarningTypeValue 7bit parameter as per 23.041 9.3.24 */
+ uint16_t warning_type;
+ /* Emergency User Alert */
+ bool user_alert;
+ /* Popup on Display */
+ bool popup_on_display;
+ uint8_t warning_sec_info[50];
+ } etws;
+ };
+};
+
+enum cbc_message_scope {
+ CBC_MSG_SCOPE_PLMN,
+ /* FIXME: more local/regional scopes than PLMN-wide */
+};
+
+/* link between a SMSCB message and a peer (BSC, RNC, MME) */
+struct cbc_message_peer {
+ struct llist_head list; /* lined to cbc_message.peers */
+
+ /* 'cbcmsg' is not really needed, as the fsm instance parent points to
+ * the fsm instance of cbc_message, so we could also dereference those */
+ struct cbc_message *cbcmsg; /* the SMSCB this relates to */
+ struct cbc_peer *peer; /* the peer thos relates to */
+ struct osmo_fsm_inst *fi; /* the FSM instance representing our state */
+
+ /* cells in which this message has been established/installed */
+ struct llist_head cell_list;
+ /* cells in which this message has NOT been established/installed */
+ struct llist_head fail_list;
+ /* number of broadcasts completed in cells of this peer */
+ struct llist_head num_compl_list;
+};
+
+/* internal representation of a CBC message */
+struct cbc_message {
+ struct llist_head list; /* global list of currently active CBCs */
+
+ const char *cbe_name; /* name of the CBE originating this SMSCB */
+ enum cbsp_category priority;
+ uint16_t rep_period; /* repetition period (1..4095) in units of 1.883s */
+ bool extended_cbch; /* basic (false) or extended (true) CBCH */
+ uint32_t warning_period_sec; /* warning period in seconds (0xffffffff = unlimited) */
+ uint16_t num_bcast; /* number of broadcasts requested (0=unlimited) */
+
+ enum cbc_message_scope scope;
+ /* FIXME: data for other scopes than PLMN-wide */
+
+ /* SMSCB message with id, serial, dcs, pages, ... */
+ struct smscb_message msg;
+
+ struct osmo_fsm_inst *fi; /* FSM instance (smscb_message_fsm) */
+
+ /* CBC peers (BSCs, RNCs, MMEs) to which this message has already been sent */
+ struct llist_head peers;
+
+ struct rest_it_op *it_op; /* inter-thread queue operation currently processing */
+
+ struct {
+ time_t created; /* when was this message created? */
+ time_t expired; /* when has this message expired? */
+ } time;
+};
+
+struct cbc_message *cbc_message_alloc(void *ctx, const struct cbc_message *cbcmsg);
+int cbc_message_new(const struct cbc_message *cbcmsg, struct rest_it_op *op);
+void cbc_message_delete(struct cbc_message *cbcmsg, struct rest_it_op *op);
+struct cbc_message *cbc_message_by_id(uint16_t message_id);
+int peer_new_cbc_message(struct cbc_peer *peer, struct cbc_message *cbcmsg);
+
+int cbc_message_del_peer(struct cbc_message *cbcmsg, struct cbc_peer *peer);
+int cbc_message_add_peer(struct cbc_message *cbcmsg, struct cbc_peer *peer);
+struct cbc_message_peer *smscb_peer_fsm_alloc(struct cbc_peer *peer, struct cbc_message
*cbcmsg);
+struct cbc_message_peer *cbc_message_peer_get(struct cbc_message *cbcmsg, struct cbc_peer
*peer);
diff --git a/include/osmocom/cbc/internal.h b/include/osmocom/cbc/internal.h
index 475442f..eff2c24 100644
--- a/include/osmocom/cbc/internal.h
+++ b/include/osmocom/cbc/internal.h
@@ -41,13 +41,6 @@
int rest_api_init(void *ctx, const char *bind_addr, uint16_t port);
void rest_api_fin(void);
-/* message_handling.c */
-struct cbc_message *cbc_message_alloc(void *ctx, const struct cbc_message *cbcmsg);
-int cbc_message_new(const struct cbc_message *cbcmsg, struct rest_it_op *op);
-void cbc_message_delete(struct cbc_message *cbcmsg, struct rest_it_op *op);
-struct cbc_message *cbc_message_by_id(uint16_t message_id);
-int peer_new_cbc_message(struct cbc_peer *peer, struct cbc_message *cbcmsg);
-
/* smscb_*fsm.c */
enum smscb_fsm_event {
diff --git a/include/osmocom/cbc/rest_it_op.h b/include/osmocom/cbc/rest_it_op.h
index c868b7c..fbfc189 100644
--- a/include/osmocom/cbc/rest_it_op.h
+++ b/include/osmocom/cbc/rest_it_op.h
@@ -7,7 +7,7 @@
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/it_q.h>
-#include <osmocom/cbc/cbc_data.h>
+#include <osmocom/cbc/cbc_message.h>
enum rest_it_operation {
REST_IT_OP_NONE,
diff --git a/src/Makefile.am b/src/Makefile.am
index f7c9516..e3458e5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,7 +11,7 @@
osmo_cbc_SOURCES = \
cbc_main.c \
- cbc_data.c \
+ cbc_message.c \
cbc_peer.c \
cbc_vty.c \
cbsp_server.c \
diff --git a/src/cbc_data.c b/src/cbc_message.c
similarity index 95%
rename from src/cbc_data.c
rename to src/cbc_message.c
index 4226cfc..c88e907 100644
--- a/src/cbc_data.c
+++ b/src/cbc_message.c
@@ -28,8 +28,7 @@
#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
-#include <osmocom/cbc/cbc_data.h>
-#include <osmocom/cbc/cbsp_server.h>
+#include <osmocom/cbc/cbc_message.h>
/* remove a peer from the message */
int cbc_message_del_peer(struct cbc_message *cbcmsg, struct cbc_peer *peer)
diff --git a/src/cbc_peer.c b/src/cbc_peer.c
index 9147a4e..a9aa12d 100644
--- a/src/cbc_peer.c
+++ b/src/cbc_peer.c
@@ -28,6 +28,7 @@
#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
+#include <osmocom/cbc/cbc_message.h>
#include <osmocom/cbc/cbc_peer.h>
#include <osmocom/cbc/cbsp_server.h>
#include <osmocom/cbc/sbcap_server.h>
diff --git a/src/cbc_vty.c b/src/cbc_vty.c
index bf15116..74e59ac 100644
--- a/src/cbc_vty.c
+++ b/src/cbc_vty.c
@@ -31,6 +31,7 @@
#include <osmocom/vty/vty.h>
#include <osmocom/cbc/cbc_data.h>
+#include <osmocom/cbc/cbc_message.h>
#include <osmocom/cbc/cbc_peer.h>
#include <osmocom/cbc/cbc_vty.h>
#include <osmocom/cbc/internal.h>
diff --git a/src/cbsp_server_fsm.c b/src/cbsp_server_fsm.c
index 8062364..cdbca82 100644
--- a/src/cbsp_server_fsm.c
+++ b/src/cbsp_server_fsm.c
@@ -22,6 +22,7 @@
#include <osmocom/gsm/cbsp.h>
+#include <osmocom/cbc/cbc_message.h>
#include <osmocom/cbc/cbc_peer.h>
#include <osmocom/cbc/cbsp_server.h>
#include <osmocom/cbc/internal.h>
diff --git a/src/sbcap_msg.c b/src/sbcap_msg.c
index 6cb3a35..bffe375 100644
--- a/src/sbcap_msg.c
+++ b/src/sbcap_msg.c
@@ -31,7 +31,7 @@
#include <osmocom/sbcap/sbcap_common.h>
-#include <osmocom/cbc/cbc_data.h>
+#include <osmocom/cbc/cbc_message.h>
#include <osmocom/cbc/sbcap_server.h>
#include <osmocom/cbc/internal.h>
diff --git a/src/sbcap_server_fsm.c b/src/sbcap_server_fsm.c
index 43c5ddb..616933e 100644
--- a/src/sbcap_server_fsm.c
+++ b/src/sbcap_server_fsm.c
@@ -25,6 +25,7 @@
#include <osmocom/sbcap/sbcap_common.h>
+#include <osmocom/cbc/cbc_message.h>
#include <osmocom/cbc/sbcap_server.h>
#include <osmocom/cbc/internal.h>
#include <osmocom/cbc/cbc_peer.h>
diff --git a/src/smscb_peer_fsm.c b/src/smscb_peer_fsm.c
index 9c840fa..ec61fc2 100644
--- a/src/smscb_peer_fsm.c
+++ b/src/smscb_peer_fsm.c
@@ -34,7 +34,7 @@
#include <osmocom/sbcap/sbcap_common.h>
-#include <osmocom/cbc/cbc_data.h>
+#include <osmocom/cbc/cbc_message.h>
#include <osmocom/cbc/cbc_peer.h>
#include <osmocom/cbc/cbsp_server.h>
#include <osmocom/cbc/sbcap_server.h>
--
To view, visit
https://gerrit.osmocom.org/c/osmo-cbc/+/28696
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-cbc
Gerrit-Branch: master
Gerrit-Change-Id: I41f6e169b1ee6731cd472f6b72ea922260e30ceb
Gerrit-Change-Number: 28696
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged